mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Display object lengths in the flux viewer.
This commit is contained in:
@@ -10,19 +10,19 @@
|
||||
|
||||
static Bytes fakeBits(const std::vector<bool>& bits)
|
||||
{
|
||||
Bytes result;
|
||||
ByteWriter bw(result);
|
||||
Bytes result;
|
||||
ByteWriter bw(result);
|
||||
|
||||
auto it = bits.begin();
|
||||
while (it != bits.end())
|
||||
{
|
||||
uint8_t b = (*it++) << 4;
|
||||
if (it != bits.end())
|
||||
b |= *it++;
|
||||
bw.write_8(b);
|
||||
}
|
||||
auto it = bits.begin();
|
||||
while (it != bits.end())
|
||||
{
|
||||
uint8_t b = (*it++) << 4;
|
||||
if (it != bits.end())
|
||||
b |= *it++;
|
||||
bw.write_8(b);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
class ExplorerPanelImpl :
|
||||
@@ -192,9 +192,9 @@ private:
|
||||
Bytes bytes;
|
||||
switch (explorerDecodeChoice->GetSelection())
|
||||
{
|
||||
case 0:
|
||||
bytes = fakeBits(bits);
|
||||
break;
|
||||
case 0:
|
||||
bytes = fakeBits(bits);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
bytes = toBytes(bits);
|
||||
|
||||
@@ -65,8 +65,17 @@ void FluxViewerControl::SetFlux(std::shared_ptr<const TrackFlux> flux)
|
||||
|
||||
_scrollPosition = 0;
|
||||
_totalDuration = 0;
|
||||
_events.clear();
|
||||
for (const auto& trackdata : _flux->trackDatas)
|
||||
{
|
||||
for (const auto& record : trackdata->records)
|
||||
{
|
||||
_events.insert(_totalDuration + record->startTime);
|
||||
_events.insert(_totalDuration + record->endTime);
|
||||
}
|
||||
|
||||
_totalDuration += trackdata->fluxmap->duration();
|
||||
}
|
||||
|
||||
auto size = GetSize();
|
||||
_nanosecondsPerPixel = (double)_totalDuration / (double)size.GetWidth();
|
||||
@@ -128,14 +137,16 @@ void FluxViewerControl::OnPaint(wxPaintEvent&)
|
||||
auto size = GetSize();
|
||||
int w = size.GetWidth();
|
||||
int h = size.GetHeight();
|
||||
constexpr int rows = 4;
|
||||
constexpr int rows = 5;
|
||||
int th = h / rows;
|
||||
int th2 = th / 2;
|
||||
int ch = th * 2 / 3;
|
||||
int ch2 = ch / 2;
|
||||
int t1y = th / 2;
|
||||
int t2y = th + th / 2;
|
||||
int t3y = th * 2 + th / 2;
|
||||
int t4y = th * 3 + th / 2;
|
||||
int t1y = th2;
|
||||
int t2y = th + th2;
|
||||
int t3y = th * 2 + th2;
|
||||
int t4y = th * 3 + th2;
|
||||
int t5y = th * 4 + th2;
|
||||
|
||||
int x = -_scrollPosition / _nanosecondsPerPixel;
|
||||
nanoseconds_t fluxStartTime = 0;
|
||||
@@ -155,7 +166,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&)
|
||||
dc.SetPen(FOREGROUND_PEN);
|
||||
dc.DrawLine({x, t1y}, {x + fw, t1y});
|
||||
dc.DrawLine({x, t2y}, {x + fw, t2y});
|
||||
dc.DrawLine({x, t3y}, {x + fw, t3y});
|
||||
dc.DrawLine({x, t4y}, {x + fw, t4y});
|
||||
|
||||
/* Index lines. */
|
||||
|
||||
@@ -203,11 +214,11 @@ void FluxViewerControl::OnPaint(wxPaintEvent&)
|
||||
ts = ch2 / 2;
|
||||
if ((tick % (100 * tickStep)) == 0)
|
||||
ts = ch2;
|
||||
dc.DrawLine({x + xx, t3y - ts}, {x + xx, t3y + ts});
|
||||
dc.DrawLine({x + xx, t4y - ts}, {x + xx, t4y + ts});
|
||||
if ((tick % (10 * tickStep)) == 0)
|
||||
{
|
||||
dc.DrawText(fmt::format("{:.3f}ms", tick / 1e6),
|
||||
{x + xx, t3y - ch2});
|
||||
{x + xx, t4y - ch2});
|
||||
}
|
||||
|
||||
tick += tickStep;
|
||||
@@ -415,7 +426,7 @@ void FluxViewerControl::OnPaint(wxPaintEvent&)
|
||||
density));
|
||||
wxBrush brush(colour);
|
||||
dc.SetBrush(brush);
|
||||
dc.DrawRectangle({x + fx, t4y - ch2}, {1, ch});
|
||||
dc.DrawRectangle({x + fx, t5y - ch2}, {1, ch});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -432,20 +443,51 @@ void FluxViewerControl::OnPaint(wxPaintEvent&)
|
||||
|
||||
int fx = fmr.tell().ns() / _nanosecondsPerPixel;
|
||||
if (((x + fx) > 0) && ((x + fx) < w))
|
||||
dc.DrawLine({x + fx, t4y - ch2}, {x + fx, t4y + ch2});
|
||||
dc.DrawLine({x + fx, t5y - ch2}, {x + fx, t5y + ch2});
|
||||
if ((x + fx) >= w)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dc.SetPen(FLUX_PEN);
|
||||
dc.DrawLine({x, t4y}, {x + fw, t4y});
|
||||
dc.DrawLine({x, t5y}, {x + fw, t5y});
|
||||
}
|
||||
|
||||
x += fw;
|
||||
fluxStartTime += duration;
|
||||
}
|
||||
|
||||
/* Ruler. */
|
||||
|
||||
{
|
||||
nanoseconds_t cursorTime =
|
||||
(_mouseX * _nanosecondsPerPixel) + _scrollPosition;
|
||||
auto rightEvent = _events.lower_bound(cursorTime);
|
||||
if (rightEvent != _events.end())
|
||||
{
|
||||
auto leftEvent = rightEvent;
|
||||
leftEvent--;
|
||||
if (leftEvent != _events.begin())
|
||||
{
|
||||
int lx = (*leftEvent - _scrollPosition) / _nanosecondsPerPixel;
|
||||
int rx = (*rightEvent - _scrollPosition) / _nanosecondsPerPixel;
|
||||
int dx = rx - lx;
|
||||
int y = t3y - th2;
|
||||
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
dc.SetPen(FOREGROUND_PEN);
|
||||
dc.DrawLine({lx, y}, {rx, y});
|
||||
|
||||
auto text =
|
||||
fmt::format("{:.3f}ms", (*rightEvent - *leftEvent) / 1e6);
|
||||
auto size = dc.GetTextExtent(text);
|
||||
int mx = (lx + rx) / 2;
|
||||
dc.DrawText(text, {mx - size.GetWidth() / 2, y});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_rightClicked = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ private:
|
||||
nanoseconds_t _scrollPosition = 0;
|
||||
nanoseconds_t _totalDuration = 0;
|
||||
double _nanosecondsPerPixel = 0;
|
||||
std::set<nanoseconds_t> _events;
|
||||
std::vector<float> _densityMap;
|
||||
int _dragStartX = -1;
|
||||
nanoseconds_t _dragStartPosition = -1;
|
||||
|
||||
@@ -31,7 +31,7 @@ void HistogramViewer::Redraw(const Fluxmap& fluxmap, nanoseconds_t clock)
|
||||
{
|
||||
_data = fluxmap.guessClock();
|
||||
_clock = clock;
|
||||
_blank = false;
|
||||
_blank = false;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ void HistogramViewer::OnPaint(wxPaintEvent&)
|
||||
dc.SetBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
|
||||
dc.Clear();
|
||||
|
||||
if (_blank)
|
||||
return;
|
||||
if (_blank)
|
||||
return;
|
||||
|
||||
uint32_t max =
|
||||
*std::max_element(std::begin(_data.buckets), std::end(_data.buckets));
|
||||
@@ -65,7 +65,7 @@ void HistogramViewer::OnPaint(wxPaintEvent&)
|
||||
{2 * BORDER + WIDTH, BORDER + HEIGHT - y});
|
||||
}
|
||||
|
||||
if (_clock != 0.0)
|
||||
if (_clock != 0.0)
|
||||
{
|
||||
int x = _clock / NS_PER_TICK;
|
||||
dc.DrawLine({BORDER + x, 2 * BORDER + HEIGHT}, {BORDER + x, 0});
|
||||
|
||||
@@ -218,8 +218,8 @@ public:
|
||||
std::shared_ptr<const TrackFlux> trackdata) override
|
||||
{
|
||||
visualiser->SetTrackData(trackdata);
|
||||
if (!trackdata->trackDatas.empty())
|
||||
histogram->Redraw(*(*trackdata->trackDatas.begin())->fluxmap, 0);
|
||||
if (!trackdata->trackDatas.empty())
|
||||
histogram->Redraw(*(*trackdata->trackDatas.begin())->fluxmap, 0);
|
||||
}
|
||||
|
||||
void SetDisk(std::shared_ptr<const DiskFlux> diskdata) override
|
||||
|
||||
Reference in New Issue
Block a user