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