snark
view_points/PointWithId.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
20 
21 #ifndef SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_POINTWITHID_H_
22 #define SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_POINTWITHID_H_
23 
24 #include <comma/base/types.h>
25 #include <snark/visiting/eigen.h>
26 #include <Qt3D/qcolor4ub.h>
27 #include "./ShapeWithId.h"
28 
29 namespace snark { namespace graphics { namespace View {
30 
31 struct PointWithId // quick and dirty
32 {
33  PointWithId() : id( 0 ), block( 0 ) {}
34  Eigen::Vector3d point;
35  Eigen::Vector3d orientation;
36  comma::uint32 id;
37  comma::uint32 block;
38  QColor4ub color;
39  std::string label;
40  double scalar;
41 };
42 
43 } } } // namespace snark { namespace graphics { namespace View {
44 
45 namespace comma { namespace visiting {
46 
47 template <> struct traits< snark::graphics::View::PointWithId >
48 {
49  template < typename Key, class Visitor >
50  static void visit( Key, snark::graphics::View::PointWithId& p, Visitor& v )
51  {
52  v.apply( "point", p.point );
53  v.apply( "roll", p.orientation.x() );
54  v.apply( "pitch", p.orientation.y() );
55  v.apply( "yaw", p.orientation.z() );
56  v.apply( "id", p.id );
57  v.apply( "block", p.block );
58  v.apply( "colour", p.color );
59  v.apply( "label", p.label );
60  v.apply( "scalar", p.scalar );
61  }
62 
63  template < typename Key, class Visitor >
64  static void visit( Key, const snark::graphics::View::PointWithId& p, Visitor& v )
65  {
66  v.apply( "point", p.point );
67  v.apply( "roll", p.orientation.x() );
68  v.apply( "pitch", p.orientation.y() );
69  v.apply( "yaw", p.orientation.z() );
70  v.apply( "id", p.id );
71  v.apply( "block", p.block );
72  v.apply( "color", p.color );
73  v.apply( "label", p.label );
74  v.apply( "scalar", p.scalar );
75  }
76 };
77 
78 
79 } } // namespace comma { namespace visiting {
80 
81 #endif /*SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_POINTWITHID_H_*/