Version: 9.12.0
GLViewer_Text.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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 #ifdef __APPLE__
38 #include <OpenGL/gl.h>
39 #else
40 #include <GL/gl.h>
41 #endif
42 
43 #include <QFont>
44 #include <QString>
45 #include <QColor>
46 
47 #ifdef WIN32
48 #pragma warning( disable:4251 )
49 #endif
50 
56 {
57 public:
58  GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) );
59  GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator);
60  ~GLViewer_Text();
61 
63  void setText( const QString& text ) { myText = text; }
65  QString getText() const { return myText; }
66 
68  void setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; }
70  void getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; }
71 
73  void setColor( const QColor& color ) { myColor = color; }
75  QColor getColor() const { return myColor; }
76 
78  void setFont( const QFont theQFont) { myQFont = theQFont; }
80  QFont getFont() const { return myQFont; }
81 
83  int getSeparator(){ return mySeparator; }
85  void setSeparator( int theSep ){ mySeparator = theSep; }
86 
88  int getWidth();
90  int getHeight();
91 
93 
94  QByteArray getByteCopy() const;
95 
97 
98  static GLViewer_Text* fromByteCopy( QByteArray );
99 
101  DisplayTextFormat getDisplayTextFormat() const { return myDTF; }
103  void setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; }
104 
105 protected:
106  QString myText;
107  float myXPos;
108  float myYPos;
109  QColor myColor;
110  QFont myQFont;
113 };
114 
115 #ifdef WIN32
116 #pragma warning ( default:4251 )
117 #endif
118 
119 #endif
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
DisplayTextFormat
Display Text Format of Objects.
Definition: GLViewer_Defs.h:47
Definition: GLViewer_Text.h:56
float myYPos
Definition: GLViewer_Text.h:108
void setPosition(float xPos, float yPos)
Sets text position.
Definition: GLViewer_Text.h:68
QString myText
Definition: GLViewer_Text.h:106
int getSeparator()
Returns text separator.
Definition: GLViewer_Text.h:83
DisplayTextFormat myDTF
Definition: GLViewer_Text.h:112
DisplayTextFormat getDisplayTextFormat() const
Sets text format BITMAP or TEXTURE.
Definition: GLViewer_Text.h:101
void setColor(const QColor &color)
Sets text color.
Definition: GLViewer_Text.h:73
void getPosition(float &xPos, float &yPos)
Returns text position.
Definition: GLViewer_Text.h:70
QFont myQFont
Definition: GLViewer_Text.h:110
void setText(const QString &text)
Sets text.
Definition: GLViewer_Text.h:63
QFont getFont() const
Returns text font.
Definition: GLViewer_Text.h:80
int mySeparator
Definition: GLViewer_Text.h:111
void setFont(const QFont theQFont)
Sets text font.
Definition: GLViewer_Text.h:78
void setSeparator(int theSep)
Sets text separator.
Definition: GLViewer_Text.h:85
QString getText() const
Returns text.
Definition: GLViewer_Text.h:65
QColor myColor
Definition: GLViewer_Text.h:109
float myXPos
Definition: GLViewer_Text.h:107
void setTextDisplayFormat(DisplayTextFormat theDTF)
Returns text format BITMAP or TEXTURE.
Definition: GLViewer_Text.h:103
QColor getColor() const
Returns text color.
Definition: GLViewer_Text.h:75
Quantity_Color color(const QColor &)
Convert QColor object to Quantity_Color object.
Definition: OCCViewer.cxx:28