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:
49  vtkTypeMacro(vtkViewport,vtkObject);
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 
82  vtkSetVector3Macro(Background,double);
83  vtkGetVector3Macro(Background,double);
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 
222  virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
223  double selectionX2, double selectionY2) = 0;
225 
227 
230  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
233 
235 
238  vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
239  double selectionX2, double selectionY2,
242 
244 
246  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
247  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
248  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
249  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
250  double GetPickX1() const {return this->PickX1;}
251  double GetPickY1() const {return this->PickY1;}
252  double GetPickX2() const {return this->PickX2;}
253  double GetPickY2() const {return this->PickY2;}
254  vtkGetMacro(IsPicking, int);
255  vtkGetMacro(CurrentPickId, unsigned int);
256  void SetCurrentPickId(unsigned int a) {this->CurrentPickId = a;};
257  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
259 
261  virtual double GetPickedZ() = 0;
262 
263 protected:
264  // Create a vtkViewport with a black background, a white ambient light,
265  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
266  // culling turned off.
267  vtkViewport();
268  ~vtkViewport();
269 
270  //BTX
271  // Picking functions to be implemented by sub-classes
272  // Perform the main picking loop
273  virtual void DevicePickRender() = 0;
274  // Enter a pick mode
275  virtual void StartPick(unsigned int pickFromSize) = 0;
276  // Set the pick id to the next id before drawing an object
277  virtual void UpdatePickId() = 0;
278  // Exit Pick mode
279  virtual void DonePick() = 0;
280  // Return the id of the picked object, only valid after a call to DonePick
281  virtual unsigned int GetPickedId() = 0;
282  // Return the number of objects picked, only valid after a call to DonePick
283  virtual unsigned int GetNumPickedIds() = 0;
284  // Put no more than atMost picked object ids into the callerBuffer and
285  // return the number of picked objects returned.
286  virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
287  //ETX
288 
289  // Ivars for picking
290  // Store a picked Prop (contained in an assembly path)
294  // Boolean flag to determine if picking is enabled for this render
296  unsigned int CurrentPickId;
297  double PickX1;
298  double PickY1;
299  double PickX2;
300  double PickY2;
301  // End Ivars for picking
302 
306  double Background[3];
307  double Background2[3];
308  double Viewport[4];
309  double Aspect[2];
310  double PixelAspect[2];
311  double Center[2];
313 
314  int Size[2];
315  int Origin[2];
316  double DisplayPoint[3];
317  double ViewPoint[3];
318  double WorldPoint[4];
319 
320 
321 private:
322  vtkViewport(const vtkViewport&); // Not implemented.
323  void operator=(const vtkViewport&); // Not implemented.
324 };
325 
326 
327 
328 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
a list of 2D actors
unsigned int CurrentPickId
Definition: vtkViewport.h:296
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:293
void SetCurrentPickId(unsigned int a)
Definition: vtkViewport.h:256
abstract specification for Viewports
Definition: vtkViewport.h:46
double GetPickWidth() const
Definition: vtkViewport.h:248
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:192
vtkPropCollection * GetViewProps()
Definition: vtkViewport.h:58
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:291
double GetPickY() const
Definition: vtkViewport.h:247
vtkPropCollection * Props
Definition: vtkViewport.h:303
double PickY2
Definition: vtkViewport.h:300
double GetPickX() const
Definition: vtkViewport.h:246
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
double GetPickX2() const
Definition: vtkViewport.h:252
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:251
a simple class to control print indentation
Definition: vtkIndent.h:38
double GetPickHeight() const
Definition: vtkViewport.h:249
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:292
double PickX2
Definition: vtkViewport.h:299
double PickX1
Definition: vtkViewport.h:297
double GetPickX1() const
Definition: vtkViewport.h:250
double GetPickY2() const
Definition: vtkViewport.h:253
#define VTKRENDERINGCORE_EXPORT
vtkWindow * VTKWindow
Definition: vtkViewport.h:305
bool GradientBackground
Definition: vtkViewport.h:312
double PickY1
Definition: vtkViewport.h:298
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:304