Feature tree: Insert mode for SketchBased features
This commit is contained in:
committed by
Stefan Tröger
parent
6235385c5a
commit
2f658733b7
@@ -102,12 +102,37 @@ App::DocumentObject* Body::getTipSolidFeature()
|
||||
return *it;
|
||||
}
|
||||
|
||||
App::DocumentObject* Body::getNextSolidFeature()
|
||||
{
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
if (features.empty()) return NULL;
|
||||
if (Tip.getValue() == features.back()) return NULL;
|
||||
|
||||
std::vector<App::DocumentObject*>::const_iterator it = std::find(features.begin(), features.end(), Tip.getValue());
|
||||
it++; // Move beyond the Tip
|
||||
|
||||
// Skip sketches
|
||||
while (!(*it)->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||
it++;
|
||||
if (it == features.end())
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
const bool Body::hasFeature(const App::DocumentObject* f)
|
||||
{
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
return std::find(features.begin(), features.end(), f) != features.end();
|
||||
}
|
||||
|
||||
const bool Body::insertMode() {
|
||||
std::vector<App::DocumentObject*> features = Model.getValues();
|
||||
if (features.empty()) return false;
|
||||
return Tip.getValue() != features.back();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Body::execute(void)
|
||||
{
|
||||
std::vector<App::DocumentObject*> children = Model.getValues();
|
||||
|
||||
@@ -66,14 +66,25 @@ public:
|
||||
*/
|
||||
App::DocumentObject *getTipSolidFeature();
|
||||
|
||||
/**
|
||||
* Return the next solid feature after the Tip feature (so this only makes sense in insert mode)
|
||||
* This is used by Sketchbased features in insert mode to re-route the Base property
|
||||
* NOTE: Currently only PartDesign features are accepted as nextSolidFeatures
|
||||
*/
|
||||
App::DocumentObject *getNextSolidFeature();
|
||||
|
||||
/// Return the shape of the feature preceding this feature
|
||||
const Part::TopoShape getPreviousSolid(const PartDesign::Feature* f);
|
||||
|
||||
/// Return true if the feature belongs to this body
|
||||
const bool hasFeature(const App::DocumentObject *f);
|
||||
|
||||
/// Returns true if we are inserting into the feature tree instead of appending at the end
|
||||
const bool insertMode();
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
Reference in New Issue
Block a user