GCC Code Coverage Report


Directory: ./
File: lib/geogram_gfx/gui/status_bar.cpp
Date: 2026-09-07 02:37:58
Exec Total Coverage
Lines: 0 51 0.0%
Functions: 0 6 0.0%
Branches: 0 40 0.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40 #include <geogram_gfx/gui/status_bar.h>
41 #include <geogram_gfx/gui/application.h>
42 #include <geogram_gfx/imgui_ext/imgui_ext.h>
43 #include <geogram_gfx/imgui_ext/icon_font.h>
44 #include <geogram/basic/string.h>
45
46 namespace GEO {
47 StatusBar::StatusBar() {
48 step_ = 0;
49 percent_ = 0;
50 progress_ = false;
51 canceled_ = false;
52 nb_active_ = 0;
53 height_ = 0.0f;
54 }
55
56 void StatusBar::begin() {
57 progress_ = true;
58 canceled_ = false;
59 ++nb_active_;
60 }
61
62 void StatusBar::progress(GEO::index_t step, GEO::index_t percent) {
63 step_ = step;
64 percent_ = percent;
65 update();
66 }
67
68 void StatusBar::end(bool canceled) {
69 geo_argused(canceled);
70 step_ = 0;
71 percent_ = 0;
72 progress_ = false;
73 --nb_active_;
74 }
75
76 void StatusBar::draw() {
77 ImGui::Begin(
78 "##Status", nullptr,
79 ImGuiWindowFlags_NoResize |
80 ImGuiWindowFlags_NoMove |
81 ImGuiWindowFlags_NoCollapse |
82 ImGuiWindowFlags_NoTitleBar |
83 ImGuiWindowFlags_NoScrollbar
84 );
85 if(progress_) {
86 // "Cancel" button does not work for now under Android
87 // (to be investigated...)
88 #ifndef GEO_OS_ANDROID
89 if(ImGui::SimpleButton(icon_UTF8("window-close"))) {
90 Progress::cancel();
91 }
92 ImGui::SameLine();
93 #endif
94 ImGui::Text(
95 "%s", Progress::current_progress_task()->task_name().c_str()
96 );
97 ImGui::SameLine();
98 std::string overlay =
99 String::to_string(step_) + "/" +
100 String::to_string(
101 Progress::current_progress_task()->max_steps()
102 ) + " (" +
103 String::to_string(percent_) +
104 "%)";
105
106 ImGui::ProgressBar(
107 std::max(0.001f, float(percent_)/float(100.0)),
108 ImVec2(-1,0.0),
109 overlay.c_str()
110 );
111 }
112 height_ = ImGui::GetFrameHeight();
113 ImGui::End();
114 }
115
116 void StatusBar::update() {
117 if(Application::instance() != nullptr) {
118 Application::instance()->draw();
119 }
120 }
121 }
122