Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / GLViewer / GLViewer_Text.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  Author : OPEN CASCADE
23 // File:      GLViewer_Text.h
24 // Created:   November, 2004
25 //
26 #ifndef GLVIEWER_TEXT_H
27 #define GLVIEWER_TEXT_H
28
29 #ifdef WIN32
30 #include <windows.h>
31 #endif
32
33 #include "GLViewer.h"
34 #include "GLViewer_Defs.h"
35
36 #include <GL/gl.h>
37
38 #include <QFont>
39 #include <QString>
40 #include <QColor>
41
42 #ifdef WIN32
43 #pragma warning( disable:4251 )
44 #endif
45
46 /*!
47   \class GLViewer_Text
48   Substitution of Prs3d_Text for OpenGL
49 */
50 class GLVIEWER_API GLViewer_Text
51 {
52 public:
53   GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) );
54   GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator);
55   ~GLViewer_Text();
56   
57   //! Sets text
58   void                  setText( const QString& text ) { myText = text; }
59   //! Returns text
60   QString               getText() const { return myText; }
61   
62   //! Sets text position
63   void                  setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; }
64   //! Returns text position
65   void                  getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; }
66   
67   //! Sets text color
68   void                  setColor( const QColor& color ) { myColor = color; }
69   //! Returns text color
70   QColor                getColor() const { return myColor; }
71   
72   //! Sets text font
73   void                  setFont( const QFont theQFont) { myQFont = theQFont; }
74   //! Returns text font
75   QFont                 getFont() const { return myQFont; }
76   
77   //! Returns text separator
78   int                   getSeparator(){ return mySeparator; }
79   //! Sets text separator
80   void                  setSeparator( int theSep ){ mySeparator = theSep; }
81   
82   //! Returns text width
83   int                   getWidth();
84   //! Returns text height
85   int                   getHeight();
86   
87   //! A function for coding object to the byte copy
88   /*! A function is used for copy-past technollogy in copy method   */
89   QByteArray            getByteCopy() const;
90   
91   //! A function for decoding object from the byte copy
92   /*! A function is used for copy-past technollogy in past method   */
93   static GLViewer_Text* fromByteCopy( QByteArray );
94   
95   //! Sets text format BITMAP or TEXTURE
96   DisplayTextFormat     getDisplayTextFormat() const { return myDTF; }
97   //! Returns text format BITMAP or TEXTURE
98   void                  setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; }
99   
100 protected:
101   QString            myText;
102   float              myXPos;
103   float              myYPos;
104   QColor             myColor;
105   QFont              myQFont;
106   int                mySeparator;
107   DisplayTextFormat  myDTF;
108 };
109
110 #ifdef WIN32
111 #pragma warning ( default:4251 )
112 #endif
113
114 #endif