Skip to content

Commit

Permalink
Markers now render properly in the packet view and move in the packet…
Browse files Browse the repository at this point in the history
… view when dragged in the timeline
  • Loading branch information
azonenberg committed Feb 1, 2024
1 parent ed4e583 commit e1ec031
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors
Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
8 changes: 6 additions & 2 deletions src/ngscopeclient/HistoryDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -246,14 +246,18 @@ bool HistoryDialog::DoRender()

//Nickname box
ImGui::TableSetColumnIndex(2);
ImGui::InputText("###nick", &m.m_name);
if(ImGui::InputText("###nick", &m.m_name))
m_parent.GetSession().OnMarkerChanged();

ImGui::PopID();
}

//Execute deletion after drawing the rest of the list
if(deletingMarker)
{
markers.erase(markers.begin() + markerToDelete);
m_parent.GetSession().OnMarkerChanged();
}

ImGui::TreePop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ngscopeclient/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down
2 changes: 1 addition & 1 deletion src/ngscopeclient/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down
2 changes: 1 addition & 1 deletion src/ngscopeclient/Marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down
9 changes: 7 additions & 2 deletions src/ngscopeclient/PacketManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -91,7 +91,6 @@ void PacketManager::RefreshRows()

//Get markers for this waveform, if any
auto& markers = m_session.GetMarkers(wavetime);
LogDebug("Refreshing: %zu markers\n", markers.size());
size_t imarker = 0;
int64_t lastoff = 0;

Expand Down Expand Up @@ -151,6 +150,12 @@ void PacketManager::RefreshRows()
}
}

void PacketManager::OnMarkerChanged()
{
lock_guard<recursive_mutex> lock(m_mutex);
RefreshRows();
}

/**
@brief Handle newly arrived waveform data (may be a change to parameters or a freshly arrived waveform)
*/
Expand Down
4 changes: 3 additions & 1 deletion src/ngscopeclient/PacketManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -189,6 +189,8 @@ class PacketManager
std::vector<RowData>& GetRows()
{ return m_rows; }

void OnMarkerChanged();

protected:
void RemoveChildHistoryFrom(Packet* pack);

Expand Down
12 changes: 11 additions & 1 deletion src/ngscopeclient/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -248,8 +248,18 @@ void Session::AddMarker(Marker m)

//Add the marker
m_markers[m.m_timestamp].push_back(m);
OnMarkerChanged();
}

/**
@brief Called when a marker is added, removed, or modified
*/
void Session::OnMarkerChanged()
{
lock_guard lock(m_packetMgrMutex);
for(auto it : m_packetmgrs)
it.second->OnMarkerChanged();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Scopesession management
Expand Down
2 changes: 2 additions & 0 deletions src/ngscopeclient/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ class Session

std::shared_ptr<TriggerGroup> GetTrendFilterGroup();

void OnMarkerChanged();

protected:
void UpdatePacketManagers(const std::set<FlowGraphNode*>& nodes);

Expand Down
5 changes: 4 additions & 1 deletion src/ngscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -665,7 +665,10 @@ void WaveformArea::PlotContextMenu()
if(hitMarker)
{
if(ImGui::MenuItem("Delete"))
{
markers.erase(markers.begin() + selectedMarker);
m_parent->GetSession().OnMarkerChanged();
}
}

//Otherwise, normal GUI context menu
Expand Down
9 changes: 7 additions & 2 deletions src/ngscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
Expand Down Expand Up @@ -583,7 +583,12 @@ void WaveformGroup::RenderMarkers(ImVec2 pos, ImVec2 size)
{
if(ImGui::IsMouseReleased(ImGuiMouseButton_Left))
m_dragState = DRAG_STATE_NONE;
m_dragMarker->m_offset = XPositionToXAxisUnits(mouse.x);
auto newpos = XPositionToXAxisUnits(mouse.x);
if(m_dragMarker->m_offset != newpos)
{
m_dragMarker->m_offset = newpos;
m_parent->GetSession().OnMarkerChanged();
}
}
}

Expand Down

0 comments on commit e1ec031

Please sign in to comment.