Some code unification for DressUp features

This commit is contained in:
jrheinlaender
2013-09-26 21:11:54 +02:00
committed by Stefan Tröger
parent d32317229d
commit a59901ee4b
7 changed files with 335 additions and 33 deletions

View File

@@ -27,6 +27,7 @@
#include "FeatureDressUp.h"
#include <Base/Exception.h>
using namespace PartDesign;
@@ -57,6 +58,22 @@ void DressUp::positionByBaseFeature(void)
this->Placement.setValue(base->Placement.getValue());
}
Part::TopoShape DressUp::getBaseShape()
{
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;
}
void DressUp::onChanged(const App::Property* prop)
{
if (prop == &BaseFeature) {