27 double width,
double height,
29 float min_col,
float max_col,
31 float min_value,
float max_value,
33 const
std::
string& label_format,
35 float label_font_size)
39 m_label_format(label_format),
42 m_min_value(min_value),
43 m_max_value(max_value),
44 m_label_font_size(label_font_size)
55 float col_min,
float col_max,
float value_min,
float value_max)
59 m_min_value = value_min;
60 m_max_value = value_max;
94 unsigned int num_divisions = 64;
95 unsigned int num_labels = 4;
96 unsigned int one_label_each_nth = num_divisions / num_labels;
98 const double x0 = .0, x1 = m_width, x2 = m_width * 1.3;
99 const double Ay = m_height / (num_divisions - 1);
101 std::vector<mrpt::img::TColor> colors(num_divisions);
102 for (
unsigned int i = 0; i < num_divisions; i++)
104 const float col_idx =
105 m_min_col + i * (m_max_col - m_min_col) / (num_divisions - 1);
117 for (
unsigned int i = 0; i < num_divisions; i++)
120 m_min_value + i * (m_max_value - m_min_value) / (num_divisions - 1);
121 const double y0 = Ay * i;
125 (i % one_label_each_nth) == 0 || i == (num_divisions - 1);
130 lines_vbd.emplace_back(x0, y0, 0);
131 lines_vbd.emplace_back(x2, y0, 0);
132 lines_cbd.emplace_back(tickColor);
133 lines_cbd.emplace_back(tickColor);
143 lines_cbd, p, m_label_font_size, textColor,
FILL, 1.5, 0.1);
148 for (
unsigned int i = 0; i < num_divisions - 1; i++)
150 const double y0 = Ay * i, y1 = Ay * (i + 1);
151 const TPoint3Df pt00(x0, y0, 0), pt10(x1, y0, 0);
152 const TPoint3Df pt01(x0, y1, 0), pt11(x1, y1, 0);
164 t.
vertices[2].setColor(colors[i + 1]);
166 tris.emplace_back(t);
173 t.
vertices[1].setColor(colors[i + 1]);
176 t.
vertices[2].setColor(colors[i + 1]);
178 tris.emplace_back(t);
194 writeToStreamRender(
out);
196 out << uint32_t(m_colormap) << m_min_col << m_max_col << m_min_value
197 << m_max_value << m_label_format << m_label_font_size;
206 readFromStreamRender(in);
209 in >> m_min_col >> m_max_col >> m_min_value >> m_max_value >>
210 m_label_format >> m_label_font_size;
213 bool old_disable_depth_test;
214 in >> old_disable_depth_test;
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()
std::string std::string format(std::string_view fmt, ARGS &&... args)
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
A triangle (float coordinates) with RGBA colors (u8) and UV (texture coordinates) for each vertex...
mrpt::opengl::shader_id_t shader_id
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
The base class of 3D objects that can be directly rendered through OpenGL.
void glDrawTextTransformed(const std::string &text, std::vector< mrpt::opengl::TTriangle > &tris, std::vector< mrpt::math::TPoint3Df > &lines, std::vector< mrpt::img::TColor > &line_colors, const mrpt::poses::CPose3D &text_pose, float text_scale, const mrpt::img::TColor &text_color, TEXT_STYLE style, double spacing, double kerning)
Appends to {tris,lines} the entities representing a given text including a pose and scale transformat...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
Context for calls to render()
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::array< Vertex, 3 > vertices
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 ReadAsAndCastTo(CAST_TO_TYPE &read_here)
Read a value from a stream stored in a type different of the target variable, making the conversion v...
static constexpr shader_id_t WIREFRAME
static constexpr TColor black()
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
void setColorAndValueLimits(float col_min, float col_max, float value_min, float value_max)
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
void onUpdateBuffers_all()
static constexpr shader_id_t TRIANGLES
std::vector< mrpt::img::TColor > m_color_buffer_data
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void setColormap(const mrpt::img::TColormap colormap)
Virtual base class for "archives": classes abstracting I/O streams.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
An RGBA color - floats in the range [0,1].
The namespace for 3D scene representation and rendering.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void computeNormals()
Compute the three normals from the cross-product of "v01 x v02".
TColor asTColor() const
Returns the 0-255 integer version of this color: RGBA_u8.
renders glyphs as filled polygons
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
static constexpr TColor white()
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...
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.