Draft: add onChanged method in the derived annotation classes

The classes `ViewProviderDimensionBase`, `ViewProviderLinearDimension`,
`ViewProviderAngularDimension`, `ViewProviderText`, and
`ViewProviderLabel` use `super()` to call the `onChanged` method
of the parent class `ViewProviderDraftAnnotation`.

In this way the `AnnotationStyle` property correctly modifies
the properties of every annotation object.
This commit is contained in:
vocx-fc
2020-06-17 20:31:39 -05:00
committed by Yorik van Havre
parent b9d4e6884a
commit 4e106902f1
3 changed files with 15 additions and 5 deletions

View File

@@ -265,8 +265,8 @@ class ViewProviderDimensionBase(ViewProviderDraftAnnotation):
return
def onChanged(self, vobj, prop):
"""called when a view property has changed"""
return
"""Execute when a view property is changed."""
super(ViewProviderDimensionBase, self).onChanged(vobj, prop)
def doubleClicked(self,vobj):
self.setEdit(vobj)
@@ -559,7 +559,9 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase):
self.line.coordIndex.setValues(0,4,(0,1,2,3))
def onChanged(self, vobj, prop):
"""called when a view property has changed"""
"""Execute when a view property is changed."""
super(ViewProviderLinearDimension, self).onChanged(vobj, prop)
if prop == "ScaleMultiplier" and hasattr(vobj, "ScaleMultiplier"):
# update all dimension values
if hasattr(self,"font"):
@@ -936,6 +938,9 @@ class ViewProviderAngularDimension(ViewProviderDimensionBase):
obj.Angle = a
def onChanged(self, vobj, prop):
"""Execute when a view property is changed."""
super(ViewProviderAngularDimension, self).onChanged(vobj, prop)
if hasattr(vobj, "ScaleMultiplier"):
if vobj.ScaleMultiplier == 0:
return

View File

@@ -276,7 +276,10 @@ class ViewProviderLabel(ViewProviderDraftAnnotation):
text.getBoundingBox(b)
return b.getBoundingBox().getSize().getValue()
def onChanged(self,vobj,prop):
def onChanged(self, vobj, prop):
"""Execute when a view property is changed."""
super(ViewProviderLabel, self).onChanged(vobj, prop)
if prop == "ScaleMultiplier":
if not hasattr(vobj,"ScaleMultiplier"):
return

View File

@@ -162,8 +162,10 @@ class ViewProviderText(ViewProviderDraftAnnotation):
self.trans.translation.setValue(obj.Placement.Base)
self.trans.rotation.setValue(obj.Placement.Rotation.Q)
def onChanged(self, vobj, prop):
"""Execute when a view property is changed."""
super(ViewProviderText, self).onChanged(vobj, prop)
def onChanged(self,vobj,prop):
if prop == "ScaleMultiplier":
if "ScaleMultiplier" in vobj.PropertiesList:
if vobj.ScaleMultiplier: