Skip to content

Commit

Permalink
Merge pull request #143 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored Jan 3, 2019
2 parents 866b388 + d5c75ea commit aacb54d
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 16 deletions.
18 changes: 17 additions & 1 deletion GuiA2p/Resources/ui/a2p_prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,26 @@
<x>30</x>
<y>40</y>
<width>521</width>
<height>71</height>
<height>95</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_4">
<property name="text">
<string>Show constraints on toolbar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>showConstraintsOnToolbar</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/A2plus</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_2">
<property name="text">
Expand Down
34 changes: 28 additions & 6 deletions InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def Initialize(self):
import a2p_MuxAssembly
import a2p_partinformation
import a2p_constraintDialog
import a2p_bom #bill of materials == partslist
import a2p_constraintcommands
import a2p_bom # bom == bill of materials == partslist

partCommands = [
'a2p_ImportPart',
Expand All @@ -65,11 +66,32 @@ def Initialize(self):
'a2p_ConvertPart',
'a2p_editImportedPart',
]
constraintCommands = [
'a2p_ConstraintDialogCommand',
'a2p_EditConstraintCommand',
'a2p_DeleteConnectionsCommand',
]

if a2plib.SHOW_CONSTRAINTS_ON_TOOLBAR:
constraintCommands = [
'a2p_ConstraintDialogCommand',
'a2p_EditConstraintCommand',
'a2p_PointIdentityConstraintCommand',
'a2p_PointOnLineConstraintCommand',
'a2p_PointOnPlaneConstraintCommand',
'a2p_SphericalSurfaceConstraintCommand',
'a2p_CircularEdgeConnection',
'a2p_AxialConstraintCommand',
'a2p_AxisParallelConstraintCommand',
'a2p_AxisPlaneParallelCommand',
'a2p_PlanesParallelConstraintCommand',
'a2p_PlaneCoincidentConstraintCommand',
'a2p_AngledPlanesConstraintCommand',

'a2p_DeleteConnectionsCommand',
]
else:
constraintCommands = [
'a2p_ConstraintDialogCommand',
'a2p_EditConstraintCommand',
'a2p_DeleteConnectionsCommand',
]

solverCommands = [
'a2p_SolverCommand',
#'a2p_newSolverCommand',
Expand Down
31 changes: 22 additions & 9 deletions a2p_constraintDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,14 @@ def manageConstraint(self):

@QtCore.Slot()
def onAcceptConstraint(self):
self.constraintValueBox.deleteLater()
#self.constraintValueBox.deleteLater()
a2plib.setConstraintEditorRef(None)
self.activeConstraint = None
FreeCADGui.Selection.clearSelection()

@QtCore.Slot()
def onDeleteConstraint(self):
self.constraintValueBox.deleteLater()
#self.constraintValueBox.deleteLater()
a2plib.setConstraintEditorRef(None)
self.activeConstraint = None
FreeCADGui.Selection.clearSelection()
Expand Down Expand Up @@ -722,11 +722,19 @@ def onSpericalConstraintButton(self):
self.manageConstraint()

#==============================================================================
def getMoveDistToScreenCenter(widg):
w = QtGui.QApplication.desktop().width()
h = QtGui.QApplication.desktop().height()
center = QtCore.QPoint(w/2,h/2)
return center- widg.rect().center()
def getMoveDistToFcCenter(widg):
mw = FreeCADGui.getMainWindow()
fcFrame = QtGui.QDesktopWidget.geometry(mw)
x = fcFrame.x()
y = fcFrame.y()
width = fcFrame.width()
height = fcFrame.height()

centerX = x + width/2
centerY = y + height/2
fcCenter = QtCore.QPoint(centerX,centerY)

return fcCenter- widg.rect().center()
#==============================================================================
class a2p_ConstraintValuePanel(QtGui.QDockWidget):

Expand All @@ -738,6 +746,7 @@ def __init__(self,constraintObject, mode):
self.constraintObject = constraintObject
self.resize(300,300)
#
print (constraintObject)
cvw = a2p_ConstraintValueWidget(
None,
constraintObject,
Expand All @@ -754,15 +763,19 @@ def __init__(self,constraintObject, mode):
self.setFloating(True)
self.activateWindow()
self.setAllowedAreas(QtCore.Qt.NoDockWidgetArea)
self.move(getMoveDistToScreenCenter(self))
self.move(getMoveDistToFcCenter(self))

a2plib.setConstraintEditorRef(self)

def onAcceptConstraint(self):
self.Accepted.emit()
a2plib.setConstraintEditorRef(None)
self.deleteLater()

def onDeleteConstraint(self):
self.Deleted.emit()
a2plib.setConstraintEditorRef(None)
self.deleteLater()

def closeEvent(self,event):
self.widget().cancelOperation()
Expand All @@ -783,7 +796,7 @@ def __init__(self):
self.setFloating(True)
self.activateWindow()
self.setAllowedAreas(QtCore.Qt.NoDockWidgetArea)
self.move(getMoveDistToScreenCenter(self))
self.move(getMoveDistToFcCenter(self))

a2plib.setConstraintDialogRef(self)
#
Expand Down
Loading

0 comments on commit aacb54d

Please sign in to comment.