IvfCoordinateInputHandler.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 _CIvfCoordinateInputHandler_h_
00026 #define _CIvfCoordinateInputHandler_h_
00027 
00028 #include <ivfwidget/IvfHandlerBase.h>
00029 #include <ivfwidget/IvfWidgetBase.h>
00030 
00031 #include <ivf/IvfScene.h>
00032 
00033 #include <ivfmath/IvfUcs3d.h>
00034 
00038 class IVFWIDGET_API CIvfMouseDown3dEvent : public CIvfEventBase 
00039 {
00040 public:
00049         virtual void onMouseDown3d(double x, double y, double z) {};
00050 };
00051 
00055 class IVFWIDGET_API CIvfMouseMove3dEvent : public CIvfEventBase 
00056 {
00057 public:
00066         virtual void onMouseMove3d(double x, double y, double z) {};
00067 };
00068 
00072 class IVFWIDGET_API CIvfMouseUp3dEvent : public CIvfEventBase 
00073 {
00074 public:
00083         virtual void onMouseUp3d(double x, double y, double z) {};
00084 };
00085 
00086 IvfSmartPointer(CIvfCoordinateInputHandler);
00087 
00098 class IVFWIDGET_API CIvfCoordinateInputHandler : public CIvfHandlerBase,
00099         CIvfMouseMoveEvent,
00100         CIvfMouseDownEvent,
00101         CIvfMouseUpEvent 
00102 {
00103 private:
00104         CIvfWidgetBase*         m_widget;
00105         CIvfCameraPtr           m_camera;
00106         CIvfUcs3dPtr            m_ucsXZ;
00107         CIvfUcs3dPtr            m_ucsXY;
00108         CIvfUcs3dPtr            m_ucsYZ;
00109         CIvfVec3d                       m_intersection;
00110         CIvfVec3d                       m_xzIntersection;
00111         CIvfVec3d                       m_temp;
00112 
00113         bool                            m_lockXZ;
00114         bool                            m_snap;
00115 
00116         int                                     m_mousePos[2];
00117 
00118         std::vector<CIvfMouseDown3dEvent*> m_mouseDown3dEvents;
00119         std::vector<CIvfMouseMove3dEvent*> m_mouseMove3dEvents;
00120         std::vector<CIvfMouseUp3dEvent*> m_mouseUp3dEvents;
00121 
00122         CIvfVec3d& calcIntersection(int x, int y);
00123         void dispatchMouseDown3dEvent(double x, double y, double z);
00124         void dispatchMouseMove3dEvent(double x, double y, double z);
00125         void dispatchMouseUp3dEvent(double x, double y, double z);
00126 
00127         void doMouseUp(int x, int y);
00128         void doMouseMove(int x, int y);
00129         void doMouseDown(int x, int y);
00130         virtual void doLockXZ(bool flag);
00131 public:
00140         CIvfCoordinateInputHandler(CIvfWidgetBase* widget, CIvfCamera* camera);
00141 
00143         virtual ~CIvfCoordinateInputHandler();
00144 
00145         IvfClassInfo("CIvfCoordinateInputHandler",CIvfHandlerBase);
00146 
00148         void setLockXZNoEvent(bool flag);
00149 
00151         void setPlanePosition(double x, double y, double z);
00152 
00154         void setPlanePosition(CIvfVec3d& vec);
00155 
00157         void addMouseDown3dEvent(CIvfMouseDown3dEvent* event);
00158 
00160         void addMouseMove3dEvent(CIvfMouseMove3dEvent* event);
00161 
00163         void addMouseUp3dEvent(CIvfMouseUp3dEvent* event);
00164 
00166         void removeMouseDown3dEvent(CIvfMouseDown3dEvent* event);
00167 
00169         void removeMouseMove3dEvent(CIvfMouseMove3dEvent* event);
00170 
00172         void removeMouseUp3dEvent(CIvfMouseUp3dEvent* event);
00173 
00175         void setLockXZ(bool flag);
00176 
00178         bool getLockXZ();
00179 
00181         CIvfCamera* getCamera();
00182 
00184         CIvfWidgetBase* getWidget();
00185 
00186         virtual void onMouseDown(int x, int y);
00187         virtual void onMouseMove(int x, int y);
00188         virtual void onMouseUp(int x, int y);
00189 };
00194 #endif

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