31 double min_col,
double max_col,
33 double min_value,
double max_value,
35 const
std::
string& label_format,
37 double label_font_size)
41 m_label_format(label_format),
44 m_min_value(min_value),
45 m_max_value(max_value),
46 m_label_font_size(label_font_size),
47 m_disable_depth_test(true)
57 double min_col,
double max_col,
59 double min_value,
double max_value,
63 double label_font_size)
68 label_format, label_font_size));
78 double col_min,
double col_max,
double value_min,
double value_max)
82 m_min_value = value_min;
83 m_max_value = value_max;
89 m_disable_depth_test = enable;
98 #if MRPT_HAS_OPENGL_GLUT 99 if (m_disable_depth_test)
107 unsigned int num_divisions = 64;
108 unsigned int num_labels = 4;
109 unsigned int one_label_each_nth = floor((num_divisions) / num_labels);
111 const double x0 = .0, x1 = m_width, x2 = m_width * 1.3;
112 const double Ay = m_height / (num_divisions - 1);
114 std::vector<mrpt::utils::TColorf> cols(num_divisions);
115 for (
unsigned int i = 0; i < num_divisions; i++)
117 const double col_idx =
118 m_min_col + i * (m_max_col - m_min_col) / (num_divisions - 1);
120 m_colormap, col_idx, cols[i].
R, cols[i].G, cols[i].B);
123 for (
unsigned int i = 0; i < num_divisions - 1; i++)
125 const double y0 = Ay * i, y1 = Ay * (i + 1);
126 const TPoint3D pt00(x0, y0, 0), pt10(x1, y0, 0);
127 const TPoint3D pt01(x0, y1, 0), pt11(x1, y1, 0);
135 glColor3f(cols[i + 1].
R, cols[i + 1].G, cols[i + 1].B);
140 glColor3f(cols[i + 1].
R, cols[i + 1].G, cols[i + 1].B);
148 for (
unsigned int i = 0; i < num_divisions; i++)
151 m_min_value + i * (m_max_value - m_min_value) / (num_divisions - 1);
152 const double y0 = Ay * i;
156 (i % one_label_each_nth) == 0 || i == (num_divisions - 1);
195 writeToStreamRender(out);
197 out <<
uint32_t(m_colormap) << m_min_col << m_max_col << m_min_value
198 << m_max_value << m_label_format << m_label_font_size
199 << m_disable_depth_test;
212 readFromStreamRender(
in);
215 in >> m_min_col >> m_max_col >> m_min_value >> m_max_value >>
216 m_label_format >> m_label_font_size >> m_disable_depth_test;
236 m_pose.composePoint(bb_min, bb_min);
237 m_pose.composePoint(bb_max, bb_max);
mrpt::utils::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.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLAPI void GLAPIENTRY glColor3b(GLbyte red, GLbyte green, GLbyte blue)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
TColormap
Different colormaps for use in mrpt::utils::colormap()
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
GLAPI void GLAPIENTRY glPopMatrix(void)
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void colormap(const TColormap &color_map, const float color_index, float &r, float &g, float &b)
Transform a float number in the range [0,1] into RGB components.
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
A renderizable object suitable for rendering with OpenGL's display lists.
void setColormap(const mrpt::utils::TColormap colormap)
static Ptr Create(Args &&... args)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
void render_dl() const override
Render.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::shared_ptr< CColorBar > Ptr
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLsizei const GLchar ** string
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
void setColorAndValueLimits(double col_min, double col_max, double value_min, double value_max)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLAPI void GLAPIENTRY glVertex2d(GLdouble x, GLdouble y)
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
void enableDepthTest(bool enable)
GLAPI void GLAPIENTRY glPushMatrix(void)
GLenum GLsizei GLsizei height
unsigned __int32 uint32_t
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...