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 "vtkObject.h"
38 
39 class vtkActor2DCollection;
40 class vtkAssemblyPath;
41 class vtkProp;
42 class vtkPropCollection;
43 class vtkWindow;
44 
46 {
47 public:
48  vtkTypeMacro(vtkViewport,vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent);
50 
53  void AddViewProp(vtkProp *);
54 
56  vtkPropCollection *GetViewProps() {return this->Props;};
57 
59  int HasViewProp(vtkProp *);
60 
62  void RemoveViewProp(vtkProp *);
63 
65  void RemoveAllViewProps(void);
66 
68 
71  void AddActor2D(vtkProp* p);
72  void RemoveActor2D(vtkProp* p);
73  vtkActor2DCollection *GetActors2D();
75 
77 
79  vtkSetVector3Macro(Background,double);
80  vtkGetVector3Macro(Background,double);
82 
84 
86  vtkSetVector3Macro(Background2,double);
87  vtkGetVector3Macro(Background2,double);
89 
91 
93  vtkSetMacro(GradientBackground,bool);
94  vtkGetMacro(GradientBackground,bool);
95  vtkBooleanMacro(GradientBackground,bool);
97 
99 
101  vtkSetVector2Macro(Aspect,double);
102  vtkGetVectorMacro(Aspect,double,2);
103  virtual void ComputeAspect();
105 
107 
110  vtkSetVector2Macro(PixelAspect,double);
111  vtkGetVectorMacro(PixelAspect,double,2);
113 
115 
118  vtkSetVector4Macro(Viewport,double);
119  vtkGetVectorMacro(Viewport,double,4);
121 
123 
126  vtkSetVector3Macro(DisplayPoint,double);
127  vtkGetVectorMacro(DisplayPoint,double,3);
129 
131 
134  vtkSetVector3Macro(ViewPoint,double);
135  vtkGetVectorMacro(ViewPoint,double,3);
137 
139 
141  vtkSetVector4Macro(WorldPoint,double);
142  vtkGetVectorMacro(WorldPoint,double,4);
144 
146  virtual double *GetCenter();
147 
149  virtual int IsInViewport(int x,int y);
150 
152  virtual vtkWindow *GetVTKWindow() = 0;
153 
155  virtual void DisplayToView(); // these get modified in subclasses
156 
158  virtual void ViewToDisplay(); // to handle stereo rendering
159 
161  virtual void WorldToView();
162 
164  virtual void ViewToWorld();
165 
167  void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
168 
170  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
171 
173 
178  virtual void LocalDisplayToDisplay(double &x, double &y);
179  virtual void DisplayToNormalizedDisplay(double &u, double &v);
180  virtual void NormalizedDisplayToViewport(double &x, double &y);
181  virtual void ViewportToNormalizedViewport(double &u, double &v);
182  virtual void NormalizedViewportToView(double &x, double &y, double &z);
183  virtual void ViewToWorld(double &, double &, double &) {};
184  virtual void DisplayToLocalDisplay(double &x, double &y);
185  virtual void NormalizedDisplayToDisplay(double &u, double &v);
186  virtual void ViewportToNormalizedDisplay(double &x, double &y);
187  virtual void NormalizedViewportToViewport(double &u, double &v);
188  virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
189  virtual void WorldToView(double &, double &, double &) {};
191 
193 
196  virtual int *GetSize();
197  virtual int *GetOrigin();
198  void GetTiledSize(int *width, int *height);
199  virtual void GetTiledSizeAndOrigin(int *width, int *height,
200  int *lowerLeftX, int *lowerLeftY);
202 
203  // The following methods describe the public pick interface for picking
204  // Props in a viewport.
205 
211  virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
212 
214 
217  vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
220 
222 
224  double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
225  double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
226  double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
227  double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
228  double GetPickX1() const {return this->PickX1;}
229  double GetPickY1() const {return this->PickY1;}
230  double GetPickX2() const {return this->PickX2;}
231  double GetPickY2() const {return this->PickY2;}
232  vtkGetMacro(IsPicking, int);
233  vtkGetObjectMacro(PickResultProps, vtkPropCollection);
235 
237  virtual double GetPickedZ() = 0;
238 
239 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
240 # define RemovePropA RemoveProp
241 # define RemovePropW RemoveProp
242 #endif
243 
245  VTK_LEGACY(void RemoveProp(vtkProp*));
246 
247 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
248 # undef RemovePropA
249 # undef RemovePropW
250  //BTX
251  VTK_LEGACY(void RemovePropA(vtkProp*));
252  VTK_LEGACY(void RemovePropW(vtkProp*));
253  //ETX
254 #endif
255 
257  VTK_LEGACY(void AddProp(vtkProp *));
258 
260  VTK_LEGACY(vtkPropCollection *GetProps());
261 
263  VTK_LEGACY(int HasProp(vtkProp *));
264 
267  VTK_LEGACY(void RemoveAllProps());
268 
269 protected:
270  // Create a vtkViewport with a black background, a white ambient light,
271  // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
272  // culling turned off.
273  vtkViewport();
274  ~vtkViewport();
275 
276  //BTX
277  // Picking functions to be implemented by sub-classes
278  // Perform the main picking loop
279  virtual void DevicePickRender() = 0;
280  // Enter a pick mode
281  virtual void StartPick(unsigned int pickFromSize) = 0;
282  // Set the pick id to the next id before drawing an object
283  virtual void UpdatePickId() = 0;
284  // Exit Pick mode
285  virtual void DonePick() = 0;
286  // Return the id of the picked object, only valid after a call to DonePick
287  virtual unsigned int GetPickedId() = 0;
288  // Return the number of objects picked, only valid after a call to DonePick
289  virtual unsigned int GetNumPickedIds() = 0;
290  // Put no more than atMost picked object ids into the callerBuffer and
291  // return the number of picked objects returned.
292  virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
293  //ETX
294 
295  // Ivars for picking
296  // Store a picked Prop (contained in an assembly path)
300  // Boolean flag to determine if picking is enabled for this render
302  unsigned int CurrentPickId;
303  double PickX1;
304  double PickY1;
305  double PickX2;
306  double PickY2;
307  // End Ivars for picking
308 
310  vtkActor2DCollection *Actors2D;
312  double Background[3];
313  double Background2[3];
314  double Viewport[4];
315  double Aspect[2];
316  double PixelAspect[2];
317  double Center[2];
319 
320  int Size[2];
321  int Origin[2];
322  double DisplayPoint[3];
323  double ViewPoint[3];
324  double WorldPoint[4];
325 
326 
327 private:
328  vtkViewport(const vtkViewport&); // Not implemented.
329  void operator=(const vtkViewport&); // Not implemented.
330 };
331 
332 
333 
334 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
unsigned int CurrentPickId
Definition: vtkViewport.h:302
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkPropCollection * PickResultProps
Definition: vtkViewport.h:299
abstract specification for Viewports
Definition: vtkViewport.h:45
#define VTK_FILTERING_EXPORT
double GetPickWidth() const
Definition: vtkViewport.h:226
virtual void WorldToView(double &, double &, double &)
Definition: vtkViewport.h:189
vtkPropCollection * GetViewProps()
Definition: vtkViewport.h:56
vtkAssemblyPath * PickedProp
Definition: vtkViewport.h:297
double GetPickY() const
Definition: vtkViewport.h:225
vtkPropCollection * Props
Definition: vtkViewport.h:309
double PickY2
Definition: vtkViewport.h:306
double GetPickX() const
Definition: vtkViewport.h:224
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
double GetPickX2() const
Definition: vtkViewport.h:230
void WorldToDisplay()
Definition: vtkViewport.h:170
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void ViewToWorld(double &, double &, double &)
Definition: vtkViewport.h:183
a list of nodes that form an assembly path
void DisplayToWorld()
Definition: vtkViewport.h:167
double GetPickY1() const
Definition: vtkViewport.h:229
a simple class to control print indentation
Definition: vtkIndent.h:37
double GetPickHeight() const
Definition: vtkViewport.h:227
vtkPropCollection * PickFromProps
Definition: vtkViewport.h:298
double PickX2
Definition: vtkViewport.h:305
double PickX1
Definition: vtkViewport.h:303
double GetPickX1() const
Definition: vtkViewport.h:228
double GetPickY2() const
Definition: vtkViewport.h:231
vtkWindow * VTKWindow
Definition: vtkViewport.h:311
bool GradientBackground
Definition: vtkViewport.h:318
double PickY1
Definition: vtkViewport.h:304
vtkActor2DCollection * Actors2D
Definition: vtkViewport.h:310