MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / OnPaint

Method OnPaint

src/gui/histogramviewer.cc:38–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void HistogramViewer::OnPaint(wxPaintEvent&)
39{
40 wxPaintDC dc(this);
41 dc.SetBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
42 dc.Clear();
43
44 if (_blank)
45 return;
46
47 uint32_t max =
48 *std::max_element(std::begin(_data.buckets), std::end(_data.buckets));
49 dc.SetPen(*wxGREY_PEN);
50 for (int x = 0; x < 256; x++)
51 {
52 double v = (double)_data.buckets[x] / (double)max;
53 dc.DrawLine({BORDER + x, BORDER + HEIGHT},
54 {BORDER + x, BORDER + HEIGHT - (int)(v * HEIGHT)});
55 }
56
57 dc.SetPen(*wxBLACK_PEN);
58 dc.DrawLine({BORDER, BORDER + HEIGHT}, {BORDER + WIDTH, BORDER + HEIGHT});
59 dc.DrawLine({BORDER, BORDER + HEIGHT}, {BORDER, BORDER});
60
61 dc.SetPen(*wxRED_PEN);
62 {
63 int y = ((double)_data.signalLevel / (double)max) * HEIGHT;
64 dc.DrawLine({0, BORDER + HEIGHT - y},
65 {2 * BORDER + WIDTH, BORDER + HEIGHT - y});
66 }
67
68 if (_clock != 0.0)
69 {
70 int x = _clock / NS_PER_TICK;
71 dc.DrawLine({BORDER + x, 2 * BORDER + HEIGHT}, {BORDER + x, 0});
72 }
73
74 {
75 wxString text = "Clock interval";
76 dc.SetFont(_font);
77 auto size = dc.GetTextExtent(text);
78 dc.DrawText(text, {BORDER + WIDTH - size.GetWidth(), BORDER + HEIGHT});
79 }
80
81 {
82 wxString text = "Frequency";
83 dc.SetFont(_font);
84 auto size = dc.GetTextExtent(text);
85 dc.DrawRotatedText(
86 text, BORDER - size.GetHeight(), BORDER + size.GetWidth(), 90);
87 }
88}

Callers

nothing calls this directly

Calls 1

ClearMethod · 0.45

Tested by

no test coverage detected