snark
label_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 
19 #ifndef SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_MAINWINDOW_H
20 #define SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_MAINWINDOW_H
21 
22 #include <string>
23 #include <QMainWindow>
24 #include <QGridLayout>
25 #include <QMenu>
26 #include <QCheckBox>
27 #include <comma/base/types.h>
28 #include "./Actions.h"
29 #include "./IdEdit.h"
30 #include "./Viewer.h"
31 
32 namespace snark { namespace graphics { namespace View {
33 
34 class CheckBox;
35 
36 class MainWindow : public QMainWindow
37 {
38  Q_OBJECT
39 
40  public:
41  MainWindow( const std::string& title, snark::graphics::View::Viewer* viewer );
42 
43  public slots:
44  void viewerInitialized();
45 
46  private:
47  Viewer& m_viewer;
48  QActionGroup m_paintToolGroup;
49  IdEdit* m_idEdit;
50  QMenu* m_viewMenu;
51  QMenu* m_writableMenu;
52  QFrame* m_fileFrame;
53  QGridLayout* m_fileLayout;
54  bool m_fileFrameVisible;
55  typedef std::map< std::string, std::vector< std::pair< CheckBox*, CheckBox* > > > FileGroupMap;
56  FileGroupMap m_fileGroups; // quick and dirty
57 
58  void closeEvent( QCloseEvent* event );
59  void saveAs();
60  void updateFileFrame();
61  void newId() const;
62  void toggleFileFrame( bool shown );
63  void makeFileGroups();
64  void showFileGroup( std::string name, bool shown );
65  void setWritableFileGroup( std::string name, bool writable );
66  void keyPressEvent(QKeyEvent *e);
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