| 1 | #ifndef _FormantGridEditor_h_ |
| 2 | #define _FormantGridEditor_h_ |
| 3 | /* FormantGridEditor.h |
| 4 | * |
| 5 | * Copyright (C) 2008-2018,2020,2022 Paul Boersma & David Weenink |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "FunctionEditor.h" |
| 22 | #include "FormantGridArea.h" |
| 23 | |
| 24 | Thing_define (FormantGridEditor, FunctionEditor) { |
| 25 | DEFINE_FunctionArea (1, FormantGridArea, formantGridArea); |
| 26 | |
| 27 | void v1_dataChanged (Editor sender) override { |
| 28 | our structFunctionEditor :: v1_dataChanged (sender); |
| 29 | our formantGridArea() -> _formantGrid = static_cast <FormantGrid> (our data()); |
| 30 | OrderedOf<structRealTier>* tiers = |
| 31 | ( our formantGridArea() -> editingBandwidths ? & our formantGridArea() -> _formantGrid -> bandwidths : & our formantGridArea() -> _formantGrid -> formants ); |
| 32 | RealTier tier = tiers->at [our formantGridArea() -> selectedFormant]; |
| 33 | our formantGridArea() -> functionChanged (tier); |
| 34 | } |
| 35 | void v_distributeAreas () override { |
| 36 | our formantGridArea() -> setGlobalYRange_fraction (0.0, 1.0); |
| 37 | } |
| 38 | void v_play (double startTime, double endTime) override { |
| 39 | FormantGridArea_playPart (our formantGridArea().get(), startTime, endTime, theFunctionEditor_playCallback, this); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | inline autoFormantGridEditor FormantGridEditor_create (conststring32 title, FormantGrid formantGrid) { |
| 44 | try { |
| 45 | autoFormantGridEditor me = Thing_new (FormantGridEditor); |
| 46 | my formantGridArea() = FormantGridArea_create (true, nullptr, me.get()); |
| 47 | FunctionEditor_init (me.get(), title, formantGrid); |
| 48 | return me; |
| 49 | } catch (MelderError) { |
| 50 | Melder_throw (U"FormantGrid window not created."); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* End of file FormantGridEditor.h */ |
| 55 | #endif |