[Draft] Group object for dimension styles
This commit is contained in:
committed by
Yorik van Havre
parent
9c4c16c7bb
commit
749f614313
@@ -31,6 +31,8 @@ import FreeCAD as App
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from draftviewproviders.view_dimensionstyle import ViewProviderDraftDimensionStyle
|
||||
from draftviewproviders.view_dimensionstyle import ViewProviderDimensionStylesContainer
|
||||
from draftobjects.draft_annotation import AnnotationStylesContainer
|
||||
|
||||
if App.GuiUp:
|
||||
import FreeCADGui as Gui
|
||||
@@ -46,8 +48,37 @@ def make_dimension_style(existing_dimension = None):
|
||||
DimensionStyle(obj)
|
||||
if App.GuiUp:
|
||||
ViewProviderDraftDimensionStyle(obj.ViewObject, existing_dimension)
|
||||
get_dimension_style_container().addObject(obj)
|
||||
return obj
|
||||
|
||||
def get_dimension_style_container():
|
||||
"""get_dimension_style_container(): returns a group object to put dimensions in"""
|
||||
for obj in App.ActiveDocument.Objects:
|
||||
if obj.Name == "DimensionStyleContainer":
|
||||
return obj
|
||||
obj = App.ActiveDocument.addObject("App::DocumentObjectGroupPython", "DimensionStyleContainer")
|
||||
obj.Label = QT_TRANSLATE_NOOP("draft", "Dimension Styles")
|
||||
DimensionStylesContainer(obj)
|
||||
if App.GuiUp:
|
||||
ViewProviderDimensionStylesContainer(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
|
||||
class DimensionStylesContainer(AnnotationStylesContainer):
|
||||
"""The Dimension Container"""
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
self.Type = "DimensionStyleContainer"
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self, obj):
|
||||
|
||||
g = obj.Group
|
||||
g.sort(key=lambda o: o.Label)
|
||||
obj.Group = g
|
||||
|
||||
|
||||
class DimensionStyle(DraftAnnotation):
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj, "DimensionStyle")
|
||||
@@ -52,4 +52,28 @@ class DraftAnnotation:
|
||||
pass
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
pass
|
||||
pass
|
||||
|
||||
class AnnotationStylesContainer:
|
||||
"""The Annotation Container"""
|
||||
|
||||
def __init__(self, obj):
|
||||
|
||||
self.Type = "AnnotationContainer"
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self, obj):
|
||||
|
||||
g = obj.Group
|
||||
g.sort(key=lambda o: o.Label)
|
||||
obj.Group = g
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
if hasattr(self, "Type"):
|
||||
return self.Type
|
||||
|
||||
def __setstate__(self, state):
|
||||
|
||||
if state:
|
||||
self.Type = state
|
||||
Reference in New Issue
Block a user