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);
52 
59 
63  vtkPropCollection *GetViewProps() {return this->Props;};
64 
69 
75 
79  void RemoveAllViewProps(void);
80 
82 
87  void AddActor2D(vtkProp* p);
91 
93 
97  vtkSetVector3Macro(Background,double);
98  vtkGetVector3Macro(Background,double);
100 
102 
106  vtkSetVector3Macro(Background2,double);
107  vtkGetVector3Macro(Background2,double);
109 
111 
116  vtkSetMacro(GradientBackground,bool);
117  vtkGetMacro(GradientBackground,bool);
118  vtkBooleanMacro(GradientBackground,bool);
120 
122 
126  vtkSetVector2Macro(Aspect,double);
127  vtkGetVectorMacro(Aspect,double,2);
128  virtual void ComputeAspect();
130 
132 
137  vtkSetVector2Macro(PixelAspect,double);
138  vtkGetVectorMacro(PixelAspect,double,2);
140 
142 
147  vtkSetVector4Macro(Viewport,double);
148  vtkGetVectorMacro(Viewport,double,4);
150 
152 
157  vtkSetVector3Macro(DisplayPoint,double);
158  vtkGetVectorMacro(DisplayPoint,double,3);
160 
162 
167  vtkSetVector3Macro(ViewPoint,double);
168  vtkGetVectorMacro(ViewPoint,double,3);
170 
172 
176  vtkSetVector4Macro(WorldPoint,double);
177  vtkGetVectorMacro(WorldPoint,double,4);
179 
183  virtual double *GetCenter();
184 
188  virtual int IsInViewport(int x,int y);
189 
193  virtual vtkWindow *GetVTKWindow() = 0;
194 
198  virtual void DisplayToView(); // these get modified in subclasses
199 
203  virtual void ViewToDisplay(); // to handle stereo rendering
204 
208  virtual void WorldToView();
209 
213  virtual void ViewToWorld();
214 
218  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
219 
223  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
224 
226 
233  virtual void LocalDisplayToDisplay(double &x, double &y);
234  virtual void DisplayToNormalizedDisplay(double &u, double &v);
235  virtual void NormalizedDisplayToViewport(double &x, double &y);
236  virtual void ViewportToNormalizedViewport(double &u, double &v);
237  virtual void NormalizedViewportToView(double &x, double &y, double &z);
238  virtual void ViewToWorld(double &, double &, double &) {}
239  virtual void DisplayToLocalDisplay(double &x, double &y);
240  virtual void NormalizedDisplayToDisplay(double &u, double &v);
241  virtual void ViewportToNormalizedDisplay(double &x, double &y);
242  virtual void NormalizedViewportToViewport(double &u, double &v);
243  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
244  virtual void WorldToView(double &, double &, double &) {}
246 
248 
253  virtual int *GetSize();
254  virtual int *GetOrigin();
255  void GetTiledSize(int *width, int *height);
256  virtual void GetTiledSizeAndOrigin(int *width, int *height,
257  int *lowerLeftX, int *lowerLeftY);
259 
260  // The following methods describe the public pick interface for picking
261  // Props in a viewport.
262 
269  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
270 
278  virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
279  double selectionX2, double selectionY2) = 0;
280 
286  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
288 
294  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
295  double selectionX2, double selectionY2,
297 
299 
303  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
304  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
305  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
306  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
307  double GetPickX1() const {return this->PickX1;}
308  double GetPickY1() const {return this->PickY1;}
309  double GetPickX2() const {return this->PickX2;}
310  double GetPickY2() const {return this->PickY2;}
311  vtkGetMacro(IsPicking, int);
312  vtkGetMacro(CurrentPickId, unsigned int);
313  void SetCurrentPickId(unsigned int a) {this->CurrentPickId = a;};
314  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
316 
320  virtual double GetPickedZ() = 0;
321 
322 protected:
323  // Create a vtkViewport with a black background, a white ambient light,
324  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
325  // culling turned off.
328 
329  // Picking functions to be implemented by sub-classes
330  // Perform the main picking loop
331  virtual void DevicePickRender() = 0;
332  // Enter a pick mode
333  virtual void StartPick(unsigned int pickFromSize) = 0;
334  // Set the pick id to the next id before drawing an object
335  virtual void UpdatePickId() = 0;
336  // Exit Pick mode
337  virtual void DonePick() = 0;
338  // Return the id of the picked object, only valid after a call to DonePick
339  virtual unsigned int GetPickedId() = 0;
340  // Return the number of objects picked, only valid after a call to DonePick
341  virtual unsigned int GetNumPickedIds() = 0;
342  // Put no more than atMost picked object ids into the callerBuffer and
343  // return the number of picked objects returned.
344  virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
345 
346  // Ivars for picking
347  // Store a picked Prop (contained in an assembly path)
351  // Boolean flag to determine if picking is enabled for this render
353  unsigned int CurrentPickId;
354  double PickX1;
355  double PickY1;
356  double PickX2;
357  double PickY2;
358  // End Ivars for picking
359 
363  double Background[3];
364  double Background2[3];
365  double Viewport[4];
366  double Aspect[2];
367  double PixelAspect[2];
368  double Center[2];
370 
371  int Size[2];
372  int Origin[2];
373  double DisplayPoint[3];
374  double ViewPoint[3];
375  double WorldPoint[4];
376 
377 
378 private:
379  vtkViewport(const vtkViewport&) VTK_DELETE_FUNCTION;
380  void operator=(const vtkViewport&) VTK_DELETE_FUNCTION;
381 };
382 
383 
384 
385 #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
abstract base class for most VTK objects
Definition: vtkObject.h:60
a list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
abstract specification for Viewports
Definition: vtkViewport.h:48
double GetPickY2() const
Definition: vtkViewport.h:310
virtual void ViewToWorld(double &, double &, double &)
Definition: vtkViewport.h:238
double GetPickX1() const
Definition: vtkViewport.h:307
vtkPropCollection * Props
Definition: vtkViewport.h:360
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:303
virtual void StartPick(unsigned int pickFromSize)=0
virtual void WorldToView()
Convert world point coordinates to view coordinates.
virtual void DisplayToLocalDisplay(double &x, double &y)
void WorldToDisplay()
Convert world point coordinates to display (or screen) coordinates.
Definition: vtkViewport.h:223
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:348
virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer)=0
virtual void ViewToNormalizedViewport(double &x, double &y, double &z)
double PickX2
Definition: vtkViewport.h:356
virtual double * GetCenter()
Return the center of this viewport in display coordinates.
virtual int * GetSize()
Get the size and origin of the viewport in display coordinates.
virtual void DisplayToView()
Convert display coordinates to view coordinates.
vtkAssemblyPath * PickPropFrom(double selectionX1, double selectionY1, double selectionX2, double selectionY2, vtkPropCollection *)
Same as PickProp with four arguments, but selects from the given collection of Props instead of the R...
virtual unsigned int GetNumPickedIds()=0
bool GradientBackground
Definition: vtkViewport.h:369
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
double GetPickX2() const
Definition: vtkViewport.h:309
void DisplayToWorld()
Convert display (or screen) coordinates to world coordinates.
Definition: vtkViewport.h:218
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:361
double GetPickHeight() const
Definition: vtkViewport.h:306
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 NormalizedDisplayToViewport(double &x, double &y)
void RemoveActor2D(vtkProp *p)
vtkWindow * VTKWindow
Definition: vtkViewport.h:362
virtual void ComputeAspect()
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:350
virtual void DevicePickRender()=0
virtual void NormalizedViewportToView(double &x, double &y, double &z)
vtkActor2DCollection * GetActors2D()
void AddActor2D(vtkProp *p)
Add/Remove different types of props to the renderer.
virtual void ViewportToNormalizedDisplay(double &x, double &y)
double PickX1
Definition: vtkViewport.h:354
virtual vtkWindow * GetVTKWindow()=0
Return the vtkWindow that owns this vtkViewport.
virtual vtkAssemblyPath * PickProp(double selectionX1, double selectionY1, double selectionX2, double selectionY2)=0
Return the Prop that has the highest z value at the given x1, y1 and x2,y2 positions in the viewport.
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.
void SetCurrentPickId(unsigned int a)
Definition: vtkViewport.h:313
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:349
virtual void NormalizedDisplayToDisplay(double &u, double &v)
virtual double GetPickedZ()=0
Return the Z value for the last picked Prop.
virtual void GetTiledSizeAndOrigin(int *width, int *height, int *lowerLeftX, int *lowerLeftY)
vtkPropCollection * GetViewProps()
Return any props in this viewport.
Definition: vtkViewport.h:63
double GetPickWidth() const
Definition: vtkViewport.h:305
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 UpdatePickId()=0
unsigned int CurrentPickId
Definition: vtkViewport.h:353
double PickY1
Definition: vtkViewport.h:355
double GetPickY() const
Definition: vtkViewport.h:304
virtual void DonePick()=0
virtual int IsInViewport(int x, int y)
Is a given display point in this Viewport's viewport.
virtual int * GetOrigin()
void RemoveAllViewProps(void)
Remove all props from the list of props.
virtual void DisplayToNormalizedDisplay(double &u, double &v)
virtual void NormalizedViewportToViewport(double &u, double &v)
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)
double PickY2
Definition: vtkViewport.h:357
virtual void ViewToDisplay()
Convert view coordinates to display coordinates.
virtual void ViewportToNormalizedViewport(double &u, double &v)
int HasViewProp(vtkProp *)
Query if a prop is in the list of props.
double GetPickY1() const
Definition: vtkViewport.h:308
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:244
virtual unsigned int GetPickedId()=0
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ Background
Definition: vtkX3D.h:71
@ height
Definition: vtkX3D.h:254
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.