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

graphics/vtkInteractorStyle.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInteractorStyle.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 =========================================================================*/
00107 #ifndef __vtkInteractorStyle_h
00108 #define __vtkInteractorStyle_h
00109 
00110 #include "vtkRenderWindowInteractor.h"
00111 
00112 // motion flags
00113 #define VTKIS_START   0
00114 #define VTKIS_ROTATE 1
00115 #define VTKIS_ZOOM   2
00116 #define VTKIS_PAN    3
00117 #define VTKIS_SPIN   4
00118 #define VTKIS_DOLLY  5
00119 #define VTKIS_USCALE 6
00120 #define VTKIS_TIMER  7 
00121 #define VTKIS_ANIM_OFF 0
00122 #define VTKIS_ANIM_ON  1
00123 
00124 class vtkPolyDataMapper;
00125 class vtkOutlineSource;
00126 
00127 class VTK_EXPORT vtkInteractorStyle : public vtkObject 
00128 {
00129 public:
00133   static vtkInteractorStyle *New();
00134 
00135   vtkTypeMacro(vtkInteractorStyle,vtkObject);
00136   void PrintSelf(ostream& os, vtkIndent indent);
00137 
00139   virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
00140   vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
00141 
00146   void FindPokedCamera(int,int);
00147   void FindPokedRenderer(int,int);
00148 
00153   virtual void HighlightProp(vtkProp *prop);
00154   virtual void HighlightActor2D(vtkActor2D *actor2D);
00155   virtual void HighlightProp3D(vtkProp3D *prop3D);
00156 
00159   vtkSetVector3Macro(PickColor,float);
00160   vtkGetVectorMacro(PickColor, float, 3);
00161 
00163   virtual void OnMouseMove  (int ctrl, int shift, int X, int Y);
00164   virtual void OnLeftButtonDown(int ctrl, int shift, int X, int Y);
00165   virtual void OnLeftButtonUp  (int ctrl, int shift, int X, int Y);
00166   virtual void OnMiddleButtonDown(int ctrl, int shift, int X, int Y);
00167   virtual void OnMiddleButtonUp  (int ctrl, int shift, int X, int Y);
00168   virtual void OnRightButtonDown(int ctrl, int shift, int X, int Y);
00169   virtual void OnRightButtonUp  (int ctrl, int shift, int X, int Y);
00170 
00173   virtual void OnChar   (int ctrl, int shift, char keycode, int repeatcount);
00174   virtual void OnKeyDown(int ctrl, int shift, char keycode, int repeatcount);
00175   virtual void OnKeyUp  (int ctrl, int shift, char keycode, int repeatcount);
00176   virtual void OnKeyPress(int ctrl, int shift, char keycode, char *keysym, 
00177            int repeatcount);
00178   virtual void OnKeyRelease(int ctrl, int shift, char keycode, char *keysym,
00179              int repeatcount);
00180 
00182   virtual void OnConfigure(int width, int height);
00183   virtual void OnEnter(int ctrl, int shift, int x, int y);
00184   virtual void OnLeave(int ctrl, int shift, int x, int y);
00185 
00188   virtual void OnTimer();
00189 
00191   void SetLeftButtonPressMethod(void (*f)(void *), void *arg);
00192   void SetLeftButtonPressMethodArgDelete(void (*f)(void *));
00193   void SetLeftButtonReleaseMethod(void (*f)(void *), void *arg);
00194   void SetLeftButtonReleaseMethodArgDelete(void (*f)(void *));
00195   void SetMiddleButtonPressMethod(void (*f)(void *), void *arg);
00196   void SetMiddleButtonPressMethodArgDelete(void (*f)(void *));
00197   void SetMiddleButtonReleaseMethod(void (*f)(void *), void *arg);
00198   void SetMiddleButtonReleaseMethodArgDelete(void (*f)(void *));
00199   void SetRightButtonPressMethod(void (*f)(void *), void *arg);
00200   void SetRightButtonPressMethodArgDelete(void (*f)(void *));
00201   void SetRightButtonReleaseMethod(void (*f)(void *), void *arg);
00202   void SetRightButtonReleaseMethodArgDelete(void (*f)(void *));
00203 
00204 protected:
00205   vtkInteractorStyle();
00206   ~vtkInteractorStyle();
00207   vtkInteractorStyle(const vtkInteractorStyle&) {};
00208   void operator=(const vtkInteractorStyle&) {};
00209 
00210   // convenience methods for converting between coordinate systems
00211   virtual void ComputeDisplayToWorld(double x, double y, double z,
00212                                      double *worldPt);
00213   virtual void ComputeWorldToDisplay(double x, double y, double z,
00214                                      double *displayPt);
00215   virtual void ComputeDisplayToWorld(double x, double y, double z,
00216                                      float *worldPt);
00217   virtual void ComputeWorldToDisplay(double x, double y, double z,
00218                                      float *displayPt);
00219 
00220   virtual void UpdateInternalState(int ctrl, int shift, int X, int Y);
00221 
00222   // These methods for the different interactions in different modes
00223   // are overridden in subclasses to perform the correct motion
00224   // This class provides a default implementation.
00225 
00226   virtual void RotateCamera(int x, int y);
00227   virtual void SpinCamera(int x, int y);
00228   virtual void PanCamera(int x, int y);
00229   virtual void DollyCamera(int x, int y);
00230 
00231   // utility routines used by state changes below
00232   virtual void StartState(int newstate);
00233   virtual void StopState();
00234 
00235   // Interaction mode entry points used internally.  
00236   virtual void StartAnimate();  
00237   virtual void StopAnimate();  
00238   virtual void StartRotate();
00239   virtual void EndRotate();
00240   virtual void StartZoom();
00241   virtual void EndZoom();
00242   virtual void StartPan();
00243   virtual void EndPan();
00244   virtual void StartSpin();
00245   virtual void EndSpin();
00246   virtual void StartDolly();
00247   virtual void EndDolly();
00248   virtual void StartUniformScale();
00249   virtual void EndUniformScale();
00250   virtual void StartTimer();
00251   virtual void EndTimer();
00252 
00253   // Data we need to maintain internally
00254   vtkRenderWindowInteractor *Interactor;
00255   //
00256   vtkCamera          *CurrentCamera;
00257   vtkLight           *CurrentLight;
00258   vtkRenderer        *CurrentRenderer;
00259   //
00260   float Center[2];
00261   float DeltaAzimuth;
00262   float DeltaElevation;
00263   int   CtrlKey;
00264   int   ShiftKey;
00265   int   LastPos[2];
00266   int   State;  
00267   int   AnimState;  
00268   float FocalDepth;  
00269 
00270   // for picking and highlighting props
00271   vtkOutlineSource   *Outline;
00272   vtkPolyDataMapper  *OutlineMapper;
00273   vtkActor           *OutlineActor;
00274   vtkRenderer        *PickedRenderer;
00275   vtkProp            *CurrentProp;
00276   int                PropPicked;          // boolean: prop picked?
00277   float              PickColor[3];        // support 2D picking
00278   vtkActor2D         *PickedActor2D;
00279 
00280   unsigned long LeftButtonPressTag;
00281   unsigned long LeftButtonReleaseTag;
00282   unsigned long MiddleButtonPressTag;
00283   unsigned long MiddleButtonReleaseTag;
00284   unsigned long RightButtonPressTag;
00285   unsigned long RightButtonReleaseTag;
00286 };
00287 
00288 #endif

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