VTK  9.1.0
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
38#include <array> // To store matrices
39
41class vtkAssemblyPath;
42class vtkProp;
44class vtkWindow;
45
46class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
47{
48public:
49 vtkTypeMacro(vtkViewport, vtkObject);
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
58
62 vtkPropCollection* GetViewProps() { return this->Props; }
63
68
74
79
81
90
92
96 vtkSetVector3Macro(Background, double);
97 vtkGetVector3Macro(Background, double);
99
101
105 vtkSetVector3Macro(Background2, double);
106 vtkGetVector3Macro(Background2, double);
108 //
109
111
115 vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
116 vtkGetMacro(BackgroundAlpha, double);
118
120
125 vtkSetMacro(GradientBackground, bool);
126 vtkGetMacro(GradientBackground, bool);
127 vtkBooleanMacro(GradientBackground, bool);
129
131
135 vtkSetVector2Macro(Aspect, double);
136 vtkGetVectorMacro(Aspect, double, 2);
137 virtual void ComputeAspect();
139
141
146 vtkSetVector2Macro(PixelAspect, double);
147 vtkGetVectorMacro(PixelAspect, double, 2);
149
151
156 vtkSetVector4Macro(Viewport, double);
157 vtkGetVectorMacro(Viewport, double, 4);
159
161
166 vtkSetVector3Macro(DisplayPoint, double);
167 vtkGetVectorMacro(DisplayPoint, double, 3);
169
171
176 vtkSetVector3Macro(ViewPoint, double);
177 vtkGetVectorMacro(ViewPoint, double, 3);
179
181
185 vtkSetVector4Macro(WorldPoint, double);
186 vtkGetVectorMacro(WorldPoint, double, 4);
188
192 virtual double* GetCenter() VTK_SIZEHINT(2);
193
197 virtual int IsInViewport(int x, int y);
198
202 virtual vtkWindow* GetVTKWindow() = 0;
203
207 virtual void DisplayToView(); // these get modified in subclasses
208
212 virtual void ViewToDisplay(); // to handle stereo rendering
213
217 virtual void WorldToView();
218
222 virtual void ViewToWorld();
223
227 void DisplayToWorld()
228 {
229 this->DisplayToView();
230 this->ViewToWorld();
231 }
232
237 {
238 this->WorldToView();
239 this->ViewToDisplay();
240 }
241
245 inline void WorldToDisplay(double& x, double& y, double& z)
246 {
247 this->WorldToView(x, y, z);
248 this->ViewToDisplay(x, y, z);
249 }
250
252
259 virtual void LocalDisplayToDisplay(double& x, double& y);
260 virtual void DisplayToNormalizedDisplay(double& u, double& v);
261 virtual void NormalizedDisplayToViewport(double& x, double& y);
262 virtual void ViewportToNormalizedViewport(double& u, double& v);
263 virtual void NormalizedViewportToView(double& x, double& y, double& z);
264 virtual void ViewToPose(double&, double&, double&) {}
265 virtual void PoseToWorld(double&, double&, double&) {}
266 virtual void DisplayToLocalDisplay(double& x, double& y);
267 virtual void NormalizedDisplayToDisplay(double& u, double& v);
268 virtual void ViewportToNormalizedDisplay(double& x, double& y);
269 virtual void NormalizedViewportToViewport(double& u, double& v);
270 virtual void ViewToNormalizedViewport(double& x, double& y, double& z);
271 virtual void PoseToView(double&, double&, double&) {}
272 virtual void WorldToPose(double&, double&, double&) {}
273 virtual void ViewToWorld(double&, double&, double&) {}
274 virtual void WorldToView(double&, double&, double&) {}
275 virtual void ViewToDisplay(double& x, double& y, double& z);
277
279
284 virtual int* GetSize() VTK_SIZEHINT(2);
285 virtual int* GetOrigin() VTK_SIZEHINT(2);
286 void GetTiledSize(int* width, int* height);
287 virtual void GetTiledSizeAndOrigin(int* width, int* height, int* lowerLeftX, int* lowerLeftY);
289
290 // The following methods describe the public pick interface for picking
291 // Props in a viewport.
292
299 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
300
308 virtual vtkAssemblyPath* PickProp(
309 double selectionX1, double selectionY1, double selectionX2, double selectionY2) = 0;
310
316 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, vtkPropCollection*);
317
323 vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1, double selectionX2,
324 double selectionY2, vtkPropCollection*);
325
327
331 double GetPickX() const { return (this->PickX1 + this->PickX2) * 0.5; }
332 double GetPickY() const { return (this->PickY1 + this->PickY2) * 0.5; }
333 double GetPickWidth() const { return this->PickX2 - this->PickX1 + 1; }
334 double GetPickHeight() const { return this->PickY2 - this->PickY1 + 1; }
335 double GetPickX1() const { return this->PickX1; }
336 double GetPickY1() const { return this->PickY1; }
337 double GetPickX2() const { return this->PickX2; }
338 double GetPickY2() const { return this->PickY2; }
339 vtkGetObjectMacro(PickResultProps, vtkPropCollection);
341
345 virtual double GetPickedZ() { return this->PickedZ; }
346
348
352 vtkSetVector3Macro(EnvironmentalBG, double);
353 vtkGetVector3Macro(EnvironmentalBG, double);
355
357
361 vtkSetVector3Macro(EnvironmentalBG2, double);
362 vtkGetVector3Macro(EnvironmentalBG2, double);
365
371 vtkSetMacro(GradientEnvironmentalBG, bool);
372 vtkGetMacro(GradientEnvironmentalBG, bool);
373 vtkBooleanMacro(GradientEnvironmentalBG, bool);
375
376protected:
377 // Create a vtkViewport with a black background, a white ambient light,
378 // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
379 // culling turned off.
381 ~vtkViewport() override;
382
383 // Ivars for picking
384 // Store a picked Prop (contained in an assembly path)
388 double PickX1;
389 double PickY1;
390 double PickX2;
391 double PickY2;
392 double PickedZ;
393 // End Ivars for picking
394
398 double Background[3];
399 double Background2[3];
401 double Viewport[4];
402 double Aspect[2];
403 double PixelAspect[2];
404 double Center[2];
406
407 double EnvironmentalBG[3];
408 double EnvironmentalBG2[3];
410
411 int Size[2];
412 int Origin[2];
413 double DisplayPoint[3];
414 double ViewPoint[3];
415 double WorldPoint[4];
416
417private:
418 std::array<int, 2> LastComputeAspectSize;
419 std::array<double, 4> LastComputeAspectVPort;
420 std::array<double, 2> LastComputeAspectPixelAspect;
421
422 vtkViewport(const vtkViewport&) = delete;
423 void operator=(const vtkViewport&) = delete;
424};
425
426#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:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:67
abstract specification for Viewports
Definition: vtkViewport.h:47
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:338
virtual void ViewToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:273
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:335
vtkPropCollection * Props
Definition: vtkViewport.h:395
void WorldToDisplay(double &x, double &y, double &z)
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:245
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.
Definition: vtkViewport.h:272
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:236
~vtkViewport() override
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:385
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:62
double PickX2
Definition: vtkViewport.h:390
bool GradientBackground
Definition: vtkViewport.h:405
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:264
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:337
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:396
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:334
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.
Definition: vtkViewport.h:265
vtkWindow * VTKWindow
Definition: vtkViewport.h:397
virtual void ComputeAspect()
Set the aspect ratio of the rendered image.
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:387
virtual int * GetSize()
Get the size and origin of the viewport in display coordinates.
double BackgroundAlpha
Definition: vtkViewport.h:400
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.
void AddActor2D(vtkProp *p)
Add/Remove different types of props to the renderer.
virtual void ViewportToNormalizedDisplay(double &x, double &y)
These methods map from one coordinate system to another.
double PickX1
Definition: vtkViewport.h:388
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
Definition: vtkViewport.h:386
virtual void NormalizedDisplayToDisplay(double &u, double &v)
These methods map from one coordinate system to another.
bool GradientEnvironmentalBG
Definition: vtkViewport.h:409
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
Definition: vtkViewport.h:345
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:333
double PickY1
Definition: vtkViewport.h:389
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:332
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 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 PoseToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:271
double PickY2
Definition: vtkViewport.h:391
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...
Definition: vtkViewport.h:336
virtual void WorldToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:274
double PickedZ
Definition: vtkViewport.h:392
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ Background
Definition: vtkX3D.h:77
@ height
Definition: vtkX3D.h:260
#define VTK_SIZEHINT(...)