/// Realizes some functionality by an operation start\r
virtual ModuleBase_Operation* currentOperation() const = 0;\r
\r
- /// Add menu items for viewer into the given menu\r
- /// \param theMenu a popup menu to be shown in the viewer\r
+ /// Add menu items for viewer into the actions map\r
/// \param theStdActions a map of standard actions\r
+ /// \param theMenuActions map of action/menu for the desirable index in the viewer menu\r
/// \return true if items are added and there is no necessity to provide standard menu\r
- virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const\r
+ virtual bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,\r
+ QWidget* theParent,\r
+ QMap<int, QAction*>& theMenuActions) const\r
{ return false; }\r
\r
/// Add menu items for object browser into the given menu\r
}
}
-bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
+bool PartSet_MenuMgr::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
+ QWidget* theParent,
+ QMap<int, QAction*>& theMenuActions) const
{
+ int anIndex = 0;
+
ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
!PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
bool hasFeature = false;
QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
- ResultPtr aResult;
- FeaturePtr aFeature;
- foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
- if (aResult.get() != NULL) {
- const GeomShapePtr& aShape = aPrs->shape();
- if (aShape.get() && aShape->isEqual(aResult->shape()))
- hasFeature = true;
- else
- hasAttribute = true;
- } else {
- aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
- hasFeature = (aFeature.get() != NULL);
+ if (aPrsList.size() > 1) {
+ hasFeature = true;
+ } else if (aPrsList.size() == 1) {
+ ResultPtr aResult;
+ FeaturePtr aFeature;
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
+ if (aResult.get() != NULL) {
+ const GeomShapePtr& aShape = aPrs->shape();
+ if (aShape.get() && aShape->isEqual(aResult->shape()))
+ hasFeature = true;
+ else
+ hasAttribute = true;
+ } else {
+ aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
+ hasFeature = (aFeature.get() != NULL);
+ }
}
- }
- if (aPrsList.size() == 1) {
const GeomShapePtr& aShape = aPrsList.first()->shape();
if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) {
// Find 2d coordinates
SketchPlugin_ConstraintCoincidence::ENTITY_B());
if (myCoinsideLines.size() > 0) {
aIsDetach = true;
- QMenu* aSubMenu = theMenu->addMenu(tr("Detach"));
+ QMenu* aSubMenu = new QMenu(tr("Detach"), theParent);
+ theMenuActions[anIndex++] = aSubMenu->menuAction();
QAction* aAction;
int i = 0;
foreach (FeaturePtr aCoins, myCoinsideLines) {
}
}
}
- if ((!aIsDetach) && hasFeature) {
- theMenu->addAction(theStdActions["DELETE_CMD"]);
+ if (!hasAttribute) {
+ bool isAuxiliary;
+ if (canSetAuxiliary(isAuxiliary)) {
+ QAction* anAction = action("AUXILIARY_CMD");
+ theMenuActions[anIndex++] = anAction;
+ anAction->setChecked(isAuxiliary);
+ }
}
- if (hasAttribute)
- return true;
- bool isAuxiliary;
- if (canSetAuxiliary(isAuxiliary)) {
- QAction* anAction = action("AUXILIARY_CMD");
- theMenu->addAction(anAction);
- anAction->setChecked(isAuxiliary);
+
+ if (!aIsDetach && hasFeature) {
+ // Delete item should be the last in the list of actions
+ theMenuActions[1000] = theStdActions["DELETE_CMD"];
}
+
return true;
}
/// \param theId an action identifier, it should be uniqued in the bounds of the module
QAction* action(const QString& theId) const;
- /// Add menu atems for viewer into the given menu
- /// \param theMenu a popup menu to be shown in the viewer
+ /// Add menu items for viewer into the actions map
/// \param theStdActions a map of standard actions
+ /// \param theParent a parent widget for the
+ /// \param theMenuActions map of action/menu for the desirable index in the viewer menu
/// \return true if items are added and there is no necessity to provide standard menu
- bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
+ bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
+ QWidget* theParent,
+ QMap<int, QAction*>& theMenuActions) const;
/// Update state of pop-up menu items in viewer
/// \param theStdActions - a map of standard actions
return aCanActivate;
}
-bool PartSet_Module::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
+bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
+ QWidget* theParent,
+ QMap<int, QAction*>& theMenuActions) const
{
- return myMenuMgr->addViewerMenu(theMenu, theStdActions);
+ return myMenuMgr->addViewerMenu(theStdActions, theParent, theMenuActions);
}
void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
/// \param theMenu a popup menu to be shown in the object browser
virtual void addObjectBrowserMenu(QMenu* theMenu) const;
- /// Add menu atems for viewer into the given menu
- /// \param theMenu a popup menu to be shown in the viewer
+ /// Add menu items for viewer into the actions map
/// \param theStdActions a map of standard actions
+ /// \param theMenuActions map of action/menu for the desirable index in the viewer menu
/// \return true if items are added and there is no necessity to provide standard menu
- virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
+ virtual bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
+ QWidget* theParent,
+ QMap<int, QAction*>& theMenuActions) const;
/// Returns a list of modes, where the AIS objects should be activated
/// \param theModes a list of modes
aList.clear();
aList.append(action("WIREFRAME_CMD"));
aList.append(action("SHADING_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator); // this separator is not shown as this action is added after show only
+ // qt list container contains only one instance of the same action
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
{
- ModuleBase_IModule* aModule = myWorkshop->module();
- if (aModule) {
- if (aModule->addViewerMenu(theMenu, myActions))
- theMenu->addSeparator();
- }
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
int aSelected = aPrsList.size();
if (myViewerMenu.contains(aName))
aActions = myViewerMenu[aName];
}
- aActions.append(action("COLOR_CMD"));
} else if (aSelected > 1) {
aActions.append(action("HIDE_CMD"));
- aActions.append(action("COLOR_CMD"));
}
// hide all is shown always even if selection in the viewer is empty
aActions.append(action("HIDEALL_CMD"));
+ aActions.append(action("COLOR_CMD"));
+
theMenu->addActions(aActions);
+ QMap<int, QAction*> aMenuActions;
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule) {
+ if (aModule->addViewerMenu(myActions, theMenu, aMenuActions))
+ theMenu->addSeparator();
+ }
+
+ // insert the module menu items on specific positions in the popup menu: some actions should be
+ // in the begin of the list, Delete action should be the last by #1343 issue
+ QList<QAction*> anActions = theMenu->actions();
+ int anActionsSize = anActions.size();
+ QAction* aFirstAction = anActions[0];
+ QMap<int, QAction*>::const_iterator anIt = aMenuActions.begin(), aLast = aMenuActions.end();
+ for (; anIt != aLast; anIt++) {
+ if (anIt.key() > anActionsSize)
+ theMenu->addAction(anIt.value());
+ else
+ theMenu->insertAction(aFirstAction, *anIt);
+ }
+
#ifndef HAVE_SALOME
theMenu->addSeparator();
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
//#define DEBUG_RESULT_COMPSOLID
#ifdef DEBUG_FEATURE_REDISPLAY
-const std::string DebugFeatureKind = "Extrusion";
+const std::string DebugFeatureKind = "";//"Extrusion";
#endif
XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
if (aFeature.get()) {
std::string aKind = aFeature->getKind();
- if (aKind == DebugFeatureKind) {
+ if (aKind == DebugFeatureKind || DebugFeatureKind.empty()) {
qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
.arg(aHide).arg(anObjInfo).toStdString().c_str());
}