Draft: fix ScaleMultiplier on annotation objects
Object auto create the property when opening an old Draft annotation .
This commit is contained in:
committed by
Yorik van Havre
parent
130d8413bf
commit
cbeca1b4a6
@@ -199,6 +199,8 @@ class DimensionBase(DraftAnnotation):
|
||||
obj.Dimline = App.Vector(0,1,0)
|
||||
obj.Normal = App.Vector(0,0,1)
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super(DimensionBase, self).onDocumentRestored(obj)
|
||||
|
||||
def execute(self, obj):
|
||||
'''Do something when recompute object'''
|
||||
@@ -263,6 +265,10 @@ class LinearDimension(DimensionBase):
|
||||
obj.Start = App.Vector(0,0,0)
|
||||
obj.End = App.Vector(1,0,0)
|
||||
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super(LinearDimension, self).onDocumentRestored(obj)
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
'''Do something when a property has changed'''
|
||||
if hasattr(obj, "Distance"):
|
||||
@@ -377,6 +383,8 @@ class AngularDimension(DimensionBase):
|
||||
obj.Center = App.Vector(0,0,0)
|
||||
obj.Normal = App.Vector(0,0,1)
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super(AngularDimension, self).onDocumentRestored(obj)
|
||||
|
||||
def execute(self, fp):
|
||||
'''Do something when recompute object'''
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
"""This module provides the object code for Draft Annotation.
|
||||
"""
|
||||
## @package annotation
|
||||
@@ -32,9 +31,15 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from draftutils import gui_utils
|
||||
|
||||
class DraftAnnotation(object):
|
||||
"""The Draft Annotation Base object
|
||||
This class is not used directly, but inherited by all annotation
|
||||
"""The Draft Annotation Base object.
|
||||
|
||||
This class is not used directly, but inherited by all Draft annotation
|
||||
objects.
|
||||
|
||||
LinearDimension through DimensionBase
|
||||
AngularDimension through DimensionBase
|
||||
Label
|
||||
Text
|
||||
"""
|
||||
def __init__(self, obj, tp="Annotation"):
|
||||
"""Add general Annotation properties to the object"""
|
||||
@@ -42,6 +47,19 @@ class DraftAnnotation(object):
|
||||
self.Type = tp
|
||||
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
'''Check if new properties are present after object is recreated.'''
|
||||
if hasattr(obj, "ViewObject") and obj.ViewObject:
|
||||
if not 'ScaleMultiplier' in obj.ViewObject.PropertiesList:
|
||||
# annotation properties
|
||||
_msg = QT_TRANSLATE_NOOP("Draft",
|
||||
"Adding property ScaleMultiplier to ")
|
||||
App.Console.PrintMessage(_msg + obj.Name + "\n")
|
||||
obj.ViewObject.addProperty("App::PropertyFloat","ScaleMultiplier",
|
||||
"Annotation",QT_TRANSLATE_NOOP("App::Property",
|
||||
"Dimension size overall multiplier"))
|
||||
obj.ViewObject.ScaleMultiplier = 1.00
|
||||
|
||||
def __getstate__(self):
|
||||
return self.Type
|
||||
|
||||
|
||||
@@ -180,6 +180,8 @@ class Label(DraftAnnotation):
|
||||
obj.TargetPoint = App.Vector(2,-1,0)
|
||||
obj.CustomText = "Label"
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super(Label, self).onDocumentRestored(obj)
|
||||
|
||||
def execute(self,obj):
|
||||
'''Do something when recompute object'''
|
||||
|
||||
@@ -90,7 +90,6 @@ def make_text(stringslist, point=App.Vector(0,0,0), screen=False):
|
||||
return obj
|
||||
|
||||
|
||||
|
||||
class Text(DraftAnnotation):
|
||||
"""The Draft Text object"""
|
||||
|
||||
@@ -118,6 +117,8 @@ class Text(DraftAnnotation):
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"The text displayed by this object"))
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super(Text, self).onDocumentRestored(obj)
|
||||
|
||||
def execute(self,obj):
|
||||
'''Do something when recompute object'''
|
||||
|
||||
Reference in New Issue
Block a user