MRPT  1.9.9
CAxis.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 
12 #include <array>
13 
14 namespace mrpt::opengl
15 {
16 /** Draw a 3D world axis, with coordinate marks at some regular interval
17  * \sa opengl::COpenGLScene
18  *
19  * <div align="center">
20  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
21  * border-style: solid;">
22  * <tr> <td> mrpt::opengl::CAxis </td> <td> \image html preview_CAxis.png
23  * </td> </tr>
24  * </table>
25  * </div>
26  *
27  * \ingroup mrpt_opengl_grp
28  */
30 {
32  public:
33  /** @name Renderizable shader API virtual methods
34  * @{ */
35  void onUpdateBuffers_Wireframe() override;
36  void render(const RenderContext& rc) const override;
38  const mrpt::opengl::TRenderMatrices& state,
39  RenderQueue& rq) const override;
40  /** @} */
41 
42  /** Constructor */
43  CAxis(
44  float xmin = -1.0f, float ymin = -1.0f, float zmin = -1.0f,
45  float xmax = 1.0f, float ymax = 1.0f, float zmax = 1.0f,
46  float frecuency = 1.f, float lineWidth = 3.0f, bool marks = true);
47 
48  virtual ~CAxis() override = default;
49 
50  void setAxisLimits(
51  float xmin, float ymin, float zmin, float xmax, float ymax, float zmax);
52  /** Changes the frequency of the "ticks" */
53  void setFrequency(float f);
54  float getFrequency() const;
55  /** Changes the size of text labels (default:0.25) */
56  void setTextScale(float f);
57  float getTextScale() const;
58  /** axis: {0,1,2}=>{X,Y,Z} */
60  int axis, float yaw_deg, float pitch_deg, float roll_deg);
61  /** axis: {0,1,2}=>{X,Y,Z} */
63  int axis, float& yaw_deg, float& pitch_deg, float& roll_deg) const;
64 
65  void enableTickMarks(bool v = true);
66  void enableTickMarks(bool show_x, bool show_y, bool show_z);
67  /** As a ratio of "marks frequency" (default: 0.05) */
68  void setTickMarksLength(float len);
69  float getTickMarksLength(float len) { return m_markLen; }
70 
71  void getBoundingBox(
73  mrpt::math::TPoint3D& bb_max) const override;
74 
75  protected:
76  float m_xmin, m_ymin, m_zmin;
77  float m_xmax, m_ymax, m_zmax;
78  float m_frequency;
79  /** draw marks for X,Y,Z */
80  std::array<bool, 3> m_marks = {false, false, false};
81  float m_textScale{0.10f};
82  float m_textRot[3][3]; // {x,y,z},{yaw,pitch,roll}
83  float m_markLen{0.07f};
84 
86 };
87 
88 } // namespace mrpt::opengl
float getFrequency() const
Definition: CAxis.cpp:236
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
mrpt::opengl::CListOpenGLObjects m_gl_labels
Definition: CAxis.h:85
Context for calls to render()
float getTextScale() const
Definition: CAxis.cpp:255
float m_textRot[3][3]
Definition: CAxis.h:82
void enableTickMarks(bool v=true)
Definition: CAxis.cpp:237
virtual ~CAxis() override=default
Rendering state related to the projection and model-view matrices.
void getTextLabelOrientation(int axis, float &yaw_deg, float &pitch_deg, float &roll_deg) const
axis: {0,1,2}=>{X,Y,Z}
Definition: CAxis.cpp:275
float m_textScale
Definition: CAxis.h:81
float getTickMarksLength(float len)
Definition: CAxis.h:69
std::array< bool, 3 > m_marks
draw marks for X,Y,Z
Definition: CAxis.h:80
void setTextLabelOrientation(int axis, float yaw_deg, float pitch_deg, float roll_deg)
axis: {0,1,2}=>{X,Y,Z}
Definition: CAxis.cpp:267
float m_markLen
Definition: CAxis.h:83
void setTickMarksLength(float len)
As a ratio of "marks frequency" (default: 0.05)
Definition: CAxis.cpp:54
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: CAxis.cpp:214
float m_frequency
Definition: CAxis.h:78
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CAxis.cpp:60
Renderizable generic renderer for objects using the wireframe shader.
Draw a 3D world axis, with coordinate marks at some regular interval.
Definition: CAxis.h:29
void setFrequency(float f)
Changes the frequency of the "ticks".
Definition: CAxis.cpp:230
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const auto bb_max
CAxis(float xmin=-1.0f, float ymin=-1.0f, float zmin=-1.0f, float xmax=1.0f, float ymax=1.0f, float zmax=1.0f, float frecuency=1.f, float lineWidth=3.0f, bool marks=true)
Constructor.
Definition: CAxis.cpp:25
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void enqueForRenderRecursive(const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq) const override
Definition: CAxis.cpp:149
const auto bb_min
void setAxisLimits(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
Definition: CAxis.cpp:256
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
Definition: CAxis.cpp:156
void setTextScale(float f)
Changes the size of text labels (default:0.25)
Definition: CAxis.cpp:249
std::map< shader_id_t, std::multimap< float, RenderQueueElement > > RenderQueue
A queue for rendering, sorted by shader program to minimize changes of OpenGL shader programs while r...
Definition: RenderQueue.h:46



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