Salome HOME
PAL10125 - by double click on reference original object becomes selected
[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 /*! 
22  * Class GLViewer_MarkerSet
23  * OpenGL MarkerSet
24  */
25
26 class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object
27 {
28 public:
29   //! A constructor
30   GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" );
31   //! A destructor
32   ~GLViewer_MarkerSet();
33
34   // redefined  methods
35   virtual void             compute();
36   virtual GLViewer_Drawer* createDrawer();
37   
38   virtual GLboolean        highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
39   virtual GLboolean        unhighlight();
40   virtual GLboolean        select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
41     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
42   virtual GLboolean        unselect();
43   
44   virtual GLViewer_Rect*   getUpdateRect();
45   
46   virtual void             moveObject( float, float, bool fromGroup = false );
47   
48   virtual QByteArray       getByteCopy();
49   virtual bool             initializeFromByteCopy( QByteArray );
50   
51   virtual bool             translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
52   virtual bool             translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
53   
54 #ifdef WIN32
55   virtual bool             translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
56 #endif
57
58   //! Sets array of x coords of markers
59   void                     setXCoord( GLfloat* xCoord, int size );
60   //! Sets array of y coords of markers
61   void                     setYCoord( GLfloat* yCoord, int size );
62   //! Returns x coords
63   GLfloat*                 getXCoord() const { return myXCoord; }
64   //! Returns y coords
65   GLfloat*                 getYCoord() const { return myYCoord; }
66   
67   //! Sets markers number
68   void                     setNumMarkers( GLint );
69   //! returns markers number
70   GLint                    getNumMarkers() const { return myNumber; };
71   //! Sets merker radius
72   void                     setMarkerSize( const float size ) { myMarkerSize = size; }
73   //! Returns merker radius
74   float                    getMarkerSize() const { return myMarkerSize; }
75   
76   //! Export numbers of heghlighted/selected markers
77   void                     exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
78                                           QValueList<int>& sel, QValueList<int>& unsel );
79   
80   //! Returns selected numbers
81   QValueList<int>          getSelectedElements() { return mySelNumbers; }
82   //! Adds or remove selected number
83   bool                     addOrRemoveSelected( int index );
84   //! Adds selected numbers
85   void                     addSelected( const TColStd_SequenceOfInteger& );
86   //! Sets selected nembers
87   void                     setSelected( const TColStd_SequenceOfInteger& );
88
89 protected:
90   GLint                   myNumber;
91   GLfloat*                myXCoord;
92   GLfloat*                myYCoord;    
93   GLfloat                 myMarkerSize;
94   QValueList<int>         myHNumbers;
95   QValueList<int>         myUHNumbers;
96   QValueList<int>         mySelNumbers;
97   QValueList<int>         myCurSelNumbers;
98   QValueList<int>         myUSelNumbers;
99   QValueList<int>         myPrevHNumbers;
100   TColStd_SequenceOfInteger mySelectedIndexes;
101 };
102
103 /*! 
104  * Class  GLViewer_Polyline
105  * OpenGL Polyline
106  */
107
108 class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object
109 {
110 public:
111   GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" );
112  ~GLViewer_Polyline();
113   
114   // redefined  methods
115   virtual void            compute();
116   virtual GLViewer_Drawer* createDrawer();
117   
118   virtual GLboolean       highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
119   virtual GLboolean       unhighlight();
120   virtual GLboolean       select( GLfloat x, GLfloat y, GLfloat tol,  GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
121     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
122   virtual GLboolean       unselect();
123   
124   virtual GLViewer_Rect*  getUpdateRect();
125   
126   virtual void            moveObject( float, float, bool fromGroup = false );
127   
128   virtual QByteArray      getByteCopy();
129   virtual bool            initializeFromByteCopy( QByteArray );
130   
131   virtual bool            translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
132   virtual bool            translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );    
133   
134 #ifdef WIN32
135   virtual bool            translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
136 #endif
137   
138   //! Sets array of x coords of points
139   void                     setXCoord( GLfloat* xCoord, int size );
140   //! Sets array of y coords of points
141   void                     setYCoord( GLfloat* yCoord, int size );
142   //! Returns x coords
143   GLfloat*                 getXCoord() const { return myXCoord; }
144   //! Returns y coords
145   GLfloat*                 getYCoord() const { return myYCoord; }
146
147   //! SetS number of points
148   void                    setNumber( GLint );
149   //! Returns number of points
150   GLint                   getNumber() const { return myNumber; };
151   
152   //! On/off closed status of polyline
153   void                    setClosed( GLboolean closed ) { myIsClosed = closed; }
154   //! Checks closed status of polyline
155   GLboolean               isClosed() const { return myIsClosed; }
156   
157   //! On/off highlight as whole object status
158   void                    setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; }
159   //! Checks highlight as whole object status
160   GLboolean               isHighSelAll() const { return myHighSelAll; }
161   
162   //! Export numbers of heghlighted/selected lines
163   void                     exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
164                                           QValueList<int>& sel, QValueList<int>& unsel );
165
166   //! Returns numbers of selected lines
167   QValueList<int>         getSelectedElements() { return mySelNumbers; }
168
169 protected:
170   GLfloat*                myXCoord;
171   GLfloat*                myYCoord;
172   GLint                   myNumber;
173   GLboolean               myIsClosed;
174   GLboolean               myHighSelAll;
175   
176   QValueList<int>         myHNumbers;
177   QValueList<int>         myUHNumbers;
178   QValueList<int>         mySelNumbers;
179   QValueList<int>         myUSelNumbers;
180   QValueList<int>         myCurSelNumbers;
181   QValueList<int>         myPrevHNumbers;
182   TColStd_SequenceOfInteger mySelectedIndexes;
183   
184   GLboolean               myHighFlag;
185 };
186
187 // Class:   GLViewer_TextObject
188 // Descr:   Text as Object for OpenGL
189
190 class GLVIEWER_API GLViewer_TextObject : public GLViewer_Object
191 {
192 public:  
193   GLViewer_TextObject( const QString&, float xPos = 0, float yPos = 0, 
194     const QColor& color = QColor( 0, 255, 0 ), const QString& toolTip = "GLText" );
195   ~GLViewer_TextObject();
196   
197   virtual void              compute();
198   virtual GLViewer_Drawer*  createDrawer();
199   
200   virtual void              setDrawer( GLViewer_Drawer* theDrawer );
201   
202   virtual GLboolean         highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE );
203   virtual GLboolean         unhighlight();
204   virtual GLboolean         select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
205     GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
206   virtual GLboolean         unselect();
207   
208   virtual GLViewer_Rect*    getUpdateRect();
209   
210   virtual void              moveObject( float, float, bool fromGroup = false );
211   
212   virtual QByteArray        getByteCopy();
213   virtual bool              initializeFromByteCopy( QByteArray );
214   
215   virtual bool              translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
216   virtual bool              translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );  
217   
218 #ifdef WIN32
219   virtual bool              translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
220 #endif
221   
222   int                       getWidth(){ return myWidth; }
223   int                       getHeight(){ return myWidth; }
224   void                      setWidth( int w ){ myWidth=w; }
225   void                      setHeight( int h ){ myHeight=h; }
226   
227 protected:
228   bool                      myHighFlag;
229   int                       myWidth;
230   int                       myHeight;
231 };
232
233 #ifdef WNT
234 #pragma warning ( default:4251 )
235 #endif
236
237 #endif