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 =========================================================================*/
32 #ifndef vtkViewport_h
33 #define vtkViewport_h
34 
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include "vtkObject.h"
37 
39 class vtkAssemblyPath;
40 class vtkProp;
41 class vtkPropCollection;
42 class vtkWindow;
43 
44 class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
45 {
46 public:
47  vtkTypeMacro(vtkViewport,vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
55  void AddViewProp(vtkProp *);
56 
60  vtkPropCollection *GetViewProps() {return this->Props;};
61 
65  int HasViewProp(vtkProp *);
66 
71  void RemoveViewProp(vtkProp *);
72 
76  void RemoveAllViewProps(void);
77 
79 
84  void AddActor2D(vtkProp* p);
85  void RemoveActor2D(vtkProp* p);
86  vtkActor2DCollection *GetActors2D();
88 
90 
94  vtkSetVector3Macro(Background,double);
95  vtkGetVector3Macro(Background,double);
97 
99 
103  vtkSetVector3Macro(Background2,double);
104  vtkGetVector3Macro(Background2,double);
106  //
107 
109 
113  vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
114  vtkGetMacro(BackgroundAlpha, double);
116 
118 
123  vtkSetMacro(GradientBackground,bool);
124  vtkGetMacro(GradientBackground,bool);
125  vtkBooleanMacro(GradientBackground,bool);
127 
129 
133  vtkSetVector2Macro(Aspect,double);
134  vtkGetVectorMacro(Aspect,double,2);
135  virtual void ComputeAspect();
137 
139 
144  vtkSetVector2Macro(PixelAspect,double);
145  vtkGetVectorMacro(PixelAspect,double,2);
147 
149 
154  vtkSetVector4Macro(Viewport,double);
155  vtkGetVectorMacro(Viewport,double,4);
157 
159 
164  vtkSetVector3Macro(DisplayPoint,double);
165  vtkGetVectorMacro(DisplayPoint,double,3);
167 
169 
174  vtkSetVector3Macro(ViewPoint,double);
175  vtkGetVectorMacro(ViewPoint,double,3);
177 
179 
183  vtkSetVector4Macro(WorldPoint,double);
184  vtkGetVectorMacro(WorldPoint,double,4);
186 
190  virtual double *GetCenter() VTK_SIZEHINT(2);
191 
195  virtual int IsInViewport(int x,int y);
196 
200  virtual vtkWindow *GetVTKWindow() = 0;
201 
205  virtual void DisplayToView(); // these get modified in subclasses
206 
210  virtual void ViewToDisplay(); // to handle stereo rendering
211 
215  virtual void WorldToView();
216 
220  virtual void ViewToWorld();
221 
225  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
226 
230  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
231 
233 
240  virtual void LocalDisplayToDisplay(double &x, double &y);
241  virtual void DisplayToNormalizedDisplay(double &u, double &v);
242  virtual void NormalizedDisplayToViewport(double &x, double &y);
243  virtual void ViewportToNormalizedViewport(double &u, double &v);
244  virtual void NormalizedViewportToView(double &x, double &y, double &z);
245  virtual void ViewToPose(double &, double &, double &) {}
246  virtual void PoseToWorld(double &, double &, double &) {}
247  virtual void DisplayToLocalDisplay(double &x, double &y);
248  virtual void NormalizedDisplayToDisplay(double &u, double &v);
249  virtual void ViewportToNormalizedDisplay(double &x, double &y);
250  virtual void NormalizedViewportToViewport(double &u, double &v);
251  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
252  virtual void PoseToView(double &, double &, double &) {}
253  virtual void WorldToPose(double &, double &, double &) {}
254  virtual void ViewToWorld(double &, double &, double &) {}
255  virtual void WorldToView(double &, double &, double &) {}
257 
259 
264  virtual int *GetSize() VTK_SIZEHINT(2);
265  virtual int *GetOrigin() VTK_SIZEHINT(2);
266  void GetTiledSize(int *width, int *height);
267  virtual void GetTiledSizeAndOrigin(int *width, int *height,
268  int *lowerLeftX, int *lowerLeftY);
270 
271  // The following methods describe the public pick interface for picking
272  // Props in a viewport.
273 
280  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
281 
289  virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
290  double selectionX2, double selectionY2) = 0;
291 
297  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
299 
305  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
306  double selectionX2, double selectionY2,
308 
310 
314  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
315  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
316  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
317  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
318  double GetPickX1() const {return this->PickX1;}
319  double GetPickY1() const {return this->PickY1;}
320  double GetPickX2() const {return this->PickX2;}
321  double GetPickY2() const {return this->PickY2;}
322  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
324 
328  virtual double GetPickedZ() { return this->PickedZ; };
329 
330 protected:
331  // Create a vtkViewport with a black background, a white ambient light,
332  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
333  // culling turned off.
334  vtkViewport();
335  ~vtkViewport() override;
336 
337  // Ivars for picking
338  // Store a picked Prop (contained in an assembly path)
342  double PickX1;
343  double PickY1;
344  double PickX2;
345  double PickY2;
346  double PickedZ;
347  // End Ivars for picking
348 
352  double Background[3];
353  double Background2[3];
355  double Viewport[4];
356  double Aspect[2];
357  double PixelAspect[2];
358  double Center[2];
360 
361  int Size[2];
362  int Origin[2];
363  double DisplayPoint[3];
364  double ViewPoint[3];
365  double WorldPoint[4];
366 
367 
368 private:
369  vtkViewport(const vtkViewport&) = delete;
370  void operator=(const vtkViewport&) = delete;
371 };
372 
373 
374 
375 #endif
vtkViewport::GetPickedZ
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
Definition: vtkViewport.h:328
vtkViewport::PickResultProps
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:341
vtkViewport::GetPickY2
double GetPickY2() const
Definition: vtkViewport.h:321
vtkViewport::PickedZ
double PickedZ
Definition: vtkViewport.h:346
vtkViewport::Actors2D
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:350
vtkViewport::WorldToPose
virtual void WorldToPose(double &, double &, double &)
Definition: vtkViewport.h:253
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkViewport::Props
vtkPropCollection * Props
Definition: vtkViewport.h:349
vtkViewport::PickY2
double PickY2
Definition: vtkViewport.h:345
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:41
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkViewport::WorldToView
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:255
vtkViewport::GetViewProps
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition: vtkViewport.h:60
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkX3D::Background
Definition: vtkX3D.h:71
vtkX3D::height
Definition: vtkX3D.h:254
vtkViewport::ViewToPose
virtual void ViewToPose(double &, double &, double &)
Definition: vtkViewport.h:245
vtkViewport::PickedProp
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:339
vtkViewport::WorldToDisplay
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:230
vtkViewport::PickX2
double PickX2
Definition: vtkViewport.h:344
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkViewport::PoseToWorld
virtual void PoseToWorld(double &, double &, double &)
Definition: vtkViewport.h:246
vtkViewport::ViewToWorld
virtual void ViewToWorld(double &, double &, double &)
Definition: vtkViewport.h:254
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkObject.h
vtkViewport::PickFromProps
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:340
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkViewport::GetPickWidth
double GetPickWidth() const
Definition: vtkViewport.h:316
vtkViewport::GetPickX1
double GetPickX1() const
Definition: vtkViewport.h:318
vtkActor2DCollection
a list of 2D actors
Definition: vtkActor2DCollection.h:38
vtkViewport::GetPickX2
double GetPickX2() const
Definition: vtkViewport.h:320
vtkViewport::GetPickHeight
double GetPickHeight() const
Definition: vtkViewport.h:317
vtkViewport::VTKWindow
vtkWindow * VTKWindow
Definition: vtkViewport.h:351
vtkViewport::GetPickY1
double GetPickY1() const
Definition: vtkViewport.h:319
vtkViewport::PickX1
double PickX1
Definition: vtkViewport.h:342
vtkViewport::GradientBackground
bool GradientBackground
Definition: vtkViewport.h:359
vtkViewport::PoseToView
virtual void PoseToView(double &, double &, double &)
Definition: vtkViewport.h:252
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkViewport::BackgroundAlpha
double BackgroundAlpha
Definition: vtkViewport.h:354
vtkViewport::PickY1
double PickY1
Definition: vtkViewport.h:343
vtkViewport::GetPickY
double GetPickY() const
Definition: vtkViewport.h:315