]> Shamusworld >> Repos - wozmaker/blobdiff - src/waveformwidget.cpp
Flesh out the disk settings dialog.
[wozmaker] / src / waveformwidget.cpp
index e3ca3bfffa6e9a51f8c60e397d8a4139b1c747a2..5393be33b970273952d31842986e2087a4426123 100644 (file)
@@ -14,7 +14,7 @@
 
 
 // Local variables
-static uint32_t slip[9];
+static uint32_t slip[6];
 static bool foundBad = false;
 
 
@@ -72,6 +72,7 @@ void WaveformWidget::HandleUpdate(void)
 
        Global::swLen = 0;
 
+// !!! FIX !!! Need to take this out so it uses the already synthesized stuff done in the parallel thread...
        if (Global::streamCount > 1)
        {
                // Try aligning streams algorithmically...
@@ -278,36 +279,21 @@ void WaveformWidget::paintEvent(QPaintEvent * event)
                {
                        for(uint32_t i=0; i<trackBytes; i++)
                        {
-#if 0
-                               uint32_t timeToNext = Global::stream[j]->data[offset + i];
-
-                               while (Global::stream[j]->data[offset + i] == 0xFF)
-                               {
-                                       i++;
-                                       timeToNext += Global::stream[j]->data[offset + i];
-                               }
-#else
                                uint32_t timeToNext = Global::wave[j][offset + i];
-#endif
 
 //                             if (i > 0)
        //                              x += timeToNext / 2;
-                                       x += ((double)timeToNext / 2.0);// * ratio[wfNum];
+                                       x += ((double)timeToNext / 2.0);
 
 //                             if ((Global::stream[j]->data[offset + i] > 24) || (i == 0))
                                {
                                        if (x >= drawXPos)
                                        {
-                                               painter.setPen(bluePen);
-
-                                               if (x >= ((estSplice / 2) /* * ratio[wfNum]*/))
-                                                       painter.setPen(Qt::magenta);
+                                               if (x < (estSplice / 2))
+                                                       DrawPulse(&painter, &bluePen, lastx, x, y);
+                                               else
+                                                       DrawPulse(&painter, Qt::magenta, lastx, x, y);
 
-                                               painter.drawLine(lastx, y, x, y);
-                                               painter.drawLine(x, y, x + 4.0, y);
-                                               painter.drawLine(x + 4.0, y, x + 4.0, y - 17.0);
-                                               painter.drawLine(x + 4.0, y - 17.0, x + 8.0, y - 17.0);
-                                               painter.drawLine(x + 8.0, y - 17.0, x + 8.0, y);
                                                lastx = x + 8.0;
                                        }
 
@@ -401,12 +387,7 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
                        {
                                if (Global::stream[j]->data[i / 8] & Global::bit[i % 8])
                                {
-                                       painter.setPen(Qt::cyan);
-                                       painter.drawLine(lastx, y, x, y);
-                                       painter.drawLine(x, y, x + 4, y);
-                                       painter.drawLine(x + 4, y, x + 4, y - 17);
-                                       painter.drawLine(x + 4, y - 17, x + 8, y - 17);
-                                       painter.drawLine(x + 8, y - 17, x + 8, y);
+                                       DrawPulse(&painter, Qt::cyan, lastx, x, y);
                                        lastx = x + 8.0;
                                }
 
@@ -429,32 +410,20 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
        uint32_t byte = 1;
        uint32_t bytePos = x;
        uint32_t bitCount = 1;
-       float hgt = 17.0f * 1.0f;
-
-       painter.setPen(greenPen);
-       painter.drawLine(lastx, y, x, y);
-       painter.drawLine(x, y, x + 4.0, y);
-       painter.drawLine(x + 4.0, y, x + 4.0, y - hgt);
-       painter.drawLine(x + 4.0, y - hgt, x + 8.0, y - hgt);
-       painter.drawLine(x + 8.0, y - hgt, x + 8.0, y);
+
+       DrawPulse(&painter, &greenPen, lastx, x, y);
        lastx = x + 8.0;
 
        for(uint32_t i=0; i<Global::swLen; i++)
        {
                uint32_t timeToNext = Global::synthWave[i];
-               hgt = 17.0 * Global::swAmplitude[i];
                x += (double)timeToNext / 2.0;
 
                if ((timeToNext > 0) || (i == 0))
                {
                        if (x >= drawXPos)
                        {
-                               painter.setPen(greenPen);
-                               painter.drawLine(lastx, y, x, y);
-                               painter.drawLine(x, y, x + 4.0, y);
-                               painter.drawLine(x + 4.0, y, x + 4.0, y - hgt);
-                               painter.drawLine(x + 4.0, y - hgt, x + 8.0, y - hgt);
-                               painter.drawLine(x + 8.0, y - hgt, x + 8.0, y);
+                               DrawPulse(&painter, &greenPen, lastx, x, y, Global::swAmplitude[i]);
                                lastx = x + 8.0;
                        }
 
@@ -534,12 +503,7 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
        x = 0;
        lastx = 0;
 
-       painter.setPen(orangePen);
-       painter.drawLine(lastx, y, x, y);
-       painter.drawLine(x, y, x + 4.0, y);
-       painter.drawLine(x + 4.0, y, x + 4.0, y - 17.0f);
-       painter.drawLine(x + 4.0, y - 17.0f, x + 8.0, y - 17.0f);
-       painter.drawLine(x + 8.0, y - 17.0f, x + 8.0, y);
+       DrawPulse(&painter, &orangePen, lastx, x, y);
        lastx = x + 8.0;
 
        for(uint32_t i=0; i<Global::synWaveLen[Global::trackNum]; i++)
@@ -549,18 +513,13 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
 
                if (x >= drawXPos)
                {
-                       painter.setPen(orangePen);
-                       painter.drawLine(lastx, y, x, y);
-                       painter.drawLine(x, y, x + 4.0, y);
-                       painter.drawLine(x + 4.0, y, x + 4.0, y - 17.0f);
-                       painter.drawLine(x + 4.0, y - 17.0f, x + 8.0, y - 17.0f);
-                       painter.drawLine(x + 8.0, y - 17.0f, x + 8.0, y);
+                       DrawPulse(&painter, &orangePen, lastx, x, y);
                        lastx = x + 8.0;
                }
 
                char buf[10];
 
-               if ((i % 100) == 0)
+               if ((i % 10) == 0)
                {
                        sprintf(buf, "|%d", i + 1);
                        painter.setPen(whitePen);
@@ -575,12 +534,7 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
        x = 0;
        lastx = 0;
 
-       painter.setPen(orangePen);
-       painter.drawLine(lastx, y, x, y);
-       painter.drawLine(x, y, x + 4.0, y);
-       painter.drawLine(x + 4.0, y, x + 4.0, y - 17.0f);
-       painter.drawLine(x + 4.0, y - 17.0f, x + 8.0, y - 17.0f);
-       painter.drawLine(x + 8.0, y - 17.0f, x + 8.0, y);
+       DrawPulse(&painter, &orangePen, lastx, x, y);
        lastx = x + 8.0;
 
        for(uint32_t i=Global::waveSync; i<Global::synWaveLen[Global::trackNum]; i++)
@@ -590,12 +544,7 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
 
                if (x >= drawXPos)
                {
-                       painter.setPen(orangePen);
-                       painter.drawLine(lastx, y, x, y);
-                       painter.drawLine(x, y, x + 4.0, y);
-                       painter.drawLine(x + 4.0, y, x + 4.0, y - 17.0f);
-                       painter.drawLine(x + 4.0, y - 17.0f, x + 8.0, y - 17.0f);
-                       painter.drawLine(x + 8.0, y - 17.0f, x + 8.0, y);
+                       DrawPulse(&painter, &orangePen, lastx, x, y);
                        lastx = x + 8.0;
                }
 
@@ -614,6 +563,25 @@ x positions are 16 pix apart, ideally.  So to get the # of bits, we need to divi
 }
 
 
+void WaveformWidget::DrawPulse(QPainter * painter, QPen * pen, float lastx, float x, float y, float height/*= 1.0*/)
+{
+       float yHeight = y - (17.0 * height);
+       painter->setPen(*pen);
+       painter->drawLine(lastx, y, x, y);
+       painter->drawLine(x, y, x + 4.0, y);
+       painter->drawLine(x + 4.0, y, x + 4.0, yHeight);
+       painter->drawLine(x + 4.0, yHeight, x + 8.0, yHeight);
+       painter->drawLine(x + 8.0, yHeight, x + 8.0, y);
+}
+
+
+void WaveformWidget::DrawPulse(QPainter * painter, Qt::GlobalColor color, float lastx, float x, float y, float height/*= 1.0*/)
+{
+       QPen pen(color);
+       DrawPulse(painter, &pen, lastx, x, y, height);
+}
+
+
 void WaveformWidget::mousePressEvent(QMouseEvent * event)
 {
        if (event->button() == Qt::LeftButton)