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 WROI_H 00026 #define WROI_H 00027 00028 #include <list> 00029 #include <string> 00030 00031 #include <boost/signals2/signal.hpp> 00032 #include <boost/signals2/connection.hpp> 00033 00034 #include <osg/Geode> 00035 00036 #include "../common/WProperties.h" 00037 00038 00039 #include "WExportWGE.h" 00040 00041 class WPickHandler; 00042 00043 /** 00044 * Superclass for different ROI (region of interest) types. 00045 */ 00046 class WGE_EXPORT WROI : public osg::Geode 00047 { 00048 public: 00049 WROI(); 00050 00051 /** 00052 * Need virtual destructor because of virtual function. 00053 */ 00054 virtual ~WROI(); 00055 00056 /** 00057 * sets the NOT flag 00058 * 00059 * \param isNot 00060 */ 00061 void setNot( bool isNot = true ); 00062 00063 /** 00064 * getter for NOT flag 00065 * 00066 * \return the flag 00067 */ 00068 bool isNot(); 00069 00070 /** 00071 * getter 00072 * 00073 * \return the active flag 00074 */ 00075 bool active(); 00076 00077 /** 00078 * setter 00079 * 00080 * \param active 00081 */ 00082 void setActive( bool active ); 00083 00084 /** 00085 * hides the roi in the scene 00086 */ 00087 void hide(); 00088 00089 /** 00090 * unhides the roi in the scene 00091 */ 00092 void unhide(); 00093 00094 /** 00095 * Getter for modified flag 00096 * \return the dirty flag 00097 */ 00098 bool dirty(); 00099 00100 /** 00101 * sets the dirty flag 00102 */ 00103 void setDirty(); 00104 00105 /** 00106 * Getter 00107 * \return the properties object for this roi 00108 */ 00109 boost::shared_ptr< WProperties > getProperties(); 00110 00111 /** 00112 * Add a specified notifier to the list of default notifiers which get connected to each roi. 00113 * 00114 * \param notifier the notifier function 00115 */ 00116 void addROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier ); 00117 00118 /** 00119 * Remove a specified notifier from the list of default notifiers which get connected to each roi. 00120 * 00121 * \param notifier the notifier function 00122 */ 00123 void removeROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier ); 00124 00125 00126 protected: 00127 /** 00128 * initializes the roi's properties 00129 */ 00130 void properties(); 00131 00132 /** 00133 * callback when a property gets changed 00134 */ 00135 void propertyChanged(); 00136 00137 /** 00138 * signals a roi change to all subscribers 00139 */ 00140 void signalRoiChange(); 00141 00142 00143 osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box. 00144 00145 /** 00146 * the property object for the module 00147 */ 00148 boost::shared_ptr< WProperties > m_properties; 00149 00150 /** 00151 * dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating 00152 * since these customers get the update notification via callback 00153 */ 00154 WPropBool m_dirty; 00155 00156 /** 00157 * indicates if the roi is active 00158 */ 00159 WPropBool m_active; 00160 00161 /** 00162 * indicates if the roi is visible in the scene 00163 */ 00164 WPropBool m_show; 00165 00166 /** 00167 * indicates if the roi is negated 00168 */ 00169 WPropBool m_not; 00170 00171 /** 00172 * threshold for an arbitrary roi 00173 */ 00174 WPropDouble m_threshold; 00175 00176 /** 00177 * A color for painting the roi in the scene 00178 */ 00179 WPropColor m_color; 00180 00181 /** 00182 * The notifiers connected to added rois by default. 00183 */ 00184 std::list< boost::shared_ptr< boost::function< void() > > > m_changeNotifiers; 00185 00186 00187 /** 00188 * Lock for associated notifiers set. 00189 */ 00190 boost::shared_mutex m_associatedNotifiersLock; 00191 00192 private: 00193 /** 00194 * updates the graphics 00195 */ 00196 virtual void updateGFX() = 0; 00197 }; 00198 00199 #endif // WROI_H