Restore ViewObject implementation for all Draft objects

In my tests the code works fine. Using @AIRCAP's instructions,  I have created a 'broken' file from draft_test_objects.FCStd.
This commit is contained in:
Roy-043
2024-10-24 15:24:13 +02:00
parent 8c4d696180
commit 0fac810797
24 changed files with 226 additions and 94 deletions

View File

@@ -34,6 +34,7 @@ import FreeCAD as App
import DraftGeomUtils
import DraftVecUtils
from draftobjects.base import DraftObject
from draftutils import gui_utils
from draftutils import params
@@ -41,7 +42,7 @@ class Wire(DraftObject):
"""The Wire object"""
def __init__(self, obj):
super(Wire, self).__init__(obj, "Wire")
super().__init__(obj, "Wire")
_tip = QT_TRANSLATE_NOOP("App::Property",
"The vertices of the wire")
@@ -94,6 +95,10 @@ class Wire(DraftObject):
obj.MakeFace = params.get_param("fillmode")
obj.Closed = False
def onDocumentRestored(self, obj):
super().onDocumentRestored(obj)
gui_utils.restore_view_object(obj, vp_module="view_wire", vp_class="ViewProviderWire")
def execute(self, obj):
if self.props_changed_placement_only(obj): # Supplying obj is required because of `Base` and `Tool`.
obj.positionBySupport()