Skip to content

Commit

Permalink
Merge pull request #142 from kbwbe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
kbwbe authored Dec 31, 2018
2 parents 0d0375b + 98064d8 commit 866b388
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions a2p_constraintDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def initUI(self):
self.mainLayout.addWidget(lbl4,self.lineNo,0)

self.offsetEdit = QtGui.QLineEdit(self)
self.offsetEdit.setText("{}".format(offs.Value))
self.offsetEdit.setText(FreeCAD.Units.Quantity(offs.Value, FreeCAD.Units.Length).UserString)
self.offsetEdit.setFixedHeight(32)
self.mainLayout.addWidget(self.offsetEdit,self.lineNo,1)

Expand Down Expand Up @@ -231,7 +231,7 @@ def setConstraintEditorData(self):
else:
self.constraintObject.directionConstraint = "none"
if hasattr(self.constraintObject,"offset"):
self.constraintObject.offset = float(self.offsetEdit.text())
self.constraintObject.offset = FreeCAD.Units.Quantity(self.offsetEdit.text()).Value
if hasattr(self.constraintObject,"angle"):
self.constraintObject.angle = float(self.angleEdit.text())
if hasattr(self.constraintObject,"lockRotation"):
Expand Down Expand Up @@ -268,24 +268,22 @@ def flipLockRotation(self):

def setOffsetZero(self):
self.winModified = True
self.offsetEdit.setText("0.0")
if a2plib.getAutoSolveState():
self.solve()
q = FreeCAD.Units.Quantity(self.offsetEdit.text())
q.Value = 0.0
self.offsetEdit.setText(q.UserString)

def flipOffsetSign(self):
self.winModified = True
try:
o = float(self.offsetEdit.text())
o = o * -1.0
if abs(o) > 1e-7:
self.offsetEdit.setText(str(o))
if a2plib.getAutoSolveState():
self.solve()
else:
self.offsetEdit.setText("0.0")
except:
self.offsetEdit.setText("0.0")

q = FreeCAD.Units.Quantity(self.offsetEdit.text())
q.Value = -q.Value
if abs(q.Value) > 1e-7:
self.offsetEdit.setText(q.UserString)
if a2plib.getAutoSolveState():
self.solve()
else:
q.Value = 0.0
self.offsetEdit.setText(q.UserString)

def flipDirection(self):
self.winModified = True
if self.directionCombo.currentIndex() == 0:
Expand Down

0 comments on commit 866b388

Please sign in to comment.