+
+// Feature that is used for selection in the Part document by the external request
+class Model_SelectionInPartFeature : public ModelAPI_Feature {
+public:
+ /// Nothing to do in constructor
+ Model_SelectionInPartFeature() : ModelAPI_Feature() {}
+
+ /// Returns the unique kind of a feature
+ virtual const std::string& getKind() {
+ static std::string MY_KIND("InternalSelectionInPartFeature");
+ return MY_KIND;
+ }
+ /// Request for initialization of data model of the object: adding all attributes
+ virtual void initAttributes() {
+ data()->addAttribute("selection", ModelAPI_AttributeSelectionList::typeId());
+ }
+ /// Nothing to do in the execution function
+ virtual void execute() {}
+
+};
+
+//! Returns the feature that is used for calculation of selection externally from the document
+AttributeSelectionListPtr Model_Document::selectionInPartFeature()
+{
+ // return already created, otherwise create
+ if (!mySelectionFeature.get() || !mySelectionFeature->data()->isValid()) {
+ // create a new one
+ mySelectionFeature = FeaturePtr(new Model_SelectionInPartFeature);
+
+ TDF_Label aFeatureLab = generalLabel().FindChild(TAG_SELECTION_FEATURE);
+ std::shared_ptr<Model_Data> aData(new Model_Data);
+ aData->setLabel(aFeatureLab.FindChild(1));
+ aData->setObject(mySelectionFeature);
+ mySelectionFeature->setDoc(myObjs->owner());
+ mySelectionFeature->setData(aData);
+ std::string aName = id() + "_Part";
+ mySelectionFeature->data()->setName(aName);
+ mySelectionFeature->setDoc(myObjs->owner());
+ mySelectionFeature->initAttributes();
+ }
+ return mySelectionFeature->selectionList("selection");
+}
+
+FeaturePtr Model_Document::lastFeature()
+{
+ if (myObjs)
+ return myObjs->lastFeature();
+ return FeaturePtr();
+}