Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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>
13 #include <mrpt/utils/CStream.h>
14 #include "opengl_internals.h"
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 using namespace mrpt::utils;
19 using namespace mrpt::math;
20 using namespace std;
21 
23 
24 CTextPtr CText::Create(const std::string &str) { return CTextPtr( new CText(str) ); }
25 
26 /*---------------------------------------------------------------
27  Constructor
28  ---------------------------------------------------------------*/
29 CText::CText( const string &str )
30 {
31  m_str = str;
32 
33  m_fontName = "Arial";
34  m_fontHeight = 10;
35  m_fontWidth = 0;
36 }
37 
38 /*---------------------------------------------------------------
39  Destructor
40  ---------------------------------------------------------------*/
42 {
43 }
44 
45 /*---------------------------------------------------------------
46  render
47  ---------------------------------------------------------------*/
48 void CText::render() const
49 {
50 #if MRPT_HAS_OPENGL_GLUT
53 
54  glColor4ub(m_color.R,m_color.G,m_color.B,m_color.A);
55  // Set the "cursor" to the XYZ position:
56  glRasterPos3f(0,0,0);//m_x,m_y,m_z);
57 
58  // Call the lists for drawing the text:
59  renderTextBitmap( m_str.c_str(), GLUT_BITMAP_TIMES_ROMAN_10 );
60 
63 #endif
64 }
65 
66 /*---------------------------------------------------------------
67  Implements the writing to a CStream capability of
68  CSerializable objects
69  ---------------------------------------------------------------*/
71 {
72  if (version)
73  *version = 1;
74  else
75  {
76  writeToStreamRender(out);
77  out << m_str;
78  out << m_fontName;
79  out << (uint32_t)m_fontHeight << (uint32_t)m_fontWidth;
80 
81  }
82 }
83 
84 /*---------------------------------------------------------------
85  Implements the reading from a CStream capability of
86  CSerializable objects
87  ---------------------------------------------------------------*/
89 {
90  switch(version)
91  {
92  case 0:
93  case 1:
94  {
95  uint32_t i;
96  readFromStreamRender(in);
97  in >> m_str;
98  if (version>=1)
99  {
100  in >> m_fontName;
101  in >> i; m_fontHeight = i;
102  in >> i; m_fontWidth = i;
103  }
104  } break;
105  default:
107 
108  };
109 }
110 
112 {
113  bb_min.x = 0;
114  bb_min.y = 0;
115  bb_min.z = 0;
116 
117  bb_max = bb_min;
118 
119  // Convert to coordinates of my parent:
120  m_pose.composePoint(bb_min, bb_min);
121  m_pose.composePoint(bb_max, bb_max);
122 }
void OPENGL_IMPEXP renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
Definition: gl_utils.cpp:238
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:39
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CText.cpp:88
GLAPI void GLAPIENTRY glEnable(GLenum cap)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CText.cpp:111
GLAPI void GLAPIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:44
STL namespace.
double z
X,Y,Z coordinates.
#define GL_DEPTH_TEST
Definition: glew.h:397
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
#define GL_LIGHTING
Definition: glew.h:381
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CText(const std::string &str=std::string(""))
Constructor.
Definition: CText.cpp:29
virtual ~CText()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CText.cpp:41
int version
Definition: mrpt_jpeglib.h:898
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CText.cpp:70
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLuint in
Definition: glext.h:6301
The namespace for 3D scene representation and rendering.
void render() const MRPT_OVERRIDE
Render.
Definition: CText.cpp:48
Lightweight 3D point.
unsigned __int32 uint32_t
Definition: rptypes.h:49
GLAPI void GLAPIENTRY glDisable(GLenum cap)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020