OpenWalnut  1.5.0dev
WROI.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WROI_H
26 #define WROI_H
27 
28 #include <list>
29 #include <memory>
30 #include <shared_mutex>
31 #include <string>
32 
33 #include <boost/signals2/connection.hpp>
34 #include <boost/signals2/signal.hpp>
35 #include <osg/Geode>
36 
37 #include "../common/WProperties.h"
38 
39 class WPickHandler;
40 
41 /**
42  * Superclass for different ROI (region of interest) types.
43  */
44 class WROI : public osg::Geode
45 {
46 public:
47  /**
48  * Ref Pointer type.
49  */
50  typedef osg::ref_ptr< WROI > RefPtr;
51 
52  WROI();
53 
54  /**
55  * Need virtual destructor because of virtual function.
56  */
57  virtual ~WROI();
58 
59  /**
60  * sets the NOT flag
61  *
62  * \param isNot
63  */
64  void setNot( bool isNot = true );
65 
66  /**
67  * getter for NOT flag
68  *
69  * \return the flag
70  */
71  bool isNot();
72 
73  /**
74  * getter
75  *
76  * \return the active flag
77  */
78  bool active();
79 
80  /**
81  * setter
82  *
83  * \param active
84  */
85  void setActive( bool active );
86 
87  /**
88  * hides the roi in the scene
89  */
90  void hide();
91 
92  /**
93  * unhides the roi in the scene
94  */
95  void unhide();
96 
97  /**
98  * Getter for modified flag
99  * \return the dirty flag
100  */
101  bool dirty();
102 
103  /**
104  * sets the dirty flag
105  */
106  void setDirty();
107 
108  /**
109  * Getter
110  * \return the properties object for this roi
111  */
112  std::shared_ptr< WProperties > getProperties();
113 
114  /**
115  * Add a specified notifier to the list of default notifiers which get connected to each roi.
116  *
117  * \param notifier the notifier function
118  */
119  void addROIChangeNotifier( std::shared_ptr< boost::function< void() > > notifier );
120 
121  /**
122  * Remove a specified notifier from the list of default notifiers which get connected to each roi.
123  *
124  * \param notifier the notifier function
125  */
126  void removeROIChangeNotifier( std::shared_ptr< boost::function< void() > > notifier );
127 
128  /**
129  * Invert property.
130  *
131  * \return the property
132  */
133  WPropBool invertProperty();
134 
135  /**
136  * The property for toggling ROI visibility.
137  *
138  * \return the property
139  */
140  WPropBool showProperty();
141 
142  /**
143  * The active property
144  *
145  * \return the property.
146  */
147  WPropBool activeProperty();
148 
149  /**
150  * The name property
151  *
152  * \return the property.
153  */
154  WPropString nameProperty();
155 protected:
156  /**
157  * initializes the roi's properties
158  */
159  void properties();
160 
161  /**
162  * callback when a property gets changed
163  */
164  void propertyChanged();
165 
166  /**
167  * signals a roi change to all subscribers
168  */
169  void signalRoiChange();
170 
171 
172  osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
173 
174  /**
175  * the property object for the module
176  */
177  std::shared_ptr< WProperties > m_properties;
178 
179  /**
180  * dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating
181  * since these customers get the update notification via callback
182  */
183  WPropBool m_dirty;
184 
185  /**
186  * indicates if the roi is active
187  */
188  WPropBool m_active;
189 
190  /**
191  * indicates if the roi is visible in the scene
192  */
193  WPropBool m_show;
194 
195  /**
196  * indicates if the roi is negated
197  */
198  WPropBool m_not;
199 
200  /**
201  * name of the ROI.
202  */
203  WPropString m_name;
204 
205  /**
206  * threshold for an arbitrary roi
207  */
208  WPropDouble m_threshold;
209 
210  /**
211  * A color for painting the roi in the scene
212  */
213  WPropColor m_color;
214 
215  /**
216  * The notifiers connected to added rois by default.
217  */
218  std::list< std::shared_ptr< boost::function< void() > > > m_changeNotifiers;
219 
220 
221  /**
222  * Lock for associated notifiers set.
223  */
224  std::shared_mutex m_associatedNotifiersLock;
225 
226 private:
227  /**
228  * updates the graphics
229  */
230  virtual void updateGFX() = 0;
231 };
232 
233 #endif // WROI_H
Class to handle events with a pick.
Definition: WPickHandler.h:44
Superclass for different ROI (region of interest) types.
Definition: WROI.h:45
void removeROIChangeNotifier(std::shared_ptr< boost::function< void() > > notifier)
Remove a specified notifier from the list of default notifiers which get connected to each roi.
Definition: WROI.cpp:157
WPropBool activeProperty()
The active property.
Definition: WROI.cpp:70
WPropBool m_show
indicates if the roi is visible in the scene
Definition: WROI.h:193
void setNot(bool isNot=true)
sets the NOT flag
Definition: WROI.cpp:97
std::shared_mutex m_associatedNotifiersLock
Lock for associated notifiers set.
Definition: WROI.h:224
void propertyChanged()
callback when a property gets changed
Definition: WROI.cpp:75
osg::ref_ptr< WPickHandler > m_pickHandler
A pointer to the pick handler used to get gui events for moving the box.
Definition: WROI.h:172
bool dirty()
Getter for modified flag.
Definition: WROI.cpp:125
std::shared_ptr< WProperties > m_properties
the property object for the module
Definition: WROI.h:177
WPropString nameProperty()
The name property.
Definition: WROI.cpp:65
void signalRoiChange()
signals a roi change to all subscribers
Definition: WROI.cpp:140
std::list< std::shared_ptr< boost::function< void() > > > m_changeNotifiers
The notifiers connected to added rois by default.
Definition: WROI.h:218
WPropBool m_not
indicates if the roi is negated
Definition: WROI.h:198
virtual ~WROI()
Need virtual destructor because of virtual function.
Definition: WROI.cpp:38
WPropDouble m_threshold
threshold for an arbitrary roi
Definition: WROI.h:208
WPropBool showProperty()
The property for toggling ROI visibility.
Definition: WROI.cpp:60
WPropString m_name
name of the ROI.
Definition: WROI.h:203
osg::ref_ptr< WROI > RefPtr
Ref Pointer type.
Definition: WROI.h:50
void setActive(bool active)
setter
Definition: WROI.cpp:113
virtual void updateGFX()=0
updates the graphics
void hide()
hides the roi in the scene
Definition: WROI.cpp:130
WPropBool m_active
indicates if the roi is active
Definition: WROI.h:188
void setDirty()
sets the dirty flag
Definition: WROI.cpp:119
WPropBool invertProperty()
Invert property.
Definition: WROI.cpp:55
void addROIChangeNotifier(std::shared_ptr< boost::function< void() > > notifier)
Add a specified notifier to the list of default notifiers which get connected to each roi.
Definition: WROI.cpp:149
WPropColor m_color
A color for painting the roi in the scene.
Definition: WROI.h:213
WPropBool m_dirty
dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating since ...
Definition: WROI.h:183
bool isNot()
getter for NOT flag
Definition: WROI.cpp:103
void unhide()
unhides the roi in the scene
Definition: WROI.cpp:135
std::shared_ptr< WProperties > getProperties()
Getter.
Definition: WROI.cpp:92
bool active()
getter
Definition: WROI.cpp:108
void properties()
initializes the roi's properties
Definition: WROI.cpp:42