Skip to content

Commit

Permalink
Rework how line numbers are shown in the scope.
Browse files Browse the repository at this point in the history
Previously we showed a 1-based line number within the frame, which is
only meaningful internally to ld-analyse.

We now use spin boxes to show 0-based X and Y coordinates within the
full frame (as you'd see in an image editor), and labels to show the
system, standard line number, field, and 1-based line within the field
(as used in the field metadata).
  • Loading branch information
atsampson committed Jun 8, 2022
1 parent 7f877c7 commit 0b1ed28
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 93 deletions.
1 change: 1 addition & 0 deletions tools/ld-analyse/ld-analyse.pro
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ HEADERS += \
../library/tbc/filters.h \
../library/tbc/jsonio.h \
../library/tbc/lddecodemetadata.h \
../library/tbc/linenumber.h \
../library/tbc/logging.h \
../library/tbc/sourcevideo.h \
../library/tbc/vbidecoder.h \
Expand Down
14 changes: 7 additions & 7 deletions tools/ld-analyse/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ MainWindow::MainWindow(QString inputFilenameParam, QWidget *parent) :
if (tbcSource.getIsWidescreen()) aspectRatio = Aspect::DAR_169;

// Connect to the scan line changed signal from the oscilloscope dialogue
connect(oscilloscopeDialog, &OscilloscopeDialog::scanLineChanged, this, &MainWindow::scanLineChangedSignalHandler);
connect(oscilloscopeDialog, &OscilloscopeDialog::scopeCoordsChanged, this, &MainWindow::scopeCoordsChangedSignalHandler);
lastScopeLine = 1;
lastScopeDot = 1;

Expand Down Expand Up @@ -453,8 +453,8 @@ void MainWindow::updateOscilloscopeDialogue()
{
// Update the oscilloscope dialogue
oscilloscopeDialog->showTraceImage(tbcSource.getScanLineData(lastScopeLine),
lastScopeLine, lastScopeDot,
tbcSource.getFrameHeight());
lastScopeDot, lastScopeLine - 1,
tbcSource.getFrameWidth(), tbcSource.getFrameHeight());
}

// Menu bar signal handlers -------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -875,14 +875,14 @@ void MainWindow::on_aspectPushButton_clicked()
// Miscellaneous handler methods --------------------------------------------------------------------------------------

// Handler called when another class changes the currenly selected scan line
void MainWindow::scanLineChangedSignalHandler(qint32 scanLine, qint32 pictureDot)
void MainWindow::scopeCoordsChangedSignalHandler(qint32 xCoord, qint32 yCoord)
{
qDebug() << "MainWindow::scanLineChangedSignalHandler(): Called with scanLine =" << scanLine << "and picture dot" << pictureDot;
qDebug() << "MainWindow::scanLineChangedSignalHandler(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;

if (tbcSource.getIsSourceLoaded()) {
// Show the oscilloscope dialogue for the selected scan-line
lastScopeDot = pictureDot;
lastScopeLine = scanLine;
lastScopeDot = xCoord;
lastScopeLine = yCoord + 1;
updateOscilloscopeDialogue();
oscilloscopeDialog->show();

Expand Down
2 changes: 1 addition & 1 deletion tools/ld-analyse/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private slots:
void on_aspectPushButton_clicked();

// Miscellaneous handlers
void scanLineChangedSignalHandler(qint32 scanLine, qint32 pictureDot);
void scopeCoordsChangedSignalHandler(qint32 xCoord, qint32 yCoord);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void chromaDecoderConfigChangedSignalHandler();
Expand Down
83 changes: 51 additions & 32 deletions tools/ld-analyse/oscilloscopedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ OscilloscopeDialog::OscilloscopeDialog(QWidget *parent) :
ui->setupUi(this);
setWindowFlags(Qt::Window);

maximumScanLines = 625;
lastScopeLine = 0;
lastScopeDot = 0;
maximumX = 1135;
maximumY = 625;
lastScopeX = 0;
lastScopeY = 0;
scopeWidth = 0;

// Configure the GUI
ui->scanLineSpinBox->setMinimum(1);
ui->scanLineSpinBox->setMaximum(625);
ui->xCoordSpinBox->setMinimum(0);
ui->xCoordSpinBox->setMaximum(maximumX - 1);
ui->yCoordSpinBox->setMinimum(0);
ui->yCoordSpinBox->setMaximum(maximumY - 1);

ui->previousPushButton->setAutoRepeat(true);
ui->previousPushButton->setAutoRepeatInterval(50);
Expand All @@ -58,32 +61,41 @@ OscilloscopeDialog::~OscilloscopeDialog()
delete ui;
}

void OscilloscopeDialog::showTraceImage(TbcSource::ScanLineData scanLineData, qint32 scanLine, qint32 pictureDot, qint32 frameHeight)
void OscilloscopeDialog::showTraceImage(TbcSource::ScanLineData scanLineData, qint32 xCoord, qint32 yCoord, qint32 frameWidth, qint32 frameHeight)
{
qDebug() << "OscilloscopeDialog::showTraceImage(): Called for scan-line" << scanLine << "with picture dot" << pictureDot;
qDebug() << "OscilloscopeDialog::showTraceImage(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;

// Set the dialogue title based on the scan-line
this->setWindowTitle("Oscilloscope trace for scan-line #" + QString::number(scanLine));
// Store coordinates
maximumX = frameWidth;
maximumY = frameHeight;
lastScopeX = xCoord;
lastScopeY = yCoord;

// Get the raw field data for the selected line
QImage traceImage;
lastScopeLine = scanLine;
lastScopeDot = pictureDot;

traceImage = getFieldLineTraceImage(scanLineData, pictureDot);
QImage traceImage = getFieldLineTraceImage(scanLineData, lastScopeX);

// Add the QImage to the QLabel in the dialogue
ui->scopeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->scopeLabel->setAlignment(Qt::AlignCenter);
ui->scopeLabel->setScaledContents(true);
ui->scopeLabel->setPixmap(QPixmap::fromImage(traceImage));

// Update the scan-line spinbox
ui->scanLineSpinBox->setMaximum(frameHeight);
ui->scanLineSpinBox->setValue(scanLine);
// Update the X coordinate spinbox
ui->xCoordSpinBox->setMaximum(maximumX - 1);
ui->xCoordSpinBox->setValue(lastScopeX);

// Update the Y coordinate spinbox
ui->yCoordSpinBox->setMaximum(maximumY - 1);
ui->yCoordSpinBox->setValue(lastScopeY);

// Update the line number displays
ui->standardLineLabel->setText(QString("%1 line %2")
.arg(scanLineData.systemDescription)
.arg(scanLineData.lineNumber.standard()));
ui->fieldLineLabel->setText(QString("Field %1 line %2")
.arg(scanLineData.lineNumber.isFirstField() ? "1" : "2")
.arg(scanLineData.lineNumber.field1()));

// Update the maximum scan-lines limit
maximumScanLines = frameHeight;
// QT Bug workaround for some macOS versions
#if defined(Q_OS_MACOS)
repaint();
Expand Down Expand Up @@ -233,43 +245,50 @@ QImage OscilloscopeDialog::getFieldLineTraceImage(TbcSource::ScanLineData scanLi

void OscilloscopeDialog::on_previousPushButton_clicked()
{
if (ui->scanLineSpinBox->value() != 1) {
emit scanLineChanged(ui->scanLineSpinBox->value() - 1, lastScopeDot);
if (ui->yCoordSpinBox->value() != 0) {
emit scopeCoordsChanged(lastScopeX, ui->yCoordSpinBox->value() - 1);
}
}

void OscilloscopeDialog::on_nextPushButton_clicked()
{
if (ui->scanLineSpinBox->value() < maximumScanLines) {
emit scanLineChanged(ui->scanLineSpinBox->value() + 1, lastScopeDot);
if (ui->yCoordSpinBox->value() < maximumY - 1) {
emit scopeCoordsChanged(lastScopeX, ui->yCoordSpinBox->value() + 1);
}
}

void OscilloscopeDialog::on_scanLineSpinBox_valueChanged(int arg1)
void OscilloscopeDialog::on_xCoordSpinBox_valueChanged(int arg1)
{
(void)arg1;
if (ui->xCoordSpinBox->value() != lastScopeX)
emit scopeCoordsChanged(ui->xCoordSpinBox->value(), lastScopeY);
}

void OscilloscopeDialog::on_yCoordSpinBox_valueChanged(int arg1)
{
(void)arg1;
if (ui->scanLineSpinBox->value() != lastScopeLine)
emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
if (ui->yCoordSpinBox->value() != lastScopeY)
emit scopeCoordsChanged(lastScopeX, ui->yCoordSpinBox->value() );
}

void OscilloscopeDialog::on_YCcheckBox_clicked()
{
emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
emit scopeCoordsChanged(lastScopeX, lastScopeY);
}

void OscilloscopeDialog::on_YcheckBox_clicked()
{
emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
emit scopeCoordsChanged(lastScopeX, lastScopeY);
}

void OscilloscopeDialog::on_CcheckBox_clicked()
{
emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
emit scopeCoordsChanged(lastScopeX, lastScopeY);
}

void OscilloscopeDialog::on_dropoutsCheckBox_clicked()
{
emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
emit scopeCoordsChanged(lastScopeX, lastScopeY);
}

// Mouse press event handler
Expand Down Expand Up @@ -322,7 +341,7 @@ void OscilloscopeDialog::mousePictureDotSelect(qint32 oX)
if (unscaledX < 0) unscaledX = 0;

// Remember the last dot selected
lastScopeDot = unscaledX;
lastScopeX = unscaledX;

emit scanLineChanged(ui->scanLineSpinBox->value(), lastScopeDot);
emit scopeCoordsChanged(lastScopeX, lastScopeY);
}
14 changes: 8 additions & 6 deletions tools/ld-analyse/oscilloscopedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ class OscilloscopeDialog : public QDialog
explicit OscilloscopeDialog(QWidget *parent = nullptr);
~OscilloscopeDialog();

void showTraceImage(TbcSource::ScanLineData scanLineData, qint32 scanLine, qint32 pictureDot, qint32 frameHeight);
void showTraceImage(TbcSource::ScanLineData scanLineData, qint32 xCoord, qint32 yCoord, qint32 frameWidth, qint32 frameHeight);

signals:
void scanLineChanged(qint32 scanLine, qint32 lastScopeDot);
void scopeCoordsChanged(qint32 xCoord, qint32 yCoord);

private slots:
void on_previousPushButton_clicked();
void on_nextPushButton_clicked();
void on_scanLineSpinBox_valueChanged(int arg1);
void on_xCoordSpinBox_valueChanged(int arg1);
void on_yCoordSpinBox_valueChanged(int arg1);
void on_YCcheckBox_clicked();
void on_YcheckBox_clicked();
void on_CcheckBox_clicked();
Expand All @@ -66,10 +67,11 @@ private slots:

private:
Ui::OscilloscopeDialog *ui;
qint32 maximumScanLines;
qint32 maximumX;
qint32 maximumY;
qint32 scopeWidth;
qint32 lastScopeLine;
qint32 lastScopeDot;
qint32 lastScopeX;
qint32 lastScopeY;

QImage getFieldLineTraceImage(TbcSource::ScanLineData scanLineData, qint32 pictureDot);
void mousePictureDotSelect(qint32 oX);
Expand Down
Loading

0 comments on commit 0b1ed28

Please sign in to comment.