Salome HOME
53604863f9a6c1563f1339c8e97761c5e702bb92
[modules/gui.git] / src / GLViewer / GLViewer_BaseObjects.h
1 // File:      GLViewer_BaseObjects.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 #ifndef GLVIEWER_BASEOBJECTS_H
7 #define GLVIEWER_BASEOBJECTS_H
8
9 #include "GLViewer.h"
10 #include "GLViewer_Object.h"
11
12 #include <qcolor.h>
13 #include <qvaluelist.h>
14
15 #include <TColStd_SequenceOfInteger.hxx>
16
17 #ifdef WNT
18 #pragma warning( disable:4251 )
19 #endif
20
21 // Class:   GLViewer_MarkerSet
22 // Descr:   OpenGL MarkerSet
23
24 class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object
25 {
26 public:
27   GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" );
28   ~GLViewer_MarkerSet();
29   
30   virtual void            compute();
31   virtual GLViewer_Drawer* createDrawer();
32   
33   virtual GLboolean       highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
34   virtual GLboolean       unhighlight();
35   virtual GLboolean       select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
36     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
37   virtual GLboolean       unselect();
38   
39   virtual GLViewer_Rect*  getUpdateRect();
40   
41   void                    setXCoord( GLfloat* xCoord, int size );
42   void                    setYCoord( GLfloat* yCoord, int size );
43   GLfloat*                getXCoord() const { return myXCoord; }
44   GLfloat*                getYCoord() const { return myYCoord; }
45   void                    setNumMarkers( GLint );
46   GLint                   getNumMarkers() const { return myNumber; };
47   
48   void                    setMarkerSize( const float size ) { myMarkerSize = size; }
49   float                   getMarkerSize() const { return myMarkerSize; }
50   
51   void                    exportNumbers( QValueList<int>&, QValueList<int>& , QValueList<int>&, QValueList<int>& );
52   
53   QValueList<int>         getSelectedElements() { return mySelNumbers; }
54   bool                    addOrRemoveSelected( int index );
55   void                    addSelected( const TColStd_SequenceOfInteger& );
56   void                    setSelected( const TColStd_SequenceOfInteger& );
57   
58   virtual void            moveObject( float, float, bool fromGroup = false );
59   
60   virtual QByteArray      getByteCopy();
61   virtual bool            initializeFromByteCopy( QByteArray );
62   
63   virtual bool            translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
64   virtual bool            translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
65   
66 #ifdef WIN32
67   virtual bool            translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
68 #endif
69
70 protected:
71   GLint                   myNumber;
72   GLfloat*                myXCoord;
73   GLfloat*                myYCoord;    
74   GLfloat                 myMarkerSize;
75   QValueList<int>         myHNumbers;
76   QValueList<int>         myUHNumbers;
77   QValueList<int>         mySelNumbers;
78   QValueList<int>         myCurSelNumbers;
79   QValueList<int>         myUSelNumbers;
80   QValueList<int>         myPrevHNumbers;
81   TColStd_SequenceOfInteger mySelectedIndexes;
82 };
83
84 // Class:   GLViewer_Polyline
85 // Descr:   OpenGL Polyline
86
87 class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object
88 {
89 public:
90   GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" );
91   ~GLViewer_Polyline();
92   
93   virtual void            compute();
94   virtual GLViewer_Drawer* createDrawer();
95   
96   virtual GLboolean       highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
97   virtual GLboolean       unhighlight();
98   virtual GLboolean       select( GLfloat x, GLfloat y, GLfloat tol,  GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
99     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
100   virtual GLboolean       unselect();
101   
102   virtual GLViewer_Rect*  getUpdateRect();
103   
104   void                    setXCoord( GLfloat* xCoord, int size );
105   void                    setYCoord( GLfloat* yCoord, int size );
106   GLfloat*                getXCoord() const { return myXCoord; }
107   GLfloat*                getYCoord() const { return myYCoord; }
108   void                    setNumber( GLint );
109   GLint                   getNumber() const { return myNumber; };
110   
111   void                    setClosed( GLboolean closed ) { myIsClosed = closed; }
112   GLboolean               isClosed() const { return myIsClosed; }
113   
114   void                    setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; }
115   GLboolean               isHighSelAll() const { return myHighSelAll; }
116   
117   void                    exportNumbers( QValueList<int>&, QValueList<int>& , QValueList<int>&, QValueList<int>& );
118   
119   QValueList<int>         getSelectedElements() { return mySelNumbers; }
120   
121   virtual void            moveObject( float, float, bool fromGroup = false );
122   
123   virtual QByteArray      getByteCopy();
124   virtual bool            initializeFromByteCopy( QByteArray );
125   
126   virtual bool            translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
127   virtual bool            translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
128   
129 #ifdef WIN32
130   virtual bool            translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
131 #endif
132
133 protected:
134   GLfloat*                myXCoord;
135   GLfloat*                myYCoord;
136   GLint                   myNumber;
137   GLboolean               myIsClosed;
138   GLboolean               myHighSelAll;
139   
140   QValueList<int>         myHNumbers;
141   QValueList<int>         myUHNumbers;
142   QValueList<int>         mySelNumbers;
143   QValueList<int>         myUSelNumbers;
144   QValueList<int>         myCurSelNumbers;
145   QValueList<int>         myPrevHNumbers;
146   TColStd_SequenceOfInteger mySelectedIndexes;
147   
148   GLboolean               myHighFlag;
149 };
150
151 // Class:   GLViewer_TextObject
152 // Descr:   Text as Object for OpenGL
153
154 class GLVIEWER_API GLViewer_TextObject : public GLViewer_Object
155 {
156 public:  
157   GLViewer_TextObject( const QString&, float xPos = 0, float yPos = 0, 
158     const QColor& color = QColor( 0, 255, 0 ), const QString& toolTip = "GLText" );
159   ~GLViewer_TextObject();
160   
161   virtual void              compute();
162   virtual GLViewer_Drawer*  createDrawer();
163   
164   virtual void              setDrawer( GLViewer_Drawer* theDrawer );
165   
166   virtual GLboolean         highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE );
167   virtual GLboolean         unhighlight();
168   virtual GLboolean         select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
169     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
170   virtual GLboolean         unselect();
171   
172   virtual GLViewer_Rect*    getUpdateRect();
173   
174   virtual void              moveObject( float, float, bool fromGroup = false );
175   
176   virtual QByteArray        getByteCopy();
177   virtual bool              initializeFromByteCopy( QByteArray );
178   
179   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
180   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );  
181   
182 #ifdef WIN32
183   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
184 #endif
185   
186   int                       getWidth(){ return myWidth; }
187   int                       getHeight(){ return myWidth; }
188   void                      setWidth( int w ){ myWidth=w; }
189   void                      setHeight( int h ){ myHeight=h; }
190   
191 protected:
192   bool                      myHighFlag;
193   int                       myWidth;
194   int                       myHeight;
195 };
196
197 #ifdef WNT
198 #pragma warning ( default:4251 )
199 #endif
200
201 #endif