| 135 | } |
| 136 | |
| 137 | static void drawPhysicalMap(unsigned minPhysicalCylinder, |
| 138 | unsigned maxPhysicalCylinder, |
| 139 | unsigned minPhysicalHead, |
| 140 | unsigned maxPhysicalHead, |
| 141 | const Disk& disk) |
| 142 | { |
| 143 | int numPhysicalCylinders = maxPhysicalCylinder - minPhysicalCylinder + 1; |
| 144 | int numPhysicalHeads = maxPhysicalHead - minPhysicalHead + 1; |
| 145 | if (!numPhysicalCylinders || !numPhysicalHeads) |
| 146 | return; |
| 147 | |
| 148 | auto originalFontSize = ImGui::GetFontSize(); |
| 149 | if (ImGui::BeginTable("physicalMap", |
| 150 | numPhysicalCylinders + 1, |
| 151 | ImGuiTableFlags_NoSavedSettings | |
| 152 | ImGuiTableFlags_HighlightHoveredColumn | |
| 153 | ImGuiTableFlags_NoClip | ImGuiTableFlags_NoPadInnerX | |
| 154 | ImGuiTableFlags_NoPadOuterX | ImGuiTableFlags_Borders)) |
| 155 | { |
| 156 | DEFER(ImGui::EndTable()); |
| 157 | |
| 158 | ImGui::PushFont(NULL, originalFontSize * 0.6); |
| 159 | DEFER(ImGui::PopFont()); |
| 160 | |
| 161 | ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {0, 0}); |
| 162 | DEFER(ImGui::PopStyleVar()); |
| 163 | |
| 164 | float rowHeight = originalFontSize * 0.6 * 2.0; |
| 165 | ImGui::TableSetupColumn( |
| 166 | "", ImGuiTableColumnFlags_WidthFixed, originalFontSize); |
| 167 | |
| 168 | drawCylinderRule(minPhysicalCylinder, maxPhysicalCylinder); |
| 169 | |
| 170 | for (unsigned head = minPhysicalHead; head <= maxPhysicalHead; head++) |
| 171 | { |
| 172 | ImGui::TableNextRow(ImGuiTableRowFlags_None, rowHeight); |
| 173 | ImGui::TableNextColumn(); |
| 174 | |
| 175 | auto text = fmt::format("h{}", head); |
| 176 | auto textSize = ImGui::CalcTextSize(text.c_str()); |
| 177 | ImGui::SetCursorPos( |
| 178 | {ImGui::GetCursorPosX() + ImGui::GetColumnWidth() / 2 - |
| 179 | textSize.x / 2, |
| 180 | ImGui::GetCursorPosY() + rowHeight / 2 - textSize.y / 2}); |
| 181 | ImGui::Text("%s", text.c_str()); |
| 182 | |
| 183 | ImGui::PushStyleVar( |
| 184 | ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f, 0.5f)); |
| 185 | DEFER(ImGui::PopStyleVar()); |
| 186 | |
| 187 | for (unsigned cylinder = minPhysicalCylinder; |
| 188 | cylinder <= maxPhysicalCylinder; |
| 189 | cylinder++) |
| 190 | { |
| 191 | auto [tooltip, colour] = analyseTrack(disk, cylinder, head); |
| 192 | ImGui::PushStyleColor(ImGuiCol_Header, colour); |
| 193 | DEFER(ImGui::PopStyleColor()); |
| 194 | ImGui::PushFont(NULL, originalFontSize); |
no test coverage detected