bool hasAttribute = false;
bool hasFeature = false;
- QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::AllControls);
+ QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
TopoDS_Shape aShape;
ResultPtr aResult;
FeaturePtr aFeature;
return true;
}
+void PartSet_MenuMgr::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
+{
+ ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
+
+ bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
+ PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
+ if (isActiveSketch) {
+ theStdActions["WIREFRAME_CMD"]->setEnabled(false);
+ theStdActions["SHADING_CMD"]->setEnabled(false);
+ theStdActions["SHOW_ONLY_CMD"]->setEnabled(false);
+ theStdActions["SHOW_CMD"]->setEnabled(false);
+ theStdActions["HIDE_CMD"]->setEnabled(false);
+ theStdActions["HIDEALL_CMD"]->setEnabled(false);
+ }
+}
+
+
void PartSet_MenuMgr::onLineHighlighted(QAction* theAction)
{
if (myPrevId != -1) {
void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
{
- QMenu* aMenu = 0;
+ QMenu* aMenu = new QMenu();
if (sender() == myWorkshop->objectBrowser()) {
updateObjectBrowserMenu();
- aMenu = objBrowserMenu();
+ addObjBrowserMenu(aMenu);
} else if (sender() == myWorkshop->viewer()) {
updateViewerMenu();
- aMenu = viewerMenu();
+ addViewerMenu(aMenu);
}
if (aMenu && (aMenu->actions().size() > 0)) {
}
if (myWorkshop->canChangeColor())
action("COLOR_CMD")->setEnabled(true);
+
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aModule->updateObjectBrowserMenu(myActions);
}
void XGUI_ContextMenuMgr::updateViewerMenu()
aAction->setEnabled(false);
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
- if (aObjects.size() > 0) {
+ QList<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ if (aPrsList.size() > 0) {
bool isVisible = false;
bool isShading = false;
bool canBeShaded = false;
- foreach(ObjectPtr aObject, aObjects)
- {
+ ObjectPtr aObject;
+ foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
+ aObject = aPrs.object();
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aRes && aRes->isDisplayed()) {
isVisible = true;
action("COLOR_CMD")->setEnabled(true);
action("DELETE_CMD")->setEnabled(true);
+
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aModule->updateViewerMenu(myActions);
}
void XGUI_ContextMenuMgr::connectObjectBrowser()
}
-QMenu* XGUI_ContextMenuMgr::objBrowserMenu() const
+void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
{
- QMenu* aMenu = new QMenu();
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
int aSelected = aObjects.size();
aActions.append(action("DELETE_CMD"));
//aActions.append(action("MOVE_CMD"));
}
- aMenu->addActions(aActions);
+ theMenu->addActions(aActions);
ModuleBase_IModule* aModule = myWorkshop->module();
if (aModule) {
- aMenu->addSeparator();
- aModule->addObjectBrowserMenu(aMenu);
+ theMenu->addSeparator();
+ aModule->addObjectBrowserMenu(theMenu);
}
- aMenu->addSeparator();
- aMenu->addActions(myWorkshop->objectBrowser()->actions());
-
- return aMenu;
+ theMenu->addSeparator();
+ theMenu->addActions(myWorkshop->objectBrowser()->actions());
}
-QMenu* XGUI_ContextMenuMgr::viewerMenu() const
+void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
{
- QMenu* aMenu = new QMenu();
ModuleBase_IModule* aModule = myWorkshop->module();
- if (aModule)
- aModule->addViewerMenu(aMenu, myActions);
-
+ if (aModule) {
+ if (aModule->addViewerMenu(theMenu, myActions))
+ theMenu->addSeparator();
+ }
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
- int aSelected = aObjects.size();
+ QList<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ int aSelected = aPrsList.size();
QActionsList aActions;
if (aSelected == 1) {
- ObjectPtr aObject = aObjects.first();
+ ObjectPtr aObject = aPrsList.first().object();
std::string aName = aObject->groupName();
if (myViewerMenu.contains(aName))
aActions = myViewerMenu[aName];
} else if (aSelected > 1) {
aActions.append(action("HIDE_CMD"));
}
- aMenu->addActions(aActions);
+ theMenu->addActions(aActions);
if (!myWorkshop->isSalomeMode()) {
- aMenu->addSeparator();
+ theMenu->addSeparator();
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
if (aMDI->actions().size() > 0) {
- QMenu* aSubMenu = aMenu->addMenu(tr("Windows"));
+ QMenu* aSubMenu = theMenu->addMenu(tr("Windows"));
aSubMenu->addActions(aMDI->actions());
}
}
- return aMenu;
}
QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
/// Connect to viewer from workshop. Has to called at creation of viewer.
void connectViewer();
- QMenu* objBrowserMenu() const;
- QMenu* viewerMenu() const;
+ void addObjBrowserMenu(QMenu*) const;
+ void addViewerMenu(QMenu*) const;
/// Returns a list of object group names of the action
/// \param theName a name of the action
/// \return a list of group names
QStringList actionObjectGroups(const QString& theName);
+ /// Updates menu for viewer
+ void updateViewerMenu();
+
signals:
/// Signal aabout triggered action
/// \param theId an id of triggered action
/// Updates menu for object browser
void updateObjectBrowserMenu();
- /// Updates menu for viewer
- void updateViewerMenu();
-
/// Creates menu for object browser
void buildObjBrowserMenu();