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-2018, 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>
14 #include <mrpt/opengl/gl_utils.h>
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 
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 
72 {
75  << m_text_kerning;
76 }
77 
79 {
80  switch (version)
81  {
82  case 0:
83  {
85 
86  uint32_t i;
88 
90  }
91  break;
92  default:
94  };
96 }
97 
99  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
100 {
101  bb_min.x = 0;
102  bb_min.y = 0;
103  bb_min.z = 0;
104 
105  bb_max.x = m_str.size() * m_scale_x;
106  bb_max.y = 1;
107  bb_max.z = 0;
108 
109  // Convert to coordinates of my parent:
110  m_pose.composePoint(bb_min, bb_min);
111  m_pose.composePoint(bb_max, bb_max);
112 }
mrpt::opengl::CText3D::m_text_kerning
double m_text_kerning
Definition: CText3D.h:53
mrpt::opengl::CText3D::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CText3D.cpp:71
mrpt::opengl::TOpenGLFontStyle
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:36
mrpt::opengl::CText3D::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CText3D.cpp:78
mrpt::opengl::CRenderizable::setScale
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
Definition: CRenderizable.h:213
glColor4ub
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
mrpt::opengl::gl_utils::glDrawText
mrpt::img::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:532
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
mrpt::opengl::gl_utils::glSetFont
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gl_utils.cpp:514
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::img::TColor::R
uint8_t R
Definition: TColor.h:48
mrpt::opengl::CText3D::render_dl
void render_dl() const override
Render.
Definition: CText3D.cpp:56
mrpt::opengl::CRenderizable::Ptr
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:45
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CText3D::getBoundingBox
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:98
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::img::TColor::B
uint8_t B
Definition: TColor.h:48
mrpt::opengl::CRenderizable::m_pose
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
mrpt::opengl::CRenderizable::m_color
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::opengl::CText3D::~CText3D
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:52
mrpt::opengl::CText3D::m_text_style
TOpenGLFontStyle m_text_style
Definition: CText3D.h:51
mrpt::img::TColor::A
uint8_t A
Definition: TColor.h:48
mrpt::opengl::CRenderizable::m_scale_x
float m_scale_x
Scale components to apply to the object (default=1)
Definition: CRenderizable.h:59
mrpt::opengl::CText3D::CText3D
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
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
gl_utils.h
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:6503
opengl-precomp.h
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::poses::CPose3D::composePoint
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:379
mrpt::opengl::CText3D::Ptr
std::shared_ptr< CText3D > Ptr
Definition: CText3D.h:47
opengl_internals.h
mrpt::img::TColor::G
uint8_t G
Definition: TColor.h:48
mrpt::opengl::CText3D::m_str
std::string m_str
Definition: CText3D.h:49
in
GLuint in
Definition: glext.h:7274
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::opengl::CText3D
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style.
Definition: CText3D.h:45
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::opengl::CRenderizable::writeToStreamRender
void writeToStreamRender(mrpt::serialization::CArchive &out) const
Definition: CRenderizable.cpp:110
mrpt::opengl::CText3D::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CText3D.cpp:70
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::opengl::CRenderizableDisplayList::readFromStreamRender
void readFromStreamRender(mrpt::serialization::CArchive &in)
Definition: CRenderizableDisplayList.h:65
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
mrpt::opengl::CText3D::m_fontName
std::string m_fontName
Definition: CText3D.h:50
CText3D.h
mrpt::opengl::CText3D::m_text_spacing
double m_text_spacing
Definition: CText3D.h:52



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST