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

Function visualiseSectorsToFile

src/fe-analyselayout.cc:41–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39static const int TRACKS = 83;
40
41void visualiseSectorsToFile(const Image& image, const std::string& filename)
42{
43 Bitmap bitmap(writeImg, imgWidth, imgHeight);
44 if (bitmap.filename.empty())
45 error("you must specify an image filename to write to");
46
47 Agg2D& painter = bitmap.painter();
48 painter.clearAll(0xff, 0xff, 0xff);
49
50 const double radians_per_ns = 2.0 * M_PI / (period * 1e6);
51 const double available_width = bitmap.width - 2 * BORDER;
52 const double available_height = bitmap.height - 2 * BORDER;
53 const double panel_centre =
54 (sideToDraw == -1) ? (available_width / 4) : (available_width / 2);
55 const double panel_size =
56 (sideToDraw == -1) ? std::min(available_width / 2, available_height)
57 : std::min(available_width, available_height);
58 const double disk_radius = (panel_size - BORDER) / 2;
59
60 auto drawSide = [&](int side)
61 {
62 int xpos =
63 BORDER + ((sideToDraw == -1) ? (panel_centre + side * panel_size)
64 : panel_centre);
65
66 for (int physicalCylinder = 0; physicalCylinder < TRACKS;
67 physicalCylinder++)
68 {
69 double visibleDistance =
70 (TRACKS * 0.5) + (TRACKS - physicalCylinder);
71 double radius = (disk_radius * visibleDistance) / (TRACKS * 1.5);
72 painter.noFill();
73 painter.lineColor(0x88, 0x88, 0x88);
74 painter.lineWidth(disk_radius / (TRACKS * 2));
75 painter.ellipse(xpos, available_height / 2, radius, radius);
76
77 nanoseconds_t offset = 0;
78 if (alignWithSector != -1)
79 {
80 for (const auto& sector : image)
81 {
82 if ((sector->physicalLocation->head == side) &&
83 (sector->physicalLocation->cylinder ==
84 physicalCylinder) &&
85 (sector->logicalSector == alignWithSector))
86 {
87 offset = sector->headerStartTime;
88 if (!offset)
89 offset = sector->dataStartTime;
90 break;
91 }
92 }
93 }
94
95 auto drawArc = [&](nanoseconds_t start, nanoseconds_t end)
96 {
97 start = fmod(start, period * 1000000.0);
98 end = fmod(end, period * 1000000.0);

Callers 1

mainAnalyseLayoutFunction · 0.85

Calls 9

errorFunction · 0.85
clearAllMethod · 0.80
noFillMethod · 0.80
lineColorMethod · 0.80
lineWidthMethod · 0.80
emptyMethod · 0.45
ellipseMethod · 0.45
arcMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected