32 double min_col,
double max_col,
34 double min_value,
double max_value,
36 const
std::
string& label_format,
38 double label_font_size)
42 m_label_format(label_format),
45 m_min_value(min_value),
46 m_max_value(max_value),
47 m_label_font_size(label_font_size)
59 double col_min,
double col_max,
double value_min,
double value_max)
63 m_min_value = value_min;
64 m_max_value = value_max;
70 m_disable_depth_test = enable;
79 #if MRPT_HAS_OPENGL_GLUT 80 if (m_disable_depth_test)
88 unsigned int num_divisions = 64;
89 unsigned int num_labels = 4;
90 unsigned int one_label_each_nth = floor((num_divisions) / num_labels);
92 const double x0 = .0, x1 = m_width, x2 = m_width * 1.3;
93 const double Ay = m_height / (num_divisions - 1);
95 std::vector<mrpt::img::TColorf> cols(num_divisions);
96 for (
unsigned int i = 0; i < num_divisions; i++)
98 const double col_idx =
99 m_min_col + i * (m_max_col - m_min_col) / (num_divisions - 1);
101 m_colormap, col_idx, cols[i].
R, cols[i].
G, cols[i].B);
104 for (
unsigned int i = 0; i < num_divisions - 1; i++)
106 const double y0 = Ay * i, y1 = Ay * (i + 1);
107 const TPoint3D pt00(x0, y0, 0), pt10(x1, y0, 0);
108 const TPoint3D pt01(x0, y1, 0), pt11(x1, y1, 0);
116 glColor3f(cols[i + 1].
R, cols[i + 1].
G, cols[i + 1].B);
121 glColor3f(cols[i + 1].
R, cols[i + 1].
G, cols[i + 1].B);
129 for (
unsigned int i = 0; i < num_divisions; i++)
132 m_min_value + i * (m_max_value - m_min_value) / (num_divisions - 1);
133 const double y0 = Ay * i;
137 (i % one_label_each_nth) == 0 || i == (num_divisions - 1);
169 writeToStreamRender(out);
171 out <<
uint32_t(m_colormap) << m_min_col << m_max_col << m_min_value
172 << m_max_value << m_label_format << m_label_font_size
173 << m_disable_depth_test;
181 readFromStreamRender(
in);
184 in >> m_min_col >> m_max_col >> m_min_value >> m_max_value >>
185 m_label_format >> m_label_font_size >> m_disable_depth_test;
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.
TColormap
Different colormaps for use in mrpt::img::colormap()
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glColor3b(GLbyte red, GLbyte green, GLbyte blue)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
GLAPI void GLAPIENTRY glPopMatrix(void)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
mrpt::img::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.
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 serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This base provides a set of functions for maths stuff.
void render_dl() const override
Render.
GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
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.
void setColormap(const mrpt::img::TColormap colormap)
GLAPI void GLAPIENTRY glVertex2d(GLdouble x, GLdouble y)
Virtual base class for "archives": classes abstracting I/O streams.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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...