OpenWalnut 1.2.5
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WSELECTORBRANCH_H 00026 #define WSELECTORBRANCH_H 00027 00028 #include <list> 00029 #include <vector> 00030 00031 #include "WSelectorRoi.h" 00032 #include "../kernel/WRMBranch.h" 00033 00034 /** 00035 * TODO(schurade): Document this! 00036 */ 00037 class WSelectorBranch 00038 { 00039 public: 00040 /** 00041 * constructor 00042 * \param fibers pointer to the fiber dataset to work on 00043 * \param branch pointer to the branch object in the roi manager 00044 */ 00045 WSelectorBranch( boost::shared_ptr< const WDataSetFibers > fibers, boost::shared_ptr< WRMBranch > branch ); 00046 00047 /** 00048 * destructor 00049 */ 00050 ~WSelectorBranch(); 00051 00052 /** 00053 * getter 00054 * \return the bitfield that is created from all rois in this branch 00055 */ 00056 boost::shared_ptr< std::vector<bool> > getBitField(); 00057 00058 /** 00059 * getter 00060 * \return pointer to the branch object, mainly for deletion and update purposes 00061 */ 00062 boost::shared_ptr<WRMBranch> getBranch(); 00063 00064 /** 00065 * adds a roi to the branch 00066 * \param roi 00067 */ 00068 void addRoi( boost::shared_ptr< WSelectorRoi > roi ); 00069 00070 00071 /** 00072 * Queries the ROIs. 00073 * 00074 * \return A copy of the list of WSelectorRois 00075 */ 00076 std::list< boost::shared_ptr< WSelectorRoi > > getROIs(); 00077 00078 /** 00079 * Removes a roi fromt he branch. 00080 * 00081 * \param roi 00082 */ 00083 void removeRoi( osg::ref_ptr< WROI > roi ); 00084 00085 /** 00086 * Checks if empty. 00087 * 00088 * \return true when this branch contains no rois 00089 */ 00090 bool empty(); 00091 00092 /** 00093 * Sets the dirty flag. 00094 */ 00095 void setDirty(); 00096 00097 /** 00098 * Checks if branch is dirty. 00099 * 00100 * \return true if dirty 00101 */ 00102 bool dirty(); 00103 00104 protected: 00105 /** 00106 * function gets called when the color property of the roi branch has changed, it will write this color 00107 * into the custom color array of the fiber dataset 00108 */ 00109 void colorChanged(); 00110 private: 00111 /** 00112 * updates the output bitfield with the information from all rois in this branch 00113 */ 00114 void recalculate(); 00115 00116 /** 00117 * Pointer to the fiber data set 00118 */ 00119 boost::shared_ptr< const WDataSetFibers > m_fibers; 00120 00121 /** 00122 * size of the fiber dataset, stored for convinience 00123 */ 00124 size_t m_size; 00125 00126 bool m_dirty; //!< dirty flag 00127 00128 /** 00129 * the bitfield given to the outside world 00130 */ 00131 boost::shared_ptr< std::vector< bool > > m_bitField; 00132 00133 /** 00134 * the bitfield we work on 00135 */ 00136 boost::shared_ptr< std::vector< bool > > m_workerBitfield; 00137 00138 /** 00139 * list of rois in this branch 00140 */ 00141 std::list< boost::shared_ptr< WSelectorRoi > > m_rois; 00142 00143 /** 00144 * pointer to the branch object in the roi manager 00145 */ 00146 boost::shared_ptr< WRMBranch > m_branch; 00147 00148 boost::shared_ptr< boost::function< void() > > m_changeSignal; //!< Signal that can be used to update the selector branch 00149 boost::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector branch 00150 }; 00151 00152 inline boost::shared_ptr< std::vector<bool> > WSelectorBranch::getBitField() 00153 { 00154 if( m_dirty ) 00155 { 00156 recalculate(); 00157 } 00158 return m_bitField; 00159 } 00160 00161 inline boost::shared_ptr< WRMBranch > WSelectorBranch::getBranch() 00162 { 00163 return m_branch; 00164 } 00165 00166 inline bool WSelectorBranch::empty() 00167 { 00168 return m_rois.empty(); 00169 } 00170 00171 inline bool WSelectorBranch::dirty() 00172 { 00173 return m_dirty; 00174 } 00175 00176 #endif // WSELECTORBRANCH_H