Salome HOME
bb8913b899f0669a4b8e48e62506f003c87e1c00
[modules/paravis.git] / src / PVGUI / PVGUI_Module_actions.cxx
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : PVGUI_Module_MenuActions.cxx
23 // Author : Margarita KARPUNINA
24 //
25
26 #include "PVGUI_Module_impl.h"
27
28 #include <QtxAction.h>
29 #include <QtxActionMenuMgr.h>
30 #include <QtxActionToolMgr.h>
31 #include <SUIT_Desktop.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_Application.h>
36
37 #include <QAction>
38 #include <QMenu>
39 #include <QToolBar>
40
41 #include <pqApplicationCore.h>
42 #include <pqColorScaleToolbar.h>
43 #include <pqProgressManager.h>
44 #include <pqRubberBandHelper.h>
45 #include <pqScalarBarVisibilityAdaptor.h>
46 #include <pqUndoStack.h>
47 #include <pqVCRController.h>
48
49 #include <pqSaveStateReaction.h>
50 #include <pqLoadDataReaction.h>
51 #include <pqLoadStateReaction.h>
52 #include <pqSaveDataReaction.h>
53 #include <pqSaveScreenshotReaction.h>
54 #include <pqExportReaction.h>
55 #include <pqSaveAnimationReaction.h>
56 #include <pqSaveAnimationGeometryReaction.h>
57 #include <pqServerConnectReaction.h>
58 #include <pqServerDisconnectReaction.h>
59 #include <pqCameraUndoRedoReaction.h>
60 #include <pqUndoRedoReaction.h>
61 #include <pqDeleteReaction.h>
62 #include <pqChangePipelineInputReaction.h>
63 #include <pqApplicationSettingsReaction.h>
64 #include <pqViewSettingsReaction.h>
65 #include <pqIgnoreSourceTimeReaction.h>
66 #include <pqViewMenuManager.h>
67 #include <pqParaViewMenuBuilders.h>
68 #include <pqProxyGroupMenuManager.h>
69 #include <pqCreateCustomFilterReaction.h>
70 #include <pqManageLinksReaction.h>
71 #include <pqManagePluginsReaction.h>
72 #include <pqCameraLinkReaction.h>
73 #include <pqManageCustomFiltersReaction.h>
74 #include <pqSetName.h>
75 #include <pqPythonShellReaction.h>
76 #include <pqTimerLogReaction.h>
77 #include <pqTestingReaction.h>
78 #include <pqAboutDialogReaction.h>
79 #include <pqHelpReaction.h>
80 #include <pqViewManager.h>
81
82 #include "PVGUI_Tools.h"
83
84
85 /*!
86   \brief Create actions for ParaView GUI operations
87   duplicating menus and toolbars in MainWindow class of
88   the standard ParaView GUI client application.
89 */
90 void PVGUI_Module::pvCreateActions()
91 {
92   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
93
94   QPixmap aPixmap;
95   QAction* anAction;
96   //QtxAction* aQtxAction;
97   
98   // --- Menu "File"
99
100   // Open File
101   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_OPEN_FILE"), false );
102   anAction = new QAction(QIcon(aPixmap), tr("MEN_OPEN"), this);
103   anAction->setToolTip(tr("TOP_OPEN_FILE"));
104   anAction->setStatusTip(tr("STB_OPEN_FILE"));
105   registerAction(OpenFileId, anAction);
106   new pqLoadDataReaction(anAction);
107   
108   // Load State
109   anAction = new QAction(tr("MEN_LOAD_STATE"), this);
110   anAction->setToolTip(tr("TOP_LOAD_STATE"));
111   anAction->setStatusTip(tr("STB_LOAD_STATE"));
112   registerAction(LoadStateId, anAction);
113   new pqLoadStateReaction(anAction);
114   
115   // Save State
116   anAction = new QAction(tr("MEN_SAVE_STATE"), this);
117   anAction->setToolTip(tr("TOP_SAVE_STATE"));
118   anAction->setStatusTip(tr("STB_SAVE_STATE"));
119   registerAction(SaveStateId, anAction);
120   new pqSaveStateReaction(anAction);
121
122   // Save Data
123   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_DATA"), false );
124   anAction = new QAction(QIcon(aPixmap), tr("MEN_SAVE_DATA"), this);
125   anAction->setToolTip(tr("TOP_SAVE_DATA"));
126   anAction->setStatusTip(tr("STB_SAVE_DATA"));
127   registerAction(SaveDataId, anAction);
128   new pqSaveDataReaction(anAction);
129
130   // Save Screenshot
131   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_SCREENSHOT"), false );
132   anAction = new QAction(QIcon(aPixmap), tr("MEN_SAVE_SCREENSHOT"), this);
133   anAction->setToolTip(tr("TOP_SAVE_SCREENSHOT"));
134   anAction->setStatusTip(tr("STB_SAVE_SCREENSHOT"));
135   registerAction(SaveScreenshotId, anAction);
136   new pqSaveScreenshotReaction(anAction);
137
138   // Export
139   anAction = new QAction(tr("MEN_EXPORT"), this);
140   anAction->setToolTip(tr("TOP_EXPORT"));
141   anAction->setStatusTip(tr("STB_EXPORT"));
142   registerAction(ExportId, anAction);
143   new pqExportReaction(anAction);
144
145   // Save Animation
146   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_ANIMATION"), false );
147   anAction = new QAction(QIcon(aPixmap), tr("MEN_SAVE_ANIMATION"), this);
148   anAction->setToolTip(tr("TOP_SAVE_ANIMATION"));
149   anAction->setStatusTip(tr("STB_SAVE_ANIMATION"));
150   registerAction(SaveAnimationId, anAction);
151   new pqSaveAnimationReaction(anAction);
152
153   // Save Geometry
154   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_GEOMETRY"), false );
155   anAction = new QAction(QIcon(aPixmap), tr("MEN_SAVE_GEOMETRY"), this);
156   anAction->setToolTip(tr("TOP_SAVE_GEOMETRY"));
157   anAction->setStatusTip(tr("STB_SAVE_GEOMETRY"));
158   registerAction(SaveGeometryId, anAction);
159   new pqSaveAnimationGeometryReaction(anAction);
160
161   // Connect
162   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CONNECT"), false );
163   anAction = new QAction(QIcon(aPixmap), tr("MEN_CONNECT"), this);
164   anAction->setToolTip(tr("TOP_CONNECT"));
165   anAction->setStatusTip(tr("STB_CONNECT"));
166   registerAction(ConnectId, anAction);
167   new pqServerConnectReaction(anAction);
168
169   // Disconnect
170   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_DISCONNECT"), false );
171   anAction = new QAction(QIcon(aPixmap), tr("MEN_DISCONNECT"), this);
172   anAction->setToolTip(tr("TOP_DISCONNECT"));
173   anAction->setStatusTip(tr("STB_DISCONNECT"));
174   registerAction(DisconnectId, anAction);
175   new pqServerDisconnectReaction(anAction);
176
177   // --- Menu "Edit"
178
179   // Undo
180   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_UNDO"), false );
181   anAction = new QAction(QIcon(aPixmap), tr("MEN_UNDO"), this);
182   anAction->setToolTip(tr("TOP_UNDO"));
183   anAction->setStatusTip(tr("STB_UNDO"));
184   registerAction(UndoId, anAction);
185   new pqUndoRedoReaction(anAction, true);
186
187   // Redo
188   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_REDO"), false );
189   anAction = new QAction(QIcon(aPixmap), tr("MEN_REDO"), this);
190   anAction->setToolTip(tr("TOP_REDO"));
191   anAction->setStatusTip(tr("STB_REDO"));
192   registerAction(RedoId, anAction);
193   new pqUndoRedoReaction(anAction, false);
194
195   // Camera Undo
196   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CAMERA_UNDO"), false );
197   anAction = new QAction(QIcon(aPixmap), tr("MEN_CAMERA_UNDO"), this);
198   anAction->setToolTip(tr("TOP_CAMERA_UNDO"));
199   anAction->setStatusTip(tr("STB_CAMERA_UNDO"));
200   registerAction(CameraUndoId, anAction);
201   new pqCameraUndoRedoReaction(anAction, true);
202   
203   // Camera Redo
204   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CAMERA_REDO"), false );
205   anAction = new QAction(QIcon(aPixmap), tr("MEN_CAMERA_REDO"), this);
206   anAction->setToolTip(tr("TOP_CAMERA_REDO"));
207   anAction->setStatusTip(tr("STB_CAMERA_REDO"));
208   registerAction(CameraRedoId, anAction);
209   new pqCameraUndoRedoReaction(anAction, false);
210
211   // Change Input
212   anAction = new QAction(tr("MEN_CHANGE_INPUT"), this);
213   anAction->setToolTip(tr("TOP_CHANGE_INPUT"));
214   anAction->setStatusTip(tr("STB_CHANGE_INPUT"));
215   registerAction(ChangeInputId, anAction);
216   new pqChangePipelineInputReaction(anAction);
217
218   // Ignore source time
219   anAction = new QAction(tr("MEN_IGNORE_TIME"), this);
220   anAction->setToolTip(tr("TOP_IGNORE_TIME"));
221   anAction->setStatusTip(tr("STB_IGNORE_TIME"));
222   anAction->setCheckable(true);
223   registerAction(IgnoreTimeId, anAction);
224   new pqIgnoreSourceTimeReaction(anAction);
225
226   // Delete
227   anAction = new QAction(tr("MEN_DELETE"), this);
228   anAction->setToolTip(tr("TOP_DELETE"));
229   anAction->setStatusTip(tr("STB_DELETE"));
230   registerAction(DeleteId, anAction);
231   new pqDeleteReaction(anAction);
232
233   // Delete All
234   anAction = new QAction(tr("MEN_DELETE_ALL"), this);
235   anAction->setToolTip(tr("TOP_DELETE_ALL"));
236   anAction->setStatusTip(tr("STB_DELETE_ALL"));
237   registerAction(DeleteAllId, anAction);
238   new pqDeleteReaction(anAction, true);
239
240
241   // Setting
242   anAction = new QAction(tr("MEN_SETTINGS"), this);
243   anAction->setToolTip(tr("TOP_SETTINGS"));
244   anAction->setStatusTip(tr("STB_SETTINGS"));
245   registerAction(SettingsId, anAction);
246   new pqApplicationSettingsReaction(anAction);
247   
248   // View Settings
249   anAction = new QAction(tr("MEN_VIEW_SETTINGS"), this);
250   anAction->setToolTip(tr("TOP_VIEW_SETTINGS"));
251   anAction->setStatusTip(tr("STB_VIEW_SETTINGS"));
252   registerAction(ViewSettingsId, anAction);
253   new pqViewSettingsReaction(anAction);
254
255   // --- Menu "View"
256   pqViewManager* viewManager = qobject_cast<pqViewManager*>(
257                                pqApplicationCore::instance()->manager("MULTIVIEW_MANAGER"));
258   if (viewManager) {
259     anAction = new QAction("Full Screen", this);
260     anAction->setObjectName("actionFullScreen");
261     anAction->setShortcut(QKeySequence("F11"));
262     connect(anAction, SIGNAL(triggered()), viewManager, SLOT(toggleFullScreen()));
263     registerAction(FullScreenId, anAction);
264   }
265
266   // --- Menu "Tools"
267   // Create Custom Filter
268   anAction = new QAction(tr("MEN_CREATE_CUSTOM_FILTER"), this);
269   anAction->setToolTip(tr("TOP_CREATE_CUSTOM_FILTER"));
270   anAction->setStatusTip(tr("STB_CREATE_CUSTOM_FILTER"));
271   registerAction(CreateCustomFilterId, anAction);
272   new pqCreateCustomFilterReaction(anAction << pqSetName("actionToolsCreateCustomFilter"));
273
274   // Manage Custom Filters
275   anAction = new QAction(tr("MEN_MANAGE_CUSTOM_FILTERS"), this);
276   anAction->setToolTip(tr("TOP_MANAGE_CUSTOM_FILTERS"));
277   anAction->setStatusTip(tr("STB_MANAGE_CUSTOM_FILTERS"));
278   registerAction(ManageCustomFiltersId, anAction);
279   new pqManageCustomFiltersReaction(anAction << pqSetName("actionToolsManageCustomFilters"));
280
281   // Manage Links
282   anAction = new QAction(tr("MEN_MANAGE_LINKS"), this);
283   anAction->setToolTip(tr("TOP_MANAGE_LINKS"));
284   anAction->setStatusTip(tr("STB_MANAGE_LINKS"));
285   registerAction(ManageLinksId, anAction);
286   new pqManageLinksReaction(anAction << pqSetName("actionToolsManageLinks"));
287
288   // Add Camera Link
289   anAction = new QAction(tr("MEN_ADD_CAMERA_LINK"), this);
290   anAction->setToolTip(tr("TOP_ADD_CAMERA_LINK"));
291   anAction->setStatusTip(tr("STB_ADD_CAMERA_LINK"));
292   registerAction(AddCameraLinkId, anAction);
293   new pqCameraLinkReaction(anAction << pqSetName("actionToolsAddCameraLink"));
294
295   // Manage Plugins/Extensions
296   anAction = new QAction(tr("MEN_MANAGE_PLUGINS"), this);
297   anAction->setToolTip(tr("TOP_MANAGE_PLUGINS"));
298   anAction->setStatusTip(tr("STB_MANAGE_PLUGINS"));
299   registerAction(ManagePluginsExtensionsId, anAction);
300   new pqManagePluginsReaction(anAction << pqSetName("actionManage_Plugins"));
301
302   // Record Test
303   anAction = new QAction(tr("MEN_RECORD_TEST"), this);
304   anAction->setToolTip(tr("TOP_RECORD_TEST"));
305   anAction->setStatusTip(tr("STB_RECORD_TEST"));
306   registerAction(RecordTestId, anAction);
307   new pqTestingReaction(anAction << pqSetName("actionToolsRecordTest"), pqTestingReaction::RECORD);
308
309   // Play Test
310   anAction = new QAction(tr("MEN_PLAY_TEST"), this);
311   anAction->setToolTip(tr("TOP_PLAY_TEST"));
312   anAction->setStatusTip(tr("STB_PLAY_TEST"));
313   registerAction(PlayTestId, anAction);
314   new pqTestingReaction(anAction << pqSetName("actionToolsPlayTest"), pqTestingReaction::PLAYBACK);
315
316   // Max Window Size
317   anAction = new QAction(tr("MEN_MAX_WINDOW_SIZE"), this);
318   anAction->setToolTip(tr("TOP_MAX_WINDOW_SIZE"));
319   anAction->setStatusTip(tr("PRP_APP_MAX_WINDOW_SIZE"));
320   anAction->setCheckable(true);
321   registerAction(MaxWindowSizeId, anAction);
322   new pqTestingReaction(anAction << pqSetName("actionTesting_Window_Size"),
323                         pqTestingReaction::LOCK_VIEW_SIZE);
324
325   // Timer Log
326   anAction = new QAction(tr("MEN_TIMER_LOG"), this);
327   anAction->setToolTip(tr("TOP_TIMER_LOG"));
328   anAction->setStatusTip(tr("STB_TIMER_LOG"));
329   registerAction(TimerLogId, anAction);
330   new pqTimerLogReaction(anAction << pqSetName("actionToolsTimerLog"));
331
332   // Output Window
333   anAction = new QAction(tr("MEN_OUTPUT_WINDOW"), this);
334   anAction->setToolTip(tr("TOP_OUTPUT_WINDOW"));
335   anAction->setStatusTip(tr("STB_OUTPUT_WINDOW"));
336   registerAction(OutputWindowId, anAction);
337   anAction << pqSetName("actionToolsOutputWindow");
338   connect(anAction, SIGNAL(triggered()), pqApplicationCore::instance(), SLOT(showOutputWindow()));
339   
340  // Python Shell
341   anAction = new QAction(tr("MEN_PYTHON_SHELL"), this);
342   anAction->setToolTip(tr("TOP_PYTHON_SHELL"));
343   anAction->setStatusTip(tr("STB_PYTHON_SHELL"));
344   registerAction(PythonShellId, anAction);
345   new pqPythonShellReaction(anAction << pqSetName("actionToolsPythonShell"));
346
347   // --- Menu "Help"
348
349   // About
350   anAction = new QAction(tr("MEN_ABOUT"), this);
351   anAction->setToolTip(tr("TOP_ABOUT"));
352   anAction->setStatusTip(tr("STB_ABOUT"));
353   registerAction(AboutParaViewId, anAction);
354   new pqAboutDialogReaction(anAction << pqSetName("actionAbout"));
355
356   // Native ParaView user documentation
357   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_PARAVIEW_HELP"), false );
358   anAction = new QAction(QIcon(aPixmap), tr("MEN_PARAVIEW_HELP"), this);
359   anAction->setToolTip(tr("TOP_PARAVIEW_HELP"));
360   anAction->setStatusTip(tr("STB_PARAVIEW_HELP"));
361   anAction->setShortcut(QKeySequence::HelpContents);
362   connect(anAction, SIGNAL(triggered()), this, SLOT(showParaViewHelp()));
363   registerAction(ParaViewHelpId, anAction);
364   //new pqHelpReaction(anAction << pqSetName("actionHelp"));
365 }
366
367 /*!
368   \brief Create menus for ParaView GUI operations
369   duplicating menus in pqMainWindow ParaView class
370
371   In particular, ParaView is responsible for updating "Sources" and "Filters" menus. 
372   For this, specific menu managers created by pqMainWindowCore class are used, and PVGUI_Module
373   is responsible for creation of corresponding QMenu objects only.
374 */
375 void PVGUI_Module::pvCreateMenus()
376 {
377   SUIT_Desktop* desk = application()->desktop();
378   
379   // --- Menu "File"
380   int aPVMnu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1 );
381
382   createMenu( OpenFileId, aPVMnu, 5 );
383
384   // Recent Files
385    int aMenuId = createMenu( tr( "MEN_RECENT_FILES" ), aPVMnu, -1, 5 );
386    QMenu* aMenu = menuMgr()->findMenu( aMenuId );
387    Implementation->RecentFilesMenu = new pqRecentFilesMenu( *aMenu, getApp()->desktop() );
388    QList<QAction*> anActns = aMenu->actions();
389    for (int i = 0; i < anActns.size(); ++i)
390      createMenu( anActns.at(i), aMenuId );
391
392
393   createMenu( separator(), aPVMnu, -1, 5 );
394
395   createMenu( LoadStateId, aPVMnu, 15 );
396   createMenu( SaveStateId, aPVMnu, 15 );
397   createMenu( separator(), aPVMnu, -1, 15 );
398
399   createMenu( SaveDataId, aPVMnu, 25 );
400   createMenu( SaveScreenshotId, aPVMnu, 25 );
401   createMenu( ExportId, aPVMnu, 25 );
402   createMenu( separator(), aPVMnu, -1, 25 );
403
404   createMenu( SaveAnimationId, aPVMnu, 35 );
405   createMenu( SaveGeometryId, aPVMnu, 35 );
406   createMenu( separator(), aPVMnu, -1, 35 );
407
408   createMenu( ConnectId, aPVMnu, 45 );
409   createMenu( DisconnectId, aPVMnu, 45 );
410   createMenu( separator(), aPVMnu, -1, 45 );
411
412   // --- Menu "Edit"
413   aPVMnu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1 );
414
415   createMenu( UndoId, aPVMnu );
416   createMenu( RedoId, aPVMnu );
417   createMenu( separator(), aPVMnu );
418
419   createMenu( CameraUndoId, aPVMnu );
420   createMenu( CameraRedoId, aPVMnu );
421   createMenu( separator(), aPVMnu );
422
423   createMenu( ChangeInputId, aPVMnu );
424   createMenu( IgnoreTimeId, aPVMnu );
425   createMenu( DeleteId, aPVMnu );
426   createMenu( DeleteAllId, aPVMnu );
427   createMenu( separator(), aPVMnu );
428
429   createMenu( SettingsId, aPVMnu );
430   createMenu( ViewSettingsId, aPVMnu );
431   createMenu( separator(), aPVMnu );
432
433   // --- Menu "View"
434   aPVMnu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1 );
435   myToolbarsMenuId = createMenu( "Toolbars", aPVMnu );
436   aMenu = getMenu( myToolbarsMenuId );
437   if (aMenu) {
438     buildToolbarsMenu();
439     connect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu()));
440   }
441   createMenu( separator(), aPVMnu );
442   createMenu( FullScreenId, aPVMnu );
443   
444   // --- Menu "Sources"
445
446   // Install ParaView managers for "Sources" menu
447   QMenu* aRes = 0;
448   mySourcesMenuId = createMenu( tr( "MEN_DESK_SOURCES" ), -1, -1, 60);
449   if ( (aRes = getMenu( mySourcesMenuId )) ) {
450     pqParaViewMenuBuilders::buildSourcesMenu(*aRes, desk);
451   }
452   
453   // --- Menu "Filters"
454
455   // Install ParaView managers for "Filters" menu
456   myFiltersMenuId = createMenu( tr( "MEN_DESK_FILTERS" ), -1, -1, 70 );
457   if ( (aRes = getMenu( myFiltersMenuId )) ) {
458     pqParaViewMenuBuilders::buildFiltersMenu(*aRes, desk);
459   }
460
461    // --- Menu "Macros"
462   myMacrosMenuId = createMenu( tr( "MEN_MACROS" ), -1, -1, 80 );
463   if ( (aRes = getMenu( myMacrosMenuId )) ) {
464     pqParaViewMenuBuilders::buildMacrosMenu(*aRes);
465   }
466  
467   // --- Menu "Tools"
468
469   int aToolsMnu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 90 );
470
471   createMenu( CreateCustomFilterId, aToolsMnu );
472   createMenu( AddCameraLinkId, aToolsMnu );
473   createMenu( separator(), aToolsMnu );
474   createMenu( ManageCustomFiltersId, aToolsMnu );
475   createMenu( ManageLinksId, aToolsMnu );
476   createMenu( ManagePluginsExtensionsId, aToolsMnu );
477   createMenu( separator(), aToolsMnu );
478
479   createMenu( RecordTestId, aToolsMnu );
480   createMenu( PlayTestId, aToolsMnu );
481   createMenu( MaxWindowSizeId, aToolsMnu );
482   createMenu( separator(), aToolsMnu );
483
484   createMenu( TimerLogId, aToolsMnu );
485   createMenu( OutputWindowId, aToolsMnu );
486   createMenu( separator(), aToolsMnu );
487
488   createMenu( PythonShellId, aToolsMnu );
489
490   // --- Menu "Help"
491
492   int aHelpMnu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1 );
493   createMenu( AboutParaViewId, aHelpMnu );
494
495   int aHelpModule = createMenu( LightApp_Application::tr( "MEN_DESK_MODULE_HELP" ), aHelpMnu, -1 );
496   createMenu( ParaViewHelpId, aHelpModule );
497 }
498
499 /*!
500   \brief Create toolbars for ParaView GUI operations
501   duplicating toolbars in pqMainWindow ParaView class
502 */
503 void PVGUI_Module::pvCreateToolBars()
504 {
505   SUIT_Desktop* desk = application()->desktop();
506   pqParaViewMenuBuilders::buildToolbars(*desk);
507 }
508
509 /*!
510   \brief Returns QMenu by its id.
511 */
512 QMenu* PVGUI_Module::getMenu( const int id )
513 {
514   QMenu* res = 0;
515   SalomeApp_Application* anApp = getApp();
516   SUIT_Desktop* desk = anApp->desktop();
517   if ( desk ){
518     QtxActionMenuMgr* menuMgr = desk->menuMgr();
519     res = menuMgr->findMenu( id );
520   }
521   return res;
522 }
523
524 /*!
525   \brief Returns list of ParaView toolbars
526 */
527 QList<QToolBar*> PVGUI_Module::getParaViewToolbars()
528 {
529   QList<QToolBar*> all_toolbars = application()->desktop()->findChildren<QToolBar*>();
530   // First two toolbars has to be ignored because they are not from ParaView
531   if (all_toolbars.size() > 2) {
532     all_toolbars.removeFirst();
533     all_toolbars.removeFirst();
534   }
535   return all_toolbars;
536 }
537
538
539
540 /*!
541   \brief Builds a menu which referred to toolbars
542 */
543 void PVGUI_Module::buildToolbarsMenu()
544 {
545   SUIT_Desktop* desk = application()->desktop();
546   QMenu* aMenu = menuMgr()->findMenu( myToolbarsMenuId );
547   if (aMenu) {
548     aMenu->clear();
549     QList<QMenu*> child_menus = aMenu->findChildren<QMenu*>();
550     foreach (QMenu* menu, child_menus) {
551       delete menu;
552     }
553     QList<QToolBar*> all_toolbars = getParaViewToolbars();
554
555     // Add menus for all toolbars and actions from them.
556     // This puts menu actions for all toolbars making it possible to access all
557     // toolbar actions even when the toolbar are not visible.
558     // I wonder if I should ignore the pqMainControlsToolbar since those actions
559     // are already placed at other places.
560     foreach (QToolBar* toolbar, all_toolbars) {
561       QMenu* sub_menu = new QMenu(aMenu) << pqSetName(toolbar->windowTitle());
562       bool added = false;
563       foreach (QAction* action, toolbar->actions()) {
564         if (!action->text().isEmpty()) {
565           added = true;
566           sub_menu->addAction(action);
567         }
568       }
569       if (added) {
570         QAction* menu_action = aMenu->addMenu(sub_menu);
571         menu_action->setText(toolbar->windowTitle());
572       } else {
573         delete sub_menu;
574       }
575     }
576     disconnect(aMenu, SIGNAL(aboutToShow()), this, SLOT(buildToolbarsMenu()));
577   }
578 }
579