Skip to content

Commit ab59f5d

Browse files
committed
fix a bug when a category have sub category, only the sub category is displayed as child. no other signals. #33
1 parent 6cbe3bb commit ab59f5d

File tree

6 files changed

+54
-48
lines changed

6 files changed

+54
-48
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
LogToGraph_Windows_Release_x64_v0.3.3583
1+
LogToGraph_Windows_Release_x64_v0.3.3595
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define LuaScripting_Prefix "LuaScripting"
4-
#define LuaScripting_BuildNumber 331
4+
#define LuaScripting_BuildNumber 332
55
#define LuaScripting_MinorNumber 1
66
#define LuaScripting_MajorNumber 0
7-
#define LuaScripting_BuildId "0.1.331"
7+
#define LuaScripting_BuildId "0.1.332"

src/headers/DatasDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ typedef std::map<SignalName, SignalSerieWeak> SignalContainerWeak;
111111
typedef std::map<SignalCategory, SignalContainerWeak> SignalSeriesWeakContainer;
112112
typedef std::map<SignalCategory, SignalContainerWeak>& SignalSeriesWeakContainerRef;
113113

114+
class SignalItem;
115+
typedef std::map<SignalName, SignalItem> SignalItemContainer;
116+
114117
class GraphGroup;
115118
typedef std::shared_ptr<GraphGroup> GraphGroupPtr;
116119
typedef std::weak_ptr<GraphGroup> GraphGroupWeak;

src/headers/LogToGraphBuild.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define LogToGraph_Prefix "LogToGraph"
4-
#define LogToGraph_BuildNumber 3595
4+
#define LogToGraph_BuildNumber 3600
55
#define LogToGraph_MinorNumber 3
66
#define LogToGraph_MajorNumber 0
7-
#define LogToGraph_BuildId "0.3.3595"
7+
#define LogToGraph_BuildId "0.3.3600"

src/models/log/SignalTree.cpp

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
void SignalTree::clear() {
99
m_RootItem.clear();
10-
m_SignalSeriesOld.clear();
1110
}
1211

1312
void SignalTree::prepare(const std::string& vSearchString) {
1413
searchPattern = vSearchString;
1514
m_RootItem.clear();
16-
m_SignalSeriesOld.clear();
1715

1816
for (const auto& signal_cnt : LogEngine::Instance()->GetSignalSeries()) {
1917
prepareRecurs(vSearchString, signal_cnt.first, signal_cnt.second, m_RootItem);
@@ -35,8 +33,7 @@ void SignalTree::prepareRecurs(const std::string& vSearchString, const SignalCat
3533
auto& item = vSignalItemRef.childs.at(left_category);
3634
if (!right_category.empty()) { // no leaf, recurs
3735
prepareRecurs(vSearchString, right_category, vSignals, item);
38-
item.count = static_cast<uint32_t>(item.childs.size());
39-
36+
item.count = static_cast<uint32_t>(item.childs.size() + item.signals.size());
4037
} else { // leaf : add
4138
item.count = static_cast<uint32_t>(vSignals.size());
4239
for (const auto& sig : vSignals) {
@@ -56,49 +53,53 @@ void SignalTree::prepareRecurs(const std::string& vSearchString, const SignalCat
5653
}
5754
}
5855

56+
const SignalItem& SignalTree::getRootItem() const {
57+
return m_RootItem;
58+
}
59+
5960
void SignalTree::displayTree(bool vCollapseAll, bool vExpandAll) {
6061
displayItemRecurs(m_RootItem, vCollapseAll, vExpandAll);
6162
}
6263

6364
void SignalTree::displayItemRecurs(SignalItem& vSignalItemRef, bool vCollapseAll, bool vExpandAll) {
64-
if (vSignalItemRef.isLeaf()) {
65-
for (auto& signal : vSignalItemRef.signals) {
66-
if (!signal.second.expired()) {
67-
auto ptr = signal.second.lock();
68-
if (ptr) {
69-
if (ImGui::Selectable(ptr->label.c_str(), ptr->show)) {
70-
ptr->show = !ptr->show;
71-
LogEngine::Instance()->ShowHideSignal(ptr->category, ptr->name, ptr->show);
72-
if (ProjectFile::Instance()->m_CollapseLogSelection) {
73-
LogPane::Instance()->PrepareLog();
74-
}
75-
ProjectFile::Instance()->SetProjectChange();
76-
}
77-
}
78-
}
65+
// display categories
66+
for (auto& child : vSignalItemRef.childs) {
67+
if (vCollapseAll) {
68+
// can close only the first item for now
69+
// or we need to reach the leaf
70+
// and close from leaf so to do on many frames
71+
// can be anoying for the user
72+
// todo : by the way
73+
ImGui::SetNextItemOpen(false);
7974
}
80-
} else { // display categories
81-
for (auto& child : vSignalItemRef.childs) {
82-
if (vCollapseAll) {
83-
// can close only the first item for now
84-
// or we need to reach the leaf
85-
// and close from leaf so to do on many frames
86-
// can be anoying for the user
87-
// todo : by the way
88-
ImGui::SetNextItemOpen(false);
89-
}
9075

91-
if (vExpandAll) {
92-
// will open all tree during recursion
93-
ImGui::SetNextItemOpen(true);
94-
}
76+
if (vExpandAll) {
77+
// will open all tree during recursion
78+
ImGui::SetNextItemOpen(true);
79+
}
9580

96-
if (ImGui::TreeNode(&child.second, "%s", child.second.label.c_str())) {
97-
ImGui::Indent();
98-
displayItemRecurs(child.second, vCollapseAll, vExpandAll);
99-
ImGui::Unindent();
100-
ImGui::TreePop();
81+
if (ImGui::TreeNode(&child.second, "%s", child.second.label.c_str())) {
82+
displayItemRecurs(child.second, vCollapseAll, vExpandAll);
83+
ImGui::TreePop();
84+
}
85+
}
86+
87+
// display signals
88+
ImGui::Indent();
89+
for (auto& signal : vSignalItemRef.signals) {
90+
if (!signal.second.expired()) {
91+
auto ptr = signal.second.lock();
92+
if (ptr) {
93+
if (ImGui::Selectable(ptr->label.c_str(), ptr->show)) {
94+
ptr->show = !ptr->show;
95+
LogEngine::Instance()->ShowHideSignal(ptr->category, ptr->name, ptr->show);
96+
if (ProjectFile::Instance()->m_CollapseLogSelection) {
97+
LogPane::Instance()->PrepareLog();
98+
}
99+
ProjectFile::Instance()->SetProjectChange();
100+
}
101101
}
102102
}
103103
}
104+
ImGui::Unindent();
104105
}

src/models/log/SignalTree.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
#include <string>
55
#include <map>
66

7-
struct SignalItem;
8-
typedef std::map<SignalName, SignalItem> SignalItemContainer;
9-
struct SignalItem {
7+
8+
class SignalItem {
9+
public:
1010
uint32_t count = 0U;
11-
std::string label; // label displayed in imgui tree
11+
std::string label; // label displayed in imgui tree
1212
SignalContainerWeak signals;
1313
SignalItemContainer childs;
14+
15+
public:
1416
bool isLeaf() const { return childs.empty(); }
1517
bool isEmpty() const { return childs.empty() && signals.empty(); }
1618
void clear() {
@@ -23,11 +25,11 @@ class SignalTree {
2325
private:
2426
std::string searchPattern;
2527
SignalItem m_RootItem;
26-
std::map<SignalName, SignalSerieWeak> m_SignalSeriesOld;
2728

2829
public:
2930
void clear();
3031
void prepare(const std::string& vSearchString);
32+
const SignalItem& getRootItem() const;
3133
void displayTree(bool vCollapseAll, bool vExpandAll);
3234

3335
private:

0 commit comments

Comments
 (0)