Added editing functionality to the tool editor
This commit is contained in:
@@ -56,18 +56,23 @@ ParameterTypeConstraint = {
|
||||
def updateConstraint(sketch, name, value):
|
||||
for i, constraint in enumerate(sketch.Constraints):
|
||||
if constraint.Name.split(';')[0] == name:
|
||||
constr = None
|
||||
if constraint.Type in ['DistanceX', 'DistanceY', 'Distance', 'Radius']:
|
||||
constr = Sketcher.Constraint(constraint.Type, constraint.First, value)
|
||||
elif constraint.Type in ['Angle']:
|
||||
constr = Sketcher.Constraint(constraint.Type, constraint.First, constraint.FirstPos, constraint.Second, constraint.SecondPos, value)
|
||||
else:
|
||||
print(constraint.Name, constraint.Type)
|
||||
|
||||
if constr is not None:
|
||||
if not PathGeom.isRoughly(constraint.Value, value.Value):
|
||||
PathLog.track(name, constraint.Type, 'update', i)
|
||||
constr = Sketcher.Constraint(constraint.Type, constraint.First, value)
|
||||
PathLog.track(name, constraint.Type, 'update', i, "(%.2f -> %.2f)" % (constraint.Value, value.Value))
|
||||
sketch.delConstraint(i)
|
||||
sketch.recompute()
|
||||
n = sketch.addConstraint(constr)
|
||||
sketch.renameConstraint(n, constraint.Name)
|
||||
else:
|
||||
PathLog.track(name, constraint.Type, 'unchanged')
|
||||
else:
|
||||
print(constraint.Name, constraint.Type)
|
||||
break
|
||||
|
||||
PropertyGroupBit = 'Bit'
|
||||
@@ -183,7 +188,7 @@ class ToolBit(object):
|
||||
value = constraint.Value
|
||||
if constraint.Type == 'Angle':
|
||||
value = value * 180 / math.pi
|
||||
PathUtil.setProperty(obj, prop, constraint.Value)
|
||||
PathUtil.setProperty(obj, prop, value)
|
||||
|
||||
def getBitThumbnail(self, obj):
|
||||
if obj.BitTemplate:
|
||||
|
||||
@@ -37,19 +37,7 @@ from PySide import QtGui
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
|
||||
|
||||
ParameterTypeConstraint = {
|
||||
'Angle': 'Angle',
|
||||
'Distance': 'Length',
|
||||
'DistanceX': 'Length',
|
||||
'DistanceY': 'Length',
|
||||
'Radius': 'Length'
|
||||
}
|
||||
|
||||
ParameterTypeProperty = {
|
||||
'Length': 'App::PropertyLength',
|
||||
'Angle': 'App::PropertyAngle'
|
||||
}
|
||||
LastPath = 'src/Mod/Path/Tools/Template'
|
||||
|
||||
class ToolBitEditor:
|
||||
'''UI and controller for editing a ToolBit.
|
||||
@@ -83,6 +71,11 @@ class ToolBitEditor:
|
||||
# qsb.setToolTip(parameter['Desc'])
|
||||
layout.addRow(label, qsb)
|
||||
self.bitEditor = editor
|
||||
img = tool.Proxy.getBitThumbnail(tool)
|
||||
if img:
|
||||
self.form.image.setPixmap(QtGui.QPixmap(QtGui.QImage.fromData(img)))
|
||||
else:
|
||||
self.form.image.setPixmap(QtGui.QPixmap())
|
||||
|
||||
def accept(self):
|
||||
self.refresh()
|
||||
@@ -101,6 +94,10 @@ class ToolBitEditor:
|
||||
def updateTemplate(self):
|
||||
self.tool.BitTemplate = str(self.form.templatePath.text())
|
||||
self.setupTool(self.tool)
|
||||
self.form.toolName.setText(self.tool.Label)
|
||||
|
||||
for editor in self.bitEditor:
|
||||
self.bitEditor[editor].updateSpinBox()
|
||||
|
||||
def updateTool(self):
|
||||
PathLog.track()
|
||||
@@ -119,9 +116,23 @@ class ToolBitEditor:
|
||||
self.updateUI()
|
||||
self.form.blockSignals(False)
|
||||
|
||||
def selectTemplate(self):
|
||||
global LastPath
|
||||
path = self.tool.BitTemplate
|
||||
if not path:
|
||||
path = LastPath
|
||||
foo = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(),
|
||||
"Path - Tool Template",
|
||||
path,
|
||||
"*.fcstd")[0]
|
||||
if foo:
|
||||
self.form.templatePath.setText(foo)
|
||||
self.updateTemplate()
|
||||
|
||||
def setupUI(self):
|
||||
PathLog.track()
|
||||
self.updateUI()
|
||||
|
||||
self.form.toolName.editingFinished.connect(self.refresh)
|
||||
self.form.templatePath.editingFinished.connect(self.updateTemplate)
|
||||
self.form.templateSet.clicked.connect(self.selectTemplate)
|
||||
|
||||
@@ -83,15 +83,16 @@ class ViewProvider(object):
|
||||
def setEdit(self, vobj, mode=0):
|
||||
# pylint: disable=unused-argument
|
||||
PathLog.track()
|
||||
taskPanel = TaskPanel(vobj)
|
||||
self.taskPanel = TaskPanel(vobj)
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCADGui.Control.showDialog(taskPanel)
|
||||
taskPanel.setupUi()
|
||||
FreeCADGui.Control.showDialog(self.taskPanel)
|
||||
self.taskPanel.setupUi()
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
# pylint: disable=unused-argument
|
||||
FreeCADGui.Control.closeDialog()
|
||||
self.taskPanel = None
|
||||
return
|
||||
|
||||
def claimChildren(self):
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user