00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef opengl_CTextMessageCapable_H 00029 #define opengl_CTextMessageCapable_H 00030 00031 00032 #include <mrpt/opengl/CRenderizable.h> 00033 #include <mrpt/opengl/opengl_fonts.h> 00034 00035 namespace mrpt 00036 { 00037 namespace opengl 00038 { 00039 /** Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes. 00040 * \ingroup mrpt_opengl_grp 00041 */ 00042 class OPENGL_IMPEXP CTextMessageCapable 00043 { 00044 protected: 00045 std::map<size_t,mrpt::opengl::T2DTextData> m_2D_texts; 00046 00047 /** Renders the messages to the current opengl rendering context (to be called OUT of MRPT mrpt::opengl render() methods ). 00048 * (w,h) are the dimensions of the rendering area in pixels. 00049 */ 00050 void render_text_messages(const int w, const int h) const; 00051 00052 public: 00053 void clearTextMessages(); 00054 00055 00056 /** Add 2D text messages overlapped to the 3D rendered scene. The string will remain displayed in the 3D window 00057 * until it's changed with subsequent calls to this same method, or all the texts are cleared with clearTextMessages(). 00058 * 00059 * \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[. 00060 * \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[. 00061 * \param text The text string to display. 00062 * \param color The text color. For example: TColorf(1.0,1.0,1.0) 00063 * \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. 00064 * 00065 * You'll need to refresh the display manually with forceRepaint(). 00066 * 00067 * \sa clearTextMessages 00068 */ 00069 void addTextMessage( 00070 const double x_frac, 00071 const double y_frac, 00072 const std::string &text, 00073 const mrpt::utils::TColorf &color = mrpt::utils::TColorf(1.0,1.0,1.0), 00074 const size_t unique_index = 0, 00075 const mrpt::opengl::TOpenGLFont font = mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24 00076 ); 00077 00078 /// \overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText() 00079 void addTextMessage( 00080 const double x_frac, 00081 const double y_frac, 00082 const std::string &text, 00083 const mrpt::utils::TColorf &color, 00084 const std::string &font_name, 00085 const double font_size, 00086 const mrpt::opengl::TOpenGLFontStyle font_style = mrpt::opengl::NICE, 00087 const size_t unique_index = 0, 00088 const double font_spacing = 1.5, 00089 const double font_kerning = 0.1 00090 ); 00091 00092 }; // end of CTextMessageCapable 00093 00094 } // end namespace 00095 } // End of namespace 00096 00097 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |