Skip to content

Commit de6fc86

Browse files
committed
Added error list to graph view
1 parent b47ed70 commit de6fc86

9 files changed

Lines changed: 262 additions & 46 deletions

src/ngscopeclient/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ add_executable(ngscopeclient
7070
EmbeddedTriggerPropertiesDialog.cpp
7171
FileBrowser.cpp
7272
FilterGraphEditor.cpp
73+
FilterGraphErrorWindow.cpp
7374
FilterGraphWorkspace.cpp
7475
FilterPropertiesDialog.cpp
7576
FontManager.cpp

src/ngscopeclient/Dialog.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void Dialog::renderNumericValue(const std::string& value, bool &clicked, bool &h
402402
if(use7Segment)
403403
{
404404
if(digitHeight <= 0) digitHeight = ImGui::GetFontSize();
405-
405+
406406
Render7SegmentValue(value,color,digitHeight,clicked,hovered,clickable);
407407
}
408408
else
@@ -419,7 +419,7 @@ void Dialog::renderNumericValue(const std::string& value, bool &clicked, bool &h
419419
clicked |= ImGui::IsItemClicked();
420420
if(ImGui::IsItemHovered())
421421
{ // Hand cursor
422-
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
422+
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
423423
// Lighter if hovered
424424
color.x = color.x * 1.2f;
425425
color.y = color.y * 1.2f;
@@ -594,7 +594,7 @@ bool Dialog::renderEditableProperty(float width, const std::string& label, std::
594594
//Prevent focus from going to parent node
595595
ImGui::ActivateItemByID(0);
596596
}
597-
else if((ImGui::GetActiveID() != editId) && (!explicitApply || !ImGui::IsItemActive() /* This is here to prevent detecting focus lost when apply button is clicked */))
597+
else if((ImGui::GetActiveID() != editId) && (!explicitApply || !ImGui::IsItemActive() /* This is here to prevent detecting focus lost when apply button is clicked */))
598598
{ // Detect focus lost => stop editing too
599599
if(explicitApply)
600600
{ // Cancel on focus lost
@@ -743,7 +743,7 @@ template bool Dialog::renderEditablePropertyWithExplicitApply<int64_t>(float wid
743743
0b00000010 : Top left v segment
744744
0b00000001 : Center h segment
745745
*/
746-
static char SEGMENTS[] =
746+
static char SEGMENTS[] =
747747
{
748748
0x7E, // 0
749749
0x30, // 1
@@ -781,7 +781,7 @@ void Dialog::Render7SegmentDigit(ImDrawList* drawList, uint8_t digit, ImVec2 siz
781781
ImVec2 centerPosition(position.x+halfSize.x,position.y+halfSize.y);
782782
float w = thickness;
783783
float h = thickness/2;
784-
float segmentSpec[7][4] =
784+
float segmentSpec[7][4] =
785785
{
786786
{-1, -1, h, h}, // Top h segment
787787
{ 1, -1, -h, h}, // Top right v seglent
@@ -795,7 +795,7 @@ void Dialog::Render7SegmentDigit(ImDrawList* drawList, uint8_t digit, ImVec2 siz
795795
{
796796
ImVec2 topLeft, bottomRight;
797797
if(i % 3 == 0)
798-
{
798+
{
799799
// Horizontal segment
800800
topLeft = ImVec2(centerPosition.x + segmentSpec[i][0] * halfSize.x + segmentSpec[i][2], centerPosition.y + segmentSpec[i][1] * halfSize.y + segmentSpec[i][3] - h);
801801
bottomRight = ImVec2(topLeft.x + size.x - w, topLeft.y + w);
@@ -812,7 +812,7 @@ void Dialog::Render7SegmentDigit(ImDrawList* drawList, uint8_t digit, ImVec2 siz
812812
if(segmentSize.x > segmentSize.y)
813813
{
814814
// Horizontal segment
815-
ImVec2 points[] =
815+
ImVec2 points[] =
816816
{
817817
{topLeft.x + u, topLeft.y + segmentSize.y * .5f},
818818
{topLeft.x + space, topLeft.y},
@@ -898,7 +898,7 @@ void Dialog::Render7SegmentValue(const std::string& value, ImVec4 color, float d
898898
else
899899
{
900900
// Iterate on each char of the value string
901-
for(const char c : value)
901+
for(const char c : value)
902902
{
903903
if(c >= '0' && c <='9')
904904
{
@@ -1021,4 +1021,4 @@ void Dialog::Render7SegmentValue(const std::string& value, ImVec4 color, float d
10211021
ImVec2(position.x + x + thickness, position.y),
10221022
fcolor,
10231023
unit.c_str());
1024-
}
1024+
}

src/ngscopeclient/Dialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ class Dialog
117117

118118
///@brief optional reference to session
119119
Session* m_session;
120+
120121
///@brief optional reference to parent MainWindow
121122
MainWindow* m_parent;
122123

123-
124124
///@brief Id of the item currently beeing edited
125125
ImGuiID m_editedItemId = 0;
126+
126127
///@brief Id of the last edited item
127128
ImGuiID m_lastEditedItemId = 0;
128129
};

src/ngscopeclient/FilterGraphEditor.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,9 @@ void FilterGraphGroup::MoveBy(ImVec2 displacement)
195195
// Construction / destruction
196196

197197
FilterGraphEditor::FilterGraphEditor(Session& session, MainWindow* parent)
198-
: Dialog("Filter Graph Editor", "Filter Graph Editor", ImVec2(800, 600))
199-
, m_session(session)
200-
, m_parent(parent)
198+
: Dialog("Filter Graph Editor", "Filter Graph Editor", ImVec2(800, 600), &session, parent)
201199
, m_nextID(1)
200+
, m_errorWindow(&session)
202201
{
203202
m_config.SaveSettings = &FilterGraphEditor::SaveSettingsCallback;
204203
m_config.LoadSettings = &FilterGraphEditor::LoadSettingsCallback;
@@ -215,7 +214,7 @@ FilterGraphEditor::FilterGraphEditor(Session& session, MainWindow* parent)
215214
//Start by reserving group IDs so they don't get reused by anything else
216215
auto groups = parent->GetGraphEditorGroups();
217216
for(auto it : groups)
218-
m_session.m_idtable.ReserveID(it.first);
217+
m_session->m_idtable.ReserveID(it.first);
219218
for(auto it : groups)
220219
{
221220
auto group = make_shared<FilterGraphGroup>(*this);
@@ -243,6 +242,9 @@ bool FilterGraphEditor::Render()
243242
else if(bdlg)
244243
bdlg->RunFileDialog();
245244

245+
//Render our error window
246+
m_errorWindow.Render();
247+
246248
return Dialog::Render();
247249
}
248250

@@ -253,7 +255,7 @@ map<shared_ptr<Instrument>, vector<InstrumentChannel*> > FilterGraphEditor::GetA
253255
{
254256
map<shared_ptr<Instrument>, vector<InstrumentChannel*> > ret;
255257

256-
auto insts = m_session.GetInstruments();
258+
auto insts = m_session->GetInstruments();
257259
for(auto inst : insts)
258260
{
259261
vector<InstrumentChannel*> chans;
@@ -343,7 +345,7 @@ vector<FlowGraphNode*> FilterGraphEditor::GetAllNodes()
343345
}
344346

345347
//Triggers
346-
auto insts = m_session.GetInstruments();
348+
auto insts = m_session->GetInstruments();
347349
for(auto inst : insts)
348350
{
349351
auto scope = dynamic_pointer_cast<Oscilloscope>(inst);
@@ -472,7 +474,7 @@ bool FilterGraphEditor::DoRender()
472474
if(ftype)
473475
{
474476
string fname((char*)ftype->Data, ftype->DataSize);
475-
auto cat = m_session.GetReferenceFilter(fname)->GetCategory();
477+
auto cat = m_session->GetReferenceFilter(fname)->GetCategory();
476478

477479
if(ftype->IsDelivery())
478480
{
@@ -516,7 +518,7 @@ bool FilterGraphEditor::DoRender()
516518
DoNodeForGroup(it.first);
517519

518520
//Make nodes for all instrument channels
519-
bool multiInst = (m_session.GetInstrumentCount() > 1);
521+
bool multiInst = (m_session->GetInstrumentCount() > 1);
520522
auto chans = GetAllVisibleChannels();
521523
for(auto it : chans)
522524
{
@@ -529,7 +531,7 @@ bool FilterGraphEditor::DoRender()
529531
ax::NodeEditor::SetNodePosition(newNode, ImGui::GetMousePos());
530532

531533
//Make nodes for all triggers
532-
auto insts = m_session.GetInstruments();
534+
auto insts = m_session->GetInstruments();
533535
for(auto inst : insts)
534536
{
535537
auto scope = dynamic_pointer_cast<Oscilloscope>(inst);
@@ -545,7 +547,7 @@ bool FilterGraphEditor::DoRender()
545547

546548
//Filters
547549
auto filters = Filter::GetAllInstances();
548-
auto filterperf = m_session.GetFilterGraphRuntime();
550+
auto filterperf = m_session->GetFilterGraphRuntime();
549551
for(auto f : filters)
550552
{
551553
DoNodeForChannel(f, nullptr, false, filterperf[f]);
@@ -556,7 +558,7 @@ bool FilterGraphEditor::DoRender()
556558
ClearOldPropertiesDialogs();
557559

558560
//All nodes
559-
auto nodes = m_session.GetAllGraphNodes();
561+
auto nodes = m_session->GetAllGraphNodes();
560562

561563
//Add links within groups
562564
for(auto it : m_groups)
@@ -581,7 +583,7 @@ bool FilterGraphEditor::DoRender()
581583
}
582584

583585
//Add links from each trigger input to the stream it's fed by
584-
auto& scopes = m_session.GetScopes();
586+
auto& scopes = m_session->GetScopes();
585587
for(auto scope : scopes)
586588
{
587589
auto trig = scope->GetTrigger();
@@ -678,7 +680,7 @@ ax::NodeEditor::NodeId FilterGraphEditor::GetID(FlowGraphNode* node)
678680
if(trig)
679681
return GetID(trig);
680682

681-
return m_session.m_idtable.emplace(node);
683+
return m_session->m_idtable.emplace(node);
682684
}
683685

684686
/**
@@ -1399,7 +1401,7 @@ ax::NodeEditor::PinId FilterGraphEditor::CanonicalizePin(ax::NodeEditor::PinId p
13991401
void FilterGraphEditor::HandleLinkCreationRequests(Filter*& fReconfigure)
14001402
{
14011403
//for some reason node editor wants colors as vec4 not ImU32
1402-
auto& prefs = m_session.GetPreferences();
1404+
auto& prefs = m_session->GetPreferences();
14031405
auto validcolor = prefs.GetColorFloat4("Appearance.Filter Graph.valid_link_color");
14041406
auto invalidcolor = prefs.GetColorFloat4("Appearance.Filter Graph.invalid_link_color");
14051407

@@ -1630,7 +1632,7 @@ void FilterGraphEditor::CreateChannelMenu()
16301632
{
16311633
vector<StreamDescriptor> streams;
16321634

1633-
auto& scopes = m_session.GetScopes();
1635+
auto& scopes = m_session->GetScopes();
16341636
for(auto scope : scopes)
16351637
{
16361638
//Channels
@@ -1910,7 +1912,7 @@ void FilterGraphEditor::DoNodeForTrigger(Trigger* trig)
19101912
{
19111913
//TODO: special color for triggers?
19121914
//Or use a preference?
1913-
auto& prefs = m_session.GetPreferences();
1915+
auto& prefs = m_session->GetPreferences();
19141916
auto tsize = ImGui::GetFontSize();
19151917
auto color = ColorFromString("#808080");
19161918
auto id = GetID(trig);
@@ -1925,7 +1927,7 @@ void FilterGraphEditor::DoNodeForTrigger(Trigger* trig)
19251927
auto pos = ax::NodeEditor::GetNodePosition(id);
19261928
auto size = ax::NodeEditor::GetNodeSize(id);
19271929
string headerText = trig->GetTriggerDisplayName();
1928-
if(m_session.IsMultiScope())
1930+
if(m_session->IsMultiScope())
19291931
headerText = trig->GetScope()->m_nickname + ": " + headerText;
19301932

19311933
//Figure out how big the header text is and reserve space for it
@@ -2011,7 +2013,7 @@ void FilterGraphEditor::DoNodeForChannel(
20112013
if(displaycolor.empty())
20122014
displaycolor = "#808080";
20132015

2014-
auto& prefs = m_session.GetPreferences();
2016+
auto& prefs = m_session->GetPreferences();
20152017
auto errorColor = prefs.GetColor("Appearance.Filter Graph.error_outline_color");
20162018

20172019
//Get some configuration / style settings
@@ -2403,7 +2405,7 @@ void FilterGraphEditor::HandleDoubleClicks()
24032405
return;
24042406

24052407
//Spawn the appropriate dialog
2406-
auto node = m_session.m_idtable.Lookup<FlowGraphNode*>(static_cast<uintptr_t>(id));
2408+
auto node = m_session->m_idtable.Lookup<FlowGraphNode*>(static_cast<uintptr_t>(id));
24072409
auto trig = dynamic_cast<Trigger*>(node);
24082410
auto ochan = dynamic_cast<OscilloscopeChannel*>(node);
24092411
auto bo = dynamic_cast<BERTOutputChannel*>(node);
@@ -2450,7 +2452,7 @@ bool FilterGraphEditor::HandleNodeProperties()
24502452

24512453
else
24522454
{
2453-
auto node = m_session.m_idtable.Lookup<FlowGraphNode*>(static_cast<uintptr_t>(id));
2455+
auto node = m_session->m_idtable.Lookup<FlowGraphNode*>(static_cast<uintptr_t>(id));
24542456
auto trig = dynamic_cast<Trigger*>(node);
24552457
auto o = dynamic_cast<OscilloscopeChannel*>(node);
24562458
auto f = dynamic_cast<Filter*>(o);
@@ -2515,7 +2517,7 @@ bool FilterGraphEditor::HandleNodeProperties()
25152517

25162518
if(oldTrigger != newTrigger)
25172519
{
2518-
m_session.m_idtable.replace(oldTrigger, newTrigger);
2520+
m_session->m_idtable.replace(oldTrigger, newTrigger);
25192521
triggerChanged = true;
25202522
}
25212523
}
@@ -2568,7 +2570,7 @@ void FilterGraphEditor::HandleBackgroundContextMenu()
25682570
void FilterGraphEditor::DoAddMenu()
25692571
{
25702572
//Get all generation filters, sorted alphabetically
2571-
auto& refs = m_session.GetReferenceFilters();
2573+
auto& refs = m_session->GetReferenceFilters();
25722574
vector<string> sortedNames;
25732575
for(auto it : refs)
25742576
{
@@ -2652,11 +2654,11 @@ uintptr_t FilterGraphEditor::AllocateID()
26522654
{
26532655
//Get next ID, if it's in use try the next one
26542656
uintptr_t id = m_nextID;
2655-
while(m_session.m_idtable.HasID(id))
2657+
while(m_session->m_idtable.HasID(id))
26562658
id++;
26572659

26582660
//Reserve the ID in the session table so nobody else will try to use it
2659-
m_session.m_idtable.ReserveID(id);
2661+
m_session->m_idtable.ReserveID(id);
26602662

26612663
//We now have an ID that is not in the table, so continue from there
26622664
m_nextID = id + 1;

src/ngscopeclient/FilterGraphEditor.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "Dialog.h"
3939
#include "Session.h"
4040
#include "Bijection.h"
41+
#include "FilterGraphErrorWindow.h"
4142
class EmbeddableDialog;
4243

4344
#include <imgui_node_editor.h>
@@ -164,6 +165,9 @@ class FilterGraphEditor : public Dialog
164165

165166
static bool IsBackEdge(FlowGraphNode* src, FlowGraphNode* dst);
166167

168+
FilterGraphErrorWindow& GetErrorWindow()
169+
{ return m_errorWindow; }
170+
167171
protected:
168172
friend class FilterGraphGroup;
169173

@@ -219,12 +223,6 @@ class FilterGraphEditor : public Dialog
219223
void FilterSubmenu(StreamDescriptor src, const std::string& name, Filter::Category cat);
220224
void CreateChannelMenu();
221225

222-
///@brief Session being manipulated
223-
Session& m_session;
224-
225-
///@brief Top level window
226-
MainWindow* m_parent;
227-
228226
///@brief Graph editor setup
229227
ax::NodeEditor::Config m_config;
230228

@@ -261,13 +259,13 @@ class FilterGraphEditor : public Dialog
261259
ax::NodeEditor::NodeId GetID(FlowGraphNode* node);
262260

263261
ax::NodeEditor::NodeId GetID(InstrumentChannel* chan)
264-
{ return m_session.m_idtable.emplace(chan); }
262+
{ return m_session->m_idtable.emplace(chan); }
265263

266264
ax::NodeEditor::NodeId GetID(Trigger* trig)
267-
{ return m_session.m_idtable.emplace(trig); }
265+
{ return m_session->m_idtable.emplace(trig); }
268266

269267
ax::NodeEditor::NodeId GetID(std::shared_ptr<FilterGraphGroup> group)
270-
{ return m_session.m_idtable.emplace(group.get()); }
268+
{ return m_session->m_idtable.emplace(group.get()); }
271269

272270
uintptr_t AllocateID();
273271
ax::NodeEditor::PinId GetID(StreamDescriptor stream);
@@ -322,6 +320,9 @@ class FilterGraphEditor : public Dialog
322320
void* pThis);
323321

324322
static size_t LoadSettingsCallback(char* data, void* pThis);
323+
324+
//Error message window
325+
FilterGraphErrorWindow m_errorWindow;
325326
};
326327

327328
#endif

0 commit comments

Comments
 (0)