PartDesign/FeatureDressUp: implement a proper getBaseObject()
The function getBaseShape() is removed and replaced with getBaseObject() because it doesn't make a lot of scense: getBaseShape() masked the base's class implementation (rather than redefine a virtual) which was better in words of code reuse. Also BaseFeature and Base properties relations are defined now in a little another way.
This commit is contained in:
parent
9feff04aad
commit
5f6f16e757
|
@ -64,20 +64,18 @@ void DressUp::positionByBaseFeature(void)
|
|||
this->Placement.setValue(base->Placement.getValue());
|
||||
}
|
||||
|
||||
Part::TopoShape DressUp::getBaseShape()
|
||||
Part::Feature *DressUp::getBaseObject() const
|
||||
{
|
||||
App::DocumentObject* link = BaseFeature.getValue();
|
||||
if (!link)
|
||||
link = this->Base.getValue(); // For legacy features
|
||||
if (!link)
|
||||
throw Base::Exception("No object linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::Exception("Linked object is not a Part object");
|
||||
Part::Feature* base = static_cast<Part::Feature*>(link);
|
||||
const Part::TopoShape& shape = base->Shape.getShape();
|
||||
if (shape._Shape.IsNull())
|
||||
throw Base::Exception("Cannot draft invalid shape");
|
||||
return shape;
|
||||
try {
|
||||
return Feature::getBaseObject();
|
||||
} catch (const Base::Exception &) {
|
||||
App::DocumentObject* base = Base.getValue();
|
||||
if(!base)
|
||||
throw Base::Exception("No Base object linked");
|
||||
if(!base->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::Exception("Linked object is not a Part object");
|
||||
return static_cast<Part::Feature*>(base);
|
||||
}
|
||||
}
|
||||
|
||||
void DressUp::getContiniusEdges(Part::TopoShape TopShape, std::vector< std::string >& SubNames) {
|
||||
|
@ -142,20 +140,21 @@ void DressUp::getContiniusEdges(Part::TopoShape TopShape, std::vector< std::stri
|
|||
else {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DressUp::onChanged(const App::Property* prop)
|
||||
{
|
||||
// the BaseFeature property should always link to the same feature as the Base
|
||||
// the BaseFeature property should track the Base and vice-versa as long as
|
||||
// the feature is inside a body (aka BaseFeature is nonzero)
|
||||
if (prop == &BaseFeature) {
|
||||
if (Base.getValue() != BaseFeature.getValue()) {
|
||||
if (BaseFeature.getValue() && Base.getValue() != BaseFeature.getValue()) {
|
||||
Base.setValue (BaseFeature.getValue());
|
||||
}
|
||||
} else if (prop == &Base) {
|
||||
// track the vice-versa changes
|
||||
if (Base.getValue() != BaseFeature.getValue()) {
|
||||
if (BaseFeature.getValue() && Base.getValue() != BaseFeature.getValue()) {
|
||||
BaseFeature.setValue (Base.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,15 +39,19 @@ public:
|
|||
|
||||
/**
|
||||
* Base feature and it's subelements to which dressup operation will be aplied to.
|
||||
* It always refers to the same feature Feature::BaseFeature does, but unlike it
|
||||
* the Base property also includes SubLinks.
|
||||
* Unlike Feature::BaseFeature it includes Sublinks and set not only inside a body.
|
||||
* But for consistancy if BaseFeature is nonzero this links to the same body as it.
|
||||
*/
|
||||
App::PropertyLinkSub Base;
|
||||
|
||||
short mustExecute() const;
|
||||
/// updates the Placement property from the Placement of the BaseFeature
|
||||
void positionByBaseFeature(void);
|
||||
Part::TopoShape getBaseShape();
|
||||
/**
|
||||
* Returns the BaseFeature property's object if it's set othervice returns Base's
|
||||
* feature property object otherviceeature property's object (if any)
|
||||
*/
|
||||
virtual Part::Feature* getBaseObject() const;
|
||||
/// extracts all edges from the subshapes (inkluding face edges) and furthermore adds
|
||||
/// all C0 continius edges to the vector
|
||||
void getContiniusEdges(Part::TopoShape, std::vector< std::string >&);
|
||||
|
|
Loading…
Reference in New Issue
Block a user