Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 =========================================================================*/
00044 #ifndef __vtkViewport_h
00045 #define __vtkViewport_h
00046 
00047 #include "vtkObject.h"
00048 
00049 class vtkActor2DCollection;
00050 class vtkAssemblyPath;
00051 class vtkProp;
00052 class vtkPropCollection;
00053 class vtkWindow;
00054 
00055 class VTK_FILTERING_EXPORT vtkViewport : public vtkObject
00056 {
00057 public:
00058   vtkTypeRevisionMacro(vtkViewport,vtkObject);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00063   void AddProp(vtkProp *);
00064 
00066   vtkPropCollection *GetProps() {return this->Props;};
00067 
00069   int HasProp(vtkProp *);
00070 
00072   void RemoveProp(vtkProp *);
00073 
00075   void RemoveAllProps(void);
00076 
00078 
00081   void AddActor2D(vtkProp* p) {this->AddProp(p);};
00082   void RemoveActor2D(vtkProp* p);
00083   vtkActor2DCollection *GetActors2D();
00085 
00087 
00089   vtkSetVector3Macro(Background,double);
00090   vtkGetVector3Macro(Background,double);
00092 
00094 
00096   vtkSetVector2Macro(Aspect,double);
00097   vtkGetVectorMacro(Aspect,double,2);
00098   virtual void ComputeAspect();
00100   
00102 
00105   vtkSetVector2Macro(PixelAspect,double);
00106   vtkGetVectorMacro(PixelAspect,double,2);
00108 
00110 
00113   vtkSetVector4Macro(Viewport,double);
00114   vtkGetVectorMacro(Viewport,double,4);
00116 
00118 
00121   vtkSetVector3Macro(DisplayPoint,double);
00122   vtkGetVectorMacro(DisplayPoint,double,3);
00124 
00126 
00129   vtkSetVector3Macro(ViewPoint,double);
00130   vtkGetVectorMacro(ViewPoint,double,3);
00132 
00134 
00136   vtkSetVector4Macro(WorldPoint,double);
00137   vtkGetVectorMacro(WorldPoint,double,4);
00139    
00141   virtual double *GetCenter();
00142 
00144   virtual int IsInViewport(int x,int y); 
00145 
00147   virtual vtkWindow *GetVTKWindow() = 0;
00148 
00150   virtual void DisplayToView(); // these get modified in subclasses
00151 
00153   virtual void ViewToDisplay(); // to handle stereo rendering
00154 
00156   virtual void WorldToView();
00157 
00159   virtual void ViewToWorld();
00160 
00162   void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
00163 
00165   void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
00166 
00168 
00173   virtual void LocalDisplayToDisplay(double &x, double &y);
00174   virtual void DisplayToNormalizedDisplay(double &u, double &v);
00175   virtual void NormalizedDisplayToViewport(double &x, double &y);
00176   virtual void ViewportToNormalizedViewport(double &u, double &v);
00177   virtual void NormalizedViewportToView(double &x, double &y, double &z);
00178   virtual void ViewToWorld(double &, double &, double &) {};
00179   virtual void DisplayToLocalDisplay(double &x, double &y);
00180   virtual void NormalizedDisplayToDisplay(double &u, double &v);
00181   virtual void ViewportToNormalizedDisplay(double &x, double &y);
00182   virtual void NormalizedViewportToViewport(double &u, double &v);
00183   virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
00184   virtual void WorldToView(double &, double &, double &) {};
00186 
00188 
00191   int *GetSize();
00192   int *GetOrigin();
00193   void GetTiledSize(int *width, int *height);
00194   void GetTiledSizeAndOrigin(int *width, int *height, 
00195                              int *lowerLeftX, int *lowerLeftY);
00197   
00198   // The following methods describe the public pick interface for picking
00199   // Props in a viewport.
00200 
00206   virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
00207 
00209 
00212   vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY, 
00213                                 vtkPropCollection*);
00215   
00217 
00219   vtkGetMacro(PickX, double);
00220   vtkGetMacro(PickY, double);
00221   vtkGetMacro(IsPicking, int);
00223 
00225   virtual double GetPickedZ() = 0;
00226   
00227 protected:
00228   // Create a vtkViewport with a black background, a white ambient light, 
00229   // two-sided lighting turned on, a viewport of (0,0,1,1), and back face 
00230   // culling turned off.
00231   vtkViewport();
00232   ~vtkViewport();
00233 
00234   //BTX
00235   // Picking functions to be implemented by sub-classes
00236   // Perform the main picking loop
00237   virtual void DevicePickRender() = 0;
00238   // Enter a pick mode
00239   virtual void StartPick(unsigned int pickFromSize) = 0;
00240   // Set the pick id to the next id before drawing an object
00241   virtual void UpdatePickId() = 0;
00242   // Exit Pick mode
00243   virtual void DonePick() = 0; 
00244   // Return the id of the picked object, only valid after a call to DonePick
00245   virtual unsigned int GetPickedId() = 0;
00246   //ETX
00247 
00248   // Ivars for picking
00249   // Store a picked Prop (contained in an assembly path)
00250   vtkAssemblyPath* PickedProp;
00251   vtkPropCollection* PickFromProps;
00252   // Boolean flag to determine if picking is enabled for this render
00253   int IsPicking;
00254   unsigned int CurrentPickId;
00255   double PickX;
00256   double PickY;
00257   // End Ivars for picking
00258   
00259   vtkPropCollection *Props;
00260   vtkActor2DCollection *Actors2D;
00261   vtkWindow *VTKWindow;
00262   double Background[3];  
00263   double Viewport[4];
00264   double Aspect[2];
00265   double PixelAspect[2];
00266   double Center[2];
00267 
00268   int Size[2];
00269   int Origin[2];
00270   double DisplayPoint[3];
00271   double ViewPoint[3];
00272   double WorldPoint[4];
00273 
00274 private:
00275   vtkViewport(const vtkViewport&);  // Not implemented.
00276   void operator=(const vtkViewport&);  // Not implemented.
00277 };
00278 
00279 
00280 
00281 #endif