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_VIEWPORT2D_H
00028 #define GLVIEWER_VIEWPORT2D_H
00029
00030 #ifdef WIN32
00031 #include <windows.h>
00032 #endif
00033
00034 #include <GL/gl.h>
00035 #include <GL/glu.h>
00036
00037 #include "GLViewer_ViewPort.h"
00038 #include "GLViewer_Widget.h"
00039 #include "GLViewer_Geom.h"
00040
00041 #include <QtOpenGL>
00042 #include <QColor>
00043 #include <QPaintDevice>
00044
00045 #ifdef WIN32
00046 #pragma warning( disable:4251 )
00047 #endif
00048
00049 class GLViewer_Compass;
00050 class GLViewer_Grid;
00051 class GLViewer_Object;
00052 class GLViewer_ViewFrame;
00053
00054 class QtxToolTip;
00055
00056 class QWidget;
00057 class QRubberBand;
00058
00063 class GLViewer_ViewPort2d: public GLViewer_ViewPort
00064 {
00065 Q_OBJECT
00066
00068 enum vpDragState{ noDrag, initDrag, inDrag };
00069
00070 public:
00071 GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
00072 ~GLViewer_ViewPort2d();
00073
00075 void turnGrid( GLboolean on );
00077 GLViewer_Grid* getGrid() const { return myGrid; }
00079 void setGridColor( const QColor gridColor, const QColor axisColor );
00080
00082 GLViewer_ViewFrame* getViewFrame() const { return myViewFrame; }
00084 GLViewer_Widget* getGLWidget() const { return myGLWidget; }
00085 virtual QPaintDevice* getPaintDevice() { return myGLWidget; }
00086
00088 void setBackgroundColor( const QColor& color);
00090 QColor backgroundColor() const;
00091
00093 void setBorder( GLViewer_Rect* border ) { myBorder = border; }
00095 GLViewer_Rect* getBorder() const { return myBorder; }
00096
00098 void setMargin( GLfloat margin ) { myMargin = margin; }
00100 GLfloat getMargin() const { return myMargin; }
00101
00103 int getWidth() const { return myWidth; }
00105 int getHeight() const { return myHeight; }
00106
00107
00109 void getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; }
00111 void getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; }
00112
00114 void initResize( int width, int height );
00115
00117 void startRotation( int, int );
00119 void rotate( int, int );
00121 void endRotation();
00122
00124 bool isDragProcess(){ return myIsDragProcess; }
00125
00127 void turnCompass( GLboolean on );
00129 void drawCompass();
00130
00132 int getViewPortId(){ return myViewPortId; }
00133
00135 virtual BlockStatus currentBlock();
00136
00138 void startSelectByRect( int x, int y );
00140 void drawSelectByRect( int x, int y );
00142 void finishSelectByRect();
00143
00145 bool startPulling( GLViewer_Pnt );
00147 void drawPulling( GLViewer_Pnt );
00149 void finishPulling();
00151 bool isPulling() const { return myIsPulling; }
00152
00154 QRect selectionRect();
00155
00157 GLViewer_Rect win2GLV( const QRect& ) const;
00159 QRect GLV2win( const GLViewer_Rect& ) const;
00160
00161 signals:
00163 void vpUpdateValues();
00164
00165 void objectMoved();
00166
00167 protected:
00168 void onDragObject( QMouseEvent* );
00169
00170 virtual void mouseMoveEvent( QMouseEvent *);
00171 virtual void mousePressEvent( QMouseEvent *);
00172 virtual void mouseReleaseEvent( QMouseEvent *);
00173 virtual void mouseDoubleClickEvent( QMouseEvent *);
00174
00175 virtual void paintEvent( QPaintEvent* );
00176 virtual void resizeEvent( QResizeEvent* );
00177
00179 virtual void reset();
00181 virtual void pan( int dx, int dy );
00183 virtual void setCenter( int x, int y );
00185 virtual void zoom( int x0, int y0, int x1, int y1 );
00187 virtual void fitRect( const QRect& );
00189 virtual void fitSelect();
00191 virtual void fitAll( bool keepScale = false, bool withZ = true );
00192
00193 protected slots:
00195 void onStartDragObject();
00197 void onPasteObject();
00199 void onCutObject();
00201 void onCopyObject();
00202
00204 void onMaybeTip( QPoint thePoint, QString& text, QFont& font, QRect& theTextReg, QRect& theViewReg );
00205
00206 protected:
00207 GLViewer_ViewFrame* myViewFrame;
00208 GLViewer_Widget* myGLWidget;
00209 GLViewer_Rect* myBorder;
00210 QColor myBackgroundColor;
00211
00212 GLfloat myMargin;
00213 int myHeight;
00214 int myWidth;
00215
00216 GLfloat myXScale;
00217 GLfloat myYScale;
00218 GLfloat myXOldScale;
00219 GLfloat myYOldScale;
00220 GLfloat myXPan;
00221 GLfloat myYPan;
00222
00223 GLViewer_Grid* myGrid;
00224 GLViewer_Compass* myCompass;
00225
00226
00227 int myIsDragProcess;
00228 float* myCurDragPosX;
00229 float* myCurDragPosY;
00230
00231
00232 QPoint* mypFirstPoint;
00233 QPoint* mypLastPoint;
00234
00235
00236 bool myIsPulling;
00237 GLViewer_Object* myPullingObject;
00238
00239 int myViewPortId;
00240
00241
00242 QtxToolTip* myObjectTip;
00244 bool myIsMouseReleaseBlock;
00245
00246 QRubberBand* myRectBand;
00247 };
00248
00249 #ifdef WIN32
00250 #pragma warning ( default:4251 )
00251 #endif
00252
00253 #endif