/// Returns the sub-feature unique identifier in this composite feature by zero-base index
virtual int subFeatureId(const int theIndex) const = 0;
+
+ /// Returns true if feature or reuslt belong to this composite feature as subs
+ virtual bool isSub(ObjectPtr theObject) const = 0;
};
//! Pointer on the composite feature object
}
/// Returns document this feature belongs to
- virtual boost::shared_ptr<ModelAPI_Document> document()
+ virtual boost::shared_ptr<ModelAPI_Document> document() const
{
return ModelAPI_Object::document();
}
}
/// Returns document this feature belongs to
- virtual boost::shared_ptr<ModelAPI_Document> document()
+ virtual boost::shared_ptr<ModelAPI_Document> document() const
{
return myDoc;
}
return subFeature(theIndex)->data()->featureId();
}
+bool SketchPlugin_Sketch::isSub(ObjectPtr theObject) const
+{
+ // check is this feature of result
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (!aFeature) {
+ ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aRes)
+ aFeature = document()->feature(aRes);
+ }
+ if (aFeature) {
+ list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
+ for(list<ObjectPtr>::iterator aSubIt = aSubs.begin(); aSubIt != aSubs.end(); aSubIt++) {
+ if (*aSubIt == aFeature)
+ return true;
+ }
+ }
+ return false;
+}
+
boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const double theY)
{
boost::shared_ptr<GeomDataAPI_Point> aC = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
/// Returns the sub-feature unique identifier in this composite feature by zero-base index
SKETCHPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
+ /// Returns true if feature or reuslt belong to this composite feature as subs
+ SKETCHPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
+
/// Construction result is allways recomuted on the fly
SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}