OpenWalnut  1.5.0dev
WSelectorBranch.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 WSELECTORBRANCH_H
26 #define WSELECTORBRANCH_H
27 
28 #include <list>
29 #include <memory>
30 #include <vector>
31 
32 #include "../kernel/WRMBranch.h"
33 #include "WSelectorRoi.h"
34 
35 /**
36  * TODO(schurade): Document this!
37  */
39 {
40 public:
41  /**
42  * constructor
43  * \param fibers pointer to the fiber dataset to work on
44  * \param branch pointer to the branch object in the roi manager
45  */
46  WSelectorBranch( std::shared_ptr< const WDataSetFibers > fibers, std::shared_ptr< WRMBranch > branch );
47 
48  /**
49  * destructor
50  */
52 
53  /**
54  * getter
55  * \return the bitfield that is created from all rois in this branch
56  */
57  std::shared_ptr< std::vector<bool> > getBitField();
58 
59  /**
60  * getter
61  * \return pointer to the branch object, mainly for deletion and update purposes
62  */
63  std::shared_ptr<WRMBranch> getBranch();
64 
65  /**
66  * adds a roi to the branch
67  * \param roi
68  */
69  void addRoi( std::shared_ptr< WSelectorRoi > roi );
70 
71 
72  /**
73  * Queries the ROIs.
74  *
75  * \return A copy of the list of WSelectorRois
76  */
77  std::list< std::shared_ptr< WSelectorRoi > > getROIs();
78 
79  /**
80  * Removes a roi fromt he branch.
81  *
82  * \param roi
83  */
84  void removeRoi( osg::ref_ptr< WROI > roi );
85 
86  /**
87  * Checks if empty.
88  *
89  * \return true when this branch contains no rois
90  */
91  bool empty();
92 
93  /**
94  * Sets the dirty flag.
95  */
96  void setDirty();
97 
98  /**
99  * Checks if branch is dirty.
100  *
101  * \return true if dirty
102  */
103  bool dirty();
104 
105  /**
106  * Return the current branch color.
107  *
108  * \return the color
109  */
110  WColor getBranchColor() const;
111 protected:
112 private:
113  /**
114  * updates the output bitfield with the information from all rois in this branch
115  */
116  void recalculate();
117 
118  /**
119  * Pointer to the fiber data set
120  */
121  std::shared_ptr< const WDataSetFibers > m_fibers;
122 
123  /**
124  * size of the fiber dataset, stored for convinience
125  */
126  size_t m_size;
127 
128  bool m_dirty; //!< dirty flag
129 
130  /**
131  * the bitfield given to the outside world
132  */
133  std::shared_ptr< std::vector< bool > > m_bitField;
134 
135  /**
136  * the bitfield we work on
137  */
138  std::shared_ptr< std::vector< bool > > m_workerBitfield;
139 
140  /**
141  * list of rois in this branch
142  */
143  std::list< std::shared_ptr< WSelectorRoi > > m_rois;
144 
145  /**
146  * pointer to the branch object in the roi manager
147  */
148  std::shared_ptr< WRMBranch > m_branch;
149 
150  std::shared_ptr< boost::function< void() > > m_changeSignal; //!< Signal that can be used to update the selector branch
151  std::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector branch
152 };
153 
154 inline std::shared_ptr< std::vector<bool> > WSelectorBranch::getBitField()
155 {
156  if( m_dirty )
157  {
158  recalculate();
159  }
160  return m_bitField;
161 }
162 
163 inline std::shared_ptr< WRMBranch > WSelectorBranch::getBranch()
164 {
165  return m_branch;
166 }
167 
169 {
170  return m_rois.empty();
171 }
172 
174 {
175  return m_dirty;
176 }
177 
178 #endif // WSELECTORBRANCH_H
TODO(schurade): Document this!
void setDirty()
Sets the dirty flag.
WColor getBranchColor() const
Return the current branch color.
std::shared_ptr< const WDataSetFibers > m_fibers
Pointer to the fiber data set.
WSelectorBranch(std::shared_ptr< const WDataSetFibers > fibers, std::shared_ptr< WRMBranch > branch)
constructor
std::shared_ptr< boost::function< void() > > m_changeRoiSignal
Signal that can be used to update the selector branch.
std::shared_ptr< boost::function< void() > > m_changeSignal
Signal that can be used to update the selector branch.
std::shared_ptr< WRMBranch > m_branch
pointer to the branch object in the roi manager
~WSelectorBranch()
destructor
bool m_dirty
dirty flag
std::shared_ptr< WRMBranch > getBranch()
getter
std::shared_ptr< std::vector< bool > > getBitField()
getter
bool dirty()
Checks if branch is dirty.
std::shared_ptr< std::vector< bool > > m_workerBitfield
the bitfield we work on
size_t m_size
size of the fiber dataset, stored for convinience
void removeRoi(osg::ref_ptr< WROI > roi)
Removes a roi fromt he branch.
std::list< std::shared_ptr< WSelectorRoi > > m_rois
list of rois in this branch
void addRoi(std::shared_ptr< WSelectorRoi > roi)
adds a roi to the branch
std::shared_ptr< std::vector< bool > > m_bitField
the bitfield given to the outside world
void recalculate()
updates the output bitfield with the information from all rois in this branch
std::list< std::shared_ptr< WSelectorRoi > > getROIs()
Queries the ROIs.
bool empty()
Checks if empty.