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