Skip to content

Commit

Permalink
[Draft] Dimension Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopav authored and yorikvanhavre committed Apr 16, 2020
1 parent 4855564 commit 88612be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 113 deletions.
10 changes: 9 additions & 1 deletion src/Mod/Draft/draftobjects/dimensionstyle.py
Expand Up @@ -81,4 +81,12 @@ def execute(self, obj):

class DimensionStyle(DraftAnnotation):
def __init__(self, obj):
super().__init__(obj, "DimensionStyle")
super().__init__(obj, "DimensionStyle")

def set_current(self, obj):
"turn non visible all the concurrent styles"
for o in get_dimension_style_container().Group:
if hasattr(o, "Visibility"):
o.Visibility = False
if hasattr(obj, "Visibility"):
obj.Visibility = True
120 changes: 8 additions & 112 deletions src/Mod/Draft/draftviewproviders/view_dimensionstyle.py
Expand Up @@ -34,6 +34,7 @@
from pivy import coin
from draftviewproviders.view_draft_annotation import ViewProviderDraftAnnotation
from draftviewproviders.view_draft_annotation import ViewProviderAnnotationStylesContainer
from draftviewproviders.view_dimension import ViewProviderDimensionBase


class ViewProviderDimensionStylesContainer(ViewProviderAnnotationStylesContainer):
Expand All @@ -48,127 +49,23 @@ def getIcon(self):
return ":/icons/Draft_Annotation_Style.svg"


class ViewProviderDraftDimensionStyle(_ViewProviderDraft):
class ViewProviderDraftDimensionStyle(ViewProviderDimensionBase):
"""
Dimension style dont have a proper object but just a viewprovider.
It stores inside a document object dimension settings and restore them on demand.
"""
def __init__(self, vobj, existing_dimension = None):
"""
vobj properties type parameter type
----------------------------------------------------------------------------------
vobj.ScaleMultiplier" App::PropertyFloat "DraftAnnotationScale" Float
vobj.FontName App::PropertyFont "textfont" Text
vobj.FontSize App::PropertyLength "textheight" Float
vobj.TextSpacing App::PropertyLength "dimspacing" Float
vobj.Decimals App::PropertyInteger "dimPrecision" Integer
vobj.ShowUnit App::PropertyBool
vobj.UnitOverride App::PropertyString
vobj.LineWidth App::PropertyFloat
vobj.LineColor App::PropertyColor
vobj.ArrowSize App::PropertyLength "arrowsize" Float
vobj.ArrowType App::PropertyEnumeration "dimsymbol" Integer
vobj.FlipArrows App::PropertyBool
vobj.DimOvershoot App::PropertyDistance "dimovershoot" Float
vobj.ExtLines App::PropertyDistance "extlines" Float
vobj.ExtOvershoot App::PropertyDistance "extovershoot" Float
vobj.ShowLine App::PropertyBool
"""

# annotation properties
vobj.addProperty("App::PropertyFloat","ScaleMultiplier",
"Annotation",
QT_TRANSLATE_NOOP("App::Property",
"Dimension size overall multiplier"))
super().__init__(vobj)

vobj.addProperty("App::PropertyBool","AutoUpdate",
"Annotation",
QT_TRANSLATE_NOOP("App::Property",
"Auto update associated dimensions"))

# text properties
vobj.addProperty("App::PropertyFont","FontName",
"Text",
QT_TRANSLATE_NOOP("App::Property","Font name"))

vobj.addProperty("App::PropertyLength","FontSize",
"Text",
QT_TRANSLATE_NOOP("App::Property",
"Font size"))

vobj.addProperty("App::PropertyLength","TextSpacing",
"Text",
QT_TRANSLATE_NOOP("App::Property",
"The spacing between the text and "
"the dimension line"))

# units properties
vobj.addProperty("App::PropertyInteger","Decimals",
"Units",
QT_TRANSLATE_NOOP("App::Property",
"The number of decimals to show"))

vobj.addProperty("App::PropertyBool","ShowUnit",
"Units",
QT_TRANSLATE_NOOP("App::Property",
"Show the unit suffix"))

vobj.addProperty("App::PropertyString","UnitOverride",
"Units",
QT_TRANSLATE_NOOP("App::Property",
"A unit to express the measurement. "
"Leave blank for system default"))

# graphics properties
vobj.addProperty("App::PropertyFloat","LineWidth",
"Graphics",
QT_TRANSLATE_NOOP("App::Property","Line width"))

vobj.addProperty("App::PropertyColor","LineColor",
"Graphics",
QT_TRANSLATE_NOOP("App::Property","Line color"))

vobj.addProperty("App::PropertyLength","ArrowSize",
"Graphics",
QT_TRANSLATE_NOOP("App::Property","Arrow size"))

vobj.addProperty("App::PropertyEnumeration","ArrowType",
"Graphics",
QT_TRANSLATE_NOOP("App::Property","Arrow type"))

vobj.addProperty("App::PropertyBool","FlipArrows",
"Graphics",
QT_TRANSLATE_NOOP("App::Property",
"Rotate the dimension arrows 180 degrees"))

vobj.addProperty("App::PropertyDistance","DimOvershoot",
"Graphics",
QT_TRANSLATE_NOOP("App::Property",
"The distance the dimension line is "
"extended past the extension lines"))

vobj.addProperty("App::PropertyDistance","ExtLines",
"Graphics",
QT_TRANSLATE_NOOP("App::Property",
"Length of the extension lines"))

vobj.addProperty("App::PropertyDistance","ExtOvershoot",
"Graphics",
QT_TRANSLATE_NOOP("App::Property",
"Length of the extension line above "
"the dimension line"))

vobj.addProperty("App::PropertyBool","ShowLine",
"Graphics",
QT_TRANSLATE_NOOP("App::Property",
"Shows dimension line and arrows"))

self.init_properties(vobj, existing_dimension)

super().__init__(vobj)

# Visibility is True only if the style is active
vobj.Visibility = False

def init_properties(self, vobj, existing_dimension):
"""
Expand Down Expand Up @@ -205,9 +102,6 @@ def onChanged(self, vobj, prop):
if hasattr(vobj, "AutoUpdate"):
if vobj.AutoUpdate:
self.update_related_dimensions(vobj)
if hasattr(vobj, "Visibility"):
if prop == "Visibility":
print(vobj.Visibility)

def doubleClicked(self,vobj):
self.set_current(vobj)
Expand Down Expand Up @@ -239,6 +133,8 @@ def set_current(self, vobj):

App.Console.PrintMessage("Current dimension style set to " + str(vobj.Object.Label) + "\n")

vobj.Object.Proxy.set_current(vobj.Object)

def update_related_dimensions(self, vobj):
"""
Apply the style to the related dimensions
Expand Down

0 comments on commit 88612be

Please sign in to comment.