aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Boxer.py3
-rw-r--r--BoxerDockWidget.py27
-rw-r--r--BoxerDockWidget.ui63
-rw-r--r--BoxerGui.py24
4 files changed, 105 insertions, 12 deletions
diff --git a/Boxer.py b/Boxer.py
index facb4e3..0319e43 100644
--- a/Boxer.py
+++ b/Boxer.py
@@ -363,11 +363,14 @@ def make(doc, cfg):
doc.recompute()
+ crossSections = None
if cfg.generateCrossSections:
crossSections = makeCrossSections(doc, cfg, extrudes)
crossSectionsGroup = doc.addObject("App::DocumentObjectGroup", "Cross Sections")
[crossSectionsGroup.addObject(cs) for cs in crossSections.values()]
+ return {'parts': parts, 'extrudes': extrudes, 'crossSections': crossSections};
+
def removeEverything(doc):
def rm(name):
if hasattr(doc, name):
diff --git a/BoxerDockWidget.py b/BoxerDockWidget.py
index 67dd59b..1d82898 100644
--- a/BoxerDockWidget.py
+++ b/BoxerDockWidget.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'BoxerDockWidget.ui'
#
-# Created: Wed May 25 23:23:01 2016
+# Created: Tue May 31 00:39:43 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, 213)
+ BoxerDockWidget.resize(499, 522)
self.dockWidgetContents = QtGui.QWidget()
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@@ -123,14 +123,34 @@ class Ui_BoxerDockWidget(object):
self.generateButton.setMaximumSize(QtCore.QSize(484, 16777215))
self.generateButton.setObjectName("generateButton")
self.verticalLayout.addWidget(self.generateButton)
+ self.line = QtGui.QFrame(self.dockWidgetContents)
+ self.line.setFrameShape(QtGui.QFrame.HLine)
+ 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)
+ spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.verticalLayout.addItem(spacerItem)
BoxerDockWidget.setWidget(self.dockWidgetContents)
self.retranslateUi(BoxerDockWidget)
QtCore.QObject.connect(self.generateButton, QtCore.SIGNAL("clicked()"), BoxerDockWidget.generateClicked)
+ QtCore.QObject.connect(self.fitViewButton, QtCore.SIGNAL("clicked()"), BoxerDockWidget.fitAllClicked)
QtCore.QMetaObject.connectSlotsByName(BoxerDockWidget)
+ BoxerDockWidget.setTabOrder(self.outerWidth, self.outerHeight)
+ BoxerDockWidget.setTabOrder(self.outerHeight, self.outerDepth)
+ BoxerDockWidget.setTabOrder(self.outerDepth, self.innerWidth)
BoxerDockWidget.setTabOrder(self.innerWidth, self.innerHeight)
BoxerDockWidget.setTabOrder(self.innerHeight, self.innerDepth)
- BoxerDockWidget.setTabOrder(self.innerDepth, self.generateButton)
+ BoxerDockWidget.setTabOrder(self.innerDepth, self.notchSize)
+ BoxerDockWidget.setTabOrder(self.notchSize, self.thickness)
+ BoxerDockWidget.setTabOrder(self.thickness, self.generateButton)
+ BoxerDockWidget.setTabOrder(self.generateButton, self.fitViewButton)
def retranslateUi(self, BoxerDockWidget):
BoxerDockWidget.setWindowTitle(QtGui.QApplication.translate("BoxerDockWidget", "DockWidget", None, QtGui.QApplication.UnicodeUTF8))
@@ -142,4 +162,5 @@ class Ui_BoxerDockWidget(object):
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.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 dcac6a1..061cf31 100644
--- a/BoxerDockWidget.ui
+++ b/BoxerDockWidget.ui
@@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>499</width>
- <height>213</height>
+ <height>522</height>
</rect>
</property>
<property name="windowTitle">
@@ -213,14 +213,50 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="fitViewButton">
+ <property name="text">
+ <string>Fit all</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</widget>
<tabstops>
+ <tabstop>outerWidth</tabstop>
+ <tabstop>outerHeight</tabstop>
+ <tabstop>outerDepth</tabstop>
<tabstop>innerWidth</tabstop>
<tabstop>innerHeight</tabstop>
<tabstop>innerDepth</tabstop>
+ <tabstop>notchSize</tabstop>
+ <tabstop>thickness</tabstop>
<tabstop>generateButton</tabstop>
+ <tabstop>fitViewButton</tabstop>
</tabstops>
<resources/>
<connections>
@@ -231,17 +267,34 @@
<slot>generateClicked()</slot>
<hints>
<hint type="sourcelabel">
- <x>199</x>
- <y>242</y>
+ <x>233</x>
+ <y>199</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>128</x>
+ <y>286</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fitViewButton</sender>
+ <signal>clicked()</signal>
+ <receiver>BoxerDockWidget</receiver>
+ <slot>fitAllClicked()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>255</x>
+ <y>244</y>
</hint>
<hint type="destinationlabel">
- <x>208</x>
- <y>110</y>
+ <x>122</x>
+ <y>350</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>generateClicked()</slot>
+ <slot>fitAllClicked()</slot>
</slots>
</ui>
diff --git a/BoxerGui.py b/BoxerGui.py
index c57a517..5cb8315 100644
--- a/BoxerGui.py
+++ b/BoxerGui.py
@@ -43,7 +43,8 @@ class BoxerGui(object):
self.dockWidget = dockWidget = QtGui.QDockWidget()
dockWidget.setWindowTitle("Box config")
dockWidget.ui = BoxerDockWidget.Ui_BoxerDockWidget()
- dockWidget.generateClicked = self.generateButtonClick
+ dockWidget.generateClicked = self.generateButtonClicked
+ dockWidget.fitAllClicked = self.fitAllButtonClicked
dockWidget.ui.setupUi(dockWidget)
dockWidget.ui.generateButton.setEnabled(doc is not None)
dockWidget.ui.outerWidth.setValue(self.cfg.outerWidth)
@@ -55,7 +56,7 @@ class BoxerGui(object):
self.documentObserver = BoxerDocumentObserver()
FreeCAD.addDocumentObserver(self.documentObserver)
- def generateButtonClick(self):
+ def generateButtonClicked(self):
ui = self.dockWidget.ui
self.cfg.outerDimmensions(
@@ -68,11 +69,26 @@ class BoxerGui(object):
self.cfg.prt()
doc = FreeCAD.ActiveDocument
Boxer.removeEverything(doc)
- Boxer.make(doc, self.cfg)
-
+ objects = Boxer.make(doc, self.cfg)
+
+ itemsToSelect = objects['parts']
+
+ extrudes = objects['extrudes']
+ if extrudes is not None:
+ itemsToSelect = extrudes
+
+ Gui.Selection.clearSelection()
+ [Gui.Selection.addSelection(e) for e in itemsToSelect.values()]
+ Gui.SendMsgToActiveView("ViewSelection")
+ Gui.Selection.clearSelection()
+
+
def removeBox(self):
doc = FreeCAD.ActiveDocument
Boxer.removeEverything(doc)
+ def fitAllButtonClicked(self):
+ Gui.SendMsgToActiveView("ViewFit")
+
gui = BoxerGui()
gui.setupGui()