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 #ifndef OCCVIEWER_VIEWSKETCHER_H
00021 #define OCCVIEWER_VIEWSKETCHER_H
00022
00023 #include "OCCViewer.h"
00024
00025 #include <QObject>
00026 #include <QCursor>
00027 #include <QSize>
00028
00029 class OCCViewer_ViewWindow;
00030 class QKeyEvent;
00031 class QMouseEvent;
00032 class QPolygon;
00033
00034 class QtxRectRubberBand;
00035 class QtxPolyRubberBand;
00036
00037 #ifdef WNT
00038 #pragma warning ( disable:4251 )
00039 #endif
00040
00045 class OCCVIEWER_EXPORT OCCViewer_ViewSketcher : public QObject
00046 {
00047 Q_OBJECT
00048
00049 public:
00050 enum { Neutral, Accept, Reject };
00051
00052 public:
00053 OCCViewer_ViewSketcher( OCCViewer_ViewWindow*, int );
00054 virtual ~OCCViewer_ViewSketcher();
00055
00056 public:
00057 int type() const;
00058 int result() const;
00059 int buttonState() const;
00060 void* data() const;
00061
00062 void activate();
00063 void deactivate();
00064
00065 int sketchButton();
00066 void setSketchButton( int );
00067
00068 virtual bool isDefault() const;
00069 virtual bool eventFilter( QObject*, QEvent* );
00070
00071 private slots:
00072 void onDrawViewPort();
00073
00074 protected:
00075 enum SketchState { Debut, EnTrain, Fin };
00076 virtual bool onKey( QKeyEvent* );
00077 virtual void onMouse( QMouseEvent* );
00078 virtual void onSketch( SketchState ) = 0;
00079 virtual void onActivate();
00080 virtual void onDeactivate();
00081
00082 protected:
00083 int mySketchButton;
00084 OCCViewer_ViewWindow* mypViewWindow;
00085 int myType;
00086 void* mypData;
00087 int myResult;
00088 QCursor mySavedCursor;
00089 QPoint myStart, myCurr;
00090 int myButtonState;
00091 };
00092
00097 class OCCVIEWER_EXPORT OCCViewer_RectSketcher : public OCCViewer_ViewSketcher
00098 {
00099 public:
00100 OCCViewer_RectSketcher( OCCViewer_ViewWindow*, int );
00101 virtual ~OCCViewer_RectSketcher();
00102
00103 protected:
00104 virtual bool onKey( QKeyEvent* );
00105 virtual void onMouse( QMouseEvent* );
00106 virtual void onSketch( SketchState );
00107 virtual void onActivate();
00108 virtual void onDeactivate();
00109 private:
00110 QtxRectRubberBand* mypRectRB;
00111 };
00112
00117 class OCCVIEWER_EXPORT OCCViewer_PolygonSketcher : public OCCViewer_ViewSketcher
00118 {
00119 public:
00120 OCCViewer_PolygonSketcher( OCCViewer_ViewWindow*, int );
00121 virtual ~OCCViewer_PolygonSketcher();
00122
00123 protected:
00124 virtual bool onKey( QKeyEvent* );
00125 virtual void onMouse( QMouseEvent* );
00126 virtual void onSketch( SketchState );
00127 virtual void onActivate();
00128 virtual void onDeactivate();
00129
00130 private:
00131 bool isValid( const QPolygon*, const QPoint& ) const;
00132 bool isIntersect( const QPoint&, const QPoint&,
00133 const QPoint&, const QPoint& ) const;
00134
00135 private:
00136 bool myDbl;
00137 QSize myToler;
00138 QPolygon* mypPoints;
00139 int myAddButton;
00140 int myDelButton;
00141
00142 QtxPolyRubberBand* mypPolyRB;
00143 };
00144
00145 #ifdef WNT
00146 #pragma warning( default:4251 )
00147 #endif
00148
00149 #endif