[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.
This commit is contained in:
donovaly
2020-11-05 00:38:15 +01:00
committed by wwmayer
parent 27070858f0
commit da2e8f1aba
3 changed files with 30 additions and 15 deletions

View File

@@ -208,7 +208,7 @@ double ViewProviderLeader::getDefLineWeight(void)
}
App::Color ViewProviderLeader::getDefLineColor(void)
{
{
return PreferencesGui::leaderColor();
}

View File

@@ -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

View File

@@ -47,9 +47,9 @@ public:
/// 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 @@ public:
virtual bool doubleClicked(void);
virtual bool canDelete(App::DocumentObject* obj) const;
static const char* LineStyleEnums[];
virtual TechDraw::DrawRichAnno* getViewObject() const;
TechDraw::DrawRichAnno* getFeature() const;