From 2f3bb4050e54d20a607aec193951f370eee8c2ef Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 11 May 2021 16:24:06 +0200 Subject: [PATCH] Draft: Added 'apply to texts/dims' button to SetStyle dialog --- .../Draft/Resources/ui/TaskPanel_SetStyle.ui | 38 +++++++++++++------ src/Mod/Draft/draftguitools/gui_setstyle.py | 26 +++++++++++++ 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui b/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui index 02554a9815..92969dd245 100644 --- a/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui +++ b/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui @@ -6,8 +6,8 @@ 0 0 - 255 - 571 + 246 + 573 @@ -344,16 +344,30 @@ - - - Apply to selected objects - - - - - - - + + + + + Apply above style to selected object(s) + + + Selected + + + + + + + + + + + + Texts/dims + + + + diff --git a/src/Mod/Draft/draftguitools/gui_setstyle.py b/src/Mod/Draft/draftguitools/gui_setstyle.py index 9ab520c519..4f0048fcee 100644 --- a/src/Mod/Draft/draftguitools/gui_setstyle.py +++ b/src/Mod/Draft/draftguitools/gui_setstyle.py @@ -73,6 +73,7 @@ class Draft_SetStyle_TaskPanel: self.form = FreeCADGui.PySideUic.loadUi(":/ui/TaskPanel_SetStyle.ui") self.form.setWindowIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg"))) self.form.applyButton.setIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg"))) + self.form.dimButton.setIcon(QtGui.QIcon(":/icons/Draft_Text.svg")) self.form.LineColor.setProperty("color",self.getPrefColor("View","DefaultShapeLineColor",255)) self.form.LineWidth.setValue(FreeCAD.ParamGet(self.p+"View").GetInt("DefaultShapeLineWidth",2)) self.form.DrawStyle.setCurrentIndex(FreeCAD.ParamGet(self.p+"Mod/Draft").GetInt("DefaultDrawStyle",0)) @@ -89,6 +90,7 @@ class Draft_SetStyle_TaskPanel: self.form.saveButton.setIcon(QtGui.QIcon.fromTheme("gtk-save", QtGui.QIcon(":/icons/document-save.svg"))) self.form.saveButton.clicked.connect(self.onSaveStyle) self.form.applyButton.clicked.connect(self.onApplyStyle) + self.form.dimButton.clicked.connect(self.onApplyDim) self.form.comboPresets.currentIndexChanged.connect(self.onLoadStyle) self.loadDefaults() @@ -218,6 +220,30 @@ class Draft_SetStyle_TaskPanel: if "UnitOverride" in vobj.PropertiesList: vobj.UnitOverride = self.form.UnitOverride.text() + def onApplyDim(self,index): + + import Draft + objs = FreeCAD.ActiveDocument.Objects + dims = Draft.getObjectsOfType(objs,"LinearDimension") + dims += Draft.getObjectsOfType(objs,"Dimension") + dims += Draft.getObjectsOfType(objs,"AngularDimension") + for obj in dims: + vobj = obj.ViewObject + vobj.FontName = self.form.TextFont.currentFont().family() + vobj.FontSize = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value + vobj.LineColor = self.form.TextColor.property("color").rgb()<<8 + vobj.ArrowType = ["Dot", "Circle", "Arrow", "Tick", "Tick-2"][self.form.ArrowStyle.currentIndex()] + vobj.ArrowSize = FreeCAD.Units.Quantity(self.form.ArrowSize.text()).Value + vobj.ShowUnit = self.form.ShowUnit.isChecked() + vobj.UnitOverride = self.form.UnitOverride.text() + texts = Draft.getObjectsOfType(objs,"Text") + texts += Draft.getObjectsOfType(objs,"DraftText") + for obj in texts: + vobj = obj.ViewObject + vobj.FontName = self.form.TextFont.currentFont().family() + vobj.FontSize = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value + vobj.TextColor = self.form.TextColor.property("color").rgb()<<8 + def onLoadStyle(self,index): if index > 0: