DisplayMode of Text was not updated. Some houskeeping
This commit is contained in:
@@ -32,6 +32,9 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
|
||||
from draftutils.messages import _wrn
|
||||
from draftutils.translate import translate
|
||||
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
|
||||
|
||||
@@ -39,9 +42,9 @@ class Text(DraftAnnotation):
|
||||
"""The Draft Text object."""
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj, "Text")
|
||||
self.set_properties(obj)
|
||||
obj.Proxy = self
|
||||
self.set_properties(obj)
|
||||
self.Type = "Text"
|
||||
|
||||
def set_properties(self, obj):
|
||||
"""Add properties to the object and set them."""
|
||||
@@ -69,6 +72,32 @@ class Text(DraftAnnotation):
|
||||
_tip)
|
||||
obj.Text = []
|
||||
|
||||
def onDocumentRestored(self,obj):
|
||||
"""Execute code when the document is restored."""
|
||||
super().onDocumentRestored(obj)
|
||||
|
||||
# See __setstate__: self.Type is None for new objects.
|
||||
if self.Type is not None \
|
||||
and hasattr(obj, "ViewObject") \
|
||||
and obj.ViewObject:
|
||||
self.update_properties_0v21(obj, obj.ViewObject)
|
||||
|
||||
self.Type = "Text"
|
||||
|
||||
def update_properties_0v21(self, obj, vobj):
|
||||
"""Update view properties."""
|
||||
# The DisplayMode is updated automatically but the new values are
|
||||
# switched: "2D text" becomes "World" and "3D text" becomes "Screen".
|
||||
# It should be the other way around:
|
||||
vobj.DisplayMode = "World" if vobj.DisplayMode == "Screen" else "Screen"
|
||||
_wrn("v0.21, " + obj.Label + ", "
|
||||
+ translate("draft", "renamed 'DisplayMode' options to 'World/Screen'"))
|
||||
|
||||
def __setstate__(self,state):
|
||||
# Before update_properties_0v21 the self.Type value was stored.
|
||||
# We use this to identify older objects that need to be updated.
|
||||
self.Type = state
|
||||
|
||||
|
||||
# Alias for compatibility with v0.18 and earlier
|
||||
DraftText = Text
|
||||
|
||||
Reference in New Issue
Block a user