Merge branch 'master' into origin/PathAddEstlcamPP

This commit is contained in:
Harald Hartmann
2023-01-14 13:57:30 +01:00
committed by GitHub
3 changed files with 27 additions and 21 deletions

View File

@@ -392,9 +392,9 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="dimButton">
<widget class="QPushButton" name="annotButton">
<property name="text">
<string>Texts/dims</string>
<string>Annotations</string>
</property>
</widget>
</item>

View File

@@ -73,7 +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.annotButton.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))
@@ -92,7 +92,7 @@ class Draft_SetStyle_TaskPanel:
self.form.LineSpacing.setValue(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("LineSpacing",1))
self.form.saveButton.clicked.connect(self.onSaveStyle)
self.form.applyButton.clicked.connect(self.onApplyStyle)
self.form.dimButton.clicked.connect(self.onApplyDim)
self.form.annotButton.clicked.connect(self.onApplyAnnot)
self.form.comboPresets.currentIndexChanged.connect(self.onLoadStyle)
self.loadDefaults()
@@ -214,8 +214,6 @@ class Draft_SetStyle_TaskPanel:
vobj.Transparency = self.form.Transparency.value()
if "FontName" in vobj.PropertiesList:
vobj.FontName = self.form.TextFont.currentFont().family()
if "TextSize" in vobj.PropertiesList:
vobj.TextSize = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value
if "FontSize" in vobj.PropertiesList:
vobj.FontSize = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value
if "TextColor" in vobj.PropertiesList:
@@ -233,30 +231,40 @@ class Draft_SetStyle_TaskPanel:
if "LineSpacing" in vobj.PropertiesList:
vobj.LineSpacing = self.form.LineSpacing.value()
def onApplyDim(self,index):
def onApplyAnnot(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:
dims = Draft.getObjectsOfType(objs, "LinearDimension")
dims += Draft.getObjectsOfType(objs, "Dimension")
dims += Draft.getObjectsOfType(objs, "AngularDimension")
texts = Draft.getObjectsOfType(objs, "Text")
texts += Draft.getObjectsOfType(objs, "DraftText")
labels = Draft.getObjectsOfType(objs, "Label")
for obj in dims + texts + labels:
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").getRgbF()
vobj.TextColor = self.form.TextColor.property("color").getRgbF()
for obj in dims:
vobj = obj.ViewObject
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()
vobj.TextSpacing = FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value
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").getRgbF()
vobj.LineSpacing = self.form.LineSpacing.value()
for obj in labels:
vobj = obj.ViewObject
vobj.ArrowType = ["Dot", "Circle", "Arrow", "Tick", "Tick-2"][self.form.ArrowStyle.currentIndex()]
vobj.ArrowSize = FreeCAD.Units.Quantity(self.form.ArrowSize.text()).Value
vobj.LineSpacing = self.form.LineSpacing.value()
def onLoadStyle(self,index):

View File

@@ -398,8 +398,6 @@ def format_object(target, origin=None):
if not origin or not hasattr(origin, 'ViewObject'):
if "FontSize" in obrep.PropertiesList:
obrep.FontSize = fs
if "TextSize" in obrep.PropertiesList:
obrep.TextSize = fs
if "TextColor" in obrep.PropertiesList:
obrep.TextColor = tcol
if "LineWidth" in obrep.PropertiesList:
@@ -407,9 +405,9 @@ def format_object(target, origin=None):
if "PointColor" in obrep.PropertiesList:
obrep.PointColor = lcol
if "LineColor" in obrep.PropertiesList:
if hasattr(obrep,"FontName") and (not hasattr(obrep,"TextColor")):
# dimensions and other objects with text but no specific
# TextColor property. TODO: Add TextColor property to dimensions
if hasattr(obrep,"FontName"):
# Do not use lcol for annotations.
# ToDo: add line color preference for annotations.
obrep.LineColor = tcol
else:
obrep.LineColor = lcol