Main MRPT website > C++ reference
MRPT logo
CTextMessageCapable.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 #ifndef opengl_CTextMessageCapable_H
29 #define opengl_CTextMessageCapable_H
30 
31 
34 
35 namespace mrpt
36 {
37  namespace opengl
38  {
39  /** Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
40  * \ingroup mrpt_opengl_grp
41  */
43  {
44  protected:
45  std::map<size_t,mrpt::opengl::T2DTextData> m_2D_texts;
46 
47  /** Renders the messages to the current opengl rendering context (to be called OUT of MRPT mrpt::opengl render() methods ).
48  * (w,h) are the dimensions of the rendering area in pixels.
49  */
50  void render_text_messages(const int w, const int h) const;
51 
52  public:
53  void clearTextMessages();
54 
55 
56  /** Add 2D text messages overlapped to the 3D rendered scene. The string will remain displayed in the 3D window
57  * until it's changed with subsequent calls to this same method, or all the texts are cleared with clearTextMessages().
58  *
59  * \param x The X position, interpreted as absolute pixels from the left if X>=1, absolute pixels from the left if X<0 or as a width factor if in the range [0,1[.
60  * \param y The Y position, interpreted as absolute pixels from the bottom if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in the range [0,1[.
61  * \param text The text string to display.
62  * \param color The text color. For example: TColorf(1.0,1.0,1.0)
63  * \param unique_index An "index" for this text message, so that subsequent calls with the same index will overwrite this text message instead of creating new ones.
64  *
65  * You'll need to refresh the display manually with forceRepaint().
66  *
67  * \sa clearTextMessages
68  */
69  void addTextMessage(
70  const double x_frac,
71  const double y_frac,
72  const std::string &text,
73  const mrpt::utils::TColorf &color = mrpt::utils::TColorf(1.0,1.0,1.0),
74  const size_t unique_index = 0,
76  );
77 
78  /// \overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText()
79  void addTextMessage(
80  const double x_frac,
81  const double y_frac,
82  const std::string &text,
83  const mrpt::utils::TColorf &color,
84  const std::string &font_name,
85  const double font_size,
87  const size_t unique_index = 0,
88  const double font_spacing = 1.5,
89  const double font_kerning = 0.1
90  );
91 
92  }; // end of CTextMessageCapable
93 
94  } // end namespace
95 } // End of namespace
96 
97 #endif



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