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=========================================================================*/
41#ifndef vtkViewport_h
42#define vtkViewport_h
43
44#include "vtkObject.h"
45#include "vtkRenderingCoreModule.h" // For export macro
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
71 vtkPropCollection* GetViewProps() { return this->Props; }
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
236 void DisplayToWorld()
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.
301
308 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
309
317 virtual vtkAssemblyPath* PickProp(
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
336
340 double GetPickX() const { return (this->PickX1 + this->PickX2) * 0.5; }
341 double GetPickY() const { return (this->PickY1 + this->PickY2) * 0.5; }
342 double GetPickWidth() const { return this->PickX2 - this->PickX1 + 1; }
343 double GetPickHeight() const { return this->PickY2 - this->PickY1 + 1; }
344 double GetPickX1() const { return this->PickX1; }
345 double GetPickY1() const { return this->PickY1; }
346 double GetPickX2() const { return this->PickX2; }
347 double GetPickY2() const { return this->PickY2; }
348 vtkGetObjectMacro(PickResultProps, vtkPropCollection);
350
354 virtual double GetPickedZ() { return this->PickedZ; }
355
357
361 vtkSetVector3Macro(EnvironmentalBG, double);
362 vtkGetVector3Macro(EnvironmentalBG, double);
364
366
370 vtkSetVector3Macro(EnvironmentalBG2, double);
371 vtkGetVector3Macro(EnvironmentalBG2, double);
374
380 vtkSetMacro(GradientEnvironmentalBG, bool);
381 vtkGetMacro(GradientEnvironmentalBG, bool);
382 vtkBooleanMacro(GradientEnvironmentalBG, bool);
384
385protected:
386 // Create a vtkViewport with a black background, a white ambient light,
387 // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
388 // culling turned off.
390 ~vtkViewport() override;
391
392 // Ivars for picking
393 // Store a picked Prop (contained in an assembly path)
397 double PickX1;
398 double PickY1;
399 double PickX2;
400 double PickY2;
401 double PickedZ;
402 // End Ivars for picking
403
407 double Background[3];
408 double Background2[3];
410 double Viewport[4];
411 double Aspect[2];
412 double PixelAspect[2];
413 double Center[2];
415
416 double EnvironmentalBG[3];
417 double EnvironmentalBG2[3];
419
420 int Size[2];
421 int Origin[2];
422 double DisplayPoint[3];
423 double ViewPoint[3];
424 double WorldPoint[4];
425
426private:
427 std::array<int, 2> LastComputeAspectSize;
428 std::array<double, 4> LastComputeAspectVPort;
429 std::array<double, 2> LastComputeAspectPixelAspect;
430
431 vtkViewport(const vtkViewport&) = delete;
432 void operator=(const vtkViewport&) = delete;
433};
434
435#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:43
abstract base class for most VTK objects
Definition: vtkObject.h:63
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
abstract specification for Viewports
Definition: vtkViewport.h:56
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:347
virtual void ViewToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:282
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:344
vtkPropCollection * Props
Definition: vtkViewport.h:404
void WorldToDisplay(double &x, double &y, double &z)
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:254
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:281
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:245
~vtkViewport() override
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:394
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
Definition: vtkViewport.h:399
bool GradientBackground
Definition: vtkViewport.h:414
virtual void ViewToPose(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:273
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:346
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:405
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:343
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:274
vtkWindow * VTKWindow
Definition: vtkViewport.h:406
virtual void ComputeAspect()
Set the aspect ratio of the rendered image.
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:396
virtual int * GetSize()
Get the size and origin of the viewport in display coordinates.
double BackgroundAlpha
Definition: vtkViewport.h:409
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:397
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:395
virtual void NormalizedDisplayToDisplay(double &u, double &v)
These methods map from one coordinate system to another.
bool GradientEnvironmentalBG
Definition: vtkViewport.h:418
virtual double GetPickedZ()
Return the Z value for the last picked Prop.
Definition: vtkViewport.h:354
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:342
double PickY1
Definition: vtkViewport.h:398
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:341
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:280
double PickY2
Definition: vtkViewport.h:400
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:345
virtual void WorldToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:283
double PickedZ
Definition: vtkViewport.h:401
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ Background
Definition: vtkX3D.h:77
@ height
Definition: vtkX3D.h:260
#define VTK_SIZEHINT(...)