Skip to content

Commit

Permalink
Draft: move default annotation style properties to utils module
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Jun 19, 2020
1 parent e1cfaf1 commit 270e4b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py
Expand Up @@ -28,28 +28,13 @@
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.
Expand Down Expand Up @@ -211,7 +196,7 @@ def save_meta(self, styles):
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
Expand Down
20 changes: 20 additions & 0 deletions src/Mod/Draft/draftutils/utils.py
Expand Up @@ -51,9 +51,29 @@
# 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.
Expand Down

0 comments on commit 270e4b1

Please sign in to comment.