From 270e4b100a3a8758149a041716847d27314d44cd Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Tue, 16 Jun 2020 10:25:19 -0500 Subject: [PATCH] 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. --- .../gui_annotationstyleeditor.py | 23 ++++--------------- src/Mod/Draft/draftutils/utils.py | 20 ++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py index d3a31cc59e..a71ea26e1f 100644 --- a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py +++ b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py @@ -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 diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 039346d456..5f0aa6040a 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -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.