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

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_FILTERING_EXPORT vtkViewport : public vtkObject
00046 {
00047 public:
00048   vtkTypeRevisionMacro(vtkViewport,vtkObject);
00049   void PrintSelf(ostream& os, vtkIndent indent);
00050 
00053   void AddViewProp(vtkProp *);
00054 
00056   vtkPropCollection *GetViewProps() {return this->Props;};
00057 
00059   int HasViewProp(vtkProp *);
00060 
00062   void RemoveViewProp(vtkProp *);
00063 
00065   void RemoveAllViewProps(void);
00066 
00068 
00071   void AddActor2D(vtkProp* p);
00072   void RemoveActor2D(vtkProp* p);
00073   vtkActor2DCollection *GetActors2D();
00075 
00077 
00079   vtkSetVector3Macro(Background,double);
00080   vtkGetVector3Macro(Background,double);
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);
00184   void GetTiledSizeAndOrigin(int *width, int *height, 
00185                              int *lowerLeftX, int *lowerLeftY);
00187   
00188   // The following methods describe the public pick interface for picking
00189   // Props in a viewport.
00190 
00196   virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
00197 
00199 
00202   vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, 
00203                                 vtkPropCollection*);
00205   
00207 
00209   vtkGetMacro(PickX, double);
00210   vtkGetMacro(PickY, double);
00211   vtkGetMacro(IsPicking, int);
00213 
00215   virtual double GetPickedZ() = 0;
00216 
00217 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00218 # define RemovePropA RemoveProp
00219 # define RemovePropW RemoveProp
00220 #endif
00221 
00223   VTK_LEGACY(void RemoveProp(vtkProp*));
00224 
00225 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00226 # undef RemovePropA
00227 # undef RemovePropW
00228   //BTX
00229   VTK_LEGACY(void RemovePropA(vtkProp*));
00230   VTK_LEGACY(void RemovePropW(vtkProp*));
00231   //ETX
00232 #endif
00233 
00235   VTK_LEGACY(void AddProp(vtkProp *));
00236 
00238   VTK_LEGACY(vtkPropCollection *GetProps());
00239 
00241   VTK_LEGACY(int HasProp(vtkProp *));
00242 
00245   VTK_LEGACY(void RemoveAllProps());
00246 
00247 protected:
00248   // Create a vtkViewport with a black background, a white ambient light, 
00249   // two-sided lighting turned on, a viewport of (0,0,1,1), and back face 
00250   // culling turned off.
00251   vtkViewport();
00252   ~vtkViewport();
00253 
00254   //BTX
00255   // Picking functions to be implemented by sub-classes
00256   // Perform the main picking loop
00257   virtual void DevicePickRender() = 0;
00258   // Enter a pick mode
00259   virtual void StartPick(unsigned int pickFromSize) = 0;
00260   // Set the pick id to the next id before drawing an object
00261   virtual void UpdatePickId() = 0;
00262   // Exit Pick mode
00263   virtual void DonePick() = 0; 
00264   // Return the id of the picked object, only valid after a call to DonePick
00265   virtual unsigned int GetPickedId() = 0;
00266   //ETX
00267 
00268   // Ivars for picking
00269   // Store a picked Prop (contained in an assembly path)
00270   vtkAssemblyPath* PickedProp;
00271   vtkPropCollection* PickFromProps;
00272   // Boolean flag to determine if picking is enabled for this render
00273   int IsPicking;
00274   unsigned int CurrentPickId;
00275   double PickX;
00276   double PickY;
00277   // End Ivars for picking
00278   
00279   vtkPropCollection *Props;
00280   vtkActor2DCollection *Actors2D;
00281   vtkWindow *VTKWindow;
00282   double Background[3];  
00283   double Viewport[4];
00284   double Aspect[2];
00285   double PixelAspect[2];
00286   double Center[2];
00287 
00288   int Size[2];
00289   int Origin[2];
00290   double DisplayPoint[3];
00291   double ViewPoint[3];
00292   double WorldPoint[4];
00293 
00294 private:
00295   vtkViewport(const vtkViewport&);  // Not implemented.
00296   void operator=(const vtkViewport&);  // Not implemented.
00297 };
00298 
00299 
00300 
00301 #endif

Generated on Mon Jan 21 23:07:21 2008 for VTK by  doxygen 1.4.3-20050530