IvfMouseViewHandler.h

00001 //
00002 // Copyright 1999-2006 by Structural Mechanics, Lund University.
00003 //
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Library General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later version.
00008 //
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Library General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Library General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017 // USA.
00018 //
00019 // Please report all bugs and problems to "ivf@byggmek.lth.se".
00020 //
00021 //
00022 // Written by Jonas Lindemann
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         // Implemented events
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

Generated on Fri Sep 1 15:36:47 2006 for Interactive Visualisation Framework - Ivf++ by  doxygen 1.4.6-NO