OpenStructure
Loading...
Searching...
No Matches
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-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 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>
35
36
37#include "overlay_base_fw.hh"
38#include "overlay_manager_fw.hh"
40
41#include <QWidget>
42#include <QPainter>
43#include <QEvent>
44namespace ost { namespace img { namespace gui {
45
46class 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
67public:
68 OverlayManager(QWidget* ref=0);
70
73
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
97
102
104 std::vector<int> GetIDList() const;
105
107 void DeleteOverlay(const String& name);
109 void DeleteOverlay(int id);
110
112
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);
128 int GetOverlayId(const String& name);
129
131
132private:
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
void SetOverlayLock(const String &name, bool visible)
lock/unlock overlay by name
int AddOverlay(const OverlayPtr &ov, bool make_active=true)
add overlay, returning a unique id
void DeleteOverlay(int id)
delete overlay by id
bool IsLocked(const String &name)
void SetOverlayVisibility(int id, bool visible)
show/hide overlay by id
int GetOverlayId(const String &name)
std::vector< int > GetIDList() const
return list with all current overlay ids
OverlayPtr GetActiveOverlay() const
return currently active overlay
void ActivateOverlay(const String &name)
activate overlay by name
void SetOverlayLock(int id, bool visible)
lock/unlock overlay by id
void Attach(OverlayManagerObserver *obs)
attach an observer to this manager
OverlayPtr RetrieveOverlay(int id)
retrieve overlay by id
OverlayPtr RetrieveOverlay(const String &name)
retrieve overlay by name
bool IsVisible(const String &name)
OverlayManager(QWidget *ref=0)
bool OnMouseEvent(QMouseEvent *e, DataViewerPanel *dvp, const QPoint &lastmouse) const
void Detach(OverlayManagerObserver *obs)
detach an observer from this manager
void SetOverlayVisibility(const String &name, bool visible)
show/hide overlay by name
void DeleteOverlay(const String &name)
delete overlay by name
void OnDraw(QPainter &pnt, DataViewerPanel *dvp) const
bool IsActive(const String &name)
void ActivateOverlay(int id)
activate overlay by id
bool OnKeyEvent(QKeyEvent *e, DataViewerPanel *dvp) const
Abstract observer base class for the OverlayManager.
#define DLLEXPORT_OST_GUI
std::string String
Definition base.hh:54
boost::shared_ptr< Overlay > OverlayPtr
Definition base.dox:1