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