]> SALOME platform Git repositories - modules/gui.git/blob - src/GLViewer/GLViewer_BaseObjects.h
Salome HOME
c5dea1285da1f50059a0a865530847fd4a179734
[modules/gui.git] / src / GLViewer / GLViewer_BaseObjects.h
1 //  Copyright (C) 2005 OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
18 //
19 //  Author : OPEN CASCADE
20 //
21
22 // File:      GLViewer_BaseObjects.h
23 // Created:   November, 2004
24
25 #ifndef GLVIEWER_BASEOBJECTS_H
26 #define GLVIEWER_BASEOBJECTS_H
27
28 #include "GLViewer.h"
29 #include "GLViewer_Object.h"
30
31 #include <qcolor.h>
32 #include <qvaluelist.h>
33
34 #include <TColStd_SequenceOfInteger.hxx>
35
36 #ifdef WNT
37 #pragma warning( disable:4251 )
38 #endif
39
40 /*! 
41  \class GLViewer_MarkerSet
42  OpenGL MarkerSet
43 */
44 class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object
45 {
46 public:
47   //! A constructor
48   GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" );
49   //! A destructor
50   ~GLViewer_MarkerSet();
51
52   // redefined  methods
53   virtual void             compute();
54   virtual GLViewer_Drawer* createDrawer();
55   
56   virtual GLboolean        highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
57   virtual GLboolean        unhighlight();
58   virtual GLboolean        select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
59     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
60   virtual GLboolean        unselect();
61   
62   virtual GLViewer_Rect*   getUpdateRect();
63   
64   virtual void             moveObject( float, float, bool fromGroup = false );
65   
66   virtual QByteArray       getByteCopy();
67   virtual bool             initializeFromByteCopy( QByteArray );
68   
69   virtual bool             translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
70   virtual bool             translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
71   
72 #ifdef WIN32
73   virtual bool             translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
74 #endif
75
76   //! Sets array of x coords of markers
77   void                     setXCoord( GLfloat* xCoord, int size );
78   //! Sets array of y coords of markers
79   void                     setYCoord( GLfloat* yCoord, int size );
80   //! Returns x coords
81   GLfloat*                 getXCoord() const { return myXCoord; }
82   //! Returns y coords
83   GLfloat*                 getYCoord() const { return myYCoord; }
84   
85   //! Sets markers number
86   void                     setNumMarkers( GLint );
87   //! returns markers number
88   GLint                    getNumMarkers() const { return myNumber; };
89   //! Sets merker radius
90   void                     setMarkerSize( const float size ) { myMarkerSize = size; }
91   //! Returns merker radius
92   float                    getMarkerSize() const { return myMarkerSize; }
93   
94   //! Export numbers of heghlighted/selected markers
95   void                     exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
96                                           QValueList<int>& sel, QValueList<int>& unsel );
97   
98   //! Returns selected numbers
99   QValueList<int>          getSelectedElements() { return mySelNumbers; }
100   //! Adds or remove selected number
101   bool                     addOrRemoveSelected( int index );
102   //! Adds selected numbers
103   void                     addSelected( const TColStd_SequenceOfInteger& );
104   //! Sets selected nembers
105   void                     setSelected( const TColStd_SequenceOfInteger& );
106
107 protected:
108   GLint                   myNumber;
109   GLfloat*                myXCoord;
110   GLfloat*                myYCoord;    
111   GLfloat                 myMarkerSize;
112   QValueList<int>         myHNumbers;
113   QValueList<int>         myUHNumbers;
114   QValueList<int>         mySelNumbers;
115   QValueList<int>         myCurSelNumbers;
116   QValueList<int>         myUSelNumbers;
117   QValueList<int>         myPrevHNumbers;
118   TColStd_SequenceOfInteger mySelectedIndexes;
119 };
120
121 /*! 
122  \class  GLViewer_Polyline
123  OpenGL Polyline
124 */
125 class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object
126 {
127 public:
128   GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" );
129  ~GLViewer_Polyline();
130   
131   // redefined  methods
132   virtual void            compute();
133   virtual GLViewer_Drawer* createDrawer();
134   
135   virtual GLboolean       highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
136   virtual GLboolean       unhighlight();
137   virtual GLboolean       select( GLfloat x, GLfloat y, GLfloat tol,  GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
138     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
139   virtual GLboolean       unselect();
140   
141   virtual GLViewer_Rect*  getUpdateRect();
142   
143   virtual void            moveObject( float, float, bool fromGroup = false );
144   
145   virtual QByteArray      getByteCopy();
146   virtual bool            initializeFromByteCopy( QByteArray );
147   
148   virtual bool            translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
149   virtual bool            translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
150   
151 #ifdef WIN32
152   virtual bool            translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
153 #endif
154   
155   //! Sets array of x coords of points
156   void                     setXCoord( GLfloat* xCoord, int size );
157   //! Sets array of y coords of points
158   void                     setYCoord( GLfloat* yCoord, int size );
159   //! Returns x coords
160   GLfloat*                 getXCoord() const { return myXCoord; }
161   //! Returns y coords
162   GLfloat*                 getYCoord() const { return myYCoord; }
163
164   //! SetS number of points
165   void                    setNumber( GLint );
166   //! Returns number of points
167   GLint                   getNumber() const { return myNumber; };
168   
169   //! On/off closed status of polyline
170   void                    setClosed( GLboolean closed ) { myIsClosed = closed; }
171   //! Checks closed status of polyline
172   GLboolean               isClosed() const { return myIsClosed; }
173   
174   //! On/off highlight as whole object status
175   void                    setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; }
176   //! Checks highlight as whole object status
177   GLboolean               isHighSelAll() const { return myHighSelAll; }
178   
179   //! Export numbers of highlighted/selected lines
180   void                     exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
181                                           QValueList<int>& sel, QValueList<int>& unsel );
182
183   //! Returns numbers of selected lines
184   QValueList<int>         getSelectedElements() { return mySelNumbers; }
185
186 protected:
187   GLfloat*                myXCoord;
188   GLfloat*                myYCoord;
189   GLint                   myNumber;
190   GLboolean               myIsClosed;
191   GLboolean               myHighSelAll;
192   
193   QValueList<int>         myHNumbers;
194   QValueList<int>         myUHNumbers;
195   QValueList<int>         mySelNumbers;
196   QValueList<int>         myUSelNumbers;
197   QValueList<int>         myCurSelNumbers;
198   QValueList<int>         myPrevHNumbers;
199   TColStd_SequenceOfInteger mySelectedIndexes;
200   
201   GLboolean               myHighFlag;
202 };
203
204 /*!
205   \class GLViewer_TextObject
206   Text as Object for OpenGL
207 */
208 class GLVIEWER_API GLViewer_TextObject : public GLViewer_Object
209 {
210 public:  
211   GLViewer_TextObject( const QString&, float xPos = 0, float yPos = 0, 
212     const QColor& color = QColor( 0, 255, 0 ), const QString& toolTip = "GLText" );
213   ~GLViewer_TextObject();
214   
215   virtual void              compute();
216   virtual GLViewer_Drawer*  createDrawer();
217   
218   virtual void              setDrawer( GLViewer_Drawer* theDrawer );
219   
220   virtual GLboolean         highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE );
221   virtual GLboolean         unhighlight();
222   virtual GLboolean         select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
223     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
224   virtual GLboolean         unselect();
225   
226   virtual GLViewer_Rect*    getUpdateRect();
227   
228   virtual void              moveObject( float, float, bool fromGroup = false );
229   
230   virtual QByteArray        getByteCopy();
231   virtual bool              initializeFromByteCopy( QByteArray );
232   
233   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
234   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );  
235   
236 #ifdef WIN32
237   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
238 #endif
239   
240   int                       getWidth(){ return myWidth; }
241   int                       getHeight(){ return myWidth; }
242   void                      setWidth( int w ){ myWidth=w; }
243   void                      setHeight( int h ){ myHeight=h; }
244   
245 protected:
246   bool                      myHighFlag;
247   int                       myWidth;
248   int                       myHeight;
249 };
250
251 #ifdef WNT
252 #pragma warning ( default:4251 )
253 #endif
254
255 #endif