Go to the documentation of this file.00001
00004
00005
00006
00007
00008 #include "../../include/qglv/gl/headers.hpp"
00009 #include "../../include/qglv/objects/path.hpp"
00010 #include "../../include/qglv/primitives/arrow.hpp"
00011
00012
00013
00014
00015
00016 namespace qglv {
00017
00018
00019
00020
00021
00022 Path::Path(const Colour& colour, const float& arrow_radius, const float& default_length)
00023 : gl_id(-1)
00024 , need_to_rebuild_gl_list(false)
00025 , arrow_radius(arrow_radius)
00026 , default_length(default_length)
00027 , colour(colour)
00028 {
00029 }
00030
00031 Path::~Path() {
00032 if ( gl_id > 0 ) {
00033 glDeleteLists(gl_id, 1);
00034 }
00035 }
00036
00037 void Path::add(const Sophus::SE3f& pose) {
00038 add(pose, default_length);
00039 }
00040
00041 void Path::add(const Sophus::SE3f& pose, const float& length) {
00042 data.push_back(std::pair<Sophus::SE3f, float>(pose, length));
00043 need_to_rebuild_gl_list = true;
00044 }
00045
00046 void Path::_glGenLists() {
00047 if ( need_to_rebuild_gl_list ) {
00048 if ( gl_id > 0 ) {
00049 glDeleteLists(gl_id, 1);
00050 }
00051 gl_id = ::glGenLists(1);
00052 glNewList( gl_id, GL_COMPILE );
00053 qglv::colour(colour);
00054 for ( const auto& pose_length : data ) {
00055 qglv::arrow(pose_length.first, pose_length.second, arrow_radius);
00056 }
00057 glEndList();
00058 }
00059 }
00060
00061 void Path::draw() {
00062 if ( need_to_rebuild_gl_list ) {
00063 _glGenLists();
00064 need_to_rebuild_gl_list = false;
00065 }
00066 glPushMatrix();
00067 if (gl_id > 0) {
00068 glCallList(gl_id);
00069 }
00070 glPopMatrix();
00071 }
00072
00073
00074
00075
00076
00077 }