[PD] disallow invalid polar and linear pattern settings

as discussed in 423d41da19 we should disallow invalid property settings
This commit is contained in:
donovaly
2021-03-02 03:24:15 +01:00
committed by wmayer
parent 6d02284b81
commit 20024707a9
4 changed files with 44 additions and 6 deletions

View File

@@ -49,12 +49,15 @@ namespace PartDesign {
PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed)
const App::PropertyIntegerConstraint::Constraints intOccurrences = { 1, INT_MAX, 1 };
LinearPattern::LinearPattern()
{
ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",(App::PropertyType)(App::Prop_None),"Direction");
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY(Length,(100.0));
ADD_PROPERTY(Occurrences,(3));
Occurrences.setConstraints(&intOccurrences);
}
short LinearPattern::mustExecute() const
@@ -187,4 +190,16 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
return transformations;
}
void LinearPattern::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop)
// transforms properties that had been changed
{
// property Occurrences had the App::PropertyInteger and was changed to App::PropertyIntegerConstraint
if (prop == &Occurrences && strcmp(TypeName, "App::PropertyInteger") == 0) {
App::PropertyInteger OccurrencesProperty;
// restore the PropertyInteger to be able to set its value
OccurrencesProperty.Restore(reader);
Occurrences.setValue(OccurrencesProperty.getValue());
}
}
}