MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoView2D/extensions/SoView2DTransRot.h
Go to the documentation of this file.
00001 #ifndef __SoView2DTransRot_H
00002 #define __SoView2DTransRot_H
00003 //----------------------------------------------------------------------------------
00004 // **InsertLicense** code
00005 //----------------------------------------------------------------------------------
00007 
00013 //----------------------------------------------------------------------------------
00014 
00015 #ifndef __SoView2DExtension_H
00016 #include "SoView2DExtension.h"
00017 #endif
00018 
00019 #include <Inventor/fields/SoSFRotation.h>
00020 #include <Inventor/fields/SoSFFloat.h>
00021 #include <Inventor/fields/SoSFVec3f.h>
00022 #include <Inventor/projectors/SbSphereSheetProjector.h>
00023 
00024 class SoView2D;
00025 
00028 class SOVIEW2D_API SoView2DTransRot : public SoView2DExtension {
00029 
00030   SO_NODE_HEADER(SoView2DTransRot);
00031 
00032 public:
00034     SoSFEnum  mouseFunctionButton1;
00035     SoSFEnum  mouseFunctionButton2;
00036     SoSFEnum  mouseFunctionButton1and2;
00037 
00039     SoSFEnum  mouseFunctionWheel;  // mouse wheel is handled like a key pair
00040     SoSFEnum  keyFunctionHoriCursor;
00041     SoSFEnum  keyFunctionVertCursor;
00042     SoSFEnum  keyFunctionPageKeys;
00043 
00045     SoSFBool  adaptCursorShape;
00046 
00048   SoSFRotation    rotation;
00050   SoSFVec3f       translation;
00051 
00053   SoSFFloat       fieldOfView;
00054 
00056   static void   initClass();
00057 
00059   SoView2DTransRot();
00060 
00062   virtual bool   evalEvent(SoView2D* view2d, View2DSliceList* slicelist,
00063                            View2DEvent* ec, View2DEventPhase phase);
00064 
00065 private:
00068     void doMouseFunction (int function, View2DSliceList* slicelist, View2DEvent* ec);
00069 
00070     void rotate      (View2DSliceList* slicelist, const SbVec2f& relMousePos,
00071                       float sensitivity);
00072     void rotateXAxis (View2DSliceList* slicelist,const SbVec2f& newMousePos,
00073                      const SbVec2f& deviceSize, float sensitivity);
00074     void rotateYAxis (View2DSliceList* slicelist, const SbVec2f& newMousePos,
00075                      const SbVec2f& deviceSize, float sensitivity);
00076     void rotateZAxis (View2DSliceList* slicelist, const SbVec2f& relMousePos,
00077                       float sensitivity);
00078     void pan         (View2DSliceList* slicelist, const SbVec2f& newMousePos,
00079                       float sensitivity);
00080     void slice       (View2DSliceList* slicelist, const SbVec2f& newMousePos,
00081                       float sensitivity);
00082     void zoom        (View2DSliceList* slicelist, const SbVec2f& newMousePos,
00083                       const SbVec2f& deviceSize, float sensitivity);
00084 
00087     virtual int getSuitableCursorShape (int function);
00088 
00092     void doStepFunction (int function, View2DSliceList* slicelist, bool up, bool shift);
00093 
00094     void panXStep   (View2DSliceList* slicelist, float step);
00095     void panYStep   (View2DSliceList* slicelist, float step);
00096     void sliceStep  (View2DSliceList* slicelist, float step);
00097     void rotXStep   (View2DSliceList* slicelist, float step);
00098     void rotYStep   (View2DSliceList* slicelist, float step);
00099     void rotZStep   (View2DSliceList* slicelist, float step);
00100     void zoomStep   (float offset);
00101 
00102 private:
00104   SbSphereSheetProjector spinprojector;
00106   SbVec2f                lastMousePos;
00108   SbVec2f                deviceOrigin, deviceSize;
00111   bool                   mouseDown;
00113   bool                   onImage;
00114   
00116   unsigned               _prevWheelCode;
00118   int                    _sumWheel;
00119 };
00120 
00121 #endif