~mrp/freecad.log_cabin

652f43b2f06ded20fe227d2c2e2bcddcb3a2addd — Mark Penner 1 year, 5 months ago 4d245aa main
add fields to task panel for creating log walls
2 files changed, 86 insertions(+), 6 deletions(-)

M freecad/log_cabin/gui_commands.py
M freecad/log_cabin/resources/ui/log_wall_dialog.ui
M freecad/log_cabin/gui_commands.py => freecad/log_cabin/gui_commands.py +16 -2
@@ 86,19 86,28 @@ class LogWallPanel:
        self.form = Gui.PySideUic.loadUi(os.path.join(UIPATH, "log_wall_dialog.ui"))
        self.form.wall_height.setProperty("value", Units.Quantity("9ft"))
        self.form.logs_tall.setProperty("value", 10)
        self.form.avg_log_size.setProperty("value", Units.Quantity("12in"))
        self.form.radius_cut_start.setProperty("value", Units.Quantity("0ft"))
        self.form.radius_cut_end.setProperty("value", Units.Quantity("0ft"))

    def accept(self):
        from .api import make_log_wall

        height = Units.Quantity(self.form.wall_height.text())
        logs_tall = self.form.logs_tall.value()
        avg_log_size = Units.Quantity(self.form.avg_log_size.text())
        radius_cut_start = Units.Quantity(self.form.radius_cut_start.text())
        radius_cut_end = Units.Quantity(self.form.radius_cut_end.text())
        start_with_half_log = self.form.half_log.isChecked()

        walls = []
        sel = Gui.Selection.getSelection()
        if sel:
            for obj in sel:
                if getattr(obj, "Shape", False):
                    make_log_wall(obj, height, logs_tall, start_with_half_log)
                    walls.append(
                        make_log_wall(obj, height, logs_tall, start_with_half_log)
                    )
                    start_with_half_log = not start_with_half_log
        else:
            from Draft import make_line


@@ 106,7 115,12 @@ class LogWallPanel:
            p1 = App.Vector(0, 0, 0)
            p2 = App.Vector(3000, 0, 0)
            line = make_line(p1, p2)
            make_log_wall(line, height, logs_tall, start_with_half_log)
            walls.append(make_log_wall(line, height, logs_tall, start_with_half_log))

        for wall in walls:
            wall.AvgLogSize = avg_log_size
            wall.RadiusCutStart = radius_cut_start
            wall.RadiusCutEnd = radius_cut_end

        App.activeDocument().recompute()
        Gui.Control.closeDialog()

M freecad/log_cabin/resources/ui/log_wall_dialog.ui => freecad/log_cabin/resources/ui/log_wall_dialog.ui +70 -4
@@ 6,14 6,14 @@
   <rect>
    <x>0</x>
    <y>0</y>
    <width>309</width>
    <height>108</height>
    <width>308</width>
    <height>201</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Dialog</string>
  </property>
  <layout class="QFormLayout" name="formLayout_2">
  <layout class="QFormLayout" name="formLayout">
   <item row="0" column="0">
    <widget class="QLabel" name="label">
     <property name="text">


@@ 29,6 29,9 @@
       <verstretch>0</verstretch>
      </sizepolicy>
     </property>
     <property name="toolTip">
      <string>The height of the wall</string>
     </property>
     <property name="unit" stdset="0">
      <string notr="true"/>
     </property>


@@ 49,17 52,80 @@
       <verstretch>0</verstretch>
      </sizepolicy>
     </property>
     <property name="toolTip">
      <string>The number of logs to use to reach the height of the wall</string>
     </property>
    </widget>
   </item>
   <item row="2" column="0">
    <widget class="QLabel" name="label_2">
     <property name="toolTip">
      <string/>
     </property>
     <property name="text">
      <string>AvgLogSize</string>
     </property>
    </widget>
   </item>
   <item row="2" column="1">
    <widget class="Gui::QuantitySpinBox" name="avg_log_size">
     <property name="toolTip">
      <string>Average log thickness. Will be recalculated from NumLogs if NumLogs &gt; 0</string>
     </property>
     <property name="unit" stdset="0">
      <string notr="true"/>
     </property>
    </widget>
   </item>
   <item row="3" column="0">
    <widget class="QLabel" name="label_5">
     <property name="toolTip">
      <string/>
     </property>
     <property name="text">
      <string>RadiusCutStart</string>
     </property>
    </widget>
   </item>
   <item row="3" column="1">
    <widget class="Gui::QuantitySpinBox" name="radius_cut_start">
     <property name="toolTip">
      <string>The height of the radius to cut on the start of the wall</string>
     </property>
     <property name="unit" stdset="0">
      <string notr="true"/>
     </property>
    </widget>
   </item>
   <item row="4" column="0">
    <widget class="QLabel" name="label_6">
     <property name="text">
      <string>RadiusCutEnd</string>
     </property>
    </widget>
   </item>
   <item row="4" column="1">
    <widget class="Gui::QuantitySpinBox" name="radius_cut_end">
     <property name="toolTip">
      <string>The height of the radius to cut on the end of the wall</string>
     </property>
     <property name="unit" stdset="0">
      <string notr="true"/>
     </property>
    </widget>
   </item>
   <item row="5" column="0">
    <widget class="QLabel" name="label_4">
     <property name="text">
      <string>Start with half log</string>
     </property>
    </widget>
   </item>
   <item row="2" column="1">
   <item row="5" column="1">
    <widget class="QCheckBox" name="half_log">
     <property name="toolTip">
      <string>If true, start with a half log at the bottom of the wall</string>
     </property>
     <property name="text">
      <string/>
     </property>