snark
view_points/Viewer.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_VIEWER_H_
22 #define SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_VIEWER_H_
23 
24 #ifdef WIN32
25 #include <winsock2.h>
26 
27 //#include <windows.h>
28 #endif
29 
30 #include <boost/optional.hpp>
31 #include <boost/thread.hpp>
32 #include <snark/graphics/qt3d/view.h>
33 #include "./CameraReader.h"
34 #include "./Reader.h"
35 
36 namespace snark { namespace graphics { namespace View {
37 
38 class Viewer : public qt3d::view
39 {
40  Q_OBJECT
41 public:
42  std::vector< boost::shared_ptr< Reader > > readers;
43  Viewer( const QColor4ub& background_color, double fov, bool z_up, bool orthographic = false,
44  boost::optional< comma::csv::options > cameracsv = boost::optional< comma::csv::options >(),
45  boost::optional< Eigen::Vector3d > cameraposition = boost::optional< Eigen::Vector3d >(),
46  boost::optional< Eigen::Vector3d > cameraorientation = boost::optional< Eigen::Vector3d >()
47  );
48  void shutdown();
49 
50 private slots:
51  void read();
52 
53 private:
54 
55  void initializeGL( QGLPainter *painter );
56  void paintGL( QGLPainter *painter );
57  void setCameraPosition( const Eigen::Vector3d& position, const Eigen::Vector3d& orientation );
58 
59  bool m_shutdown;
60  bool m_lookAt;
61  boost::scoped_ptr< CameraReader > m_cameraReader;
62  boost::optional< Eigen::Vector3d > m_cameraposition;
63  boost::optional< Eigen::Vector3d > m_cameraorientation;
64  bool m_cameraFixed;
65 };
66 
67 } } } // namespace snark { namespace graphics { namespace View {
68 
69 #endif /*SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_VIEWER_H_*/