support to load old project files with PD draft object, restore handling with constraints
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user