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