Skip to content

Commit

Permalink
Merge pull request #200 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored Feb 14, 2019
2 parents 2fe0885 + d2af113 commit 280cf57
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
2 changes: 1 addition & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.3.5'
A2P_VERSION = 'V0.3.6'

import sys
PyVersion = sys.version_info[0]
Expand Down
38 changes: 33 additions & 5 deletions a2p_constraintDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#==============================================================================
class a2p_ConstraintValueWidget(QtGui.QWidget):
#class a2p_ConstraintValueWidget(QtGui.QDialog):

Deleted = QtCore.Signal()
Accepted = QtCore.Signal()
Expand Down Expand Up @@ -106,6 +107,7 @@ def initUI(self):
self.directionCombo.setCurrentIndex(2)
#
self.directionCombo.setFixedHeight(32)
self.directionCombo.currentIndexChanged[int].connect(self.flipDirection2)
self.mainLayout.addWidget(self.directionCombo,self.lineNo,1)

self.flipDirectionButton = QtGui.QPushButton(self)
Expand Down Expand Up @@ -161,7 +163,7 @@ def initUI(self):
#==============================
if hasattr(self.constraintObject,"lockRotation"):
lbl6 = QtGui.QLabel(self)
lbl6.setText("lockRotation")
lbl6.setText("Lock Rotation")
lbl6.setFixedHeight(32)
self.mainLayout.addWidget(lbl6,self.lineNo,0)

Expand Down Expand Up @@ -206,6 +208,7 @@ def initUI(self):
self.acceptButton.setIcon(QtGui.QIcon(':/icons/a2p_CheckAssembly.svg')) #need new Icon
self.acceptButton.setToolTip("solve Constraints")
self.acceptButton.setText("Accept")
#self.acceptButton.setDefault(True)

self.buttonPanelLayout.addWidget(self.deleteButton)
self.buttonPanelLayout.addWidget(self.solveButton)
Expand Down Expand Up @@ -286,6 +289,11 @@ def flipOffsetSign(self):
q.Value = 0.0
self.offsetEdit.setText(q.UserString)

def flipDirection2(self,idx):
self.winModified = True
if a2plib.getAutoSolveState():
self.solve()

def flipDirection(self):
self.winModified = True
if self.directionCombo.currentIndex() == 0:
Expand Down Expand Up @@ -332,6 +340,12 @@ def delete(self):
a2plib.setConstraintEditorRef(None)
self.Deleted.emit()

def keyPressEvent(self,e):
if e.key() == QtCore.Qt.Key_Enter:
self.accept()
if e.key() == QtCore.Qt.Key_Return:
self.accept()

def accept(self):
doc = FreeCAD.activeDocument()
if self.constraintObject not in doc.Objects:
Expand Down Expand Up @@ -769,15 +783,15 @@ def __init__(self,constraintObject, mode):
self.resize(300,300)
#
print (constraintObject)
cvw = a2p_ConstraintValueWidget(
self.cvw = a2p_ConstraintValueWidget(
None,
constraintObject,
mode
)
self.setWidget(cvw)
self.setWidget(self.cvw)
self.setWindowTitle("Constraint Properties")
QtCore.QObject.connect(cvw, QtCore.SIGNAL("Accepted()"), self.onAcceptConstraint)
QtCore.QObject.connect(cvw, QtCore.SIGNAL("Deleted()"), self.onDeleteConstraint)
QtCore.QObject.connect(self.cvw, QtCore.SIGNAL("Accepted()"), self.onAcceptConstraint)
QtCore.QObject.connect(self.cvw, QtCore.SIGNAL("Deleted()"), self.onDeleteConstraint)

mw = FreeCADGui.getMainWindow()
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea,self)
Expand All @@ -793,6 +807,20 @@ def __init__(self,constraintObject, mode):
doc = FreeCAD.activeDocument()
if doc != None:
solveConstraints(doc)

self.timer = QtCore.QTimer()
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.onTimer)
self.timer.start(100)

self.cvw.activateWindow()


def onTimer(self):
# The dialog is not modal, so that still zooming/rotating is possible
# within the 3D view. As this widget then looses his input focus, it
# is activated by timer regularly.
#self.cvw.acceptButton.activateWindow() # pushe whole App to foreground, not so good.
self.cvw.acceptButton.setFocus()

def storeWindowCenterPosition(self):
# ConstraintDialog has Priority on storing its position
Expand Down
6 changes: 3 additions & 3 deletions a2p_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ def getToolTip():
moved to be coincident
select:
1.) linearEdge or cylinderFace from a part
2.) linearEdge or cylinderFace from another part
1.) linear edge or cylindrical face from a part
2.) linear edge or cylindrical face from another part
Button gets active after
correct selection.
Expand Down Expand Up @@ -420,7 +420,7 @@ def getToolTip():
'''
Creates an axisPlaneParallel constraint.
1) select a linearEdge or cylinderAxis
1) select a linear edge or cylinder axis
2) select a plane face on another part
This constraint adjusts an axis parallel
Expand Down
14 changes: 13 additions & 1 deletion a2p_importpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,22 @@ def Activated(self):
else:
flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No
msg = "Delete %s's constraint(s):\n - %s?" % ( part.Name, '\n - '.join( c.Name for c in deleteList))
response = QtGui.QMessageBox.critical(QtGui.QApplication.activeWindow(), "Delete constraints?", msg, flags )
response = QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(), "Delete constraints?", msg, flags )
if response == QtGui.QMessageBox.Yes:
for c in deleteList:
a2plib.removeConstraint(c)

def IsActive(self):
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
return False

obj = selection[0]
if a2plib.isA2pPart(obj):
return True
else:
return False

def GetResources(self):
return {
'Pixmap' : a2plib.pathOfModule()+'/icons/a2p_DeleteConnections.svg',
Expand Down

0 comments on commit 280cf57

Please sign in to comment.