OpenWalnut  1.5.0dev
WHeadSurfaceCallback.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 WHEADSURFACECALLBACK_H
26 #define WHEADSURFACECALLBACK_H
27 
28 #include <cstddef>
29 #include <memory>
30 #include <vector>
31 
32 #include <osg/Drawable>
33 
34 #include "WEEGEvent.h"
35 #include "core/common/WFlag.h"
36 #include "core/common/WPropertyTypes.h"
37 
38 
39 /**
40  * OSG Update Callback to change the color of a head surface by changing its 1D
41  * texture coordinates when an event position changed.
42  * \note Only add it to a Geometry with a 1D texture!
43  */
45 {
46 public:
47  /**
48  * Constructor
49  *
50  * \param channelIDs the mapping from vertex indices to channel IDs
51  * \param colorSensitivity The sensitivity of the color map as property. The
52  * color map ranges from -colorSensitivity to
53  * +colorSensitivity in microvolt.
54  * \param event event marking a special time position as WFlag
55  */
56  WHeadSurfaceCallback( const std::vector< std::size_t >& channelIDs,
57  WPropDouble colorSensitivity,
58  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event );
59 
60  /**
61  * Callback method called by the NodeVisitor.
62  * Changes the color of the head surface according to the event.
63  *
64  * \param drawable The drawable this callback is connected to. Should be
65  * a Geometry with a 1D texture.
66  */
67  virtual void update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawable );
68 
69 protected:
70 private:
71  /**
72  * the sensitivity of the color map which is currently used
73  */
75 
76  /**
77  * The time position which is currently used.
78  * The color is updated if the new time from the m_event is different to
79  * this.
80  */
81  double m_currentTime;
82 
83  /**
84  * the mapping from vertex indices to channel IDs
85  */
86  const std::vector< std::size_t > m_channelIDs;
87 
88  /**
89  * The sensitivity of the color map as property. The color map ranges
90  * from -m_colorSensitivity to +m_colorSensitivity in microvolt.
91  */
92  WPropDouble m_colorSensitivity;
93 
94  /**
95  * event marking a special time position as WFlag
96  */
97  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event;
98 };
99 
100 #endif // WHEADSURFACECALLBACK_H
Class to have a simple notification/condition system for simple flags.
Definition: WFlag.h:39
OSG Update Callback to change the color of a head surface by changing its 1D texture coordinates when...
virtual void update(osg::NodeVisitor *, osg::Drawable *drawable)
Callback method called by the NodeVisitor.
WHeadSurfaceCallback(const std::vector< std::size_t > &channelIDs, WPropDouble colorSensitivity, std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event)
Constructor.
const std::vector< std::size_t > m_channelIDs
the mapping from vertex indices to channel IDs
WPropDouble m_colorSensitivity
The sensitivity of the color map as property.
std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event
event marking a special time position as WFlag
double m_currentColorSensitivity
the sensitivity of the color map which is currently used
double m_currentTime
The time position which is currently used.