OpenWalnut  1.5.0dev
WEEGViewHandler.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 WEEGVIEWHANDLER_H
26 #define WEEGVIEWHANDLER_H
27 
28 #include <cstddef>
29 #include <memory>
30 
31 #include <osg/ref_ptr>
32 #include <osgGA/GUIActionAdapter>
33 #include <osgGA/GUIEventAdapter>
34 #include <osgGA/GUIEventHandler>
35 
36 #include "WEEGEvent.h"
37 #include "core/common/WFlag.h"
38 #include "core/common/WPropertyTypes.h"
39 #include "core/dataHandler/WDataSetDipoles.h"
40 #include "core/dataHandler/WEEG2.h"
41 #include "core/graphicsEngine/WGEGroupNode.h"
42 
43 
44 /**
45  * GUI event handler class used for the 2D EEG view.
46  */
47 class WEEGViewHandler : public osgGA::GUIEventHandler
48 {
49 public:
50  /**
51  * Constructor
52  *
53  * \param labelsWidth the width of the label display in pixel as
54  * property
55  * \param timePos the time position in seconds where to start the
56  * graph at the left edge as property
57  * \param timeRange the width of the graph in seconds as property
58  * \param graphWidth the width of the graph in pixel as property
59  * \param yPos the y position in pixel at the lower edge as
60  * property
61  * \param ySpacing the distance between two curves of the graph in
62  * pixel as property
63  * \param ySensitivity the sensitivity of the graph in microvolt per
64  * pixel as property
65  * \param colorSensitivity The sensitivity of the color map as property. The
66  * color map ranges from -colorSensitivity to
67  * +colorSensitivity in microvolt.
68  * \param event event marking a special time position as WFlag
69  * \param eventParentNode parent node, where an marked event position is
70  * inserted and removed from
71  * \param eeg pointer to the loaded EEG dataset
72  * \param segmentID number of the segment
73  * \param snapToDipole Property determining whether the selected time
74  * position should be snapped to an active
75  * dipole
76  * \param proofOfConcept Property determining whether we only show the
77  * proof of concept or the real dipoles
78  * \param dipoles pointer to the loaded dipoles dataset
79  */
80  WEEGViewHandler( WPropInt labelsWidth,
81  WPropDouble timePos,
82  WPropDouble timeRange,
83  WPropInt graphWidth,
84  WPropDouble yPos,
85  WPropDouble ySpacing,
86  WPropDouble ySensitivity,
87  WPropDouble colorSensitivity,
88  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > event,
89  osg::ref_ptr< WGEGroupNode > eventParentNode,
90  std::shared_ptr< WEEG2 > eeg,
91  std::size_t segmentID,
92  WPropBool snapToDipole,
93  WPropBool proofOfConcept,
94  std::shared_ptr< WDataSetDipoles > dipoles );
95 
96  /**
97  * Handle events.
98  *
99  * \param ea event class for storing keyboard, mouse and window events
100  * \return true if handled, false otherwise
101  */
102  virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /*aa*/ );
103 
104 protected:
105 private:
106  /**
107  * the width of the label display in pixel as property
108  */
109  WPropInt m_labelsWidth;
110 
111  /**
112  * the time position in seconds where to start the graph at the left edge as
113  * property
114  */
115  WPropDouble m_timePos;
116 
117  /**
118  * the width of the graph in seconds as property
119  */
120  WPropDouble m_timeRange;
121 
122  /**
123  * the width of the graph in pixel as property
124  */
125  WPropInt m_graphWidth;
126 
127  /**
128  * the y position in pixel at the lower edge as property
129  */
130  WPropDouble m_yPos;
131 
132  /**
133  * the distance between two curves of the graph in pixel as property
134  */
135  WPropDouble m_ySpacing;
136 
137  /**
138  * the sensitivity of the graph in microvolt per pixel as property
139  */
140  WPropDouble m_ySensitivity;
141 
142  /**
143  * The sensitivity of the color map as property. The color map ranges
144  * from -m_colorSensitivity to +m_colorSensitivity in microvolt.
145  */
146  WPropDouble m_colorSensitivity;
147 
148  /**
149  * event marking a special time position as WFlag
150  */
151  std::shared_ptr< WFlag< std::shared_ptr< WEEGEvent > > > m_event;
152 
153  /**
154  * parent node, where an marked event position is inserted and removed from
155  */
156  osg::ref_ptr< WGEGroupNode > m_eventParentNode;
157 
158  /**
159  * pointer to the loaded EEG dataset
160  */
161  std::shared_ptr< WEEG2 > m_eeg;
162 
163  /**
164  * number of the segment
165  */
166  std::size_t m_segmentID;
167 
168  /**
169  * Property determining whether the selected time position should be snapped to an active dipole
170  */
171  WPropBool m_snapToDipole;
172 
173  /**
174  * Property determining whether we only show the proof of concept or the real dipoles
175  */
176  WPropBool m_proofOfConcept;
177 
178  /**
179  * Pointer to the loaded dipoles dataset
180  */
181  std::shared_ptr< WDataSetDipoles > m_dipoles;
182 
183  float m_oldX; //!< previous mouse x position
184  float m_oldY; //!< previous mouse y position
185 
186  /**
187  * Update the event position according to the clicked position
188  *
189  * \param x the x coordinate of the mouse pointer in pixel
190  * \return true if handled, false otherwise
191  */
192  bool markEvent( float x );
193 };
194 
195 #endif // WEEGVIEWHANDLER_H
GUI event handler class used for the 2D EEG view.
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.
Definition: WFlag.h:39