Salome HOME
Transaction management in operations modifed.
[modules/gui.git] / src / GLViewer / GLViewer_Text.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_Text.h
23 // Created:   November, 2004
24
25 #ifndef GLVIEWER_TEXT_H
26 #define GLVIEWER_TEXT_H
27
28 #ifdef WNT
29 #include <windows.h>
30 #endif
31
32 #include "GLViewer.h"
33 #include "GLViewer_Defs.h"
34
35 #include <GL/gl.h>
36
37 #include <qfont.h>
38 #include <qstring.h>
39 #include <qcolor.h>
40 #include <qfontmetrics.h>
41
42 #ifdef WNT
43 #pragma warning( disable:4251 )
44 #endif
45
46 /* Class GLViewer_Text
47 * Substitution of Prs3d_Text for OpenGL */
48
49 class GLVIEWER_API GLViewer_Text
50 {
51 public:
52   GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) );
53   GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator);
54   ~GLViewer_Text();
55   
56   //! Sets text
57   void                  setText( const QString& text ) { myText = text; }
58   //! Returns text
59   QString               getText() const { return myText; }
60   
61   //! Sets text position
62   void                  setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; }
63   //! Returns text position
64   void                  getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; }
65   
66   //! Sets text color
67   void                  setColor( const QColor& color ) { myColor = color; }
68   //! Returns text color
69   QColor                getColor() const { return myColor; }
70   
71   //! Sets text font
72   void                  setFont( const QFont theQFont) { myQFont = theQFont; }
73   //! Returns text font
74   QFont                 getFont() const { return myQFont; }
75   
76   //! Returns text separator
77   int                   getSeparator(){ return mySeparator; }
78   //! Sets text separator
79   void                  setSeparator( int theSep ){ mySeparator = theSep; }
80   
81   //! Returns text width
82   int                   getWidth();
83   //! Returns text height
84   int                   getHeight();
85   
86   //! A function for coding object to the byte copy
87   /*! A function is used for copy-past technollogy in copy method   */
88   QByteArray            getByteCopy() const;
89   
90   //! A function for decoding object from the byte copy
91   /*! A function is used for copy-past technollogy in past method   */
92   static GLViewer_Text* fromByteCopy( QByteArray );
93   
94   //! Sets text format BITMAP or TEXTURE
95   DisplayTextFormat     getDisplayTextFormat() const { return myDTF; }
96   //! Returns text format BITMAP or TEXTURE
97   void                  setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; }
98   
99 protected:
100   QString            myText;
101   float              myXPos;
102   float              myYPos;
103   QColor             myColor;
104   QFont              myQFont;
105   int                mySeparator;
106   DisplayTextFormat  myDTF;
107 };
108
109 #ifdef WNT
110 #pragma warning ( default:4251 )
111 #endif
112
113 #endif