1 // File: GLViewer_ViewPort2d.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 #ifndef GLVIEWER_VIEWPORT2D_H
7 #define GLVIEWER_VIEWPORT2D_H
16 #include "GLViewer_ViewPort.h"
17 #include "GLViewer_Widget.h"
18 #include "GLViewer_Geom.h"
23 #include <qpaintdevice.h>
26 #pragma warning( disable:4251 )
29 class GLViewer_Compass;
31 class GLViewer_Object;
32 class GLViewer_ViewFrame;
36 class GLViewer_ViewPort2d: public GLViewer_ViewPort
40 enum vpDragState{ noDrag, initDrag, inDrag };
43 GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
44 ~GLViewer_ViewPort2d();
46 void turnGrid( GLboolean on );
47 GLViewer_Grid* getGrid() const { return myGrid; }
48 void setGridColor( const QColor gridColor, const QColor axisColor );
50 GLViewer_ViewFrame* getViewFrame() const { return myViewFrame; }
51 GLViewer_Widget* getGLWidget() const { return myGLWidget; }
52 virtual QPaintDevice* getPaintDevice() { return myGLWidget; }
54 void setBackgroundColor( const QColor& color);
55 QColor backgroundColor() const;
57 void setBorder( GLViewer_Rect* border ) { myBorder = border; }
58 GLViewer_Rect* getBorder() const { return myBorder; }
60 void setMargin( GLfloat margin ) { myMargin = margin; }
61 GLfloat getMargin() const { return myMargin; }
63 int getHeight() const { return myHeight; }
64 int getWidth() const { return myWidth; }
66 void getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; }
67 void getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; }
69 void initResize( int, int );
71 void startRotation( int, int );
72 void rotate( int, int );
75 bool isDragProcess(){ return myIsDragProcess; }
77 void turnCompass( GLboolean on );
80 int getViewPortId(){ return myViewPortId; }
82 virtual BlockStatus currentBlock();
84 void startSelectByRect( int, int );
85 void drawSelectByRect( int, int );
86 void finishSelectByRect();
88 bool startPulling( GLViewer_Pnt );
89 void drawPulling( GLViewer_Pnt );
91 bool isPulling() const { return myIsPulling; }
94 QRect selectionRect();
96 GLViewer_Rect win2GLV( const QRect& ) const;
97 QRect GLV2win( const GLViewer_Rect& ) const;
100 void vpUpdateValues();
104 void onDragObject( QMouseEvent* );
106 virtual void mouseMoveEvent( QMouseEvent *);
107 virtual void mousePressEvent( QMouseEvent *);
108 virtual void mouseReleaseEvent( QMouseEvent *);
110 virtual void paintEvent( QPaintEvent* );
111 virtual void resizeEvent( QResizeEvent* );
113 virtual void reset();
114 virtual void pan( int, int );
115 virtual void setCenter( int, int );
116 virtual void zoom( int, int, int, int );
117 virtual void fitRect( const QRect& );
118 virtual void fitSelect();
119 virtual void fitAll( bool keepScale = false, bool withZ = true );
122 void onStartDragObject();
123 void onPasteObject();
127 void onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& );
130 GLViewer_ViewFrame* myViewFrame;
131 GLViewer_Widget* myGLWidget;
132 GLViewer_Rect* myBorder;
133 QColor myBackgroundColor;
146 GLViewer_Grid* myGrid;
147 GLViewer_Compass* myCompass;
151 float* myCurDragPosX;
152 float* myCurDragPosY;
155 QPoint* mypFirstPoint;
156 QPoint* mypLastPoint;
160 GLViewer_Object* myPullingObject;
164 //GLViewer_ObjectTip* myObjectTip;
165 QtxToolTip* myObjectTip;
169 #pragma warning ( default:4251 )