Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkViewport.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkViewport.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00034 #ifndef __vtkViewport_h 00035 #define __vtkViewport_h 00036 00037 #include "vtkObject.h" 00038 00039 class vtkActor2DCollection; 00040 class vtkAssemblyPath; 00041 class vtkProp; 00042 class vtkPropCollection; 00043 class vtkWindow; 00044 00045 class VTK_COMMON_EXPORT vtkViewport : public vtkObject 00046 { 00047 public: 00048 vtkTypeRevisionMacro(vtkViewport,vtkObject); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00050 00053 void AddProp(vtkProp *); 00054 00056 vtkPropCollection *GetProps() {return this->Props;}; 00057 00059 int HasProp(vtkProp *); 00060 00062 void RemoveProp(vtkProp *); 00063 00065 void RemoveAllProps(void); 00066 00068 00071 void AddActor2D(vtkProp* p) {this->AddProp(p);}; 00072 void RemoveActor2D(vtkProp* p); 00073 vtkActor2DCollection *GetActors2D(); 00075 00077 00079 vtkSetVector3Macro(Background,double); 00080 vtkGetVectorMacro(Background,double,3); 00082 00084 00086 vtkSetVector2Macro(Aspect,double); 00087 vtkGetVectorMacro(Aspect,double,2); 00088 virtual void ComputeAspect(); 00090 00092 00095 vtkSetVector2Macro(PixelAspect,double); 00096 vtkGetVectorMacro(PixelAspect,double,2); 00098 00100 00103 vtkSetVector4Macro(Viewport,double); 00104 vtkGetVectorMacro(Viewport,double,4); 00106 00108 00111 vtkSetVector3Macro(DisplayPoint,double); 00112 vtkGetVectorMacro(DisplayPoint,double,3); 00114 00116 00119 vtkSetVector3Macro(ViewPoint,double); 00120 vtkGetVectorMacro(ViewPoint,double,3); 00122 00124 00126 vtkSetVector4Macro(WorldPoint,double); 00127 vtkGetVectorMacro(WorldPoint,double,4); 00129 00131 virtual double *GetCenter(); 00132 00134 virtual int IsInViewport(int x,int y); 00135 00137 virtual vtkWindow *GetVTKWindow() = 0; 00138 00140 virtual void DisplayToView(); // these get modified in subclasses 00141 00143 virtual void ViewToDisplay(); // to handle stereo rendering 00144 00146 virtual void WorldToView(); 00147 00149 virtual void ViewToWorld(); 00150 00152 void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();}; 00153 00155 void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();}; 00156 00158 00163 virtual void LocalDisplayToDisplay(double &x, double &y); 00164 virtual void DisplayToNormalizedDisplay(double &u, double &v); 00165 virtual void NormalizedDisplayToViewport(double &x, double &y); 00166 virtual void ViewportToNormalizedViewport(double &u, double &v); 00167 virtual void NormalizedViewportToView(double &x, double &y, double &z); 00168 virtual void ViewToWorld(double &, double &, double &) {}; 00169 virtual void DisplayToLocalDisplay(double &x, double &y); 00170 virtual void NormalizedDisplayToDisplay(double &u, double &v); 00171 virtual void ViewportToNormalizedDisplay(double &x, double &y); 00172 virtual void NormalizedViewportToViewport(double &u, double &v); 00173 virtual void ViewToNormalizedViewport(double &x, double &y, double &z); 00174 virtual void WorldToView(double &, double &, double &) {}; 00176 00178 00181 int *GetSize(); 00182 int *GetOrigin(); 00183 void GetTiledSize(int *width, int *height); 00185 00186 // The following methods describe the public pick interface for picking 00187 // Props in a viewport. 00188 00194 virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0; 00195 00197 00200 vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, 00201 vtkPropCollection*); 00203 00205 00207 vtkGetMacro(PickX, double); 00208 vtkGetMacro(PickY, double); 00209 vtkGetMacro(IsPicking, int); 00211 00213 virtual double GetPickedZ() = 0; 00214 00215 protected: 00216 // Create a vtkViewport with a black background, a white ambient light, 00217 // two-sided lighting turned on, a viewport of (0,0,1,1), and back face 00218 // culling turned off. 00219 vtkViewport(); 00220 ~vtkViewport(); 00221 00222 //BTX 00223 // Picking functions to be implemented by sub-classes 00224 // Perform the main picking loop 00225 virtual void DevicePickRender() = 0; 00226 // Enter a pick mode 00227 virtual void StartPick(unsigned int pickFromSize) = 0; 00228 // Set the pick id to the next id before drawing an object 00229 virtual void UpdatePickId() = 0; 00230 // Exit Pick mode 00231 virtual void DonePick() = 0; 00232 // Return the id of the picked object, only valid after a call to DonePick 00233 virtual unsigned int GetPickedId() = 0; 00234 //ETX 00235 00236 // Ivars for picking 00237 // Store a picked Prop (contained in an assembly path) 00238 vtkAssemblyPath* PickedProp; 00239 vtkPropCollection* PickFromProps; 00240 // Boolean flag to determine if picking is enabled for this render 00241 int IsPicking; 00242 unsigned int CurrentPickId; 00243 double PickX; 00244 double PickY; 00245 // End Ivars for picking 00246 00247 vtkPropCollection *Props; 00248 vtkActor2DCollection *Actors2D; 00249 vtkWindow *VTKWindow; 00250 double Background[3]; 00251 double Viewport[4]; 00252 double Aspect[2]; 00253 double PixelAspect[2]; 00254 double Center[2]; 00255 00256 int Size[2]; 00257 int Origin[2]; 00258 double DisplayPoint[3]; 00259 double ViewPoint[3]; 00260 double WorldPoint[4]; 00261 00262 private: 00263 vtkViewport(const vtkViewport&); // Not implemented. 00264 void operator=(const vtkViewport&); // Not implemented. 00265 }; 00266 00267 00268 00269 #endif