MRPT  1.9.9
CText.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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  ---------------------------------------------------------------*/
39 CText::~CText() = default;
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 
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 }
void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
Definition: gl_utils.cpp:272
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:35
~CText() override
Private, virtual destructor: only can be deleted from smart pointers.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CText.cpp:61
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:40
STL namespace.
#define GL_DEPTH_TEST
Definition: glew.h:402
#define GL_LIGHTING
Definition: glew.h:386
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
void render() const override
Render.
Definition: CText.cpp:43
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CText.cpp:62
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:54
mrpt::vision::TStereoCalibResults out
GLuint in
Definition: glext.h:7391
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
const auto bb_min
Lightweight 3D point.
Definition: TPoint3D.h:90
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
GLAPI void GLAPIENTRY glDisable(GLenum cap)
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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 479715d5b Tue Nov 12 07:26:21 2019 +0100 at mar nov 12 07:30:12 CET 2019