OpenWalnut  1.5.0dev
WElectrodePositionCallback.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 WELECTRODEPOSITIONCALLBACK_H
26 #define WELECTRODEPOSITIONCALLBACK_H
27 
28 #include <cstddef>
29 #include <memory>
30 
31 #include <osg/Drawable>
32 #include <osg/ref_ptr>
33 #include <osgSim/ScalarsToColors>
34 
35 #include "WEEGEvent.h"
36 #include "core/common/WFlag.h"
37 #include "core/common/WPropertyTypes.h"
38 
39 
40 /**
41  * OSG Update Callback to change the color of an electrode position when the
42  * event position changed.
43  * \note Only add it to a ShapeDrawable!
44  */
46 {
47 public:
48  /**
49  * Constructor
50  *
51  * \param channelID the number of the channel
52  * \param colorSensitivity The sensitivity of the color map as property. The
53  * color map ranges from -colorSensitivity to
54  * +colorSensitivity in microvolt.
55  * \param event event marking a special time position as WFlag
56  * \param colorMap the object mapping the electrode potentials to
57  * colors
58  */
59  WElectrodePositionCallback( std::size_t channelID,
60  WPropDouble colorSensitivity,
61  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event,
62  osg::ref_ptr< const osgSim::ScalarsToColors > colorMap );
63 
64  /**
65  * Callback method called by the NodeVisitor.
66  * Changes the color of the electrode position according to the event.
67  *
68  * \param drawable The drawable this callback is connected to. Should be
69  * a ShapeDrawable.
70  */
71  virtual void update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawable );
72 
73 protected:
74 private:
75  /**
76  * the number of the channel
77  */
78  const std::size_t m_channelID;
79 
80  /**
81  * the sensitivity of the color map which is currently used
82  */
84 
85  /**
86  * The time position which is currently used.
87  * The color is updated if the new time from the m_event is different to
88  * this.
89  */
90  double m_currentTime;
91 
92  /**
93  * The sensitivity of the color map as property. The color map ranges
94  * from -m_colorSensitivity to +m_colorSensitivity in microvolt.
95  */
96  WPropDouble m_colorSensitivity;
97 
98  /**
99  * event marking a special time position as WFlag
100  */
101  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event;
102 
103  /**
104  * the ScalarsToColors object mapping the potentials at the electrodes
105  * to colors
106  */
107  const osg::ref_ptr< const osgSim::ScalarsToColors > m_colorMap;
108 };
109 
110 #endif // WELECTRODEPOSITIONCALLBACK_H
OSG Update Callback to change the color of an electrode position when the event position changed.
double m_currentTime
The time position which is currently used.
std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event
event marking a special time position as WFlag
virtual void update(osg::NodeVisitor *, osg::Drawable *drawable)
Callback method called by the NodeVisitor.
WElectrodePositionCallback(std::size_t channelID, WPropDouble colorSensitivity, std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event, osg::ref_ptr< const osgSim::ScalarsToColors > colorMap)
Constructor.
const osg::ref_ptr< const osgSim::ScalarsToColors > m_colorMap
the ScalarsToColors object mapping the potentials at the electrodes to colors
double m_currentColorSensitivity
the sensitivity of the color map which is currently used
const std::size_t m_channelID
the number of the channel
WPropDouble m_colorSensitivity
The sensitivity of the color map as property.
Class to have a simple notification/condition system for simple flags.
Definition: WFlag.h:39