Skip to content

Commit

Permalink
[TD] change RichAnnos's linestyle to the one of other TD components
Browse files Browse the repository at this point in the history
we already use enumerations for line styles for other components of TD and also the preferences. It seems I just have overseen this occurrence.
  • Loading branch information
donovaly authored and wwmayer committed Nov 6, 2020
1 parent 0d27ad1 commit edc5925
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/ViewProviderLeader.cpp
Expand Up @@ -208,7 +208,7 @@ double ViewProviderLeader::getDefLineWeight(void)
}

App::Color ViewProviderLeader::getDefLineColor(void)
{
{
return PreferencesGui::leaderColor();
}

Expand Down
35 changes: 24 additions & 11 deletions src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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();
}

Expand All @@ -194,21 +199,29 @@ 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
LineWidthProperty.Restore(reader);
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
Expand Down
8 changes: 5 additions & 3 deletions src/Mod/TechDraw/Gui/ViewProviderRichAnno.h
Expand Up @@ -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;}
Expand All @@ -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;

Expand Down

0 comments on commit edc5925

Please sign in to comment.