2 // diskdrawthread.cpp: Disk display thread
4 // Part of the WOZ Maker project
6 // (C) 2018 Underground Software
8 // Since this can take a bit of time, we shunt all the heavy lifting to a
9 // separate worker thread so that it doesn't block the GUI thread.
12 #include "diskdrawthread.h"
20 DiskDrawThread::DiskDrawThread(QObject * parent): QThread(parent)
25 DiskDrawThread::~DiskDrawThread()
38 void DiskDrawThread::StartRender(QImage * i)
45 void DiskDrawThread::run()
51 void DiskDrawThread::DrawDisk(QImage * diskImg)
53 QPainter painter(diskImg);
54 painter.setRenderHint(QPainter::Antialiasing);
56 QPen dkGreyPen(QColor(0x3A, 0x3B, 0x3A, 0xFF));
57 QBrush dkGreyBrush(QColor(0x3A, 0x3B, 0x3A, 0xFF));
60 painter.setPen(dkGreyPen);
61 painter.setBrush(dkGreyBrush);
62 painter.drawEllipse(0, 0, 1024, 1024);
63 painter.setPen(Qt::white);
64 painter.setBrush(Qt::white);
65 painter.drawEllipse(388, 388, 248, 248);
69 948-949 (brighter to the 949 side) 1063-1064 (brighter to the 1064 side)
71 116 px for 36 tracks (3.2857... px per track)
73 3px on each side of the tracks
75 388 / 122 = 3.1803278688525
76 qtr track width = 2.6836879432624
78 // Draw disk track data
79 uint8_t lastLocation = 0xFF;
80 float x = 9.6, y = 9.6, w = 1024.0 - (2.0 * 9.6);
81 float tw = 2.6156028368794;
83 for(uint32_t str=0; str<Global::numStreams; str++)
85 //N.B.: Should also make sure this isn't a BITS stream, or handle it properly (because right now, it doesn't)
86 if (Global::stream[str]->location != lastLocation)
88 uint32_t splicePoint = Uint32LE(Global::stream[str]->estLoopPoint);
89 float angleTime = (float)splicePoint / (5760.0f / 2.0f);
92 float curTime = angleTime;
94 for(uint32_t i=0; i<5760; i+=2)
98 while (strTime < curTime)
100 while (Global::stream[str]->data[pos] == 0xFF)
101 strTime += Global::stream[str]->data[pos++];
103 strTime += Global::stream[str]->data[pos++];
107 uint32_t color = ((ones * 32.0f) / angleTime) * 255.0f;
112 painter.setPen(QPen(QColor(color, color, color, 0xFF), tw, Qt::SolidLine));
113 painter.drawArc(x, y, w, w, -i + 1440, 2);
115 curTime += angleTime;
121 lastLocation = Global::stream[str]->location;