OpenWalnut  1.4.0
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 <string>
30 
31 #ifndef Q_MOC_RUN
32 #include <boost/signals2/signal.hpp>
33 #endif
34 #ifndef Q_MOC_RUN
35 #include <boost/signals2/connection.hpp>
36 #endif
37 
38 #include <osg/Geode>
39 
40 #include "../common/WProperties.h"
41 
42 class WPickHandler;
43 
44 /**
45  * Superclass for different ROI (region of interest) types.
46  */
47 class WROI : public osg::Geode
48 {
49 public:
50  /**
51  * Ref Pointer type.
52  */
53  typedef osg::ref_ptr< WROI > RefPtr;
54 
55  WROI();
56 
57  /**
58  * Need virtual destructor because of virtual function.
59  */
60  virtual ~WROI();
61 
62  /**
63  * sets the NOT flag
64  *
65  * \param isNot
66  */
67  void setNot( bool isNot = true );
68 
69  /**
70  * getter for NOT flag
71  *
72  * \return the flag
73  */
74  bool isNot();
75 
76  /**
77  * getter
78  *
79  * \return the active flag
80  */
81  bool active();
82 
83  /**
84  * setter
85  *
86  * \param active
87  */
88  void setActive( bool active );
89 
90  /**
91  * hides the roi in the scene
92  */
93  void hide();
94 
95  /**
96  * unhides the roi in the scene
97  */
98  void unhide();
99 
100  /**
101  * Getter for modified flag
102  * \return the dirty flag
103  */
104  bool dirty();
105 
106  /**
107  * sets the dirty flag
108  */
109  void setDirty();
110 
111  /**
112  * Getter
113  * \return the properties object for this roi
114  */
115  boost::shared_ptr< WProperties > getProperties();
116 
117  /**
118  * Add a specified notifier to the list of default notifiers which get connected to each roi.
119  *
120  * \param notifier the notifier function
121  */
122  void addROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
123 
124  /**
125  * Remove a specified notifier from the list of default notifiers which get connected to each roi.
126  *
127  * \param notifier the notifier function
128  */
129  void removeROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
130 
131  /**
132  * Invert property.
133  *
134  * \return the property
135  */
136  WPropBool invertProperty();
137 
138  /**
139  * The property for toggling ROI visibility.
140  *
141  * \return the property
142  */
143  WPropBool showProperty();
144 
145  /**
146  * The active property
147  *
148  * \return the property.
149  */
150  WPropBool activeProperty();
151 
152  /**
153  * The name property
154  *
155  * \return the property.
156  */
157  WPropString nameProperty();
158 protected:
159  /**
160  * initializes the roi's properties
161  */
162  void properties();
163 
164  /**
165  * callback when a property gets changed
166  */
167  void propertyChanged();
168 
169  /**
170  * signals a roi change to all subscribers
171  */
172  void signalRoiChange();
173 
174 
175  osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
176 
177  /**
178  * the property object for the module
179  */
180  boost::shared_ptr< WProperties > m_properties;
181 
182  /**
183  * dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating
184  * since these customers get the update notification via callback
185  */
186  WPropBool m_dirty;
187 
188  /**
189  * indicates if the roi is active
190  */
191  WPropBool m_active;
192 
193  /**
194  * indicates if the roi is visible in the scene
195  */
196  WPropBool m_show;
197 
198  /**
199  * indicates if the roi is negated
200  */
201  WPropBool m_not;
202 
203  /**
204  * name of the ROI.
205  */
206  WPropString m_name;
207 
208  /**
209  * threshold for an arbitrary roi
210  */
211  WPropDouble m_threshold;
212 
213  /**
214  * A color for painting the roi in the scene
215  */
216  WPropColor m_color;
217 
218  /**
219  * The notifiers connected to added rois by default.
220  */
221  std::list< boost::shared_ptr< boost::function< void() > > > m_changeNotifiers;
222 
223 
224  /**
225  * Lock for associated notifiers set.
226  */
227  boost::shared_mutex m_associatedNotifiersLock;
228 
229 private:
230  /**
231  * updates the graphics
232  */
233  virtual void updateGFX() = 0;
234 };
235 
236 #endif // WROI_H
WPropBool showProperty()
The property for toggling ROI visibility.
Definition: WROI.cpp:59
void setDirty()
sets the dirty flag
Definition: WROI.cpp:118
WPropString nameProperty()
The name property.
Definition: WROI.cpp:64
boost::shared_ptr< WProperties > getProperties()
Getter.
Definition: WROI.cpp:91
WPropDouble m_threshold
threshold for an arbitrary roi
Definition: WROI.h:211
osg::ref_ptr< WPickHandler > m_pickHandler
A pointer to the pick handler used to get gui events for moving the box.
Definition: WROI.h:175
boost::shared_mutex m_associatedNotifiersLock
Lock for associated notifiers set.
Definition: WROI.h:227
WPropBool invertProperty()
Invert property.
Definition: WROI.cpp:54
WPropBool m_show
indicates if the roi is visible in the scene
Definition: WROI.h:196
void setActive(bool active)
setter
Definition: WROI.cpp:112
void removeROIChangeNotifier(boost::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:156
WPropBool m_active
indicates if the roi is active
Definition: WROI.h:191
void propertyChanged()
callback when a property gets changed
Definition: WROI.cpp:74
WPropColor m_color
A color for painting the roi in the scene.
Definition: WROI.h:216
Superclass for different ROI (region of interest) types.
Definition: WROI.h:47
void signalRoiChange()
signals a roi change to all subscribers
Definition: WROI.cpp:139
bool isNot()
getter for NOT flag
Definition: WROI.cpp:102
void properties()
initializes the roi's properties
Definition: WROI.cpp:41
boost::shared_ptr< WProperties > m_properties
the property object for the module
Definition: WROI.h:180
WPropString m_name
name of the ROI.
Definition: WROI.h:206
Class to handle events with a pick.
Definition: WPickHandler.h:45
WPropBool m_dirty
dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating since ...
Definition: WROI.h:186
virtual void updateGFX()=0
updates the graphics
bool active()
getter
Definition: WROI.cpp:107
std::list< boost::shared_ptr< boost::function< void() > > > m_changeNotifiers
The notifiers connected to added rois by default.
Definition: WROI.h:221
WPropBool m_not
indicates if the roi is negated
Definition: WROI.h:201
void unhide()
unhides the roi in the scene
Definition: WROI.cpp:134
void addROIChangeNotifier(boost::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:148
virtual ~WROI()
Need virtual destructor because of virtual function.
Definition: WROI.cpp:37
WPropBool activeProperty()
The active property.
Definition: WROI.cpp:69
void setNot(bool isNot=true)
sets the NOT flag
Definition: WROI.cpp:96
osg::ref_ptr< WROI > RefPtr
Ref Pointer type.
Definition: WROI.h:53
void hide()
hides the roi in the scene
Definition: WROI.cpp:129
bool dirty()
Getter for modified flag.
Definition: WROI.cpp:124