Skip to content

Commit

Permalink
fix a bug when a category have sub category, only the sub category is…
Browse files Browse the repository at this point in the history
… displayed as child. no other signals. #33
  • Loading branch information
aiekick committed Dec 1, 2024
1 parent 6cbe3bb commit ab59f5d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 48 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LogToGraph_Windows_Release_x64_v0.3.3583
LogToGraph_Windows_Release_x64_v0.3.3595
4 changes: 2 additions & 2 deletions plugins/LuaScripting/src/headers/LuaScriptingBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define LuaScripting_Prefix "LuaScripting"
#define LuaScripting_BuildNumber 331
#define LuaScripting_BuildNumber 332
#define LuaScripting_MinorNumber 1
#define LuaScripting_MajorNumber 0
#define LuaScripting_BuildId "0.1.331"
#define LuaScripting_BuildId "0.1.332"
3 changes: 3 additions & 0 deletions src/headers/DatasDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ typedef std::map<SignalName, SignalSerieWeak> SignalContainerWeak;
typedef std::map<SignalCategory, SignalContainerWeak> SignalSeriesWeakContainer;
typedef std::map<SignalCategory, SignalContainerWeak>& SignalSeriesWeakContainerRef;

class SignalItem;
typedef std::map<SignalName, SignalItem> SignalItemContainer;

class GraphGroup;
typedef std::shared_ptr<GraphGroup> GraphGroupPtr;
typedef std::weak_ptr<GraphGroup> GraphGroupWeak;
Expand Down
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 3595
#define LogToGraph_BuildNumber 3600
#define LogToGraph_MinorNumber 3
#define LogToGraph_MajorNumber 0
#define LogToGraph_BuildId "0.3.3595"
#define LogToGraph_BuildId "0.3.3600"
77 changes: 39 additions & 38 deletions src/models/log/SignalTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

void SignalTree::clear() {
m_RootItem.clear();
m_SignalSeriesOld.clear();
}

void SignalTree::prepare(const std::string& vSearchString) {
searchPattern = vSearchString;
m_RootItem.clear();
m_SignalSeriesOld.clear();

for (const auto& signal_cnt : LogEngine::Instance()->GetSignalSeries()) {
prepareRecurs(vSearchString, signal_cnt.first, signal_cnt.second, m_RootItem);
Expand All @@ -35,8 +33,7 @@ void SignalTree::prepareRecurs(const std::string& vSearchString, const SignalCat
auto& item = vSignalItemRef.childs.at(left_category);
if (!right_category.empty()) { // no leaf, recurs
prepareRecurs(vSearchString, right_category, vSignals, item);
item.count = static_cast<uint32_t>(item.childs.size());

item.count = static_cast<uint32_t>(item.childs.size() + item.signals.size());
} else { // leaf : add
item.count = static_cast<uint32_t>(vSignals.size());
for (const auto& sig : vSignals) {
Expand All @@ -56,49 +53,53 @@ void SignalTree::prepareRecurs(const std::string& vSearchString, const SignalCat
}
}

const SignalItem& SignalTree::getRootItem() const {
return m_RootItem;
}

void SignalTree::displayTree(bool vCollapseAll, bool vExpandAll) {
displayItemRecurs(m_RootItem, vCollapseAll, vExpandAll);
}

void SignalTree::displayItemRecurs(SignalItem& vSignalItemRef, bool vCollapseAll, bool vExpandAll) {
if (vSignalItemRef.isLeaf()) {
for (auto& signal : vSignalItemRef.signals) {
if (!signal.second.expired()) {
auto ptr = signal.second.lock();
if (ptr) {
if (ImGui::Selectable(ptr->label.c_str(), ptr->show)) {
ptr->show = !ptr->show;
LogEngine::Instance()->ShowHideSignal(ptr->category, ptr->name, ptr->show);
if (ProjectFile::Instance()->m_CollapseLogSelection) {
LogPane::Instance()->PrepareLog();
}
ProjectFile::Instance()->SetProjectChange();
}
}
}
// display categories
for (auto& child : vSignalItemRef.childs) {
if (vCollapseAll) {
// can close only the first item for now
// or we need to reach the leaf
// and close from leaf so to do on many frames
// can be anoying for the user
// todo : by the way
ImGui::SetNextItemOpen(false);
}
} else { // display categories
for (auto& child : vSignalItemRef.childs) {
if (vCollapseAll) {
// can close only the first item for now
// or we need to reach the leaf
// and close from leaf so to do on many frames
// can be anoying for the user
// todo : by the way
ImGui::SetNextItemOpen(false);
}

if (vExpandAll) {
// will open all tree during recursion
ImGui::SetNextItemOpen(true);
}
if (vExpandAll) {
// will open all tree during recursion
ImGui::SetNextItemOpen(true);
}

if (ImGui::TreeNode(&child.second, "%s", child.second.label.c_str())) {
ImGui::Indent();
displayItemRecurs(child.second, vCollapseAll, vExpandAll);
ImGui::Unindent();
ImGui::TreePop();
if (ImGui::TreeNode(&child.second, "%s", child.second.label.c_str())) {
displayItemRecurs(child.second, vCollapseAll, vExpandAll);
ImGui::TreePop();
}
}

// display signals
ImGui::Indent();
for (auto& signal : vSignalItemRef.signals) {
if (!signal.second.expired()) {
auto ptr = signal.second.lock();
if (ptr) {
if (ImGui::Selectable(ptr->label.c_str(), ptr->show)) {
ptr->show = !ptr->show;
LogEngine::Instance()->ShowHideSignal(ptr->category, ptr->name, ptr->show);
if (ProjectFile::Instance()->m_CollapseLogSelection) {
LogPane::Instance()->PrepareLog();
}
ProjectFile::Instance()->SetProjectChange();
}
}
}
}
ImGui::Unindent();
}
12 changes: 7 additions & 5 deletions src/models/log/SignalTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
#include <string>
#include <map>

struct SignalItem;
typedef std::map<SignalName, SignalItem> SignalItemContainer;
struct SignalItem {

class SignalItem {
public:
uint32_t count = 0U;
std::string label; // label displayed in imgui tree
std::string label; // label displayed in imgui tree
SignalContainerWeak signals;
SignalItemContainer childs;

public:
bool isLeaf() const { return childs.empty(); }
bool isEmpty() const { return childs.empty() && signals.empty(); }
void clear() {
Expand All @@ -23,11 +25,11 @@ class SignalTree {
private:
std::string searchPattern;
SignalItem m_RootItem;
std::map<SignalName, SignalSerieWeak> m_SignalSeriesOld;

public:
void clear();
void prepare(const std::string& vSearchString);
const SignalItem& getRootItem() const;
void displayTree(bool vCollapseAll, bool vExpandAll);

private:
Expand Down

0 comments on commit ab59f5d

Please sign in to comment.