Skip to content

Commit

Permalink
graph and all graph view can show only variable signals. see the opti…
Browse files Browse the repository at this point in the history
…ons in settings menu of each panes
  • Loading branch information
aiekick committed Nov 30, 2024
1 parent c2eab08 commit 3cecd05
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/headers/LogToGraphBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define LogToGraph_Prefix "LogToGraph"
#define LogToGraph_BuildNumber 1046
#define LogToGraph_BuildNumber 1051
#define LogToGraph_MinorNumber 2
#define LogToGraph_MajorNumber 0
#define LogToGraph_BuildId "0.2.1046"
#define LogToGraph_BuildId "0.2.1051"
10 changes: 10 additions & 0 deletions src/models/graphs/GraphView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ void GraphView::DrawMenuBar() {
if (ImGui::BeginMenu("Settings")) {
ImGui::MenuItem("Synchronize Graphs", nullptr, &ProjectFile::Instance()->m_SyncGraphs);

if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInGraphView)) {
ProjectFile::Instance()->SetProjectChange();
}

if (ImGui::BeginMenu("Axis Labels")) {
if (ImGui::MenuItem(m_show_hide_x_axis ? "Show X Axis LabelsR##GraphPaneDrawPanes" : "Hide X Axis LabelsR##GraphPaneDrawPanes")) {
m_show_hide_x_axis = !m_show_hide_x_axis;
Expand Down Expand Up @@ -739,6 +743,9 @@ void GraphView::DrawAloneGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImVec
for (auto& name : cat.second) {
auto datas_ptr = name.second.lock();
if (datas_ptr) {
if (ProjectFile::Instance()->m_ShowVariableSignalsInGraphView && datas_ptr->isConstant()) {
continue;
}
prDrawSignalGraph_ImPlot(datas_ptr, vSize, vFirstGraph);

vFirstGraph = false;
Expand Down Expand Up @@ -786,6 +793,9 @@ void GraphView::DrawGroupedGraphs(const GraphGroupPtr& vGraphGroupPtr, const ImV
for (auto& name : cat.second) {
auto datas_ptr = name.second.lock();
if (datas_ptr && datas_ptr->show_hide_temporary) {
if (ProjectFile::Instance()->m_ShowVariableSignalsInGraphView && datas_ptr->isConstant()) {
continue;
}
const auto& name_str = datas_ptr->category + " / " + datas_ptr->name;
if (ImPlot::BeginItem(name_str.c_str())) {
bool _is_zone_reached = false;
Expand Down
6 changes: 5 additions & 1 deletion src/models/log/SignalSerie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ void SignalSerie::drawAnnotations() {

void SignalSerie::finalize() {
label = ez::str::toStr("%s (%u)", name.c_str(), static_cast<uint32_t>(count_base_records));
}
}

bool SignalSerie::isConstant() {
return ez::isEqual(range_value.x, range_value.y);
}
2 changes: 2 additions & 0 deletions src/models/log/SignalSerie.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include <string>
#include <unordered_map>
#include <headers/DatasDef.h>
#include <ezlibs/ezVec2.hpp>

class SignalSerie {
public:
Expand Down Expand Up @@ -58,5 +59,6 @@ class SignalSerie {

void drawAnnotations();

bool isConstant();
void finalize();
};
61 changes: 43 additions & 18 deletions src/panes/GraphListPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ bool GraphListPane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened,
flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_MenuBar;
#endif
if (ProjectFile::Instance()->IsProjectLoaded()) {
if (ImGui::BeginMenuBar()) {
DrawMenuBar();
ImGui::EndMenuBar();
}
DrawTree();
}
}
Expand Down Expand Up @@ -90,6 +94,7 @@ void GraphListPane::DisplayItem(const int& vIdx, const SignalSerieWeak& vDatasSe
ImGui::PushID(vIdx);
ImGui::TableSetColumnIndex(0);
if (ImGui::Selectable(datas_ptr->category.c_str(), &datas_ptr->show, ImGuiSelectableFlags_SpanAllColumns, ImVec2(0, GRAPHS_HEIGHT))) {
ProjectFile::Instance()->SetProjectChange();
LogEngine::Instance()->ShowHideSignal(datas_ptr->category, datas_ptr->name, datas_ptr->show);
if (ProjectFile::Instance()->m_CollapseLogSelection) {
LogPane::Instance()->PrepareLog();
Expand All @@ -99,6 +104,7 @@ void GraphListPane::DisplayItem(const int& vIdx, const SignalSerieWeak& vDatasSe

ImGui::TableSetColumnIndex(1);
if (ImGui::Selectable(datas_ptr->name.c_str(), &datas_ptr->show, ImGuiSelectableFlags_SpanAllColumns, ImVec2(0, GRAPHS_HEIGHT))) {
ProjectFile::Instance()->SetProjectChange();
LogEngine::Instance()->ShowHideSignal(datas_ptr->category, datas_ptr->name, datas_ptr->show);
if (ProjectFile::Instance()->m_CollapseLogSelection) {
LogPane::Instance()->PrepareLog();
Expand Down Expand Up @@ -159,28 +165,45 @@ void GraphListPane::DisplayItem(const int& vIdx, const SignalSerieWeak& vDatasSe
}
}

void GraphListPane::DrawTree() {
auto& search_string = ProjectFile::Instance()->m_AllGraphSignalsSearchString;

if (ImGui::BeginMenuBar()) {
ImGui::Text("%s", "Search : ");
void GraphListPane::DrawMenuBar() {
bool change = false;

snprintf(m_search_buffer, 1024, "%s", search_string.c_str());
if (ImGui::ContrastedButton("R##GraphListPane_SearchDrawTree")) {
search_string.clear();
m_search_buffer[0] = '\0';
PrepareLog(search_string);
if (ImGui::BeginMenu("Settings")) {
if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInAllGraphView)) {
ProjectFile::Instance()->SetProjectChange();
change = true;
}

ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::InputText("##GraphListPane_Search", m_search_buffer, 1024)) {
search_string = ez::str::toLower(m_search_buffer);
PrepareLog(search_string);
}
ImGui::PopItemWidth();
ImGui::EndMenu();
}

ImGui::Text("%s", "Search : ");

auto& search_string = ProjectFile::Instance()->m_AllGraphSignalsSearchString;
snprintf(m_search_buffer, 1024, "%s", search_string.c_str());

if (ImGui::ContrastedButton("R##GraphListPane_SearchDrawTree")) {
ProjectFile::Instance()->SetProjectChange();
search_string.clear();
m_search_buffer[0] = '\0';
change = true;
}

ImGui::EndMenuBar();
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::InputText("##GraphListPane_Search", m_search_buffer, 1024)) {
ProjectFile::Instance()->SetProjectChange();
search_string = ez::str::toLower(m_search_buffer);
change = true;
}
ImGui::PopItemWidth();

if (change) {
PrepareLog(search_string);
}
}

void GraphListPane::DrawTree() {
auto& search_string = ProjectFile::Instance()->m_AllGraphSignalsSearchString;

static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY |
ImGuiTableFlags_NoHostExtendY | ImGuiTableFlags_Resizable;
Expand Down Expand Up @@ -232,7 +255,9 @@ void GraphListPane::PrepareLog(const std::string& vSearchString) {
if (is_their_some_search && signal_ptr->low_case_name_for_search.find(vSearchString) == std::string::npos) {
continue;
}

if (ProjectFile::Instance()->m_ShowVariableSignalsInAllGraphView && signal_ptr->isConstant()) {
continue;
}
m_FilteredSignalSeries.push_back(item_name);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/panes/GraphListPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GraphListPane : public AbstractPane {

private:
void DisplayItem(const int& vIdx, const SignalSerieWeak& vDatasSerie);
void DrawMenuBar();
void DrawTree();
void PrepareLog(const std::string& vSearchString);
void HideAllGraphs();
Expand Down
6 changes: 6 additions & 0 deletions src/project/ProjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ ez::xml::Nodes ProjectFile::getXmlNodes(const std::string& /*vUserDatas*/) {
node.addChild("default_curve_display_thickness").setContent(m_DefaultCurveDisplayThickNess);
node.addChild("use_predefined_zero_value").setContent(m_UsePredefinedZeroValue);
node.addChild("predefined_zero_value").setContent(m_PredefinedZeroValue);
node.addChild("show_variable_signals_in_all_graph_view").setContent(m_ShowVariableSignalsInAllGraphView);
node.addChild("show_variable_signals_in_graph_view").setContent(m_ShowVariableSignalsInGraphView);
node.addChild("last_log_file_path").setContent(m_LastLogFilePath);
node.addChild("script_file").setContent(m_ScriptFilePathName);
auto& childNode = node.addChild("log_files");
Expand Down Expand Up @@ -341,6 +343,10 @@ bool ProjectFile::setFromXmlNodes(const ez::xml::Node& vNode, const ez::xml::Nod
m_UsePredefinedZeroValue = ez::ivariant(strValue).GetB();
} else if (strName == "predefined_zero_value") {
m_PredefinedZeroValue = ez::dvariant(strValue).GetD();
} else if (strName == "show_variable_signals_in_all_graph_view") {
m_ShowVariableSignalsInAllGraphView = ez::dvariant(strValue).GetB();
} else if (strName == "show_variable_signals_in_graph_view") {
m_ShowVariableSignalsInGraphView = ez::dvariant(strValue).GetB();
} else if (strName == "last_log_file_path") {
m_LastLogFilePath = strValue;
} else if (strName == "script_file") {
Expand Down
2 changes: 2 additions & 0 deletions src/project/ProjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ProjectFile : public Ltg::IProject, public ez::xml::Config {
SourceFileName m_ScriptFileName;
std::vector<std::pair<SourceFileName, SourceFilePathName>> m_SourceFilePathNames;
Ltg::ScriptingModuleName m_ScriptingModuleName;
bool m_ShowVariableSignalsInAllGraphView = false;
bool m_ShowVariableSignalsInGraphView = false;

private: // dont save
bool m_IsLoaded = false;
Expand Down

0 comments on commit 3cecd05

Please sign in to comment.