Main MRPT website > C++ reference for MRPT 1.5.7
CText3D.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "opengl-precomp.h" // Precompiled header
11 
12 #include <mrpt/opengl/CText3D.h>
13 #include <mrpt/utils/CStream.h>
14 #include <mrpt/opengl/gl_utils.h>
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 using namespace mrpt::utils;
20 using namespace std;
21 
23 
24 CText3DPtr CText3D::Create(
25  const std::string &str,
26  const std::string &fontName,
27  const double scale,
28  const mrpt::opengl::TOpenGLFontStyle text_style,
29  const double text_spacing,
30  const double text_kerning )
31 {
32  return CText3DPtr( new CText3D(str,fontName,scale,text_style,text_spacing,text_kerning) );
33 }
34 /*---------------------------------------------------------------
35  Constructor
36  ---------------------------------------------------------------*/
38  const std::string &str,
39  const std::string &fontName,
40  const double scale ,
41  const mrpt::opengl::TOpenGLFontStyle text_style,
42  const double text_spacing ,
43  const double text_kerning ) :
44  m_str ( str ),
45  m_fontName ( fontName ),
46  m_text_style ( text_style ),
47  m_text_spacing ( text_spacing ),
48  m_text_kerning ( text_kerning )
49 {
50  this->setScale(scale);
51 }
52 
53 /*---------------------------------------------------------------
54  Destructor
55  ---------------------------------------------------------------*/
57 {
58 }
59 
60 /*---------------------------------------------------------------
61  render
62  ---------------------------------------------------------------*/
63 void CText3D::render_dl() const
64 {
65 #if MRPT_HAS_OPENGL_GLUT
67 
70  m_str,
71  1.0, // Scale
74 
75 #endif
76 }
77 
78 /*---------------------------------------------------------------
79  Implements the writing to a CStream capability of
80  CSerializable objects
81  ---------------------------------------------------------------*/
83 {
84  if (version)
85  *version = 0;
86  else
87  {
89  out << m_str
90  << m_fontName
93  << m_text_kerning;
94  }
95 }
96 
97 /*---------------------------------------------------------------
98  Implements the reading from a CStream capability of
99  CSerializable objects
100  ---------------------------------------------------------------*/
102 {
103  switch(version)
104  {
105  case 0:
106  {
108 
109  uint32_t i;
110  in >> m_str
111  >> m_fontName
112  >> i
113  >> m_text_spacing
114  >> m_text_kerning;
115 
117 
118  } break;
119  default:
121 
122  };
124 }
125 
127 {
128  bb_min.x = 0;
129  bb_min.y = 0;
130  bb_min.z = 0;
131 
132  bb_max.x = m_str.size() * m_scale_x;
133  bb_max.y = 1;
134  bb_max.z = 0;
135 
136  // Convert to coordinates of my parent:
137  m_pose.composePoint(bb_min, bb_min);
138  m_pose.composePoint(bb_max, bb_max);
139 }
mrpt::utils::TPixelCoordf OPENGL_IMPEXP glDrawText(const std::string &text, const double textScale, enum TOpenGLFontStyle style=NICE, double spacing=1.5, double kerning=0.1)
renders a string in GL using the current settings.
Definition: gl_utils.cpp:600
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
TOpenGLFontStyle m_text_style
Definition: CText3D.h:49
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:5717
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:56
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
STL namespace.
double z
X,Y,Z coordinates.
void render_dl() const MRPT_OVERRIDE
Render.
Definition: CText3D.cpp:63
void OPENGL_IMPEXP glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gl_utils.cpp:583
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
Definition: CRenderizable.h:55
double m_text_kerning
Definition: CText3D.h:51
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
CText3D(const std::string &str=std::string(""), const std::string &fontName=std::string("sans"), const double scale=1.0, const mrpt::opengl::TOpenGLFontStyle text_style=mrpt::opengl::NICE, const double text_spacing=1.5, const double text_kerning=0.1)
Constructor.
Definition: CText3D.cpp:37
std::string m_fontName
Definition: CText3D.h:48
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
Definition: CPose3D.cpp:427
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
std::string m_str
Definition: CText3D.h:47
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:37
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CText3D.cpp:126
void readFromStreamRender(mrpt::utils::CStream &in)
mrpt::utils::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
int version
Definition: mrpt_jpeglib.h:898
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
GLsizei const GLchar ** string
Definition: glext.h:3919
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CText3D.cpp:82
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double m_text_spacing
Definition: CText3D.h:50
GLuint in
Definition: glext.h:6301
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:43
The namespace for 3D scene representation and rendering.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CText3D.cpp:101
Lightweight 3D point.
unsigned __int32 uint32_t
Definition: rptypes.h:49



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019