VTK  9.0.20210123
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 "vtkObject.h"
36 #include "vtkRenderingCoreModule.h" // For export macro
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()
226  {
227  this->DisplayToView();
228  this->ViewToWorld();
229  }
230 
235  {
236  this->WorldToView();
237  this->ViewToDisplay();
238  }
239 
241 
248  virtual void LocalDisplayToDisplay(double& x, double& y);
249  virtual void DisplayToNormalizedDisplay(double& u, double& v);
250  virtual void NormalizedDisplayToViewport(double& x, double& y);
251  virtual void ViewportToNormalizedViewport(double& u, double& v);
252  virtual void NormalizedViewportToView(double& x, double& y, double& z);
253  virtual void ViewToPose(double&, double&, double&) {}
254  virtual void PoseToWorld(double&, double&, double&) {}
255  virtual void DisplayToLocalDisplay(double& x, double& y);
256  virtual void NormalizedDisplayToDisplay(double& u, double& v);
257  virtual void ViewportToNormalizedDisplay(double& x, double& y);
258  virtual void NormalizedViewportToViewport(double& u, double& v);
259  virtual void ViewToNormalizedViewport(double& x, double& y, double& z);
260  virtual void PoseToView(double&, double&, double&) {}
261  virtual void WorldToPose(double&, double&, double&) {}
262  virtual void ViewToWorld(double&, double&, double&) {}
263  virtual void WorldToView(double&, double&, double&) {}
265 
267 
272  virtual int* GetSize() VTK_SIZEHINT(2);
273  virtual int* GetOrigin() VTK_SIZEHINT(2);
274  void GetTiledSize(int* width, int* height);
275  virtual void GetTiledSizeAndOrigin(int* width, int* height, int* lowerLeftX, int* lowerLeftY);
277 
278  // The following methods describe the public pick interface for picking
279  // Props in a viewport.
280 
287  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
288 
296  virtual vtkAssemblyPath* PickProp(
297  double selectionX1, double selectionY1, double selectionX2, double selectionY2) = 0;
298 
304  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*);
305 
311  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
312  double selectionY2, vtkPropCollection*);
313 
315 
319  double GetPickX() const { return (this->PickX1 + this->PickX2) * 0.5; }
320  double GetPickY() const { return (this->PickY1 + this->PickY2) * 0.5; }
321  double GetPickWidth() const { return this->PickX2 - this->PickX1 + 1; }
322  double GetPickHeight() const { return this->PickY2 - this->PickY1 + 1; }
323  double GetPickX1() const { return this->PickX1; }
324  double GetPickY1() const { return this->PickY1; }
325  double GetPickX2() const { return this->PickX2; }
326  double GetPickY2() const { return this->PickY2; }
327  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
329 
333  virtual double GetPickedZ() { return this->PickedZ; }
334 
336 
340  vtkSetVector3Macro(EnvironmentalBG, double);
341  vtkGetVector3Macro(EnvironmentalBG, double);
343 
345 
349  vtkSetVector3Macro(EnvironmentalBG2, double);
350  vtkGetVector3Macro(EnvironmentalBG2, double);
352 
353 
359  vtkSetMacro(GradientEnvironmentalBG, bool);
360  vtkGetMacro(GradientEnvironmentalBG, bool);
361  vtkBooleanMacro(GradientEnvironmentalBG, bool);
363 
364 protected:
365  // Create a vtkViewport with a black background, a white ambient light,
366  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
367  // culling turned off.
368  vtkViewport();
369  ~vtkViewport() override;
370 
371  // Ivars for picking
372  // Store a picked Prop (contained in an assembly path)
376  double PickX1;
377  double PickY1;
378  double PickX2;
379  double PickY2;
380  double PickedZ;
381  // End Ivars for picking
382 
386  double Background[3];
387  double Background2[3];
389  double Viewport[4];
390  double Aspect[2];
391  double PixelAspect[2];
392  double Center[2];
394 
395  double EnvironmentalBG[3];
396  double EnvironmentalBG2[3];
398 
399  int Size[2];
400  int Origin[2];
401  double DisplayPoint[3];
402  double ViewPoint[3];
403  double WorldPoint[4];
404 
405 private:
406  vtkViewport(const vtkViewport&) = delete;
407  void operator=(const vtkViewport&) = delete;
408 };
409 
410 #endif
vtkViewport::GetPickedZ
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
Definition: vtkViewport.h:333
vtkViewport::PickResultProps
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:375
vtkViewport::GetPickY2
double GetPickY2() const
Definition: vtkViewport.h:326
vtkViewport::PickedZ
double PickedZ
Definition: vtkViewport.h:380
vtkViewport::Actors2D
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:384
vtkViewport::WorldToPose
virtual void WorldToPose(double &, double &, double &)
Definition: vtkViewport.h:261
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkViewport::Props
vtkPropCollection * Props
Definition: vtkViewport.h:383
vtkViewport::PickY2
double PickY2
Definition: vtkViewport.h:379
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:41
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
vtkViewport::WorldToView
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:263
vtkViewport::GradientEnvironmentalBG
bool GradientEnvironmentalBG
Definition: vtkViewport.h:397
vtkViewport::GetViewProps
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition: vtkViewport.h:60
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkX3D::Background
Definition: vtkX3D.h:77
vtkX3D::height
Definition: vtkX3D.h:260
vtkViewport::ViewToPose
virtual void ViewToPose(double &, double &, double &)
Definition: vtkViewport.h:253
vtkViewport::PickedProp
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:373
vtkViewport::WorldToDisplay
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:234
vtkViewport::PickX2
double PickX2
Definition: vtkViewport.h:378
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:254
vtkViewport::ViewToWorld
virtual void ViewToWorld(double &, double &, double &)
Definition: vtkViewport.h:262
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkObject.h
vtkViewport::PickFromProps
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:374
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkViewport::GetPickWidth
double GetPickWidth() const
Definition: vtkViewport.h:321
vtkViewport::GetPickX1
double GetPickX1() const
Definition: vtkViewport.h:323
vtkActor2DCollection
a list of 2D actors
Definition: vtkActor2DCollection.h:38
vtkViewport::GetPickX2
double GetPickX2() const
Definition: vtkViewport.h:325
vtkViewport::GetPickHeight
double GetPickHeight() const
Definition: vtkViewport.h:322
vtkViewport::VTKWindow
vtkWindow * VTKWindow
Definition: vtkViewport.h:385
vtkViewport::GetPickY1
double GetPickY1() const
Definition: vtkViewport.h:324
vtkViewport::PickX1
double PickX1
Definition: vtkViewport.h:376
vtkViewport::GradientBackground
bool GradientBackground
Definition: vtkViewport.h:393
vtkViewport::PoseToView
virtual void PoseToView(double &, double &, double &)
Definition: vtkViewport.h:260
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkViewport::BackgroundAlpha
double BackgroundAlpha
Definition: vtkViewport.h:388
vtkViewport::PickY1
double PickY1
Definition: vtkViewport.h:377
vtkViewport::GetPickY
double GetPickY() const
Definition: vtkViewport.h:320