From bb2db008ad425ca86479562d028cdcda1eabf9f5 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sat, 7 Dec 2019 04:26:15 +0100 Subject: [PATCH] TD: add units for line widths - this also prevents negative values - also fix an issue in DrawViewBalloon introduced by me recently --- src/Mod/TechDraw/App/DrawViewBalloon.cpp | 4 +-- src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 30 +++++++++++++++++++ src/Mod/TechDraw/Gui/ViewProviderViewPart.h | 10 ++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.cpp b/src/Mod/TechDraw/App/DrawViewBalloon.cpp index e6653d5302..ea70fb5fd4 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.cpp +++ b/src/Mod/TechDraw/App/DrawViewBalloon.cpp @@ -136,8 +136,8 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c // property OriginX had the App::PropertyFloat and was changed to App::PropertyLength if (prop == &OriginX && strcmp(TypeName, "App::PropertyFloat") == 0) { - App::PropertyInteger OriginXProperty; - // restore the PropertyInteger to be able to set its value + App::PropertyFloat OriginXProperty; + // restore the PropertyFloat to be able to set its value OriginXProperty.Restore(reader); OriginX.setValue(OriginXProperty.getValue()); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 347c6013f4..9631bbf6f6 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -215,3 +215,33 @@ TechDraw::DrawViewPart* ViewProviderViewPart::getViewPart() const { return getViewObject(); } + +void ViewProviderViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +// transforms properties that had been changed +{ + // property LineWidth had the App::PropertyFloat and was changed to App::PropertyLength + if (prop == &LineWidth && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat LineWidthProperty; + // restore the PropertyFloat to be able to set its value + LineWidthProperty.Restore(reader); + LineWidth.setValue(LineWidthProperty.getValue()); + } + // property HiddenWidth had the App::PropertyFloat and was changed to App::PropertyLength + else if (prop == &HiddenWidth && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat HiddenWidthProperty; + HiddenWidthProperty.Restore(reader); + HiddenWidth.setValue(HiddenWidthProperty.getValue()); + } + // property IsoWidth had the App::PropertyFloat and was changed to App::PropertyLength + else if (prop == &IsoWidth && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat IsoWidthProperty; + IsoWidthProperty.Restore(reader); + IsoWidth.setValue(IsoWidthProperty.getValue()); + } + // property ExtraWidth had the App::PropertyFloat and was changed to App::PropertyLength + else if (prop == &ExtraWidth && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat ExtraWidthProperty; + ExtraWidthProperty.Restore(reader); + ExtraWidth.setValue(ExtraWidthProperty.getValue()); + } +} diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h index f55d58e016..9d94223888 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h @@ -43,10 +43,10 @@ public: /// destructor virtual ~ViewProviderViewPart(); - App::PropertyFloat LineWidth; - App::PropertyFloat HiddenWidth; - App::PropertyFloat IsoWidth; - App::PropertyFloat ExtraWidth; + App::PropertyLength LineWidth; + App::PropertyLength HiddenWidth; + App::PropertyLength IsoWidth; + App::PropertyLength ExtraWidth; App::PropertyBool ArcCenterMarks; App::PropertyFloat CenterScale; App::PropertyBool HorizCenterLine; @@ -64,6 +64,8 @@ public: public: virtual void onChanged(const App::Property *prop); virtual void updateData(const App::Property*); + virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop); + virtual std::vector claimChildren(void) const;