31 #include <osg/Drawable>
32 #include <osg/Geometry>
33 #include <osg/NodeVisitor>
34 #include <osg/PrimitiveSet>
37 #include "WLineStripCallback.h"
38 #include "core/common/WPropertyTypes.h"
39 #include "core/common/WPropertyVariable.h"
40 #include "core/dataHandler/WEEG2Segment.h"
41 #include "core/dataHandler/WEEGValueMatrix.h"
45 WPropDouble timeRange,
46 std::shared_ptr< WEEG2Segment > segment,
48 : m_channelID( channelID ),
49 m_currentTimePos( 0.0 ),
50 m_currentTimeRange( -1.0 ),
52 m_timeRange( timeRange ),
54 m_samplingRate( samplingRate )
65 osg::Geometry* geometry =
static_cast< osg::Geometry*
>( drawable );
68 const std::size_t nbSamples =
m_segment->getNumberOfSamples();
80 osg::Vec3Array* vertices =
new osg::Vec3Array();
81 vertices->reserve( endSample - startSample );
84 std::size_t start = startSample;
85 std::size_t end = std::min( endSample, currentStartSample );
88 const std::size_t length = end - start;
89 std::shared_ptr< const WEEGValueMatrix > values =
m_segment->getValues( start, length );
90 for( std::size_t i = 0; i < length; ++i )
97 start = std::max( startSample, currentStartSample );
98 end = std::min( endSample, currentEndSample );
101 const osg::Vec3Array* currentVertices =
static_cast< osg::Vec3Array*
>( geometry->getVertexArray() );
102 vertices->insert( vertices->end(),
103 currentVertices->begin() + ( start - currentStartSample ),
104 currentVertices->begin() + ( end - currentStartSample ) );
108 start = std::max( startSample, currentEndSample );
112 const std::size_t length = end - start;
113 std::shared_ptr< const WEEGValueMatrix > values =
m_segment->getValues( start, length );
114 for( std::size_t i = 0; i < length; ++i )
120 geometry->setVertexArray( vertices );
122 osg::DrawArrays* primitiveSet =
static_cast< osg::DrawArrays*
>( geometry->getPrimitiveSet( 0 ) );
123 primitiveSet->setCount( endSample - startSample );
133 std::size_t out = ( value > 0.0 ) ? value : 0u;
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