2021-02-24 08:18:19 +00:00
|
|
|
#include "meter.h"
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
meter::meter(QWidget *parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
//QPainter painter(this);
|
|
|
|
|
|
|
|
// Colors from qdarkstylesheet:
|
|
|
|
// $COLOR_BACKGROUND_LIGHT: #505F69;
|
|
|
|
// $COLOR_BACKGROUND_NORMAL: #32414B;
|
|
|
|
// $COLOR_BACKGROUND_DARK: #19232D;
|
|
|
|
// $COLOR_FOREGROUND_LIGHT: #F0F0F0; // grey
|
|
|
|
// $COLOR_FOREGROUND_NORMAL: #AAAAAA; // grey
|
|
|
|
// $COLOR_FOREGROUND_DARK: #787878; // grey
|
|
|
|
// $COLOR_SELECTION_LIGHT: #148CD2;
|
|
|
|
// $COLOR_SELECTION_NORMAL: #1464A0;
|
|
|
|
// $COLOR_SELECTION_DARK: #14506E;
|
|
|
|
|
|
|
|
|
|
|
|
// Colors I found that I liked from VFD images:
|
|
|
|
// 3FB7CD
|
|
|
|
// 3CA0DB
|
|
|
|
//
|
|
|
|
// Text in qdarkstylesheet seems to be #EFF0F1
|
|
|
|
|
2021-08-17 06:25:11 +00:00
|
|
|
if(drawLabels)
|
|
|
|
{
|
|
|
|
mXstart = 32;
|
|
|
|
} else {
|
|
|
|
mXstart = 0;
|
|
|
|
}
|
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
meterType = meterS;
|
|
|
|
|
2021-02-24 08:18:19 +00:00
|
|
|
currentColor.setNamedColor("#148CD2");
|
|
|
|
currentColor = currentColor.darker();
|
|
|
|
|
|
|
|
peakColor.setNamedColor("#3CA0DB");
|
|
|
|
peakColor = peakColor.lighter();
|
|
|
|
|
|
|
|
averageColor.setNamedColor("#3FB7CD");
|
|
|
|
|
|
|
|
lowTextColor.setNamedColor("#eff0f1");
|
|
|
|
lowLineColor = lowTextColor;
|
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
avgLevels.resize(averageBalisticLength, 0);
|
|
|
|
peakLevels.resize(peakBalisticLength, 0);
|
|
|
|
|
2021-02-24 08:18:19 +00:00
|
|
|
}
|
|
|
|
|
2021-08-21 05:19:47 +00:00
|
|
|
void meter::clearMeterOnPTTtoggle()
|
2021-07-17 00:45:07 +00:00
|
|
|
{
|
2021-08-21 05:19:47 +00:00
|
|
|
// When a meter changes type, such as the fixed S -- TxPo meter,
|
2022-03-23 15:45:51 +00:00
|
|
|
// there is automatic clearing. However, some meters do not switch on their own,
|
2021-08-21 05:19:47 +00:00
|
|
|
// and thus we are providing this clearing method. We are careful
|
|
|
|
// not to clear meters that don't make sense to clear (such as Vd and Id)
|
2021-07-18 06:39:40 +00:00
|
|
|
|
2021-08-21 05:19:47 +00:00
|
|
|
|
|
|
|
if( (meterType == meterALC) || (meterType == meterSWR)
|
2021-08-21 05:23:16 +00:00
|
|
|
|| (meterType == meterComp) || (meterType == meterTxMod)
|
|
|
|
|| (meterType == meterCenter ))
|
2021-08-21 05:19:47 +00:00
|
|
|
{
|
|
|
|
clearMeter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::clearMeter()
|
|
|
|
{
|
2021-07-20 18:11:51 +00:00
|
|
|
current = 0;
|
|
|
|
average = 0;
|
|
|
|
peak = 0;
|
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
avgLevels.clear();
|
|
|
|
peakLevels.clear();
|
|
|
|
avgLevels.resize(averageBalisticLength, 0);
|
|
|
|
peakLevels.resize(peakBalisticLength, 0);
|
2021-07-18 06:39:40 +00:00
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
peakPosition = 0;
|
|
|
|
avgPosition = 0;
|
2021-07-17 00:45:07 +00:00
|
|
|
// re-draw scale:
|
2021-07-20 18:11:51 +00:00
|
|
|
update();
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-21 05:19:47 +00:00
|
|
|
void meter::setMeterType(meterKind type)
|
|
|
|
{
|
|
|
|
if(type == meterType)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meterType = type;
|
|
|
|
// clear average and peak vectors:
|
|
|
|
this->clearMeter();
|
|
|
|
}
|
|
|
|
|
2021-07-18 06:39:40 +00:00
|
|
|
meterKind meter::getMeterType()
|
|
|
|
{
|
|
|
|
return meterType;
|
|
|
|
}
|
2021-02-24 08:18:19 +00:00
|
|
|
|
2021-07-20 06:46:11 +00:00
|
|
|
void meter::setMeterShortString(QString s)
|
|
|
|
{
|
|
|
|
meterShortString = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString meter::getMeterShortString()
|
|
|
|
{
|
|
|
|
return meterShortString;
|
|
|
|
}
|
|
|
|
|
2021-02-24 08:18:19 +00:00
|
|
|
void meter::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
// This next line sets up a canvis within the
|
2022-03-23 15:45:51 +00:00
|
|
|
// space of the widget, and gives it coordinates.
|
2021-02-24 08:18:19 +00:00
|
|
|
// The end effect, is that the drawing functions will all
|
|
|
|
// scale to the window size.
|
2021-08-17 06:25:11 +00:00
|
|
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
|
|
painter.setFont(QFont(this->fontInfo().family(), fontSize));
|
|
|
|
widgetWindowHeight = this->height();
|
|
|
|
painter.setWindow(QRect(0, 0, 255+mXstart+15, widgetWindowHeight));
|
|
|
|
barHeight = widgetWindowHeight / 2;
|
2021-07-20 06:46:11 +00:00
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
switch(meterType)
|
|
|
|
{
|
|
|
|
case meterS:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "S";
|
2021-07-18 06:39:40 +00:00
|
|
|
peakRedLevel = 120; // S9+
|
2021-07-17 00:45:07 +00:00
|
|
|
drawScaleS(&painter);
|
|
|
|
break;
|
|
|
|
case meterPower:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "PWR";
|
2021-07-18 06:39:40 +00:00
|
|
|
peakRedLevel = 210; // 100%
|
2021-07-17 00:45:07 +00:00
|
|
|
drawScalePo(&painter);
|
|
|
|
break;
|
2021-07-17 07:37:27 +00:00
|
|
|
case meterALC:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "ALC";
|
2021-07-18 06:39:40 +00:00
|
|
|
peakRedLevel = 100;
|
2021-07-17 07:37:27 +00:00
|
|
|
drawScaleALC(&painter);
|
|
|
|
break;
|
|
|
|
case meterSWR:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "SWR";
|
2021-07-18 06:39:40 +00:00
|
|
|
peakRedLevel = 100; // SWR 2.5
|
2021-07-17 07:37:27 +00:00
|
|
|
drawScaleSWR(&painter);
|
|
|
|
break;
|
2021-07-18 21:27:21 +00:00
|
|
|
case meterCenter:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "CTR";
|
2021-07-18 21:27:21 +00:00
|
|
|
peakRedLevel = 256; // No need for red here
|
|
|
|
drawScaleCenter(&painter);
|
|
|
|
break;
|
2021-07-20 06:46:11 +00:00
|
|
|
case meterVoltage:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "Vd";
|
2021-07-20 06:46:11 +00:00
|
|
|
peakRedLevel = 241;
|
|
|
|
drawScaleVd(&painter);
|
|
|
|
break;
|
2021-08-17 06:25:11 +00:00
|
|
|
case meterCurrent:
|
|
|
|
label = "Id";
|
|
|
|
peakRedLevel = 120;
|
|
|
|
drawScaleId(&painter);
|
|
|
|
break;
|
|
|
|
case meterComp:
|
|
|
|
label = "CMP";
|
|
|
|
peakRedLevel = 100;
|
|
|
|
drawScaleComp(&painter);
|
|
|
|
break;
|
2021-08-21 05:19:47 +00:00
|
|
|
case meterNone:
|
|
|
|
return;
|
|
|
|
break;
|
2021-07-17 00:45:07 +00:00
|
|
|
default:
|
2021-08-17 06:25:11 +00:00
|
|
|
label = "DN";
|
|
|
|
peakRedLevel = 241;
|
2021-07-18 21:27:21 +00:00
|
|
|
drawScaleRaw(&painter);
|
2021-07-17 00:45:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-02-24 08:18:19 +00:00
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
// Current: the most-current value.
|
|
|
|
// Draws a bar from start to value.
|
2021-02-24 08:18:19 +00:00
|
|
|
painter.setPen(currentColor);
|
|
|
|
painter.setBrush(currentColor);
|
2021-07-18 21:27:21 +00:00
|
|
|
|
|
|
|
if(meterType == meterCenter)
|
2021-02-24 08:18:19 +00:00
|
|
|
{
|
2021-07-18 21:27:21 +00:00
|
|
|
painter.drawRect(mXstart+128,mYstart,current-128,barHeight);
|
|
|
|
|
|
|
|
// Average:
|
|
|
|
painter.setPen(averageColor);
|
|
|
|
painter.setBrush(averageColor);
|
|
|
|
painter.drawRect(mXstart+average-1,mYstart,1,barHeight); // bar is 1 pixel wide, height = meter start?
|
|
|
|
|
|
|
|
// Peak:
|
|
|
|
painter.setPen(peakColor);
|
|
|
|
painter.setBrush(peakColor);
|
|
|
|
if((peak > 191) || (peak < 63))
|
|
|
|
{
|
|
|
|
painter.setBrush(Qt::red);
|
|
|
|
painter.setPen(Qt::red);
|
|
|
|
}
|
2021-02-24 08:18:19 +00:00
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
painter.drawRect(mXstart+peak-1,mYstart,1,barHeight);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// X, Y, Width, Height
|
|
|
|
painter.drawRect(mXstart,mYstart,current,barHeight);
|
|
|
|
|
|
|
|
// Average:
|
|
|
|
painter.setPen(averageColor);
|
|
|
|
painter.setBrush(averageColor);
|
|
|
|
painter.drawRect(mXstart+average-1,mYstart,1,barHeight); // bar is 1 pixel wide, height = meter start?
|
|
|
|
|
|
|
|
// Peak:
|
|
|
|
painter.setPen(peakColor);
|
|
|
|
painter.setBrush(peakColor);
|
|
|
|
if(peak > peakRedLevel)
|
|
|
|
{
|
|
|
|
painter.setBrush(Qt::red);
|
|
|
|
painter.setPen(Qt::red);
|
|
|
|
}
|
|
|
|
|
|
|
|
painter.drawRect(mXstart+peak-1,mYstart,2,barHeight);
|
|
|
|
}
|
2021-08-17 06:25:11 +00:00
|
|
|
if(drawLabels)
|
|
|
|
{
|
|
|
|
drawLabel(&painter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::drawLabel(QPainter *qp)
|
|
|
|
{
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawText(0,scaleTextYstart, label );
|
2021-02-24 08:18:19 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:04 +00:00
|
|
|
void meter::setLevel(int current)
|
2021-02-24 08:18:19 +00:00
|
|
|
{
|
|
|
|
this->current = current;
|
2021-07-18 21:27:21 +00:00
|
|
|
|
|
|
|
avgLevels[(avgPosition++)%averageBalisticLength] = current;
|
|
|
|
peakLevels[(peakPosition++)%peakBalisticLength] = current;
|
|
|
|
|
|
|
|
int sum=0;
|
|
|
|
|
|
|
|
for(unsigned int i=0; i < (unsigned int)std::min(avgPosition, (int)avgLevels.size()); i++)
|
|
|
|
{
|
|
|
|
sum += avgLevels.at(i);
|
|
|
|
}
|
|
|
|
this->average = sum / std::min(avgPosition, (int)avgLevels.size());
|
|
|
|
|
|
|
|
this->peak = 0;
|
|
|
|
|
|
|
|
for(unsigned int i=0; i < peakLevels.size(); i++)
|
|
|
|
{
|
|
|
|
if( peakLevels.at(i) > this->peak)
|
|
|
|
this->peak = peakLevels.at(i);
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:04 +00:00
|
|
|
this->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::setLevels(int current, int peak, int average)
|
|
|
|
{
|
|
|
|
this->current = current;
|
|
|
|
this->peak = peak;
|
|
|
|
this->average = average;
|
|
|
|
|
2021-02-24 08:18:19 +00:00
|
|
|
this->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::updateDrawing(int num)
|
|
|
|
{
|
|
|
|
fontSize = num;
|
|
|
|
length = num;
|
|
|
|
}
|
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
// The drawScale functions draw the numbers and number unerline for each type of meter
|
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
void meter::drawScaleRaw(QPainter *qp)
|
|
|
|
{
|
|
|
|
qp->setPen(lowTextColor);
|
2021-07-20 06:46:11 +00:00
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
2021-07-18 21:27:21 +00:00
|
|
|
int i=mXstart;
|
2021-08-17 06:25:11 +00:00
|
|
|
for(; i<mXstart+256; i+=25)
|
2021-07-18 21:27:21 +00:00
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(i) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the lines:
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
|
|
|
// Line: X1, Y1 -->to--> X2, Y2
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-07-20 06:46:11 +00:00
|
|
|
void meter::drawScaleVd(QPainter *qp)
|
|
|
|
{
|
|
|
|
qp->setPen(lowTextColor);
|
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
|
|
|
|
|
|
|
// 7300/9700 and others:
|
|
|
|
int midPointDn = 13;
|
|
|
|
int midPointVd = 10;
|
|
|
|
|
|
|
|
// 705:
|
|
|
|
//int midPointDn = 75;
|
|
|
|
//int midPointVd = 5;
|
|
|
|
|
|
|
|
int highPointDn = 241;
|
|
|
|
int highPointVd = 16;
|
|
|
|
float VdperDn = (float)(highPointVd-midPointVd) / float(highPointDn-midPointDn);
|
|
|
|
|
|
|
|
int i=mXstart;
|
2021-08-17 06:25:11 +00:00
|
|
|
for(; i<mXstart+midPointDn; i+=midPointDn/1)
|
2021-07-20 06:46:11 +00:00
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int)((i-mXstart) * (float(midPointVd) / float(midPointDn)) )) );
|
|
|
|
}
|
|
|
|
|
|
|
|
for(; i<mXstart+255; i+= (highPointDn-midPointDn) / (highPointVd-midPointVd))
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int) std::round( ((i-mXstart-midPointDn) * (VdperDn) ) + (midPointVd) )));
|
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the lines:
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
|
|
|
// Line: X1, Y1 -->to--> X2, Y2
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-07-18 21:27:21 +00:00
|
|
|
void meter::drawScaleCenter(QPainter *qp)
|
|
|
|
{
|
|
|
|
// No known units
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawText(60+mXstart,scaleTextYstart, QString("-"));
|
|
|
|
|
|
|
|
qp->setPen(Qt::green);
|
|
|
|
// Attempt to draw the zero at the actual center
|
|
|
|
qp->drawText(128-2+mXstart,scaleTextYstart, QString("0"));
|
|
|
|
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawText(195+mXstart,scaleTextYstart, QString("+"));
|
|
|
|
|
|
|
|
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,128-32+mXstart,scaleLineYstart);
|
|
|
|
|
|
|
|
qp->setPen(Qt::green);
|
|
|
|
qp->drawLine(128-32+mXstart,scaleLineYstart,128+32+mXstart,scaleLineYstart);
|
|
|
|
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawLine(128+32+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
void meter::drawScalePo(QPainter *qp)
|
|
|
|
{
|
2021-07-17 07:37:27 +00:00
|
|
|
//From the manual: "0000=0% to 0143=50% to 0213=100%"
|
2021-08-08 20:03:22 +00:00
|
|
|
float dnPerWatt = 143.0f / 50.0f;
|
2021-07-17 00:45:07 +00:00
|
|
|
|
|
|
|
qp->setPen(lowTextColor);
|
2021-07-20 06:46:11 +00:00
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
int i=mXstart;
|
|
|
|
// 13.3 DN per s-unit:
|
|
|
|
int p=0;
|
|
|
|
for(; i<mXstart+143; i+=(int)(10*dnPerWatt))
|
|
|
|
{
|
|
|
|
// Stop just before the next 10w spot
|
|
|
|
if(i<mXstart+140)
|
2021-07-17 07:37:27 +00:00
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(10*(p++)) );
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modify current scale position:
|
|
|
|
|
|
|
|
// Here, P is now 60 watts:
|
|
|
|
// Higher scale:
|
|
|
|
i = i - (int)(10*dnPerWatt); // back one tick first. Otherwise i starts at 178.
|
2021-07-25 05:53:36 +00:00
|
|
|
//qDebug() << "meter i: " << i;
|
2021-08-08 20:03:22 +00:00
|
|
|
dnPerWatt = (213-143.0f) / 50.0f; // 1.4 dn per watt
|
2021-07-25 05:53:36 +00:00
|
|
|
// P=5 here.
|
2021-07-17 00:45:07 +00:00
|
|
|
qp->setPen(Qt::yellow);
|
2021-07-25 05:53:36 +00:00
|
|
|
int k=0;
|
|
|
|
for(i=mXstart+143; i<mXstart+213; i+=(5*dnPerWatt))
|
2021-07-17 00:45:07 +00:00
|
|
|
{
|
2021-07-25 05:53:36 +00:00
|
|
|
k = 50+(( i-mXstart-143 ) / dnPerWatt);
|
|
|
|
if(k==40||k==50||k==65||k==80)
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(k) );
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now we're out past 100:
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
|
|
|
|
for(i=mXstart+213; i<mXstart+255; i+=(10*dnPerWatt))
|
|
|
|
{
|
2021-07-25 05:53:36 +00:00
|
|
|
k = 50+(( i-mXstart-143 ) / dnPerWatt);
|
|
|
|
if(k==100)
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(k) );
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now the lines:
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
2021-07-17 06:23:29 +00:00
|
|
|
// Line: X1, Y1 -->to--> X2, Y2
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,213+mXstart,scaleLineYstart);
|
2021-07-17 00:45:07 +00:00
|
|
|
qp->setPen(Qt::red);
|
2021-07-17 06:23:29 +00:00
|
|
|
qp->drawLine(213+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
2021-07-17 00:45:07 +00:00
|
|
|
|
|
|
|
(void)qp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::drawScaleRxdB(QPainter *qp)
|
|
|
|
{
|
|
|
|
(void)qp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void meter::drawScaleALC(QPainter *qp)
|
|
|
|
{
|
2021-07-17 07:37:27 +00:00
|
|
|
// From the manual: 0000=Minimum to 0120=Maximum
|
|
|
|
|
|
|
|
qp->setPen(lowTextColor);
|
2021-07-20 06:46:11 +00:00
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
2021-07-17 07:37:27 +00:00
|
|
|
int i=mXstart;
|
|
|
|
int alc=0;
|
|
|
|
for(; i<mXstart+100; i += (20))
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(alc) );
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
2021-07-17 07:37:27 +00:00
|
|
|
alc +=20;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
|
|
|
|
for(; i<mXstart+120; i+=(int)(10*i))
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("+%1").arg(alc) );
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
2021-07-17 07:37:27 +00:00
|
|
|
alc +=10;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,100+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(100+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
|
|
|
|
(void)qp;
|
|
|
|
}
|
|
|
|
|
2021-08-17 06:25:11 +00:00
|
|
|
void meter::drawScaleComp(QPainter *qp)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// 0000=0 dB, 0130=15 dB,0241=30 dB
|
|
|
|
//
|
|
|
|
|
|
|
|
qp->setPen(lowTextColor);
|
|
|
|
|
|
|
|
int midPointDn = 130;
|
|
|
|
int midPointdB = 15;
|
|
|
|
|
|
|
|
int highPointDn = 241;
|
|
|
|
int highPointdB = 30;
|
|
|
|
float dBperDn = (float)(highPointdB-midPointdB) / float(highPointDn-midPointDn);
|
|
|
|
|
|
|
|
int i=mXstart;
|
|
|
|
for(; i<mXstart+midPointDn; i+=midPointDn/4)
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int)((i-mXstart) * (float(midPointdB) / float(midPointDn)) )) );
|
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = midPointDn+60;
|
|
|
|
for(; i<mXstart+255; i+= 30)
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int) std::round( ((i-mXstart-midPointDn) * (dBperDn) ) + (midPointdB) )));
|
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the lines:
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
|
|
|
// Line: X1, Y1 -->to--> X2, Y2
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
}
|
|
|
|
|
2021-07-17 07:37:27 +00:00
|
|
|
void meter::drawScaleSWR(QPainter *qp)
|
|
|
|
{
|
|
|
|
// From the manual:
|
|
|
|
// 0000=SWR1.0,
|
|
|
|
// 0048=SWR1.5,
|
|
|
|
// 0080=SWR2.0,
|
|
|
|
// 0120=SWR3.0
|
|
|
|
|
|
|
|
qp->drawText(mXstart,scaleTextYstart, QString("1.0"));
|
|
|
|
qp->drawText(24+mXstart,scaleTextYstart, QString("1.3"));
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawText(48+mXstart,scaleTextYstart, QString("1.5"));
|
2021-07-17 07:37:27 +00:00
|
|
|
qp->drawText(80+mXstart,scaleTextYstart, QString("2.0"));
|
|
|
|
qp->drawText(100+mXstart,scaleTextYstart, QString("2.5"));
|
|
|
|
qp->drawText(120+mXstart,scaleTextYstart, QString("3.0"));
|
|
|
|
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine( 0+mXstart,scaleTextYstart, 0+mXstart, scaleTextYstart+5);
|
|
|
|
qp->drawLine( 24+mXstart,scaleTextYstart, 24+mXstart, scaleTextYstart+5);
|
|
|
|
qp->drawLine( 48+mXstart,scaleTextYstart, 48+mXstart, scaleTextYstart+5);
|
|
|
|
qp->drawLine( 80+mXstart,scaleTextYstart, 80+mXstart, scaleTextYstart+5);
|
|
|
|
qp->drawLine(100+mXstart,scaleTextYstart,100+mXstart, scaleTextYstart+5); // does not draw?
|
|
|
|
qp->drawLine(120+mXstart,scaleTextYstart,120+mXstart, scaleTextYstart+5);
|
|
|
|
|
|
|
|
|
2021-07-17 07:37:27 +00:00
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,100+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(100+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
|
|
|
|
2021-08-17 06:25:11 +00:00
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void meter::drawScaleId(QPainter *qp)
|
|
|
|
{
|
2021-08-17 06:25:11 +00:00
|
|
|
// IC-7300:
|
|
|
|
// 0000=0, 0097=10, 0146=15, 0241=25
|
|
|
|
//
|
|
|
|
|
|
|
|
qp->setPen(lowTextColor);
|
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
|
|
|
|
|
|
|
// 7300/9700 and others:
|
|
|
|
int midPointDn = 97;
|
|
|
|
int midPointId = 10;
|
|
|
|
|
|
|
|
int highPointDn = 146;
|
|
|
|
int highPointId = 15;
|
|
|
|
float IdperDn = (float)(highPointId-midPointId) / float(highPointDn-midPointDn);
|
|
|
|
|
|
|
|
int i=mXstart;
|
|
|
|
for(; i<mXstart+midPointDn; i+=midPointDn/4)
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int)((i-mXstart) * (float(midPointId) / float(midPointDn)) )) );
|
2021-08-17 06:37:50 +00:00
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
2021-08-17 06:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(; i<mXstart+255; i+= 4*(highPointDn-midPointDn) / (highPointId-midPointId))
|
|
|
|
{
|
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg( (int) std::round( ((i-mXstart-midPointDn) * (IdperDn) ) + (midPointId) )));
|
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the lines:
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
|
|
|
// Line: X1, Y1 -->to--> X2, Y2
|
|
|
|
qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart);
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
2021-07-17 00:45:07 +00:00
|
|
|
}
|
2021-02-24 08:18:19 +00:00
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
void meter::drawScaleS(QPainter *qp)
|
2021-02-24 08:18:19 +00:00
|
|
|
{
|
2021-08-17 06:25:11 +00:00
|
|
|
//
|
|
|
|
// 0000=S0, 0120=S9, 0241=S9+60dB
|
|
|
|
// 120 / 9 = 13.333 steps per S-unit
|
|
|
|
|
2021-02-24 08:18:19 +00:00
|
|
|
qp->setPen(lowTextColor);
|
2021-07-20 06:46:11 +00:00
|
|
|
//qp->setFont(QFont("Arial", fontSize));
|
2021-07-17 00:45:07 +00:00
|
|
|
int i=mXstart;
|
2021-02-24 08:18:19 +00:00
|
|
|
// 13.3 DN per s-unit:
|
|
|
|
int s=0;
|
2021-07-17 00:45:07 +00:00
|
|
|
for(; i<mXstart+120; i+=13)
|
2021-02-24 08:18:19 +00:00
|
|
|
{
|
2021-07-20 06:46:11 +00:00
|
|
|
qp->drawText(i,scaleTextYstart, QString("%1").arg(s++) );
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
2021-02-24 08:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 2 DN per 1 dB now:
|
|
|
|
// 20 DN per 10 dB
|
|
|
|
// 40 DN per 20 dB
|
|
|
|
|
|
|
|
// Modify current scale position:
|
|
|
|
s = 20;
|
|
|
|
i+=20;
|
|
|
|
|
|
|
|
qp->setPen(Qt::red);
|
|
|
|
|
2021-07-17 00:45:07 +00:00
|
|
|
for(; i<mXstart+255; i+=40)
|
2021-02-24 08:18:19 +00:00
|
|
|
{
|
2021-07-20 06:46:11 +00:00
|
|
|
qp->drawText(i,scaleTextYstart, QString("+%1").arg(s) );
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(i,scaleTextYstart, i, scaleTextYstart+5);
|
2021-02-24 08:18:19 +00:00
|
|
|
s = s + 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp->setPen(lowLineColor);
|
|
|
|
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart);
|
2021-02-24 08:18:19 +00:00
|
|
|
qp->setPen(Qt::red);
|
2021-08-17 06:25:11 +00:00
|
|
|
qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart);
|
2021-02-24 08:18:19 +00:00
|
|
|
|
|
|
|
}
|