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);
}
if (hasFeature || hasParameter)
action("DELETE_CMD")->setEnabled(true);
+
+ if (hasFeature || hasParameter)
+ action("MOVE_CMD")->setEnabled(true);
}
if (myWorkshop->canChangeColor())
action("COLOR_CMD")->setEnabled(true);
// Feature menu
aList.clear();
aList.append(action("DELETE_CMD"));
+ aList.append(action("MOVE_CMD"));
myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
//-------------------------------------
aActions.append(action("SHOW_ONLY_CMD"));
aActions.append(mySeparator);
aActions.append(action("DELETE_CMD"));
+ aActions.append(action("MOVE_CMD"));
}
aMenu->addActions(aActions);
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")
}
}
+//**************************************************************
+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,
//! 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;