From edc592514849d37a183bfca8bfc86104fd3c1f26 Mon Sep 17 00:00:00 2001 From: donovaly Date: Thu, 5 Nov 2020 00:38:15 +0100 Subject: [PATCH] [TD] change RichAnnos's linestyle to the one of other TD components we already use enumerations for line styles for other components of TD and also the preferences. It seems I just have overseen this occurrence. --- src/Mod/TechDraw/Gui/ViewProviderLeader.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp | 35 +++++++++++++------ src/Mod/TechDraw/Gui/ViewProviderRichAnno.h | 8 +++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp index 76cccd5ea96b..3e4755eb849c 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp @@ -208,7 +208,7 @@ double ViewProviderLeader::getDefLineWeight(void) } App::Color ViewProviderLeader::getDefLineColor(void) -{ +{ return PreferencesGui::leaderColor(); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp index 607117af058f..a81a2711ad73 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp @@ -60,11 +60,16 @@ using namespace TechDrawGui; using namespace TechDraw; -// there are only 5 frame line styles -App::PropertyIntegerConstraint::Constraints ViewProviderRichAnno::LineStyleRange = {0, 5, 1}; - PROPERTY_SOURCE(TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderDrawingView) +const char* ViewProviderRichAnno::LineStyleEnums[] = { "NoLine", + "Continuous", + "Dash", + "Dot", + "DashDot", + "DashDotDot", + NULL }; + //************************************************************************** // Construction/Destruction @@ -74,11 +79,11 @@ ViewProviderRichAnno::ViewProviderRichAnno() static const char *group = "Frame Format"; - ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()), group,(App::PropertyType)(App::Prop_None),"Frame line width"); - ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Frame line style index"); - ADD_PROPERTY_TYPE(LineColor,(getDefLineColor()),group,App::Prop_None,"The color of the frame"); + ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group,(App::PropertyType)(App::Prop_None), "Frame line width"); + LineStyle.setEnums(LineStyleEnums); + ADD_PROPERTY_TYPE(LineStyle, (1), group, (App::PropertyType)(App::Prop_None), "Frame line style"); + ADD_PROPERTY_TYPE(LineColor, (getDefLineColor()), group, App::Prop_None, "The color of the frame"); - LineStyle.setConstraints(&LineStyleRange); } ViewProviderRichAnno::~ViewProviderRichAnno() @@ -167,12 +172,12 @@ TechDraw::DrawRichAnno* ViewProviderRichAnno::getFeature() const } App::Color ViewProviderRichAnno::getDefLineColor(void) -{ +{ return PreferencesGui::leaderColor(); } std::string ViewProviderRichAnno::getDefFont(void) -{ +{ return Preferences::labelFont(); } @@ -194,7 +199,7 @@ double ViewProviderRichAnno::getDefLineWeight(void) void ViewProviderRichAnno::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 + // property LineWidth had 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 @@ -202,13 +207,21 @@ void ViewProviderRichAnno::handleChangedPropertyType(Base::XMLReader &reader, co LineWidth.setValue(LineWidthProperty.getValue()); } - // property LineStyle had the App::PropertyInteger and was changed to App::PropertyIntegerConstraint + // property LineStyle had App::PropertyInteger and was changed to App::PropertyIntegerConstraint if (prop == &LineStyle && strcmp(TypeName, "App::PropertyInteger") == 0) { App::PropertyInteger LineStyleProperty; // restore the PropertyInteger to be able to set its value LineStyleProperty.Restore(reader); LineStyle.setValue(LineStyleProperty.getValue()); } + + // property LineStyle had App::PropertyIntegerConstraint and was changed to App::PropertyEnumeration + if (prop == &LineStyle && strcmp(TypeName, "App::PropertyIntegerConstraint") == 0) { + App::PropertyIntegerConstraint LineStyleProperty; + // restore the PropertyIntegerConstraint to be able to set its value + LineStyleProperty.Restore(reader); + LineStyle.setValue(LineStyleProperty.getValue()); + } } bool ViewProviderRichAnno::canDelete(App::DocumentObject *obj) const diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.h b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.h index ce77a5d3a41d..b780fd680344 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.h +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.h @@ -47,9 +47,9 @@ class TechDrawGuiExport ViewProviderRichAnno : public ViewProviderDrawingView /// destructor virtual ~ViewProviderRichAnno(); - App::PropertyLength LineWidth; - App::PropertyIntegerConstraint LineStyle; - App::PropertyColor LineColor; + App::PropertyLength LineWidth; + App::PropertyEnumeration LineStyle; + App::PropertyColor LineColor; virtual void attach(App::DocumentObject *); virtual bool useNewSelectionModel(void) const {return false;} @@ -60,6 +60,8 @@ class TechDrawGuiExport ViewProviderRichAnno : public ViewProviderDrawingView virtual bool doubleClicked(void); virtual bool canDelete(App::DocumentObject* obj) const; + static const char* LineStyleEnums[]; + virtual TechDraw::DrawRichAnno* getViewObject() const; TechDraw::DrawRichAnno* getFeature() const;