[Draft] Annotation refactor and Cleanup
. .
This commit is contained in:
committed by
Yorik van Havre
parent
530e8b6c58
commit
6d8fe07312
@@ -30,9 +30,11 @@
|
||||
import FreeCAD as App
|
||||
import math
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import DraftGeomUtils
|
||||
import draftutils.gui_utils as gui_utils
|
||||
import draftutils.utils as utils
|
||||
from draftobjects.draft_annotation import DimensionBase
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
from draftviewproviders.view_dimension import ViewProviderDimensionBase
|
||||
from draftviewproviders.view_dimension import ViewProviderLinearDimension
|
||||
|
||||
def make_dimension(p1,p2,p3=None,p4=None):
|
||||
@@ -111,10 +113,40 @@ def make_dimension(p1,p2,p3=None,p4=None):
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
class DimensionBase(DraftAnnotation):
|
||||
"""
|
||||
The Draft Dimension Base object
|
||||
This class is not used directly, but inherited by all dimension
|
||||
objects.
|
||||
"""
|
||||
|
||||
def __init__(self, obj, tp = "Dimension"):
|
||||
"Initialize common properties for dimension objects"
|
||||
DraftAnnotation.__init__(self,obj, tp)
|
||||
|
||||
# Annotation
|
||||
obj.addProperty("App::PropertyLink","DimensionStyle",
|
||||
"Annotation",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"Link dimension style"))
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
|
||||
if prop == "DimensionStyle":
|
||||
if hasattr(obj, "DimensionStyle"):
|
||||
gui_utils.format_object(target = obj, origin = obj.DimensionStyle)
|
||||
|
||||
|
||||
def execute(self, obj):
|
||||
|
||||
return
|
||||
|
||||
|
||||
class LinearDimension(DimensionBase):
|
||||
"""The Draft Dimension object"""
|
||||
"""The Draft Linear Dimension object"""
|
||||
def __init__(self, obj):
|
||||
DimensionBase.__init__(self,obj,"Dimension")
|
||||
super().__init__(obj, "Dimension")
|
||||
|
||||
# Draft
|
||||
obj.addProperty("App::PropertyVectorDistance","Start",
|
||||
@@ -179,7 +211,6 @@ class LinearDimension(DimensionBase):
|
||||
|
||||
|
||||
def execute(self, obj):
|
||||
import DraftGeomUtils
|
||||
# set start point and end point according to the linked geometry
|
||||
if obj.LinkedGeometry:
|
||||
if len(obj.LinkedGeometry) == 1:
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
import FreeCAD as App
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from draftviewproviders.view_dimensionstyle import ViewProviderDraftDimensionStyle
|
||||
|
||||
if App.GuiUp:
|
||||
import FreeCADGui as Gui
|
||||
from draftviewproviders.view_dimensionstyle import ViewProviderDraftDimensionStyle
|
||||
|
||||
def make_dimension_style(existing_dimension = None):
|
||||
"""
|
||||
@@ -50,4 +50,4 @@ def make_dimension_style(existing_dimension = None):
|
||||
|
||||
class DimensionStyle(DraftAnnotation):
|
||||
def __init__(self, obj):
|
||||
DraftAnnotation.__init__(self, obj, "DimensionStyle")
|
||||
super().__init__(obj, "DimensionStyle")
|
||||
@@ -32,8 +32,11 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from draftutils import gui_utils
|
||||
|
||||
class DraftAnnotation:
|
||||
"""The Draft Annotation Base object"""
|
||||
def __init__(self,obj,tp="Unknown"):
|
||||
"""The Draft Annotation Base object
|
||||
This class is not used directly, but inherited by all annotation
|
||||
objects.
|
||||
"""
|
||||
def __init__(self, obj, tp="Unknown"):
|
||||
if obj:
|
||||
obj.Proxy = self
|
||||
self.Type = tp
|
||||
@@ -49,30 +52,4 @@ class DraftAnnotation:
|
||||
pass
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class DimensionBase(DraftAnnotation):
|
||||
"""The Draft Dimension Base object"""
|
||||
|
||||
def __init__(self, obj, tp = "Dimension"):
|
||||
"Initialize common properties for dimension objects"
|
||||
DraftAnnotation.__init__(self,obj, tp)
|
||||
|
||||
# Annotation
|
||||
obj.addProperty("App::PropertyLink","DimensionStyle",
|
||||
"Annotation",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"Link dimension style"))
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
|
||||
if prop == "DimensionStyle":
|
||||
if hasattr(obj, "DimensionStyle"):
|
||||
gui_utils.format_object(target = obj, origin = obj.DimensionStyle)
|
||||
|
||||
|
||||
def execute(self, obj):
|
||||
|
||||
return
|
||||
pass
|
||||
Reference in New Issue
Block a user