From 8ec5ebeba7673603bd96145a6445d16ad17ae245 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Mar 2025 08:06:46 -0500 Subject: [PATCH] [TD]use correct property type for directions --- src/Mod/TechDraw/App/DrawViewPart.cpp | 28 +++++++++++++++++++++++++++ src/Mod/TechDraw/App/DrawViewPart.h | 7 ++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 987f37b84a..c03fcca040 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -1042,6 +1042,7 @@ bool DrawViewPart::hasGeometry() const const std::vector& verts = getVertexGeometry(); const std::vector& edges = getEdgeGeometry(); + return !(verts.empty() && edges.empty()); } @@ -1477,6 +1478,33 @@ void DrawViewPart::resetReferenceVerts() addReferencesToGeom(); } +void DrawViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + if (prop == &Direction) { + // Direction was PropertyVector but is now PropertyDirection + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + Direction.setValue(tmpValue); + } + return; + } + + if (prop == &XDirection) { + // XDirection was PropertyFloat but is now PropertyLength + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + XDirection.setValue(tmpValue); + } + return; + } +} + // debugging ---------------------------------------------------------------------------- void DrawViewPart::dumpVerts(std::string text) diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index e5d772097e..6265c2544c 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -90,9 +90,8 @@ public: App::PropertyLinkList Source; App::PropertyXLinkList XSource; - App::PropertyVector - Direction;//TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection) - App::PropertyVector XDirection; + App::PropertyDirection Direction; // the projection direction + App::PropertyDirection XDirection; App::PropertyBool Perspective; App::PropertyDistance Focus; @@ -115,6 +114,8 @@ public: App::DocumentObjectExecReturn* execute() override; const char* getViewProviderName() const override { return "TechDrawGui::ViewProviderViewPart"; } PyObject* getPyObject() override; + void handleChangedPropertyType( + Base::XMLReader &reader, const char * TypeName, App::Property * prop) override; static TopoDS_Shape centerScaleRotate(const DrawViewPart* dvp, TopoDS_Shape& inOutShape, Base::Vector3d centroid);