Main MRPT website > C++ reference
MRPT logo
CArrow.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef opengl_CArrow_H
00029 #define opengl_CArrow_H
00030 
00031 #include <mrpt/opengl/CRenderizableDisplayList.h>
00032 
00033 namespace mrpt
00034 {
00035         namespace opengl
00036         {
00037                 class OPENGL_IMPEXP CArrow;
00038 
00039                 // This must be added to any CSerializable derived class:
00040                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CArrow, CRenderizableDisplayList, OPENGL_IMPEXP )
00041 
00042                 /** A 3D arrow
00043                   *  \sa opengl::COpenGLScene
00044                   *  
00045                   *  <div align="center">
00046                   *  <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
00047                   *   <tr> <td> mrpt::opengl::CArrow </td> <td> \image html preview_CArrow.png </td> </tr>
00048                   *  </table>
00049                   *  </div>
00050                   * \ingroup mrpt_opengl_grp
00051                   *  
00052                   */
00053                 class OPENGL_IMPEXP CArrow : public CRenderizableDisplayList
00054                 {
00055                         DEFINE_SERIALIZABLE( CArrow )
00056                 protected:
00057                         mutable float   m_x0,m_y0,m_z0;
00058                         mutable float   m_x1,m_y1,m_z1;
00059                         float   m_headRatio;
00060                         float   m_smallRadius, m_largeRadius;
00061                         //For version 2 in stream
00062                         float   m_arrow_roll;
00063                         float   m_arrow_pitch;
00064                         float   m_arrow_yaw;
00065 
00066                 public:
00067 
00068                         void setArrowEnds(float x0,float y0, float z0, float x1,float y1, float z1)
00069                         {
00070                                 m_x0=x0;  m_y0 = y0;  m_z0=z0;
00071                                 m_x1=x1;  m_y1 = y1;  m_z1=z1;
00072                                 CRenderizableDisplayList::notifyChange();
00073                         }
00074                         void setHeadRatio(float rat) { m_headRatio=rat; CRenderizableDisplayList::notifyChange(); }
00075                         void setSmallRadius(float rat) { m_smallRadius=rat; CRenderizableDisplayList::notifyChange(); }
00076                         void setLargeRadius(float rat) { m_largeRadius=rat; CRenderizableDisplayList::notifyChange(); }
00077                         void setArrowYawPitchRoll(float yaw,float pitch, float roll ) { m_arrow_yaw=yaw; m_arrow_pitch=pitch; m_arrow_roll=roll; CRenderizableDisplayList::notifyChange(); }
00078 
00079                         /** Render
00080                           */
00081                         void  render_dl() const;
00082 
00083                         /** Class factory  */
00084                         static CArrowPtr Create(
00085                                 float   x0,
00086                                 float   y0,
00087                                 float   z0,
00088                                 float   x1,
00089                                 float   y1,
00090                                 float   z1,
00091                                 float   headRatio = 0.2f,
00092                                 float   smallRadius = 0.05f,
00093                                 float   largeRadius = 0.2f,
00094                                 float   arrow_roll = -1.0f,
00095                                 float   arrow_pitch = -1.0f,
00096                                 float   arrow_yaw = -1.0f
00097                                 )
00098                         {
00099                                 return CArrowPtr(new CArrow(x0,y0,z0, x1,y1,z1, headRatio, smallRadius, largeRadius, arrow_roll, arrow_pitch, arrow_yaw ));
00100                         }
00101 
00102                 private:
00103                         /** Constructor
00104                           */
00105                         CArrow(
00106                                 float   x0 = 0,
00107                                 float   y0 = 0,
00108                                 float   z0 = 0,
00109                                 float   x1 = 1,
00110                                 float   y1 = 1,
00111                                 float   z1 = 1,
00112                                 float   headRatio = 0.2f,
00113                                 float   smallRadius = 0.05f,
00114                                 float   largeRadius = 0.2f,
00115                                 float   arrow_roll = -1.0f,
00116                                 float   arrow_pitch = -1.0f,
00117                                 float   arrow_yaw = -1.0f
00118                                 ) :
00119                                 m_x0(x0),m_y0(y0),m_z0(z0),
00120                                 m_x1(x1),m_y1(y1),m_z1(z1),
00121                                 m_headRatio(headRatio),
00122                                 m_smallRadius(smallRadius),
00123                                 m_largeRadius(largeRadius),
00124                                 m_arrow_roll(arrow_roll),
00125                                 m_arrow_pitch(arrow_pitch),
00126                                 m_arrow_yaw(arrow_yaw)
00127                         {
00128                         }
00129 
00130                         /** Private, virtual destructor: only can be deleted from smart pointers */
00131                         virtual ~CArrow() { }
00132                 };
00133 
00134 
00135         } // end namespace
00136 } // End of namespace
00137 
00138 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011