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 =========================================================================*/
34 #ifndef __vtkViewport_h
35 #define __vtkViewport_h
36 
37 #include "vtkRenderingCoreModule.h" // For export macro
38 #include "vtkObject.h"
39 
41 class vtkAssemblyPath;
42 class vtkProp;
43 class vtkPropCollection;
44 class vtkWindow;
45 
47 {
48 public:
50  void PrintSelf(ostream& os, vtkIndent indent);
51 
55  void AddViewProp(vtkProp *);
56 
58  vtkPropCollection *GetViewProps() {return this->Props;};
59 
61  int HasViewProp(vtkProp *);
62 
65  void RemoveViewProp(vtkProp *);
66 
68  void RemoveAllViewProps(void);
69 
71 
74  void AddActor2D(vtkProp* p);
75  void RemoveActor2D(vtkProp* p);
76  vtkActor2DCollection *GetActors2D();
78 
80 
85 
87 
89  vtkSetVector3Macro(Background2,double);
90  vtkGetVector3Macro(Background2,double);
92 
94 
96  vtkSetMacro(GradientBackground,bool);
97  vtkGetMacro(GradientBackground,bool);
98  vtkBooleanMacro(GradientBackground,bool);
100 
102 
104  vtkSetVector2Macro(Aspect,double);
105  vtkGetVectorMacro(Aspect,double,2);
106  virtual void ComputeAspect();
108 
110 
113  vtkSetVector2Macro(PixelAspect,double);
114  vtkGetVectorMacro(PixelAspect,double,2);
116 
118 
121  vtkSetVector4Macro(Viewport,double);
122  vtkGetVectorMacro(Viewport,double,4);
124 
126 
129  vtkSetVector3Macro(DisplayPoint,double);
130  vtkGetVectorMacro(DisplayPoint,double,3);
132 
134 
137  vtkSetVector3Macro(ViewPoint,double);
138  vtkGetVectorMacro(ViewPoint,double,3);
140 
142 
144  vtkSetVector4Macro(WorldPoint,double);
145  vtkGetVectorMacro(WorldPoint,double,4);
147 
149  virtual double *GetCenter();
150 
152  virtual int IsInViewport(int x,int y);
153 
155  virtual vtkWindow *GetVTKWindow() = 0;
156 
158  virtual void DisplayToView(); // these get modified in subclasses
159 
161  virtual void ViewToDisplay(); // to handle stereo rendering
162 
164  virtual void WorldToView();
165 
167  virtual void ViewToWorld();
168 
170  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
171 
173  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
174 
176 
181  virtual void LocalDisplayToDisplay(double &x, double &y);
182  virtual void DisplayToNormalizedDisplay(double &u, double &v);
183  virtual void NormalizedDisplayToViewport(double &x, double &y);
184  virtual void ViewportToNormalizedViewport(double &u, double &v);
185  virtual void NormalizedViewportToView(double &x, double &y, double &z);
186  virtual void ViewToWorld(double &, double &, double &) {}
187  virtual void DisplayToLocalDisplay(double &x, double &y);
188  virtual void NormalizedDisplayToDisplay(double &u, double &v);
189  virtual void ViewportToNormalizedDisplay(double &x, double &y);
190  virtual void NormalizedViewportToViewport(double &u, double &v);
191  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
192  virtual void WorldToView(double &, double &, double &) {}
194 
196 
199  virtual int *GetSize();
200  virtual int *GetOrigin();
201  void GetTiledSize(int *width, int *height);
202  virtual void GetTiledSizeAndOrigin(int *width, int *height,
203  int *lowerLeftX, int *lowerLeftY);
205 
206  // The following methods describe the public pick interface for picking
207  // Props in a viewport.
208 
214  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
215 
217 
220  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
223 
225 
227  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
228  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
229  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
230  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
231  double GetPickX1() const {return this->PickX1;}
232  double GetPickY1() const {return this->PickY1;}
233  double GetPickX2() const {return this->PickX2;}
234  double GetPickY2() const {return this->PickY2;}
235  vtkGetMacro(IsPicking, int);
236  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
238 
240  virtual double GetPickedZ() = 0;
241 
242 protected:
243  // Create a vtkViewport with a black background, a white ambient light,
244  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
245  // culling turned off.
246  vtkViewport();
247  ~vtkViewport();
248 
249  //BTX
250  // Picking functions to be implemented by sub-classes
251  // Perform the main picking loop
252  virtual void DevicePickRender() = 0;
253  // Enter a pick mode
254  virtual void StartPick(unsigned int pickFromSize) = 0;
255  // Set the pick id to the next id before drawing an object
256  virtual void UpdatePickId() = 0;
257  // Exit Pick mode
258  virtual void DonePick() = 0;
259  // Return the id of the picked object, only valid after a call to DonePick
260  virtual unsigned int GetPickedId() = 0;
261  // Return the number of objects picked, only valid after a call to DonePick
262  virtual unsigned int GetNumPickedIds() = 0;
263  // Put no more than atMost picked object ids into the callerBuffer and
264  // return the number of picked objects returned.
265  virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
266  //ETX
267 
268  // Ivars for picking
269  // Store a picked Prop (contained in an assembly path)
273  // Boolean flag to determine if picking is enabled for this render
275  unsigned int CurrentPickId;
276  double PickX1;
277  double PickY1;
278  double PickX2;
279  double PickY2;
280  // End Ivars for picking
281 
285  double Background[3];
286  double Background2[3];
287  double Viewport[4];
288  double Aspect[2];
289  double PixelAspect[2];
290  double Center[2];
292 
293  int Size[2];
294  int Origin[2];
295  double DisplayPoint[3];
296  double ViewPoint[3];
297  double WorldPoint[4];
298 
299 
300 private:
301  vtkViewport(const vtkViewport&); // Not implemented.
302  void operator=(const vtkViewport&); // Not implemented.
303 };
304 
305 
306 
307 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
a list of 2D actors
unsigned int CurrentPickId
Definition: vtkViewport.h:275
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:272
const GLdouble * v
Definition: vtkgl.h:11595
abstract specification for Viewports
Definition: vtkViewport.h:46
double GetPickWidth() const
Definition: vtkViewport.h:229
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:192
vtkPropCollection * GetViewProps()
Definition: vtkViewport.h:58
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:270
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
double GetPickY() const
Definition: vtkViewport.h:228
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
vtkPropCollection * Props
Definition: vtkViewport.h:282
double PickY2
Definition: vtkViewport.h:279
double GetPickX() const
Definition: vtkViewport.h:227
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
a list of Props
GLdouble GLdouble z
Definition: vtkgl.h:11754
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
double GetPickX2() const
Definition: vtkViewport.h:233
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
void WorldToDisplay()
Definition: vtkViewport.h:173
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void ViewToWorld(double &, double &, double &)
Definition: vtkViewport.h:186
a list of nodes that form an assembly path
void DisplayToWorld()
Definition: vtkViewport.h:170
double GetPickY1() const
Definition: vtkViewport.h:232
#define vtkSetVector4Macro(name, type)
Definition: vtkSetGet.h:312
a simple class to control print indentation
Definition: vtkIndent.h:38
GLint GLint GLsizei width
Definition: vtkgl.h:11316
double GetPickHeight() const
Definition: vtkViewport.h:230
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:294
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:271
double PickX2
Definition: vtkViewport.h:278
double PickX1
Definition: vtkViewport.h:276
double GetPickX1() const
Definition: vtkViewport.h:231
double GetPickY2() const
Definition: vtkViewport.h:234
#define VTKRENDERINGCORE_EXPORT
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
vtkWindow * VTKWindow
Definition: vtkViewport.h:284
#define vtkSetVector3Macro(name, type)
Definition: vtkSetGet.h:277
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:414
bool GradientBackground
Definition: vtkViewport.h:291
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
double PickY1
Definition: vtkViewport.h:277
GLfloat GLfloat p
Definition: vtkgl.h:15717
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:283