Salome HOME
The external feature should be executed manually in order to return first result.
[modules/shaper.git] / src / PartSet / PartSet_MenuMgr.cpp
index f232b9b4845a5fba8b2a5185f270c073d3c41a4c..9b5919c20d411df18d759c8cbe87ccc36781c5ee 100644 (file)
@@ -26,6 +26,8 @@
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
 #include <XGUI_Displayer.h>
+#include <XGUI_DataModel.h>
+#include <XGUI_ObjectsBrowser.h>
 
 #include <Events_Loop.h>
 #include <ModelAPI_Events.h>
@@ -86,6 +88,11 @@ void PartSet_MenuMgr::createActions()
   aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this);
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool)));
   myActions["EDIT_CMD"] = aAction;
+
+  aAction = new QAction(QIcon(), tr("Select parent feature"), this);
+  aAction->setCheckable(false);
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSelectParentFeature()));
+  myActions["SELECT_PARENT_CMD"] = aAction;
 }
 
 
@@ -481,3 +488,20 @@ void PartSet_MenuMgr::onEdit(bool)
   if (aFeature.get() != NULL)
     myModule->editFeature(aFeature);
 }
+
+void PartSet_MenuMgr::onSelectParentFeature()
+{
+  QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects();
+  if (aObjects.size() != 1)
+    return;
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>( aObjects.first() );
+  if( !aResult.get() )
+    return;
+
+  FeaturePtr aParentFeature = aResult->document()->feature( aResult );
+  QObjectPtrList aSelection;
+  aSelection.append( aParentFeature );
+  myModule->workshop()->selection()->setSelectedObjects( aSelection );
+}