[TD] use enum for line style

see https://forum.freecadweb.org/viewtopic.php?f=10&t=44268#p377798
This commit is contained in:
donovaly
2020-03-18 22:45:19 +01:00
committed by WandererFan
parent 45ee763af2
commit bfe542fd67
2 changed files with 22 additions and 9 deletions

View File

@@ -63,11 +63,16 @@
using namespace TechDrawGui;
// there are only 5 line styles
App::PropertyIntegerConstraint::Constraints ViewProviderLeader::LineStyleRange = { 0, 5, 1 };
PROPERTY_SOURCE(TechDrawGui::ViewProviderLeader, TechDrawGui::ViewProviderDrawingView)
const char* ViewProviderLeader::LineStyleEnums[] = { "NoLine",
"Continuous",
"Dash",
"Dot",
"DashDot",
"DashDotDot",
NULL };
//**************************************************************************
// Construction/Destruction
@@ -78,10 +83,9 @@ ViewProviderLeader::ViewProviderLeader()
static const char *group = "Line Format";
ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()),group,(App::PropertyType)(App::Prop_None),"Line width");
ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Line style index");
ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"The color of the Markup");
LineStyle.setConstraints(&LineStyleRange);
LineStyle.setEnums(LineStyleEnums);
ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Line style");
ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"Color of the Markup");
}
ViewProviderLeader::~ViewProviderLeader()
@@ -191,7 +195,6 @@ TechDraw::DrawLeaderLine* ViewProviderLeader::getFeature() const
return dynamic_cast<TechDraw::DrawLeaderLine*>(pcObject);
}
double ViewProviderLeader::getDefLineWeight(void)
{
double result = 0.0;
@@ -230,6 +233,14 @@ void ViewProviderLeader::handleChangedPropertyType(Base::XMLReader &reader, cons
LineStyleProperty.Restore(reader);
LineStyle.setValue(LineStyleProperty.getValue());
}
// property LineStyle had the 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 ViewProviderLeader::onDelete(const std::vector<std::string> &)