Main MRPT website > C++ reference
MRPT logo
CArrow.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef opengl_CArrow_H
29 #define opengl_CArrow_H
30 
32 
33 namespace mrpt
34 {
35  namespace opengl
36  {
38 
39  // This must be added to any CSerializable derived class:
41 
42  /** A 3D arrow
43  * \sa opengl::COpenGLScene
44  *
45  * <div align="center">
46  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
47  * <tr> <td> mrpt::opengl::CArrow </td> <td> \image html preview_CArrow.png </td> </tr>
48  * </table>
49  * </div>
50  * \ingroup mrpt_opengl_grp
51  *
52  */
54  {
56  protected:
57  mutable float m_x0,m_y0,m_z0;
58  mutable float m_x1,m_y1,m_z1;
59  float m_headRatio;
60  float m_smallRadius, m_largeRadius;
61  //For version 2 in stream
62  float m_arrow_roll;
63  float m_arrow_pitch;
64  float m_arrow_yaw;
65 
66  public:
67 
68  void setArrowEnds(float x0,float y0, float z0, float x1,float y1, float z1)
69  {
70  m_x0=x0; m_y0 = y0; m_z0=z0;
71  m_x1=x1; m_y1 = y1; m_z1=z1;
73  }
74  void setHeadRatio(float rat) { m_headRatio=rat; CRenderizableDisplayList::notifyChange(); }
75  void setSmallRadius(float rat) { m_smallRadius=rat; CRenderizableDisplayList::notifyChange(); }
76  void setLargeRadius(float rat) { m_largeRadius=rat; CRenderizableDisplayList::notifyChange(); }
77  void setArrowYawPitchRoll(float yaw,float pitch, float roll ) { m_arrow_yaw=yaw; m_arrow_pitch=pitch; m_arrow_roll=roll; CRenderizableDisplayList::notifyChange(); }
78 
79  /** Render
80  */
81  void render_dl() const;
82 
83  /** Class factory */
84  static CArrowPtr Create(
85  float x0,
86  float y0,
87  float z0,
88  float x1,
89  float y1,
90  float z1,
91  float headRatio = 0.2f,
92  float smallRadius = 0.05f,
93  float largeRadius = 0.2f,
94  float arrow_roll = -1.0f,
95  float arrow_pitch = -1.0f,
96  float arrow_yaw = -1.0f
97  )
98  {
99  return CArrowPtr(new CArrow(x0,y0,z0, x1,y1,z1, headRatio, smallRadius, largeRadius, arrow_roll, arrow_pitch, arrow_yaw ));
100  }
101 
102  private:
103  /** Constructor
104  */
106  float x0 = 0,
107  float y0 = 0,
108  float z0 = 0,
109  float x1 = 1,
110  float y1 = 1,
111  float z1 = 1,
112  float headRatio = 0.2f,
113  float smallRadius = 0.05f,
114  float largeRadius = 0.2f,
115  float arrow_roll = -1.0f,
116  float arrow_pitch = -1.0f,
117  float arrow_yaw = -1.0f
118  ) :
119  m_x0(x0),m_y0(y0),m_z0(z0),
120  m_x1(x1),m_y1(y1),m_z1(z1),
121  m_headRatio(headRatio),
122  m_smallRadius(smallRadius),
123  m_largeRadius(largeRadius),
124  m_arrow_roll(arrow_roll),
125  m_arrow_pitch(arrow_pitch),
126  m_arrow_yaw(arrow_yaw)
127  {
128  }
129 
130  /** Private, virtual destructor: only can be deleted from smart pointers */
131  virtual ~CArrow() { }
132  };
133 
134 
135  } // end namespace
136 } // End of namespace
137 
138 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013