pqRenderView.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqRenderView_h
5 #define pqRenderView_h
6 
7 #include "pqRenderViewBase.h"
8 #include "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATION
9 #include <QColor> // needed for return type.
10 #include <QCursor> // needed for return type.
11 
13 class QAction;
14 class vtkCollection;
15 class vtkIntArray;
17 
18 // This is a PQ abstraction of a render view.
19 class PQCORE_EXPORT pqRenderView : public pqRenderViewBase
20 {
21  Q_OBJECT
23 
24 public:
25  static QString renderViewType() { return "RenderView"; }
26 
27  // Constructor:
28  // \c group :- SManager registration group name.
29  // \c name :- SManager registration name.
30  // \c view :- RenderView proxy.
31  // \c server:- server on which the proxy is created.
32  // \c parent:- QObject parent.
33  pqRenderView(const QString& group, const QString& name, vtkSMViewProxy* renModule,
34  pqServer* server, QObject* parent = nullptr);
35 
36  // This version allows subclasses to substitute their own renderViewType.
37  pqRenderView(const QString& tname, const QString& group, const QString& name,
38  vtkSMViewProxy* renModule, pqServer* server, QObject* parent = nullptr);
39 
40  // Destructor.
41  ~pqRenderView() override;
42 
46  virtual vtkSMRenderViewProxy* getRenderViewProxy() const;
47 
55  void resetCamera(bool closest = false, double offsetRatio = 0.9) override;
56 
60  virtual void resetCenterOfRotation();
61 
65  virtual void resetParallelScale();
66 
70  virtual bool getOrientationAxesVisibility() const;
71 
75  virtual bool getOrientationAxesInteractivity() const;
76 
80  virtual QColor getOrientationAxesLabelColor() const;
81 
85  virtual QColor getOrientationAxesOutlineColor() const;
86 
90  virtual bool getResetCenterWithCamera() const { return this->ResetCenterWithCamera; }
91 
96  {
97  return this->UseMultipleRepresentationSelection;
98  }
99 
103  virtual bool getCenterAxesVisibility() const;
104 
108  virtual void getCenterOfRotation(double center[3]) const;
109 
114  bool supportsUndo() const override { return true; }
115 
117 
121  bool canUndo() const override;
122  bool canRedo() const override;
124 
129  bool supportsCapture() const override { return true; }
130 
132 
137  virtual void linkUndoStack(pqRenderView* other);
138  virtual void unlinkUndoStack(pqRenderView* other);
140 
144  virtual void clearUndoStack();
145 
149  virtual void resetViewDirection(
150  double look_x, double look_y, double look_z, double up_x, double up_y, double up_z);
151  virtual void adjustView(const int& adjustType, const double& angle);
152  virtual void adjustAzimuth(const double& value);
153  virtual void adjustElevation(const double& value);
154  virtual void adjustRoll(const double& value);
155  virtual void adjustZoom(const double& value);
156  virtual void applyIsometricView();
157  virtual void resetViewDirectionToPositiveX();
158  virtual void resetViewDirectionToNegativeX();
159  virtual void resetViewDirectionToPositiveY();
160  virtual void resetViewDirectionToNegativeY();
161  virtual void resetViewDirectionToPositiveZ();
162  virtual void resetViewDirectionToNegativeZ();
163 
165 
171  virtual void setCursor(const QCursor&);
172  virtual QCursor cursor();
174 
176 
180  void setCursorVisible(bool visible);
181  bool cursorVisible();
183 
185 
189  PARAVIEW_DEPRECATED_IN_5_11_0("Use selectCellsOnSurface instead.")
190  virtual void selectOnSurface(int rectangle[4],
191  int selectionModifier = pqView::PV_SELECTION_DEFAULT, const char* array = nullptr)
192  {
193  this->selectCellsOnSurface(rectangle, selectionModifier, array);
194  }
195  virtual void selectCellsOnSurface(int rectangle[4],
196  int selectionModifier = pqView::PV_SELECTION_DEFAULT, const char* array = nullptr);
197  virtual void selectPointsOnSurface(int rectangle[4],
198  int selectionModifier = pqView::PV_SELECTION_DEFAULT, const char* array = nullptr);
200 
206  virtual pqDataRepresentation* pick(int pos[2]);
207 
218  virtual pqDataRepresentation* pickBlock(int pos[2], unsigned int& flatIndex, int& rank);
219 
221 
225  PARAVIEW_DEPRECATED_IN_5_11_0("Use selectFrustumCells instead.")
226  virtual void selectFrustum(int rectangle[4]) { this->selectFrustumCells(rectangle); }
227  virtual void selectFrustumCells(
228  int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
229  virtual void selectFrustumPoints(
230  int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
232 
237  virtual void selectBlock(int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
238 
240 
244  virtual void selectPolygonPoints(
245  vtkIntArray* polygon, int selectionModifier = pqView::PV_SELECTION_DEFAULT);
246  virtual void selectPolygonCells(
247  vtkIntArray* polygon, int selectionModifier = pqView::PV_SELECTION_DEFAULT);
249 
250 Q_SIGNALS:
251  // Triggered when interaction mode change underneath
252  void updateInteractionMode(int mode);
253 
254 public Q_SLOTS:
255  // Toggle the orientation axes visibility.
256  virtual void setOrientationAxesVisibility(bool visible);
257 
258  // Toggle orientation axes interactivity.
259  virtual void setOrientationAxesInteractivity(bool interactive);
260 
261  // Set orientation axes label color.
262  virtual void setOrientationAxesLabelColor(const QColor&);
263 
264  // Set orientation axes outline color.
265  virtual void setOrientationAxesOutlineColor(const QColor&);
266 
267  // Set the center of rotation. For this to work,
268  // one should have appropriate interaction style (vtkPVInteractorStyle subclass)
269  // and camera manipulators that use the center of rotation.
270  // They are setup correctly by default.
271  virtual void setCenterOfRotation(double x, double y, double z);
272  virtual void setCenterOfRotation(double xyz[3])
273  {
274  this->setCenterOfRotation(xyz[0], xyz[1], xyz[2]);
275  }
276 
277  // Set the parallel scale
278  virtual void setParallelScale(double scale);
279 
280  // Toggle center axes visibility.
281  virtual void setCenterAxesVisibility(bool visible);
282 
287  virtual void setResetCenterWithCamera(bool b) { this->ResetCenterWithCamera = b; }
288 
293  {
294  this->UseMultipleRepresentationSelection = b;
295  }
296 
300  virtual void linkToOtherView();
301 
306  void undo() override;
307 
312  void redo() override;
313 
317  virtual void resetCenterOfRotationIfNeeded() { this->onResetCameraEvent(); }
318 
322  virtual void updateInteractionMode(pqOutputPort* opPort);
323 
324 protected Q_SLOTS:
328  virtual void onInteractionModeChange();
329 
333  virtual void onGenericFilmicPresetsChange();
334 
335  // Called when vtkSMRenderViewProxy fires ResetCameraEvent.
336  virtual void onResetCameraEvent();
337 
342  virtual void onUndoStackChanged();
343 
344 protected: // NOLINT(readability-redundant-access-specifiers)
348  virtual void fakeUndoRedo(bool redo, bool self);
349 
355  virtual void fakeInteraction(bool start);
356 
361  QWidget* createWidget() override;
362 
366  void initialize() override;
367 
368  // When true, the camera center of rotation will be reset when the
369  // user reset the camera.
371 
372  // When true, the selection will be performed on all representations.
374 
375 private:
376  void selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>&, bool select_points,
377  int selectionModifier, bool select_blocks, const char* array = nullptr);
378 
379  void selectPolygonInternal(vtkIntArray* polygon, QList<pqOutputPort*>&, bool select_points,
380  int selectionModifier, bool select_blocks);
381 
382  void emitSelectionSignal(QList<pqOutputPort*> outputPorts, int selectionModifier);
383 
384  void collectSelectionPorts(vtkCollection* selectedRepresentations,
385  vtkCollection* selectionSources, QList<pqOutputPort*>& pqPorts, int selectionModifier,
386  bool select_blocks);
387 
388  void InternalConstructor(vtkSMViewProxy* renModule);
389 
390  class pqInternal;
391  pqInternal* Internal;
392 };
393 
394 #endif
pqView::canUndo
virtual bool canUndo() const
Returns true if undo can be done.
Definition: pqView.h:122
pqRenderViewBase.h
vtkSMRenderViewProxy
implementation for View that includes render window and renderers.
Definition: vtkSMRenderViewProxy.h:27
pqView
This is a PQ abstraction of a generic view module.
Definition: pqView.h:26
pqRenderView::getResetCenterWithCamera
virtual bool getResetCenterWithCamera() const
Get whether resetCamera() resets the center of rotation as well.
Definition: pqRenderView.h:90
pqDataRepresentation
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
Definition: pqDataRepresentation.h:24
pqView::PV_SELECTION_DEFAULT
@ PV_SELECTION_DEFAULT
Definition: pqView.h:34
pqRenderView::UseMultipleRepresentationSelection
bool UseMultipleRepresentationSelection
Definition: pqRenderView.h:373
vtkCollection
pqServer
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:35
pqView::canRedo
virtual bool canRedo() const
Returns true if redo can be done.
Definition: pqView.h:127
vtkIntArray
pqRenderView::supportsCapture
bool supportsCapture() const override
Returns if this view module can support image capture.
Definition: pqRenderView.h:129
pqRenderView::setUseMultipleRepresentationSelection
virtual void setUseMultipleRepresentationSelection(bool b)
Set whether selection will be done on multiple representations.
Definition: pqRenderView.h:292
pqRenderView::setResetCenterWithCamera
virtual void setResetCenterWithCamera(bool b)
Get/Set whether resetCamera() resets the center of rotation as well.
Definition: pqRenderView.h:287
pqRenderView::ResetCenterWithCamera
bool ResetCenterWithCamera
Definition: pqRenderView.h:370
pqRenderView
Definition: pqRenderView.h:19
vtkParaViewDeprecation.h
pqView::redo
virtual void redo()
Called to redo interaction.
Definition: pqView.h:109
pqRenderViewBase::resetCamera
virtual void resetCamera(bool closest=false, double offsetRatio=0.9)=0
Resets the camera to include all visible data.
pqRenderView::resetCenterOfRotationIfNeeded
virtual void resetCenterOfRotationIfNeeded()
Resets center of rotation if this->ResetCenterWithCamera is true.
Definition: pqRenderView.h:317
pqRenderView::getUseMultipleRepresentationSelection
virtual bool getUseMultipleRepresentationSelection() const
Get whether selection will be done on multiple representations.
Definition: pqRenderView.h:95
pqView::undo
virtual void undo()
Called to undo interaction.
Definition: pqView.h:103
vtkSMViewProxy
Superclass for all view proxies.
Definition: vtkSMViewProxy.h:42
pqRenderViewBase::createWidget
QWidget * createWidget() override
Creates a new instance of the QWidget subclass to be used to show this view.
PARAVIEW_DEPRECATED_IN_5_11_0
#define PARAVIEW_DEPRECATED_IN_5_11_0(reason)
Definition: vtkParaViewDeprecation.h:109
pqRenderView::setCenterOfRotation
virtual void setCenterOfRotation(double xyz[3])
Definition: pqRenderView.h:272
pqRenderView::renderViewType
static QString renderViewType()
Definition: pqRenderView.h:25
pqRenderView::supportsUndo
bool supportsUndo() const override
Returns if this view module can support undo/redo.
Definition: pqRenderView.h:114
pqRenderViewBase
pqRenderViewBase is an abstract base class for all render-view based views.
Definition: pqRenderViewBase.h:16
pqOutputPort
pqOutputPort is a server manager model item for an output port of any pqPipelineSource item.
Definition: pqOutputPort.h:29
pqRenderViewBase::initialize
void initialize() override
Use this method to initialize the pqObject state using the underlying vtkSMProxy.