77
88void SignalTree::clear () {
99 m_RootItem.clear ();
10- m_SignalSeriesOld.clear ();
1110}
1211
1312void 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+
5960void SignalTree::displayTree (bool vCollapseAll, bool vExpandAll) {
6061 displayItemRecurs (m_RootItem, vCollapseAll, vExpandAll);
6162}
6263
6364void 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}
0 commit comments