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