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

Method drawContent

src/gui2/visualiserview.cc:30–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void VisualiserView::drawContent()
31{
32 const auto& diskLayout = Datastore::getDiskLayout();
33 const auto& disk = Datastore::getDisk();
34
35 ImDrawList* drawList = ImGui::GetWindowDrawList();
36 auto pos = ImGui::GetCursorScreenPos();
37 auto size = ImGui::GetContentRegionAvail();
38 auto padding = ImGui::GetStyle().WindowPadding;
39 uint32_t fg = ImGui::GetColorU32(ImGuiCol_Text);
40 uint32_t bg = ImGui::GetColorU32(ImGuiCol_WindowBg);
41 uint32_t diskbg = ImGui::GetColorU32(ImGuiCol_FrameBg);
42
43 ImVec2 centre(pos.x + size.x / 2, pos.y + size.y / 2);
44 float outerRadius = (size.x - padding.x * 2) / 2;
45 ImVec2 side0pos(centre.x, centre.y - outerRadius - padding.y);
46 ImVec2 side1pos(centre.x, centre.y + outerRadius + padding.y);
47
48 bool badData = false;
49
50 auto drawCentered =
51 [&](const ImVec2& pos, uint32_t colour, const std::string& s)
52 {
53 auto size = ImGui::CalcTextSize(s.c_str());
54 drawList->AddText({pos.x - size.x / 2, pos.y - size.y / 2},
55 colour,
56 &*s.begin(),
57 &*s.end());
58 };
59
60 auto drawSide = [&](int head, ImVec2 pos)
61 {
62 drawList->AddCircleFilled(pos, outerRadius, diskbg, 0);
63 drawList->AddCircleFilled(pos, INNER_RADIUS, bg, 0);
64 drawList->AddCircle(pos, outerRadius, fg, 0);
65 drawList->AddCircle(pos, INNER_RADIUS, fg, 0);
66 drawCentered(pos, fg, fmt::format("h{}", head));
67
68 if (!diskLayout || !disk)
69 return;
70
71 int numPhysicalTracks =
72 diskLayout->maxPhysicalCylinder - diskLayout->minPhysicalCylinder;
73 float trackSpacing = (float)(outerRadius - INNER_RADIUS) /
74 (float)(numPhysicalTracks + 2);
75
76 for (const auto& [ch, track] : disk->tracksByPhysicalLocation)
77 {
78 if (ch.head != head)
79 continue;
80 if (!track->fluxmap)
81 continue;
82
83 const auto& indexMarks = track->fluxmap->getIndexMarks();
84 nanoseconds_t rotationalPeriod;
85 if (indexMarks.empty())
86 {
87 badData = true;

Callers

nothing calls this directly

Calls 5

ImVec2Class · 0.85
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected