MRPT  1.9.9
CColorBar.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/img/color_maps.h>
12 #include <mrpt/math/TPoint3D.h>
15 
16 namespace mrpt::opengl
17 {
18 /** A colorbar indicator. This class renders a colorbar as a 3D object, in the
19  * XY plane.
20  * For an overlay indicator that can be easily added to any display, see
21  * COpenGLScene::addColorBar()
22  *
23  * \sa opengl::COpenGLScene,opengl::CRenderizable, COpenGLScene::addColorBar()
24  *
25  * <div align="center">
26  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
27  * border-style: solid;">
28  * <tr> <td> mrpt::opengl::CColorBar </td> <td> \image html
29  * preview_CColorBar.png </td> </tr>
30  * </table>
31  * </div>
32  *
33  * \ingroup mrpt_opengl_grp
34  */
37 {
39 
40  public:
41  CColorBar(/** The colormap to represent. */
43  /** size of the color bar */
44  double width = 0.2, double height = 1.0,
45  /** limits for [0,1] colormap indices */
46  float min_col = .0, float max_col = 1.0,
47  /** limits for values associated to extreme colors */
48  float min_value = .0, float max_value = 1.0,
49  /** sprintf-like format string for values */
50  const std::string& label_format = std::string("%7.02f"),
51  /** Label text font size */
52  float label_font_size = .05f);
53 
54  /** @name Renderizable shader API virtual methods
55  * @{ */
56  void render(const RenderContext& rc) const override;
57  void renderUpdateBuffers() const override;
58 
59  virtual shader_list_t requiredShaders() const override
60  {
61  // May use up to two shaders (triangles and lines):
63  }
64  void onUpdateBuffers_Wireframe() override;
65  void onUpdateBuffers_Triangles() override;
66  void onUpdateBuffers_all();
67  void freeOpenGLResources() override
68  {
71  }
72  /** @} */
73 
74  void getBoundingBox(
76  mrpt::math::TPoint3D& bb_max) const override;
77 
80  float col_min, float col_max, float value_min, float value_max);
81 
82  protected:
84  double m_width, m_height;
85  std::string m_label_format;
88 };
89 } // namespace mrpt::opengl
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.
Definition: color_maps.cpp:114
TColormap
Different colormaps for use in mrpt::img::colormap()
Definition: color_maps.h:30
void freeOpenGLResources() override
Free opengl buffers.
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CColorBar.cpp:182
Renderizable generic renderer for objects using the triangles shader.
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
Definition: Shader.h:26
std::string m_label_format
Definition: CColorBar.h:85
Context for calls to render()
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
Definition: CColorBar.h:59
static constexpr shader_id_t WIREFRAME
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
Definition: CColorBar.cpp:77
void setColorAndValueLimits(float col_min, float col_max, float value_min, float value_max)
Definition: CColorBar.cpp:54
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CColorBar.cpp:186
static constexpr shader_id_t TRIANGLES
CColorBar(const mrpt::img::TColormap colormap=mrpt::img::cmGRAYSCALE, double width=0.2, double height=1.0, float min_col=.0, float max_col=1.0, float min_value=.0, float max_value=1.0, const std::string &label_format=std::string("%7.02f"), float label_font_size=.05f)
Definition: CColorBar.cpp:23
void setColormap(const mrpt::img::TColormap colormap)
Definition: CColorBar.cpp:48
A colorbar indicator.
Definition: CColorBar.h:35
Renderizable generic renderer for objects using the wireframe shader.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const auto bb_max
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
Definition: CColorBar.cpp:64
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
const auto bb_min
mrpt::img::TColormap m_colormap
Definition: CColorBar.h:83
void freeOpenGLResources() override
Free opengl buffers.
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: CColorBar.cpp:223
void freeOpenGLResources() override
Free opengl buffers.
Definition: CColorBar.h:67



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020