Debian Codegraph @

gram/NoulliGridArea.cpp

raw
1 /* NoulliGridArea.cpp
2 *
3 * Copyright (C) 2018-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 "NoulliGridArea.h"
20 #include "EditorM.h"
21
22 Thing_implement (NoulliGridArea, FunctionArea, 0);
23
24 void structNoulliGridArea :: v_drawInside () {
25 NoulliGrid_paintInside (our noulliGrid(), our graphics(), our startWindow(), our endWindow());
26 }
27
28 #pragma mark - NoulliGridArea Query selection
29
30 static void INFO_selection (NoulliGridArea me, EDITOR_ARGS) {
31 INFO_EDITOR
32 MelderInfo_open ();
33 for (integer itier = 1; itier <= my noulliGrid() -> tiers.size; itier ++) {
34 MelderInfo_writeLine (U"Tier number: ", itier);
35 autoNoulliPoint average = NoulliGrid_average (my noulliGrid(), itier, my startSelection(), my endSelection());
36 for (integer icat = 1; icat <= average -> numberOfCategories; icat ++)
37 MelderInfo_writeLine (U" p(", icat, U") = ", Melder_fixed (average -> probabilities [icat], 6),
38 U" ; ", my noulliGrid() -> categoryNames [icat].get());
39 const integer winningCategory = NoulliPoint_getWinningCategory (average.get());
40 MelderInfo_writeLine (U" Winner: ", winningCategory, U" ; ",
41 my noulliGrid() -> categoryNames [winningCategory].get());
42 }
43 MelderInfo_close ();
44 INFO_EDITOR_END
45 }
46
47 void structNoulliGridArea :: v_createMenus () {
48 NoulliGridArea_Parent :: v_createMenus (); // does nothing (last checked 2023-02-06)
49
50 EditorMenu menu = Editor_addMenu (our functionEditor(), U"NoulliGrid", 0);
51
52 FunctionAreaMenu_addCommand (menu, U"- Query selected part of NoulliGrid:", 0, nullptr, this);
53 FunctionAreaMenu_addCommand (menu, U"Info on selection", 'P' + GuiMenu_DEPTH_1, INFO_selection, this);
54 }
55
56 /* End of file NoulliGridArea.cpp */