pqParaViewMenuBuilders.cxx 31.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
/*=========================================================================

   Program: ParaView
   Module:    pqParaViewMenuBuilders.cxx

   Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
   All rights reserved.

   ParaView is a free software; you can redistribute it and/or modify it
10
   under the terms of the ParaView license version 1.2.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

   See License_v1.2.txt for the full ParaView license.
   A copy of this license can be obtained by contacting
   Kitware Inc.
   28 Corporate Drive
   Clifton Park, NY 12065
   USA

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

========================================================================*/
#include "pqParaViewMenuBuilders.h"
33
#include "vtkPVConfig.h"
34
35

#include "ui_pqEditMenuBuilder.h"
36
#include "ui_pqFileMenuBuilder.h"
37
38
39
40
41

#include "pqAboutDialogReaction.h"
#include "pqAnimationTimeToolbar.h"
#include "pqApplicationCore.h"
#include "pqApplicationSettingsReaction.h"
42
#include "pqApplyPropertiesReaction.h"
43
44
45
46
#include "pqAxesToolbar.h"
#include "pqCameraLinkReaction.h"
#include "pqCameraToolbar.h"
#include "pqCameraUndoRedoReaction.h"
47
#include "pqCatalystConnectReaction.h"
48
#include "pqCatalystContinueReaction.h"
49
#include "pqCatalystExportReaction.h"
50
#include "pqCatalystPauseSimulationReaction.h"
51
52
#include "pqCatalystRemoveBreakpointReaction.h"
#include "pqCatalystSetBreakpointReaction.h"
53
54
55
#include "pqCategoryToolbarsBehavior.h"
#include "pqChangePipelineInputReaction.h"
#include "pqColorToolbar.h"
56
#include "pqCopyReaction.h"
57
#include "pqCreateCustomFilterReaction.h"
58
#include "pqCustomViewpointsToolbar.h"
59
#include "pqCustomizeShortcutsReaction.h"
60
#include "pqDataQueryReaction.h"
61
#include "pqDeleteReaction.h"
62
#include "pqDesktopServicesReaction.h"
63
#include "pqExampleVisualizationsDialogReaction.h"
64
#include "pqExportReaction.h"
65
#include "pqExtractGeneratorsMenuReaction.h"
66
#include "pqFiltersMenuReaction.h"
67
#ifdef PARAVIEW_USE_QTHELP
68
#include "pqHelpReaction.h"
69
#endif
70
#include "pqIgnoreSourceTimeReaction.h"
71
#include "pqImmediateExportReaction.h"
72
#include "pqLinkSelectionReaction.h"
73
#include "pqLoadDataReaction.h"
74
#include "pqLoadMaterialsReaction.h"
75
#include "pqLoadRestoreWindowLayoutReaction.h"
76
#include "pqLoadStateReaction.h"
77
#include "pqLogViewerReaction.h"
78
79
#include "pqMainControlsToolbar.h"
#include "pqManageCustomFiltersReaction.h"
80
#include "pqManageFavoritesReaction.h"
81
82
#include "pqManageLinksReaction.h"
#include "pqManagePluginsReaction.h"
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
83
#include "pqPVApplicationCore.h"
84
#include "pqPropertiesPanel.h"
85
#include "pqProxyGroupMenuManager.h"
86
#include "pqRecentFilesMenu.h"
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
87
#include "pqReloadFilesReaction.h"
88
#include "pqRenameProxyReaction.h"
89
#include "pqRepresentationToolbar.h"
90
#include "pqResetDefaultSettingsReaction.h"
91
92
93
94
95
#include "pqSaveAnimationGeometryReaction.h"
#include "pqSaveAnimationReaction.h"
#include "pqSaveDataReaction.h"
#include "pqSaveScreenshotReaction.h"
#include "pqSaveStateReaction.h"
Nicolas Vuaille's avatar
Nicolas Vuaille committed
96
#include "pqSearchItemReaction.h"
97
98
#include "pqServerConnectReaction.h"
#include "pqServerDisconnectReaction.h"
99
#include "pqSetMainWindowTitleReaction.h"
100
#include "pqSetName.h"
101
#include "pqShowHideAllReaction.h"
102
#include "pqSourcesMenuReaction.h"
103
#include "pqTemporalExportReaction.h"
104
105
106
107
108
109
#include "pqTestingReaction.h"
#include "pqTimerLogReaction.h"
#include "pqUndoRedoReaction.h"
#include "pqVCRToolbar.h"
#include "pqViewMenuManager.h"

110
#if VTK_MODULE_ENABLE_ParaView_pqPython
111
#include "pqMacroReaction.h"
112
#include "pqPythonManager.h"
113
#include "pqTraceReaction.h"
114
115
#endif

116
#include <QApplication>
117
#include <QDockWidget>
118
#include <QFileInfo>
119
120
121
122
#include <QKeySequence>
#include <QLayout>
#include <QMainWindow>
#include <QMenu>
123
#include <QProxyStyle>
124
#include <QSysInfo>
125

126
#include "vtkPVFileInformation.h"
127
#include "vtkSMProxyManager.h"
128

129
130
131
132
133
134
135
//-----------------------------------------------------------------------------
class pqActiveDisabledStyle : public QProxyStyle
{
public:
  int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0,
    QStyleHintReturn* returnData = 0) const override
  {
136
137
138
    return hint == QStyle::SH_Menu_AllowActiveAndDisabled
      ? 1
      : QProxyStyle::styleHint(hint, option, widget, returnData);
139
140
141
  }
};

142
143
144
145
146
147
148
149
150
//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildFileMenu(QMenu& menu)
{
  QString objectName = menu.objectName();
  Ui::pqFileMenuBuilder ui;
  ui.setupUi(&menu);
  // since the UI file tends to change the name of the menu.
  menu.setObjectName(objectName);

Kitware Robot's avatar
Kitware Robot committed
151
  QObject::connect(
152
    ui.actionFileExit, SIGNAL(triggered()), QApplication::instance(), SLOT(closeAllWindows()));
153
154
155

  // now setup reactions.
  new pqLoadDataReaction(ui.actionFileOpen);
156
#if VTK_MODULE_ENABLE_VTK_RenderingRayTracing
157
158
  new pqLoadMaterialsReaction(ui.actionFileLoadMaterials);
#else
159
  ui.actionFileLoadMaterials->setEnabled(false);
160
#endif
161
  new pqRecentFilesMenu(*ui.menuRecentFiles, ui.menuRecentFiles);
162
  new pqReloadFilesReaction(ui.actionReloadFiles);
163
164
165

  new pqLoadStateReaction(ui.actionFileLoadServerState);
  new pqSaveStateReaction(ui.actionFileSaveServerState);
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
166
167
168
169
170
#if VTK_MODULE_ENABLE_ParaView_pqPython
  new pqCatalystExportReaction(ui.actionFileSaveCatalystState);
#else
  ui.actionFileSaveCatalystState->setEnabled(false);
#endif
171
172
173
174
175
176
177
178
179

  new pqServerConnectReaction(ui.actionServerConnect);
  new pqServerDisconnectReaction(ui.actionServerDisconnect);

  new pqSaveScreenshotReaction(ui.actionFileSaveScreenshot);
  new pqSaveAnimationReaction(ui.actionFileSaveAnimation);
  new pqSaveAnimationGeometryReaction(ui.actionFileSaveGeometry);

  new pqExportReaction(ui.actionExport);
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
180
  new pqImmediateExportReaction(ui.actionFileSaveExtracts);
181
  new pqSaveDataReaction(ui.actionFileSaveData);
182

183
184
  new pqLoadRestoreWindowLayoutReaction(true, ui.actionFileLoadWindowArrangement);
  new pqLoadRestoreWindowLayoutReaction(false, ui.actionFileSaveWindowArrangement);
185
186
187
}

//-----------------------------------------------------------------------------
188
void pqParaViewMenuBuilders::buildEditMenu(QMenu& menu, pqPropertiesPanel* propertiesPanel)
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{
  QString objectName = menu.objectName();
  Ui::pqEditMenuBuilder ui;
  ui.setupUi(&menu);
  // since the UI file tends to change the name of the menu.
  menu.setObjectName(objectName);

  new pqUndoRedoReaction(ui.actionEditUndo, true);
  new pqUndoRedoReaction(ui.actionEditRedo, false);
  new pqCameraUndoRedoReaction(ui.actionEditCameraUndo, true);
  new pqCameraUndoRedoReaction(ui.actionEditCameraRedo, false);
  new pqChangePipelineInputReaction(ui.actionChangeInput);
  new pqIgnoreSourceTimeReaction(ui.actionIgnoreTime);
  new pqDeleteReaction(ui.actionDelete);
203
  ui.actionDelete->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D));
204
  new pqDeleteReaction(ui.actionDelete_All, true);
205
206
  new pqShowHideAllReaction(ui.actionShow_All, pqShowHideAllReaction::ActionType::Show);
  new pqShowHideAllReaction(ui.actionHide_All, pqShowHideAllReaction::ActionType::Hide);
207
  new pqSaveScreenshotReaction(ui.actionCopyScreenshotToClipboard, true);
208
  new pqCopyReaction(ui.actionCopy);
209
  new pqCopyReaction(ui.actionPaste, true);
210
  new pqApplicationSettingsReaction(ui.actionEditSettings);
211
  new pqDataQueryReaction(ui.actionQuery);
Nicolas Vuaille's avatar
Nicolas Vuaille committed
212
  new pqSearchItemReaction(ui.actionSearch);
213
  new pqResetDefaultSettingsReaction(ui.actionResetDefaultSettings);
214
  new pqSetMainWindowTitleReaction(ui.actionSetMainWindowTitle);
215
  new pqRenameProxyReaction(ui.actionRename, propertiesPanel);
216
217
218

  if (propertiesPanel)
  {
219
    QAction* applyAction = new QAction(QIcon(":/pqWidgets/Icons/pqApply.svg"), "Apply", &menu);
220
    applyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
221
    QAction* resetAction = new QAction(QIcon(":/pqWidgets/Icons/pqCancel.svg"), "Reset", &menu);
222
    resetAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_R));
223
224
225
226
227
    menu.insertAction(ui.actionDelete, applyAction);
    menu.insertAction(ui.actionDelete, resetAction);
    new pqApplyPropertiesReaction(propertiesPanel, applyAction, true);
    new pqApplyPropertiesReaction(propertiesPanel, resetAction, false);
  }
228
229
230
}

//-----------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
231
void pqParaViewMenuBuilders::buildSourcesMenu(QMenu& menu, QMainWindow* mainWindow)
232
233
{
  pqProxyGroupMenuManager* mgr = new pqProxyGroupMenuManager(&menu, "ParaViewSources");
234
  mgr->addProxyDefinitionUpdateListener("sources");
David E. DeMarle's avatar
David E. DeMarle committed
235
  mgr->setRecentlyUsedMenuSize(10);
236
237
  new pqSourcesMenuReaction(mgr);
  if (mainWindow)
Kitware Robot's avatar
Kitware Robot committed
238
  {
239
240
    // create toolbars for categories as needed.
    new pqCategoryToolbarsBehavior(mgr, mainWindow);
Kitware Robot's avatar
Kitware Robot committed
241
  }
242
243
244
}

//-----------------------------------------------------------------------------
245
void pqParaViewMenuBuilders::buildFiltersMenu(
246
  QMenu& menu, QMainWindow* mainWindow, bool hideDisabled, bool quickLaunchable)
247
{
248
249
250
  // Make sure disabled actions are still considered active
  menu.setStyle(new pqActiveDisabledStyle);

251
252
  pqProxyGroupMenuManager* mgr =
    new pqProxyGroupMenuManager(&menu, "ParaViewFilters", quickLaunchable);
253
  mgr->addProxyDefinitionUpdateListener("filters");
254
  mgr->setRecentlyUsedMenuSize(10);
255
  mgr->setEnableFavorites(true);
256
  pqFiltersMenuReaction* menuReaction = new pqFiltersMenuReaction(mgr, hideDisabled);
257
258
259
260

  // Connect the filters menu about to show and the quick-launch dialog about to show
  // to update the enabled/disabled state of the menu items via the
  // pqFiltersMenuReaction
261
262
263
264
265
266
267
  menuReaction->connect(&menu, SIGNAL(aboutToShow()), SLOT(updateEnableState()));

  auto* pvappcore = pqPVApplicationCore::instance();
  if (quickLaunchable && pvappcore)
  {
    menuReaction->connect(pvappcore, SIGNAL(aboutToShowQuickLaunch()), SLOT(updateEnableState()));
  }
268
269

  if (mainWindow)
Kitware Robot's avatar
Kitware Robot committed
270
  {
271
272
    // create toolbars for categories as needed.
    new pqCategoryToolbarsBehavior(mgr, mainWindow);
Kitware Robot's avatar
Kitware Robot committed
273
  }
274
275
}

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildExtractGeneratorsMenu(
  QMenu& menu, QMainWindow* mainWindow, bool hideDisabled, bool quickLaunchable)
{
  // Make sure disabled actions are still considered active
  menu.setStyle(new pqActiveDisabledStyle);

  pqProxyGroupMenuManager* mgr =
    new pqProxyGroupMenuManager(&menu, "ParaViewExtractWriters", quickLaunchable);
  mgr->addProxyDefinitionUpdateListener("extract_writers");

  auto menuReaction = new pqExtractGeneratorsMenuReaction(mgr, hideDisabled);
  auto* pvappcore = pqPVApplicationCore::instance();
  if (quickLaunchable && pvappcore)
  {
    menuReaction->connect(pvappcore, SIGNAL(aboutToShowQuickLaunch()), SLOT(updateEnableState()));
  }

  if (mainWindow)
  {
    // create toolbars for categories as needed.
    new pqCategoryToolbarsBehavior(mgr, mainWindow);
  }
}

301
302
303
//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildToolsMenu(QMenu& menu)
{
Kitware Robot's avatar
Kitware Robot committed
304
305
306
307
308
309
  new pqCreateCustomFilterReaction(
    menu.addAction("Create Custom Filter...") << pqSetName("actionToolsCreateCustomFilter"));
  new pqCameraLinkReaction(
    menu.addAction("Add Camera Link...") << pqSetName("actionToolsAddCameraLink"));
  new pqLinkSelectionReaction(
    menu.addAction("Link with Selection") << pqSetName("actionToolsLinkSelection"));
310
  menu.addSeparator();
Kitware Robot's avatar
Kitware Robot committed
311
312
313
314
  new pqManageCustomFiltersReaction(
    menu.addAction("Manage Custom Filters...") << pqSetName("actionToolsManageCustomFilters"));
  new pqManageLinksReaction(
    menu.addAction("Manage Links...") << pqSetName("actionToolsManageLinks"));
315
  //<addaction name="actionToolsAddCameraLink" />
316
  // Add support for importing plugins only if ParaView was built shared.
Kitware Robot's avatar
Kitware Robot committed
317
318
  new pqManagePluginsReaction(
    menu.addAction("Manage Plugins...") << pqSetName("actionManage_Plugins"));
319

Nicolas Vuaille's avatar
Nicolas Vuaille committed
320
321
322
323
  QMenu* dummyMenu = new QMenu();
  pqProxyGroupMenuManager* mgr = new pqProxyGroupMenuManager(dummyMenu, "ParaViewFilters", false);
  mgr->addProxyDefinitionUpdateListener("filters");

324
325
326
  QAction* manageFavoritesAction = menu.addAction("Manage Favorites...")
    << pqSetName("actionManage_Favorites");
  new pqManageFavoritesReaction(manageFavoritesAction, mgr);
Nicolas Vuaille's avatar
Nicolas Vuaille committed
327

328
329
330
  new pqCustomizeShortcutsReaction(
    menu.addAction("Customize Shortcuts...") << pqSetName("actionCustomize"));

331
332
  menu.addSeparator(); // --------------------------------------------------

333
  //<addaction name="actionToolsDumpWidgetNames" />
Kitware Robot's avatar
Kitware Robot committed
334
  new pqTestingReaction(menu.addAction("Record Test...") << pqSetName("actionToolsRecordTest"),
335
    pqTestingReaction::RECORD);
Kitware Robot's avatar
Kitware Robot committed
336
337
338
  new pqTestingReaction(menu.addAction("Play Test...") << pqSetName("actionToolsPlayTest"),
    pqTestingReaction::PLAYBACK, Qt::QueuedConnection);
  new pqTestingReaction(menu.addAction("Lock View Size") << pqSetName("actionTesting_Window_Size"),
339
    pqTestingReaction::LOCK_VIEW_SIZE);
Kitware Robot's avatar
Kitware Robot committed
340
341
  new pqTestingReaction(
    menu.addAction("Lock View Size Custom...") << pqSetName("actionTesting_Window_Size_Custom"),
342
    pqTestingReaction::LOCK_VIEW_SIZE_CUSTOM);
343
  menu.addSeparator();
Kitware Robot's avatar
Kitware Robot committed
344
  new pqTimerLogReaction(menu.addAction("Timer Log") << pqSetName("actionToolsTimerLog"));
345
  new pqLogViewerReaction(menu.addAction("Log Viewer") << pqSetName("actionToolsLogViewer"));
346

347
#if VTK_MODULE_ENABLE_ParaView_pqPython
348
  menu.addSeparator(); // --------------------------------------------------
349
350
  new pqTraceReaction(menu.addAction("Start Trace") << pqSetName("actionToolsStartStopTrace"),
    "Start Trace", "Stop Trace");
351
#endif
352
353
354
355
356
357
358
359
360
}

//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildViewMenu(QMenu& menu, QMainWindow& mainWindow)
{
  new pqViewMenuManager(&mainWindow, &menu);
}

//-----------------------------------------------------------------------------
361
void pqParaViewMenuBuilders::buildPipelineBrowserContextMenu(QMenu& menu, QMainWindow* mainWindow)
362
{
363
364
365
366
  // Build the context menu manually so we can insert submenus where needed.
  QAction* actionPBOpen = new QAction(menu.parent());
  actionPBOpen->setObjectName(QStringLiteral("actionPBOpen"));
  QIcon icon4;
367
  icon4.addFile(QStringLiteral(":/pqWidgets/Icons/pqOpen.svg"), QSize(), QIcon::Normal, QIcon::Off);
368
369
370
371
372
373
374
375
376
377
378
379
380
  actionPBOpen->setIcon(icon4);
  actionPBOpen->setShortcutContext(Qt::WidgetShortcut);
  actionPBOpen->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Open", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBOpen->setToolTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Open", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_STATUSTIP
  actionPBOpen->setStatusTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Open", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

381
382
383
384
  QAction* actionPBShowAll = new QAction(menu.parent());
  actionPBShowAll->setObjectName(QStringLiteral("actionPBShowAll"));
  QIcon showAllIcon;
  showAllIcon.addFile(
385
    QStringLiteral(":/pqWidgets/Icons/pqEyeball.svg"), QSize(), QIcon::Normal, QIcon::Off);
386
387
388
389
390
  actionPBShowAll->setIcon(showAllIcon);
  actionPBShowAll->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Show All", Q_NULLPTR));
#ifndef QT_NO_STATUSTIP
  actionPBShowAll->setStatusTip(QApplication::translate(
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
391
    "pqPipelineBrowserContextMenu", "Show all source outputs in the pipeline", Q_NULLPTR));
392
393
#endif // QT_NO_STATUSTIP

394
395
  QAction* actionPBHideAll = new QAction(menu.parent());
  actionPBHideAll->setObjectName(QStringLiteral("actionPBHideAll"));
396
397
  QIcon hideAllIcon;
  hideAllIcon.addFile(
398
    QStringLiteral(":/pqWidgets/Icons/pqEyeballClosed.svg"), QSize(), QIcon::Normal, QIcon::Off);
399
  actionPBHideAll->setIcon(hideAllIcon);
400
401
402
403
404
405
406
407
408
409
  actionPBHideAll->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Hide All", Q_NULLPTR));
#ifndef QT_NO_STATUSTIP
  actionPBHideAll->setStatusTip(QApplication::translate(
    "pqPipelineBrowserContextMenu", "Hide all source outputs in the pipeline", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

  QAction* actionPBCopy = new QAction(menu.parent());
  actionPBCopy->setObjectName(QStringLiteral("actionPBCopy"));
  QIcon icon2;
410
  icon2.addFile(QStringLiteral(":/pqWidgets/Icons/pqCopy.svg"), QSize(), QIcon::Normal, QIcon::Off);
411
412
413
414
415
416
417
418
419
420
421
422
  actionPBCopy->setIcon(icon2);
  actionPBCopy->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Copy", Q_NULLPTR));
#ifndef QT_NO_STATUSTIP
  actionPBCopy->setStatusTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Copy Properties", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

  QAction* actionPBPaste = new QAction(menu.parent());
  actionPBPaste->setObjectName(QStringLiteral("actionPBPaste"));
  QIcon icon3;
  icon3.addFile(
423
    QStringLiteral(":/pqWidgets/Icons/pqPaste.svg"), QSize(), QIcon::Normal, QIcon::Off);
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
  actionPBPaste->setIcon(icon3);
  actionPBPaste->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Paste", Q_NULLPTR));
#ifndef QT_NO_STATUSTIP
  actionPBPaste->setStatusTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Paste Properties", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

  QAction* actionPBChangeInput = new QAction(menu.parent());
  actionPBChangeInput->setObjectName(QStringLiteral("actionPBChangeInput"));
  actionPBChangeInput->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Change &Input...", Q_NULLPTR));
  actionPBChangeInput->setIconText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Change Input...", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBChangeInput->setToolTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Change a Filter's Input", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_STATUSTIP
  actionPBChangeInput->setStatusTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Change a Filter's Input", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

  QAction* actionPBReloadFiles = new QAction(menu.parent());
  actionPBReloadFiles->setObjectName(QStringLiteral("actionPBReloadFiles"));
  actionPBReloadFiles->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Reload Files", Q_NULLPTR));
  actionPBReloadFiles->setIconText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Reload Files", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBReloadFiles->setToolTip(QApplication::translate("pqPipelineBrowserContextMenu",
    "Reload data files in case they were changed externally.", Q_NULLPTR));
#endif // QT_NO_TOOLTIP

  QAction* actionPBIgnoreTime = new QAction(menu.parent());
  actionPBIgnoreTime->setObjectName(QStringLiteral("actionPBIgnoreTime"));
  actionPBIgnoreTime->setCheckable(true);
  actionPBIgnoreTime->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Ignore Time", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBIgnoreTime->setToolTip(QApplication::translate("pqPipelineBrowserContextMenu",
    "Disregard this source/filter's time from animations", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_STATUSTIP
  actionPBIgnoreTime->setStatusTip(QApplication::translate("pqPipelineBrowserContextMenu",
    "Disregard this source/filter's time from animations", Q_NULLPTR));
#endif // QT_NO_STATUSTIP

  QAction* actionPBDelete = new QAction(menu.parent());
  actionPBDelete->setObjectName(QStringLiteral("actionPBDelete"));
  QIcon icon;
  icon.addFile(
476
    QStringLiteral(":/QtWidgets/Icons/pqDelete.svg"), QSize(), QIcon::Normal, QIcon::Off);
477
478
479
480
481
482
483
  actionPBDelete->setIcon(icon);
  actionPBDelete->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Delete", Q_NULLPTR));
#ifndef QT_NO_STATUSTIP
  actionPBDelete->setStatusTip(
    QApplication::translate("pqPipelineBrowserContextMenu", "Delete", Q_NULLPTR));
#endif // QT_NO_STATUSTIP
484

Kitware Robot's avatar
Kitware Robot committed
485
  QByteArray signalName = QMetaObject::normalizedSignature("deleteKey()");
486
  if (menu.parent()->metaObject()->indexOfSignal(signalName) != -1)
Kitware Robot's avatar
Kitware Robot committed
487
  {
488
    // Trigger a delete when the user requests a delete.
Kitware Robot's avatar
Kitware Robot committed
489
    QObject::connect(
490
      menu.parent(), SIGNAL(deleteKey()), actionPBDelete, SLOT(trigger()), Qt::QueuedConnection);
Kitware Robot's avatar
Kitware Robot committed
491
  }
492

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
  QAction* actionPBCreateCustomFilter = new QAction(menu.parent());
  actionPBCreateCustomFilter->setObjectName(QStringLiteral("actionPBCreateCustomFilter"));
  actionPBCreateCustomFilter->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "&Create Custom Filter...", Q_NULLPTR));

  QAction* actionPBLinkSelection = new QAction(menu.parent());
  actionPBLinkSelection->setObjectName(QStringLiteral("actionPBLinkSelection"));
  actionPBLinkSelection->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Link with selection", Q_NULLPTR));
  actionPBLinkSelection->setIconText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Link with selection", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBLinkSelection->setToolTip(QApplication::translate("pqPipelineBrowserContextMenu",
    "Link this source and current selected source as a selection link", Q_NULLPTR));
#endif // QT_NO_TOOLTIP

509
510
511
512
513
514
515
516
517
518
519
520
521
  QAction* actionPBRename = new QAction(menu.parent());
  actionPBRename->setObjectName(QStringLiteral("actionPBRename"));
  actionPBRename->setText(
    QApplication::translate("pqPipelineBrowserContextMenu", "Rename", Q_NULLPTR));
#ifndef QT_NO_TOOLTIP
  actionPBRename->setToolTip(QApplication::translate(
    "pqPipelineBrowserContextMenu", "Rename currently selected source", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
#ifndef QT_NO_STATUSTIP
  actionPBRename->setStatusTip(QApplication::translate(
    "pqPipelineBrowserContextMenu", "Rename currently selected source", Q_NULLPTR));
#endif // QT_NO_TOOLTIP

522
  menu.addAction(actionPBOpen);
523
  menu.addAction(actionPBShowAll);
524
  menu.addAction(actionPBHideAll);
525
  menu.addSeparator();
526
527
  menu.addAction(actionPBCopy);
  menu.addAction(actionPBPaste);
528
529
530
531
532
533
  menu.addSeparator();
  menu.addAction(actionPBDelete);
  menu.addAction(actionPBRename);
  menu.addAction(actionPBReloadFiles);
  menu.addAction(actionPBIgnoreTime);
  menu.addSeparator();
534
  menu.addAction(actionPBChangeInput);
535
  QMenu* addFilterMenu = menu.addMenu("Add Filter");
536
537
  pqParaViewMenuBuilders::buildFiltersMenu(
    *addFilterMenu, nullptr, true /*hide disabled*/, false /*quickLaunchable*/);
538
  menu.addSeparator();
539
540
541
  menu.addAction(actionPBCreateCustomFilter);
  menu.addAction(actionPBLinkSelection);

542
543
  // And here the reactions come in handy! Just reuse the reaction used for
  // File | Open.
544
  new pqLoadDataReaction(actionPBOpen);
545
546
  new pqShowHideAllReaction(actionPBShowAll, pqShowHideAllReaction::ActionType::Show);
  new pqShowHideAllReaction(actionPBHideAll, pqShowHideAllReaction::ActionType::Hide);
547
548
549
550
551
552
553
554
  new pqCopyReaction(actionPBCopy);
  new pqCopyReaction(actionPBPaste, true);
  new pqChangePipelineInputReaction(actionPBChangeInput);
  new pqReloadFilesReaction(actionPBReloadFiles);
  new pqIgnoreSourceTimeReaction(actionPBIgnoreTime);
  new pqDeleteReaction(actionPBDelete);
  new pqCreateCustomFilterReaction(actionPBCreateCustomFilter);
  new pqLinkSelectionReaction(actionPBLinkSelection);
555
  new pqRenameProxyReaction(actionPBRename, mainWindow);
556
557
558
}

//-----------------------------------------------------------------------------
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
559
void pqParaViewMenuBuilders::buildMacrosMenu(QMenu& menu)
560
{
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
561
  Q_UNUSED(menu);
562
#if VTK_MODULE_ENABLE_ParaView_pqPython
563
564
565
  // Give the macros menu to the pqPythonMacroSupervisor
  pqPythonManager* manager = pqPVApplicationCore::instance()->pythonManager();
  if (manager)
Kitware Robot's avatar
Kitware Robot committed
566
  {
567
    new pqMacroReaction(menu.addAction("Import new macro...") << pqSetName("actionMacroCreate"));
Kitware Robot's avatar
Kitware Robot committed
568
569
    QMenu* editMenu = menu.addMenu("Edit...");
    QMenu* deleteMenu = menu.addMenu("Delete...");
Sebastien Jourdain's avatar
Sebastien Jourdain committed
570
571
572
573
    menu.addSeparator();
    manager->addWidgetForRunMacros(&menu);
    manager->addWidgetForEditMacros(editMenu);
    manager->addWidgetForDeleteMacros(deleteMenu);
Kitware Robot's avatar
Kitware Robot committed
574
  }
575
576
577
578
579
580
#endif
}

//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildHelpMenu(QMenu& menu)
{
581
  QString documentationPath(vtkPVFileInformation::GetParaViewDocDirectory().c_str());
582
583
  QString paraViewGettingStartedFile = documentationPath + "/GettingStarted.pdf";

Cory Quammen's avatar
Cory Quammen committed
584
  // Getting Started with ParaView
Kitware Robot's avatar
Kitware Robot committed
585
586
  new pqDesktopServicesReaction(QUrl::fromLocalFile(paraViewGettingStartedFile),
    (menu.addAction(QIcon(":/pqWidgets/Icons/pdf.png"), "Getting Started with ParaView")
587
588
589
590
591
592
593
594
595
596
597
598
599
      << pqSetName("actionGettingStarted")));

  QString versionString = QString("%1.%2.%3")
                            .arg(vtkSMProxyManager::GetVersionMajor())
                            .arg(vtkSMProxyManager::GetVersionMinor())
                            .arg(vtkSMProxyManager::GetVersionPatch());

  // ParaView Guide. If there is a copy local to the install tree, use it instead of going
  // out to the web.
  QString paraViewGuideFile =
    QString("%1/ParaViewGuide-%2.pdf").arg(documentationPath).arg(versionString);
  QFile guideLocalFile(paraViewGuideFile);
  QAction* guide = menu.addAction("ParaView Guide");
600
601
  guide->setObjectName("actionGuide");
  guide->setShortcut(QKeySequence::HelpContents);
602
603
604
605
606
607
608
609
610
611
612
613
  if (guideLocalFile.exists())
  {
    guide->setIcon(QIcon(":/pqWidgets/Icons/pdf.png"));
    QUrl guideUrl = QUrl::fromLocalFile(paraViewGuideFile);
    new pqDesktopServicesReaction(guideUrl, guide);
  }
  else
  {
    // Remote ParaView Guide
    QString guideURL = QString("https://docs.paraview.org/en/v%1/").arg(versionString);
    new pqDesktopServicesReaction(QUrl(guideURL), guide);
  }
614

615
#ifdef PARAVIEW_USE_QTHELP
616
  // Help
Kitware Robot's avatar
Kitware Robot committed
617
  QAction* help = menu.addAction("Reader, Filter, and Writer Reference") << pqSetName("actionHelp");
618
  new pqHelpReaction(help);
619
#endif
620

Cory Quammen's avatar
Cory Quammen committed
621
622
623
  // -----------------
  menu.addSeparator();

624
625
626
627
628
629
630
  // ParaView Tutorial
  QString tutorialURL = QString("https://www.paraview.org/paraview-downloads/"
                                "download.php?submit=Download&version=v%1.%2&type=binary&os="
                                "Sources&downloadFile=ParaViewTutorial-%1.%2.%3.pdf")
                          .arg(vtkSMProxyManager::GetVersionMajor())
                          .arg(vtkSMProxyManager::GetVersionMinor())
                          .arg(vtkSMProxyManager::GetVersionPatch());
631
632
633
  new pqDesktopServicesReaction(QUrl(tutorialURL),
    (menu.addAction(QIcon(":/pqWidgets/Icons/pdf.png"), "ParaView Tutorial")
      << pqSetName("actionTutorialNotes")));
Cory Quammen's avatar
Cory Quammen committed
634
635

  // Sandia National Labs Tutorials
Kitware Robot's avatar
Kitware Robot committed
636
  new pqDesktopServicesReaction(QUrl("http://www.paraview.org/Wiki/SNL_ParaView_4_Tutorials"),
Cory Quammen's avatar
Cory Quammen committed
637
638
639
640
641
    (menu.addAction("Sandia National Labs Tutorials") << pqSetName("actionSNLTutorial")));

  // Example Data Sets

  // Example Visualizations
642
643
  new pqExampleVisualizationsDialogReaction(
    menu.addAction("Example Visualizations") << pqSetName("ExampleVisualizations"));
Cory Quammen's avatar
Cory Quammen committed
644
645

  // -----------------
646
  menu.addSeparator();
Cory Quammen's avatar
Cory Quammen committed
647
648

  // ParaView Web Site
Kitware Robot's avatar
Kitware Robot committed
649
  new pqDesktopServicesReaction(QUrl("http://www.paraview.org"),
Cory Quammen's avatar
Cory Quammen committed
650
651
652
    (menu.addAction("ParaView Web Site") << pqSetName("actionWebSite")));

  // ParaView Wiki
Kitware Robot's avatar
Kitware Robot committed
653
  new pqDesktopServicesReaction(QUrl("http://www.paraview.org/Wiki/ParaView"),
Cory Quammen's avatar
Cory Quammen committed
654
655
    (menu.addAction("ParaView Wiki") << pqSetName("actionWiki")));

656
657
658
  // ParaView Community Support
  new pqDesktopServicesReaction(QUrl("http://www.paraview.org/community-support/"),
    (menu.addAction("ParaView Community Support") << pqSetName("actionCommunitySupport")));
Cory Quammen's avatar
Cory Quammen committed
659
660
661
662
663
664
665
666
667
668
669

  // ParaView Release Notes
  versionString.replace('.', '-');
  new pqDesktopServicesReaction(
    QUrl("https://blog.kitware.com/paraview-" + versionString + "-release-notes/"),
    (menu.addAction("Release Notes") << pqSetName("actionReleaseNotes")));

  // -----------------
  menu.addSeparator();

  // Professional Support
Kitware Robot's avatar
Kitware Robot committed
670
  new pqDesktopServicesReaction(QUrl("http://www.kitware.com/products/paraviewpro.html"),
Cory Quammen's avatar
Cory Quammen committed
671
672
673
    (menu.addAction("Professional Support") << pqSetName("actionProfessionalSupport")));

  // Professional Training
Kitware Robot's avatar
Kitware Robot committed
674
  new pqDesktopServicesReaction(QUrl("http://www.kitware.com/products/protraining.php"),
Cory Quammen's avatar
Cory Quammen committed
675
676
677
    (menu.addAction("Professional Training") << pqSetName("actionTraining")));

  // Online Tutorials
Kitware Robot's avatar
Kitware Robot committed
678
  new pqDesktopServicesReaction(QUrl("http://www.paraview.org/tutorials/"),
679
    (menu.addAction("Online Tutorials") << pqSetName("actionTutorials")));
Cory Quammen's avatar
Cory Quammen committed
680
681

  // Online Blogs
Kitware Robot's avatar
Kitware Robot committed
682
  new pqDesktopServicesReaction(QUrl("https://blog.kitware.com/tag/ParaView/"),
683
684
    (menu.addAction("Online Blogs") << pqSetName("actionBlogs")));

Cory Quammen's avatar
Cory Quammen committed
685
686
#if !defined(__APPLE__)
  // -----------------
687
  menu.addSeparator();
Cory Quammen's avatar
Cory Quammen committed
688
689
#endif

690
  // Bug report
691
  QString bugReportURL = QString("https://gitlab.kitware.com/paraview/paraview/-/issues/"
692
693
694
695
696
697
698
699
                                 "new?issue[title]=Bug&issue[description]="
                                 "OS: %1\nParaView Version: %2\nQt Version: %3\n\nDescription")
                           .arg(QSysInfo::prettyProductName())
                           .arg(PARAVIEW_VERSION_FULL)
                           .arg(QT_VERSION_STR);
  new pqDesktopServicesReaction(
    QUrl(bugReportURL), (menu.addAction("Bug Report") << pqSetName("bugReport")));

Cory Quammen's avatar
Cory Quammen committed
700
  // About
Kitware Robot's avatar
Kitware Robot committed
701
  new pqAboutDialogReaction(menu.addAction("About...") << pqSetName("actionAbout"));
702
703
704
705
706
707
708
709
710
711
}

//-----------------------------------------------------------------------------
void pqParaViewMenuBuilders::buildToolbars(QMainWindow& mainWindow)
{
  QToolBar* mainToolBar = new pqMainControlsToolbar(&mainWindow)
    << pqSetName("MainControlsToolbar");
  mainToolBar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, mainToolBar);

Kitware Robot's avatar
Kitware Robot committed
712
  QToolBar* vcrToolbar = new pqVCRToolbar(&mainWindow) << pqSetName("VCRToolbar");
713
714
715
716
717
718
719
720
  vcrToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, vcrToolbar);

  QToolBar* timeToolbar = new pqAnimationTimeToolbar(&mainWindow)
    << pqSetName("currentTimeToolbar");
  timeToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, timeToolbar);

721
722
723
724
725
726
727
  QToolBar* customViewpointsToolbar = new pqCustomViewpointsToolbar(&mainWindow)
    << pqSetName("customViewpointsToolbar");
  customViewpointsToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, customViewpointsToolbar);

  mainWindow.addToolBarBreak();

Kitware Robot's avatar
Kitware Robot committed
728
  QToolBar* colorToolbar = new pqColorToolbar(&mainWindow) << pqSetName("variableToolbar");
729
730
  colorToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, colorToolbar);
731

732
733
734
735
736
  QToolBar* reprToolbar = new pqRepresentationToolbar(&mainWindow)
    << pqSetName("representationToolbar");
  reprToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, reprToolbar);

Kitware Robot's avatar
Kitware Robot committed
737
  QToolBar* cameraToolbar = new pqCameraToolbar(&mainWindow) << pqSetName("cameraToolbar");
738
739
740
  cameraToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, cameraToolbar);

Kitware Robot's avatar
Kitware Robot committed
741
  QToolBar* axesToolbar = new pqAxesToolbar(&mainWindow) << pqSetName("axesToolbar");
742
743
744
  axesToolbar->layout()->setSpacing(0);
  mainWindow.addToolBar(Qt::TopToolBarArea, axesToolbar);

745
#if VTK_MODULE_ENABLE_ParaView_pqPython
746
  // Give the macros menu to the pqPythonMacroSupervisor
Kitware Robot's avatar
Kitware Robot committed
747
748
  pqPythonManager* manager =
    qobject_cast<pqPythonManager*>(pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
749
  if (manager)
Kitware Robot's avatar
Kitware Robot committed
750
  {
751
752
    QToolBar* macrosToolbar = new QToolBar("Macros Toolbars", &mainWindow)
      << pqSetName("MacrosToolbar");
Sebastien Jourdain's avatar
Sebastien Jourdain committed
753
    manager->addWidgetForRunMacros(macrosToolbar);
754
    mainWindow.addToolBar(Qt::TopToolBarArea, macrosToolbar);
Kitware Robot's avatar
Kitware Robot committed
755
  }
756
757
#endif
}
758
759

//-----------------------------------------------------------------------------
760
void pqParaViewMenuBuilders::buildCatalystMenu(QMenu& menu)
761
{
Kitware Robot's avatar
Kitware Robot committed
762
  new pqCatalystConnectReaction(menu.addAction("Connect...") << pqSetName("actionCatalystConnect"));
763
  new pqCatalystPauseSimulationReaction(
Kitware Robot's avatar
Kitware Robot committed
764
    menu.addAction("Pause Simulation") << pqSetName("actionCatalystPauseSimulation"));
765

Kitware Robot's avatar
Kitware Robot committed
766
  new pqCatalystContinueReaction(menu.addAction("Continue") << pqSetName("actionCatalystContinue"));
767
768

  new pqCatalystSetBreakpointReaction(
Kitware Robot's avatar
Kitware Robot committed
769
    menu.addAction("Set Breakpoint") << pqSetName("actionCatalystSetBreakpoint"));
770
771

  new pqCatalystRemoveBreakpointReaction(
Kitware Robot's avatar
Kitware Robot committed
772
    menu.addAction("Remove Breakpoint") << pqSetName("actionCatalystRemoveBreakpoint"));
773
}