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