IvfShapePlacementHandler.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 _CIvfShapePlacementHandler_h_
00026 #define _CIvfShapePlacementHandler_h_
00027 
00028 #include <ivfwidget/IvfCoordinateInputHandler.h>
00029 
00030 #include <ivf/IvfShapeSelection.h>
00031 #include <ivf/IvfNodeCursor.h>
00032 #include <ivf/IvfRuler.h>
00033 
00035 class IVFWIDGET_API CIvfCreateShapeEvent : public CIvfEventBase {
00036 public:
00037         virtual void onCreateShapeEvent(double x, double y, double z, CIvfShapePtr& shape) {};
00038 };
00039 
00041 class IVFWIDGET_API CIvfMoveSelectionEvent : public CIvfEventBase {
00042 public:
00043         virtual bool onMoveSelection() {return true;};
00044 };
00045 
00047 class IVFWIDGET_API CIvfFinishMoveEvent : public CIvfEventBase {
00048 public:
00049         virtual void onFinishMove() {};
00050 };
00051 
00053 class IVFWIDGET_API CIvfCopyShapeEvent : public CIvfEventBase {
00054 public:
00055         virtual void onCopyShape(double x, double y, double z, CIvfShapePtr& shape, CIvfShapePtr& newShape) {};
00056 };
00057 
00059 class IVFWIDGET_API CIvfFinishCopyEvent : public CIvfEventBase {
00060 public:
00061         virtual void onFinishCopy() {};
00062 };
00063 
00065 class IVFWIDGET_API CIvfCursorUpdateEvent : public CIvfEventBase {
00066 public:
00067         virtual void onCursorUpdate() {};
00068 };
00069 
00070 IvfSmartPointer(CIvfShapePlacementHandler);
00071 
00077 class IVFWIDGET_API CIvfShapePlacementHandler : public CIvfCoordinateInputHandler,
00078         CIvfMouseDown3dEvent,
00079         CIvfMouseMove3dEvent,
00080         CIvfMouseUp3dEvent
00081 {
00082 public:
00083         enum TInputMethod {
00084                 IM_TWO_CLICK,
00085                 IM_CLICK_MODIFIER
00086         };
00087         enum TOperatingMode {
00088                 OM_CREATE_SHAPE,
00089                 OM_MOVE_SHAPE,
00090                 OM_COPY_SHAPE
00091         };
00092 private:
00093         CIvfNodeCursorPtr                               m_cursor;
00094         CIvfRulerPtr                                    m_ruler;
00095         CIvfScenePtr                                    m_scene;
00096         CIvfCompositePtr                                m_composite;
00097 
00098         CIvfShapePtr                                    m_shapeRepresentation;
00099         CIvfShapePtr                                    m_moveShape;
00100 
00101         TInputMethod                                    m_inputMethod;
00102         TOperatingMode                                  m_operatingMode;
00103 
00104         int                                                             m_clickCount;
00105 
00106         CIvfCreateShapeEvent*                   m_createShapeEvent;
00107         CIvfMoveSelectionEvent*                 m_moveSelectionEvent;
00108         CIvfCopyShapeEvent*                             m_copyShapeEvent;
00109         CIvfFinishCopyEvent*                    m_finishCopyEvent;
00110         CIvfFinishMoveEvent*                    m_finishMoveEvent;
00111         CIvfCursorUpdateEvent*                  m_cursorUpdateEvent;
00112 
00113         bool                                                    m_lastButtonLeft;
00114 
00115         CIvfVec3d                                               m_startPoint;
00116         CIvfVec3d                                               m_currentPoint;
00117         CIvfVec3d                                               m_endPoint;
00118         CIvfVec3d                                               m_moveDelta;
00119 
00120         CIvfShapeSelectionPtr                   m_shapeSelection;
00121 
00122         bool                                                    m_moving;
00123         bool                                                    m_moveDone;
00124 
00125 public:
00126         void reset();
00127         CIvfShapePlacementHandler(CIvfWidgetBase* widget, CIvfCamera* camera, CIvfScene* scene, CIvfComposite* composite);
00128         virtual ~CIvfShapePlacementHandler();
00129 
00130         IvfClassInfo("CIvfShapePlacementHandler",CIvfCoordinateInputHandler);
00131 
00132         void setShapeRepresentation(CIvfShape* shape);
00133 
00134         void setInputMethod(TInputMethod method);
00135         TInputMethod getInputMethod();
00136 
00137         CIvfNodeCursor* getCursor();
00138 
00139         void setCreateShapeEvent(CIvfCreateShapeEvent* event);
00140         void setMoveSelectionEvent(CIvfMoveSelectionEvent* event);
00141         void setCursorUpdateEvent(CIvfCursorUpdateEvent* event);
00142         void setFinishMoveEvent(CIvfFinishMoveEvent* event);
00143         void setFinishCopyEvent(CIvfFinishCopyEvent* event);
00144         void setCopyShapeEvent(CIvfCopyShapeEvent* event);
00145 
00146         void setMoveShape(CIvfShape* shape);
00147 
00148         TOperatingMode getOperatingMode();
00149         void setOperatingMode(TOperatingMode mode);
00150 
00151         void initiateMove(CIvfVec3d& vec);
00152         void initiateMove(double x, double y, double z);
00153         void setShapeSelection(CIvfShapeSelection* shapeSelection);
00154         bool isMoving();
00155         void finalizeMove();
00156 
00157         virtual void doLockXZ(bool flag);
00158         virtual void doDeactivate();
00159         virtual void doActivate();
00160 
00161         virtual void onMouseDown3d(double x, double y, double z);
00162         virtual void onMouseMove3d(double x, double y, double z);
00163         virtual void onMouseUp3d(double x, double y, double z);
00164 };
00165 
00166 #endif 

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