Main MRPT website > C++ reference for MRPT 1.9.9
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 CText3D::Ptr CText3D::Create(
25  const std::string& str, const std::string& fontName, const double scale,
26  const mrpt::opengl::TOpenGLFontStyle text_style, const double text_spacing,
27  const double text_kerning)
28 {
29  return CText3D::Ptr(
30  new CText3D(
31  str, fontName, scale, text_style, text_spacing, text_kerning));
32 }
33 /*---------------------------------------------------------------
34  Constructor
35  ---------------------------------------------------------------*/
37  const std::string& str, const std::string& fontName, const double scale,
38  const mrpt::opengl::TOpenGLFontStyle text_style, const double text_spacing,
39  const double text_kerning)
40  : m_str(str),
41  m_fontName(fontName),
42  m_text_style(text_style),
43  m_text_spacing(text_spacing),
44  m_text_kerning(text_kerning)
45 {
46  this->setScale(scale);
47 }
48 
49 /*---------------------------------------------------------------
50  Destructor
51  ---------------------------------------------------------------*/
53 /*---------------------------------------------------------------
54  render
55  ---------------------------------------------------------------*/
56 void CText3D::render_dl() const
57 {
58 #if MRPT_HAS_OPENGL_GLUT
60 
63  m_str,
64  1.0, // Scale
66 
67 #endif
68 }
69 
70 /*---------------------------------------------------------------
71  Implements the writing to a CStream capability of
72  CSerializable objects
73  ---------------------------------------------------------------*/
74 void CText3D::writeToStream(mrpt::utils::CStream& out, int* version) const
75 {
76  if (version)
77  *version = 0;
78  else
79  {
82  << m_text_kerning;
83  }
84 }
85 
86 /*---------------------------------------------------------------
87  Implements the reading from a CStream capability of
88  CSerializable objects
89  ---------------------------------------------------------------*/
91 {
92  switch (version)
93  {
94  case 0:
95  {
97 
98  uint32_t i;
100 
102  }
103  break;
104  default:
106  };
108 }
109 
111  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
112 {
113  bb_min.x = 0;
114  bb_min.y = 0;
115  bb_min.z = 0;
116 
117  bb_max.x = m_str.size() * m_scale_x;
118  bb_max.y = 1;
119  bb_max.z = 0;
120 
121  // Convert to coordinates of my parent:
122  m_pose.composePoint(bb_min, bb_min);
123  m_pose.composePoint(bb_max, bb_max);
124 }
mrpt::utils::TPixelCoordf 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:640
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
TOpenGLFontStyle m_text_style
Definition: CText3D.h:51
#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:6502
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CText3D.cpp:90
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:52
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.
std::shared_ptr< CObject > Ptr
Definition: CObject.h:154
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gl_utils.cpp:621
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
double m_text_kerning
Definition: CText3D.h:53
std::shared_ptr< CText3D > Ptr
Definition: CText3D.h:47
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:36
std::string m_fontName
Definition: CText3D.h:50
float m_scale_x
Scale components to apply to the object (default=1)
Definition: CRenderizable.h:59
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
std::string m_str
Definition: CText3D.h:49
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
void readFromStreamRender(mrpt::utils::CStream &in)
mrpt::utils::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
double x
X,Y,Z coordinates.
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
GLsizei const GLchar ** string
Definition: glext.h:4101
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:52
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, 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:453
GLuint in
Definition: glext.h:7274
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:45
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CText3D.cpp:110
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CText3D.cpp:74
Lightweight 3D point.
void render_dl() const override
Render.
Definition: CText3D.cpp:56
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019