Debian Codegraph @

gram/CubeGridEditor.cpp

raw symbols SCIP
1 /* CubeGridEditor.cpp
2 *
3 * Copyright (C) 2023 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 "CubeGridEditor.h"
20 #include "EditorM.h"
21
22 Thing_implement (CubeGridEditor, FunctionEditor, 0);
23
24 #include "Prefs_define.h"
25 #include "CubeGridEditor_prefs.h"
26 #include "Prefs_install.h"
27 #include "CubeGridEditor_prefs.h"
28 #include "Prefs_copyToInstance.h"
29 #include "CubeGridEditor_prefs.h"
30
31 static void drawSelectionOrWindow (CubeGridEditor me, double tmin, double tmax, conststring32 header) {
32 for (integer itier = 1; itier <= my cubeGrid() -> tiers.size; itier ++) {
33 if (itier == 1) {
34 Graphics_setColour (my graphics.get(), Melder_BLACK);
35 Graphics_setTextAlignment (my graphics.get(), kGraphics_horizontalAlignment::CENTRE, Graphics_BOTTOM);
36 Graphics_text (my graphics.get(), 0.0, 1.0, header);
37 }
38 autoCubePoint average = CubeGrid_average (my cubeGrid(), itier, tmin, tmax);
39 Graphics_setColour (my graphics.get(), MelderColour (average -> red, average -> green, average -> blue));
40 Graphics_fillRectangle (my graphics.get(), 0.15, 0.85, 0.3, 1.0);
41 Graphics_setColour (my graphics.get(), Melder_BLACK);
42 Graphics_setTextAlignment (my graphics.get(), kGraphics_horizontalAlignment::CENTRE, Graphics_HALF);
43 Graphics_text (my graphics.get(), 0.5, 0.25,
44 Melder_cat (my cubeGrid() -> redName.get(), U": ", Melder_fixed (average -> red, 6)));
45 Graphics_text (my graphics.get(), 0.5, 0.15,
46 Melder_cat (my cubeGrid() -> greenName.get(), U": ", Melder_fixed (average -> green, 6)));
47 Graphics_text (my graphics.get(), 0.5, 0.05,
48 Melder_cat (my cubeGrid() -> blueName.get(), U": ", Melder_fixed (average -> blue, 6)));
49 }
50 }
51
52 void structCubeGridEditor :: v_drawSelectionViewer () {
53 Graphics_setWindow (our graphics.get(), 0.0, 1.0, 0.0, 1.0);
54 Graphics_setColour (our graphics.get(), DataGuiColour_WINDOW_BACKGROUND);
55 Graphics_fillRectangle (our graphics.get(), 0.0, 1.0, 0.0, 1.0);
56 drawSelectionOrWindow (this, our startSelection, our endSelection, U"");
57 }
58
59 void structCubeGridEditor :: v_drawRealTimeSelectionViewer (double time) {
60 Graphics_setWindow (our graphics.get(), 0.0, 1.0, 0.0, 1.0);
61 drawSelectionOrWindow (this, time - 1.0, time + 1.0, U"");
62 }
63
64 autoCubeGridEditor CubeGridEditor_create (conststring32 title, CubeGrid cubeGrid, Sound optionalSoundToCopy) {
65 try {
66 autoCubeGridEditor me = Thing_new (CubeGridEditor);
67 my cubeGridArea() = CubeGridArea_create (true, nullptr, me.get());
68 if (optionalSoundToCopy)
69 my soundArea() = SoundArea_create (false, optionalSoundToCopy, me.get());
70 FunctionEditor_init (me.get(), title, cubeGrid);
71 return me;
72 } catch (MelderError) {
73 Melder_throw (U"CubeGrid window not created.");
74 }
75 }
76
77 /* End of file CubeGridEditor.cpp */
78