Salome HOME
projects
/
modules
/
shaper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
1. Mirror/Rotation/Translation constraint: using RefList instead of SelectionList
[modules/shaper.git]
/
src
/
XGUI
/
XGUI_ContextMenuMgr.cpp
diff --git
a/src/XGUI/XGUI_ContextMenuMgr.cpp
b/src/XGUI/XGUI_ContextMenuMgr.cpp
index 8da4ebda28455e529d251aa028209ec78aff7918..8557a43f972489ffbb5c490282131b11e69f11b6 100644
(file)
--- a/
src/XGUI/XGUI_ContextMenuMgr.cpp
+++ b/
src/XGUI/XGUI_ContextMenuMgr.cpp
@@
-54,6
+54,10
@@
void XGUI_ContextMenuMgr::createActions()
aAction->setShortcut(Qt::Key_Delete);
aAction->setShortcutContext(Qt::ApplicationShortcut);
aAction->setShortcut(Qt::Key_Delete);
aAction->setShortcutContext(Qt::ApplicationShortcut);
+ aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
+ addAction("RENAME_CMD", aAction);
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRename()));
+
aAction = new QAction(QIcon(":pictures/move.png"), tr("Move..."), this);
addAction("MOVE_CMD", aAction);
aAction = new QAction(QIcon(":pictures/move.png"), tr("Move..."), this);
addAction("MOVE_CMD", aAction);
@@
-129,13
+133,13
@@
void XGUI_ContextMenuMgr::updateCommandsStatus()
void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
{
void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
{
- QMenu* aMenu =
0
;
+ QMenu* aMenu =
new QMenu()
;
if (sender() == myWorkshop->objectBrowser()) {
updateObjectBrowserMenu();
if (sender() == myWorkshop->objectBrowser()) {
updateObjectBrowserMenu();
- a
Menu = objBrowserMenu(
);
+ a
ddObjBrowserMenu(aMenu
);
} else if (sender() == myWorkshop->viewer()) {
updateViewerMenu();
} else if (sender() == myWorkshop->viewer()) {
updateViewerMenu();
- a
Menu = viewerMenu(
);
+ a
ddViewerMenu(aMenu
);
}
if (aMenu && (aMenu->actions().size() > 0)) {
}
if (aMenu && (aMenu->actions().size() > 0)) {
@@
-163,7
+167,8
@@
void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
bool hasResult = false;
bool hasFeature = false;
bool hasParameter = false;
bool hasResult = false;
bool hasFeature = false;
bool hasParameter = false;
- ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter);
+ bool hasSubFeature = false;
+ ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, hasSubFeature);
//Process Feature
if (aSelected == 1) {
//Process Feature
if (aSelected == 1) {
@@
-180,16
+185,17
@@
void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
action("SHOW_CMD")->setEnabled(true);
}
action("SHOW_CMD")->setEnabled(true);
}
- ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
- if (aPartRes) {
- action("SHOW_CMD")->setEnabled(true);
- }
-
if (!(hasParameter || hasFeature))
action("SHOW_ONLY_CMD")->setEnabled(true);
}
else if (hasFeature && myWorkshop->canMoveFeature())
action("MOVE_CMD")->setEnabled(true);
if (!(hasParameter || hasFeature))
action("SHOW_ONLY_CMD")->setEnabled(true);
}
else if (hasFeature && myWorkshop->canMoveFeature())
action("MOVE_CMD")->setEnabled(true);
+
+ if( aMgr->activeDocument() == aObject->document() )
+ {
+ action("RENAME_CMD")->setEnabled(true);
+ action("DELETE_CMD")->setEnabled(true);
+ }
}
} else {
if (hasResult && (!hasParameter)) {
}
} else {
if (hasResult && (!hasParameter)) {
@@
-200,11
+206,24
@@
void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
action("WIREFRAME_CMD")->setEnabled(true);
}
}
action("WIREFRAME_CMD")->setEnabled(true);
}
}
- if (hasFeature || hasParameter)
- action("DELETE_CMD")->setEnabled(true);
+ bool allActive = true;
+ foreach( ObjectPtr aObject, aObjects )
+ if( aMgr->activeDocument() != aObject->document() )
+ {
+ allActive = false;
+ break;
+ }
+ if (!hasSubFeature && allActive ) {
+ if (hasFeature || hasParameter)
+ action("DELETE_CMD")->setEnabled(true);
+ }
}
if (myWorkshop->canChangeColor())
action("COLOR_CMD")->setEnabled(true);
}
if (myWorkshop->canChangeColor())
action("COLOR_CMD")->setEnabled(true);
+
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aModule->updateObjectBrowserMenu(myActions);
}
void XGUI_ContextMenuMgr::updateViewerMenu()
}
void XGUI_ContextMenuMgr::updateViewerMenu()
@@
-213,13
+232,14
@@
void XGUI_ContextMenuMgr::updateViewerMenu()
aAction->setEnabled(false);
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
aAction->setEnabled(false);
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- Q
ObjectPtrList aObjects = aSelMgr->selection()->selectedObjects(
);
- if (a
Objects
.size() > 0) {
+ Q
List<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer
);
+ if (a
PrsList
.size() > 0) {
bool isVisible = false;
bool isShading = false;
bool canBeShaded = false;
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;
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aRes && aRes->isDisplayed()) {
isVisible = true;
@@
-244,6
+264,10
@@
void XGUI_ContextMenuMgr::updateViewerMenu()
action("COLOR_CMD")->setEnabled(true);
action("DELETE_CMD")->setEnabled(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()
}
void XGUI_ContextMenuMgr::connectObjectBrowser()
@@
-271,9
+295,9
@@
void XGUI_ContextMenuMgr::buildObjBrowserMenu()
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
aList.append(action("COLOR_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
- // Result part menu
- myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
//-------------------------------------
// Result body menu
aList.clear();
//-------------------------------------
// Result body menu
aList.clear();
@@
-284,18
+308,26
@@
void XGUI_ContextMenuMgr::buildObjBrowserMenu()
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
// Group menu
myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
// Group menu
myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
+ // Result part menu
+ myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
//-------------------------------------
// Feature menu
aList.clear();
aList.append(action("DELETE_CMD"));
aList.append(action("MOVE_CMD"));
//-------------------------------------
// Feature menu
aList.clear();
aList.append(action("DELETE_CMD"));
aList.append(action("MOVE_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
aList.clear();
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
aList.clear();
aList.append(action("DELETE_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
//-------------------------------------
}
myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
//-------------------------------------
}
@@
-329,9
+361,8
@@
void XGUI_ContextMenuMgr::buildViewerMenu()
}
}
-
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();
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
int aSelected = aObjects.size();
@@
-352,49
+383,46
@@
QMenu* XGUI_ContextMenuMgr::objBrowserMenu() const
aActions.append(action("DELETE_CMD"));
//aActions.append(action("MOVE_CMD"));
}
aActions.append(action("DELETE_CMD"));
//aActions.append(action("MOVE_CMD"));
}
-
a
Menu->addActions(aActions);
+
the
Menu->addActions(aActions);
ModuleBase_IModule* aModule = myWorkshop->module();
if (aModule) {
ModuleBase_IModule* aModule = myWorkshop->module();
if (aModule) {
-
a
Menu->addSeparator();
- aModule->addObjectBrowserMenu(
a
Menu);
+
the
Menu->addSeparator();
+ aModule->addObjectBrowserMenu(
the
Menu);
}
}
- 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();
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();
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- Q
ObjectPtrList aObjects = aSelMgr->selection()->selectedObjects(
);
- int aSelected = a
Objects
.size();
+ Q
List<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer
);
+ int aSelected = a
PrsList
.size();
QActionsList aActions;
if (aSelected == 1) {
QActionsList aActions;
if (aSelected == 1) {
- ObjectPtr aObject = a
Objects.firs
t();
+ ObjectPtr aObject = a
PrsList.first().objec
t();
std::string aName = aObject->groupName();
if (myViewerMenu.contains(aName))
aActions = myViewerMenu[aName];
} else if (aSelected > 1) {
aActions.append(action("HIDE_CMD"));
}
std::string aName = aObject->groupName();
if (myViewerMenu.contains(aName))
aActions = myViewerMenu[aName];
} else if (aSelected > 1) {
aActions.append(action("HIDE_CMD"));
}
-
a
Menu->addActions(aActions);
+
the
Menu->addActions(aActions);
if (!myWorkshop->isSalomeMode()) {
if (!myWorkshop->isSalomeMode()) {
-
a
Menu->addSeparator();
+
the
Menu->addSeparator();
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
if (aMDI->actions().size() > 0) {
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
if (aMDI->actions().size() > 0) {
- QMenu* aSubMenu =
a
Menu->addMenu(tr("Windows"));
+ QMenu* aSubMenu =
the
Menu->addMenu(tr("Windows"));
aSubMenu->addActions(aMDI->actions());
}
}
aSubMenu->addActions(aMDI->actions());
}
}
- return aMenu;
}
QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
}
QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
@@
-417,3
+445,8
@@
QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
}
return aGroups;
}
}
return aGroups;
}
+
+void XGUI_ContextMenuMgr::onRename()
+{
+ myWorkshop->objectBrowser()->onEditItem();
+}