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 }
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:6502
virtual ~CText3D()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText3D.cpp:52
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CText3D.cpp:70
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.
uint8_t B
Definition: TColor.h:46
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
uint8_t G
Definition: TColor.h:46
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Definition: gl_utils.cpp:514
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:55
double m_text_kerning
Definition: CText3D.h:51
unsigned char uint8_t
Definition: rptypes.h:41
std::shared_ptr< CText3D > Ptr
Definition: CText3D.h:45
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
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:48
float m_scale_x
Scale components to apply to the object (default=1)
Definition: CRenderizable.h:57
void writeToStreamRender(mrpt::serialization::CArchive &out) const
std::string m_str
Definition: CText3D.h:47
TOpenGLFontStyle
Different style for vectorized font rendering.
Definition: opengl_fonts.h:34
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CText3D.cpp:71
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
uint8_t R
Definition: TColor.h:46
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:52
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
double m_text_spacing
Definition: CText3D.h:50
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
GLuint in
Definition: glext.h:7274
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.
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:98
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
Lightweight 3D point.
void render_dl() const override
Render.
Definition: CText3D.cpp:56
unsigned __int32 uint32_t
Definition: rptypes.h:47
void readFromStreamRender(mrpt::serialization::CArchive &in)
uint8_t A
Definition: TColor.h:46



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020