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://mrpt.sourceforge.net/                            |
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                   *  
00051                   */
00052                 class OPENGL_IMPEXP CArrow : public CRenderizableDisplayList
00053                 {
00054                         DEFINE_SERIALIZABLE( CArrow )
00055                 protected:
00056                         mutable float   m_x0,m_y0,m_z0;
00057                         mutable float   m_x1,m_y1,m_z1;
00058                         float   m_headRatio;
00059                         float   m_smallRadius, m_largeRadius;
00060                         //For version 2 in stream
00061                         float   m_arrow_roll;
00062                         float   m_arrow_pitch;
00063                         float   m_arrow_yaw;
00064 
00065                 public:
00066 
00067                         void setArrowEnds(float x0,float y0, float z0, float x1,float y1, float z1)
00068                         {
00069                                 m_x0=x0;  m_y0 = y0;  m_z0=z0;
00070                                 m_x1=x1;  m_y1 = y1;  m_z1=z1;
00071                                 CRenderizableDisplayList::notifyChange();
00072                         }
00073                         void setHeadRatio(float rat) { m_headRatio=rat; CRenderizableDisplayList::notifyChange(); }
00074                         void setSmallRadius(float rat) { m_smallRadius=rat; CRenderizableDisplayList::notifyChange(); }
00075                         void setLargeRadius(float rat) { m_largeRadius=rat; CRenderizableDisplayList::notifyChange(); }
00076                         void setArrowYawPitchRoll(float yaw,float pitch, float roll ) { m_arrow_yaw=yaw; m_arrow_pitch=pitch; m_arrow_roll=roll; CRenderizableDisplayList::notifyChange(); }
00077 
00078                         /** Render
00079                           */
00080                         void  render_dl() const;
00081 
00082                         /** Class factory  */
00083                         static CArrowPtr Create(
00084                                 float   x0,
00085                                 float   y0,
00086                                 float   z0,
00087                                 float   x1,
00088                                 float   y1,
00089                                 float   z1,
00090                                 float   headRatio = 0.2f,
00091                                 float   smallRadius = 0.05f,
00092                                 float   largeRadius = 0.2f,
00093                                 float   arrow_roll = -1.0f,
00094                                 float   arrow_pitch = -1.0f,
00095                                 float   arrow_yaw = -1.0f
00096                                 )
00097                         {
00098                                 return CArrowPtr(new CArrow(x0,y0,z0, x1,y1,z1, headRatio, smallRadius, largeRadius, arrow_roll, arrow_pitch, arrow_yaw ));
00099                         }
00100 
00101                 private:
00102                         /** Constructor
00103                           */
00104                         CArrow(
00105                                 float   x0 = 0,
00106                                 float   y0 = 0,
00107                                 float   z0 = 0,
00108                                 float   x1 = 1,
00109                                 float   y1 = 1,
00110                                 float   z1 = 1,
00111                                 float   headRatio = 0.2f,
00112                                 float   smallRadius = 0.05f,
00113                                 float   largeRadius = 0.2f,
00114                                 float   arrow_roll = -1.0f,
00115                                 float   arrow_pitch = -1.0f,
00116                                 float   arrow_yaw = -1.0f
00117                                 ) :
00118                                 m_x0(x0),m_y0(y0),m_z0(z0),
00119                                 m_x1(x1),m_y1(y1),m_z1(z1),
00120                                 m_headRatio(headRatio),
00121                                 m_smallRadius(smallRadius),
00122                                 m_largeRadius(largeRadius),
00123                                 m_arrow_roll(arrow_roll),
00124                                 m_arrow_pitch(arrow_pitch),
00125                                 m_arrow_yaw(arrow_yaw)
00126                         {
00127                         }
00128 
00129                         /** Private, virtual destructor: only can be deleted from smart pointers */
00130                         virtual ~CArrow() { }
00131                 };
00132 
00133 
00134         } // end namespace
00135 } // End of namespace
00136 
00137 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011