PartDesign: Fixed similar issue compared to #2302 with unit handling when using an expression for the chamfer size.
This commit is contained in:
parent
acd0f6a79e
commit
be5e79601a
|
@ -32,6 +32,8 @@
|
|||
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "FeatureChamfer.h"
|
||||
|
@ -42,11 +44,12 @@ using namespace PartDesign;
|
|||
|
||||
PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp)
|
||||
|
||||
const App::PropertyFloatConstraint::Constraints floatSize = {0.0,FLT_MAX,0.1};
|
||||
const App::PropertyQuantityConstraint::Constraints floatSize = {0.0,FLT_MAX,0.1};
|
||||
|
||||
Chamfer::Chamfer()
|
||||
{
|
||||
ADD_PROPERTY(Size,(1.0));
|
||||
Size.setUnit(Base::Unit::Length);
|
||||
Size.setConstraints(&floatSize);
|
||||
}
|
||||
|
||||
|
@ -109,3 +112,39 @@ App::DocumentObjectExecReturn *Chamfer::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
void Chamfer::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("Properties");
|
||||
int Cnt = reader.getAttributeAsInteger("Count");
|
||||
|
||||
for (int i=0 ;i<Cnt ;i++) {
|
||||
reader.readElement("Property");
|
||||
const char* PropName = reader.getAttribute("name");
|
||||
const char* TypeName = reader.getAttribute("type");
|
||||
App::Property* prop = getPropertyByName(PropName);
|
||||
|
||||
try {
|
||||
if (prop && strcmp(prop->getTypeId().getName(), TypeName) == 0) {
|
||||
prop->Restore(reader);
|
||||
}
|
||||
else if (prop && strcmp(TypeName,"App::PropertyFloatConstraint") == 0 &&
|
||||
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
|
||||
App::PropertyFloatConstraint p;
|
||||
p.Restore(reader);
|
||||
static_cast<App::PropertyQuantityConstraint*>(prop)->setValue(p.getValue());
|
||||
}
|
||||
}
|
||||
catch (const Base::XMLParseException&) {
|
||||
throw; // re-throw
|
||||
}
|
||||
catch (const Base::Exception &e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
reader.readEndElement("Property");
|
||||
}
|
||||
reader.readEndElement("Properties");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define PARTDESIGN_FEATURECHAMFER_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "FeatureDressUp.h"
|
||||
|
||||
|
@ -38,7 +39,7 @@ class PartDesignExport Chamfer : public DressUp
|
|||
public:
|
||||
Chamfer();
|
||||
|
||||
App::PropertyFloatConstraint Size;
|
||||
App::PropertyQuantityConstraint Size;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -50,6 +51,10 @@ public:
|
|||
return "PartDesignGui::ViewProviderChamfer";
|
||||
}
|
||||
//@}
|
||||
|
||||
protected:
|
||||
void Restore(Base::XMLReader &reader);
|
||||
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
|
Loading…
Reference in New Issue
Block a user