Draft: Added dim overshoot parameters to Style task dialog (#9514)

* Draft: Added dim overshoot parameters to Style task dialog - fixes issue #9507

* Draft: additional fixes to styles task dialog
This commit is contained in:
Yorik van Havre
2023-05-13 21:01:51 +02:00
committed by GitHub
parent 58335e7a93
commit 07d7f08fb3
2 changed files with 153 additions and 73 deletions

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>246</width>
<height>573</height>
<width>287</width>
<height>945</height>
</rect>
</property>
<property name="windowTitle">
@@ -44,8 +44,7 @@
</property>
<property name="icon">
<iconset theme="gtk-save">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
@@ -199,6 +198,23 @@
<string>Annotations</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,0" columnminimumwidth="0,120">
<item row="1" column="1">
<widget class="Gui::InputField" name="TextSize">
<property name="toolTip">
<string>The size of texts and dimension texts</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::ColorButton" name="TextColor">
<property name="toolTip">
<string>The color of texts and dimension texts</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -206,6 +222,27 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Text size</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Line spacing</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Text color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="TextFont">
<property name="sizePolicy">
@@ -219,31 +256,30 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Text size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="TextSize">
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="LineSpacing">
<property name="toolTip">
<string>The size of texts and dimension texts</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
<string>The spacing between different lines of text</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Dimensions</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0" columnminimumwidth="0,120">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Text spacing</string>
<string>Arrow style</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="8" column="1">
<widget class="Gui::InputField" name="TextSpacing">
<property name="toolTip">
<string>The space between the text and the dimension line</string>
@@ -253,42 +289,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Text color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::ColorButton" name="TextColor">
<property name="toolTip">
<string>The color of texts and dimension texts</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Line spacing</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="LineSpacing">
<property name="toolTip">
<string>The spacing between different lines of text</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Arrow style</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="0" column="1">
<widget class="QComboBox" name="ArrowStyle">
<property name="toolTip">
<string>The type of dimension arrows</string>
@@ -320,14 +321,14 @@
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<item row="6" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Arrow size</string>
<string>Ext lines</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="1" column="1">
<widget class="Gui::InputField" name="ArrowSize">
<property name="toolTip">
<string>The size of dimension arrows</string>
@@ -337,14 +338,7 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Show unit</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="ShowUnit">
<property name="toolTip">
<string>If the unit suffix is shown on dimension texts or not</string>
@@ -357,21 +351,86 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Text spacing</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::InputField" name="DimOvershoot">
<property name="toolTip">
<string>The distance the dimension line is extended past the extension lines</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Arrow size</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Dim overshoot</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::InputField" name="ExtOvershoot">
<property name="toolTip">
<string>Length of the extension lines beyond the dimension line</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::InputField" name="ExtLines">
<property name="toolTip">
<string>Length of the extension lines</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Show unit</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Ext overshoot</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Unit override</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLineEdit" name="UnitOverride">
<property name="toolTip">
<string>The unit to use for dimensions. Leave blank to use current FreeCAD unit</string>
</property>
</widget>
</item>
</layout>
</layout>
</widget>
</item>
<item>
@@ -386,13 +445,15 @@
</property>
<property name="icon">
<iconset theme="gtk-apply">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="annotButton">
<property name="toolTip">
<string>Apply above style to all annotations (texts and dimensions)</string>
</property>
<property name="text">
<string>Annotations</string>
</property>

View File

@@ -92,6 +92,9 @@ class Draft_SetStyle_TaskPanel:
self.form.saveButton.setIcon(QtGui.QIcon.fromTheme("gtk-save", QtGui.QIcon(":/icons/document-save.svg")))
self.form.TextSpacing.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("dimspacing",1),FreeCAD.Units.Length).UserString)
self.form.LineSpacing.setValue(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("LineSpacing",1))
self.form.DimOvershoot.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("dimovershoot",0),FreeCAD.Units.Length).UserString)
self.form.ExtLines.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("extlines",0),FreeCAD.Units.Length).UserString)
self.form.ExtOvershoot.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("extovershoot",0),FreeCAD.Units.Length).UserString)
self.form.saveButton.clicked.connect(self.onSaveStyle)
self.form.applyButton.clicked.connect(self.onApplyStyle)
self.form.annotButton.clicked.connect(self.onApplyAnnot)
@@ -139,6 +142,9 @@ class Draft_SetStyle_TaskPanel:
preset["UnitOverride"] = self.form.UnitOverride.text()
preset["TextSpacing"] = FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value
preset["LineSpacing"] = self.form.LineSpacing.value()
preset["DimOvershoot"] = FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value
preset["ExtLines"] = FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value
preset["ExtOvershoot"] = FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value
return preset
def setValues(self,preset):
@@ -159,6 +165,9 @@ class Draft_SetStyle_TaskPanel:
self.form.ArrowSize.setText(FreeCAD.Units.Quantity(preset.get("ArrowSize",5),FreeCAD.Units.Length).UserString)
self.form.TextSpacing.setText(FreeCAD.Units.Quantity(preset.get("TextSpacing",25),FreeCAD.Units.Length).UserString)
self.form.LineSpacing.setValue(preset.get("LineSpacing",3))
self.form.DimOvershoot.setText(FreeCAD.Units.Quantity(preset.get("DimOvershoot",0),FreeCAD.Units.Length).UserString)
self.form.ExtLines.setText(FreeCAD.Units.Quantity(preset.get("ExtLines",0),FreeCAD.Units.Length).UserString)
self.form.ExtOvershoot.setText(FreeCAD.Units.Quantity(preset.get("ExtOvershoot",0),FreeCAD.Units.Length).UserString)
def reject(self):
@@ -186,6 +195,9 @@ class Draft_SetStyle_TaskPanel:
param_draft.SetString("overrideUnit",self.form.UnitOverride.text())
param_draft.SetFloat("dimspacing",FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value)
param_draft.SetFloat("LineSpacing",self.form.LineSpacing.value())
param_draft.SetFloat("dimovershoot",FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value)
param_draft.SetFloat("extlines",FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value)
param_draft.SetFloat("extovershoot",FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value)
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.setStyleButton()
self.reject()
@@ -250,6 +262,12 @@ class Draft_SetStyle_TaskPanel:
vobj.TextSpacing = FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value
if "LineSpacing" in properties:
vobj.LineSpacing = self.form.LineSpacing.value()
if "DimOvershoot" in properties:
vobj.DimOvershoot = FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value
if "ExtLines" in properties:
vobj.ExtLines = FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value
if "ExtOvershoot" in properties:
vobj.ExtOvershoot = FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value
def onLoadStyle(self,index):
@@ -291,6 +309,7 @@ class Draft_SetStyle_TaskPanel:
import json
from json.decoder import JSONDecodeError
except Exception:
FreeCAD.Console.PrintError(translate("Draft","Error: json module not found. Unable to load style")+"\n")
return
if os.path.exists(PRESETPATH):
with open(PRESETPATH,"r") as f: