OpenStructure
overlay_manager_gui.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 
22 /*
23  Authors: Ansgar Philippsen, Andreas Schenk
24 */
25 
26 #ifndef IMG_OV_GUI_OVDIALOG_H
27 #define IMG_OV_GUI_OVDIALOG_H
28 
29 
30 #include <vector>
31 #include <map>
33 
34 #include <QWidget>
35 #include <QRadioButton>
36 #include <QCheckBox>
37 #include <QMenu>
38 #include <QGridLayout>
39 #include <QLabel>
40 #include <QPushButton>
41 #include <QButtonGroup>
42 namespace ost { namespace img { namespace gui {
43 
44 class OverlayCustomActCheckBox: public QRadioButton
45 {
46  Q_OBJECT;
47 public:
49 
50 public slots:
51  void OnToggle(bool c);
52 
53 private:
54  int id_;
55  OverlayManager* man_;
56 };
57 
59 
60 class OverlayCustomVisCheckBox: public QCheckBox
61 {
62  Q_OBJECT;
63 public:
65 
66 public slots:
67  void OnToggle(bool c);
68 
69 private:
70  int id_;
71  OverlayManager* man_;
72 };
73 
75 
76 class OverlayCustomLockCheckBox: public QCheckBox
77 {
78  Q_OBJECT;
79 public:
81 
82 public slots:
83  void OnToggle(bool c);
84 
85 private:
86  int id_;
87  OverlayManager* man_;
88 };
89 
91 
92 class OverlayManagerGUI: public QWidget, public OverlayManagerObserver {
93  Q_OBJECT;
94 
95  struct OverlayEntry {
96  int row;
97  QRadioButton* a;
98  QCheckBox* v;
99  QCheckBox* l;
100  QPushButton* b;
101  };
102 
103  typedef std::map<int, OverlayEntry> EntryMap;
104 
105 public:
106  OverlayManagerGUI(QWidget* p, OverlayManagerPtr ov_manager);
107 
108  // observer interface
109  virtual void OnLockChange(OverlayManager* m, int id, bool lock);
110  virtual void OnVisibilityChange(OverlayManager* m, int id, bool is_visible);
111  virtual void OnActivate(OverlayManager* m, int id) ;
112  virtual void OnAddOverlay(OverlayManager* m, int id) ;
113  virtual void OnRemoveOverlay(OverlayManager* m, int id) ;
114  virtual void OnRelease(OverlayManager* m) ;
115 
116  //
117  void OnEventActivate(QAction* e);
118  void OnEventShowHide(QAction* e);
119  void OnEventLock(QAction* e);
120  void OnEventMenuPopup(QAction* e);
121  void OnEventMenu(QAction* e);
122 
123  QButtonGroup* GetButtonGroup(void);
124 
125 public slots:
126  void SetInfoText(const QString& t);
127 
128 signals:
130 
131 private:
132  OverlayManagerPtr ov_manager_;
133  EntryMap entry_map_;
134  QButtonGroup* active_group_;
135  QGridLayout* layout_;
136  QLabel* infotext_;
137 
138  void UpdateView();
139 };
140 
141 }}} //ns
142 
143 #endif
OverlayCustomActCheckBox(int i, OverlayManager *m)
OverlayCustomLockCheckBox(int i, OverlayManager *m)
OverlayCustomVisCheckBox(int i, OverlayManager *m)
QButtonGroup * GetButtonGroup(void)
virtual void OnVisibilityChange(OverlayManager *m, int id, bool is_visible)
called on overlay visibility change
virtual void OnRemoveOverlay(OverlayManager *m, int id)
called on removal of an overlay
OverlayManagerGUI(QWidget *p, OverlayManagerPtr ov_manager)
void SetInfoText(const QString &t)
virtual void OnRelease(OverlayManager *m)
called if observed manager will go out of scope
virtual void OnLockChange(OverlayManager *m, int id, bool lock)
called on overlay lock change
virtual void OnAddOverlay(OverlayManager *m, int id)
called on addition of an overlay
virtual void OnActivate(OverlayManager *m, int id)
called on overlay activation
Abstract observer base class for the OverlayManager.
boost::shared_ptr< OverlayManager > OverlayManagerPtr
Definition: base.dox:1