Moogli
 All Classes
NetworkViewer.hpp
1 #ifndef _NETWORK_VIEWER_HPP_
2 #define _NETWORK_VIEWER_HPP_
3 
4 #include "utility/libraries.hpp"
5 #include "utility/constants.hpp"
6 #include "core/Network.hpp"
7 
8 using namespace std;
9 
10 class NetworkViewer : public QGLWidget
11 {
12  Q_OBJECT
13 
14 public:
15 
16  double up_distance;
17  double down_distance;
18  double left_distance;
19  double right_distance;
20  double forward_distance;
21  double backward_distance;
22  double zoom_factor;
23  double roll_angle;
24  double pitch_angle;
25  double yaw_angle;
26 
27  Network *
28  get_network();
29 
30  NetworkViewer( Network * network
31  , QWidget * parent = 0
32  , const QGLWidget* shareWidget = 0
33  , Qt::WindowFlags f = 0
34  );
35  void
36  add_view( int x
37  , int y
38  , int width
39  , int height
40  );
41 
42  void
43  split_horizontally( unsigned int view_index = 0
44  , unsigned int width_factor = 2
45  );
46 
47  void
48  split_vertically( unsigned int view_index = 0
49  , unsigned int height_factor = 2
50  );
51 
52  void
53  home(unsigned int index = 0);
54 
55  void
56  forward( double distance
57  , unsigned int index = 0
58  );
59  void
60  backward( double distance
61  , unsigned int index = 0
62  );
63  void
64  left( double distance
65  , unsigned int index = 0
66  );
67  void
68  right( double distance
69  , unsigned int index = 0
70  );
71 
72  void
73  up( double distance
74  , unsigned int index = 0
75  );
76 
77  void
78  down( double distance
79  , unsigned int index = 0
80  );
81 
82  void
83  zoom( double factor
84  , unsigned int index = 0
85  );
86 
87  void
88  roll( double angle
89  , unsigned int index = 0
90  );
91 
92  void
93  pitch( double angle
94  , unsigned int index = 0
95  );
96 
97  void
98  yaw( double angle
99  , unsigned int index = 0
100  );
101 
102  // void
103  // capture_continuous_toggle(unsigned int index);
104 
105  // void
106  // capture_once(unsigned int index);
107 
108  virtual
109  ~NetworkViewer();
110 
111 protected:
112 
113  virtual void paintEvent( QPaintEvent* paintEvent );
114  virtual void paintGL();
115  virtual void resizeGL( int width, int height );
116 
117  virtual void keyPressEvent( QKeyEvent* event );
118  virtual void keyReleaseEvent( QKeyEvent* event );
119 
120  virtual void mouseMoveEvent( QMouseEvent* event );
121  virtual void mousePressEvent( QMouseEvent* event );
122  virtual void mouseReleaseEvent( QMouseEvent* event );
123  virtual void wheelEvent( QWheelEvent* event );
124 
125  virtual bool event( QEvent* event );
126 
127 private:
128  void
129  _get_transformation( unsigned int index
130  , osg::Vec3d & eye
131  , osg::Vec3d & center
132  , double & distance
133  , osg::Vec3d & up
134  , osg::Vec3d & look
135  , osg::Vec3d & side
136  );
137 
138  void
139  _set_transformation( unsigned int index
140  , const osg::Vec3d & eye
141  , const osg::Vec3d & center
142  , const osg::Vec3d & up
143  );
144 
145  unsigned int
146  _get_view_index_with_focus();
147 
148  virtual void
149  onHome();
150 
151  virtual void
152  onResize(int width, int height);
153 
154  osgViewer::View *
155  createView();
156 
157  osg::Camera *
158  createCamera();
159 
160  osgGA::EventQueue*
161  getEventQueue() const;
162 
163  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _graphics_window;
164  osg::ref_ptr<osgViewer::CompositeViewer> _viewer;
165 
166  int _previous_width;
167  int _previous_height;
168 
169  string capture_location;
170  string capture_format;
171 
172  Network * network;
173 
174 };
175 
176 #endif /* _NETWORK_VIEWER_HPP_ */