MouseSelection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MOUSESELECTION_H
00025 #define MOUSESELECTION_H
00026
00027 #include <vector>
00028 #include <Inventor/SbLinear.h>
00029 #include <Inventor/SbVec2f.h>
00030
00031
00032 class QMouseEvent;
00033 class QWheelEvent;
00034 class QKeyEvent;
00035 class QPaintEvent;
00036 class QResizeEvent;
00037 class SoEvent;
00038 class SbViewportRegion;
00039 class SoMouseButtonEvent;
00040 class SoLocation2Event;
00041 class SoKeyboardEvent;
00042
00043 namespace Gui {
00044 class View3DInventorViewer;
00045
00053 class GuiExport AbstractMouseSelection
00054 {
00055 public:
00056 enum { Continue=0, Restart=1, Finish=2, Cancel=3 };
00057
00058 AbstractMouseSelection();
00059 virtual ~AbstractMouseSelection(void){}
00061 virtual void initialize() = 0;
00063 virtual void terminate () = 0;
00064 void grabMouseModel(Gui::View3DInventorViewer*);
00065 void releaseMouseModel(void);
00066 const std::vector<SbVec2s>& getPositions() const { return _clPoly; }
00067 SbBool isInner() const { return m_bInner; }
00068
00069 void redraw();
00070
00073 int handleEvent(const SoEvent * const ev, const SbViewportRegion& vp);
00075
00076 protected:
00077 virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos ){ return 0; };
00078 virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos ){ return 0; };
00079 virtual int keyboardEvent ( const SoKeyboardEvent * const e ) { return 0; };
00080
00082 virtual void draw (){};
00083
00084 protected:
00085 Gui::View3DInventorViewer*_pcView3D;
00086 QCursor m_cPrevCursor;
00087 int m_iXold, m_iYold;
00088 int m_iXnew, m_iYnew;
00089 SbBool m_bInner;
00090 SbBool mustRedraw;
00091
00092 private:
00093 std::vector<SbVec2s> _clPoly;
00094 };
00095
00096
00097
00102 class GuiExport BaseMouseSelection : public AbstractMouseSelection
00103 {
00104 public:
00105 BaseMouseSelection();
00106 virtual ~BaseMouseSelection(){}
00107 };
00108
00109
00110
00116 class GuiExport PolyPickerSelection : public BaseMouseSelection
00117 {
00118 public:
00119 PolyPickerSelection();
00120 virtual ~PolyPickerSelection();
00121
00123 virtual void initialize();
00125 virtual void terminate();
00126
00127 protected:
00128 virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
00129 virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos );
00130 virtual int keyboardEvent ( const SoKeyboardEvent * const e );
00131
00133 virtual void draw ();
00134 virtual int popupMenu();
00135
00136 protected:
00137 std::vector<QPoint> _cNodeVector;
00138 int m_iRadius, m_iNodes;
00139 bool m_bWorking;
00140 };
00141
00142
00143
00149 class GuiExport PolyClipSelection : public PolyPickerSelection
00150 {
00151 public:
00152 PolyClipSelection();
00153 virtual ~PolyClipSelection();
00154
00155 protected:
00156 virtual int popupMenu();
00157 };
00158
00159
00160
00166 class GuiExport RectangleSelection : public BaseMouseSelection
00167 {
00168 public:
00169 RectangleSelection();
00170 virtual ~RectangleSelection();
00171
00173 virtual void initialize();
00175 virtual void terminate();
00176
00177 protected:
00178 virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
00179 virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos );
00180 virtual int keyboardEvent ( const SoKeyboardEvent * const e );
00181
00183 virtual void draw ();
00184
00185 private:
00186 bool m_bWorking;
00187 };
00188
00189
00190
00196 class GuiExport BoxZoomSelection : public RectangleSelection
00197 {
00198 public:
00199 BoxZoomSelection();
00200 ~BoxZoomSelection();
00201 void terminate();
00202 };
00203
00204 }
00205
00206 #endif // MOUSESELECTION_H