VTK
vtkViewport.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkViewport.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
35 #ifndef vtkViewport_h
36 #define vtkViewport_h
37 
38 #include "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkObject.h"
40 
42 class vtkAssemblyPath;
43 class vtkProp;
44 class vtkPropCollection;
45 class vtkWindow;
46 
47 class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
48 {
49 public:
50  vtkTypeMacro(vtkViewport,vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
58  void AddViewProp(vtkProp *);
59 
63  vtkPropCollection *GetViewProps() {return this->Props;};
64 
68  int HasViewProp(vtkProp *);
69 
74  void RemoveViewProp(vtkProp *);
75 
79  void RemoveAllViewProps(void);
80 
82 
87  void AddActor2D(vtkProp* p);
88  void RemoveActor2D(vtkProp* p);
89  vtkActor2DCollection *GetActors2D();
91 
93 
97  vtkSetVector3Macro(Background,double);
98  vtkGetVector3Macro(Background,double);
100 
102 
106  vtkSetVector3Macro(Background2,double);
107  vtkGetVector3Macro(Background2,double);
109  //
110 
112 
116  vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
117  vtkGetMacro(BackgroundAlpha, double);
119 
121 
126  vtkSetMacro(GradientBackground,bool);
127  vtkGetMacro(GradientBackground,bool);
128  vtkBooleanMacro(GradientBackground,bool);
130 
132 
136  vtkSetVector2Macro(Aspect,double);
137  vtkGetVectorMacro(Aspect,double,2);
138  virtual void ComputeAspect();
140 
142 
147  vtkSetVector2Macro(PixelAspect,double);
148  vtkGetVectorMacro(PixelAspect,double,2);
150 
152 
157  vtkSetVector4Macro(Viewport,double);
158  vtkGetVectorMacro(Viewport,double,4);
160 
162 
167  vtkSetVector3Macro(DisplayPoint,double);
168  vtkGetVectorMacro(DisplayPoint,double,3);
170 
172 
177  vtkSetVector3Macro(ViewPoint,double);
178  vtkGetVectorMacro(ViewPoint,double,3);
180 
182 
186  vtkSetVector4Macro(WorldPoint,double);
187  vtkGetVectorMacro(WorldPoint,double,4);
189 
193  virtual double *GetCenter() VTK_SIZEHINT(2);
194 
198  virtual int IsInViewport(int x,int y);
199 
203  virtual vtkWindow *GetVTKWindow() = 0;
204 
208  virtual void DisplayToView(); // these get modified in subclasses
209 
213  virtual void ViewToDisplay(); // to handle stereo rendering
214 
218  virtual void WorldToView();
219 
223  virtual void ViewToWorld();
224 
228  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
229 
233  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
234 
236 
243  virtual void LocalDisplayToDisplay(double &x, double &y);
244  virtual void DisplayToNormalizedDisplay(double &u, double &v);
245  virtual void NormalizedDisplayToViewport(double &x, double &y);
246  virtual void ViewportToNormalizedViewport(double &u, double &v);
247  virtual void NormalizedViewportToView(double &x, double &y, double &z);
248  virtual void ViewToPose(double &, double &, double &) {}
249  virtual void PoseToWorld(double &, double &, double &) {}
250  virtual void DisplayToLocalDisplay(double &x, double &y);
251  virtual void NormalizedDisplayToDisplay(double &u, double &v);
252  virtual void ViewportToNormalizedDisplay(double &x, double &y);
253  virtual void NormalizedViewportToViewport(double &u, double &v);
254  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
255  virtual void PoseToView(double &, double &, double &) {}
256  virtual void WorldToPose(double &, double &, double &) {}
257  virtual void ViewToWorld(double &, double &, double &) {}
258  virtual void WorldToView(double &, double &, double &) {}
260 
262 
267  virtual int *GetSize() VTK_SIZEHINT(2);
268  virtual int *GetOrigin() VTK_SIZEHINT(2);
269  void GetTiledSize(int *width, int *height);
270  virtual void GetTiledSizeAndOrigin(int *width, int *height,
271  int *lowerLeftX, int *lowerLeftY);
273 
274  // The following methods describe the public pick interface for picking
275  // Props in a viewport.
276 
283  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
284 
292  virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
293  double selectionX2, double selectionY2) = 0;
294 
300  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
302 
308  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
309  double selectionX2, double selectionY2,
311 
313 
317  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
318  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
319  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
320  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
321  double GetPickX1() const {return this->PickX1;}
322  double GetPickY1() const {return this->PickY1;}
323  double GetPickX2() const {return this->PickX2;}
324  double GetPickY2() const {return this->PickY2;}
325  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
327 
331  virtual double GetPickedZ() { return this->PickedZ; };
332 
333 protected:
334  // Create a vtkViewport with a black background, a white ambient light,
335  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
336  // culling turned off.
337  vtkViewport();
338  ~vtkViewport() override;
339 
340  // Ivars for picking
341  // Store a picked Prop (contained in an assembly path)
345  double PickX1;
346  double PickY1;
347  double PickX2;
348  double PickY2;
349  double PickedZ;
350  // End Ivars for picking
351 
355  double Background[3];
356  double Background2[3];
358  double Viewport[4];
359  double Aspect[2];
360  double PixelAspect[2];
361  double Center[2];
363 
364  int Size[2];
365  int Origin[2];
366  double DisplayPoint[3];
367  double ViewPoint[3];
368  double WorldPoint[4];
369 
370 
371 private:
372  vtkViewport(const vtkViewport&) = delete;
373  void operator=(const vtkViewport&) = delete;
374 };
375 
376 
377 
378 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
double PickedZ
Definition: vtkViewport.h:349
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
Definition: vtkViewport.h:331
virtual void WorldToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:256
a list of 2D actors
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:344
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
abstract specification for Viewports
Definition: vtkViewport.h:47
double GetPickWidth() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:319
virtual void WorldToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:258
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition: vtkViewport.h:63
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:342
double GetPickY() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:318
vtkPropCollection * Props
Definition: vtkViewport.h:352
double PickY2
Definition: vtkViewport.h:348
double GetPickX() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:317
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
double GetPickX2() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:323
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:233
virtual void ViewToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:257
a list of nodes that form an assembly path
void DisplayToWorld()
Convert display (or screen) coordinates to world coordinates.
Definition: vtkViewport.h:228
double GetPickY1() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:322
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:249
double GetPickHeight() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:320
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:248
#define VTK_SIZEHINT(...)
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:343
double PickX2
Definition: vtkViewport.h:347
double PickX1
Definition: vtkViewport.h:345
double GetPickX1() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:321
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:255
double GetPickY2() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:324
vtkWindow * VTKWindow
Definition: vtkViewport.h:354
bool GradientBackground
Definition: vtkViewport.h:362
double PickY1
Definition: vtkViewport.h:346
double BackgroundAlpha
Definition: vtkViewport.h:357
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:353