1 // PARAVIS : ParaView wrapper SALOME module
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : PVGUI_Module_MenuActions.cxx
23 // Author : Margarita KARPUNINA
26 #include "PVGUI_Module_impl.h"
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>
40 #include <pqApplicationCore.h>
41 #include <pqColorScaleToolbar.h>
42 #include <pqMainWindowCore.h>
43 #include <pqObjectInspectorDriver.h>
44 #include <pqPipelineBrowser.h>
45 #include <pqProgressManager.h>
46 #include <pqRubberBandHelper.h>
47 #include <pqScalarBarVisibilityAdaptor.h>
48 #include <pqUndoStack.h>
49 #include <pqVCRController.h>
51 #include "PVGUI_Tools.h"
55 \brief Create actions for ParaView GUI operations
56 duplicating menus and toolbars in MainWindow class of
57 the standard ParaView GUI client application.
59 void PVGUI_Module::pvCreateActions()
61 SUIT_Desktop* desk = application()->desktop();
62 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
66 QtxAction* aQtxAction;
71 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_OPEN_FILE"), false );
72 createAction( OpenFileId, tr("TOP_OPEN_FILE"), QIcon(aPixmap),
73 tr("MEN_OPEN"), tr("STB_OPEN_FILE"),
74 //0, desk, false, &Implementation->Core, SLOT( onFileOpen() ) );
75 // This avoids an immediate exception on wrong MED file opening
76 0, desk, false, this, SLOT( onOpenFile() ) );
79 anAction = createAction( LoadStateId, tr("TOP_LOAD_STATE"), QIcon(),
80 tr("MEN_LOAD_STATE"), tr("STB_LOAD_STATE"),
81 0, desk, false, &Implementation->Core, SLOT( onFileLoadServerState() ) );
82 connect( &Implementation->Core, SIGNAL( enableFileLoadServerState(bool) ),
83 anAction, SLOT( setEnabled(bool) ) );
86 anAction = createAction( SaveStateId, tr("TOP_SAVE_STATE"), QIcon(),
87 tr("MEN_SAVE_STATE"), tr("STB_SAVE_STATE"),
88 0, desk, false, &Implementation->Core, SLOT( onFileSaveServerState() ) );
89 connect( &Implementation->Core, SIGNAL( enableFileSaveServerState(bool) ),
90 anAction, SLOT( setEnabled(bool) ) );
93 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_DATA"), false );
94 anAction = createAction( SaveDataId, tr("TOP_SAVE_DATA"), QIcon(aPixmap),
95 tr("MEN_SAVE_DATA"), tr("STB_SAVE_DATA"),
96 0, desk, false, &Implementation->Core, SLOT( onFileSaveData() ) );
97 connect( &Implementation->Core, SIGNAL( enableFileSaveData(bool) ),
98 anAction, SLOT( setEnabled(bool) ) );
101 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_SCREENSHOT"), false );
102 anAction = createAction( SaveScreenshotId, tr("TOP_SAVE_SCREENSHOT"), QIcon(aPixmap),
103 tr("MEN_SAVE_SCREENSHOT"), tr("STB_SAVE_SCREENSHOT"),
104 0, desk, false, &Implementation->Core, SLOT( onFileSaveScreenshot() ) );
105 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
106 anAction, SLOT( setEnabled(bool) ) );
109 anAction = createAction( ExportId, tr("TOP_EXPORT"), QIcon(),
110 tr("MEN_EXPORT"), tr("STB_EXPORT"),
111 0, desk, false, &Implementation->Core, SLOT( onFileExport() ) );
112 connect( &Implementation->Core, SIGNAL( enableExport(bool) ),
113 anAction, SLOT( setEnabled(bool) ) );
116 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_ANIMATION"), false );
117 anAction = createAction( SaveAnimationId, tr("TOP_SAVE_ANIMATION"), QIcon(aPixmap),
118 tr("MEN_SAVE_ANIMATION"), tr("STB_SAVE_ANIMATION"),
119 0, desk, false, &Implementation->Core, SLOT( onFileSaveAnimation() ) );
120 connect( &Implementation->Core, SIGNAL( enableFileSaveAnimation(bool) ),
121 anAction, SLOT( setEnabled(bool) ) );
124 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SAVE_GEOMETRY"), false );
125 anAction = createAction( SaveGeometryId, tr("TOP_SAVE_GEOMETRY"), QIcon(aPixmap),
126 tr("MEN_SAVE_GEOMETRY"), tr("STB_SAVE_GEOMETRY"),
127 0, desk, false, &Implementation->Core, SLOT( onSaveGeometry() ) );
128 connect( &Implementation->Core, SIGNAL( enableFileSaveGeometry(bool) ),
129 anAction, SLOT( setEnabled(bool) ) );
132 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CONNECT"), false );
133 anAction = createAction( ConnectId, tr("TOP_CONNECT"), QIcon(aPixmap),
134 tr("MEN_CONNECT"), tr("STB_CONNECT"),
135 0, desk, false, &Implementation->Core, SLOT( onServerConnect() ) );
136 connect( &Implementation->Core, SIGNAL( enableServerConnect(bool) ),
137 anAction, SLOT( setEnabled(bool) ) );
140 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_DISCONNECT"), false );
141 anAction = createAction( DisconnectId, tr("TOP_DISCONNECT"), QIcon(aPixmap),
142 tr("MEN_DISCONNECT"), tr("STB_DISCONNECT"),
143 0, desk, false, &Implementation->Core, SLOT( onServerDisconnect() ) );
144 connect( &Implementation->Core, SIGNAL( enableServerDisconnect(bool) ),
145 anAction, SLOT( setEnabled(bool) ) );
149 pqUndoStack* undoStack = Implementation->Core.getApplicationUndoStack();
152 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_UNDO"), false );
153 anAction = createAction( UndoId, tr("TOP_UNDO"), QIcon(aPixmap),
154 tr("MEN_UNDO"), tr("STB_UNDO"), Qt::CTRL+Qt::Key_Z,
155 desk, false, undoStack, SLOT( undo() ) );
156 connect( undoStack, SIGNAL( canUndoChanged(bool) ),
157 anAction, SLOT( setEnabled(bool) ) );
158 connect( undoStack, SIGNAL( undoLabelChanged(const QString&) ),
159 this, SLOT( onUndoLabel(const QString&) ) );
160 anAction->setEnabled( undoStack->canUndo() );
161 onUndoLabel(undoStack->undoLabel());
164 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_REDO"), false );
165 anAction = createAction( RedoId, tr("TOP_REDO"), QIcon(aPixmap),
166 tr("MEN_REDO"), tr("STB_REDO"), Qt::CTRL+Qt::Key_Y,
167 desk, false, undoStack, SLOT( redo() ) );
168 connect( undoStack, SIGNAL( canRedoChanged(bool) ),
169 anAction, SLOT( setEnabled(bool) ) );
170 connect( undoStack, SIGNAL( redoLabelChanged(const QString&) ),
171 this, SLOT( onRedoLabel(const QString&) ) );
172 anAction->setEnabled( undoStack->canRedo() );
173 onRedoLabel(undoStack->redoLabel());
176 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CAMERA_UNDO"), false );
177 anAction = createAction( CameraUndoId, tr("TOP_CAMERA_UNDO"), QIcon(aPixmap),
178 tr("MEN_CAMERA_UNDO"), tr("STB_CAMERA_UNDO"), Qt::CTRL+Qt::Key_C+Qt::Key_B,
179 desk, false, &Implementation->Core, SLOT( onEditCameraUndo() ) );
180 connect( &Implementation->Core, SIGNAL( enableCameraUndo(bool) ),
181 anAction, SLOT( setEnabled(bool) ) );
182 connect( &Implementation->Core, SIGNAL( cameraUndoLabel(const QString&) ),
183 this, SLOT( onCameraUndoLabel(const QString&) ) );
186 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_CAMERA_REDO"), false );
187 anAction = createAction( CameraRedoId, tr("TOP_CAMERA_REDO"), QIcon(aPixmap),
188 tr("MEN_CAMERA_REDO"), tr("STB_CAMERA_REDO"), Qt::CTRL+Qt::Key_C+Qt::Key_F,
189 desk, false, &Implementation->Core, SLOT( onEditCameraRedo() ) );
190 connect( &Implementation->Core, SIGNAL( enableCameraRedo(bool) ),
191 anAction, SLOT( setEnabled(bool) ) );
192 connect( &Implementation->Core, SIGNAL( cameraRedoLabel(const QString&) ),
193 this, SLOT( onCameraRedoLabel(const QString&) ) );
195 pqPipelineBrowser* browser = Implementation->Core.pipelineBrowser();
198 createAction( ChangeInputId, tr("TOP_CHANGE_INPUT"), QIcon(),
199 tr("MEN_CHANGE_INPUT"), tr("STB_CHANGE_INPUT"),
200 0, desk, false, browser, SLOT( changeInput() ) );
203 createAction( DeleteId, tr("TOP_DELETE"), QIcon(),
204 tr("MEN_DELETE"), tr("STB_DELETE"),
205 0, desk, false, browser, SLOT( deleteSelected() ) );
208 createAction( DeleteAllId, tr("TOP_DELETE_ALL"), QIcon(),
209 tr("MEN_DELETE_ALL"), tr("STB_DELETE_ALL"),
210 0, desk, false, this, SLOT( onDeleteAll() ) );
213 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_INTERACT"), false );
214 anAction = createAction( InteractId, tr("TOP_INTERACT"), QIcon(aPixmap),
215 tr("MEN_INTERACT"), tr("STB_INTERACT"), 0, desk, true,
216 Implementation->Core.renderViewSelectionHelper(), SLOT( endSelection() ) );
217 anAction->setChecked( true ); ///!!!
218 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( interactionModeChanged(bool) ),
219 anAction, SLOT( setChecked(bool) ) );
222 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SELECT_CELLS_ON"), false );
223 anAction = createAction( SelectCellsOnId, tr("TOP_SELECT_CELLS_ON"), QIcon(aPixmap),
224 tr("MEN_SELECT_CELLS_ON"), tr("STB_SELECT_CELLS_ON"), Qt::Key_S, desk, true,
225 Implementation->Core.renderViewSelectionHelper(), SLOT( beginSurfaceSelection() ) );
226 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( enableSurfaceSelection(bool) ),
227 anAction, SLOT( setEnabled(bool) ) );
230 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SELECT_POINTS_ON"), false );
231 anAction = createAction( SelectPointsOnId, tr("TOP_SELECT_POINTS_ON"), QIcon(aPixmap),
232 tr("MEN_SELECT_POINTS_ON"), tr("STB_SELECT_POINTS_ON"), 0, desk, true,
233 Implementation->Core.renderViewSelectionHelper(), SLOT( beginSurfacePointsSelection() ) );
234 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( enableSurfacePointsSelection(bool) ),
235 anAction, SLOT( setEnabled(bool) ) );
237 // Select Cells Through
238 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SELECT_CELLS_THROUGH"), false );
239 anAction = createAction( SelectCellsThroughId, tr("TOP_SELECT_CELLS_THROUGH"), QIcon(aPixmap),
240 tr("MEN_SELECT_CELLS_THROUGH"), tr("STB_SELECT_CELLS_THROUGH"), 0, desk, true,
241 Implementation->Core.renderViewSelectionHelper(), SLOT( beginFrustumSelection() ) );
242 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( enableFrustumSelection(bool) ),
243 anAction, SLOT( setEnabled(bool) ) );
245 // Select Points Through
246 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SELECT_POINTS_THROUGH"), false );
247 anAction = createAction( SelectPointsThroughId, tr("TOP_SELECT_POINTS_THROUGH"), QIcon(aPixmap),
248 tr("MEN_SELECT_POINTS_THROUGH"), tr("STB_SELECT_POINTS_THROUGH"), 0, desk, true,
249 Implementation->Core.renderViewSelectionHelper(), SLOT( beginFrustumPointsSelection() ) );
250 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( enableFrustumPointSelection(bool) ),
251 anAction, SLOT( setEnabled(bool) ) );
254 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SELECT_BLOCK"), false );
255 anAction = createAction( SelectBlockId, tr("TOP_SELECT_BLOCK"), QIcon(aPixmap),
256 tr("MEN_SELECT_BLOCK"), tr("STB_SELECT_BLOCK"), Qt::Key_B, desk, true,
257 Implementation->Core.renderViewSelectionHelper(), SLOT( beginBlockSelection() ) );
258 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( enableBlockSelection(bool) ),
259 anAction, SLOT( setEnabled(bool) ) );
261 // Create action group for exclusively selected modes
262 QActionGroup* aModeGroup = new QActionGroup( desk );
263 aModeGroup->addAction( action(InteractId) );
264 aModeGroup->addAction( action(SelectCellsOnId) );
265 aModeGroup->addAction( action(SelectPointsOnId) );
266 aModeGroup->addAction( action(SelectCellsThroughId) );
267 aModeGroup->addAction( action(SelectPointsThroughId) );
268 aModeGroup->addAction( action(SelectBlockId) );
270 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( selectionModeChanged(int) ),
271 this, SLOT( onSelectionModeChanged(int) ) );
272 // When a selection is marked, we revert to interaction mode.
273 connect( Implementation->Core.renderViewSelectionHelper(), SIGNAL( selectionFinished(int, int, int, int) ),
274 Implementation->Core.renderViewSelectionHelper(), SLOT( endSelection() ) );
277 createAction( SettingsId, tr("TOP_SETTINGS"), QIcon(),
278 tr("MEN_SETTINGS"), tr("STB_SETTINGS"),
279 0, desk, false, &Implementation->Core, SLOT( onEditSettings() ) );
282 createAction( ViewSettingsId, tr("TOP_VIEW_SETTINGS"), QIcon(),
283 tr("MEN_VIEW_SETTINGS"), tr("STB_VIEW_SETTINGS"),
284 0, desk, false, &Implementation->Core, SLOT( onEditViewSettings() ) );
288 // Camera submenu -> Reset
289 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_RESET_CAMERA"), false );
290 anAction = createAction( ResetCameraId, tr("TOP_RESET_CAMERA"), QIcon(aPixmap),
291 tr("MEN_RESET_CAMERA"), tr("STB_RESET_CAMERA"),
292 0, desk, false, &Implementation->Core, SLOT( resetCamera() ) );
293 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
294 anAction, SLOT( setEnabled(bool) ) );
296 // Camera submenu -> +X
297 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_+X"), false );
298 anAction = createAction( PositiveXId, tr("TOP_+X"), QIcon(aPixmap),
299 tr("MEN_+X"), tr("STB_+X"),
300 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionPosX() ) );
301 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
302 anAction, SLOT( setEnabled(bool) ) );
304 // Camera submenu -> -X
305 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_-X"), false );
306 anAction = createAction( NegativeXId, tr("TOP_-X"), QIcon(aPixmap),
307 tr("MEN_-X"), tr("STB_-X"),
308 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionNegX() ) );
309 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
310 anAction, SLOT( setEnabled(bool) ) );
312 // Camera submenu -> +Y
313 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_+Y"), false );
314 anAction = createAction( PositiveYId, tr("TOP_+Y"), QIcon(aPixmap),
315 tr("MEN_+Y"), tr("STB_+Y"),
316 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionPosY() ) );
317 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
318 anAction, SLOT( setEnabled(bool) ) );
320 // Camera submenu -> -Y
321 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_-Y"), false );
322 anAction = createAction( NegativeYId, tr("TOP_-Y"), QIcon(aPixmap),
323 tr("MEN_-Y"), tr("STB_-Y"),
324 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionNegY() ) );
325 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
326 anAction, SLOT( setEnabled(bool) ) );
328 // Camera submenu -> +Z
329 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_+Z"), false );
330 anAction = createAction( PositiveZId, tr("TOP_+Z"), QIcon(aPixmap),
331 tr("MEN_+Z"), tr("STB_+Z"),
332 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionPosZ() ) );
333 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
334 anAction, SLOT( setEnabled(bool) ) );
336 // Camera submenu -> -Z
337 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_-Z"), false );
338 anAction = createAction( NegativeZId, tr("TOP_-Z"), QIcon(aPixmap),
339 tr("MEN_-Z"), tr("STB_-Z"),
340 0, desk, false, &Implementation->Core, SLOT( resetViewDirectionNegZ() ) );
341 connect( &Implementation->Core, SIGNAL( enableFileSaveScreenshot(bool) ),
342 anAction, SLOT( setEnabled(bool) ) );
345 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SHOW_CENTER"), false );
346 aQtxAction = new QtxAction( tr("TOP_SHOW_CENTER"), QIcon(aPixmap),
347 tr("MEN_SHOW_CENTER"), 0, desk );
348 aQtxAction->setStatusTip( tr( "PRP_APP_SHOW_CENTER" ) );
349 aQtxAction->setCheckable( true );
350 registerAction( ShowCenterId, aQtxAction );
351 connect( aQtxAction, SIGNAL( toggled(bool) ),
352 &Implementation->Core, SLOT( setCenterAxesVisibility(bool) ) );
353 connect( &Implementation->Core, SIGNAL( enableShowCenterAxis(bool) ),
354 this, SLOT( onShowCenterAxisChanged(bool) ), Qt::QueuedConnection );
357 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_RESET_CENTER"), false );
358 anAction = createAction( ResetCenterId, tr("TOP_RESET_CENTER"), QIcon(aPixmap),
359 tr("MEN_RESET_CENTER"), tr("STB_RESET_CENTER"), 0, desk, false,
360 &Implementation->Core, SLOT( resetCenterOfRotationToCenterOfCurrentData() ) );
361 connect( &Implementation->Core, SIGNAL( enableResetCenter(bool) ),
362 anAction, SLOT( setEnabled(bool) ) );
365 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_PICK_CENTER"), false );
366 aQtxAction = new QtxAction( tr("TOP_PICK_CENTER"), QIcon(aPixmap),
367 tr("MEN_PICK_CENTER"), 0, desk );
368 aQtxAction->setStatusTip( tr( "PRP_APP_PICK_CENTER" ) );
369 aQtxAction->setCheckable( true );
370 registerAction( PickCenterId, aQtxAction );
371 connect( aQtxAction, SIGNAL( toggled(bool) ),
372 &Implementation->Core, SLOT( pickCenterOfRotation(bool) ) );
373 connect( &Implementation->Core, SIGNAL( enablePickCenter(bool) ),
374 aQtxAction, SLOT( setEnabled(bool) ) );
375 connect( &Implementation->Core, SIGNAL( pickingCenter(bool) ),
376 aQtxAction, SLOT( setChecked(bool) ) );
379 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_SHOW_COLOR_LEGEND"), false );
380 aQtxAction = new QtxAction( tr("TOP_SHOW_COLOR_LEGEND"), QIcon(aPixmap),
381 tr("MEN_SHOW_COLOR_LEGEND"), 0, desk );
382 aQtxAction->setStatusTip( tr( "PRP_APP_SHOW_COLOR_LEGEND" ) );
383 aQtxAction->setCheckable( true );
384 aQtxAction->setEnabled(false);
385 registerAction( ShowColorLegendId, aQtxAction );
386 pqScalarBarVisibilityAdaptor* sbva = new pqScalarBarVisibilityAdaptor( aQtxAction );
387 connect( Implementation->Core.getObjectInspectorDriver(),
388 SIGNAL( representationChanged(pqDataRepresentation*, pqView*) ),
390 SLOT( setActiveRepresentation(pqDataRepresentation*) ) );
392 // --- Menu "Sources" and "Filters"
393 // As ParaView is responsible for updating "Sources" and "Filters" menus,
394 // actions for these menus are created inside the pqMainWindowCore.
395 // So, the creation of corresponding QMenu object is in the PVGUI_Module::pvCreateMenus().
397 // --- Menu "Animation"
399 pqVCRController* vcrcontroller = &Implementation->Core.VCRController();
402 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_FIRST_FRAME"), false );
403 anAction = createAction( FirstFrameId, tr("TOP_FIRST_FRAME"), QIcon(aPixmap),
404 tr("MEN_FIRST_FRAME"), tr("STB_FIRST_FRAME"),
405 0, desk, false, vcrcontroller, SLOT( onFirstFrame() ) );
406 connect( vcrcontroller, SIGNAL( enabled(bool) ), anAction, SLOT( setEnabled(bool) ) );
409 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_PREVIOUS_FRAME"), false );
410 anAction = createAction( PreviousFrameId, tr("TOP_PREVIOUS_FRAME"), QIcon(aPixmap),
411 tr("MEN_PREVIOUS_FRAME"), tr("STB_PREVIOUS_FRAME"),
412 0, desk, false, vcrcontroller, SLOT( onPreviousFrame() ) );
413 connect( vcrcontroller, SIGNAL( enabled(bool) ), anAction, SLOT( setEnabled(bool) ) );
416 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_PLAY"), false );
417 anAction = createAction( PlayId, tr("TOP_PLAY"), QIcon(aPixmap),
418 tr("MEN_PLAY"), tr("STB_PLAY"),
419 0, desk, false, vcrcontroller, SLOT( onPlay() ) );
420 connect( vcrcontroller, SIGNAL( enabled(bool) ), anAction, SLOT( setEnabled(bool) ) );
423 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_NEXT_FRAME"), false );
424 anAction = createAction( NextFrameId, tr("TOP_NEXT_FRAME"), QIcon(aPixmap),
425 tr("MEN_NEXT_FRAME"), tr("STB_NEXT_FRAME"),
426 0, desk, false, vcrcontroller, SLOT( onNextFrame() ) );
427 connect( vcrcontroller, SIGNAL( enabled(bool) ), anAction, SLOT( setEnabled(bool) ) );
430 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_LAST_FRAME"), false );
431 anAction = createAction( LastFrameId, tr("TOP_LAST_FRAME"), QIcon(aPixmap),
432 tr("MEN_LAST_FRAME"), tr("STB_LAST_FRAME"),
433 0, desk, false, vcrcontroller, SLOT( onLastFrame() ) );
434 connect( vcrcontroller, SIGNAL( enabled(bool) ), anAction, SLOT( setEnabled(bool) ) );
437 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_LOOP"), false );
438 aQtxAction = new QtxAction( tr("TOP_LOOP"), QIcon(aPixmap),
439 tr("MEN_LOOP"), 0, desk );
440 aQtxAction->setStatusTip( tr( "PRP_APP_LOOP" ) );
441 aQtxAction->setCheckable(true);
442 registerAction( LoopId, aQtxAction );
443 connect( aQtxAction, SIGNAL( toggled(bool) ), vcrcontroller, SLOT( onLoop(bool) ) );
444 connect( vcrcontroller, SIGNAL( enabled(bool) ), aQtxAction, SLOT( setEnabled(bool) ) );
445 connect( vcrcontroller, SIGNAL( loop(bool) ), aQtxAction, SLOT( setChecked(bool) ) );
447 connect( vcrcontroller, SIGNAL( playing(bool) ), this, SLOT( onPlaying(bool) ) );
448 connect( vcrcontroller, SIGNAL( timeRanges(double, double) ),
449 this, SLOT( setTimeRanges(double, double) ) );
453 // Create Custom Filter
454 createAction( CreateCustomFilterId, tr("TOP_CREATE_CUSTOM_FILTER"), QIcon(),
455 tr("MEN_CREATE_CUSTOM_FILTER"), tr("STB_CREATE_CUSTOM_FILTER"),
456 0, desk, false, &Implementation->Core, SLOT( onToolsCreateCustomFilter() ) );
458 // Manage Custom Filters
459 createAction( ManageCustomFiltersId, tr("TOP_MANAGE_CUSTOM_FILTERS"), QIcon(),
460 tr("MEN_MANAGE_CUSTOM_FILTERS"), tr("STB_MANAGE_CUSTOM_FILTERS"),
461 0, desk, false, &Implementation->Core, SLOT( onToolsManageCustomFilters() ) );
464 createAction( CreateLookmarkId, tr("TOP_CREATE_LOOKMARK"), QIcon(),
465 tr("MEN_CREATE_LOOKMARK"), tr("STB_CREATE_LOOKMARK"),
466 0, desk, false, &Implementation->Core, SLOT( onToolsCreateLookmark() ) );
469 createAction( ManageLinksId, tr("TOP_MANAGE_LINKS"), QIcon(),
470 tr("MEN_MANAGE_LINKS"), tr("STB_MANAGE_LINKS"),
471 0, desk, false, &Implementation->Core, SLOT( onToolsManageLinks() ) );
474 createAction( AddCameraLinkId, tr("TOP_ADD_CAMERA_LINK"), QIcon(),
475 tr("MEN_ADD_CAMERA_LINK"), tr("STB_ADD_CAMERA_LINK"),
476 0, desk, false, this, SLOT( onAddCameraLink() ) );
478 // Manage Plugins/Extensions
479 createAction( ManagePluginsExtensionsId, tr( "TOP_MANAGE_PLUGINS" ), QIcon(),
480 tr( "MEN_MANAGE_PLUGINS" ), tr( "STB_MANAGE_PLUGINS" ),
481 0, desk, false, &Implementation->Core, SLOT( onManagePlugins() ) );
484 createAction( DumpWidgetNamesId, tr( "TOP_DUMP_WIDGET_NAMES" ), QIcon(),
485 tr( "MEN_DUMP_WIDGET_NAMES" ), tr( "STB_DUMP_WIDGET_NAMES" ),
486 0, desk, false, &Implementation->Core, SLOT( onToolsDumpWidgetNames() ) );
489 createAction( RecordTestId, tr( "TOP_RECORD_TEST" ), QIcon(),
490 tr( "MEN_RECORD_TEST" ), tr( "STB_RECORD_TEST" ),
491 0, desk, false, &Implementation->Core, SLOT( onToolsRecordTest() ) );
493 // Record Test Screenshot
494 createAction( RecordTestScreenshotId, tr( "TOP_RECORD_TEST_SCREENSHOT" ), QIcon(),
495 tr( "MEN_RECORD_TEST_SCREENSHOT" ), tr( "STB_RECORD_TEST_SCREENSHOT" ),
496 0, desk, false, &Implementation->Core, SLOT( onToolsRecordTestScreenshot() ) );
499 createAction( PlayTestId, tr( "TOP_PLAY_TEST" ), QIcon(),
500 tr( "MEN_PLAY_TEST" ), tr( "STB_PLAY_TEST" ),
501 0, desk, false, &Implementation->Core, SLOT( onToolsPlayTest() ) );
504 aQtxAction = new QtxAction( tr("TOP_MAX_WINDOW_SIZE"), QIcon(),
505 tr("MEN_MAX_WINDOW_SIZE"), 0, desk );
506 aQtxAction->setStatusTip( tr( "PRP_APP_MAX_WINDOW_SIZE" ) );
507 aQtxAction->setCheckable(true);
508 registerAction( MaxWindowSizeId, aQtxAction );
509 connect( aQtxAction, SIGNAL( toggled(bool) ), &Implementation->Core, SLOT( enableTestingRenderWindowSize(bool) ) );
512 createAction( TimerLogId, tr( "TOP_TIMER_LOG" ), QIcon(),
513 tr( "MEN_TIMER_LOG" ), tr( "STB_TIMER_LOG" ),
514 0, desk, false, &Implementation->Core, SLOT( onToolsTimerLog() ) );
517 createAction( OutputWindowId, tr( "TOP_OUTPUT_WINDOW" ), QIcon(),
518 tr( "MEN_OUTPUT_WINDOW" ), tr( "STB_OUTPUT_WINDOW" ),
519 0, desk, false, &Implementation->Core, SLOT( onToolsOutputWindow() ) );
522 createAction( PythonShellId, tr( "TOP_PYTHON_SHELL" ), QIcon(),
523 tr( "MEN_PYTHON_SHELL" ), tr( "STB_PYTHON_SHELL" ),
524 0, desk, false, &Implementation->Core, SLOT( onToolsPythonShell() ) );
529 createAction( AboutParaViewId, tr( "TOP_ABOUT" ), QIcon(),
530 tr( "MEN_ABOUT" ), tr( "STB_ABOUT" ),
531 0, desk, false, this, SLOT( onHelpAbout() ) );
533 // Native ParaView user documentation
534 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_PARAVIEW_HELP"), false );
535 createAction( ParaViewHelpId, tr( "TOP_PARAVIEW_HELP" ), QIcon(aPixmap),
536 tr( "MEN_PARAVIEW_HELP" ), tr( "STB_PARAVIEW_HELP" ),
537 0, desk, false, this, SLOT( onParaViewHelp() ) );
540 aQtxAction = new QtxAction( tr("TOP_ENABLE_TOOLTIPS"), QIcon(),
541 tr("MEN_ENABLE_TOOLTIPS"), 0, desk );
542 aQtxAction->setStatusTip( tr( "PRP_APP_ENABLE_TOOLTIPS" ) );
543 aQtxAction->setCheckable(true);
544 aQtxAction->setChecked(true);
545 registerAction( EnableTooltipsId, aQtxAction );
549 \brief Create menus for ParaView GUI operations
550 duplicating menus in pqMainWindow ParaView class
552 In particular, ParaView is responsible for updating "Sources" and "Filters" menus.
553 For this, specific menu managers created by pqMainWindowCore class are used, and PVGUI_Module
554 is responsible for creation of corresponding QMenu objects only.
556 void PVGUI_Module::pvCreateMenus()
559 int aPVMnu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1 );
561 createMenu( OpenFileId, aPVMnu, 5 );
564 int aMenuId = createMenu( tr( "MEN_RECENT_FILES" ), aPVMnu, -1, 5 );
565 QMenu* aMenu = menuMgr()->findMenu( aMenuId );
566 Implementation->RecentFilesMenu = new pqRecentFilesMenu( *aMenu, getApp()->desktop() );
567 connect( Implementation->RecentFilesMenu, SIGNAL( serverConnectFailed() ),
568 &Implementation->Core, SLOT( makeDefaultConnectionIfNoneExists() ) );
569 QList<QAction*> anActns = aMenu->actions();
570 for (int i = 0; i < anActns.size(); ++i)
571 createMenu( anActns.at(i), aMenuId );
574 createMenu( separator(), aPVMnu, -1, 5 );
576 createMenu( LoadStateId, aPVMnu, 15 );
577 createMenu( SaveStateId, aPVMnu, 15 );
578 createMenu( separator(), aPVMnu, -1, 15 );
580 createMenu( SaveDataId, aPVMnu, 25 );
581 createMenu( SaveScreenshotId, aPVMnu, 25 );
582 createMenu( ExportId, aPVMnu, 25 );
583 createMenu( separator(), aPVMnu, -1, 25 );
585 createMenu( SaveAnimationId, aPVMnu, 35 );
586 createMenu( SaveGeometryId, aPVMnu, 35 );
587 createMenu( separator(), aPVMnu, -1, 35 );
589 createMenu( ConnectId, aPVMnu, 45 );
590 createMenu( DisconnectId, aPVMnu, 45 );
591 createMenu( separator(), aPVMnu, -1, 45 );
594 aPVMnu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1 );
596 createMenu( UndoId, aPVMnu );
597 createMenu( RedoId, aPVMnu );
598 createMenu( separator(), aPVMnu );
600 createMenu( CameraUndoId, aPVMnu );
601 createMenu( CameraRedoId, aPVMnu );
602 createMenu( separator(), aPVMnu );
604 createMenu( ChangeInputId, aPVMnu );
605 createMenu( DeleteId, aPVMnu );
606 createMenu( DeleteAllId, aPVMnu );
607 createMenu( separator(), aPVMnu );
609 createMenu( InteractId, aPVMnu );
610 createMenu( SelectCellsOnId, aPVMnu );
611 createMenu( SelectPointsOnId, aPVMnu );
612 createMenu( SelectCellsThroughId, aPVMnu );
613 createMenu( SelectPointsThroughId, aPVMnu );
614 createMenu( SelectBlockId, aPVMnu );
615 createMenu( separator(), aPVMnu );
617 createMenu( SettingsId, aPVMnu );
618 createMenu( ViewSettingsId, aPVMnu );
619 createMenu( separator(), aPVMnu );
622 aPVMnu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1 );
624 int aCameraMnu = createMenu( tr( "MEN_CAMERA" ), aPVMnu );
625 createMenu( ResetCameraId, aCameraMnu );
626 createMenu( PositiveXId, aCameraMnu );
627 createMenu( NegativeXId, aCameraMnu );
628 createMenu( PositiveYId, aCameraMnu );
629 createMenu( NegativeYId, aCameraMnu );
630 createMenu( PositiveZId, aCameraMnu );
631 createMenu( NegativeZId, aCameraMnu );
632 createMenu( separator(), aPVMnu );
634 createMenu( ShowCenterId, aPVMnu );
635 createMenu( ResetCenterId, aPVMnu );
636 createMenu( PickCenterId, aPVMnu );
637 createMenu( ShowColorLegendId, aPVMnu );
638 createMenu( separator(), aPVMnu );
640 // --- Menu "Sources"
642 // Install ParaView managers for "Sources" menu
644 mySourcesMenuId = createMenu( tr( "MEN_DESK_SOURCES" ), -1, -1, 60 );
645 if ( (aRes = getMenu( mySourcesMenuId )) ) {
646 Implementation->Core.setSourceMenu( aRes );
647 connect( &Implementation->Core, SIGNAL( enableSourceCreate(bool) ),
648 aRes, SLOT( setEnabled(bool) ) );
651 // --- Menu "Filters"
653 // Install ParaView managers for "Filters" menu
654 myFiltersMenuId = createMenu( tr( "MEN_DESK_FILTERS" ), -1, -1, 70 );
655 if ( (aRes = getMenu( myFiltersMenuId )) ) {
656 Implementation->Core.setFilterMenu( aRes );
657 connect( &Implementation->Core, SIGNAL( enableFilterCreate(bool) ),
658 aRes, SLOT( setEnabled(bool) ) );
661 // --- Menu "Animation"
662 int anAnimationMnu = createMenu( tr( "MEN_DESK_ANIMATION" ), -1, -1, 80 );
664 createMenu( FirstFrameId, anAnimationMnu );
665 createMenu( PreviousFrameId, anAnimationMnu );
666 createMenu( PlayId, anAnimationMnu );
667 createMenu( NextFrameId, anAnimationMnu );
668 createMenu( LastFrameId, anAnimationMnu );
669 createMenu( LoopId, anAnimationMnu );
673 int aToolsMnu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 90 );
675 createMenu( CreateCustomFilterId, aToolsMnu );
676 createMenu( ManageCustomFiltersId, aToolsMnu );
677 createMenu( CreateLookmarkId, aToolsMnu );
678 createMenu( ManageLinksId, aToolsMnu );
679 createMenu( AddCameraLinkId, aToolsMnu );
680 createMenu( ManagePluginsExtensionsId, aToolsMnu );
681 createMenu( separator(), aToolsMnu );
683 createMenu( DumpWidgetNamesId, aToolsMnu );
684 createMenu( RecordTestId, aToolsMnu );
685 createMenu( RecordTestScreenshotId, aToolsMnu );
686 createMenu( PlayTestId, aToolsMnu );
687 createMenu( MaxWindowSizeId, aToolsMnu );
688 createMenu( separator(), aToolsMnu );
690 createMenu( TimerLogId, aToolsMnu );
691 createMenu( OutputWindowId, aToolsMnu );
692 createMenu( separator(), aToolsMnu );
694 createMenu( PythonShellId, aToolsMnu );
698 int aHelpMnu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1 );
700 createMenu( AboutParaViewId, aHelpMnu );
701 createMenu( ParaViewHelpId, aHelpMnu );
702 createMenu( separator(), aHelpMnu );
703 createMenu( EnableTooltipsId, aHelpMnu );
708 \brief Create toolbars for ParaView GUI operations
709 duplicating toolbars in pqMainWindow ParaView class
711 void PVGUI_Module::pvCreateToolBars()
713 SUIT_Desktop* desk = application()->desktop();
714 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
717 QtxAction* aQtxAction;
719 // --- Toolbar "Main Controls"
721 int aToolId = createTool( tr("TOOL_MAIN_CONTROLS") );
723 createTool( OpenFileId, aToolId );
724 createTool( SaveDataId, aToolId );
725 createTool( separator(), aToolId );
726 createTool( ConnectId, aToolId );
727 createTool( DisconnectId, aToolId );
728 createTool( separator(), aToolId );
729 createTool( ParaViewHelpId, aToolId );
731 // --- Toolbar "Selection Controls"
733 mySelectionControlsTb = createTool( tr("TOOL_SELECTION_CONTROLS") );
735 createTool( InteractId, mySelectionControlsTb );
736 createTool( SelectCellsOnId, mySelectionControlsTb );
737 createTool( SelectPointsOnId, mySelectionControlsTb );
738 createTool( SelectCellsThroughId, mySelectionControlsTb );
739 createTool( SelectPointsThroughId, mySelectionControlsTb );
740 createTool( SelectBlockId, mySelectionControlsTb );
742 // --- Toolbar "Undo/Redo Controls"
744 aToolId = createTool( tr("TOOL_UNDOREDO_CONTROLS") );
746 createTool( UndoId, aToolId );
747 createTool( RedoId, aToolId );
749 // --- Toolbar "VCR Controls"
751 aToolId = createTool( tr("TOOL_VCR_CONTROLS") );
753 createTool( FirstFrameId, aToolId );
754 createTool( PreviousFrameId, aToolId );
755 createTool( PlayId, aToolId );
756 createTool( NextFrameId, aToolId );
757 createTool( LastFrameId, aToolId );
758 createTool( LoopId, aToolId );
760 pqProgressManager* progress_manager = pqApplicationCore::instance()->getProgressManager();
761 progress_manager->addNonBlockableObject( toolMgr()->toolBar( aToolId ) );
763 // --- Toolbar "Active Variable Controls"
765 aToolId = createTool( tr("TOOL_ACTIVE_VARIABLE_CONTROLS") );
766 QToolBar* aTB = toolMgr()->toolBar( aToolId );
768 createTool( ShowColorLegendId, aToolId );
770 // To set up the color map tool buttons.
771 pqColorScaleToolbar* colorScale = Implementation->Core.getColorScaleEditorManager();
774 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_EDIT_COLOR_MAP"), false );
775 aQtxAction = new QtxAction( tr("TOP_EDIT_COLOR_MAP"), QIcon(aPixmap),
776 tr("MEN_EDIT_COLOR_MAP"), 0, desk );
777 aQtxAction->setStatusTip( tr( "PRP_APP_EDIT_COLOR_MAP" ) );
778 registerAction( EditColorMapId, aQtxAction );
779 connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
780 aQtxAction, SLOT( setEnabled(bool) ) );
781 colorScale->setColorAction( aQtxAction ); /// !!!
782 createTool( EditColorMapId, aToolId );
785 aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_RESET_RANGE"), false );
786 aQtxAction = new QtxAction( tr("TOP_RESET_RANGE"), QIcon(aPixmap),
787 tr("MEN_RESET_RANGE"), 0, desk );
788 aQtxAction->setStatusTip( tr( "PRP_APP_RESET_RANGE" ) );
789 registerAction( ResetRangeId, aQtxAction );
790 connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
791 aQtxAction, SLOT( setEnabled(bool) ) );
792 colorScale->setRescaleAction( aQtxAction ); /// !!!
793 createTool( ResetRangeId, aToolId );
795 Implementation->Core.setupVariableToolbar(aTB);
796 QList<QAction*> anActns = aTB->actions();
797 for (int i = 0; i < anActns.size(); ++i)
798 if ( anActns.at(i) != action(ShowColorLegendId) ) {
799 createTool( anActns.at(i), aToolId );
800 connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
801 anActns.at(i), SLOT( setEnabled(bool) ) );
804 // --- Toolbar "Representation"
806 aToolId = createTool( tr("TOOL_REPRESENTATION") );
807 aTB = toolMgr()->toolBar( aToolId );
809 Implementation->Core.setupRepresentationToolbar(aTB);
810 anActns = aTB->actions();
811 for (int i = 0; i < anActns.size(); ++i) {
812 createTool( anActns.at(i), aToolId );
813 connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
814 anActns.at(i), SLOT( setEnabled(bool) ) );
817 // --- Toolbar "Camera Controls"
819 aToolId = createTool( tr("TOOL_CAMERA_CONTROLS") );
821 createTool( ResetCameraId, aToolId );
822 createTool( PositiveXId, aToolId );
823 createTool( NegativeXId, aToolId );
824 createTool( PositiveYId, aToolId );
825 createTool( NegativeYId, aToolId );
826 createTool( PositiveZId, aToolId );
827 createTool( NegativeZId, aToolId );
829 // --- Toolbar "Center Axes Controls"
831 aToolId = createTool( tr("TOOL_CENTER_AXES_CONTROLS") );
833 createTool( ShowCenterId, aToolId );
834 createTool( ResetCenterId, aToolId );
835 createTool( PickCenterId, aToolId );
837 // --- Toolbar "Common Filters"
839 aToolId = createTool( tr("TOOL_COMMON_FILTERS") );
840 aTB = toolMgr()->toolBar( aToolId );
842 Implementation->Core.setupCommonFiltersToolbar(aTB);
843 anActns = aTB->actions();
844 for (int i = 0; i < anActns.size(); ++i)
845 createTool( anActns.at(i), aToolId );
847 // --- Toolbar "Lookmarks"
849 aToolId = createTool( tr("TOOL_LOOKMARKS") );
850 aTB = toolMgr()->toolBar(aToolId);
852 aTB->setContextMenuPolicy(Qt::CustomContextMenu);
853 aTB->setOrientation(Qt::Vertical);
854 aTB->setAllowedAreas(Qt::RightToolBarArea);
855 toolMgr()->mainWindow()->addToolBar(Qt::RightToolBarArea,aTB);
856 Implementation->Core.setupLookmarkToolbar(aTB);
860 \brief Returns QMenu by its id.
862 QMenu* PVGUI_Module::getMenu( const int id )
865 SalomeApp_Application* anApp = getApp();
866 SUIT_Desktop* desk = anApp->desktop();
868 QtxActionMenuMgr* menuMgr = desk->menuMgr();
869 res = menuMgr->findMenu( id );