From f7ca1d91d3ffb9ead95ee6b0575fa7e814d6f9e5 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 24 Nov 2019 23:14:28 +0100 Subject: [PATCH] TechDraw: add units for position see https://forum.freecadweb.org/viewtopic.php?f=35&t=40608 for details --- src/Mod/TechDraw/App/DrawView.cpp | 34 ++++++++++++++++++++++--------- src/Mod/TechDraw/App/DrawView.h | 7 ++++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index afdb1684db..f753c4d05b 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -75,17 +75,17 @@ DrawView::DrawView(void): mouseMove(false) { static const char *group = "Base"; - ADD_PROPERTY_TYPE(X ,(0.0),group,App::Prop_None,"X position in internal units"); - ADD_PROPERTY_TYPE(Y ,(0.0),group,App::Prop_None,"Y position in internal units"); - ADD_PROPERTY_TYPE(LockPosition ,(false),group,App::Prop_None,"Lock View position to parent Page or Group"); - ADD_PROPERTY_TYPE(Rotation ,(0.0),group,App::Prop_None,"Rotation in degrees counterclockwise"); + ADD_PROPERTY_TYPE(X, (0.0), group, App::Prop_None, "X position"); + ADD_PROPERTY_TYPE(Y, (0.0), group, App::Prop_None, "Y position"); + ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_None, "Lock View position to parent Page or Group"); + ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_None, "Rotation in degrees counterclockwise"); ScaleType.setEnums(ScaleTypeEnums); - ADD_PROPERTY_TYPE(ScaleType,((long)0),group, App::Prop_None, "Scale Type"); - ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view"); + ADD_PROPERTY_TYPE(ScaleType, ((long)0), group, App::Prop_None, "Scale Type"); + ADD_PROPERTY_TYPE(Scale, (1.0), group, App::Prop_None, "Scale factor of the view"); Scale.setConstraints(&scaleRange); - ADD_PROPERTY_TYPE(Caption ,(""),group,App::Prop_None,"Short text about the view"); + ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_None, "Short text about the view"); } DrawView::~DrawView() @@ -340,9 +340,8 @@ void DrawView::handleChangedPropertyType( Scale.setValue(1.0); } } else { - // has Scale prop that isn't Float! - Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n"); - // no idea + // has Scale property that isn't float + Base::Console().Log("DrawPage::Restore - old document Scale is not a float!\n"); } } else if (prop->isDerivedFrom(App::PropertyLinkList::getClassTypeId()) && strcmp(prop->getName(),"Source")==0) @@ -365,6 +364,21 @@ void DrawView::handleChangedPropertyType( } } } + // property X had App::PropertyFloat and was changed to App::PropertyLength + else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat XProperty; + XProperty.setContainer(this); + // restore the PropertyFloat to be able to set its value + XProperty.Restore(reader); + X.setValue(XProperty.getValue()); + } + // property Y had App::PropertyFloat and was changed to App::PropertyLength + else if (prop == &Y && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat YProperty; + YProperty.setContainer(this); + YProperty.Restore(reader); + Y.setValue(YProperty.getValue()); + } } bool DrawView::keepUpdated(void) diff --git a/src/Mod/TechDraw/App/DrawView.h b/src/Mod/TechDraw/App/DrawView.h index 0093eac9ae..dc8378accc 100644 --- a/src/Mod/TechDraw/App/DrawView.h +++ b/src/Mod/TechDraw/App/DrawView.h @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace TechDraw @@ -51,9 +52,9 @@ public: DrawView(void); virtual ~DrawView(); - App::PropertyFloat X; - App::PropertyFloat Y; - App::PropertyBool LockPosition; + App::PropertyLength X; + App::PropertyLength Y; + App::PropertyBool LockPosition; App::PropertyFloatConstraint Scale; App::PropertyEnumeration ScaleType;