OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
overlay_manager.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-2011 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  Authors: Ansgar Philippsen, Andreas Schenk
23 */
24 
25 #ifndef IMG_GUI_OVERLAY_MANAGER_HH
26 #define IMG_GUI_OVERLAY_MANAGER_HH
27 
28 #include <vector>
29 #include <list>
30 
31 
32 
33 #include <ost/base.hh>
34 #include <ost/gui/module_config.hh>
35 
36 
37 #include "overlay_base_fw.hh"
38 #include "overlay_manager_fw.hh"
40 
41 #include <QWidget>
42 #include <QPainter>
43 #include <QEvent>
44 namespace ost { namespace img { namespace gui {
45 
46 class DataViewerPanel;
47 
49 {
50  struct OverlayInfo {
51  OverlayInfo():
52  ov(),id(0),visible(true),locked(false) {}
53 
54  OverlayInfo(const OverlayPtr& o, int i, bool v):
55  ov(o), id(i), visible(v),locked(false) {}
56 
57  OverlayPtr ov;
58  int id;
59  bool visible;
60  bool locked;
61  };
62 
63  typedef std::vector<OverlayInfo> OverlayList;
64 
65  typedef std::list<OverlayManagerObserver*> ObserverList;
66 
67 public:
68  OverlayManager(QWidget* ref=0);
69  ~OverlayManager();
70 
72  void Attach(OverlayManagerObserver* obs);
73 
75  void Detach(OverlayManagerObserver* obs);
76 
78  int AddOverlay(const OverlayPtr& ov, bool make_active=true);
79 
81  void ActivateOverlay(const String& name);
83  void ActivateOverlay(int id);
84 
86  void SetOverlayVisibility(const String& name, bool visible);
88  void SetOverlayVisibility(int id, bool visible);
89 
91  void SetOverlayLock(const String& name, bool visible);
93  void SetOverlayLock(int id, bool visible);
94 
96  OverlayPtr GetActiveOverlay() const;
97 
99  OverlayPtr RetrieveOverlay(const String& name);
101  OverlayPtr RetrieveOverlay(int id);
102 
104  std::vector<int> GetIDList() const;
105 
107  void DeleteOverlay(const String& name);
109  void DeleteOverlay(int id);
110 
111  void DeleteAllOverlays();
112 
113  void DeleteActiveOverlay();
114 
115  void OnDraw(QPainter& pnt, DataViewerPanel* dvp) const;
116 
117  bool OnMouseEvent(QMouseEvent* e, DataViewerPanel* dvp, const QPoint& lastmouse) const;
118 
119  bool OnKeyEvent(QKeyEvent* e, DataViewerPanel* dvp) const;
120 
121  bool IsVisible(const String& name);
122  bool IsVisible(int id);
123  bool IsLocked(const String& name);
124  bool IsLocked(int id);
125  bool IsActive(const String& name);
126  bool IsActive(int id);
127  String GetOverlayName(int id);
128  int GetOverlayId(const String& name);
129 
130  void RequestRedraw();
131 
132 private:
133  QWidget* ref_;
134  OverlayList ov_list_;
135  int next_id_;
136 
137  OverlayPtr active_ov_;
138 
139  ObserverList obs_list_;
140 
141  OverlayList::iterator find_ov(int id);
142  OverlayList::iterator find_ov(const String& name);
143  OverlayList::iterator find_ov(OverlayPtr anoverlay);
144 };
145 
146 
147 }}} //ns
148 
149 #endif
boost::shared_ptr< Overlay > OverlayPtr
std::string String
Definition: base.hh:54
#define DLLEXPORT_OST_GUI
Abstract observer base class for the OverlayManager.