Salome HOME
PAL10125 - by double click on reference original object becomes selected
[modules/gui.git] / src / GLViewer / GLViewer_Text.h
1 // File:      GLViewer_Text.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 #ifndef GLVIEWER_TEXT_H
7 #define GLVIEWER_TEXT_H
8
9 #ifdef WNT
10 #include <windows.h>
11 #endif
12
13 #include "GLViewer.h"
14 #include "GLViewer_Defs.h"
15
16 #include <GL/gl.h>
17
18 #include <qfont.h>
19 #include <qstring.h>
20 #include <qcolor.h>
21 #include <qfontmetrics.h>
22
23 #ifdef WNT
24 #pragma warning( disable:4251 )
25 #endif
26
27 /* Class GLViewer_Text
28 * Substitution of Prs3d_Text for OpenGL */
29
30 class GLVIEWER_API GLViewer_Text
31 {
32 public:
33   GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) );
34   GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator);
35   ~GLViewer_Text();
36   
37   //! Sets text
38   void                  setText( const QString& text ) { myText = text; }
39   //! Returns text
40   QString               getText() const { return myText; }
41   
42   //! Sets text position
43   void                  setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; }
44   //! Returns text position
45   void                  getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; }
46   
47   //! Sets text color
48   void                  setColor( const QColor& color ) { myColor = color; }
49   //! Returns text color
50   QColor                getColor() const { return myColor; }
51   
52   //! Sets text font
53   void                  setFont( const QFont theQFont) { myQFont = theQFont; }
54   //! Returns text font
55   QFont                 getFont() const { return myQFont; }
56   
57   //! Returns text separator
58   int                   getSeparator(){ return mySeparator; }
59   //! Sets text separator
60   void                  setSeparator( int theSep ){ mySeparator = theSep; }
61   
62   //! Returns text width
63   int                   getWidth();
64   //! Returns text height
65   int                   getHeight();
66   
67   //! A function for coding object to the byte copy
68   /*! A function is used for copy-past technollogy in copy method   */
69   QByteArray            getByteCopy() const;
70   
71   //! A function for decoding object from the byte copy
72   /*! A function is used for copy-past technollogy in past method   */
73   static GLViewer_Text* fromByteCopy( QByteArray );
74   
75   //! Sets text format BITMAP or TEXTURE
76   DisplayTextFormat     getDisplayTextFormat() const { return myDTF; }
77   //! Returns text format BITMAP or TEXTURE
78   void                  setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; }
79   
80 protected:
81   QString            myText;
82   float              myXPos;
83   float              myYPos;
84   QColor             myColor;
85   QFont              myQFont;
86   int                mySeparator;
87   DisplayTextFormat  myDTF;
88 };
89
90 #ifdef WNT
91 #pragma warning ( default:4251 )
92 #endif
93
94 #endif