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
00025
00026
00027 #ifndef GLVIEWER_VIEWPORT_H
00028 #define GLVIEWER_VIEWPORT_H
00029
00030 #include "GLViewer.h"
00031
00032
00033 #include <QColor>
00034
00035 #include <QWidget>
00036
00037
00038
00039 class QRect;
00040 class QCursor;
00041 class QPainter;
00042 class GLViewer_ViewSketcher;
00043 class GLViewer_ViewTransformer;
00044
00045 #ifdef WIN32
00046 #pragma warning( disable:4251 )
00047 #endif
00048
00049 enum BlockStatus
00050 {
00051 BS_NoBlock = 0x0000,
00052 BS_Highlighting = 0x0001,
00053 BS_Selection = 0x0002,
00054 BS_Dragging = 0x0004
00055 };
00056
00061 class GLVIEWER_API GLViewer_ViewPort: public QWidget
00062 {
00063 Q_OBJECT
00064 friend class GLViewer_ViewSketcher;
00065 friend class GLViewer_ViewTransformer;
00066
00067 public:
00068 GLViewer_ViewPort( QWidget* parent );
00069 ~GLViewer_ViewPort();
00070
00071 public:
00073 void setSketchingEnabled( bool );
00075 bool isSketchingEnabled() const;
00077 void setTransformEnabled( bool );
00079 bool isTransformEnabled() const;
00080
00082 virtual QColor backgroundColor() const;
00084 virtual void setBackgroundColor( const QColor& );
00085
00087 void redrawPainters();
00088
00090 virtual void onUpdate();
00091
00093 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
00094
00095 protected:
00096 enum ViewType { Type2D, Type3D };
00097 void selectVisualId( ViewType );
00098
00099 virtual QPaintDevice* getPaintDevice() { return this; }
00100 virtual void contextMenuEvent( QContextMenuEvent * e );
00101
00103 static void createCursors();
00104 static void destroyCursors();
00105 static QCursor* getHandCursor() { return handCursor; }
00106 static void setHandCursor( const QCursor& newCursor );
00107 static QCursor* getPanCursor() { return panCursor; }
00108 static void setPanCursor( const QCursor& newCursor );
00109 static QCursor* getPanglCursor() { return panglCursor; }
00110 static void setPanglCursor( const QCursor& newCursor );
00111 static QCursor* getZoomCursor() { return zoomCursor; }
00112 static void setZoomCursor( const QCursor& newCursor );
00113
00114 public:
00115 static QCursor* getDefaultCursor() { return defCursor; }
00116 static void setDefaultCursor( const QCursor& newCursor );
00117 static QCursor* getRotCursor() { return rotCursor; }
00118 static void setRotCursor( const QCursor& newCursor );
00119 static QCursor* getSketchCursor() { return sketchCursor; }
00120 static void setSketchCursor( const QCursor& newCursor );
00121
00122 protected:
00124 virtual void paintEvent( QPaintEvent *);
00125 virtual void mouseMoveEvent( QMouseEvent *);
00126 virtual void mouseReleaseEvent( QMouseEvent *);
00127 virtual void mousePressEvent( QMouseEvent *);
00128 virtual void mouseDoubleClickEvent( QMouseEvent *);
00129 virtual void keyPressEvent( QKeyEvent *);
00130 virtual void keyReleaseEvent( QKeyEvent *);
00131 virtual void wheelEvent( QWheelEvent *);
00132
00134 virtual void reset() = 0;
00135 virtual void pan( int, int ) = 0;
00136 virtual void setCenter( int, int ) = 0;
00137 virtual void zoom( int, int, int, int ) = 0;
00138 virtual void fitRect( const QRect& ) = 0;
00139 virtual void fitSelect() = 0;
00140 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
00141
00142 protected slots:
00143 virtual void onChangeBgColor();
00144
00145 signals:
00146 void vpKeyEvent( QKeyEvent* );
00147 void vpMouseEvent( QMouseEvent* );
00148 void vpWheelEvent( QWheelEvent* );
00149 void vpDrawExternal( QPainter* );
00150
00151 void contextMenuRequested( QContextMenuEvent* );
00152
00153 private:
00154 void initialize();
00155 void cleanup();
00156
00157 protected:
00158
00159 bool myEnableSketching;
00160 bool myEnableTransform;
00161 bool myPaintersRedrawing;
00162
00163
00164 private:
00165 static int nCounter;
00166 static QCursor* defCursor;
00167 static QCursor* panglCursor;
00168 static QCursor* handCursor;
00169 static QCursor* panCursor;
00170 static QCursor* zoomCursor;
00171 static QCursor* rotCursor;
00172 static QCursor* sketchCursor;
00173 };
00174
00175 #ifdef WIN32
00176 #pragma warning ( default:4251 )
00177 #endif
00178
00179 #endif