Skip to content

Commit 978d46b

Browse files
committed
History: display full timestamp of the waveform including date in mouseover tooltip
1 parent 8dfb3a0 commit 978d46b

2 files changed

Lines changed: 61 additions & 3 deletions

File tree

src/ngscopeclient/HistoryDialog.cpp

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -42,6 +42,33 @@ using namespace std;
4242
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4343
// TimePoint
4444

45+
string TimePoint::PrettyPrintDate() const
46+
{
47+
auto base = GetSec();
48+
auto offset = GetFs();
49+
50+
//If offset is >1 sec, shift the timestamp
51+
if(offset > FS_PER_SECOND)
52+
{
53+
base += (offset / FS_PER_SECOND);
54+
offset = offset % (int64_t)FS_PER_SECOND;
55+
}
56+
57+
//Format timestamp
58+
char tmp[128];
59+
struct tm ltime;
60+
61+
#ifdef _WIN32
62+
localtime_s(&ltime, &base);
63+
#else
64+
localtime_r(&base, &ltime);
65+
#endif
66+
67+
strftime(tmp, sizeof(tmp), "%F", &ltime);
68+
string stime = tmp;
69+
return stime;
70+
}
71+
4572
string TimePoint::PrettyPrint() const
4673
{
4774
auto base = GetSec();
@@ -65,7 +92,6 @@ string TimePoint::PrettyPrint() const
6592
#endif
6693

6794
//round to nearest 100ps for display
68-
//TODO: do we want to include date as an optional column or something??
6995
strftime(tmp, sizeof(tmp), "%H:%M:%S.", &ltime);
7096
string stime = tmp;
7197
snprintf(tmp, sizeof(tmp), "%010zu", static_cast<size_t>(offset / 100000));
@@ -148,6 +174,37 @@ bool HistoryDialog::DoRender()
148174
m_selectionChanged = true;
149175
m_selectedMarker = nullptr;
150176
}
177+
if(ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
178+
{
179+
//Format full details for saved waveforms
180+
string strDetails;
181+
strDetails += string("Waveform acquired on ") + point->m_time.PrettyPrintDate() +
182+
" at " + point->m_time.PrettyPrint() + "\n";
183+
strDetails += "\n";
184+
strDetails += string("Data for ") + to_string(point->m_history.size());
185+
if(point->m_history.size() > 1)
186+
strDetails += " instruments:\n";
187+
else
188+
strDetails += " instrument:\n";
189+
for(auto& jt : point->m_history)
190+
{
191+
//Figure out how many channels actually have non-null waveform data
192+
size_t numNonNull = 0;
193+
for(auto& kt : jt.second)
194+
{
195+
if(kt.second)
196+
numNonNull ++;
197+
}
198+
199+
strDetails += " * " + jt.first->m_nickname + " (" + to_string(numNonNull) + " channels with data)\n";
200+
}
201+
202+
ImGui::BeginTooltip();
203+
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
204+
ImGui::TextUnformatted(strDetails.c_str());
205+
ImGui::PopTextWrapPos();
206+
ImGui::EndTooltip();
207+
}
151208

152209
if(ImGui::BeginPopupContextItem())
153210
{

src/ngscopeclient/Marker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -64,6 +64,7 @@ class TimePoint : public std::pair<time_t, int64_t>
6464
{ second = fs; }
6565

6666
std::string PrettyPrint() const;
67+
std::string PrettyPrintDate() const;
6768

6869
int64_t operator-(const TimePoint& rhs)
6970
{

0 commit comments

Comments
 (0)