| 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"cxx . . $ `<file>/gram/NoulliGridArea.h`/ |
| 20 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 21 | |
| 22 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (NoulliGridArea, FunctionArea, 0); |
| 23 | |
| 24 | void structNoulliGridAreacxx . . $ structNoulliGridArea# :: v_drawInsidecxx . . $ structNoulliGridArea#v_drawInside(49f6e7a06ebc5aa8). () { |
| 25 | NoulliGrid_paintInsidecxx . . $ NoulliGrid_paintInside(e9370d2b65d977e3). (ourcxx . . $ `melder/melder.h:42:9`! noulliGridcxx . . $ structNoulliGridArea#noulliGrid(5ed5fe233a85eea).(), ourcxx . . $ `melder/melder.h:42:9`! graphicscxx . . $ structFunctionArea#graphics(5af6864da672d398).(), ourcxx . . $ `melder/melder.h:42:9`! startWindowcxx . . $ structFunctionArea#startWindow(21b6c25e127938e2).(), ourcxx . . $ `melder/melder.h:42:9`! endWindowcxx . . $ structFunctionArea#endWindow(21b6c25e127938e2).()); |
| 26 | } |
| 27 | |
| 28 | #pragma mark - NoulliGridArea Query selection |
| 29 | |
| 30 | static void INFO_selectioncxx . . $ INFO_selection(934424606fbf0b68). (NoulliGridAreacxx . . $ NoulliGridArea# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 31 | INFO_EDITORcxx . . $ `sys/EditorM.h:539:9`! |
| 32 | MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). (); |
| 33 | for (integercxx . . $ integer# itier = 1; itier <= mycxx . . $ `melder/melder.h:44:9`! noulliGridcxx . . $ structNoulliGridArea#noulliGrid(5ed5fe233a85eea).() -> tierscxx . . $ structNoulliGrid#tiers..sizecxx . . $ CollectionOf#size.; itier ++) { |
| 34 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Tier number: ", itier); |
| 35 | autoNoulliPointcxx . . $ autoNoulliPoint# average = NoulliGrid_averagecxx . . $ NoulliGrid_average(e93752e781671d06). (mycxx . . $ `melder/melder.h:44:9`! noulliGridcxx . . $ structNoulliGridArea#noulliGrid(5ed5fe233a85eea).(), itier, mycxx . . $ `melder/melder.h:44:9`! startSelectioncxx . . $ structFunctionArea#startSelection(21b6c25e127938e2).(), mycxx . . $ `melder/melder.h:44:9`! endSelectioncxx . . $ structFunctionArea#endSelection(21b6c25e127938e2).()); |
| 36 | for (integercxx . . $ integer# icat = 1; icat <= average ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfCategoriescxx . . $ structNoulliPoint#numberOfCategories.; icat ++) |
| 37 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" p(", icat, U") = ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (average ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). probabilitiescxx . . $ structNoulliPoint#probabilities. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icat], 6), |
| 38 | U" ; ", mycxx . . $ `melder/melder.h:44:9`! noulliGridcxx . . $ structNoulliGridArea#noulliGrid(5ed5fe233a85eea).() -> categoryNamescxx . . $ structNoulliGrid#categoryNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icat].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 39 | const integercxx . . $ integer# winningCategory = NoulliPoint_getWinningCategorycxx . . $ NoulliPoint_getWinningCategory(836ef92ee70b59b). (average.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 40 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Winner: ", winningCategory, U" ; ", |
| 41 | mycxx . . $ `melder/melder.h:44:9`! noulliGridcxx . . $ structNoulliGridArea#noulliGrid(5ed5fe233a85eea).() -> categoryNamescxx . . $ structNoulliGrid#categoryNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).winningCategory].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 42 | } |
| 43 | MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). (); |
| 44 | INFO_EDITOR_ENDcxx . . $ `sys/EditorM.h:540:9`! |
| 45 | } |
| 46 | |
| 47 | void structNoulliGridAreacxx . . $ structNoulliGridArea# :: v_createMenuscxx . . $ structNoulliGridArea#v_createMenus(49f6e7a06ebc5aa8). () { |
| 48 | NoulliGridArea_Parentcxx . . $ NoulliGridArea_Parent# :: v_createMenuscxx . . $ structDataGui#v_createMenus(49f6e7a06ebc5aa8). (); // does nothing (last checked 2023-02-06) |
| 49 | |
| 50 | EditorMenucxx . . $ EditorMenu# menu = Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (ourcxx . . $ `melder/melder.h:42:9`! functionEditorcxx . . $ structFunctionArea#functionEditor(985d6162d6c279b).(), U"NoulliGrid", 0); |
| 51 | |
| 52 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"- Query selected part of NoulliGrid:", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this); |
| 53 | FunctionAreaMenu_addCommandcxx . . $ FunctionAreaMenu_addCommand(e6bf179389aae652). (menu, U"Info on selection", 'P' + GuiMenu_DEPTH_1cxx . . $ `sys/Gui.h:862:9`!, INFO_selectioncxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 54 | } |
| 55 | |
| 56 | /* End of file NoulliGridArea.cpp */ |