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

graphics/vtkInteractorStyleTrackball.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInteractorStyleTrackball.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 =========================================================================*/
00059 #ifndef __vtkInteractorStyleTrackball_h
00060 #define __vtkInteractorStyleTrackball_h
00061 
00062 #include "vtkInteractorStyle.h"
00063 #include "vtkAbstractPropPicker.h"
00064 
00065 #define VTKIS_JOY   0
00066 #define VTKIS_TRACK  1
00067 #define VTKIS_CAMERA 0
00068 #define VTKIS_ACTOR  1
00069 #define VTKIS_CONTROL_OFF 0
00070 #define VTKIS_CONTROL_ON 1
00071 
00072 class VTK_EXPORT vtkInteractorStyleTrackball : public vtkInteractorStyle 
00073 {
00074 public:
00075   static vtkInteractorStyleTrackball *New();
00076   vtkTypeMacro(vtkInteractorStyleTrackball,vtkInteractorStyle);
00077   void PrintSelf(ostream& os, vtkIndent indent);
00078   
00080   virtual   void OnRightButtonDown(int ctrl, int shift, int X, int Y);
00081   virtual   void OnRightButtonUp  (int ctrl, int shift, int X, int Y);
00082   virtual   void OnMiddleButtonDown(int ctrl, int shift, int X, int Y);
00083   virtual   void OnMiddleButtonUp  (int ctrl, int shift, int X, int Y);
00084   virtual   void OnLeftButtonDown(int ctrl, int shift, int X, int Y);
00085   virtual   void OnLeftButtonUp  (int ctrl, int shift, int X, int Y);
00086   virtual   void OnChar(int ctrl, int shift, char keycode, int repeatcount);
00087   
00089   virtual void SetActorModeToCamera();
00090   virtual void SetActorModeToActor();
00091   vtkGetMacro(ActorMode, int);
00092   
00094   virtual void SetTrackballModeToTrackball();
00095   virtual void SetTrackballModeToJoystick();
00096   vtkGetMacro(TrackballMode, int);
00097 
00100   virtual void OnTimer(void);
00101 
00102 protected:
00103   vtkInteractorStyleTrackball();
00104   ~vtkInteractorStyleTrackball();
00105   vtkInteractorStyleTrackball(const vtkInteractorStyleTrackball&) {};
00106   void operator=(const vtkInteractorStyleTrackball&) {};
00107 
00108   // used to track picked objects in actor mode
00109   // reason for existence: user may use any kind of picker.  Interactor
00110   //    need the high precision of cell picker at all time.
00111   vtkAbstractPropPicker *InteractionPicker;
00112   int PropPicked;                      // boolean: prop picked?
00113   vtkProp3D *InteractionProp;
00114   
00115   // new interactor modes
00116   int ActorMode;
00117   int TrackballMode;
00118   int ControlMode;
00119   float MotionFactor;                // constant: for motion
00120   int Preprocess;                       // boolean: was preprocessing done?
00121   float RadianToDegree;                 // constant: for conv from deg to rad
00122 
00123   // data arrays for motion
00124   float NewPickPoint[4];
00125   float OldPickPoint[4];
00126   float MotionVector[3];                // vector used for interaction
00127   float OldX;
00128   float OldY;
00129   
00130   // this really belong in camera
00131   double ViewLook[3];
00132   double ViewPoint[3];
00133   double ViewFocus[3];
00134   double ViewUp[3];
00135   double ViewRight[3];
00136 
00137   // actor stuff
00138   float Origin[3];
00139   float Position[3];
00140   float ObjCenter[3];                   // center of bounding box
00141   float DispObjCenter[3];               // center of box in display coord
00142   float Radius;                         // radius of virtual sphere
00143 
00144   // methods for the different interactions in different modes
00145   virtual void TrackballRotateCamera(int x, int y);
00146   virtual void TrackballSpinCamera(int x, int y);
00147   virtual void TrackballPanCamera(int x, int y);
00148   virtual void TrackballDollyCamera(int x, int y);
00149   
00150   virtual void JoystickRotateActor(int x, int y);
00151   virtual void JoystickSpinActor(int x, int y);
00152   virtual void JoystickPanActor(int x, int y);
00153   virtual void JoystickDollyActor(int x, int y);
00154   virtual void JoystickScaleActor(int x, int y);
00155   
00156   virtual void TrackballRotateActor(int x, int y);
00157   virtual void TrackballSpinActor(int x, int y);
00158   virtual void TrackballPanActor(int x, int y);
00159   virtual void TrackballDollyActor(int x, int y);
00160   virtual void TrackballScaleActor(int x, int y);
00161 
00162   void Prop3DTransform(vtkProp3D *prop3D, double *boxCenter,
00163                       int numRotation, double **rotate,
00164                       double *scale);
00165   void Prop3DTransform(vtkProp3D *prop3D,float *boxCenter,
00166                       int NumRotation,double **rotate,
00167                       double *scale);
00168   void FindPickedActor(int X, int Y);
00169 };
00170 
00171 #endif

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