Main MRPT website > C++ reference for MRPT 1.9.9
CText.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/CText.h>
14 #include "opengl_internals.h"
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 
19 using namespace mrpt::math;
20 using namespace std;
21 
23 
24 /*---------------------------------------------------------------
25  Constructor
26  ---------------------------------------------------------------*/
27 CText::CText(const string& str)
28 {
29  m_str = str;
30 
31  m_fontName = "Arial";
32  m_fontHeight = 10;
33  m_fontWidth = 0;
34 }
35 
36 /*---------------------------------------------------------------
37  Destructor
38  ---------------------------------------------------------------*/
40 /*---------------------------------------------------------------
41  render
42  ---------------------------------------------------------------*/
43 void CText::render() const
44 {
45 #if MRPT_HAS_OPENGL_GLUT
48 
49  glColor4ub(m_color.R, m_color.G, m_color.B, m_color.A);
50  // Set the "cursor" to the XYZ position:
51  glRasterPos3f(0, 0, 0); // m_x,m_y,m_z);
52 
53  // Call the lists for drawing the text:
54  renderTextBitmap(m_str.c_str(), GLUT_BITMAP_TIMES_ROMAN_10);
55 
58 #endif
59 }
60 
61 uint8_t CText::serializeGetVersion() const { return 1; }
63 {
64  writeToStreamRender(out);
65  out << m_str;
66  out << m_fontName;
67  out << (uint32_t)m_fontHeight << (uint32_t)m_fontWidth;
68 }
69 
71 {
72  switch (version)
73  {
74  case 0:
75  case 1:
76  {
77  uint32_t i;
78  readFromStreamRender(in);
79  in >> m_str;
80  if (version >= 1)
81  {
82  in >> m_fontName;
83  in >> i;
84  m_fontHeight = i;
85  in >> i;
86  m_fontWidth = i;
87  }
88  }
89  break;
90  default:
92  };
93 }
94 
96  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
97 {
98  bb_min.x = 0;
99  bb_min.y = 0;
100  bb_min.z = 0;
101 
102  bb_max = bb_min;
103 
104  // Convert to coordinates of my parent:
105  m_pose.composePoint(bb_min, bb_min);
106  m_pose.composePoint(bb_max, bb_max);
107 }
mrpt::opengl::gl_utils::renderTextBitmap
void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
Definition: gl_utils.cpp:258
mrpt::opengl::CRenderizable
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:43
glColor4ub
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
glDisable
GLAPI void GLAPIENTRY glDisable(GLenum cap)
mrpt::opengl::CText::~CText
virtual ~CText()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText.cpp:39
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
glRasterPos3f
GLAPI void GLAPIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
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::opengl::CText::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CText.cpp:70
mrpt::opengl::CText::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CText.cpp:61
GL_LIGHTING
#define GL_LIGHTING
Definition: glew.h:385
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
GL_DEPTH_TEST
#define GL_DEPTH_TEST
Definition: glew.h:401
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
mrpt::opengl::CText::render
void render() const override
Render.
Definition: CText.cpp:43
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
opengl-precomp.h
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::opengl::CText::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CText.cpp:62
opengl_internals.h
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
in
GLuint in
Definition: glext.h:7274
CArchive.h
mrpt::opengl::CText::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: CText.cpp:95
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::opengl::CText
A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location.
Definition: CText.h:38
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
CText.h



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