| 1284 | template <vkb::BindingType bindingType> |
| 1285 | inline void Gui<bindingType>::show_stats(const vkb::stats::Stats<bindingType> &stats) |
| 1286 | { |
| 1287 | for (const auto &stat_index : stats.get_requested_stats()) |
| 1288 | { |
| 1289 | // Draw graph |
| 1290 | auto &graph_data = stats_view.get_stat_graph_data(stat_index); |
| 1291 | const auto &graph_elements = stats.get_data(stat_index); |
| 1292 | float graph_min = 0.0f; |
| 1293 | float graph_max = graph_data.max_value; |
| 1294 | |
| 1295 | if (!graph_data.has_fixed_max) |
| 1296 | { |
| 1297 | auto new_max = *std::max_element(graph_elements.begin(), graph_elements.end()) * stats_view.get_top_padding(); |
| 1298 | if (new_max > graph_max) |
| 1299 | { |
| 1300 | graph_max = new_max; |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | const ImVec2 graph_size = ImVec2{ImGui::GetIO().DisplaySize.x, stats_view.get_graph_height() /* dpi */ * dpi_factor}; |
| 1305 | |
| 1306 | std::stringstream graph_label; |
| 1307 | float avg = std::accumulate(graph_elements.begin(), graph_elements.end(), 0.0f) / graph_elements.size(); |
| 1308 | |
| 1309 | // Check if the stat is available in the current platform |
| 1310 | if (stats.is_available(stat_index)) |
| 1311 | { |
| 1312 | auto graph_value = avg * graph_data.scale_factor; |
| 1313 | graph_label << fmt::vformat(graph_data.name + ": " + graph_data.format, fmt::make_format_args(graph_value)); |
| 1314 | ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); |
| 1315 | ImGui::PlotLines("", &graph_elements[0], static_cast<int>(graph_elements.size()), 0, graph_label.str().c_str(), graph_min, graph_max, graph_size); |
| 1316 | ImGui::PopItemFlag(); |
| 1317 | } |
| 1318 | else |
| 1319 | { |
| 1320 | graph_label << graph_data.name << ": not available"; |
| 1321 | ImGui::Text("%s", graph_label.str().c_str()); |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | template <vkb::BindingType bindingType> |
| 1327 | inline void Gui<bindingType>::show_top_window(const std::string &app_name, const vkb::stats::Stats<bindingType> *stats, DebugInfo *debug_info) |
| 1328 | { |
no test coverage detected