VTK
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 =========================================================================*/
35 #ifndef vtkViewport_h
36 #define vtkViewport_h
37 
38 #include "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkObject.h"
40 
42 class vtkAssemblyPath;
43 class vtkProp;
44 class vtkPropCollection;
45 class vtkWindow;
46 
47 class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
48 {
49 public:
50  vtkTypeMacro(vtkViewport,vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
58  void AddViewProp(vtkProp *);
59 
63  vtkPropCollection *GetViewProps() {return this->Props;};
64 
68  int HasViewProp(vtkProp *);
69 
74  void RemoveViewProp(vtkProp *);
75 
79  void RemoveAllViewProps(void);
80 
82 
87  void AddActor2D(vtkProp* p);
88  void RemoveActor2D(vtkProp* p);
89  vtkActor2DCollection *GetActors2D();
91 
93 
97  vtkSetVector3Macro(Background,double);
98  vtkGetVector3Macro(Background,double);
100 
102 
106  vtkSetVector3Macro(Background2,double);
107  vtkGetVector3Macro(Background2,double);
109  //
110 
112 
116  vtkSetClampMacro(BackgroundAlpha, double, 0.0, 1.0);
117  vtkGetMacro(BackgroundAlpha, double);
119 
121 
126  vtkSetMacro(GradientBackground,bool);
127  vtkGetMacro(GradientBackground,bool);
128  vtkBooleanMacro(GradientBackground,bool);
130 
132 
136  vtkSetVector2Macro(Aspect,double);
137  vtkGetVectorMacro(Aspect,double,2);
138  virtual void ComputeAspect();
140 
142 
147  vtkSetVector2Macro(PixelAspect,double);
148  vtkGetVectorMacro(PixelAspect,double,2);
150 
152 
157  vtkSetVector4Macro(Viewport,double);
158  vtkGetVectorMacro(Viewport,double,4);
160 
162 
167  vtkSetVector3Macro(DisplayPoint,double);
168  vtkGetVectorMacro(DisplayPoint,double,3);
170 
172 
177  vtkSetVector3Macro(ViewPoint,double);
178  vtkGetVectorMacro(ViewPoint,double,3);
180 
182 
186  vtkSetVector4Macro(WorldPoint,double);
187  vtkGetVectorMacro(WorldPoint,double,4);
189 
193  virtual double *GetCenter();
194 
198  virtual int IsInViewport(int x,int y);
199 
203  virtual vtkWindow *GetVTKWindow() = 0;
204 
208  virtual void DisplayToView(); // these get modified in subclasses
209 
213  virtual void ViewToDisplay(); // to handle stereo rendering
214 
218  virtual void WorldToView();
219 
223  virtual void ViewToWorld();
224 
228  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
229 
233  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
234 
236 
243  virtual void LocalDisplayToDisplay(double &x, double &y);
244  virtual void DisplayToNormalizedDisplay(double &u, double &v);
245  virtual void NormalizedDisplayToViewport(double &x, double &y);
246  virtual void ViewportToNormalizedViewport(double &u, double &v);
247  virtual void NormalizedViewportToView(double &x, double &y, double &z);
248  virtual void ViewToWorld(double &, double &, double &) {}
249  virtual void DisplayToLocalDisplay(double &x, double &y);
250  virtual void NormalizedDisplayToDisplay(double &u, double &v);
251  virtual void ViewportToNormalizedDisplay(double &x, double &y);
252  virtual void NormalizedViewportToViewport(double &u, double &v);
253  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
254  virtual void WorldToView(double &, double &, double &) {}
256 
258 
263  virtual int *GetSize();
264  virtual int *GetOrigin();
265  void GetTiledSize(int *width, int *height);
266  virtual void GetTiledSizeAndOrigin(int *width, int *height,
267  int *lowerLeftX, int *lowerLeftY);
269 
270  // The following methods describe the public pick interface for picking
271  // Props in a viewport.
272 
279  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
280 
288  virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
289  double selectionX2, double selectionY2) = 0;
290 
296  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
298 
304  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
305  double selectionX2, double selectionY2,
307 
309 
313  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
314  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
315  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
316  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
317  double GetPickX1() const {return this->PickX1;}
318  double GetPickY1() const {return this->PickY1;}
319  double GetPickX2() const {return this->PickX2;}
320  double GetPickY2() const {return this->PickY2;}
321  vtkGetMacro(IsPicking, int);
322  vtkGetMacro(CurrentPickId, unsigned int);
323  void SetCurrentPickId(unsigned int a) {this->CurrentPickId = a;};
324  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
326 
330  virtual double GetPickedZ() = 0;
331 
332 protected:
333  // Create a vtkViewport with a black background, a white ambient light,
334  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
335  // culling turned off.
336  vtkViewport();
337  ~vtkViewport() override;
338 
339  // Picking functions to be implemented by sub-classes
340  // Perform the main picking loop
341  virtual void DevicePickRender() = 0;
342  // Enter a pick mode
343  virtual void StartPick(unsigned int pickFromSize) = 0;
344  // Set the pick id to the next id before drawing an object
345  virtual void UpdatePickId() = 0;
346  // Exit Pick mode
347  virtual void DonePick() = 0;
348  // Return the id of the picked object, only valid after a call to DonePick
349  virtual unsigned int GetPickedId() = 0;
350  // Return the number of objects picked, only valid after a call to DonePick
351  virtual unsigned int GetNumPickedIds() = 0;
352  // Put no more than atMost picked object ids into the callerBuffer and
353  // return the number of picked objects returned.
354  virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
355 
356  // Ivars for picking
357  // Store a picked Prop (contained in an assembly path)
361  // Boolean flag to determine if picking is enabled for this render
363  unsigned int CurrentPickId;
364  double PickX1;
365  double PickY1;
366  double PickX2;
367  double PickY2;
368  // End Ivars for picking
369 
373  double Background[3];
374  double Background2[3];
376  double Viewport[4];
377  double Aspect[2];
378  double PixelAspect[2];
379  double Center[2];
381 
382  int Size[2];
383  int Origin[2];
384  double DisplayPoint[3];
385  double ViewPoint[3];
386  double WorldPoint[4];
387 
388 
389 private:
390  vtkViewport(const vtkViewport&) = delete;
391  void operator=(const vtkViewport&) = delete;
392 };
393 
394 
395 
396 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
a list of 2D actors
unsigned int CurrentPickId
Definition: vtkViewport.h:363
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:360
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetCurrentPickId(unsigned int a)
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:323
abstract specification for Viewports
Definition: vtkViewport.h:47
virtual void WorldToView(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:254
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition: vtkViewport.h:63
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:358
vtkPropCollection * Props
Definition: vtkViewport.h:370
double PickY2
Definition: vtkViewport.h:367
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:233
double GetPickX() const
Methods used to return the pick (x,y) in local display coordinates (i.e., it's that same as selection...
Definition: vtkViewport.h:313
virtual void ViewToWorld(double &, double &, double &)
These methods map from one coordinate system to another.
Definition: vtkViewport.h:248
a list of nodes that form an assembly path
void DisplayToWorld()
Convert display (or screen) coordinates to world coordinates.
Definition: vtkViewport.h:228
a simple class to control print indentation
Definition: vtkIndent.h:39
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:315
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:317
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:359
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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:318
double PickX2
Definition: vtkViewport.h:366
double PickX1
Definition: vtkViewport.h:364
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:316
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:314
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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:319
vtkWindow * VTKWindow
Definition: vtkViewport.h:372
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:320
bool GradientBackground
Definition: vtkViewport.h:380
double PickY1
Definition: vtkViewport.h:365
double BackgroundAlpha
Definition: vtkViewport.h:375
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:371