From: nds Date: Mon, 6 Jul 2015 13:09:45 +0000 (+0300) Subject: Issue #660 Move Group is still not implemented X-Git-Tag: V_1.3.0~97 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=109611fcd212b3fae262b1fe231388c1cf21fabc;p=modules%2Fshaper.git Issue #660 Move Group is still not implemented --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index dac0f4625..bd1f2012f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8bbf783e3..2614975ff 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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(aObj); + if (aFeature.get()) { + anActiveDocument->moveFeature(aFeature, aCurrentFeature); + aCurrentFeature = anActiveDocument->currentFeature(true); + } + } + aMgr->finishOperation(); +} + //************************************************************** bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList, const std::set& theIgnoredFeatures, diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index d10d3b729..79abe20b9 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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;