28 #include <osg/ref_ptr>
29 #include <osgGA/GUIActionAdapter>
30 #include <osgGA/GUIEventAdapter>
32 #include "WEEGEvent.h"
33 #include "WEEGViewHandler.h"
34 #include "core/common/WAssert.h"
35 #include "core/common/WFlag.h"
36 #include "core/common/WPropertyTypes.h"
37 #include "core/common/WPropertyVariable.h"
38 #include "core/common/exceptions/WOutOfBounds.h"
39 #include "core/dataHandler/WDataSetDipoles.h"
40 #include "core/dataHandler/WEEG2.h"
41 #include "core/graphicsEngine/WGEGroupNode.h"
46 WPropDouble timeRange,
50 WPropDouble ySensitivity,
51 WPropDouble colorSensitivity,
52 std::shared_ptr<
WFlag< std::shared_ptr< WEEGEvent > > > event,
53 osg::ref_ptr< WGEGroupNode > eventParentNode,
54 std::shared_ptr< WEEG2 > eeg,
55 std::size_t segmentID,
56 WPropBool snapToDipole,
57 WPropBool proofOfConcept,
58 std::shared_ptr< WDataSetDipoles > dipoles )
59 : m_labelsWidth( labelsWidth ),
61 m_timeRange( timeRange ),
62 m_graphWidth( graphWidth ),
64 m_ySpacing( ySpacing ),
65 m_ySensitivity( ySensitivity ),
66 m_colorSensitivity( colorSensitivity ),
68 m_eventParentNode( eventParentNode ),
70 m_segmentID( segmentID ),
71 m_snapToDipole( snapToDipole ),
72 m_proofOfConcept( proofOfConcept ),
75 WAssert( eventParentNode.valid(),
"No Event Parent Node" );
76 WAssert( eeg,
"No EEG data" );
77 WAssert( segmentID < eeg->getNumberOfSegments(),
"Invalid segment number" );
84 switch( ea.getEventType() )
86 case osgGA::GUIEventAdapter::PUSH:
88 if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
93 else if( ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON
94 || ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
105 case osgGA::GUIEventAdapter::DRAG:
107 if( ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
113 if( ea.getButtonMask() & ( osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON | osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON ) )
115 if( ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON )
122 if( ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
126 if( labelsWidth <
m_oldX && labelsWidth < ea.getX() )
141 case osgGA::GUIEventAdapter::RESIZE:
150 case osgGA::GUIEventAdapter::SCROLL:
153 switch( ea.getScrollingMotion() )
155 case osgGA::GUIEventAdapter::SCROLL_UP:
160 case osgGA::GUIEventAdapter::SCROLL_DOWN:
165 case osgGA::GUIEventAdapter::SCROLL_2D:
167 delta = ea.getScrollingDeltaY();
179 switch( ea.getButtonMask() )
181 case osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON:
189 case osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON:
192 const float addend = -0.001f * delta;
196 m_yPos->set(
m_yPos->get() * ( 1.0f + addend ) + ea.getY() * addend );
230 bool handled =
false;
232 if( labelsWidth <= x )
236 std::shared_ptr< WEEGEvent > event(
new WEEGEvent(
A special time position in an EEG recording with corresponding data.
bool markEvent(float x)
Update the event position according to the clicked position.
std::size_t m_segmentID
number of the segment
WPropDouble m_colorSensitivity
The sensitivity of the color map as property.
WPropInt m_graphWidth
the width of the graph in pixel as property
float m_oldY
previous mouse y position
WPropDouble m_timePos
the time position in seconds where to start the graph at the left edge as property
WPropDouble m_ySpacing
the distance between two curves of the graph in pixel as property
WPropDouble m_timeRange
the width of the graph in seconds as property
WPropDouble m_yPos
the y position in pixel at the lower edge as property
std::shared_ptr< WDataSetDipoles > m_dipoles
Pointer to the loaded dipoles dataset.
WEEGViewHandler(WPropInt labelsWidth, WPropDouble timePos, WPropDouble timeRange, WPropInt graphWidth, WPropDouble yPos, WPropDouble ySpacing, WPropDouble ySensitivity, WPropDouble colorSensitivity, std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event, osg::ref_ptr< WGEGroupNode > eventParentNode, std::shared_ptr< WEEG2 > eeg, std::size_t segmentID, WPropBool snapToDipole, WPropBool proofOfConcept, std::shared_ptr< WDataSetDipoles > dipoles)
Constructor.
WPropInt m_labelsWidth
the width of the label display in pixel as property
WPropDouble m_ySensitivity
the sensitivity of the graph in microvolt per pixel as property
osg::ref_ptr< WGEGroupNode > m_eventParentNode
parent node, where an marked event position is inserted and removed from
float m_oldX
previous mouse x position
std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event
event marking a special time position as WFlag
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &)
Handle events.
WPropBool m_proofOfConcept
Property determining whether we only show the proof of concept or the real dipoles.
std::shared_ptr< WEEG2 > m_eeg
pointer to the loaded EEG dataset
WPropBool m_snapToDipole
Property determining whether the selected time position should be snapped to an active dipole.
Class to have a simple notification/condition system for simple flags.
Indicates invalid element access of a container.