Main MRPT website > C++ reference
MRPT logo
CText3D.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef opengl_CText3D_H
30 #define opengl_CText3D_H
31 
33 
34 namespace mrpt
35 {
36  namespace opengl
37  {
39 
40  // This must be added to any CSerializable derived class:
42 
43  /** A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style.
44  * Use \a setString and \a setFont to change the text displayed by this object (can be multi-lined).
45  *
46  * Text is drawn along the (+X,+Y) axes.
47  *
48  * Default size of characters is "1.0 units". Change it with the standard method \a CRenderizable::setScale() as with any other 3D object.
49  * The color can be also changed with standard methods in the base class \a CRenderizable.
50  *
51  * \sa opengl::COpenGLScene, CText
52  *
53  * <div align="center">
54  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
55  * <tr> <td> mrpt::opengl::CText3D </td> <td> \image html preview_CText3D.png </td> </tr>
56  * </table>
57  * </div>
58  *
59  * \note This class is based on code from libcvd (LGPL, http://www.edwardrosten.com/cvd/ )
60  * \ingroup mrpt_opengl_grp
61  */
63  {
65  protected:
66  std::string m_str;
67  std::string m_fontName;
68  TOpenGLFontStyle m_text_style;
69  double m_text_spacing;
70  double m_text_kerning;
71 
72  public:
73  /** Sets the displayed string */
74  inline void setString( const std::string &s ) {
75  m_str=s;
77  }
78  /** Returns the currently text associated to this object */
79  inline const std::string &getString() const { return m_str; }
80 
81  /** Changes the font name, among accepted values: "sans", "mono", "serif" */
82  inline void setFont( const std::string &font ) {
83  m_fontName=font;
85  }
86  /** Returns the text font */
87  inline const std::string &getFont() const { return m_fontName; }
88 
89  /** Change drawing style: FILL, OUTLINE, NICE */
91  m_text_style = text_style;
93  }
94  /** Gets the current drawing style */
95  mrpt::opengl::TOpenGLFontStyle getTextStyle() const { return m_text_style; }
96 
97  void setTextSpacing(const double text_spacing) {
98  m_text_spacing = text_spacing;
100  }
101  double setTextSpacing() const { return m_text_spacing; }
102 
103  void setTextKerning(const double text_kerning) {
104  m_text_kerning = text_kerning;
106  }
107  double setTextKerning() const { return m_text_kerning; }
108 
109 
110  /** Render */
111  void render_dl() const;
112 
113 
114  /** Class factory */
115  static CText3DPtr Create(
116  const std::string &str,
117  const std::string &fontName = std::string("sans"),
118  const double scale = 1.0,
120  const double text_spacing = 1.5,
121  const double text_kerning = 0.1 )
122  {
123  return CText3DPtr( new CText3D(str,fontName,scale,text_style,text_spacing,text_kerning) );
124  }
125 
126  private:
127  /** Constructor */
128  CText3D(
129  const std::string &str = std::string(""),
130  const std::string &fontName = std::string("sans"),
131  const double scale = 1.0,
133  const double text_spacing = 1.5,
134  const double text_kerning = 0.1 );
135 
136  /** Private, virtual destructor: only can be deleted from smart pointers */
137  virtual ~CText3D();
138  };
139 
140  } // end namespace
141 
142 } // End of namespace
143 
144 
145 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013