Salome HOME
Copyright update 2022
[modules/paravis.git] / src / PVGUI / PVGUI_Module_actions.cxx
index 6af1403796b5be136e90857d31d1894869eec414..9b328237c8a347219df8abc4f9d654bf5d33adc2 100644 (file)
@@ -1,6 +1,6 @@
 // PARAVIS : ParaView wrapper SALOME module
 //
-// Copyright (C) 2010-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2010-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,8 @@
 //
 
 #include "PVGUI_Module.h"
+#include <PVViewer_GUIElements.h>
+#include <PVViewer_ViewManager.h>
 
 #include <QtxAction.h>
 #include <QtxActionMenuMgr.h>
@@ -30,7 +32,6 @@
 #include <SUIT_Desktop.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
-#include <SalomeApp_Application.h>
 #include <LightApp_Application.h>
 
 #include <QAction>
 #include <QFile>
 
 #include <pqApplicationCore.h>
-#include <pqColorScaleToolbar.h>
-#include <pqProgressManager.h>
-#include <pqRubberBandHelper.h>
-#include <pqScalarBarVisibilityAdaptor.h>
-#include <pqUndoStack.h>
-#include <pqVCRController.h>
 
 #include <pqSaveStateReaction.h>
 #include <pqLoadDataReaction.h>
 #include <pqDeleteReaction.h>
 #include <pqChangePipelineInputReaction.h>
 #include <pqApplicationSettingsReaction.h>
-#include <pqViewSettingsReaction.h>
 #include <pqIgnoreSourceTimeReaction.h>
-#include <pqViewMenuManager.h>
-#include <pqParaViewMenuBuilders.h>
-#include <pqProxyGroupMenuManager.h>
 #include <pqCreateCustomFilterReaction.h>
 #include <pqManageLinksReaction.h>
 #include <pqManagePluginsReaction.h>
 #include <pqCameraLinkReaction.h>
 #include <pqManageCustomFiltersReaction.h>
-#include <pqSetName.h>
-#include <pqPythonShellReaction.h>
 #include <pqTimerLogReaction.h>
 #include <pqTestingReaction.h>
 #include <pqAboutDialogReaction.h>
 #include <pqHelpReaction.h>
-#include <pqViewManager.h>
 #include <pqDataQueryReaction.h>
-#include <pqRecentFilesMenu.h>
-
-#include "PVGUI_Tools.h"
+//#include <pqPythonShellReaction.h>
 
+#include <pqViewManager.h>
+#include <pqViewMenuManager.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqProxyGroupMenuManager.h>
+#include <pqSetName.h>
+#include <pqRecentFilesMenu.h>
+#include <pqPipelineBrowserWidget.h>
 
 /*!
   \brief Create actions for ParaView GUI operations
@@ -95,7 +88,6 @@ void PVGUI_Module::pvCreateActions()
 
   QPixmap aPixmap;
   QAction* anAction;
-  //QtxAction* aQtxAction;
   
   // --- Menu "File"
 
@@ -255,11 +247,11 @@ void PVGUI_Module::pvCreateActions()
   new pqApplicationSettingsReaction(anAction);*/
   
   // View Settings
-  anAction = new QAction(tr("MEN_VIEW_SETTINGS"), this);
-  anAction->setToolTip(tr("TOP_VIEW_SETTINGS"));
-  anAction->setStatusTip(tr("STB_VIEW_SETTINGS"));
-  registerAction(ViewSettingsId, anAction);
-  new pqViewSettingsReaction(anAction);
+//  anAction = new QAction(tr("MEN_VIEW_SETTINGS"), this);
+//  anAction->setToolTip(tr("TOP_VIEW_SETTINGS"));
+//  anAction->setStatusTip(tr("STB_VIEW_SETTINGS"));
+//  registerAction(ViewSettingsId, anAction);
+//  new pqViewSettingsReaction(anAction);
 
   // --- Menu "View"
   //pqViewManager* viewManager = qobject_cast<pqViewManager*>(
@@ -351,20 +343,17 @@ void PVGUI_Module::pvCreateActions()
   registerAction(TimerLogId, anAction);
   new pqTimerLogReaction(anAction << pqSetName("actionToolsTimerLog"));
 
-  // Output Window
-  anAction = new QAction(tr("MEN_OUTPUT_WINDOW"), this);
-  anAction->setToolTip(tr("TOP_OUTPUT_WINDOW"));
-  anAction->setStatusTip(tr("STB_OUTPUT_WINDOW"));
-  registerAction(OutputWindowId, anAction);
-  anAction << pqSetName("actionToolsOutputWindow");
-  connect(anAction, SIGNAL(triggered()), pqApplicationCore::instance(), SLOT(showOutputWindow()));
-  
- // Python Shell
+  // Python Shell
+  // ???
+  // No more pqPythonShellReaction class, but there is a pqPythonShell class.
+  // Is that equivalent? I don't know what to do at this stage.
   anAction = new QAction(tr("MEN_PYTHON_SHELL"), this);
   anAction->setToolTip(tr("TOP_PYTHON_SHELL"));
   anAction->setStatusTip(tr("STB_PYTHON_SHELL"));
   registerAction(PythonShellId, anAction);
+  /*
   new pqPythonShellReaction(anAction << pqSetName("actionToolsPythonShell"));
+  */
 
   //Show Trace
   anAction = new QAction(tr("MEN_SHOW_TRACE"), this);
@@ -373,7 +362,7 @@ void PVGUI_Module::pvCreateActions()
   connect(anAction, SIGNAL(triggered()), this, SLOT(onShowTrace()));
   registerAction(ShowTraceId, anAction);
 
-  //Show Trace
+  //Restart Trace
   anAction = new QAction(tr("MEN_RESTART_TRACE"), this);
   anAction->setToolTip(tr("TOP_RESTART_TRACE"));
   anAction->setStatusTip(tr("STB_RESTART_TRACE"));
@@ -420,12 +409,10 @@ void PVGUI_Module::pvCreateMenus()
   // Recent Files
    myRecentMenuId = createMenu( tr( "MEN_RECENT_FILES" ), aPVMnu, -1, 5 );
    QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
-   pqRecentFilesMenu* aRecentFilesMenu = new pqRecentFilesMenu( *aMenu, getApp()->desktop() );
+   /*pqRecentFilesMenu* aRecentFilesMenu = */new pqRecentFilesMenu( *aMenu, getApp()->desktop() );
    QList<QAction*> anActns = aMenu->actions();
-   for (int i = 0; i < anActns.size(); ++i) {
-       createMenu( anActns.at(i), myRecentMenuId );
-   }
-
+   for (int i = 0; i < anActns.size(); ++i)
+     createMenu( anActns.at(i), myRecentMenuId );
 
   createMenu( separator(), aPVMnu, -1, 5 );
 
@@ -465,46 +452,31 @@ void PVGUI_Module::pvCreateMenus()
   createMenu( separator(), aPVMnu );
 
   //createMenu( SettingsId, aPVMnu );
-  createMenu( ViewSettingsId, aPVMnu );
+  //createMenu( ViewSettingsId, aPVMnu );
   createMenu( separator(), aPVMnu );
 
   // --- Menu "View"
   aPVMnu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1 );
-  /*myToolbarsMenuId = createMenu( "Toolbars", aPVMnu );
-  aMenu = getMenu( myToolbarsMenuId );
-  if (aMenu) {
-    buildToolbarsMenu();
-    connect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu()));
-  }
-  createMenu( separator(), aPVMnu );*/
 
   createMenu( FullScreenId, aPVMnu );
   
   // --- Menu "Sources"
-
   // Install ParaView managers for "Sources" menu
   QMenu* aRes = 0;
-  mySourcesMenuId = createMenu( tr( "MEN_DESK_SOURCES" ), -1, -1, 60);
-  if ( (aRes = getMenu( mySourcesMenuId )) ) {
-    pqParaViewMenuBuilders::buildSourcesMenu(*aRes, desk);
-  }
+  PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
+  aRes = guiElements->getSourcesMenu();
+  mySourcesMenuId = createMenu( tr( "MEN_DESK_SOURCES" ), -1, -1, 60, -1, aRes);
   
   // --- Menu "Filters"
-
   // Install ParaView managers for "Filters" menu
-  myFiltersMenuId = createMenu( tr( "MEN_DESK_FILTERS" ), -1, -1, 70 );
-  if ( (aRes = getMenu( myFiltersMenuId )) ) {
-    pqParaViewMenuBuilders::buildFiltersMenu(*aRes, desk);
-  }
+  aRes = guiElements->getFiltersMenu();
+  myFiltersMenuId = createMenu( tr( "MEN_DESK_FILTERS" ), -1, -1, 70, -1, aRes);
 
    // --- Menu "Macros"
-  myMacrosMenuId = createMenu( tr( "MEN_MACROS" ), -1, -1, 80 );
-  if ( (aRes = getMenu( myMacrosMenuId )) ) {
-    pqParaViewMenuBuilders::buildMacrosMenu(*aRes);
-  }
+  aRes = guiElements->getMacrosMenu();
+  myMacrosMenuId = createMenu( tr( "MEN_MACROS" ), -1, -1, 80, -1, aRes);
  
   // --- Menu "Tools"
-
   int aToolsMnu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 90 );
 
   createMenu( CreateCustomFilterId, aToolsMnu );
@@ -522,7 +494,6 @@ void PVGUI_Module::pvCreateMenus()
   createMenu( separator(), aToolsMnu );
 
   createMenu( TimerLogId, aToolsMnu );
-  createMenu( OutputWindowId, aToolsMnu );
   createMenu( separator(), aToolsMnu );
 
   createMenu( PythonShellId, aToolsMnu );
@@ -530,15 +501,24 @@ void PVGUI_Module::pvCreateMenus()
   createMenu( ShowTraceId, aToolsMnu );
   createMenu( RestartTraceId, aToolsMnu );
 
+  // --- Menu "Catalyst"
+  aRes = guiElements->getCatalystMenu();
+  myCatalystMenuId = createMenu( tr( "MEN_DESK_CATALYST" ), -1, -1, 100, -1, aRes);
+
   // --- Menu "Help"
 
   int aHelpMnu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1 );
-  int aPVHelpMnu = createMenu( tr( "ParaViS module" ), aHelpMnu, -1, 0 );
+  int aUsersGuide = createMenu( tr( "User's Guide" ), aHelpMnu, -1 );
+  int aPVHelpMnu = createMenu( tr( "ParaViS module" ), aUsersGuide, -1, 5 );
 #ifdef HAS_PV_DOC
   createMenu( ParaViewHelpId,  aPVHelpMnu );
   createMenu( separator(),     aPVHelpMnu );
 #endif
   createMenu( AboutParaViewId, aPVHelpMnu );
+
+  // -- Context menu in the pipeline browser
+  pqPipelineBrowserWidget * pq = guiElements->getPipelineBrowserWidget();
+  pqParaViewMenuBuilders::buildPipelineBrowserContextMenu( *(pq->contextMenu()) );
 }
 
 /*!
@@ -548,126 +528,7 @@ void PVGUI_Module::pvCreateMenus()
 void PVGUI_Module::pvCreateToolBars()
 {
   SUIT_Desktop* desk = application()->desktop();
-  pqParaViewMenuBuilders::buildToolbars(*desk);
-}
-
-/*!
-  \brief Returns QMenu by its id.
-*/
-QMenu* PVGUI_Module::getMenu( const int id )
-{
-  QMenu* res = 0;
-  SalomeApp_Application* anApp = getApp();
-  SUIT_Desktop* desk = anApp->desktop();
-  if ( desk ){
-    QtxActionMenuMgr* menuMgr = desk->menuMgr();
-    res = menuMgr->findMenu( id );
-  }
-  return res;
-}
-
-/*!
-  \brief Returns list of ParaView toolbars
-*/
-/*QList<QToolBar*> PVGUI_Module::getParaViewToolbars()
-{
-  QList<QToolBar*> all_toolbars = application()->desktop()->findChildren<QToolBar*>();
-  // First two toolbars has to be ignored because they are not from ParaView
-  if (all_toolbars.size() > 2) {
-    all_toolbars.removeFirst();
-    all_toolbars.removeFirst();
-  }
-  return all_toolbars;
-  }*/
-
-
-
-/*!
-  \brief Builds a menu which referred to toolbars
-*/
-/*void PVGUI_Module::buildToolbarsMenu()
-{
-  SUIT_Desktop* desk = application()->desktop();
-  QMenu* aMenu = menuMgr()->findMenu( myToolbarsMenuId );
-  if (aMenu) {
-    aMenu->clear();
-    QList<QMenu*> child_menus = aMenu->findChildren<QMenu*>();
-    foreach (QMenu* menu, child_menus) {
-      delete menu;
-    }
-    QList<QToolBar*> all_toolbars = getParaViewToolbars();
-
-    // Add menus for all toolbars and actions from them.
-    // This puts menu actions for all toolbars making it possible to access all
-    // toolbar actions even when the toolbar are not visible.
-    // I wonder if I should ignore the pqMainControlsToolbar since those actions
-    // are already placed at other places.
-    foreach (QToolBar* toolbar, all_toolbars) {
-      QMenu* sub_menu = new QMenu(aMenu) << pqSetName(toolbar->windowTitle());
-      bool added = false;
-      foreach (QAction* action, toolbar->actions()) {
-        if (!action->text().isEmpty()) {
-          added = true;
-          sub_menu->addAction(action);
-        }
-      }
-      if (added) {
-        QAction* menu_action = aMenu->addMenu(sub_menu);
-        menu_action->setText(toolbar->windowTitle());
-      } else {
-        delete sub_menu;
-      }
-    }
-    disconnect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu()));
-  }
-  }*/
-
-/*!
-  \brief Create actions for ParaViS
-*/
-void PVGUI_Module::createActions()
-{
-  QAction* anAction;
-
-  // New ParaView window
-  anAction = new QtxAction(tr("MEN_NEW_PV_VIEW"), tr("MEN_NEW_PV_VIEW"), 0, 
-                          this, false, "ParaViS:Create new ParaView view");
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onNewParaViewWindow()));
-  registerAction(ParaViewNewWindowId, anAction);
-
-  // Save state under the module root object
-  anAction = new QAction(tr("MEN_SAVE_MULTI_STATE"), this);
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onSaveMultiState()));
-  registerAction(SaveStatePopupId, anAction);
-
-  // Restore the selected state by merging with the current one
-  anAction = new QAction(tr("MEN_ADD_STATE"), this);
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onAddState()));
-  registerAction(AddStatePopupId, anAction);
-
-  // Clean the current state and restore the selected one
-  anAction = new QAction(tr("MEN_CLEAN_ADD_STATE"), this);
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onCleanAddState()));
-  registerAction(CleanAndAddStatePopupId, anAction);
-
-  // Rename the selected object (Object Browser)
-  anAction = new QAction(tr("MEN_PARAVIS_RENAME"), this);
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onRename()));
-  registerAction(ParaVisRenameId, anAction);
-
-  // Delete the selected object (Object Browser)
-  anAction = new QAction(tr("MEN_PARAVIS_DELETE"), this);
-  connect(anAction, SIGNAL(triggered()), this, SLOT(onDelete()));
-  registerAction(ParaVisDeleteId, anAction);
-}
-
-/*!
-  \brief Create actions for ParaViS
-*/
-void PVGUI_Module::createMenus()
-{
-  // "Window" - "New Window" - "ParaView view" menu
-  int aWindowMenu = createMenu(tr( "MEN_DESK_WINDOW" ), -1, -1);
-  int aNewWindowMenu = createMenu(tr( "MEN_DESK_NEWWINDOW"), aWindowMenu, -1, -1);
-  createMenu(ParaViewNewWindowId, aNewWindowMenu);
+//  pqParaViewMenuBuilders::buildToolbars(*desk);
+  PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desk);
+  guiElements->setToolBarVisible(true);
 }