ParaView
pqRenderView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqRenderView.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  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  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 #ifndef pqRenderViewModule_h
33 #define pqRenderViewModule_h
34 
35 
36 #include "pqRenderViewBase.h"
37 #include <QColor> // needed for return type.
38 
40 class QAction;
41 class QVTKWidget;
42 class vtkCollection;
43 class vtkIntArray;
44 class vtkSMRenderViewProxy;
45 
46 // This is a PQ abstraction of a render view.
47 class PQCORE_EXPORT pqRenderView : public pqRenderViewBase
48 {
49  Q_OBJECT
51 
52 public:
53  static QString renderViewType() { return "RenderView"; }
54 
55  // Constructor:
56  // \c group :- SManager registration group name.
57  // \c name :- SManager registration name.
58  // \c view :- RenderView proxy.
59  // \c server:- server on which the proxy is created.
60  // \c parent:- QObject parent.
61  pqRenderView( const QString& group,
62  const QString& name,
63  vtkSMViewProxy* renModule,
64  pqServer* server,
65  QObject* parent=NULL);
66 
67  // This version allows subclasses to substitute their own renderViewType.
68  pqRenderView( const QString& tname,
69  const QString& group,
70  const QString& name,
71  vtkSMViewProxy* renModule,
72  pqServer* server,
73  QObject* parent=NULL);
74 
75  // Destructor.
76  virtual ~pqRenderView();
77 
79  virtual vtkSMRenderViewProxy* getRenderViewProxy() const;
80 
84  virtual void resetCamera();
85 
87  void resetCenterOfRotation();
88 
90  bool getOrientationAxesVisibility() const;
91 
93  bool getOrientationAxesInteractivity() const;
94 
96  QColor getOrientationAxesLabelColor() const;
97 
99  QColor getOrientationAxesOutlineColor() const;
100 
104  { return this->ResetCenterWithCamera; }
105 
108  { return this->UseMultipleRepresentationSelection; }
109 
111  bool getCenterAxesVisibility() const;
112 
114  void getCenterOfRotation(double center[3]) const;
115 
119  virtual bool supportsUndo() const { return true; }
120 
123  virtual bool canUndo() const;
124  virtual bool canRedo() const;
125 
129  void linkUndoStack(pqRenderView* other);
130  void unlinkUndoStack(pqRenderView* other);
131 
134  void clearUndoStack();
135 
137  void resetViewDirection(
138  double look_x, double look_y, double look_z,
139  double up_x, double up_y, double up_z);
140 
145  virtual void setCursor(const QCursor &);
146 
147 public:
150  void selectOnSurface(int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
151  void selectPointsOnSurface(int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
152 
156  pqDataRepresentation* pick(int pos[2]);
157 
161  pqDataRepresentation* pickBlock(int pos[2], unsigned int &flatIndex);
162 
165  void selectFrustum(int rectangle[4]);
166  void selectFrustumPoints(int rectangle[4]);
167 
170  void selectBlock(int rectangle[4], int selectionModifier = pqView::PV_SELECTION_DEFAULT);
171 
174  void selectPolygonPoints(vtkIntArray* polygon, int selectionModifier = pqView::PV_SELECTION_DEFAULT);
175 
178  void selectPolygonCells(vtkIntArray* polygon, int selectionModifier = pqView::PV_SELECTION_DEFAULT);
179 
180 signals:
181  // Triggered when interaction mode change underneath
182  void updateInteractionMode(int mode);
183 
184 public slots:
185  // Toggle the orientation axes visibility.
186  void setOrientationAxesVisibility(bool visible);
187 
188  // Toggle orientation axes interactivity.
189  void setOrientationAxesInteractivity(bool interactive);
190 
191  // Set orientation axes label color.
192  void setOrientationAxesLabelColor(const QColor&);
193 
194  // Set orientation axes outline color.
195  void setOrientationAxesOutlineColor(const QColor&);
196 
197  // Set the center of rotation. For this to work,
198  // one should have approriate interaction style (vtkPVInteractorStyle subclass)
199  // and camera manipulators that use the center of rotation.
200  // They are setup correctly by default.
201  void setCenterOfRotation(double x, double y, double z);
202  void setCenterOfRotation(double xyz[3])
203  {
204  this->setCenterOfRotation(xyz[0], xyz[1], xyz[2]);
205  }
206 
207  // Toggle center axes visibility.
208  void setCenterAxesVisibility(bool visible);
209 
213  { this->ResetCenterWithCamera = b;}
214 
217  { this->UseMultipleRepresentationSelection = b;}
218 
220  void linkToOtherView();
221 
224  virtual void undo();
225 
228  virtual void redo();
229 
232  { this->onResetCameraEvent(); }
233 
235  void updateInteractionMode(pqOutputPort* opPort);
236 
237 private slots:
238  // Called when vtkSMRenderViewProxy fires
239  // ResetCameraEvent.
240  void onResetCameraEvent();
241 
244  void onUndoStackChanged();
245 
247  void onInteractionModeChange();
248 
249 protected:
250  // When true, the camera center of rotation will be reset when the
251  // user reset the camera.
253 
254  // When true, the selection will be performed on all representations.
256 
258  void fakeUndoRedo(bool redo, bool self);
259 
263  void fakeInteraction(bool start);
264 
267  virtual QWidget* createWidget();
268 
270  virtual void initialize();
271 private:
272  class pqInternal;
273  pqInternal* Internal;
274  void selectOnSurfaceInternal(int rect[4], QList<pqOutputPort*>&,
275  bool select_points, int selectionModifier, bool select_blocks);
276  void selectPolygonInternal(vtkIntArray* polygon, QList<pqOutputPort*>&,
277  bool select_points, int selectionModifier, bool select_blocks);
278 
279  void emitSelectionSignal(QList<pqOutputPort*>);
280  void collectSelectionPorts(vtkCollection* selectedRepresentations,
281  vtkCollection* selectionSources, QList<pqOutputPort*> &pqPorts,
282  int selectionModifier, bool select_blocks);
283 
284  void InternalConstructor(vtkSMViewProxy *renModule);
285 };
286 
287 #endif
288 
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
pqOutputPort is a server manager model item for an output port of any pqPipelineSource item...
Definition: pqOutputPort.h:55
virtual void resetCamera()=0
Resets the camera to include all visible data.
void setUseMultipleRepresentationSelection(bool b)
Set whether selection will be done on multiple representations.
Definition: pqRenderView.h:216
bool getResetCenterWithCamera() const
Get whether resetCamera() resets the center of rotation as well.
Definition: pqRenderView.h:103
virtual void redo()
Called to redo interaction.
Definition: pqView.h:116
bool UseMultipleRepresentationSelection
Definition: pqRenderView.h:255
bool getUseMultipleRepresentationSelection() const
Get whether selection will be done on multiple representations.
Definition: pqRenderView.h:107
void resetCenterOfRotationIfNeeded()
Resets center of rotation if this->ResetCenterWithCamera is true.
Definition: pqRenderView.h:231
void setCenterOfRotation(double xyz[3])
Definition: pqRenderView.h:202
virtual bool canUndo() const
Returns true if undo can be done.
Definition: pqView.h:125
void setResetCenterWithCamera(bool b)
Get/Set whether resetCamera() resets the center of rotation as well.
Definition: pqRenderView.h:212
virtual bool canRedo() const
Returns true if redo can be done.
Definition: pqView.h:128
pqRenderViewBase is an abstract base class for all render-view based views.
virtual void undo()
Called to undo interaction.
Definition: pqView.h:112
bool ResetCenterWithCamera
Definition: pqRenderView.h:252
virtual bool supportsUndo() const
Returns if this view module can support undo/redo.
Definition: pqRenderView.h:119
virtual void initialize()
Use this method to initialize the pqObject state using the underlying vtkSMProxy. ...
virtual QWidget * createWidget()
Creates a new instance of the QWidget subclass to be used to show this view.
static QString renderViewType()
Definition: pqRenderView.h:53
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:62