aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-06-10 06:01:19 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-06-11 20:47:09 +0200
commit05347f2f8df2437c9a915858bc89035901feda5d (patch)
tree1cd95af02a6a1d7198bd0771238357dbe5d3fc71
parentdd3f7b40b4b53bca37b41697bb424b145b9fcf96 (diff)
downloadfreecad-boxer-05347f2f8df2437c9a915858bc89035901feda5d.tar.gz
freecad-boxer-05347f2f8df2437c9a915858bc89035901feda5d.tar.bz2
freecad-boxer-05347f2f8df2437c9a915858bc89035901feda5d.tar.xz
freecad-boxer-05347f2f8df2437c9a915858bc89035901feda5d.zip
o Basic support for disabling sides.
-rw-r--r--Boxer.py142
-rw-r--r--BoxerDockWidget.py88
-rw-r--r--BoxerDockWidget.ui91
-rw-r--r--BoxerGui.py33
4 files changed, 228 insertions, 126 deletions
diff --git a/Boxer.py b/Boxer.py
index a15b03a..be2ee80 100644
--- a/Boxer.py
+++ b/Boxer.py
@@ -69,20 +69,23 @@ class SideConfig(Enum):
raise Exception("Unknown direction: " + repr(direction))
-class BoxSide(Enum):
- front = ('Front', MeasurementDirection.width, MeasurementDirection.height, SideConfig.large, (0, -1, 0))
- back = ('Back', MeasurementDirection.width, MeasurementDirection.height, SideConfig.large, (0, 1, 0))
- left = ('Left', MeasurementDirection.depth, MeasurementDirection.height, SideConfig.small, (-1, 0, 0))
- right = ('Right', MeasurementDirection.depth, MeasurementDirection.height, SideConfig.small, (1, 0, 0))
- top = ('Top', MeasurementDirection.width, MeasurementDirection.depth, SideConfig.medium, (0, 0, 1))
- bottom = ('Bottom', MeasurementDirection.width, MeasurementDirection.depth, SideConfig.medium, (0, 0, -1))
+class SideType(Enum):
+ front = 1
+ back = 2
+ left = 3
+ right = 4
+ top = 5
+ bottom = 6
+
+class BoxSide(object):
def __init__(self, title, directionX, directionY, sideConfig, extrudeVector):
self.title = title
self.directionX = directionX
self.directionY = directionY
self.sideConfig = sideConfig
self.extrudeVector = Vector(extrudeVector)
+ self.enabled = True
class NotchConfig(object):
@@ -101,6 +104,14 @@ class BoxCfg(object):
self.generateExtrudes = True
self.generateCrossSections = False # Not very useful so off by default
self.outerDimmensions(100, 100, 100)
+ self.sides = {
+ SideType.front: BoxSide('Front', MeasurementDirection.width, MeasurementDirection.height, SideConfig.large, (0, -1, 0)),
+ SideType.back: BoxSide('Back', MeasurementDirection.width, MeasurementDirection.height, SideConfig.large, (0, 1, 0)),
+ SideType.left: BoxSide('Left', MeasurementDirection.depth, MeasurementDirection.height, SideConfig.small, (-1, 0, 0)),
+ SideType.right: BoxSide('Right', MeasurementDirection.depth, MeasurementDirection.height, SideConfig.small, (1, 0, 0)),
+ SideType.top: BoxSide('Top', MeasurementDirection.width, MeasurementDirection.depth, SideConfig.medium, (0, 0, 1)),
+ SideType.bottom: BoxSide('Bottom', MeasurementDirection.width, MeasurementDirection.depth, SideConfig.medium, (0, 0, -1))
+ }
self.calculate()
@property
@@ -130,6 +141,9 @@ class BoxCfg(object):
def notchSize(self, notchSize):
self._notchSize = notchSize
+ def side(self, sideType):
+ return self.sides[sideType]
+
def outerDimmensions(self, width, height, depth):
self.outerWidth = width
self.outerHeight = height
@@ -165,6 +179,9 @@ class BoxCfg(object):
print("Thickness : " + str(self._thickness))
print("Outer w/h/d: " + str(self.outerWidth) + "/" + str(self.outerHeight) + "/" + str(self.outerDepth))
print("Inner w/h/d: " + str(self.innerWidth) + "/" + str(self.innerHeight) + "/" + str(self.innerDepth))
+ print("Sides:")
+ for (sideType, boxSide) in self.sides.items():
+ print(" {:<9}: enabled: {}".format(boxSide.title, boxSide.enabled))
print("Notch size : " + str(self._notchSize))
print(" Width: " + str(self.notchConfig(MeasurementDirection.width)))
print(" Height: " + str(self.notchConfig(MeasurementDirection.height)))
@@ -236,8 +253,8 @@ def makeBoxSide(cfg, boxSide):
return v
-def makeBox(doc, cfg):
- objects = {}
+def makeParts(doc, cfg):
+ parts = {}
sep = cfg.outerWidth * 0.05
@@ -258,51 +275,37 @@ def makeBox(doc, cfg):
m.move(v)
return m
- # front back left
- # right top bottom
-
- s = Part.makePolygon(makeBoxSide(cfg, BoxSide.front))
- s.transformShape(m(True, False, -0.5, -0.5, 0.5))
- front = doc.addObject("Part::Feature", "Front")
- front.Shape = s
-
- s = Part.makePolygon(makeBoxSide(cfg, BoxSide.back))
- s.transformShape(m(True, False, -0.5, 0.5, 0.5))
- back = doc.addObject("Part::Feature", "Back")
- back.Shape = s
-
- l = Part.makePolygon(makeBoxSide(cfg, BoxSide.left))
- l.transformShape(m(True, True, -0.5, -0.5, 0.5))
- left = doc.addObject("Part::Feature", "Left")
- left.Shape = l
-
- l = Part.makePolygon(makeBoxSide(cfg, BoxSide.right))
- l.transformShape(m(True, True, 0.5, -0.5, 0.5))
- right = doc.addObject("Part::Feature", "Right")
- right.Shape = l
-
- l = Part.makePolygon(makeBoxSide(cfg, BoxSide.top))
- l.transformShape(m(False, False, -0.5, 0.5, 0.5))
- top = doc.addObject("Part::Feature", "Top")
- top.Shape = l
-
- l = Part.makePolygon(makeBoxSide(cfg, BoxSide.bottom))
- l.transformShape(m(False, False, -0.5, 0.5, -0.5))
- bottom = doc.addObject("Part::Feature", "Bottom")
- bottom.Shape = l
-
- #front.ViewObject.Visibility = False
- #back.ViewObject.Visibility = False
- #left.ViewObject.Visibility = False
- #right.ViewObject.Visibility = False
- #top.ViewObject.Visibility = False
- #bottom.ViewObject.Visibility = False
-
- return {'front': front, 'back': back, 'left': left, 'right': right, 'top': top, 'bottom': bottom}
-
-
-def makeExtrudes(doc, cfg):
- def makeExtrude(doc, cfg, side, part):
+ # yapf: disable
+ ms = {
+ SideType.front: m(True, False, -0.5, -0.5, 0.5),
+ SideType.back: m(True, False, -0.5, 0.5, 0.5),
+ SideType.left: m(True, True, -0.5, -0.5, 0.5),
+ SideType.right: m(True, True, 0.5, -0.5, 0.5),
+ SideType.top: m(False, False, -0.5, 0.5, 0.5),
+ SideType.bottom: m(False, False, -0.5, 0.5, -0.5)
+ }
+ # yapf: enable
+
+ for sideType in SideType:
+ boxSide = cfg.side(sideType)
+
+ if not boxSide.enabled:
+ continue
+
+ s = Part.makePolygon(makeBoxSide(cfg, boxSide))
+ s.transformShape(ms[sideType])
+ feature = doc.addObject("Part::Feature", boxSide.title + '_Part')
+ feature.Label = boxSide.title + ' Part'
+ feature.Shape = s
+ parts[sideType] = feature
+
+ return parts
+
+
+def makeExtrudes(doc, parts, cfg):
+ def makeExtrude(doc, cfg, sideType):
+ side = cfg.side(sideType)
+ part = parts[sideType]
extrude = doc.addObject("Part::Extrusion", side.title + "_Extrude")
extrude.Base = part
extrude.Dir = side.extrudeVector * cfg.thickness
@@ -321,22 +324,11 @@ def makeExtrudes(doc, cfg):
return extrude
- objects = {}
- objects['front'] = makeExtrude(doc, cfg, BoxSide.front, doc.Front)
- objects['back'] = makeExtrude(doc, cfg, BoxSide.back, doc.Back)
- objects['left'] = makeExtrude(doc, cfg, BoxSide.left, doc.Left)
- objects['right'] = makeExtrude(doc, cfg, BoxSide.right, doc.Right)
- objects['top'] = makeExtrude(doc, cfg, BoxSide.top, doc.Top)
- objects['bottom'] = makeExtrude(doc, cfg, BoxSide.bottom, doc.Bottom)
-
- #objects['front'].ViewObject.Visibility = False
- #objects['back'].ViewObject.Visibility = False
- #objects['left'].ViewObject.Visibility = False
- #objects['right'].ViewObject.Visibility = False
- #objects['top'].ViewObject.Visibility = False
- #objects['bottom'].ViewObject.Visibility = False
+ extrudes = {}
+ for sideType, part in parts.items():
+ extrudes[sideType] = makeExtrude(doc, cfg, sideType)
- return objects
+ return extrudes
def makeCrossSections(doc, cfg, extrudes):
@@ -354,18 +346,18 @@ def makeCrossSections(doc, cfg, extrudes):
cs.purgeTouched()
return cs
- objects = {}
+ crossSections = {}
for key, extrude in extrudes.items():
- objects[key] = makeCrossSection(extrude, key.title())
- return objects
+ crossSections[key] = makeCrossSection(extrude, key.title())
+ return crossSections
def make(doc, cfg):
# Cretate the underlying parts
- parts = makeBox(doc, cfg)
+ parts = makeParts(doc, cfg)
if cfg.generateExtrudes:
- extrudes = makeExtrudes(doc, cfg)
+ extrudes = makeExtrudes(doc, parts, cfg)
box = doc.addObject("App::DocumentObjectGroup", "Box")
for e in extrudes.values():
@@ -393,4 +385,4 @@ def removeEverything(doc):
for key in ['Front', 'Back', 'Left', 'Right', 'Top', 'Bottom']:
rm(key + '_Cross_Section')
rm(key + '_Extrude')
- rm(key)
+ rm(key + '_Part')
diff --git a/BoxerDockWidget.py b/BoxerDockWidget.py
index 1d82898..cbaa482 100644
--- a/BoxerDockWidget.py
+++ b/BoxerDockWidget.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'BoxerDockWidget.ui'
#
-# Created: Tue May 31 00:39:43 2016
+# Created: Thu Jun 9 22:48:14 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!
@@ -12,7 +12,7 @@ from PySide import QtCore, QtGui
class Ui_BoxerDockWidget(object):
def setupUi(self, BoxerDockWidget):
BoxerDockWidget.setObjectName("BoxerDockWidget")
- BoxerDockWidget.resize(499, 522)
+ BoxerDockWidget.resize(499, 737)
self.dockWidgetContents = QtGui.QWidget()
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@@ -23,8 +23,8 @@ class Ui_BoxerDockWidget(object):
self.verticalLayout = QtGui.QVBoxLayout(self.dockWidgetContents)
self.verticalLayout.setSizeConstraint(QtGui.QLayout.SetMaximumSize)
self.verticalLayout.setObjectName("verticalLayout")
- self.gridLayout_2 = QtGui.QGridLayout()
- self.gridLayout_2.setObjectName("gridLayout_2")
+ self.dimLayout = QtGui.QGridLayout()
+ self.dimLayout.setObjectName("dimLayout")
self.notchSizeLabel = QtGui.QLabel(self.dockWidgetContents)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@@ -33,7 +33,7 @@ class Ui_BoxerDockWidget(object):
self.notchSizeLabel.setSizePolicy(sizePolicy)
self.notchSizeLabel.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.notchSizeLabel.setObjectName("notchSizeLabel")
- self.gridLayout_2.addWidget(self.notchSizeLabel, 3, 0, 1, 1)
+ self.dimLayout.addWidget(self.notchSizeLabel, 3, 0, 1, 1)
self.widthLabel = QtGui.QLabel(self.dockWidgetContents)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
@@ -41,18 +41,18 @@ class Ui_BoxerDockWidget(object):
sizePolicy.setHeightForWidth(self.widthLabel.sizePolicy().hasHeightForWidth())
self.widthLabel.setSizePolicy(sizePolicy)
self.widthLabel.setObjectName("widthLabel")
- self.gridLayout_2.addWidget(self.widthLabel, 0, 1, 1, 1)
+ self.dimLayout.addWidget(self.widthLabel, 0, 1, 1, 1)
self.heightLabel = QtGui.QLabel(self.dockWidgetContents)
self.heightLabel.setObjectName("heightLabel")
- self.gridLayout_2.addWidget(self.heightLabel, 0, 2, 1, 1)
+ self.dimLayout.addWidget(self.heightLabel, 0, 2, 1, 1)
self.innerLabel = QtGui.QLabel(self.dockWidgetContents)
self.innerLabel.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.innerLabel.setObjectName("innerLabel")
- self.gridLayout_2.addWidget(self.innerLabel, 2, 0, 1, 1)
+ self.dimLayout.addWidget(self.innerLabel, 2, 0, 1, 1)
self.outerLabel = QtGui.QLabel(self.dockWidgetContents)
self.outerLabel.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.outerLabel.setObjectName("outerLabel")
- self.gridLayout_2.addWidget(self.outerLabel, 1, 0, 1, 1)
+ self.dimLayout.addWidget(self.outerLabel, 1, 0, 1, 1)
self.innerHeight = QtGui.QLineEdit(self.dockWidgetContents)
self.innerHeight.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
@@ -61,7 +61,7 @@ class Ui_BoxerDockWidget(object):
sizePolicy.setHeightForWidth(self.innerHeight.sizePolicy().hasHeightForWidth())
self.innerHeight.setSizePolicy(sizePolicy)
self.innerHeight.setObjectName("innerHeight")
- self.gridLayout_2.addWidget(self.innerHeight, 2, 2, 1, 1)
+ self.dimLayout.addWidget(self.innerHeight, 2, 2, 1, 1)
self.innerDepth = QtGui.QLineEdit(self.dockWidgetContents)
self.innerDepth.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
@@ -70,39 +70,39 @@ class Ui_BoxerDockWidget(object):
sizePolicy.setHeightForWidth(self.innerDepth.sizePolicy().hasHeightForWidth())
self.innerDepth.setSizePolicy(sizePolicy)
self.innerDepth.setObjectName("innerDepth")
- self.gridLayout_2.addWidget(self.innerDepth, 2, 3, 1, 1)
+ self.dimLayout.addWidget(self.innerDepth, 2, 3, 1, 1)
self.depthLabel = QtGui.QLabel(self.dockWidgetContents)
self.depthLabel.setObjectName("depthLabel")
- self.gridLayout_2.addWidget(self.depthLabel, 0, 3, 1, 1)
+ self.dimLayout.addWidget(self.depthLabel, 0, 3, 1, 1)
self.label = QtGui.QLabel(self.dockWidgetContents)
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label.setObjectName("label")
- self.gridLayout_2.addWidget(self.label, 3, 2, 1, 1)
+ self.dimLayout.addWidget(self.label, 3, 2, 1, 1)
self.outerWidth = QtGui.QSpinBox(self.dockWidgetContents)
self.outerWidth.setMinimum(1)
self.outerWidth.setMaximum(99999)
self.outerWidth.setObjectName("outerWidth")
- self.gridLayout_2.addWidget(self.outerWidth, 1, 1, 1, 1)
+ self.dimLayout.addWidget(self.outerWidth, 1, 1, 1, 1)
self.outerHeight = QtGui.QSpinBox(self.dockWidgetContents)
self.outerHeight.setMinimum(1)
self.outerHeight.setMaximum(99999)
self.outerHeight.setObjectName("outerHeight")
- self.gridLayout_2.addWidget(self.outerHeight, 1, 2, 1, 1)
+ self.dimLayout.addWidget(self.outerHeight, 1, 2, 1, 1)
self.outerDepth = QtGui.QSpinBox(self.dockWidgetContents)
self.outerDepth.setMinimum(1)
self.outerDepth.setMaximum(99999)
self.outerDepth.setObjectName("outerDepth")
- self.gridLayout_2.addWidget(self.outerDepth, 1, 3, 1, 1)
+ self.dimLayout.addWidget(self.outerDepth, 1, 3, 1, 1)
self.notchSize = QtGui.QSpinBox(self.dockWidgetContents)
self.notchSize.setMinimum(1)
self.notchSize.setMaximum(99999)
self.notchSize.setObjectName("notchSize")
- self.gridLayout_2.addWidget(self.notchSize, 3, 1, 1, 1)
+ self.dimLayout.addWidget(self.notchSize, 3, 1, 1, 1)
self.thickness = QtGui.QSpinBox(self.dockWidgetContents)
self.thickness.setMinimum(1)
self.thickness.setMaximum(99999)
self.thickness.setObjectName("thickness")
- self.gridLayout_2.addWidget(self.thickness, 3, 3, 1, 1)
+ self.dimLayout.addWidget(self.thickness, 3, 3, 1, 1)
self.innerWidth = QtGui.QLineEdit(self.dockWidgetContents)
self.innerWidth.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
@@ -111,8 +111,38 @@ class Ui_BoxerDockWidget(object):
sizePolicy.setHeightForWidth(self.innerWidth.sizePolicy().hasHeightForWidth())
self.innerWidth.setSizePolicy(sizePolicy)
self.innerWidth.setObjectName("innerWidth")
- self.gridLayout_2.addWidget(self.innerWidth, 2, 1, 1, 1)
- self.verticalLayout.addLayout(self.gridLayout_2)
+ self.dimLayout.addWidget(self.innerWidth, 2, 1, 1, 1)
+ self.verticalLayout.addLayout(self.dimLayout)
+ self.line_2 = QtGui.QFrame(self.dockWidgetContents)
+ self.line_2.setFrameShape(QtGui.QFrame.HLine)
+ self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
+ self.line_2.setObjectName("line_2")
+ self.verticalLayout.addWidget(self.line_2)
+ self.groupBox = QtGui.QGroupBox(self.dockWidgetContents)
+ self.groupBox.setEnabled(True)
+ self.groupBox.setObjectName("groupBox")
+ self.verticalLayout_3 = QtGui.QVBoxLayout(self.groupBox)
+ self.verticalLayout_3.setObjectName("verticalLayout_3")
+ self.frontCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.frontCheckBox.setTristate(False)
+ self.frontCheckBox.setObjectName("frontCheckBox")
+ self.verticalLayout_3.addWidget(self.frontCheckBox)
+ self.backCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.backCheckBox.setObjectName("backCheckBox")
+ self.verticalLayout_3.addWidget(self.backCheckBox)
+ self.leftCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.leftCheckBox.setObjectName("leftCheckBox")
+ self.verticalLayout_3.addWidget(self.leftCheckBox)
+ self.rightCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.rightCheckBox.setObjectName("rightCheckBox")
+ self.verticalLayout_3.addWidget(self.rightCheckBox)
+ self.topCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.topCheckBox.setObjectName("topCheckBox")
+ self.verticalLayout_3.addWidget(self.topCheckBox)
+ self.bottomCheckBox = QtGui.QCheckBox(self.groupBox)
+ self.bottomCheckBox.setObjectName("bottomCheckBox")
+ self.verticalLayout_3.addWidget(self.bottomCheckBox)
+ self.verticalLayout.addWidget(self.groupBox)
self.generateButton = QtGui.QPushButton(self.dockWidgetContents)
self.generateButton.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Maximum)
@@ -128,9 +158,6 @@ class Ui_BoxerDockWidget(object):
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
self.verticalLayout.addWidget(self.line)
- self.horizontalLayout = QtGui.QHBoxLayout()
- self.horizontalLayout.setObjectName("horizontalLayout")
- self.verticalLayout.addLayout(self.horizontalLayout)
self.fitViewButton = QtGui.QPushButton(self.dockWidgetContents)
self.fitViewButton.setObjectName("fitViewButton")
self.verticalLayout.addWidget(self.fitViewButton)
@@ -149,7 +176,13 @@ class Ui_BoxerDockWidget(object):
BoxerDockWidget.setTabOrder(self.innerHeight, self.innerDepth)
BoxerDockWidget.setTabOrder(self.innerDepth, self.notchSize)
BoxerDockWidget.setTabOrder(self.notchSize, self.thickness)
- BoxerDockWidget.setTabOrder(self.thickness, self.generateButton)
+ BoxerDockWidget.setTabOrder(self.thickness, self.frontCheckBox)
+ BoxerDockWidget.setTabOrder(self.frontCheckBox, self.backCheckBox)
+ BoxerDockWidget.setTabOrder(self.backCheckBox, self.leftCheckBox)
+ BoxerDockWidget.setTabOrder(self.leftCheckBox, self.rightCheckBox)
+ BoxerDockWidget.setTabOrder(self.rightCheckBox, self.topCheckBox)
+ BoxerDockWidget.setTabOrder(self.topCheckBox, self.bottomCheckBox)
+ BoxerDockWidget.setTabOrder(self.bottomCheckBox, self.generateButton)
BoxerDockWidget.setTabOrder(self.generateButton, self.fitViewButton)
def retranslateUi(self, BoxerDockWidget):
@@ -161,6 +194,13 @@ class Ui_BoxerDockWidget(object):
self.outerLabel.setText(QtGui.QApplication.translate("BoxerDockWidget", "Outer", None, QtGui.QApplication.UnicodeUTF8))
self.depthLabel.setText(QtGui.QApplication.translate("BoxerDockWidget", "Depth", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("BoxerDockWidget", "Thickness", None, QtGui.QApplication.UnicodeUTF8))
+ self.groupBox.setTitle(QtGui.QApplication.translate("BoxerDockWidget", "Enabled sides", None, QtGui.QApplication.UnicodeUTF8))
+ self.frontCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Front", None, QtGui.QApplication.UnicodeUTF8))
+ self.backCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Back", None, QtGui.QApplication.UnicodeUTF8))
+ self.leftCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Left", None, QtGui.QApplication.UnicodeUTF8))
+ self.rightCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Right", None, QtGui.QApplication.UnicodeUTF8))
+ self.topCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Top", None, QtGui.QApplication.UnicodeUTF8))
+ self.bottomCheckBox.setText(QtGui.QApplication.translate("BoxerDockWidget", "Bottom", None, QtGui.QApplication.UnicodeUTF8))
self.generateButton.setText(QtGui.QApplication.translate("BoxerDockWidget", "Generate", None, QtGui.QApplication.UnicodeUTF8))
self.fitViewButton.setText(QtGui.QApplication.translate("BoxerDockWidget", "Fit all", None, QtGui.QApplication.UnicodeUTF8))
diff --git a/BoxerDockWidget.ui b/BoxerDockWidget.ui
index 061cf31..d604084 100644
--- a/BoxerDockWidget.ui
+++ b/BoxerDockWidget.ui
@@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>499</width>
- <height>522</height>
+ <height>737</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,7 +26,7 @@
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
- <layout class="QGridLayout" name="gridLayout_2">
+ <layout class="QGridLayout" name="dimLayout">
<item row="3" column="0">
<widget class="QLabel" name="notchSizeLabel">
<property name="sizePolicy">
@@ -192,6 +192,70 @@
</layout>
</item>
<item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>Enabled sides</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QCheckBox" name="frontCheckBox">
+ <property name="text">
+ <string>Front</string>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="backCheckBox">
+ <property name="text">
+ <string>Back</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="leftCheckBox">
+ <property name="text">
+ <string>Left</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rightCheckBox">
+ <property name="text">
+ <string>Right</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="topCheckBox">
+ <property name="text">
+ <string>Top</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="bottomCheckBox">
+ <property name="text">
+ <string>Bottom</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="generateButton">
<property name="enabled">
<bool>false</bool>
@@ -221,9 +285,6 @@
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout"/>
- </item>
- <item>
<widget class="QPushButton" name="fitViewButton">
<property name="text">
<string>Fit all</string>
@@ -255,6 +316,12 @@
<tabstop>innerDepth</tabstop>
<tabstop>notchSize</tabstop>
<tabstop>thickness</tabstop>
+ <tabstop>frontCheckBox</tabstop>
+ <tabstop>backCheckBox</tabstop>
+ <tabstop>leftCheckBox</tabstop>
+ <tabstop>rightCheckBox</tabstop>
+ <tabstop>topCheckBox</tabstop>
+ <tabstop>bottomCheckBox</tabstop>
<tabstop>generateButton</tabstop>
<tabstop>fitViewButton</tabstop>
</tabstops>
@@ -268,11 +335,11 @@
<hints>
<hint type="sourcelabel">
<x>233</x>
- <y>199</y>
+ <y>434</y>
</hint>
<hint type="destinationlabel">
- <x>128</x>
- <y>286</y>
+ <x>151</x>
+ <y>520</y>
</hint>
</hints>
</connection>
@@ -283,12 +350,12 @@
<slot>fitAllClicked()</slot>
<hints>
<hint type="sourcelabel">
- <x>255</x>
- <y>244</y>
+ <x>269</x>
+ <y>476</y>
</hint>
<hint type="destinationlabel">
- <x>122</x>
- <y>350</y>
+ <x>219</x>
+ <y>568</y>
</hint>
</hints>
</connection>
diff --git a/BoxerGui.py b/BoxerGui.py
index 2242e4a..1527ca4 100644
--- a/BoxerGui.py
+++ b/BoxerGui.py
@@ -2,35 +2,21 @@ import FreeCAD
from FreeCAD import Gui
from PySide import QtGui, QtCore
import Boxer, BoxerDockWidget
+from Boxer import SideType
class BoxerDocumentObserver:
def __init__(self):
pass
-# def slotCreatedDocument(self, doc):
-# print('slotCreatedDocument')
-
def slotDeletedDocument(self, doc):
print('slotDeletedDocument')
gui.dockWidget.ui.generateButton.setEnabled(False)
-# def slotRelabelDocument(self, doc):
-# print('slotRelabelDocument')
-
def slotActivateDocument(self, doc):
print('slotActivateDocument')
gui.dockWidget.ui.generateButton.setEnabled(True)
-# def slotCreatedObject(self, obj):
-# print('slotCreatedObject')
-
-# def slotDeletedObject(self, obj):
-# print('slotDeletedObject')
-
-# def slotChangedObject(self, obj, prop):
-# print('slotChangedObject')
-
class BoxerGui(object):
def __init__(self):
@@ -54,6 +40,20 @@ class BoxerGui(object):
dockWidget.ui.thickness.setValue(self.cfg.thickness)
dockWidget.ui.notchSize.setValue(self.cfg.notchUnitWidth)
+ self.sideCheckBoxes = [
+ # yapf: disable
+ (SideType.front, dockWidget.ui.frontCheckBox),
+ (SideType.back, dockWidget.ui.backCheckBox),
+ (SideType.left, dockWidget.ui.leftCheckBox),
+ (SideType.right, dockWidget.ui.rightCheckBox),
+ (SideType.top, dockWidget.ui.topCheckBox),
+ (SideType.bottom, dockWidget.ui.bottomCheckBox)
+ # yapf: enable
+ ]
+
+ for (sideType, checkBox) in self.sideCheckBoxes:
+ checkBox.setChecked(self.cfg.side(sideType).enabled)
+
self.documentObserver = BoxerDocumentObserver()
FreeCAD.addDocumentObserver(self.documentObserver)
@@ -64,6 +64,9 @@ class BoxerGui(object):
self.cfg.thickness = self.dockWidget.ui.thickness.value()
self.cfg.notchSize = self.dockWidget.ui.notchSize.value()
+ for (sideType, checkBox) in self.sideCheckBoxes:
+ self.cfg.side(sideType).enabled = checkBox.isChecked()
+
self.cfg.prt()
doc = FreeCAD.ActiveDocument
Boxer.removeEverything(doc)