Added new meter widget.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3489 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Edson W. R. Pereira 2013-07-16 21:16:57 +00:00
parent e26c53e253
commit 94b80c4b0d
8 changed files with 271 additions and 128 deletions

View File

@ -191,8 +191,14 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
m_CATerror=false;
decodeBusy(false);
ui->xThermo->setMaximumWidth(12);
ui->xThermo->setTextVisible(false);
//ui->xThermo->setMaximumWidth(12);
//ui->xThermo->setTextVisible(false);
signalMeter = new SignalMeter(ui->meterFrame);
signalMeter->resize(50, 160);
qDebug() << signalMeter->size();
ui->labAz->setStyleSheet("border: 0px;");
ui->labDist->setStyleSheet("border: 0px;");
@ -639,7 +645,8 @@ void MainWindow::dataSink(int k)
m_pctZap=nzap*100.0/m_nsps;
t.sprintf(" Rx noise: %5.1f ",px);
lab2->setText(t);
ui->xThermo->setValue((double)px); //Update thermometer
//ui->xThermo->setValue((double)px); //Update thermometer
signalMeter->setValue(px); // Update thermometer
if(m_monitoring || m_diskData) {
g_pWideGraph->dataSink2(s,df3,ihsym,m_diskData);
}
@ -1729,7 +1736,8 @@ void MainWindow::guiUpdate()
m_msgSent0=t;
}
ui->xThermo->setValue(0.0); //Set Thermo to zero
//ui->xThermo->setValue(0.0); //Set Thermo to zero
signalMeter->setValue(0);
m_monitoring=false;
soundInThread.setMonitoring(false);
btxok=true;
@ -1802,7 +1810,8 @@ void MainWindow::guiUpdate()
t.time().toString() + " ";
ui->labUTC->setText(utc);
if(!m_monitoring and !m_diskData) {
ui->xThermo->setValue(0.0);
//ui->xThermo->setValue(0.0);
signalMeter->setValue(0);
}
if(m_catEnabled and m_poll>0 and (nsec%m_poll)==0 and !m_decoderBusy) {
@ -1868,7 +1877,8 @@ void MainWindow::startTx2()
soundOutThread.setTxSNR(snr);
soundOutThread.m_modeTx=m_modeTx;
soundOutThread.start(QThread::HighestPriority);
ui->xThermo->setValue(0.0); //Set Thermo to zero
//ui->xThermo->setValue(0.0); //Set Thermo to zero
signalMeter->setValue(0);
m_monitoring=false;
soundInThread.setMonitoring(false);
btxok=true;

View File

@ -12,6 +12,7 @@
#include "commons.h"
#include "psk_reporter.h"
#include "rigclass.h"
#include "signalmeter.h"
#ifdef WIN32
#include "PSKReporter.h"
@ -330,10 +331,9 @@ private:
SoundInThread soundInThread; //Instantiate the audio threads
SoundOutThread soundOutThread;
QSharedMemory *mem_jt9;
PSK_Reporter *psk_Reporter;
SignalMeter *signalMeter;
//---------------------------------------------------- private functions
void readSettings();

View File

@ -84,7 +84,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Courier New'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
@ -526,7 +526,57 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="3">
<item row="2" column="0" rowspan="5">
<widget class="QFrame" name="meterFrame">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="labAz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>23</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QComboBox" name="bandComboBox">
<property name="toolTip">
<string>Select operating band</string>
@ -616,7 +666,7 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="2">
<widget class="QPushButton" name="readFreq">
<property name="maximumSize">
<size>
@ -632,7 +682,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="4" colspan="2">
<item row="0" column="3" colspan="2">
<widget class="QLabel" name="labDialFreq">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -670,7 +720,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="7">
<item row="0" column="6">
<widget class="QCheckBox" name="txFirstCheckBox">
<property name="minimumSize">
<size>
@ -692,7 +742,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="9" rowspan="7">
<item row="0" column="8" rowspan="7">
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -707,7 +757,7 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
@ -743,7 +793,7 @@ p, li { white-space: pre-wrap; }
<enum>QTabWidget::Triangular</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -819,7 +869,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -853,7 +903,7 @@ p, li { white-space: pre-wrap; }
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -884,7 +934,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -1052,7 +1102,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -1200,7 +1250,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -1231,7 +1281,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
@ -1493,14 +1543,14 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="cbPlus2kHz">
<property name="text">
<string> +2 kHz</string>
</property>
</widget>
</item>
<item row="1" column="4">
<item row="1" column="3">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -1592,7 +1642,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="4">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -1690,7 +1740,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="7">
<item row="1" column="6">
<widget class="QPushButton" name="pbTxMode">
<property name="enabled">
<bool>false</bool>
@ -1701,40 +1751,6 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="2" column="1" rowspan="5">
<widget class="QProgressBar" name="xThermo">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>160</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>15</width>
<height>160</height>
</size>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="2" column="2" rowspan="5">
<widget class="QSlider" name="inGain">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -1768,7 +1784,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="4">
<item row="2" column="3">
<widget class="QLineEdit" name="dxCallEntry">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -1799,7 +1815,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="5">
<item row="2" column="4">
<widget class="QLineEdit" name="dxGridEntry">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -1830,7 +1846,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="7">
<item row="2" column="6">
<widget class="QSpinBox" name="TxFreqSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -1871,40 +1887,6 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="labAz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>23</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QLabel" name="labDist">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -1932,7 +1914,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="3" column="6">
<item row="3" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -1948,7 +1930,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="3" column="7">
<item row="3" column="6">
<widget class="QSpinBox" name="RxFreqSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -1979,7 +1961,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="3" column="8">
<item row="3" column="7">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -1995,26 +1977,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>dB</string>
</property>
</widget>
</item>
<item row="4" column="4">
<item row="4" column="3">
<widget class="QPushButton" name="lookupButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2036,7 +1999,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="5">
<item row="4" column="4">
<widget class="QPushButton" name="addButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2058,7 +2021,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="7">
<item row="4" column="6">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>5</number>
@ -2112,7 +2075,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="5" column="4" rowspan="2" colspan="2">
<item row="5" column="3" rowspan="2" colspan="2">
<widget class="QLabel" name="labUTC">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2157,14 +2120,14 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="5" column="7">
<item row="5" column="6">
<widget class="QCheckBox" name="cbTxLock">
<property name="text">
<string>Lock Tx=Rx</string>
</property>
</widget>
</item>
<item row="6" column="7">
<item row="6" column="6">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>5</number>
@ -2228,7 +2191,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>760</width>
<height>21</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">

51
meterwidget.cpp Normal file
View File

@ -0,0 +1,51 @@
// Simple bargraph meter
// Implemented by Edson Pereira PY2SDR
#include "meterwidget.h"
MeterWidget::MeterWidget(QWidget *parent) :
QWidget(parent),
m_signal(0)
{
for ( int i = 0; i < 10; i++ ) {
signalQueue.enqueue(0);
}
}
void MeterWidget::setValue(int value)
{
m_signal = value;
signalQueue.enqueue(value);
signalQueue.dequeue();
// Get signal peak
int tmp = 0;
for (int i = 0; i < signalQueue.size(); ++i) {
if (signalQueue.at(i) > tmp)
tmp = signalQueue.at(i);
}
m_sigPeak = tmp;
update();
}
void MeterWidget::paintEvent( QPaintEvent * )
{
int pos;
QPainter p;
p.begin(this);
// Sanitize
m_signal = m_signal < 0 ? 0 : m_signal;
m_signal = m_signal > 60 ? 60 : m_signal;
pos = m_signal * 2;
QRect r(0, height() - pos, width(), pos );
p.fillRect(r, QColor( 255, 150, 0 ));
// Draw peak hold indicator
p.setPen(Qt::black);
pos = m_sigPeak * 2;
p.drawLine(0, height() - pos, 10, height() - pos);
}

30
meterwidget.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef METERWIDGET_H
#define METERWIDGET_H
#include <QWidget>
#include <QtGui>
#include <QQueue>
class MeterWidget : public QWidget
{
Q_OBJECT
public:
explicit MeterWidget(QWidget *parent = 0);
signals:
public slots:
void setValue(int value);
private:
QQueue<int> signalQueue;
int m_signal;
int m_sigPeak;
protected:
void paintEvent( QPaintEvent * );
};
#endif // METERWIDGET_H

53
signalmeter.cpp Normal file
View File

@ -0,0 +1,53 @@
// Simple bargraph dB meter
// Implemented by Edson Pereira PY2SDR
//
// Limits and geometry are hardcded for now.
#include "signalmeter.h"
SignalMeter::SignalMeter(QWidget *parent) :
QWidget(parent)
{
resize(parent->size());
m_meter = new MeterWidget(this);
m_meter->setGeometry(10, 10, 10, 120);
m_label = new QLabel(this);
m_label->setGeometry(10, 135, 20, 20);
QLabel *dbLabel = new QLabel(this);
dbLabel->setText("dB");
dbLabel->setGeometry(30, 135, 20, 20);
}
SignalMeter::~SignalMeter()
{
}
void SignalMeter::paintEvent( QPaintEvent * )
{
QPainter p;
p.begin(this);
p.drawLine(22, 10, 22, 130);
for ( int i = 0; i <= 60; i += 10 ) {
p.drawLine(22, i*2 + 10, 25, i*2 + 10);
}
for ( int i = 10; i < 60; i += 10 ) {
p.drawText(30, i*2 + 15, QString::number(60 - i));
}
}
void SignalMeter::setValue(int value)
{
m_meter->setValue(value);
m_label->setText(QString::number(value));
}
void SignalMeter::resizeEvent(QResizeEvent *s)
{
resize(s->size());
}

32
signalmeter.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef SIGNALMETER_H
#define SIGNALMETER_H
#include <QtGui>
#include <QLabel>
#include <meterwidget.h>
class SignalMeter : public QWidget
{
Q_OBJECT
public:
explicit SignalMeter(QWidget *parent = 0);
~SignalMeter();
public slots:
void setValue(int value);
private:
MeterWidget *m_meter;
QLabel *m_label;
int m_signal;
int m_sigPeak;
protected:
void paintEvent( QPaintEvent * );
void resizeEvent(QResizeEvent *s);
};
#endif // SIGNALMETER_H

View File

@ -36,7 +36,9 @@ QMAKE_EXTRA_COMPILERS += gfortran
SOURCES += main.cpp mainwindow.cpp plotter.cpp about.cpp \
soundin.cpp soundout.cpp devsetup.cpp widegraph.cpp \
getfile.cpp displaytext.cpp getdev.cpp logqso.cpp \
psk_reporter.cpp rigclass.cpp
psk_reporter.cpp rigclass.cpp \
signalmeter.cpp \
meterwidget.cpp
win32 {
SOURCES += killbyname.cpp
@ -45,7 +47,9 @@ SOURCES += killbyname.cpp
HEADERS += mainwindow.h plotter.h soundin.h soundout.h \
about.h devsetup.h widegraph.h getfile.h \
commons.h sleep.h displaytext.h logqso.h \
psk_reporter.h rigclass.h
psk_reporter.h rigclass.h \
signalmeter.h \
meterwidget.h
# (Is the following really needed???)
#DEFINES += __cplusplus