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=========================================================================*/
37
38#ifndef vtkViewport_h
39#define vtkViewport_h
40
41#include "vtkObject.h"
42#include "vtkRenderingCoreModule.h" // For export macro
43
44#include "vtkSelection.h" // Needed for selection
45#include "vtkSmartPointer.h" // Needed for assigning default nullptr value
46
47#include <array> // To store matrices
48
50class vtkAssemblyPath;
51class vtkProp;
53class vtkWindow;
54
55class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
56{
57public:
58 vtkTypeMacro(vtkViewport, vtkObject);
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
67
72
77
83
88
90
99
101
105 vtkSetVector3Macro(Background, double);
106 vtkGetVector3Macro(Background, double);
108
110
114 vtkSetVector3Macro(Background2, double);
115 vtkGetVector3Macro(Background2, double);
117 //
118
120
124 vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
125 vtkGetMacro(BackgroundAlpha, double);
127
129
134 vtkSetMacro(GradientBackground, bool);
135 vtkGetMacro(GradientBackground, bool);
136 vtkBooleanMacro(GradientBackground, bool);
138
140
144 vtkSetVector2Macro(Aspect, double);
145 vtkGetVectorMacro(Aspect, double, 2);
146 virtual void ComputeAspect();
148
150
155 vtkSetVector2Macro(PixelAspect, double);
156 vtkGetVectorMacro(PixelAspect, double, 2);
158
160
165 vtkSetVector4Macro(Viewport, double);
166 vtkGetVectorMacro(Viewport, double, 4);
168
170
175 vtkSetVector3Macro(DisplayPoint, double);
176 vtkGetVectorMacro(DisplayPoint, double, 3);
178
180
185 vtkSetVector3Macro(ViewPoint, double);
186 vtkGetVectorMacro(ViewPoint, double, 3);
188
190
194 vtkSetVector4Macro(WorldPoint, double);
195 vtkGetVectorMacro(WorldPoint, double, 4);
197
201 virtual double* GetCenter() VTK_SIZEHINT(2);
202
206 virtual int IsInViewport(int x, int y);
207
211 virtual vtkWindow* GetVTKWindow() = 0;
212
216 virtual void DisplayToView(); // these get modified in subclasses
217
221 virtual void ViewToDisplay(); // to handle stereo rendering
222
226 virtual void WorldToView();
227
231 virtual void ViewToWorld();
232
237 {
238 this->DisplayToView();
239 this->ViewToWorld();
240 }
241
246 {
247 this->WorldToView();
248 this->ViewToDisplay();
249 }
250
254 inline void WorldToDisplay(double& x, double& y, double& z)
255 {
256 this->WorldToView(x, y, z);
257 this->ViewToDisplay(x, y, z);
258 }
259
261
268 virtual void LocalDisplayToDisplay(double& x, double& y);
269 virtual void DisplayToNormalizedDisplay(double& u, double& v);
270 virtual void NormalizedDisplayToViewport(double& x, double& y);
271 virtual void ViewportToNormalizedViewport(double& u, double& v);
272 virtual void NormalizedViewportToView(double& x, double& y, double& z);
273 virtual void ViewToPose(double&, double&, double&) {}
274 virtual void PoseToWorld(double&, double&, double&) {}
275 virtual void DisplayToLocalDisplay(double& x, double& y);
276 virtual void NormalizedDisplayToDisplay(double& u, double& v);
277 virtual void ViewportToNormalizedDisplay(double& x, double& y);
278 virtual void NormalizedViewportToViewport(double& u, double& v);
279 virtual void ViewToNormalizedViewport(double& x, double& y, double& z);
280 virtual void PoseToView(double&, double&, double&) {}
281 virtual void WorldToPose(double&, double&, double&) {}
282 virtual void ViewToWorld(double&, double&, double&) {}
283 virtual void WorldToView(double&, double&, double&) {}
284 virtual void ViewToDisplay(double& x, double& y, double& z);
286
288
293 virtual int* GetSize() VTK_SIZEHINT(2);
294 virtual int* GetOrigin() VTK_SIZEHINT(2);
295 void GetTiledSize(int* width, int* height);
296 virtual void GetTiledSizeAndOrigin(int* width, int* height, int* lowerLeftX, int* lowerLeftY);
298
299 // The following methods describe the public pick interface for picking
300 // Props in a viewport without/with setting fieldAssociation and selection.
301
308 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
309
318 double selectionX1, double selectionY1, double selectionX2, double selectionY2) = 0;
319
325 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*);
326
332 vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
333 double selectionY2, vtkPropCollection*);
334
343 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY, int fieldAssociation,
344 vtkSmartPointer<vtkSelection> selection) = 0;
345
355 virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1, double selectionX2,
356 double selectionY2, int fieldAssociation, vtkSmartPointer<vtkSelection> selection) = 0;
357
365 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*,
366 int fieldAssociation, vtkSmartPointer<vtkSelection> selection);
367
375 vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
376 double selectionY2, vtkPropCollection*, int fieldAssociation,
377 vtkSmartPointer<vtkSelection> selection);
378
380
384 double GetPickX() const { return (this->PickX1 + this->PickX2) * 0.5; }
385 double GetPickY() const { return (this->PickY1 + this->PickY2) * 0.5; }
386 double GetPickWidth() const { return this->PickX2 - this->PickX1 + 1; }
387 double GetPickHeight() const { return this->PickY2 - this->PickY1 + 1; }
388 double GetPickX1() const { return this->PickX1; }
389 double GetPickY1() const { return this->PickY1; }
390 double GetPickX2() const { return this->PickX2; }
391 double GetPickY2() const { return this->PickY2; }
394
398 virtual double GetPickedZ() { return this->PickedZ; }
399
401
405 vtkSetVector3Macro(EnvironmentalBG, double);
406 vtkGetVector3Macro(EnvironmentalBG, double);
408
410
414 vtkSetVector3Macro(EnvironmentalBG2, double);
415 vtkGetVector3Macro(EnvironmentalBG2, double);
418
424 vtkSetMacro(GradientEnvironmentalBG, bool);
425 vtkGetMacro(GradientEnvironmentalBG, bool);
426 vtkBooleanMacro(GradientEnvironmentalBG, bool);
428
429protected:
430 // Create a vtkViewport with a black background, a white ambient light,
431 // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
432 // culling turned off.
434 ~vtkViewport() override;
435
436 // Ivars for picking
437 // Store a picked Prop (contained in an assembly path)
441 double PickX1;
442 double PickY1;
443 double PickX2;
444 double PickY2;
445 double PickedZ;
446 // End Ivars for picking
447
451 double Background[3];
452 double Background2[3];
454 double Viewport[4];
455 double Aspect[2];
456 double PixelAspect[2];
457 double Center[2];
459
463
464 int Size[2];
465 int Origin[2];
466 double DisplayPoint[3];
467 double ViewPoint[3];
468 double WorldPoint[4];
469
470private:
471 std::array<int, 2> LastComputeAspectSize;
472 std::array<double, 4> LastComputeAspectVPort;
473 std::array<double, 2> LastComputeAspectPixelAspect;
474
475 vtkViewport(const vtkViewport&) = delete;
476 void operator=(const vtkViewport&) = delete;
477};
478
479#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:40
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:57
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:71
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(...)