OpenWalnut  1.5.0dev
WLineStripCallback.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 WLINESTRIPCALLBACK_H
26 #define WLINESTRIPCALLBACK_H
27 
28 #include <cstddef>
29 #include <memory>
30 
31 #include <osg/Drawable>
32 #include <osg/NodeVisitor>
33 
34 #include "core/common/WPropertyTypes.h"
35 #include "core/dataHandler/WEEG2Segment.h"
36 
37 
38 /**
39  * OSG Update Callback to update the EEG graph of one channel by changing the
40  * vertex array of the line strip.
41  */
43 {
44 public:
45  /**
46  * Constructor
47  *
48  * \param channelID the number of the channel
49  * \param timePos the time position in seconds where to start the graph
50  * at the left edge as property
51  * \param timeRange the width of the graph in seconds as property
52  * \param segment pointer to the EEG segment
53  * \param samplingRate sampling rate used by the recording
54  */
55  WLineStripCallback( std::size_t channelID,
56  WPropDouble timePos,
57  WPropDouble timeRange,
58  std::shared_ptr< WEEG2Segment > segment,
59  double samplingRate );
60 
61  /**
62  * Callback method called by the NodeVisitor.
63  * Changes the vertex array of the line strip according to the properties.
64  *
65  * \param drawable The drawable this callback is connected to. Should be
66  * a Geometry.
67  */
68  virtual void update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawable );
69 
70 protected:
71 private:
72  /**
73  * the number of the channel
74  */
75  const std::size_t m_channelID;
76 
77  /**
78  * the time position in seconds where to start the graph at the left edge
79  * which is currently used
80  */
82 
83  /**
84  * the width of the graph in seconds which is currently used
85  */
87 
88  /**
89  * the time position in seconds where to start the graph at the left edge as
90  * property
91  */
92  WPropDouble m_timePos;
93 
94  /**
95  * the width of the graph in seconds as property
96  */
97  WPropDouble m_timeRange;
98 
99  /**
100  * pointer to the EEG segment
101  */
102  std::shared_ptr< WEEG2Segment > m_segment;
103 
104  /**
105  * sampling rate used by the recording
106  */
108 
109  /**
110  * Convert the given double value to std::size_t and clamp it into the given
111  * range
112  *
113  * \param value value to convert
114  * \param min minimum of the valid range
115  * \param max maximum of the valid range
116  * \return converted value
117  */
118  std::size_t clampToRange( double value, std::size_t min, std::size_t max ) const;
119 };
120 
121 #endif // WLINESTRIPCALLBACK_H
OSG Update Callback to update the EEG graph of one channel by changing the vertex array of the line s...
std::size_t clampToRange(double value, std::size_t min, std::size_t max) const
Convert the given double value to std::size_t and clamp it into the given range.
WLineStripCallback(std::size_t channelID, WPropDouble timePos, WPropDouble timeRange, std::shared_ptr< WEEG2Segment > segment, double samplingRate)
Constructor.
double m_currentTimeRange
the width of the graph in seconds which is currently used
double m_currentTimePos
the time position in seconds where to start the graph at the left edge which is currently used
WPropDouble m_timePos
the time position in seconds where to start the graph at the left edge as property
double m_samplingRate
sampling rate used by the recording
virtual void update(osg::NodeVisitor *, osg::Drawable *drawable)
Callback method called by the NodeVisitor.
std::shared_ptr< WEEG2Segment > m_segment
pointer to the EEG segment
const std::size_t m_channelID
the number of the channel
WPropDouble m_timeRange
the width of the graph in seconds as property