support to load old project files with PD draft object, restore handling with constraints

This commit is contained in:
wmayer
2019-09-14 19:57:31 +02:00
parent 35aa7bf313
commit f0a1b46b5c
2 changed files with 21 additions and 4 deletions

View File

@@ -59,6 +59,7 @@
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Tools.h>
using namespace PartDesign;
@@ -66,14 +67,29 @@ using namespace PartDesign;
PROPERTY_SOURCE(PartDesign::Draft, PartDesign::DressUp)
App::PropertyAngle::Constraints Draft::floatAngle = {0.0,89.99,0.1};
Draft::Draft()
{
ADD_PROPERTY(Angle,(1.5));
Angle.setConstraints(&floatAngle);
ADD_PROPERTY_TYPE(NeutralPlane,(0),"Draft",(App::PropertyType)(App::Prop_None),"NeutralPlane");
ADD_PROPERTY_TYPE(PullDirection,(0),"Draft",(App::PropertyType)(App::Prop_None),"PullDirection");
ADD_PROPERTY(Reversed,(0));
}
void Draft::handleChangedPropertyType(Base::XMLReader &reader,
const char * TypeName,
App::Property * prop)
{
Base::Type inputType = Base::Type::fromName(TypeName);
if (prop == &Angle && inputType == App::PropertyFloatConstraint::getClassTypeId()) {
App::PropertyFloatConstraint v;
v.Restore(reader);
Angle.setValue(v.getValue());
}
}
short Draft::mustExecute() const
{
if (Placement.isTouched() ||
@@ -103,10 +119,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
return new App::DocumentObjectExecReturn("No faces specified");
// Draft angle
double angle = Angle.getValue();
angle = angle >= 90.0 ? 89.99 : angle < 0.0 ? 0.0 : angle;
Angle.setValue(angle);
angle = angle / 180.0 * M_PI;
double angle = Base::toRadians(Angle.getValue());
// Pull direction
gp_Dir pullDirection;

View File

@@ -54,6 +54,10 @@ public:
return "PartDesignGui::ViewProviderDraft";
}
//@}
private:
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop);
static App::PropertyAngle::Constraints floatAngle;
};
} //namespace PartDesign