]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #649: selection of the "parent" feature
authorasl <asl@opencascade.com>
Fri, 14 Aug 2015 11:33:21 +0000 (14:33 +0300)
committerasl <asl@opencascade.com>
Fri, 14 Aug 2015 11:33:21 +0000 (14:33 +0300)
src/ModuleBase/ModuleBase_ISelection.h
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_MenuMgr.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h

index ffe5e389f64c3e129e40803a6e23051c8d447592..a64335b8311cffa4fad7e8231f712b46f3096ed0 100644 (file)
@@ -60,6 +60,8 @@ class ModuleBase_ISelection
    */
   virtual QObjectPtrList selectedObjects() const = 0;
 
+  virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
+
   /**
    * Returns list of currently selected results
    */
index c5ad640cbfc728b4feb850051c3a03585ba2b3c0..9b5919c20d411df18d759c8cbe87ccc36781c5ee 100644 (file)
@@ -88,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;
 }
 
 
@@ -483,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 );
+}
index b31493dcddf59f4103ff4e0f5bee3933e59f96d8..865bbccdc58ff83d5aba681721177006211ec6ad 100644 (file)
@@ -73,6 +73,8 @@ private slots:
   /// A slot called on edit of feature
   void onEdit(bool);
 
+  void onSelectParentFeature();
+
 private:
   /// Returns true if the current operation is sketch entity create operation
   /// \param theValue the current auxiliary value
index 96083adb9213cff98f7a196af56a0bf18ce5f64c..8541f89227403eee0f313f4183051c103262ed18 100644 (file)
@@ -829,6 +829,12 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
         if (hasParameter || hasFeature)
           theMenu->addAction(myMenuMgr->action("EDIT_CMD"));
       }
+
+      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+      if( aResult.get() )
+      {
+        theMenu->addAction(myMenuMgr->action("SELECT_PARENT_CMD"));
+      }
     } else {  // If feature is 0 the it means that selected root object (document)
       if (aMgr->activeDocument() != aMgr->moduleDocument())
         theMenu->addAction(myMenuMgr->action("ACTIVATE_PARTSET_CMD"));
index cd7379944763add298976d7252fd582007d2476d..27a3f18c2d0006089dce5ad343416bcbb765b39b 100644 (file)
@@ -165,6 +165,11 @@ QObjectPtrList XGUI_Selection::selectedObjects() const
   return myWorkshop->objectBrowser()->selectedObjects();
 }
 
+void XGUI_Selection::setSelectedObjects( const QObjectPtrList& theObjects ) const
+{
+  return myWorkshop->objectBrowser()->setObjectsSelected( theObjects );
+}
+
 QObjectPtrList XGUI_Selection::selectedPresentations() const
 {
   QObjectPtrList aSelectedList;
index a768c132be95b1ca1a4e2e1c9a0cb4e4dc699573..5e4b672bc7b09a5419251749045322611eb28f6e 100644 (file)
@@ -53,6 +53,8 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
    */
   virtual QObjectPtrList selectedObjects() const;
 
+  virtual void setSelectedObjects( const QObjectPtrList& ) const;
+
   /**
    * Returns list of currently selected results
    */