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

# Common/vtkViewport.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkViewport.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00050 #ifndef __vtkViewport_h
    00051 #define __vtkViewport_h
    00052
    00053 #include "vtkObject.h"
    00054
    00055 class vtkActor2DCollection;
    00056 class vtkAssemblyPath;
    00057 class vtkProp;
    00058 class vtkPropCollection;
    00059 class vtkWindow;
    00060
    00061 class VTK_COMMON_EXPORT vtkViewport : public vtkObject
    00062 {
    00063 public:
    00064   vtkTypeRevisionMacro(vtkViewport,vtkObject);
    00065   void PrintSelf(ostream& os, vtkIndent indent);
    00066
    00069   void AddProp(vtkProp *);
    00070
    00072   vtkPropCollection *GetProps() {return this->Props;};
    00073
    00075   void RemoveProp(vtkProp *);
    00076
    00078   void RemoveAllProps(void);
    00079
    00081
    00084   void AddActor2D(vtkProp* p) {this->AddProp(p);};
    00085   void RemoveActor2D(vtkProp* p);
    00086   vtkActor2DCollection *GetActors2D();
    00088
    00090
    00092   vtkSetVector3Macro(Background,float);
    00093   vtkGetVectorMacro(Background,float,3);
    00095
    00097
    00099   vtkSetVector2Macro(Aspect,float);
    00100   vtkGetVectorMacro(Aspect,float,2);
    00101   void ComputeAspect();
    00103
    00105
    00108   vtkSetVector2Macro(PixelAspect,float);
    00109   vtkGetVectorMacro(PixelAspect,float,2);
    00111
    00113
    00116   vtkSetVector4Macro(Viewport,float);
    00117   vtkGetVectorMacro(Viewport,float,4);
    00119
    00121
    00124   vtkSetVector3Macro(DisplayPoint,float);
    00125   vtkGetVectorMacro(DisplayPoint,float,3);
    00126   void GetDisplayPoint(double a[3])
    00127     {
    00128       a[0] = this->DisplayPoint[0];
    00129       a[1] = this->DisplayPoint[1];
    00130       a[2] = this->DisplayPoint[2];
    00131     };
    00133
    00135
    00138   vtkSetVector3Macro(ViewPoint,float);
    00139   vtkGetVectorMacro(ViewPoint,float,3);
    00141
    00143
    00145   vtkSetVector4Macro(WorldPoint,float);
    00146   vtkGetVectorMacro(WorldPoint,float,4);
    00147   void GetWorldPoint(double a[4])
    00148     {
    00149       a[0] = this->WorldPoint[0];
    00150       a[1] = this->WorldPoint[1];
    00151       a[2] = this->WorldPoint[2];
    00152       a[3] = this->WorldPoint[3];
    00153     };
    00155
    00157   virtual float *GetCenter();
    00158
    00160   virtual int IsInViewport(int x,int y);
    00161
    00163   virtual vtkWindow *GetVTKWindow() = 0;
    00164
    00167   void SetStartRenderMethod(void (*f)(void *), void *arg);
    00168
    00171   void SetEndRenderMethod(void (*f)(void *), void *arg);
    00172
    00174   void SetStartRenderMethodArgDelete(void (*f)(void *));
    00175
    00177   void SetEndRenderMethodArgDelete(void (*f)(void *));
    00178
    00180   virtual void DisplayToView(); // these get modified in subclasses
    00181
    00183   virtual void ViewToDisplay(); // to handle stereo rendering
    00184
    00186   virtual void WorldToView();
    00187
    00189   virtual void ViewToWorld();
    00190
    00192   void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
    00193
    00195   void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
    00196
    00198
    00203   virtual void LocalDisplayToDisplay(float &x, float &y);
    00204   virtual void DisplayToNormalizedDisplay(float &u, float &v);
    00205   virtual void NormalizedDisplayToViewport(float &x, float &y);
    00206   virtual void ViewportToNormalizedViewport(float &u, float &v);
    00207   virtual void NormalizedViewportToView(float &x, float &y, float &z);
    00208   virtual void ViewToWorld(float &, float &, float &) {};
    00209   virtual void DisplayToLocalDisplay(float &x, float &y);
    00210   virtual void NormalizedDisplayToDisplay(float &u, float &v);
    00211   virtual void ViewportToNormalizedDisplay(float &x, float &y);
    00212   virtual void NormalizedViewportToViewport(float &u, float &v);
    00213   virtual void ViewToNormalizedViewport(float &x, float &y, float &z);
    00214   virtual void WorldToView(float &, float &, float &) {};
    00216
    00218
    00221   int *GetSize();
    00222   int *GetOrigin();
    00223   void GetTiledSize(int *width, int *height);
    00225
    00226   // The following methods describe the public pick interface for picking
    00227   // Props in a viewport.
    00228
    00234   virtual vtkAssemblyPath* PickProp(float selectionX, float selectionY) = 0;
    00235
    00237
    00240   vtkAssemblyPath* PickPropFrom(float selectionX, float selectionY,
    00241                                 vtkPropCollection*);
    00243
    00245
    00247   vtkGetMacro(PickX, float);
    00248   vtkGetMacro(PickY, float);
    00249   vtkGetMacro(IsPicking, int);
    00251
    00253   virtual float GetPickedZ() = 0;
    00254
    00255 protected:
    00256   // Create a vtkViewport with a black background, a white ambient light,
    00257   // two-sided lighting turned on, a viewport of (0,0,1,1), and back face
    00258   // culling turned off.
    00259   vtkViewport();
    00260   ~vtkViewport();
    00261
    00262   //BTX
    00263   // Picking functions to be implemented by sub-classes
    00264   // Perform the main picking loop
    00265   virtual void DevicePickRender() = 0;
    00266   // Enter a pick mode
    00267   virtual void StartPick(unsigned int pickFromSize) = 0;
    00268   // Set the pick id to the next id before drawing an object
    00269   virtual void UpdatePickId() = 0;
    00270   // Exit Pick mode
    00271   virtual void DonePick() = 0;
    00272   // Return the id of the picked object, only valid after a call to DonePick
    00273   virtual unsigned int GetPickedId() = 0;
    00274   //ETX
    00275
    00276   // Ivars for picking
    00277   // Store a picked Prop (contained in an assembly path)
    00278   vtkAssemblyPath* PickedProp;
    00279   vtkPropCollection* PickFromProps;
    00280   // Boolean flag to determine if picking is enabled for this render
    00281   int IsPicking;
    00282   unsigned int CurrentPickId;
    00283   float PickX;
    00284   float PickY;
    00285   // End Ivars for picking
    00286
    00287   vtkPropCollection *Props;
    00288   vtkActor2DCollection *Actors2D;
    00289   vtkWindow *VTKWindow;
    00290   float Background[3];
    00291   float Viewport[4];
    00292   float Aspect[2];
    00293   float PixelAspect[2];
    00294   float Center[2];
    00295
    00296   unsigned long StartTag;
    00297   unsigned long EndTag;
    00298
    00299   int Size[2];
    00300   int Origin[2];
    00301   float DisplayPoint[3];
    00302   float ViewPoint[3];
    00303   float WorldPoint[4];
    00304
    00305 private:
    00306   vtkViewport(const vtkViewport&);  // Not implemented.
    00307   void operator=(const vtkViewport&);  // Not implemented.
    00308 };
    00309
    00310
    00311
    00312 #endif