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 }
void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
Definition: gl_utils.cpp:258
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:36
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)
This must be inserted in all CSerializable classes implementation files.
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:41
STL namespace.
#define GL_DEPTH_TEST
Definition: glew.h:401
#define GL_LIGHTING
Definition: glew.h:385
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
This base provides a set of functions for maths stuff.
void render() const override
Render.
Definition: CText.cpp:43
virtual ~CText()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText.cpp:39
double x
X,Y,Z coordinates.
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:52
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
Lightweight 3D point.
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
unsigned __int32 uint32_t
Definition: rptypes.h:47
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020