From 6c27f44ccc937771e1d2ab29e358b51a89e93c3d Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sat, 24 Jul 2021 22:53:36 -0700 Subject: [PATCH] Meter now scales the meter bar to fit the avaliable depth. Text should scale to have the correct aspect ratio. Fixed minor bug in reporting connection type (always reported serial and then was replaced with connection status). --- meter.cpp | 23 ++++++++++++++++------- wfmain.cpp | 35 +++++++++++------------------------ wfmain.ui | 2 +- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/meter.cpp b/meter.cpp index 34cfceb..a8d7dd9 100644 --- a/meter.cpp +++ b/meter.cpp @@ -93,8 +93,12 @@ void meter::paintEvent(QPaintEvent *) // Clamp down on stretching fonts. // TODO: Make this more elegant painter.setFont(QFont(this->fontInfo().family(), widgetWindowHeight/3.5)); - } else { - painter.setFont(QFont(this->fontInfo().family(), widgetWindowHeight/2.5)); + widgetWindowHeight = this->height(); + painter.setWindow(QRect(0, 0, 255+mXstart, widgetWindowHeight)); + barHeight = widgetWindowHeight / 2; + + + //painter.setFont(QFont(this->fontInfo().family(), widgetWindowHeight/2.5)); } switch(meterType) @@ -327,13 +331,16 @@ void meter::drawScalePo(QPainter *qp) // Here, P is now 60 watts: // Higher scale: i = i - (int)(10*dnPerWatt); // back one tick first. Otherwise i starts at 178. - qDebug() << "meter i: " << i; + //qDebug() << "meter i: " << i; dnPerWatt = (213-143.0) / 50.0; // 1.4 dn per watt - + // P=5 here. qp->setPen(Qt::yellow); - for(i=mXstart+143; idrawText(i,scaleTextYstart, QString("%1").arg(10*(p++)) ); + k = 50+(( i-mXstart-143 ) / dnPerWatt); + if(k==40||k==50||k==65||k==80) + qp->drawText(i,scaleTextYstart, QString("%1").arg(k) ); } // Now we're out past 100: @@ -341,7 +348,9 @@ void meter::drawScalePo(QPainter *qp) for(i=mXstart+213; idrawText(i,scaleTextYstart, QString("%1").arg(10*(p++)) ); + k = 50+(( i-mXstart-143 ) / dnPerWatt); + if(k==100) + qp->drawText(i,scaleTextYstart, QString("%1").arg(k) ); } // Now the lines: diff --git a/wfmain.cpp b/wfmain.cpp index e6855c6..e483948 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -207,9 +207,9 @@ void wfmain::openRig() } usingLAN = false; emit sendCommSetup(prefs.radioCIVAddr, serialPortRig, prefs.serialPortBaud,prefs.virtualSerialPort); + ui->statusBar->showMessage(QString("Connecting to rig using serial port ").append(serialPortRig), 1000); } - ui->statusBar->showMessage(QString("Connecting to rig using serial port ").append(serialPortRig), 1000); } @@ -670,6 +670,15 @@ void wfmain::setupMainUI() ui->meter2selectionCombo->addItem("Center", meterCenter); ui->meter2Widget->hide(); +#ifdef QT_DEBUG + // Experimental feature: + ui->meter2selectionCombo->show(); + ui->secondaryMeterSelectionLabel->show(); +#else + ui->meter2selectionCombo->hide(); + ui->secondaryMeterSelectionLabel->hide(); +#endif + // Future ideas: //ui->meter2selectionCombo->addItem("Transmit Audio", meterTxMod); //ui->meter2selectionCombo->addItem("Receive Audio", meterRxAudio); @@ -4143,7 +4152,7 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) //ui->udpServerSetupBtn->setEnabled(false); if(checked) { - showStatusBarText("After filling in values, press Save Settings and re-start wfview."); + showStatusBarText("After filling in values, press Save Settings."); } } @@ -5200,26 +5209,4 @@ void wfmain::on_debugBtn_clicked() //wf->setInteraction(QCP::iRangeZoom, true); //wf->setInteraction(QCP::iRangeDrag, true); - // debug the fast queue: - qDebug(logSystem()) << "Size of fast command queue: " << periodicCmdQueue.size(); - - for (auto it = periodicCmdQueue.cbegin(); it != periodicCmdQueue.cend(); ++it) { - qDebug(logSystem()) << *it ; - } - -// bool ok = false; -// unsigned char level = (unsigned char) QInputDialog::getInt(this, "wfview simulated radio level", "Raw level (0-255)", 128, 1, 255, 1, &ok ); -// if(ok) -// { -// int peak = level*1.5; -// if(peak > 255) -// peak = 255; -// int average = peak / 2; - -// ui->meterSPoWidget->setMeterType(meterALC); -// ui->meterSPoWidget->setLevels(level, peak, average); -// ui->meterSPoWidget->update(); -// } - - } diff --git a/wfmain.ui b/wfmain.ui index 1677d86..aa855c7 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -18,7 +18,7 @@ - 1 + 3