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 =========================================================================*/
00058 #ifndef __vtkViewport_h
00059 #define __vtkViewport_h
00060 
00061 #include "vtkObject.h"
00062 #include "vtkPropCollection.h"
00063 #include "vtkActor2DCollection.h"
00064 
00065 class vtkWindow;
00066 class vtkAssemblyPath;
00067 
00068 class VTK_EXPORT vtkViewport : public vtkObject
00069 {
00070 public:
00071   vtkTypeMacro(vtkViewport,vtkObject);
00072   void PrintSelf(ostream& os, vtkIndent indent);
00073 
00076   void AddProp(vtkProp *);
00077 
00079   vtkPropCollection *GetProps() {return this->Props;};
00080 
00082   void RemoveProp(vtkProp *);
00083 
00087   void AddActor2D(vtkProp* p) {this->AddProp(p);};
00088   void RemoveActor2D(vtkProp* p);
00089   vtkActor2DCollection *GetActors2D();
00090 
00093   vtkSetVector3Macro(Background,float);
00094   vtkGetVectorMacro(Background,float,3);
00095 
00098   vtkSetVector2Macro(Aspect,float);
00099   vtkGetVectorMacro(Aspect,float,2);
00100   void ComputeAspect();
00101   
00105   vtkSetVector4Macro(Viewport,float);
00106   vtkGetVectorMacro(Viewport,float,4);
00107 
00111   vtkSetVector3Macro(DisplayPoint,float);
00112   vtkGetVectorMacro(DisplayPoint,float,3);
00113   void GetDisplayPoint(double *a) 
00114     {
00115       a[0] = this->DisplayPoint[0];
00116       a[1] = this->DisplayPoint[1];
00117       a[2] = this->DisplayPoint[2];
00118       a[3] = 1.0;
00119     };
00120 
00124   vtkSetVector3Macro(ViewPoint,float);
00125   vtkGetVectorMacro(ViewPoint,float,3);
00126 
00129   vtkSetVector4Macro(WorldPoint,float);
00130   vtkGetVectorMacro(WorldPoint,float,4);
00131   void GetWorldPoint(double *a) 
00132     {
00133       a[0] = this->WorldPoint[0];
00134       a[1] = this->WorldPoint[1];
00135       a[2] = this->WorldPoint[2];
00136       a[3] = this->WorldPoint[3];
00137     };
00138    
00140   virtual float *GetCenter();
00141 
00143   virtual int IsInViewport(int x,int y); 
00144 
00146   virtual vtkWindow *GetVTKWindow() = 0;
00147 
00150   void SetStartRenderMethod(void (*f)(void *), void *arg);
00151 
00154   void SetEndRenderMethod(void (*f)(void *), void *arg);
00155 
00157   void SetStartRenderMethodArgDelete(void (*f)(void *));
00158 
00160   void SetEndRenderMethodArgDelete(void (*f)(void *));
00161 
00163   virtual void DisplayToView(); // these get modified in subclasses
00164 
00166   virtual void ViewToDisplay(); // to handle stereo rendering
00167 
00169   virtual void WorldToView();
00170 
00172   virtual void ViewToWorld();
00173 
00175   void DisplayToWorld() {this->DisplayToView(); this->ViewToWorld();};
00176 
00178   void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};
00179 
00185   virtual void LocalDisplayToDisplay(float &x, float &y);
00186   virtual void DisplayToNormalizedDisplay(float &u, float &v);
00187   virtual void NormalizedDisplayToViewport(float &x, float &y);
00188   virtual void ViewportToNormalizedViewport(float &u, float &v);
00189   virtual void NormalizedViewportToView(float &x, float &y, float &z);
00190   virtual void ViewToWorld(float &, float &, float &) {};
00191   virtual void DisplayToLocalDisplay(float &x, float &y);
00192   virtual void NormalizedDisplayToDisplay(float &u, float &v);
00193   virtual void ViewportToNormalizedDisplay(float &x, float &y);
00194   virtual void NormalizedViewportToViewport(float &u, float &v);
00195   virtual void ViewToNormalizedViewport(float &x, float &y, float &z);
00196   virtual void WorldToView(float &, float &, float &) {};
00197 
00201   int *GetSize();
00202   int *GetOrigin();
00203 
00204   // The following methods describe the public pick interface for picking
00205   // Props in a viewport.
00206 
00212   virtual vtkAssemblyPath* PickProp(float selectionX, float selectionY) = 0;
00213 
00217   vtkAssemblyPath* PickPropFrom(float selectionX, float selectionY, 
00218                                 vtkPropCollection*);
00219   
00222   vtkGetMacro(PickX, float);
00223   vtkGetMacro(PickY, float);
00224   vtkGetMacro(IsPicking, int);
00225 
00227   virtual float GetPickedZ() = 0;
00228   
00229 protected:
00230   // Create a vtkViewport with a black background, a white ambient light, 
00231   // two-sided lighting turned on, a viewport of (0,0,1,1), and back face 
00232   // culling turned off.
00233   vtkViewport();
00234   ~vtkViewport();
00235   vtkViewport(const vtkViewport&) {};
00236   void operator=(const vtkViewport&) {};
00237 
00238   //BTX
00239   // Picking functions to be implemented by sub-classes
00240   // Perform the main picking loop
00241   virtual void DevicePickRender() = 0;
00242   // Enter a pick mode
00243   virtual void StartPick(unsigned int pickFromSize) = 0;
00244   // Set the pick id to the next id before drawing an object
00245   virtual void UpdatePickId() = 0;
00246   // Exit Pick mode
00247   virtual void DonePick() = 0; 
00248   // Return the id of the picked object, only valid after a call to DonePick
00249   virtual unsigned int GetPickedId() = 0;
00250   //ETX
00251 
00252   // Ivars for picking
00253   // Store a picked Prop (contained in an assembly path)
00254   vtkAssemblyPath* PickedProp;
00255   vtkPropCollection* PickFromProps;
00256   // Boolean flag to determine if picking is enabled for this render
00257   int IsPicking;
00258   unsigned int CurrentPickId;
00259   float PickX;
00260   float PickY;
00261   // End Ivars for picking
00262   
00263   vtkPropCollection *Props;
00264   vtkActor2DCollection *Actors2D;
00265   vtkWindow *VTKWindow;
00266   float Background[3];  
00267   float Viewport[4];
00268   float Aspect[2];
00269   float Center[2];
00270 
00271   unsigned long StartTag;
00272   unsigned long EndTag;
00273 
00274   int Size[2];
00275   int Origin[2];
00276   float DisplayPoint[3];
00277   float ViewPoint[3];
00278   float WorldPoint[4];
00279 
00280 };
00281 
00282 
00283 
00284 #endif

Generated on Wed Nov 21 12:26:54 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001