Draft: move default annotation style properties to utils module

These style properties are used by `ViewProviderDraftAnnotation`
and by the Gui Command `Draft_AnnotationStyleEditor`.

Therefore, they are moved from `draftguitools.gui_annotationstyleeditor`
module to the `draftutils.utils` module, so that they
are in a central location where they won't cause circular
dependencies.
This commit is contained in:
vocx-fc
2020-06-16 10:25:19 -05:00
committed by Yorik van Havre
parent e1cfaf1298
commit 270e4b100a
2 changed files with 24 additions and 19 deletions

View File

@@ -28,28 +28,13 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import draftguitools.gui_base as gui_base
from FreeCAD import Units as U
from draftutils.translate import _tr
from draftutils.utils import ANNOTATION_STYLE as DEFAULT
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
DEFAULT = {
"FontName": ("font", param.GetString("textfont", "Sans")),
"FontSize": ("str", str(param.GetFloat("textheight", 100))),
"LineSpacing": ("float", 1),
"ScaleMultiplier": ("float", 1),
"ShowUnit": ("bool", False),
"UnitOverride": ("str", ""),
"Decimals": ("int", 2),
"ShowLines": ("bool", True),
"LineWidth": ("int", param.GetInt("linewidth", 1)),
"LineColor": ("color", param.GetInt("color", 255)),
"ArrowType": ("index", param.GetInt("dimsymbol", 0)),
"ArrowSize": ("str", str(param.GetFloat("arrowsize", 20))),
"DimensionOvershoot": ("str", str(param.GetFloat("dimovershoot", 20))),
"ExtensionLines": ("str", str(param.GetFloat("extlines", 300))),
"ExtensionOvershoot": ("str", str(param.GetFloat("extovershoot", 20))),
}
class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
"""Annotation style editor for text and dimensions.
@@ -211,7 +196,7 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
try:
setattr(vobj,attr,attrvalue)
except:
unitvalue = FreeCAD.Units.Quantity(attrvalue,FreeCAD.Units.Length).Value
unitvalue = U.Quantity(attrvalue, U.Length).Value
setattr(vobj,attr,unitvalue)
else:
# the style has been removed

View File

@@ -51,9 +51,29 @@ if App.GuiUp:
# The module is used to prevent complaints from code checkers (flake8)
True if Draft_rc else False
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
ARROW_TYPES = ["Dot", "Circle", "Arrow", "Tick", "Tick-2"]
arrowtypes = ARROW_TYPES
ANNOTATION_STYLE = {
"FontName": ("font", param.GetString("textfont", "Sans")),
"FontSize": ("str", str(param.GetFloat("textheight", 100))),
"LineSpacing": ("float", 1),
"ScaleMultiplier": ("float", 1),
"ShowUnit": ("bool", False),
"UnitOverride": ("str", ""),
"Decimals": ("int", 2),
"ShowLines": ("bool", True),
"LineWidth": ("int", param.GetInt("linewidth", 1)),
"LineColor": ("color", param.GetInt("color", 255)),
"ArrowType": ("index", param.GetInt("dimsymbol", 0)),
"ArrowSize": ("str", str(param.GetFloat("arrowsize", 20))),
"DimensionOvershoot": ("str", str(param.GetFloat("dimovershoot", 20))),
"ExtensionLines": ("str", str(param.GetFloat("extlines", 300))),
"ExtensionOvershoot": ("str", str(param.GetFloat("extovershoot", 20))),
}
def string_encode_coin(ustr):
"""Encode a unicode object to be used as a string in coin.