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

Rendering/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 =========================================================================*/
00112 #ifndef __vtkInteractorStyle_h
00113 #define __vtkInteractorStyle_h
00114 
00115 #include "vtkRenderWindowInteractor.h"
00116 
00117 // motion flags
00118 #define VTKIS_START   0
00119 #define VTKIS_ROTATE 1
00120 #define VTKIS_ZOOM   2
00121 #define VTKIS_PAN    3
00122 #define VTKIS_SPIN   4
00123 #define VTKIS_DOLLY  5
00124 #define VTKIS_USCALE 6
00125 #define VTKIS_TIMER  7 
00126 #define VTKIS_ANIM_OFF 0
00127 #define VTKIS_ANIM_ON  1
00128 
00129 class vtkPolyDataMapper;
00130 class vtkOutlineSource;
00131 
00132 class VTK_RENDERING_EXPORT vtkInteractorStyle : public vtkObject 
00133 {
00134 public:
00138   static vtkInteractorStyle *New();
00139 
00140   vtkTypeMacro(vtkInteractorStyle,vtkObject);
00141   void PrintSelf(ostream& os, vtkIndent indent);
00142 
00144 
00145   virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
00146   vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
00148 
00150 
00156   vtkSetClampMacro( AutoAdjustCameraClippingRange, int, 0, 1 );
00157   vtkGetMacro( AutoAdjustCameraClippingRange, int );
00158   vtkBooleanMacro( AutoAdjustCameraClippingRange, int );
00160   
00162 
00166   void FindPokedCamera(int,int);
00167   void FindPokedRenderer(int,int);
00169 
00171 
00175   virtual void HighlightProp(vtkProp *prop);
00176   virtual void HighlightActor2D(vtkActor2D *actor2D);
00177   virtual void HighlightProp3D(vtkProp3D *prop3D);
00179 
00181 
00183   vtkSetVector3Macro(PickColor,float);
00184   vtkGetVectorMacro(PickColor, float, 3);
00186 
00188 
00189   virtual void OnMouseMove  (int ctrl, int shift, int X, int Y);
00190   virtual void OnLeftButtonDown(int ctrl, int shift, int X, int Y);
00191   virtual void OnLeftButtonUp  (int ctrl, int shift, int X, int Y);
00192   virtual void OnMiddleButtonDown(int ctrl, int shift, int X, int Y);
00193   virtual void OnMiddleButtonUp  (int ctrl, int shift, int X, int Y);
00194   virtual void OnRightButtonDown(int ctrl, int shift, int X, int Y);
00195   virtual void OnRightButtonUp  (int ctrl, int shift, int X, int Y);
00197 
00199 
00201   virtual void OnChar   (int ctrl, int shift, char keycode, int repeatcount);
00202   virtual void OnKeyDown(int ctrl, int shift, char keycode, int repeatcount);
00203   virtual void OnKeyUp  (int ctrl, int shift, char keycode, int repeatcount);
00204   virtual void OnKeyPress(int ctrl, int shift, char keycode, char *keysym, 
00205                           int repeatcount);
00206   virtual void OnKeyRelease(int ctrl, int shift, char keycode, char *keysym,
00207                             int repeatcount);
00209 
00211 
00212   virtual void OnConfigure(int width, int height);
00213   virtual void OnEnter(int ctrl, int shift, int x, int y);
00214   virtual void OnLeave(int ctrl, int shift, int x, int y);
00216 
00219   virtual void OnTimer();
00220 
00222 
00223   void SetLeftButtonPressMethod(void (*f)(void *), void *arg);
00224   void SetLeftButtonPressMethodArgDelete(void (*f)(void *));
00225   void SetLeftButtonReleaseMethod(void (*f)(void *), void *arg);
00226   void SetLeftButtonReleaseMethodArgDelete(void (*f)(void *));
00227   void SetMiddleButtonPressMethod(void (*f)(void *), void *arg);
00228   void SetMiddleButtonPressMethodArgDelete(void (*f)(void *));
00229   void SetMiddleButtonReleaseMethod(void (*f)(void *), void *arg);
00230   void SetMiddleButtonReleaseMethodArgDelete(void (*f)(void *));
00231   void SetRightButtonPressMethod(void (*f)(void *), void *arg);
00232   void SetRightButtonPressMethodArgDelete(void (*f)(void *));
00233   void SetRightButtonReleaseMethod(void (*f)(void *), void *arg);
00234   void SetRightButtonReleaseMethodArgDelete(void (*f)(void *));
00236 
00237 protected:
00238   vtkInteractorStyle();
00239   ~vtkInteractorStyle();
00240 
00241   // Will the clipping range be automatically adjust before each render?
00242   int AutoAdjustCameraClippingRange;
00243   void ResetCameraClippingRange();
00244   
00245   // convenience methods for converting between coordinate systems
00246   virtual void ComputeDisplayToWorld(double x, double y, double z,
00247                                      double *worldPt);
00248   virtual void ComputeWorldToDisplay(double x, double y, double z,
00249                                      double *displayPt);
00250   virtual void ComputeDisplayToWorld(double x, double y, double z,
00251                                      float *worldPt);
00252   virtual void ComputeWorldToDisplay(double x, double y, double z,
00253                                      float *displayPt);
00254 
00255   virtual void UpdateInternalState(int ctrl, int shift, int X, int Y);
00256 
00257   // These methods for the different interactions in different modes
00258   // are overridden in subclasses to perform the correct motion
00259   // This class provides a default implementation.
00260 
00261   virtual void RotateCamera(int x, int y);
00262   virtual void SpinCamera(int x, int y);
00263   virtual void PanCamera(int x, int y);
00264   virtual void DollyCamera(int x, int y);
00265 
00266   // utility routines used by state changes below
00267   virtual void StartState(int newstate);
00268   virtual void StopState();
00269 
00270   // Interaction mode entry points used internally.  
00271   virtual void StartAnimate();  
00272   virtual void StopAnimate();  
00273   virtual void StartRotate();
00274   virtual void EndRotate();
00275   virtual void StartZoom();
00276   virtual void EndZoom();
00277   virtual void StartPan();
00278   virtual void EndPan();
00279   virtual void StartSpin();
00280   virtual void EndSpin();
00281   virtual void StartDolly();
00282   virtual void EndDolly();
00283   virtual void StartUniformScale();
00284   virtual void EndUniformScale();
00285   virtual void StartTimer();
00286   virtual void EndTimer();
00287 
00288   // Data we need to maintain internally
00289   vtkRenderWindowInteractor *Interactor;
00290   //
00291   vtkCamera          *CurrentCamera;
00292   vtkLight           *CurrentLight;
00293   vtkRenderer        *CurrentRenderer;
00294   //
00295   float Center[2];
00296   float DeltaAzimuth;
00297   float DeltaElevation;
00298   int   CtrlKey;
00299   int   ShiftKey;
00300   int   LastPos[2];
00301   int   State;  
00302   int   AnimState;  
00303   float FocalDepth;  
00304 
00305   // for picking and highlighting props
00306   vtkOutlineSource   *Outline;
00307   vtkPolyDataMapper  *OutlineMapper;
00308   vtkActor           *OutlineActor;
00309   vtkRenderer        *PickedRenderer;
00310   vtkProp            *CurrentProp;
00311   int                PropPicked;          // boolean: prop picked?
00312   float              PickColor[3];        // support 2D picking
00313   vtkActor2D         *PickedActor2D;
00314 
00315   unsigned long LeftButtonPressTag;
00316   unsigned long LeftButtonReleaseTag;
00317   unsigned long MiddleButtonPressTag;
00318   unsigned long MiddleButtonReleaseTag;
00319   unsigned long RightButtonPressTag;
00320   unsigned long RightButtonReleaseTag;
00321 private:
00322   vtkInteractorStyle(const vtkInteractorStyle&);  // Not implemented.
00323   void operator=(const vtkInteractorStyle&);  // Not implemented.
00324 };
00325 
00326 #endif

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