snark
view_points/MainWindow.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_MAINWINDOW_H_
22 #define SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_MAINWINDOW_H_
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 #include <QCheckBox>
28 #include <QMainWindow>
29 #include <comma/base/types.h>
30 #include "./Viewer.h"
31 
32 QT_BEGIN_NAMESPACE
33 class QAction;
34 class QActionGroup;
35 class QFrame;
36 class QGridLayout;
37 class QMenu;
38 class QToolBar;
39 QT_END_NAMESPACE
40 
41 namespace snark { namespace graphics { namespace View {
42 
43 class CheckBox;
44 
45 class MainWindow : public QMainWindow
46 {
47  Q_OBJECT
48 
49  public:
50  MainWindow( const std::string& title, snark::graphics::View::Viewer* viewer );
51 
52  private:
53  QMenu* m_viewMenu;
54  Viewer& m_viewer;
55  QFrame* m_fileFrame;
56  QGridLayout* m_fileLayout;
57  bool m_fileFrameVisible;
58  typedef std::map< std::string, std::vector< CheckBox* > > FileGroupMap;
59  FileGroupMap m_fileGroups; // quick and dirty
60 
61  void closeEvent( QCloseEvent* event );
62  void keyPressEvent( QKeyEvent *e );
63  void updateFileFrame();
64  void toggleFileFrame( bool shown );
65  void makeFileGroups();
66  void showFileGroup( std::string name, bool shown );
67 };
68 
69 class CheckBox : public QCheckBox // quick and dirty
70 {
71  Q_OBJECT
72 
73  public:
74  CheckBox( boost::function< void( bool ) > f );
75 
76  public slots:
77  void action( bool checked );
78 
79  private:
80  boost::function< void( bool ) > m_f;
81 };
82 
83 } } } // namespace snark { namespace graphics { namespace View {
84 
85 #endif /*SNARK_GRAPHICS_APPLICATIONS_VIEWPOINTS_MAINWINDOW_H_*/