]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #660 Move Group is still not implemented
authornds <natalia.donis@opencascade.com>
Mon, 6 Jul 2015 13:09:45 +0000 (16:09 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 6 Jul 2015 13:10:12 +0000 (16:10 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index dac0f4625ee444c6b1e152026576d778e892021c..bd1f2012fab765c247f8aebe29090346f04bdc2e 100644 (file)
@@ -54,6 +54,9 @@ void XGUI_ContextMenuMgr::createActions()
   aAction->setShortcut(Qt::Key_Delete);
   aAction->setShortcutContext(Qt::ApplicationShortcut);
 
+  aAction = new QAction(QIcon(":pictures/move.png"), tr("Move..."), this);
+  addAction("MOVE_CMD", aAction);
+
   aAction = new QAction(QIcon(":pictures/color.png"), tr("Color..."), this);
   addAction("COLOR_CMD", aAction);
 
@@ -197,6 +200,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
     }
     if (hasFeature || hasParameter)
       action("DELETE_CMD")->setEnabled(true);
+
+    if (hasFeature || hasParameter)
+      action("MOVE_CMD")->setEnabled(true);
   }
   if (myWorkshop->canChangeColor())
     action("COLOR_CMD")->setEnabled(true);
@@ -286,6 +292,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   // Feature menu
   aList.clear();
   aList.append(action("DELETE_CMD"));
+  aList.append(action("MOVE_CMD"));
   myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
   myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
   //-------------------------------------
@@ -341,6 +348,7 @@ QMenu* XGUI_ContextMenuMgr::objBrowserMenu() const
       aActions.append(action("SHOW_ONLY_CMD"));
       aActions.append(mySeparator);
       aActions.append(action("DELETE_CMD"));
+      aActions.append(action("MOVE_CMD"));
   }
   aMenu->addActions(aActions);
 
index 8bbf783e39c08ed9978adba884b1a71347e0eb1d..2614975ff2cc7627f739089299de12cc426cfb91 100644 (file)
@@ -965,6 +965,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
   QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
   if (theId == "DELETE_CMD")
     deleteObjects();
+  if (theId == "MOVE_CMD")
+    moveObjects();
   else if (theId == "COLOR_CMD")
     changeColor(aObjects);
   else if (theId == "SHOW_CMD")
@@ -1043,6 +1045,31 @@ void XGUI_Workshop::deleteObjects()
   }
 }
 
+//**************************************************************
+void XGUI_Workshop::moveObjects()
+{
+  if (!isActiveOperationAborted())
+    return;
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+
+  QString aDescription = contextMenuMgr()->action("MOVE_CMD")->text();
+  aMgr->startOperation(aDescription.toStdString());
+
+  QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
+  DocumentPtr anActiveDocument = aMgr->activeDocument();
+
+  FeaturePtr aCurrentFeature = anActiveDocument->currentFeature(true);
+  foreach (ObjectPtr aObj, anObjects) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    if (aFeature.get()) {
+      anActiveDocument->moveFeature(aFeature, aCurrentFeature);
+      aCurrentFeature = anActiveDocument->currentFeature(true);
+    }
+  }
+  aMgr->finishOperation();
+}
+
 //**************************************************************
 bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList,
                                    const std::set<FeaturePtr>& theIgnoredFeatures,
index d10d3b729ea6cf7b6cac98f8c3f257d70c351d49..79abe20b902c0bb808a765e95119e561818d0ffe 100644 (file)
@@ -163,6 +163,9 @@ Q_OBJECT
   //! Delete features
   void deleteObjects();
 
+  //! Move selected features to be after the current feature
+  void moveObjects();
+
   //! Returns true if there is at least one selected body/construction/group result
   //! \return boolean value
   bool canChangeColor() const;