Skip to content

Commit

Permalink
Using InputField for width and height and use proper properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jan 11, 2017
1 parent 6792e2c commit f89eea7
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 38 deletions.
79 changes: 57 additions & 22 deletions src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>363</width>
<height>530</height>
<width>380</width>
<height>539</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -16,6 +16,12 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QToolBox" name="toolBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand All @@ -27,8 +33,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>476</height>
<width>362</width>
<height>485</height>
</rect>
</property>
<attribute name="label">
Expand All @@ -48,38 +54,50 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="dsbWidth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Specify the resulting width of tags at the base.&lt;/p&gt;&lt;p&gt;The initial default width is based on the longest edge found in the base path.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="dsbHeight">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Height of holding tags.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Angle </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::InputField" name="ifWidth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Width of the resulting holding tag.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="ifHeight">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Height of holding tag.&lt;/p&gt;&lt;p&gt;Note that resulting tag might be smaller if the tag's width and angle result in a triangular shape.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="dsbAngle">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Angle of ascend and descend of the tool for the holding tag cutout.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If the angle is too flat for the given width to reach the specified height the resulting tag will have a triangular shape and not as high as specified.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Plunge angle for ascent and descent of holding tag.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<double>5.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
<property name="singleStep">
<double>15.000000000000000</double>
</property>
<property name="value">
<double>45.000000000000000</double>
</property>
</widget>
</item>
Expand All @@ -89,14 +107,14 @@
<item>
<widget class="QListWidget" name="lwTags">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;List of current tags.&lt;/p&gt;&lt;p&gt;Edit coordinates to move tag or invoker snapper tool.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;List of current tags.&lt;/p&gt;&lt;p&gt;Edit coordinates by double click or Enter key.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QPushButton" name="pbDelete">
<property name="enabled">
<bool>false</bool>
Expand All @@ -106,13 +124,23 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="2">
<widget class="QPushButton" name="pbAdd">
<property name="text">
<string>Add...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -154,6 +182,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
30 changes: 14 additions & 16 deletions src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Expand Up @@ -577,9 +577,9 @@ class ObjectDressup:
def __init__(self, obj):
self.obj = obj
obj.addProperty("App::PropertyLink", "Base","Base", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "The base path to modify"))
obj.addProperty("App::PropertyFloat", "Width", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Width of tags."))
obj.addProperty("App::PropertyFloat", "Height", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Height of tags."))
obj.addProperty("App::PropertyFloat", "Angle", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Angle of tag plunge and ascent."))
obj.addProperty("App::PropertyLength", "Width", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Width of tags."))
obj.addProperty("App::PropertyLength", "Height", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Height of tags."))
obj.addProperty("App::PropertyAngle", "Angle", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Angle of tag plunge and ascent."))
obj.addProperty("App::PropertyVectorList", "Positions", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Locations of insterted holding tags"))
obj.addProperty("App::PropertyIntegerList", "Disabled", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Ids of disabled holding tags"))
obj.Proxy = self
Expand All @@ -592,7 +592,7 @@ def __setstate__(self, state):

def generateTags(self, obj, count):
if hasattr(self, "pathData"):
self.tags = self.pathData.generateTags(obj, count, obj.Width, obj.Height, obj.Angle, None)
self.tags = self.pathData.generateTags(obj, count, obj.Width.Value, obj.Height.Value, obj.Angle, None)
obj.Positions = [tag.originAt(0) for tag in self.tags]
obj.Disabled = []
return False
Expand Down Expand Up @@ -696,7 +696,7 @@ def doExecute(self,obj):
self.tags = []
if hasattr(obj, "Positions"):
for i, pos in enumerate(obj.Positions):
tag = Tag(pos.x, pos.y, obj.Width, obj.Height, obj.Angle, not i in obj.Disabled)
tag = Tag(pos.x, pos.y, obj.Width.Value, obj.Height.Value, obj.Angle, not i in obj.Disabled)
tag.createSolidsAt(pathData.minZ, self.toolRadius)
self.tags.append(tag)

Expand Down Expand Up @@ -829,8 +829,8 @@ def getTags(self, includeCurrent):
return tags

def getTagParameters(self):
self.obj.Width = self.formTags.dsbWidth.value()
self.obj.Height = self.formTags.dsbHeight.value()
self.obj.Width = FreeCAD.Units.Quantity(self.formTags.ifWidth.text()).Value
self.obj.Height = FreeCAD.Units.Quantity(self.formTags.ifHeight.text()).Value
self.obj.Angle = self.formTags.dsbAngle.value()

def getFields(self):
Expand Down Expand Up @@ -954,9 +954,9 @@ def removeGlobalCallbacks(self):
def getPoint(self, whenDone, start=None):

def displayPoint(p):
self.formPoint.ifValueX.setText(DraftGui.displayExternal(p.x))
self.formPoint.ifValueY.setText(DraftGui.displayExternal(p.y))
self.formPoint.ifValueZ.setText(DraftGui.displayExternal(p.z))
self.formPoint.ifValueX.setText(FreeCAD.Units.Quantity(p.x, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueY.setText(FreeCAD.Units.Quantity(p.y, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueZ.setText(FreeCAD.Units.Quantity(p.z, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueX.setFocus()
self.formPoint.ifValueX.selectAll()

Expand Down Expand Up @@ -1002,11 +1002,9 @@ def setupSpinBox(self, widget, val, decimals = 2):
def setFields(self):
self.updateTagsView()
self.setupSpinBox(self.formTags.sbCount, len(self.obj.Positions), None)
self.setupSpinBox(self.formTags.dsbHeight, self.obj.Height)
self.setupSpinBox(self.formTags.dsbWidth, self.obj.Width)
self.formTags.ifHeight.setText(FreeCAD.Units.Quantity(self.obj.Height, FreeCAD.Units.Length).UserString)
self.formTags.ifWidth.setText(FreeCAD.Units.Quantity(self.obj.Width, FreeCAD.Units.Length).UserString)
self.setupSpinBox(self.formTags.dsbAngle, self.obj.Angle, 0)
self.formTags.dsbAngle.setMaximum(90)
self.formTags.dsbAngle.setSingleStep(5.)

def updateModelHeight(self):
print('updateModelHeight')
Expand All @@ -1031,8 +1029,8 @@ def setupUi(self):
self.formTags.sbCount.valueChanged.connect(self.whenCountChanged)
self.formTags.pbGenerate.clicked.connect(self.generateNewTags)

self.formTags.dsbHeight.editingFinished.connect(self.updateModelHeight)
self.formTags.dsbWidth.editingFinished.connect(self.updateModelWidth)
self.formTags.ifHeight.editingFinished.connect(self.updateModelHeight)
self.formTags.ifWidth.editingFinished.connect(self.updateModelWidth)
self.formTags.dsbAngle.editingFinished.connect(self.updateModelAngle)
self.formTags.lwTags.itemChanged.connect(self.updateModelTags)
self.formTags.lwTags.itemSelectionChanged.connect(self.whenTagSelectionChanged)
Expand Down

0 comments on commit f89eea7

Please sign in to comment.