Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
f79d06cf
Commit
f79d06cf
authored
Apr 03, 2010
by
cornimueller
Browse files
[FIX] Fixed crashing of the EEG view module when trying to display values at invalid time positions
parent
fa3d3d9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
6 deletions
+37
-6
src/dataHandler/io/WPagerEEGLibeep.cpp
src/dataHandler/io/WPagerEEGLibeep.cpp
+1
-1
src/modules/eegView/WLineStripCallback.cpp
src/modules/eegView/WLineStripCallback.cpp
+25
-5
src/modules/eegView/WLineStripCallback.h
src/modules/eegView/WLineStripCallback.h
+11
-0
No files found.
src/dataHandler/io/WPagerEEGLibeep.cpp
View file @
f79d06cf
...
@@ -123,7 +123,7 @@ boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t seg
...
@@ -123,7 +123,7 @@ boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t seg
{
{
std
::
ostringstream
stream
;
std
::
ostringstream
stream
;
stream
<<
"Could not read sample number "
<<
start
+
length
-
1
<<
" of file "
<<
m_fileName
stream
<<
"Could not read sample number "
<<
start
+
length
-
1
<<
" of file "
<<
m_fileName
<<
", it
has
only "
<<
m_nbSamples
<<
" samples"
;
<<
", it only
has
"
<<
m_nbSamples
<<
" samples"
;
throw
WOutOfBounds
(
stream
.
str
()
);
throw
WOutOfBounds
(
stream
.
str
()
);
}
}
...
...
src/modules/eegView/WLineStripCallback.cpp
View file @
f79d06cf
...
@@ -68,12 +68,17 @@ void WLineStripCallback::update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawab
...
@@ -68,12 +68,17 @@ void WLineStripCallback::update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawab
osg
::
Geometry
*
geometry
=
static_cast
<
osg
::
Geometry
*
>
(
drawable
);
osg
::
Geometry
*
geometry
=
static_cast
<
osg
::
Geometry
*
>
(
drawable
);
if
(
geometry
)
if
(
geometry
)
{
{
const
std
::
size_t
startSample
=
timePos
*
m_samplingRate
;
const
std
::
size_t
nbSamples
=
m_segment
->
getNumberOfSamples
();
const
std
::
size_t
endSample
=
std
::
ceil
(
(
timePos
+
timeRange
)
*
m_samplingRate
)
+
1
;
const
std
::
size_t
startSample
=
clampToRange
(
timePos
*
m_samplingRate
,
0u
,
nbSamples
-
1u
);
const
std
::
size_t
currentStartSample
=
m_currentTimePos
*
m_samplingRate
;
const
std
::
size_t
endSample
=
clampToRange
(
std
::
ceil
(
(
timePos
+
timeRange
)
*
m_samplingRate
)
+
1.0
,
startSample
,
nbSamples
);
const
std
::
size_t
currentStartSample
=
clampToRange
(
m_currentTimePos
*
m_samplingRate
,
0u
,
nbSamples
-
1u
);
const
std
::
size_t
currentEndSample
=
(
0.0
<=
m_currentTimeRange
)
?
const
std
::
size_t
currentEndSample
=
(
0.0
<=
m_currentTimeRange
)
?
std
::
ceil
(
(
m_currentTimePos
+
m_currentTimeRange
)
*
m_samplingRate
)
+
1
:
clampToRange
(
std
::
ceil
(
(
m_currentTimePos
+
m_currentTimeRange
)
*
m_samplingRate
)
+
1.0
,
currentStartSample
;
currentStartSample
,
nbSamples
)
:
currentStartSample
;
osg
::
Vec3Array
*
vertices
=
new
osg
::
Vec3Array
();
osg
::
Vec3Array
*
vertices
=
new
osg
::
Vec3Array
();
vertices
->
reserve
(
endSample
-
startSample
);
vertices
->
reserve
(
endSample
-
startSample
);
...
@@ -125,3 +130,18 @@ void WLineStripCallback::update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawab
...
@@ -125,3 +130,18 @@ void WLineStripCallback::update( osg::NodeVisitor* /*nv*/, osg::Drawable* drawab
m_currentTimeRange
=
timeRange
;
m_currentTimeRange
=
timeRange
;
}
}
}
}
std
::
size_t
WLineStripCallback
::
clampToRange
(
double
value
,
std
::
size_t
min
,
std
::
size_t
max
)
const
{
std
::
size_t
out
=
(
value
>
0.0
)
?
value
:
0u
;
if
(
out
<
min
)
{
out
=
min
;
}
else
if
(
max
<
out
)
{
out
=
max
;
}
return
out
;
}
src/modules/eegView/WLineStripCallback.h
View file @
f79d06cf
...
@@ -106,6 +106,17 @@ private:
...
@@ -106,6 +106,17 @@ private:
* sampling rate used by the recording
* sampling rate used by the recording
*/
*/
double
m_samplingRate
;
double
m_samplingRate
;
/**
* Convert the given double value to std::size_t and clamp it into the given
* range
*
* \param value value to convert
* \param min minimum of the valid range
* \param max maximum of the valid range
* \return converted value
*/
std
::
size_t
clampToRange
(
double
value
,
std
::
size_t
min
,
std
::
size_t
max
)
const
;
};
};
#endif // WLINESTRIPCALLBACK_H
#endif // WLINESTRIPCALLBACK_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment