]> SALOME platform Git repositories - modules/gui.git/blob - src/GLViewer/GLViewer_ViewPort2d.h
Salome HOME
*** empty log message ***
[modules/gui.git] / src / GLViewer / GLViewer_ViewPort2d.h
1 // File:      GLViewer_ViewPort2d.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 #ifndef GLVIEWER_VIEWPORT2D_H
7 #define GLVIEWER_VIEWPORT2D_H
8
9 #ifdef WNT
10 #include <windows.h>
11 #endif
12
13 #include <GL/gl.h>
14 #include <GL/glu.h>
15
16 #include "GLViewer_ViewPort.h"
17 #include "GLViewer_Widget.h"
18 #include "GLViewer_Geom.h"
19
20 #include <qgl.h>
21 #include <qcolor.h>
22 #include <qwidget.h>
23 #include <qpaintdevice.h>
24
25 #ifdef WNT
26 #pragma warning( disable:4251 )
27 #endif
28
29 class GLViewer_Compass;
30 class GLViewer_Grid;
31 class GLViewer_Object;
32 class GLViewer_ViewFrame;
33
34 class QtxToolTip;
35
36 class GLViewer_ViewPort2d: public GLViewer_ViewPort
37 {
38   Q_OBJECT
39
40       enum vpDragState{ noDrag, initDrag, inDrag };
41
42 public:
43     GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
44     ~GLViewer_ViewPort2d();
45
46     void                   turnGrid( GLboolean on );
47     GLViewer_Grid*         getGrid() const { return myGrid; }
48     void                   setGridColor( const QColor gridColor, const QColor axisColor );
49
50     GLViewer_ViewFrame*    getViewFrame() const { return myViewFrame; }
51     GLViewer_Widget*       getGLWidget() const { return myGLWidget; }
52     virtual QPaintDevice*  getPaintDevice() { return myGLWidget; }
53
54     void                   setBackgroundColor( const QColor& color);
55     QColor                 backgroundColor() const;
56
57     void                   setBorder( GLViewer_Rect* border ) { myBorder = border; }
58     GLViewer_Rect*         getBorder() const { return myBorder; }
59
60     void                   setMargin( GLfloat margin ) { myMargin = margin; }
61     GLfloat                getMargin() const { return myMargin; }
62
63     int                    getHeight() const { return myHeight; }
64     int                    getWidth() const { return myWidth; }
65
66     void                   getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; }
67     void                   getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; }
68
69     void                   initResize( int, int );
70
71     void                   startRotation( int, int );
72     void                   rotate( int, int );
73     void                   endRotation();
74
75     bool                   isDragProcess(){ return myIsDragProcess; }
76
77     void                   turnCompass( GLboolean on );
78     void                   drawCompass();
79
80     int                    getViewPortId(){ return myViewPortId; }
81
82     virtual BlockStatus    currentBlock();
83
84     void                   startSelectByRect( int, int );
85     void                   drawSelectByRect( int, int );
86     void                   finishSelectByRect();
87
88     bool                   startPulling( GLViewer_Pnt );
89     void                   drawPulling( GLViewer_Pnt );
90     void                   finishPulling();
91     bool                   isPulling() const { return myIsPulling; }
92
93     //selection by rect
94     QRect                  selectionRect();
95     
96     GLViewer_Rect          win2GLV( const QRect& ) const;
97     QRect                  GLV2win( const GLViewer_Rect& ) const;
98
99 signals:
100     void                   vpUpdateValues();
101     void                   objectMoved();
102
103 protected:
104     void                   onDragObject( QMouseEvent* );
105     
106     virtual void           mouseMoveEvent( QMouseEvent *);
107     virtual void           mousePressEvent( QMouseEvent *);
108     virtual void           mouseReleaseEvent( QMouseEvent *);
109
110     virtual void           paintEvent( QPaintEvent* );
111     virtual void           resizeEvent( QResizeEvent* );
112
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 );
120
121 protected slots:
122     void                   onStartDragObject();
123     void                   onPasteObject();
124     void                   onCutObject();
125     void                   onCopyObject();
126
127     void                   onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& );
128
129 protected:
130     GLViewer_ViewFrame*    myViewFrame;
131     GLViewer_Widget*       myGLWidget;
132     GLViewer_Rect*         myBorder;
133     QColor                 myBackgroundColor;
134
135     GLfloat                myMargin;
136     int                    myHeight;
137     int                    myWidth;
138
139     GLfloat                myXScale;
140     GLfloat                myYScale;
141     GLfloat                myXOldScale;
142     GLfloat                myYOldScale;
143     GLfloat                myXPan;
144     GLfloat                myYPan;
145
146     GLViewer_Grid*         myGrid; 
147     GLViewer_Compass*      myCompass;
148
149     //dragging
150     int                    myIsDragProcess;
151     float*                 myCurDragPosX;
152     float*                 myCurDragPosY;
153
154     //selection by rect
155     QPoint*                mypFirstPoint;
156     QPoint*                mypLastPoint;
157
158     //pulling
159     bool                   myIsPulling;
160     GLViewer_Object*       myPullingObject;
161     
162     int                    myViewPortId;
163
164     //GLViewer_ObjectTip*    myObjectTip;
165     QtxToolTip*            myObjectTip;
166 };
167
168 #ifdef WNT
169 #pragma warning ( default:4251 )
170 #endif
171
172 #endif