Debian Codegraph @

gram/CubeGridArea.cpp

raw
1 /* CubeGridArea.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 "CubeGridArea.h"
20 #include "EditorM.h"
21
22 Thing_implement (CubeGridArea, FunctionArea, 0);
23
24 void structCubeGridArea :: v_drawInside () {
25 CubeGrid_paintInside (our cubeGrid(), our graphics(), our startWindow(), our endWindow());
26 }
27
28 #pragma mark - CubeGridArea Query selection
29
30 static void INFO_selection (CubeGridArea me, EDITOR_ARGS) {
31 INFO_EDITOR
32 MelderInfo_open ();
33 for (integer itier = 1; itier <= my cubeGrid() -> tiers.size; itier ++) {
34 MelderInfo_writeLine (U"Tier number: ", itier);
35 autoCubePoint average = CubeGrid_average (my cubeGrid(), itier, my startSelection(), my endSelection());
36 MelderInfo_writeLine (
37 U" red = ", Melder_fixed (average -> red, 6), U" ; ", my cubeGrid() -> redName.get(),
38 U" green = ", Melder_fixed (average -> green, 6), U" ; ", my cubeGrid() -> greenName.get(),
39 U" blue = ", Melder_fixed (average -> blue, 6), U" ; ", my cubeGrid() -> blueName.get()
40 );
41 }
42 MelderInfo_close ();
43 INFO_EDITOR_END
44 }
45
46 void structCubeGridArea :: v_createMenus () {
47 CubeGridArea_Parent :: v_createMenus (); // does nothing (last checked 2023-02-06)
48
49 EditorMenu menu = Editor_addMenu (our functionEditor(), U"CubeGrid", 0);
50
51 FunctionAreaMenu_addCommand (menu, U"- Query selected part of CubeGrid:", 0, nullptr, this);
52 FunctionAreaMenu_addCommand (menu, U"Info on selection", 'P' + GuiMenu_DEPTH_1, INFO_selection, this);
53 }
54
55 /* End of file CubeGridArea.cpp */