VTK  9.2.6
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=========================================================================*/
31
32#ifndef vtkViewport_h
33#define vtkViewport_h
34
35#include "vtkObject.h"
36#include "vtkRenderingCoreModule.h" // For export macro
37
38#include "vtkSelection.h" // Needed for selection
39#include "vtkSmartPointer.h" // Needed for assigning default nullptr value
40
41#include <array> // To store matrices
42
44class vtkAssemblyPath;
45class vtkProp;
47class vtkWindow;
48
49class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
50{
51public:
52 vtkTypeMacro(vtkViewport, vtkObject);
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
61
66
71
77
82
84
93
95
99 vtkSetVector3Macro(Background, double);
100 vtkGetVector3Macro(Background, double);
102
104
108 vtkSetVector3Macro(Background2, double);
109 vtkGetVector3Macro(Background2, double);
111 //
112
114
118 vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
119 vtkGetMacro(BackgroundAlpha, double);
121
123
128 vtkSetMacro(GradientBackground, bool);
129 vtkGetMacro(GradientBackground, bool);
130 vtkBooleanMacro(GradientBackground, bool);
132
134
138 vtkSetVector2Macro(Aspect, double);
139 vtkGetVectorMacro(Aspect, double, 2);
140 virtual void ComputeAspect();
142
144
149 vtkSetVector2Macro(PixelAspect, double);
150 vtkGetVectorMacro(PixelAspect, double, 2);
152
154
159 vtkSetVector4Macro(Viewport, double);
160 vtkGetVectorMacro(Viewport, double, 4);
162
164
169 vtkSetVector3Macro(DisplayPoint, double);
170 vtkGetVectorMacro(DisplayPoint, double, 3);
172
174
179 vtkSetVector3Macro(ViewPoint, double);
180 vtkGetVectorMacro(ViewPoint, double, 3);
182
184
188 vtkSetVector4Macro(WorldPoint, double);
189 vtkGetVectorMacro(WorldPoint, double, 4);
191
195 virtual double* GetCenter() VTK_SIZEHINT(2);
196
200 virtual int IsInViewport(int x, int y);
201
205 virtual vtkWindow* GetVTKWindow() = 0;
206
210 virtual void DisplayToView(); // these get modified in subclasses
211
215 virtual void ViewToDisplay(); // to handle stereo rendering
216
220 virtual void WorldToView();
221
225 virtual void ViewToWorld();
226
231 {
232 this->DisplayToView();
233 this->ViewToWorld();
234 }
235
240 {
241 this->WorldToView();
242 this->ViewToDisplay();
243 }
244
248 inline void WorldToDisplay(double& x, double& y, double& z)
249 {
250 this->WorldToView(x, y, z);
251 this->ViewToDisplay(x, y, z);
252 }
253
255
262 virtual void LocalDisplayToDisplay(double& x, double& y);
263 virtual void DisplayToNormalizedDisplay(double& u, double& v);
264 virtual void NormalizedDisplayToViewport(double& x, double& y);
265 virtual void ViewportToNormalizedViewport(double& u, double& v);
266 virtual void NormalizedViewportToView(double& x, double& y, double& z);
267 virtual void ViewToPose(double&, double&, double&) {}
268 virtual void PoseToWorld(double&, double&, double&) {}
269 virtual void DisplayToLocalDisplay(double& x, double& y);
270 virtual void NormalizedDisplayToDisplay(double& u, double& v);
271 virtual void ViewportToNormalizedDisplay(double& x, double& y);
272 virtual void NormalizedViewportToViewport(double& u, double& v);
273 virtual void ViewToNormalizedViewport(double& x, double& y, double& z);
274 virtual void PoseToView(double&, double&, double&) {}
275 virtual void WorldToPose(double&, double&, double&) {}
276 virtual void ViewToWorld(double&, double&, double&) {}
277 virtual void WorldToView(double&, double&, double&) {}
278 virtual void ViewToDisplay(double& x, double& y, double& z);
280
282
287 virtual int* GetSize() VTK_SIZEHINT(2);
288 virtual int* GetOrigin() VTK_SIZEHINT(2);
289 void GetTiledSize(int* width, int* height);
290 virtual void GetTiledSizeAndOrigin(int* width, int* height, int* lowerLeftX, int* lowerLeftY);
292
293 // The following methods describe the public pick interface for picking
294 // Props in a viewport without/with setting fieldAssociation and selection.
295
302 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
303
312 double selectionX1, double selectionY1, double selectionX2, double selectionY2) = 0;
313
319 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*);
320
326 vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
327 double selectionY2, vtkPropCollection*);
328
337 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY, int fieldAssociation,
338 vtkSmartPointer<vtkSelection> selection) = 0;
339
349 virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1, double selectionX2,
350 double selectionY2, int fieldAssociation, vtkSmartPointer<vtkSelection> selection) = 0;
351
359 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*,
360 int fieldAssociation, vtkSmartPointer<vtkSelection> selection);
361
369 vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
370 double selectionY2, vtkPropCollection*, int fieldAssociation,
371 vtkSmartPointer<vtkSelection> selection);
372
374
378 double GetPickX() const { return (this->PickX1 + this->PickX2) * 0.5; }
379 double GetPickY() const { return (this->PickY1 + this->PickY2) * 0.5; }
380 double GetPickWidth() const { return this->PickX2 - this->PickX1 + 1; }
381 double GetPickHeight() const { return this->PickY2 - this->PickY1 + 1; }
382 double GetPickX1() const { return this->PickX1; }
383 double GetPickY1() const { return this->PickY1; }
384 double GetPickX2() const { return this->PickX2; }
385 double GetPickY2() const { return this->PickY2; }
388
392 virtual double GetPickedZ() { return this->PickedZ; }
393
395
399 vtkSetVector3Macro(EnvironmentalBG, double);
400 vtkGetVector3Macro(EnvironmentalBG, double);
402
404
408 vtkSetVector3Macro(EnvironmentalBG2, double);
409 vtkGetVector3Macro(EnvironmentalBG2, double);
412
418 vtkSetMacro(GradientEnvironmentalBG, bool);
419 vtkGetMacro(GradientEnvironmentalBG, bool);
420 vtkBooleanMacro(GradientEnvironmentalBG, bool);
422
423protected:
424 // Create a vtkViewport with a black background, a white ambient light,
425 // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
426 // culling turned off.
428 ~vtkViewport() override;
429
430 // Ivars for picking
431 // Store a picked Prop (contained in an assembly path)
435 double PickX1;
436 double PickY1;
437 double PickX2;
438 double PickY2;
439 double PickedZ;
440 // End Ivars for picking
441
445 double Background[3];
446 double Background2[3];
448 double Viewport[4];
449 double Aspect[2];
450 double PixelAspect[2];
451 double Center[2];
453
457
458 int Size[2];
459 int Origin[2];
460 double DisplayPoint[3];
461 double ViewPoint[3];
462 double WorldPoint[4];
463
464private:
465 std::array<int, 2> LastComputeAspectSize;
466 std::array<double, 4> LastComputeAspectVPort;
467 std::array<double, 2> LastComputeAspectPixelAspect;
468
469 vtkViewport(const vtkViewport&) = delete;
470 void operator=(const vtkViewport&) = delete;
471};
472
473#endif
a list of 2D actors
a list of nodes that form an assembly path
a simple class to control print indentation
Definition vtkIndent.h:34
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:51
data object that represents a "selection" in VTK.
Hold a reference to a vtkObjectBase instance.
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
double GetPickY2() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
virtual void ViewToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
double GetPickX1() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
vtkPropCollection * Props
double GetPickX() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
double WorldPoint[4]
void WorldToDisplay(double &x, double &y, double &z)
Convert world point coordinates to display (or screen) coordinates.
double Aspect[2]
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void DisplayToLocalDisplay(double &x, double &y)
These methods map from one coordinate system to another.
virtual void WorldToPose(double &, double &, double &)
These methods map from one coordinate system to another.
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
~vtkViewport() override
vtkAssemblyPath * PickedProp
virtual void ViewToNormalizedViewport(double &x, double &y, double &z)
These methods map from one coordinate system to another.
virtual double * GetCenter()
Return the center of this viewport in display coordinates.
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition vtkViewport.h:65
double PickX2
virtual void DisplayToView()
Convert display coordinates to view coordinates.
double EnvironmentalBG2[3]
bool GradientBackground
double DisplayPoint[3]
double Background2[3]
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
double Background[3]
double GetPickX2() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
void DisplayToWorld()
Convert display (or screen) coordinates to world coordinates.
vtkActor2DCollection * Actors2D
double GetPickHeight() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
virtual void NormalizedDisplayToViewport(double &x, double &y)
These methods map from one coordinate system to another.
void RemoveActor2D(vtkProp *p)
Add/Remove different types of props to the renderer.
virtual void PoseToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
double ViewPoint[3]
vtkWindow * VTKWindow
virtual void ComputeAspect()
Set the aspect ratio of the rendered image.
vtkPropCollection * PickResultProps
virtual int * GetSize()
Get the size and origin of the viewport in display coordinates.
double BackgroundAlpha
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void NormalizedViewportToView(double &x, double &y, double &z)
These methods map from one coordinate system to another.
double EnvironmentalBG[3]
virtual int * GetOrigin()
Get the size and origin of the viewport in display coordinates.
void AddActor2D(vtkProp *p)
Add/Remove different types of props to the renderer.
double Viewport[4]
vtkAssemblyPath * PickPropFrom(double selectionX, double selectionY, vtkPropCollection *)
Same as PickProp with two arguments, but selects from the given collection of Props instead of the Re...
virtual void ViewportToNormalizedDisplay(double &x, double &y)
These methods map from one coordinate system to another.
double PickX1
vtkActor2DCollection * GetActors2D()
Add/Remove different types of props to the renderer.
virtual void LocalDisplayToDisplay(double &x, double &y)
These methods map from one coordinate system to another.
void AddViewProp(vtkProp *)
Add a prop to the list of props.
vtkPropCollection * PickFromProps
virtual void NormalizedDisplayToDisplay(double &u, double &v)
These methods map from one coordinate system to another.
bool GradientEnvironmentalBG
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
virtual void GetTiledSizeAndOrigin(int *width, int *height, int *lowerLeftX, int *lowerLeftY)
Get the size and origin of the viewport in display coordinates.
double GetPickWidth() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
int Origin[2]
double PickY1
double GetPickY() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
virtual int IsInViewport(int x, int y)
Is a given display point in this Viewport's viewport.
double PixelAspect[2]
void RemoveAllViewProps(void)
Remove all props from the list of props.
virtual void DisplayToNormalizedDisplay(double &u, double &v)
These methods map from one coordinate system to another.
virtual vtkAssemblyPath * PickProp(double selectionX, double selectionY)=0
Return the Prop that has the highest z value at the given x, y position in the viewport.
virtual void ViewToDisplay(double &x, double &y, double &z)
These methods map from one coordinate system to another.
virtual void NormalizedViewportToViewport(double &u, double &v)
These methods map from one coordinate system to another.
void RemoveViewProp(vtkProp *)
Remove a prop from the list of props.
virtual void ViewToWorld()
Convert view point coordinates to world coordinates.
void GetTiledSize(int *width, int *height)
Get the size and origin of the viewport in display coordinates.
virtual void PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
double PickY2
double Center[2]
virtual void ViewToDisplay()
Convert view coordinates to display coordinates.
virtual void ViewportToNormalizedViewport(double &u, double &v)
These methods map from one coordinate system to another.
int HasViewProp(vtkProp *)
Query if a prop is in the list of props.
double GetPickY1() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
virtual void WorldToView(double &, double &, double &)
These methods map from one coordinate system to another.
double PickedZ
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
#define VTK_SIZEHINT(...)