Skip to content

Commit

Permalink
Draft: Fixed patterns + added default pattern size pref option
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Oct 12, 2020
1 parent e3c30e7 commit 5609b38
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
54 changes: 54 additions & 0 deletions src/Mod/Draft/Resources/ui/preferences-draftvisual.ui
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_2">
<property name="toolTip">
<string>The resolution to draw the patterns in. Default value is 128. Higher values give better resolutions, lower values make drawing faster</string>
</property>
<property name="maximum">
<number>512</number>
</property>
Expand All @@ -269,6 +272,52 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Hatch Pattern default size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefDoubleSpinBox" name="doubleSpinBox">
<property name="toolTip">
<string>The default size of hatch patterns</string>
</property>
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>0.000100000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>HatchPatternSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down Expand Up @@ -508,6 +557,11 @@
<extends>QLineEdit</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftutils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_param_type(param):
return "string"
elif param in ("textheight", "tolerance", "gridSpacing",
"arrowsize", "extlines", "dimspacing",
"dimovershoot", "extovershoot"):
"dimovershoot", "extovershoot","HatchPatternSize"):
return "float"
elif param in ("selectBaseObjects", "alwaysSnap", "grid",
"fillmode", "saveonexit", "maxSnap",
Expand Down
7 changes: 4 additions & 3 deletions src/Mod/Draft/draftviewproviders/view_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _set_properties(self, vobj):
"PatternSize",
"Draft",
QT_TRANSLATE_NOOP("App::Property", _tip))
vobj.PatternSize = 1
vobj.PatternSize = utils.get_param("HatchPatternSize", 1)

def __getstate__(self):
"""Return a tuple of all serializable objects or None.
Expand Down Expand Up @@ -286,8 +286,9 @@ def onChanged(self, vobj, prop):
if path and vobj.RootNode:
if vobj.RootNode.getChildren().getLength() > 2:
if vobj.RootNode.getChild(2).getChildren().getLength() > 0:
if vobj.RootNode.getChild(2).getChild(0).getChildren().getLength() > 2:
r = vobj.RootNode.getChild(2).getChild(0).getChild(2)
innodes = vobj.RootNode.getChild(2).getChild(0).getChildren().getLength()
if innodes > 2:
r = vobj.RootNode.getChild(2).getChild(0).getChild(innodes-1)
i = QtCore.QFileInfo(path)
if self.texture:
r.removeChild(self.texture)
Expand Down

0 comments on commit 5609b38

Please sign in to comment.