aboutsummaryrefslogtreecommitdiff
path: root/BoxerGui
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-05-25 23:31:20 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-05-25 23:31:20 +0200
commit739b0e37ee6ce461cdfa550f3a5d410470f18f6c (patch)
tree396441e8cc66b93a10c023be42d223beffe83b72 /BoxerGui
parent5c386786c57ffc09f53976c488db68adbc932b98 (diff)
downloadfreecad-boxer-739b0e37ee6ce461cdfa550f3a5d410470f18f6c.tar.gz
freecad-boxer-739b0e37ee6ce461cdfa550f3a5d410470f18f6c.tar.bz2
freecad-boxer-739b0e37ee6ce461cdfa550f3a5d410470f18f6c.tar.xz
freecad-boxer-739b0e37ee6ce461cdfa550f3a5d410470f18f6c.zip
o Working FreeCAD module for creating boxes useful for laser cutting.
Diffstat (limited to 'BoxerGui')
-rw-r--r--BoxerGui135
1 files changed, 135 insertions, 0 deletions
diff --git a/BoxerGui b/BoxerGui
new file mode 100644
index 0000000..f21283f
--- /dev/null
+++ b/BoxerGui
@@ -0,0 +1,135 @@
+class BoxerDocumentObserver:
+ def __init__(self):
+ bgui.dockWidget.generateButton.enabled = False
+
+# def slotCreatedDocument(self, doc):
+# print('slotCreatedDocument')
+
+ def slotDeletedDocument(self, doc):
+ print('slotDeletedDocument')
+ bgui.dockWidget.generateButton.enabled = False
+
+# def slotRelabelDocument(self, doc):
+# print('slotRelabelDocument')
+
+ def slotActivateDocument(self, doc):
+ print('slotActivateDocument')
+ bgui.dockWidget.generateButton.enabled = 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):
+ from PySide import QtGui, QtCore
+
+ self.dockWidget = dockWidget = QtGui.QDockWidget()
+ dockWidget.setWindowTitle("Box config")
+ dockWidget.ui = BoxerDockWidget.Ui_BoxerDockWidget()
+ dockWidget.generateClicked = self.generateButtonClick
+ dockWidget.ui.setupUi(dockWidget)
+
+ self.documentObserver = BoxerDocumentObserver()
+
+print('BoxerGui: ' + str(BoxerGui))
+
+class MakeBoxCommandClass():
+ def GetResources(self):
+ return {#'Pixmap' : os.path.join( iconPath , 'AddWall.svg') , # the name of a svg file available in the resources
+ 'MenuText': "Make Box" ,
+ 'ToolTip' : "Extends a wall from a side face of metal sheet"}
+
+ def Activated(self):
+ from Boxer import BoxCfg, makeBox
+ # TODO: put all objects in a group:
+ # group = doc.addObject("App::DocumentObjectGroup","Group")
+
+ cfg = BoxCfg().outerDimmensions(300, 100, 50)
+ # cfg.notches = 2
+ cfg.notchUnitWidth = 10
+ cfg.thickness = 10
+ cfg.prt()
+
+ doc = FreeCAD.ActiveDocument
+ makeBox(doc, cfg)
+
+ doc.recompute()
+ Gui.SendMsgToActiveView("ViewFit")
+
+ return
+
+ def IsActive(self):
+ return FreeCAD.ActiveDocument is not None
+
+class RemoveBoxCommandClass():
+ def GetResources(self):
+ return {
+ 'MenuText': "Remove Box",
+ 'ToolTip' : "Remove the box"}
+
+ def Activated(self):
+ doc = FreeCAD.ActiveDocument
+
+ def rm(name):
+ o = getattr(doc, name, None);
+ if hasattr(doc, name):
+ doc.removeObject(name)
+
+ rm("Top")
+ rm("Back")
+ rm("Left")
+ rm("Front")
+ rm("Right")
+ rm("Bottom")
+ return
+
+ def IsActive(self):
+ return FreeCAD.ActiveDocument is not None
+
+class ShowPanelCommandClass():
+ def GetResources(self):
+ return {
+ 'MenuText': "Show Panel"}
+
+ def generateButtonClick(e):
+ print("generateButtonClick!")
+
+ def Activated(self):
+ print('ShowPanelCommandClass.Activated')
+
+ #dockWidget = QtGui.QDockWidget()
+ #dockWidget.setWindowTitle("Boxer 3")
+ #dockWidget.resize(656, 300)
+ #dockWidget.setObjectName("BoxerDockWidget")
+ #verticalLayout = QtGui.QVBoxLayout(dockWidget)
+ #verticalLayout.setObjectName("verticalLayout")
+ #tabSizeLabel = QtGui.QLabel(dockWidget)
+ #tabSizeLabel.setObjectName("tabSizeLabel")
+ #tabSizeLabel.setText("Tab size")
+
+ dockWiget = bgui.dockWidget
+
+ window = FreeCADGui.getMainWindow()
+ window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dockWidget)
+
+# app = QtGui.qApp
+# window = app.activeWindow()
+# window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dockWidget)
+
+# d = QtGui.QWidget()
+# d.ui = BoxerDockWidget.Ui_BoxerDockWidget()
+# d.ui.setupUi(d)
+# d.show()
+
+ return
+
+ def IsActive(self):
+ return True
+
+bgui = None