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
afa6529b
Commit
afa6529b
authored
Jan 29, 2010
by
Mathias Goldau
Browse files
[MERGE]
parents
4e1eab9d
f7438892
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
508 additions
and
27 deletions
+508
-27
src/graphicsEngine/WEvent.cpp
src/graphicsEngine/WEvent.cpp
+50
-0
src/graphicsEngine/WEvent.h
src/graphicsEngine/WEvent.h
+85
-0
src/graphicsEngine/WGE2DManipulator.cpp
src/graphicsEngine/WGE2DManipulator.cpp
+2
-2
src/graphicsEngine/WGE2DManipulator.h
src/graphicsEngine/WGE2DManipulator.h
+2
-2
src/graphicsEngine/WGEViewer.cpp
src/graphicsEngine/WGEViewer.cpp
+9
-1
src/graphicsEngine/WGEViewer.h
src/graphicsEngine/WGEViewer.h
+13
-0
src/graphicsEngine/WMarkHandler.cpp
src/graphicsEngine/WMarkHandler.cpp
+85
-0
src/graphicsEngine/WMarkHandler.h
src/graphicsEngine/WMarkHandler.h
+82
-0
src/graphicsEngine/WROI.h
src/graphicsEngine/WROI.h
+2
-3
src/graphicsEngine/WROIBox.cpp
src/graphicsEngine/WROIBox.cpp
+28
-8
src/graphicsEngine/WROIBox.h
src/graphicsEngine/WROIBox.h
+37
-4
src/gui/WCustomWidget.h
src/gui/WCustomWidget.h
+14
-1
src/gui/qt4/WQtCustomDockWidget.cpp
src/gui/qt4/WQtCustomDockWidget.cpp
+5
-0
src/gui/qt4/WQtCustomDockWidget.h
src/gui/qt4/WQtCustomDockWidget.h
+7
-0
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
+1
-1
src/modules/eegView/WMEEGView.cpp
src/modules/eegView/WMEEGView.cpp
+65
-4
src/modules/eegView/WMEEGView.h
src/modules/eegView/WMEEGView.h
+21
-1
No files found.
src/graphicsEngine/WEvent.cpp
0 → 100644
View file @
afa6529b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WEvent.h"
WEvent
::
WEvent
(
double
time
)
:
m_time
(
time
)
{
}
void
WEvent
::
setTime
(
double
time
)
{
m_time
=
time
;
}
double
WEvent
::
getTime
()
const
{
return
m_time
;
}
void
WEvent
::
setNode
(
osg
::
ref_ptr
<
osg
::
Node
>
node
)
{
m_node
=
node
;
}
osg
::
ref_ptr
<
osg
::
Node
>
WEvent
::
getNode
()
const
{
return
m_node
;
}
src/graphicsEngine/WEvent.h
0 → 100644
View file @
afa6529b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEVENT_H
#define WEVENT_H
#include <osg/Node>
/**
* This class marks a special time position in an EEG or MEG recording.
*/
class
WEvent
{
public:
/**
* Constructor
*
* \param time sets the time position
*/
explicit
WEvent
(
double
time
);
/**
* Set the time position
*
* \param time time position
*/
void
setTime
(
double
time
);
/**
* Get the time position
*
* \return time position
*/
double
getTime
()
const
;
/**
* Set the OSG-Node representing the event
*
* \param node OSG-Node as ref_ptr
*/
void
setNode
(
osg
::
ref_ptr
<
osg
::
Node
>
node
);
/**
* Get the OSG-Node representing the event
*
* \return OSG-Node as ref_ptr
*/
osg
::
ref_ptr
<
osg
::
Node
>
getNode
()
const
;
protected:
private:
/**
* time position
*/
double
m_time
;
/**
* OSG-Node representing the event
*/
osg
::
ref_ptr
<
osg
::
Node
>
m_node
;
};
#endif // WEVENT_H
src/graphicsEngine/WGE2DManipulator.cpp
View file @
afa6529b
...
...
@@ -26,7 +26,7 @@
WGE2DManipulator
::
WGE2DManipulator
()
:
m_positionX
(
0
.0
),
:
m_positionX
(
-
64
.0
),
m_positionY
(
0.0
),
m_zoom
(
1.0
)
{
...
...
@@ -63,7 +63,7 @@ osg::Matrixd WGE2DManipulator::getInverseMatrix() const
void
WGE2DManipulator
::
home
(
const
osgGA
::
GUIEventAdapter
&
/*ea*/
,
osgGA
::
GUIActionAdapter
&
us
)
// NOLINT We can not change the interface of OSG
{
m_positionX
=
0
.0
;
m_positionX
=
-
64
.0
;
m_positionY
=
0.0
;
m_zoom
=
1.0
;
...
...
src/graphicsEngine/WGE2DManipulator.h
View file @
afa6529b
...
...
@@ -93,7 +93,7 @@ public:
/**
* Handle events
*
* \param ea event class for storing
K
eyboard, mouse and window events
* \param ea event class for storing
k
eyboard, mouse and window events
* \param us the action adapter used to request actions of the GUI
* \return true if handled, false otherwise
*/
...
...
@@ -149,7 +149,7 @@ private:
/**
* Handles events related to zooming.
*
* \param ea event class for storing
K
eyboard, mouse and window events
* \param ea event class for storing
k
eyboard, mouse and window events
*/
bool
zoom
(
const
osgGA
::
GUIEventAdapter
&
ea
);
...
...
src/graphicsEngine/WGEViewer.cpp
View file @
afa6529b
...
...
@@ -60,15 +60,18 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, i
m_View
->
setCamera
(
new
WGECamera
(
width
,
height
,
projectionMode
)
);
m_View
->
getCamera
()
->
setGraphicsContext
(
m_GraphicsContext
);
// camera manipulator
switch
(
projectionMode
)
{
case
(
WGECamera
::
ORTHOGRAPHIC
):
case
(
WGECamera
::
PERSPECTIVE
):
// camera manipulator
m_View
->
setCameraManipulator
(
new
WGEZoomTrackballManipulator
()
);
break
;
case
(
WGECamera
::
TWO_D
):
m_View
->
setCameraManipulator
(
new
WGE2DManipulator
()
);
m_markHandler
=
new
WMarkHandler
();
m_View
->
addEventHandler
(
m_markHandler
);
break
;
default:
throw
WGEInitFailed
(
"Unknown projection mode"
);
...
...
@@ -165,6 +168,11 @@ osg::ref_ptr< WPickHandler > WGEViewer::getPickHandler()
return
m_pickHandler
;
}
osg
::
ref_ptr
<
WMarkHandler
>
WGEViewer
::
getMarkHandler
()
const
{
return
m_markHandler
;
}
void
WGEViewer
::
reset
()
{
m_View
->
home
();
...
...
src/graphicsEngine/WGEViewer.h
View file @
afa6529b
...
...
@@ -44,6 +44,7 @@
#include "WGEGraphicsWindow.h"
#include "WGECamera.h"
#include "WMarkHandler.h"
#include "WPickHandler.h"
...
...
@@ -164,6 +165,13 @@ public:
*/
osg
::
ref_ptr
<
WPickHandler
>
getPickHandler
();
/**
* Getter for the mark handler
*
* \return the mark handler
*/
osg
::
ref_ptr
<
WMarkHandler
>
getMarkHandler
()
const
;
protected:
/**
* The OpenSceneGraph view used in this (Composite)Viewer.
...
...
@@ -180,6 +188,11 @@ protected:
*/
osg
::
ref_ptr
<
WPickHandler
>
m_pickHandler
;
/**
* Pointer to the mark handler of the viewer.
*/
osg
::
ref_ptr
<
WMarkHandler
>
m_markHandler
;
private:
};
...
...
src/graphicsEngine/WMarkHandler.cpp
0 → 100644
View file @
afa6529b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WMarkHandler.h"
WMarkHandler
::
WMarkHandler
()
:
m_positionFlag
(
new
WCondition
,
-
1.0
)
{
}
WFlag
<
double
>*
WMarkHandler
::
getPositionFlag
()
{
return
&
m_positionFlag
;
}
WMarkHandler
::~
WMarkHandler
()
{
}
bool
WMarkHandler
::
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
)
{
bool
handled
=
false
;
switch
(
ea
.
getEventType
()
)
{
case
osgGA
::
GUIEventAdapter
::
PUSH
:
case
osgGA
::
GUIEventAdapter
::
DRAG
:
if
(
ea
.
getButtonMask
()
==
osgGA
::
GUIEventAdapter
::
RIGHT_MOUSE_BUTTON
)
{
handled
=
calculateNewPosition
(
ea
,
aa
);
}
break
;
default:
// do nothing
break
;
}
return
handled
;
}
bool
WMarkHandler
::
calculateNewPosition
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
)
{
bool
handled
=
false
;
osg
::
View
*
view
=
aa
.
asView
();
if
(
view
)
{
osg
::
Camera
*
camera
=
view
->
getCamera
();
if
(
camera
)
{
osg
::
Matrixd
matrix
=
camera
->
getViewMatrix
();
matrix
.
postMult
(
camera
->
getProjectionMatrix
()
);
if
(
camera
->
getViewport
()
)
{
matrix
.
postMult
(
camera
->
getViewport
()
->
computeWindowMatrix
()
);
}
osg
::
Vec3d
selectedPoint
=
osg
::
Vec3d
(
ea
.
getX
(),
ea
.
getY
(),
0.0
)
*
osg
::
Matrixd
::
inverse
(
matrix
);
m_positionFlag
.
set
(
selectedPoint
.
x
()
);
handled
=
true
;
}
}
return
handled
;
}
src/graphicsEngine/WMarkHandler.h
0 → 100644
View file @
afa6529b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMARKHANDLER_H
#define WMARKHANDLER_H
#include <osgGA/GUIEventHandler>
#include "../common/WFlag.h"
/**
* Class to handle events which mark a time position in an EEG or MEG recording.
*/
class
WMarkHandler
:
public
osgGA
::
GUIEventHandler
{
public:
/**
* Constructor
*/
WMarkHandler
();
/**
* Handle events.
*
* \param ea event class for storing keyboard, mouse and window events
* \param aa the action adapter
* \return true if handled, false otherwise
*/
virtual
bool
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
);
/**
* Get the flag which contains the marked position
*
* \return the flag as pointer
*/
WFlag
<
double
>*
getPositionFlag
();
protected:
/**
* Protected destructor because this class is derived from an OSG class
*/
virtual
~
WMarkHandler
();
private:
/**
* Flag which contains the marked position
*/
WFlag
<
double
>
m_positionFlag
;
/**
* Calculate the new marked position
*
* \param ea event class for storing keyboard, mouse and window events
* \param aa the action adapter
* \return true if handled, false otherwise
*/
bool
calculateNewPosition
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
);
};
#endif // WMARKHANDLER_H
src/graphicsEngine/WROI.h
View file @
afa6529b
...
...
@@ -54,10 +54,9 @@ private:
bool
m_useColor
;
//!< Indicated whether m_color should be used for display.
/**
* updates the graphics
* \param text text info from pick
* updates the graphics. Remember that this shoudl only be called from a node callback
*/
virtual
void
updateGFX
(
std
::
string
text
)
=
0
;
virtual
void
updateGFX
()
=
0
;
};
#endif // WROI_H
src/graphicsEngine/WROIBox.cpp
View file @
afa6529b
...
...
@@ -111,7 +111,8 @@ void setVertices( osg::Vec3Array* vertices, wmath::WPosition minPos, wmath::WPos
WROIBox
::
WROIBox
(
wmath
::
WPosition
minPos
,
wmath
::
WPosition
maxPos
)
:
WROI
(),
boxId
(
maxBoxId
++
)
boxId
(
maxBoxId
++
),
needUpdate
(
false
)
{
m_minPos
=
minPos
;
m_maxPos
=
maxPos
;
...
...
@@ -122,11 +123,14 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
boost
::
shared_ptr
<
WGEViewer
>
viewer
=
ge
->
getViewerByName
(
"main"
);
assert
(
viewer
);
m_pickHandler
=
viewer
->
getPickHandler
();
m_pickHandler
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WROIBox
::
updateGFX
,
this
,
_1
)
);
m_pickHandler
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WROIBox
::
registerPick
,
this
,
_1
)
);
osg
::
Geometry
*
surfaceGeometry
=
new
osg
::
Geometry
();
m_geode
=
new
osg
::
Geode
;
m_geode
->
setUserData
(
this
);
m_geode
->
setUpdateCallback
(
new
ROIBoxNodeCallback
);
std
::
stringstream
ss
;
ss
<<
"ROIBox"
<<
boxId
;
...
...
@@ -180,16 +184,32 @@ wmath::WPosition WROIBox::getMaxPos() const
return
m_maxPos
;
}
void
WROIBox
::
registerPick
(
std
::
string
text
)
{
boost
::
unique_lock
<
boost
::
shared_mutex
>
slock
;
slock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_updateLock
);
infoText
=
text
;
needUpdate
=
true
;
void
WROIBox
::
updateGFX
(
std
::
string
text
)
slock
.
unlock
();
}
void
WROIBox
::
updateGFX
()
{
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
;
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_updateLock
);
boost
::
unique_lock
<
boost
::
shared_mutex
>
slock
;
slock
=
boost
::
unique_lock
<
boost
::
shared_mutex
>
(
m_updateLock
);
if
(
!
needUpdate
)
// exit early if we do not need an update
{
slock
.
unlock
();
return
;
}
std
::
stringstream
ss
;
ss
<<
"
\"
ROIBox"
<<
boxId
<<
"
\"
"
;
if
(
t
ext
.
find
(
"Object "
)
!=
std
::
string
::
npos
&&
t
ext
.
find
(
ss
.
str
()
)
!=
std
::
string
::
npos
)
if
(
infoT
ext
.
find
(
"Object "
)
!=
std
::
string
::
npos
&&
infoT
ext
.
find
(
ss
.
str
()
)
!=
std
::
string
::
npos
)
{
wmath
::
WPosition
newPos
(
m_pickHandler
->
getHitPosition
()
);
if
(
m_isPicked
)
...
...
@@ -210,7 +230,7 @@ void WROIBox::updateGFX( std::string text )
m_pickedPosition
=
newPos
;
m_isPicked
=
true
;
}
if
(
m_isPicked
&&
t
ext
.
find
(
"unpick"
)
!=
std
::
string
::
npos
)
if
(
m_isPicked
&&
infoT
ext
.
find
(
"unpick"
)
!=
std
::
string
::
npos
)
{
osg
::
Vec4Array
*
colors
=
new
osg
::
Vec4Array
;
colors
->
push_back
(
osg
::
Vec4
(
0.
f
,
0.
f
,
1.
f
,
0.5
f
)
);
...
...
src/graphicsEngine/WROIBox.h
View file @
afa6529b
...
...
@@ -37,7 +37,7 @@
/**
* A box representing a region of interest.
*/
class
WROIBox
:
public
WROI
class
WROIBox
:
public
WROI
,
public
osg
::
Referenced
{
public:
/**
...
...
@@ -68,11 +68,44 @@ private:
wmath
::
WPosition
m_pickedPosition
;
//!< Caches the old picked position to a allow for cmoparison
boost
::
shared_mutex
m_updateLock
;
//!< Lock to prevent concurrent threads trying to update the osg node
std
::
string
infoText
;
//!< The info text coming from the last pick.
bool
needUpdate
;
//!< Indicates whether the grafics need update due to changed text.
/**
*
updates the graph
ic
s
* \param text
text
info from pick
*
note that there was a p
ic
k
* \param text info from pick
*/
virtual
void
updateGFX
(
std
::
string
text
);
void
registerPick
(
std
::
string
text
);
/**
* updates the graphics
*/
void
updateGFX
();
/**
* Node callback to handle updates properly
*/
class
ROIBoxNodeCallback
:
public
osg
::
NodeCallback
{
public:
// NOLINT
/**
* operator ()
*
* \param node the osg node
* \param nv the node visitor
*/
virtual
void
operator
()(
osg
::
Node
*
node
,
osg
::
NodeVisitor
*
nv
)
{
osg
::
ref_ptr
<
WROIBox
>
module
=
static_cast
<
WROIBox
*
>
(
node
->
getUserData
()
);
if
(
module
)
{
module
->
updateGFX
();
}
traverse
(
node
,
nv
);
}
};
};
#endif // WROIBOX_H
src/gui/WCustomWidget.h
View file @
afa6529b
...
...
@@ -25,7 +25,13 @@
#ifndef WCUSTOMWIDGET_H
#define WCUSTOMWIDGET_H
#include "../graphicsEngine/WGEGroupNode.h"
#include <boost/shared_ptr.hpp>
#include <osg/ref_ptr>
class
WGEGroupNode
;
class
WGEViewer
;
/**
* Custom widget which is created by a module to display custom information.
...
...
@@ -45,6 +51,13 @@ public:
*/
virtual
osg
::
ref_ptr
<
WGEGroupNode
>
getScene
()
const
=
0
;
/**
* Get the viewer which is used
*
* \return the viewer as boost::shard_ptr
*/
virtual
boost
::
shared_ptr
<
WGEViewer
>
getViewer
()
const
=
0
;
protected:
private:
};
...
...
src/gui/qt4/WQtCustomDockWidget.cpp
View file @
afa6529b
...
...
@@ -50,6 +50,11 @@ osg::ref_ptr< WGEGroupNode > WQtCustomDockWidget::getScene() const
return
m_scene
;
}
boost
::
shared_ptr
<
WGEViewer
>
WQtCustomDockWidget
::
getViewer
()
const
{
return
m_glWidget
->
getViewer
();
}
void
WQtCustomDockWidget
::
increaseUseCount
()
{
++
m_useCount
;
...
...
src/gui/qt4/WQtCustomDockWidget.h
View file @
afa6529b
...
...
@@ -56,6 +56,13 @@ public:
*/
virtual
osg
::
ref_ptr
<
WGEGroupNode
>
getScene
()
const
;
/**
* Get the viewer which is used by the GL widget
*
* \return the viewer as boost::shard_ptr
*/
virtual
boost
::
shared_ptr
<
WGEViewer
>
getViewer
()
const
;
/**
* Notify the widget that another module needs it.
*/
...
...
src/gui/qt4/datasetbrowser/WQtDatasetBrowser.cpp
View file @
afa6529b
...
...
@@ -253,7 +253,7 @@ void WQtDatasetBrowser::selectTreeItem()
module
=
(
(
WQtModuleTreeItem
*
)
m_treeWidget
->
selectedItems
().
at
(
0
)
)
->
getModule
();
}
// every module may have compatibles: create
ribbon menu
entry
// every module may have compatibles: create
toolBar
entry
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>
comps
=
WModuleFactory
::
getModuleFactory
()
->
getCompatiblePrototypes
(
module
);
for
(
std
::
set
<
boost
::
shared_ptr
<
WModule
>
>::
iterator
iter
=
comps
.
begin
();
iter
!=
comps
.
end
();
++
iter
)
{
...
...
src/modules/eegView/WMEEGView.cpp
View file @
afa6529b
...
...
@@ -32,7 +32,9 @@ WMEEGView::WMEEGView()
:
WModule
(),
m_dataChanged
(
new
WCondition
,
true
),
m_isActive
(
new
WCondition
,
true
),