VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Core/vtkViewport.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkViewport.h
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 "vtkRenderingCoreModule.h" // For export macro
00038 #include "vtkObject.h"
00039 
00040 class vtkActor2DCollection;
00041 class vtkAssemblyPath;
00042 class vtkProp;
00043 class vtkPropCollection;
00044 class vtkWindow;
00045 
00046 class VTKRENDERINGCORE_EXPORT vtkViewport : public vtkObject
00047 {
00048 public:
00049   vtkTypeMacro(vtkViewport,vtkObject);
00050   void PrintSelf(ostream& os, vtkIndent indent);
00051 
00055   void AddViewProp(vtkProp *);
00056 
00058   vtkPropCollection *GetViewProps() {return this->Props;};
00059 
00061   int HasViewProp(vtkProp *);
00062 
00065   void RemoveViewProp(vtkProp *);
00066 
00068   void RemoveAllViewProps(void);
00069 
00071 
00074   void AddActor2D(vtkProp* p);
00075   void RemoveActor2D(vtkProp* p);
00076   vtkActor2DCollection *GetActors2D();
00078 
00080 
00082   vtkSetVector3Macro(Background,double);
00083   vtkGetVector3Macro(Background,double);
00085 
00087 
00089   vtkSetVector3Macro(Background2,double);
00090   vtkGetVector3Macro(Background2,double);
00092 
00094 
00096   vtkSetMacro(GradientBackground,bool);
00097   vtkGetMacro(GradientBackground,bool);
00098   vtkBooleanMacro(GradientBackground,bool);
00100 
00102 
00104   vtkSetVector2Macro(Aspect,double);
00105   vtkGetVectorMacro(Aspect,double,2);
00106   virtual void ComputeAspect();
00108 
00110 
00113   vtkSetVector2Macro(PixelAspect,double);
00114   vtkGetVectorMacro(PixelAspect,double,2);
00116 
00118 
00121   vtkSetVector4Macro(Viewport,double);
00122   vtkGetVectorMacro(Viewport,double,4);
00124 
00126 
00129   vtkSetVector3Macro(DisplayPoint,double);
00130   vtkGetVectorMacro(DisplayPoint,double,3);
00132 
00134 
00137   vtkSetVector3Macro(ViewPoint,double);
00138   vtkGetVectorMacro(ViewPoint,double,3);
00140 
00142 
00144   vtkSetVector4Macro(WorldPoint,double);
00145   vtkGetVectorMacro(WorldPoint,double,4);
00147 
00149   virtual double *GetCenter();
00150 
00152   virtual int IsInViewport(int x,int y);
00153 
00155   virtual vtkWindow *GetVTKWindow() = 0;
00156 
00158   virtual void DisplayToView(); // these get modified in subclasses
00159 
00161   virtual void ViewToDisplay(); // to handle stereo rendering
00162 
00164   virtual void WorldToView();
00165 
00167   virtual void ViewToWorld();
00168 
00170   void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
00171 
00173   void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
00174 
00176 
00181   virtual void LocalDisplayToDisplay(double &x, double &y);
00182   virtual void DisplayToNormalizedDisplay(double &u, double &v);
00183   virtual void NormalizedDisplayToViewport(double &x, double &y);
00184   virtual void ViewportToNormalizedViewport(double &u, double &v);
00185   virtual void NormalizedViewportToView(double &x, double &y, double &z);
00186   virtual void ViewToWorld(double &, double &, double &) {}
00187   virtual void DisplayToLocalDisplay(double &x, double &y);
00188   virtual void NormalizedDisplayToDisplay(double &u, double &v);
00189   virtual void ViewportToNormalizedDisplay(double &x, double &y);
00190   virtual void NormalizedViewportToViewport(double &u, double &v);
00191   virtual void ViewToNormalizedViewport(double &x, double &y, double &z);
00192   virtual void WorldToView(double &, double &, double &) {}
00194 
00196 
00199   virtual int *GetSize();
00200   virtual int *GetOrigin();
00201   void GetTiledSize(int *width, int *height);
00202   virtual void GetTiledSizeAndOrigin(int *width, int *height,
00203                                      int *lowerLeftX, int *lowerLeftY);
00205 
00206   // The following methods describe the public pick interface for picking
00207   // Props in a viewport.
00208 
00214   virtual vtkAssemblyPath* PickProp(double selectionX, double selectionY) = 0;
00215 
00217 
00222   virtual vtkAssemblyPath* PickProp(double selectionX1, double selectionY1,
00223                                     double selectionX2, double selectionY2) = 0;
00225 
00227 
00230   vtkAssemblyPath* PickPropFrom(double selectionX, double selectionY,
00231                                 vtkPropCollection*);
00233 
00235 
00238   vtkAssemblyPath* PickPropFrom(double selectionX1, double selectionY1,
00239                                 double selectionX2, double selectionY2,
00240                                 vtkPropCollection*);
00242 
00244 
00246   double GetPickX() const {return (this->PickX1 + this->PickX2)*0.5;}
00247   double GetPickY() const {return (this->PickY1 + this->PickY2)*0.5;}
00248   double GetPickWidth() const {return this->PickX2 - this->PickX1 + 1;};
00249   double GetPickHeight() const {return this->PickY2 - this->PickY1 + 1;};
00250   double GetPickX1() const {return this->PickX1;}
00251   double GetPickY1() const {return this->PickY1;}
00252   double GetPickX2() const {return this->PickX2;}
00253   double GetPickY2() const {return this->PickY2;}
00254   vtkGetMacro(IsPicking, int);
00255   vtkGetMacro(CurrentPickId, unsigned int);
00256   void SetCurrentPickId(unsigned int a) {this->CurrentPickId = a;};
00257   vtkGetObjectMacro(PickResultProps, vtkPropCollection);
00259 
00261   virtual double GetPickedZ() = 0;
00262 
00263 protected:
00264   // Create a vtkViewport with a black background, a white ambient light,
00265   // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
00266   // culling turned off.
00267   vtkViewport();
00268   ~vtkViewport();
00269 
00270   //BTX
00271   // Picking functions to be implemented by sub-classes
00272   // Perform the main picking loop
00273   virtual void DevicePickRender() = 0;
00274   // Enter a pick mode
00275   virtual void StartPick(unsigned int pickFromSize) = 0;
00276   // Set the pick id to the next id before drawing an object
00277   virtual void UpdatePickId() = 0;
00278   // Exit Pick mode
00279   virtual void DonePick() = 0;
00280   // Return the id of the picked object, only valid after a call to DonePick
00281   virtual unsigned int GetPickedId() = 0;
00282   // Return the number of objects picked, only valid after a call to DonePick
00283   virtual unsigned int GetNumPickedIds() = 0;
00284   // Put no more than atMost picked object ids into the callerBuffer and
00285   // return the number of picked objects returned.
00286   virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer) = 0;
00287   //ETX
00288 
00289   // Ivars for picking
00290   // Store a picked Prop (contained in an assembly path)
00291   vtkAssemblyPath* PickedProp;
00292   vtkPropCollection* PickFromProps;
00293   vtkPropCollection* PickResultProps;
00294   // Boolean flag to determine if picking is enabled for this render
00295   int IsPicking;
00296   unsigned int CurrentPickId;
00297   double PickX1;
00298   double PickY1;
00299   double PickX2;
00300   double PickY2;
00301   // End Ivars for picking
00302 
00303   vtkPropCollection *Props;
00304   vtkActor2DCollection *Actors2D;
00305   vtkWindow *VTKWindow;
00306   double Background[3];
00307   double Background2[3];
00308   double Viewport[4];
00309   double Aspect[2];
00310   double PixelAspect[2];
00311   double Center[2];
00312   bool GradientBackground;
00313 
00314   int Size[2];
00315   int Origin[2];
00316   double DisplayPoint[3];
00317   double ViewPoint[3];
00318   double WorldPoint[4];
00319 
00320 
00321 private:
00322   vtkViewport(const vtkViewport&);  // Not implemented.
00323   void operator=(const vtkViewport&);  // Not implemented.
00324 };
00325 
00326 
00327 
00328 #endif