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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00062 #ifndef __vtkViewport_h
00063 #define __vtkViewport_h
00064 
00065 #include "vtkObject.h"
00066 #include "vtkPropCollection.h"
00067 #include "vtkActor2DCollection.h"
00068 
00069 class vtkWindow;
00070 class vtkAssemblyPath;
00071 
00072 class VTK_COMMON_EXPORT vtkViewport : public vtkObject
00073 {
00074 public:
00075   vtkTypeMacro(vtkViewport,vtkObject);
00076   void PrintSelf(ostream& os, vtkIndent indent);
00077 
00080   void AddProp(vtkProp *);
00081 
00083   vtkPropCollection *GetProps() {return this->Props;};
00084 
00086   void RemoveProp(vtkProp *);
00087 
00089 
00092   void AddActor2D(vtkProp* p) {this->AddProp(p);};
00093   void RemoveActor2D(vtkProp* p);
00094   vtkActor2DCollection *GetActors2D();
00096 
00098 
00100   vtkSetVector3Macro(Background,float);
00101   vtkGetVectorMacro(Background,float,3);
00103 
00105 
00107   vtkSetVector2Macro(Aspect,float);
00108   vtkGetVectorMacro(Aspect,float,2);
00109   void ComputeAspect();
00111   
00113 
00116   vtkSetVector2Macro(PixelAspect,float);
00117   vtkGetVectorMacro(PixelAspect,float,2);
00119 
00121 
00124   vtkSetVector4Macro(Viewport,float);
00125   vtkGetVectorMacro(Viewport,float,4);
00127 
00129 
00132   vtkSetVector3Macro(DisplayPoint,float);
00133   vtkGetVectorMacro(DisplayPoint,float,3);
00134   void GetDisplayPoint(double *a) 
00135     {
00136       a[0] = this->DisplayPoint[0];
00137       a[1] = this->DisplayPoint[1];
00138       a[2] = this->DisplayPoint[2];
00139       a[3] = 1.0;
00140     };
00142 
00144 
00147   vtkSetVector3Macro(ViewPoint,float);
00148   vtkGetVectorMacro(ViewPoint,float,3);
00150 
00152 
00154   vtkSetVector4Macro(WorldPoint,float);
00155   vtkGetVectorMacro(WorldPoint,float,4);
00156   void GetWorldPoint(double *a) 
00157     {
00158       a[0] = this->WorldPoint[0];
00159       a[1] = this->WorldPoint[1];
00160       a[2] = this->WorldPoint[2];
00161       a[3] = this->WorldPoint[3];
00162     };
00164    
00166   virtual float *GetCenter();
00167 
00169   virtual int IsInViewport(int x,int y); 
00170 
00172   virtual vtkWindow *GetVTKWindow() = 0;
00173 
00176   void SetStartRenderMethod(void (*f)(void *), void *arg);
00177 
00180   void SetEndRenderMethod(void (*f)(void *), void *arg);
00181 
00183   void SetStartRenderMethodArgDelete(void (*f)(void *));
00184 
00186   void SetEndRenderMethodArgDelete(void (*f)(void *));
00187 
00189   virtual void DisplayToView(); // these get modified in subclasses
00190 
00192   virtual void ViewToDisplay(); // to handle stereo rendering
00193 
00195   virtual void WorldToView();
00196 
00198   virtual void ViewToWorld();
00199 
00201   void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
00202 
00204   void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
00205 
00207 
00212   virtual void LocalDisplayToDisplay(float &x, float &y);
00213   virtual void DisplayToNormalizedDisplay(float &u, float &v);
00214   virtual void NormalizedDisplayToViewport(float &x, float &y);
00215   virtual void ViewportToNormalizedViewport(float &u, float &v);
00216   virtual void NormalizedViewportToView(float &x, float &y, float &z);
00217   virtual void ViewToWorld(float &, float &, float &) {};
00218   virtual void DisplayToLocalDisplay(float &x, float &y);
00219   virtual void NormalizedDisplayToDisplay(float &u, float &v);
00220   virtual void ViewportToNormalizedDisplay(float &x, float &y);
00221   virtual void NormalizedViewportToViewport(float &u, float &v);
00222   virtual void ViewToNormalizedViewport(float &x, float &y, float &z);
00223   virtual void WorldToView(float &, float &, float &) {};
00225 
00227 
00230   int *GetSize();
00231   int *GetOrigin();
00233 
00234   // The following methods describe the public pick interface for picking
00235   // Props in a viewport.
00236 
00242   virtual vtkAssemblyPath* PickProp(float selectionX, float selectionY) = 0;
00243 
00245 
00248   vtkAssemblyPath* PickPropFrom(float selectionX, float selectionY, 
00249                                 vtkPropCollection*);
00251   
00253 
00255   vtkGetMacro(PickX, float);
00256   vtkGetMacro(PickY, float);
00257   vtkGetMacro(IsPicking, int);
00259 
00261   virtual float 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   //ETX
00283 
00284   // Ivars for picking
00285   // Store a picked Prop (contained in an assembly path)
00286   vtkAssemblyPath* PickedProp;
00287   vtkPropCollection* PickFromProps;
00288   // Boolean flag to determine if picking is enabled for this render
00289   int IsPicking;
00290   unsigned int CurrentPickId;
00291   float PickX;
00292   float PickY;
00293   // End Ivars for picking
00294   
00295   vtkPropCollection *Props;
00296   vtkActor2DCollection *Actors2D;
00297   vtkWindow *VTKWindow;
00298   float Background[3];  
00299   float Viewport[4];
00300   float Aspect[2];
00301   float PixelAspect[2];
00302   float Center[2];
00303 
00304   unsigned long StartTag;
00305   unsigned long EndTag;
00306 
00307   int Size[2];
00308   int Origin[2];
00309   float DisplayPoint[3];
00310   float ViewPoint[3];
00311   float WorldPoint[4];
00312 
00313 private:
00314   vtkViewport(const vtkViewport&);  // Not implemented.
00315   void operator=(const vtkViewport&);  // Not implemented.
00316 };
00317 
00318 
00319 
00320 #endif

Generated on Thu Mar 28 14:19:18 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001