From 93631da49e0e405bf29d812b7a7e6e953ac26fc4 Mon Sep 17 00:00:00 2001 From: aiekick Date: Sat, 30 Nov 2024 22:26:56 +0100 Subject: [PATCH] fix for #31 --- src/headers/LogToGraphBuild.h | 4 ++-- src/models/graphs/GraphView.cpp | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/headers/LogToGraphBuild.h b/src/headers/LogToGraphBuild.h index 6249da4..881479d 100644 --- a/src/headers/LogToGraphBuild.h +++ b/src/headers/LogToGraphBuild.h @@ -1,7 +1,7 @@ #pragma once #define LogToGraph_Prefix "LogToGraph" -#define LogToGraph_BuildNumber 1051 +#define LogToGraph_BuildNumber 1053 #define LogToGraph_MinorNumber 2 #define LogToGraph_MajorNumber 0 -#define LogToGraph_BuildId "0.2.1051" +#define LogToGraph_BuildId "0.2.1053" diff --git a/src/models/graphs/GraphView.cpp b/src/models/graphs/GraphView.cpp index f5e8f99..c66bb75 100644 --- a/src/models/graphs/GraphView.cpp +++ b/src/models/graphs/GraphView.cpp @@ -812,6 +812,7 @@ void GraphView::DrawGroupedGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImV double last_value = _data_ptr_0->value, current_value; std::string last_string = _data_ptr_0->string, current_string; std::string last_status = _data_ptr_0->status, current_status; + std::string last_desc = _data_ptr_0->desc, current_desc; bool _is_h_hovered = false; last_value_pos = ImPlot::PlotToPixels(last_time, _data_ptr_0->value); @@ -822,6 +823,11 @@ void GraphView::DrawGroupedGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImV current_value = _data_ptr_i->value; current_string = _data_ptr_i->string; current_status = _data_ptr_i->status; + current_desc = _data_ptr_i->desc; + if (i == 1U && !current_desc.empty() && last_desc.empty()) { + last_desc = current_desc; + } + value_pos = ImPlot::PlotToPixels(current_time, current_value); ImPlot::FitPoint(ImPlotPoint(current_time, current_value)); @@ -912,12 +918,17 @@ void GraphView::DrawGroupedGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImV if (last_string.empty()) { // tofix : to refactor const auto p_min = ImGui::GetCursorScreenPos() - ImVec2(spacing_L, spacing_U); - const auto p_max = ImVec2(p_min.x + ImGui::GetContentRegionAvail().x + spacing_R, - p_min.y + (ImGui::GetFrameHeight() - spacing_D)); + const auto p_max = ImVec2( // + p_min.x + ImGui::GetContentRegionAvail().x + spacing_R, + p_min.y + (ImGui::GetFrameHeight() - spacing_D) * 2.0f); ImGui::GetWindowDrawList()->AddRectFilled(p_min, p_max, _color); const bool pushed = ImGui::PushStyleColorWithContrast4( _color, ImGuiCol_Text, ImGui::CustomStyle::puContrastedTextColor, ImGui::CustomStyle::puContrastRatio); - ImGui::Text("%s : %f", name_str.c_str(), last_value); + if (!last_desc.empty()) { + ImGui::Text("%f (%s) %s", last_value, last_desc.c_str(), name_str.c_str()); + } else { + ImGui::Text("%f %s", last_value, name_str.c_str()); + } if (pushed) ImGui::PopStyleColor(); } else { @@ -963,6 +974,7 @@ void GraphView::DrawGroupedGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImV last_value = current_value; last_string = current_string; last_status = current_status; + last_desc = current_desc; } }