| 1 |
/* EEGWindow.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 2011-2018,2021,2022 Paul Boersma |
| 4 |
* |
| 5 |
* This code is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
* See the GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "EEGWindow.h" |
| 20 |
#include "EditorM.h" |
| 21 |
|
| 22 |
Thing_implement (EEGWindow, FunctionEditor, 0); |
| 23 |
|
| 24 |
#include "Prefs_define.h" |
| 25 |
#include "EEGWindow_prefs.h" |
| 26 |
#include "Prefs_install.h" |
| 27 |
#include "EEGWindow_prefs.h" |
| 28 |
#include "Prefs_copyToInstance.h" |
| 29 |
#include "EEGWindow_prefs.h" |
| 30 |
|
| 31 |
static void menu_cb_EEGWindowHelp (EEGWindow, EDITOR_ARGS) { Melder_help (U"EEG window"); } |
| 32 |
|
| 33 |
void structEEGWindow :: v_createMenuItems_help (EditorMenu menu) { |
| 34 |
structFunctionEditor :: v_createMenuItems_help (menu); |
| 35 |
EditorMenu_addCommand (menu, U"EEGWindow help", '?', menu_cb_EEGWindowHelp); |
| 36 |
} |
| 37 |
|
| 38 |
static void CONVERT_DATA_TO_ONE__ExtractSelectedEEG_preserveTimes (EEGWindow me, EDITOR_ARGS) { |
| 39 |
CONVERT_DATA_TO_ONE |
| 40 |
if (my endSelection <= my startSelection) |
| 41 |
Melder_throw (U"No selection."); |
| 42 |
autoEEG result = EEG_extractPart (my eeg(), my startSelection, my endSelection, true); |
| 43 |
CONVERT_DATA_TO_ONE_END (U"untitled") |
| 44 |
} |
| 45 |
|
| 46 |
static void CONVERT_DATA_TO_ONE__ExtractSelectedEEG_timeFromZero (EEGWindow me, EDITOR_ARGS) { |
| 47 |
CONVERT_DATA_TO_ONE |
| 48 |
if (my endSelection <= my startSelection) |
| 49 |
Melder_throw (U"No selection."); |
| 50 |
autoEEG result = EEG_extractPart (my eeg(), my startSelection, my endSelection, false); |
| 51 |
CONVERT_DATA_TO_ONE_END (U"untitled") |
| 52 |
} |
| 53 |
|
| 54 |
void structEEGWindow :: v_createMenus () { |
| 55 |
EEGWindow_Parent :: v_createMenus (); |
| 56 |
EditorMenu eegMenu = Editor_addMenu (this, U"EEG", 0); |
| 57 |
our extractSelectedEEGPreserveTimesButton = EditorMenu_addCommand (eegMenu, U"Extract selected EEG (preserve times)", 0, |
| 58 |
CONVERT_DATA_TO_ONE__ExtractSelectedEEG_preserveTimes); |
| 59 |
our extractSelectedEEGTimeFromZeroButton = EditorMenu_addCommand (eegMenu, U"Extract selected EEG (time from zero)", 0, |
| 60 |
CONVERT_DATA_TO_ONE__ExtractSelectedEEG_timeFromZero); |
| 61 |
} |
| 62 |
|
| 63 |
void structEEGWindow :: v_updateMenuItems () { |
| 64 |
EEGWindow_Parent :: v_updateMenuItems (); |
| 65 |
GuiThing_setSensitive (our extractSelectedEEGPreserveTimesButton, our endSelection > our startSelection); |
| 66 |
GuiThing_setSensitive (our extractSelectedEEGTimeFromZeroButton, our endSelection > our startSelection); |
| 67 |
} |
| 68 |
|
| 69 |
autoEEGWindow EEGWindow_create (conststring32 title, EEG eeg) { |
| 70 |
try { |
| 71 |
autoEEGWindow me = Thing_new (EEGWindow); |
| 72 |
my eegArea() = EEGArea_create (false, nullptr, me.get()); |
| 73 |
my eegArea() -> borrowedEEG = eeg; |
| 74 |
my eegAnalysisArea() = EEGAnalysisArea_create (false, nullptr, me.get()); |
| 75 |
my textGridArea() = TextGridArea_create (true, nullptr, me.get()); |
| 76 |
FunctionEditor_init (me.get(), title, eeg); |
| 77 |
// no spelling checker |
| 78 |
// no callback socket |
| 79 |
return me; |
| 80 |
} catch (MelderError) { |
| 81 |
Melder_throw (U"EEG window not created."); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
/* End of file EEGWindow.cpp */ |