00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _CIvfMouseViewHandler_h_
00026 #define _CIvfMouseViewHandler_h_
00027
00028 #include <ivf/IvfBase.h>
00029 #include <ivf/IvfCamera.h>
00030
00031 #include <ivfwidget/IvfWidgetBase.h>
00032 #include <ivfwidget/IvfHandlerBase.h>
00033
00034 IvfSmartPointer(CIvfMouseViewHandler);
00035
00045 class IVFWIDGET_API CIvfMouseViewHandler : public CIvfHandlerBase,
00046 CIvfMouseDownEvent,
00047 CIvfMouseMoveEvent,
00048 CIvfMouseUpEvent,
00049 CIvfResizeEvent
00050 {
00051 public:
00052 enum TKeyHandling {
00053 KH_NORMAL,
00054 KH_MIDDLE_BUTTON
00055 };
00056 private:
00057 double m_angleX;
00058 double m_angleY;
00059 double m_moveX;
00060 double m_moveY;
00061 double m_zoomX;
00062 double m_zoomY;
00063
00064 int m_beginX;
00065 int m_beginY;
00066
00067 int m_width;
00068 int m_height;
00069
00070 double m_panScalefactor;
00071 double m_zoomScalefactor;
00072 double m_rotateScalefactor;
00073
00074 double m_autoScaleBias;
00075
00076 bool m_autoScale;
00077
00078 CIvfCameraPtr m_camera;
00079 CIvfWidgetBase* m_widget;
00080
00081 TKeyHandling m_keyHandling;
00082
00083 bool isPan();
00084 bool isZoom();
00085 bool isRotating();
00086 bool isZoomOrPan();
00087 void calcAutoScale();
00088 public:
00095 CIvfMouseViewHandler(CIvfWidgetBase* widget, CIvfCamera* camera);
00096
00098 virtual ~CIvfMouseViewHandler();
00099
00100 IvfClassInfo("CIvfMouseViewHandler",CIvfBase);
00101
00109 void setPanScalefactor(double factor);
00110
00112 double getPanScalefactor();
00113
00120 void setZoomScalefactor(double factor);
00121
00123 double getZoomScalefactor();
00124
00133 void setAutoScale(bool flag);
00134
00136 bool getAutoScale();
00137
00143 void setAutoScaleBias(double bias);
00144
00146 double getAutoScaleBias();
00147
00155 void setKeyHandling(TKeyHandling keyHandling);
00156
00158 TKeyHandling getKeyHandling();
00159
00160 virtual void doResize(int width, int height);
00161 virtual void doMouseDown(int x, int y);
00162 virtual void doMouseMove(int x, int y);
00163 virtual void doMouseUp(int x, int y);
00164
00165
00166
00167 virtual void onMouseDown(int x, int y);
00168 virtual void onMouseMove(int x, int y);
00169 virtual void onMouseUp(int x, int y);
00170 virtual void onResize(int width, int height);
00171
00172 };
00173
00174 #endif