From 437c8c5c3fdf1de86a8e38d4b26d822f8d9e2115 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 4 Jun 2015 16:42:38 +0000 Subject: [PATCH] Starting to add EME Echo mode. (Not yet functional!) git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5522 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 3 + Modes.cpp | 1 + Modes.hpp | 1 + echograph.cpp | 84 ++++++++++++++ echograph.h | 31 ++++++ echograph.ui | 233 +++++++++++++++++++++++++++++++++++++++ echoplot.cpp | 292 +++++++++++++++++++++++++++++++++++++++++++++++++ echoplot.h | 92 ++++++++++++++++ mainwindow.cpp | 17 +++ mainwindow.h | 6 + mainwindow.ui | 23 +++- wsjtx.pro | 8 +- 12 files changed, 787 insertions(+), 4 deletions(-) create mode 100644 echograph.cpp create mode 100644 echograph.h create mode 100644 echograph.ui create mode 100644 echoplot.cpp create mode 100644 echoplot.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a664f0272..92e091cff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,6 +230,8 @@ set (wsjtx_CXXSRCS signalmeter.cpp plotter.cpp widegraph.cpp + echograph.cpp + echoplot.cpp about.cpp astro.cpp messageaveraging.cpp @@ -394,6 +396,7 @@ set (wsjtx_UISRCS mainwindow.ui about.ui astro.ui + echograph.ui messageaveraging.ui widegraph.ui logqso.ui diff --git a/Modes.cpp b/Modes.cpp index adae5a8aa..503330dfe 100644 --- a/Modes.cpp +++ b/Modes.cpp @@ -13,6 +13,7 @@ namespace "JT9W-1", "JT4", "WSPR", + "Echo", }; } diff --git a/Modes.hpp b/Modes.hpp index 47d548acd..dba2bd78b 100644 --- a/Modes.hpp +++ b/Modes.hpp @@ -20,6 +20,7 @@ public: JT9W_1, JT4, WSPR, + Echo, }; explicit Modes (QObject * parent = nullptr); diff --git a/echograph.cpp b/echograph.cpp new file mode 100644 index 000000000..c2fc9c665 --- /dev/null +++ b/echograph.cpp @@ -0,0 +1,84 @@ +//#include "commons.h" +#include "echoplot.h" +#include "echograph.h" +#include "ui_echograph.h" + +#define NSMAX2 1366 + +EchoGraph::EchoGraph(QWidget *parent) : + QDialog(parent), + ui(new Ui::EchoGraph) +{ + ui->setupUi(this); + this->setWindowFlags(Qt::Dialog); + this->installEventFilter(parent); //Installing the filter + ui->echoPlot->setCursor(Qt::CrossCursor); + this->setMaximumWidth(2048); + this->setMaximumHeight(880); + ui->echoPlot->setMaximumHeight(800); + +//Restore user's settings + QString inifile(QApplication::applicationDirPath()); + inifile += "/emecho.ini"; + QSettings settings(inifile, QSettings::IniFormat); + + settings.beginGroup("EchoGraph"); + ui->echoPlot->setPlotZero(settings.value("PlotZero", 0).toInt()); + ui->echoPlot->setPlotGain(settings.value("PlotGain", 0).toInt()); + ui->zeroSlider->setValue(ui->echoPlot->getPlotZero()); + ui->gainSlider->setValue(ui->echoPlot->getPlotGain()); + ui->smoothSpinBox->setValue(settings.value("Smooth",0).toInt()); + ui->echoPlot->m_blue=settings.value("BlueCurve",false).toBool(); + ui->cbBlue->setChecked(ui->echoPlot->m_blue); + settings.endGroup(); +} + +EchoGraph::~EchoGraph() +{ + saveSettings(); + delete ui; +} + +void EchoGraph::saveSettings() +{ +//Save user's settings + QString inifile(QApplication::applicationDirPath()); + inifile += "/emecho.ini"; + QSettings settings(inifile, QSettings::IniFormat); + + settings.beginGroup("EchoGraph"); + settings.setValue("PlotZero",ui->echoPlot->m_plotZero); + settings.setValue("PlotGain",ui->echoPlot->m_plotGain); + settings.setValue("Smooth",ui->echoPlot->m_smooth); + settings.setValue("BlueCurve",ui->echoPlot->m_blue); + settings.endGroup(); +} + +void EchoGraph::plotSpec() +{ + ui->echoPlot->draw(); +} + +void EchoGraph::on_smoothSpinBox_valueChanged(int n) +{ + ui->echoPlot->setSmooth(n); + ui->echoPlot->draw(); +} + +void EchoGraph::on_cbBlue_toggled(bool checked) +{ + ui->echoPlot->m_blue=checked; + ui->echoPlot->draw(); +} + +void EchoGraph::on_gainSlider_valueChanged(int value) +{ + ui->echoPlot->setPlotGain(value); + ui->echoPlot->draw(); +} + +void EchoGraph::on_zeroSlider_valueChanged(int value) +{ + ui->echoPlot->setPlotZero(value); + ui->echoPlot->draw(); +} diff --git a/echograph.h b/echograph.h new file mode 100644 index 000000000..25657265d --- /dev/null +++ b/echograph.h @@ -0,0 +1,31 @@ +#ifndef ECHOGRAPH_H +#define ECHOGRAPH_H +#include + +namespace Ui { + class EchoGraph; +} + +class EchoGraph : public QDialog +{ + Q_OBJECT + +public: + explicit EchoGraph(QWidget *parent = 0); + ~EchoGraph(); + + void plotSpec(); + void saveSettings(); + +private slots: + void on_smoothSpinBox_valueChanged(int n); + void on_cbBlue_toggled(bool checked); + void on_gainSlider_valueChanged(int value); + void on_zeroSlider_valueChanged(int value); + +private: + + Ui::EchoGraph *ui; +}; + +#endif // ECHOGRAPH_H diff --git a/echograph.ui b/echograph.ui new file mode 100644 index 000000000..78121764a --- /dev/null +++ b/echograph.ui @@ -0,0 +1,233 @@ + + + EchoGraph + + + + 0 + 0 + 625 + 336 + + + + + 0 + 0 + + + + + 570 + 0 + + + + Echo Graph + + + + 2 + + + 2 + + + 2 + + + + + 2 + + + + + true + + + + 0 + 0 + + + + + 273 + 200 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 1 + + + + + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + Gain + + + + + + + -20 + + + 20 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + Zero + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + Smooth + + + + + + + 20 + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + Blue + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + + + + + EPlotter + QFrame +
plotter.h
+ 1 +
+
+ + +
diff --git a/echoplot.cpp b/echoplot.cpp new file mode 100644 index 000000000..e0e44e53c --- /dev/null +++ b/echoplot.cpp @@ -0,0 +1,292 @@ +#include "echoplot.h" +//#include "commons.h" +#include +#include +#include "moc_echoplot.cpp" + +#define MAX_SCREENSIZE 2048 + + +EPlotter::EPlotter(QWidget *parent) : //EPlotter Constructor + QFrame(parent) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setFocusPolicy(Qt::StrongFocus); + setAttribute(Qt::WA_PaintOnScreen,false); + setAutoFillBackground(false); + setAttribute(Qt::WA_OpaquePaintEvent, false); + setAttribute(Qt::WA_NoSystemBackground, true); + + m_StartFreq = -200; + m_fftBinWidth=48000.0/131072.0; + m_fSpan=1000.0; + m_hdivs = HORZ_DIVS; + m_Running = false; + m_paintEventBusy=false; + m_2DPixmap = QPixmap(0,0); + m_ScalePixmap = QPixmap(0,0); + m_OverlayPixmap = QPixmap(0,0); + m_Size = QSize(0,0); + m_TxFreq = 1500; + m_line = 0; + m_dBStepSize=10; + m_Percent2DScreen = 89; //percent of screen used for 2D display +} + +EPlotter::~EPlotter() { } // Destructor + +QSize EPlotter::minimumSizeHint() const +{ + return QSize(50, 50); +} + +QSize EPlotter::sizeHint() const +{ + return QSize(180, 180); +} + +void EPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() +{ + if(!size().isValid()) return; + if( m_Size != size() ) { //if changed, resize pixmaps to new screensize + m_Size = size(); + m_w = m_Size.width(); + m_h = m_Size.height(); + m_h1 = (100-m_Percent2DScreen)*(m_Size.height())/100; + m_h2 = (m_Percent2DScreen)*(m_Size.height())/100; + + m_2DPixmap = QPixmap(m_Size.width(), m_h2); + m_2DPixmap.fill(Qt::black); + m_OverlayPixmap = QPixmap(m_Size.width(), m_h2); + m_OverlayPixmap.fill(Qt::black); + + m_2DPixmap.fill(Qt::black); + m_ScalePixmap = QPixmap(m_w,30); + m_ScalePixmap.fill(Qt::white); + + m_fSpan=m_w*m_fftBinWidth; + m_StartFreq=50 * int((-0.5*m_fSpan)/50.0 - 0.5); + } + DrawOverlay(); + draw(); +} + +void EPlotter::paintEvent(QPaintEvent *) // paintEvent() +{ + if(m_paintEventBusy) return; + m_paintEventBusy=true; + QPainter painter(this); + painter.drawPixmap(0,0,m_ScalePixmap); + painter.drawPixmap(0,m_h1,m_2DPixmap); + m_paintEventBusy=false; +} + +void EPlotter::draw() //draw() +{ + int i,j,y; + float blue[2000],red[2000]; + float gain = pow(10.0,(m_plotGain/20.0)); + + if(m_2DPixmap.size().width()==0) return; + QPainter painter2D(&m_2DPixmap); + QRect tmp(0,0,m_w,m_h2); + painter2D.fillRect(tmp,Qt::black); +/* + if(datcom_.nclearave==0) { + QPoint LineBuf[MAX_SCREENSIZE]; + QPen penBlue(QColor(0,255,255),1); + QPen penRed(Qt::red,1); + j=0; + int i0=1000 + int(m_StartFreq/m_fftBinWidth); + for(i=0; i<2000; i++) { + blue[i]=datcom_.blue[i]; + red[i]=datcom_.red[i]; + } + if(m_smooth>0) { + for(i=0; i250) m_freqPerDiv=50; + float pixPerHdiv = m_freqPerDiv/m_fftBinWidth; + float pixPerVdiv = float(m_h2)/float(VERT_DIVS); + + m_hdivs = m_w*m_fftBinWidth/m_freqPerDiv + 0.9999; + + painter.setPen(QPen(Qt::white, 1,Qt::DotLine)); + for( int i=1; im_w) return m_w; + return x; +} + +float EPlotter::FreqfromX(int x) //FreqfromX() +{ + return float(m_StartFreq + x*m_fftBinWidth); +} + +void EPlotter::SetRunningState(bool running) //SetRunningState() +{ + m_Running = running; +} + +void EPlotter::setPlotZero(int plotZero) //setPlotZero() +{ + m_plotZero=plotZero; +} + +int EPlotter::getPlotZero() //getPlotZero() +{ + return m_plotZero; +} + +void EPlotter::setPlotGain(int plotGain) //setPlotGain() +{ + m_plotGain=plotGain; +} + +int EPlotter::getPlotGain() //getPlotGain() +{ + return m_plotGain; +} + +void EPlotter::setSmooth(int n) //setSmooth() +{ + m_smooth=n; +} + +int EPlotter::getSmooth() //getSmooth() +{ + return m_smooth; +} +int EPlotter::plotWidth(){return m_2DPixmap.width();} +void EPlotter::UpdateOverlay() {DrawOverlay();} diff --git a/echoplot.h b/echoplot.h new file mode 100644 index 000000000..ce6553361 --- /dev/null +++ b/echoplot.h @@ -0,0 +1,92 @@ +/////////////////////////////////////////////////////////////////////////// +// Some code in this file and accompanying files is based on work by +// Moe Wheatley, AE4Y, released under the "Simplified BSD License". +// For more details see the accompanying file LICENSE_WHEATLEY.TXT +/////////////////////////////////////////////////////////////////////////// + +#ifndef EPLOTTER_H +#define EPLOTTER_H + +#include +#include +#include +#include + +#define VERT_DIVS 7 //specify grid screen divisions +#define HORZ_DIVS 20 + +class EPlotter : public QFrame +{ + Q_OBJECT +public: + explicit EPlotter(QWidget *parent = 0); + ~EPlotter(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + QColor m_ColorTbl[256]; + float m_fSpan; + qint32 m_TxFreq; + qint32 m_w; + qint32 m_plotZero; + qint32 m_plotGain; + qint32 m_smooth; + bool m_blue; + + void draw(); //Update the waterfall + void SetRunningState(bool running); + void setPlotZero(int plotZero); + int getPlotZero(); + void setPlotGain(int plotGain); + int getPlotGain(); + int plotWidth(); + void UpdateOverlay(); + void DrawOverlay(); + void setSmooth(int n); + int getSmooth(); + +// void SetPercent2DScreen(int percent){m_Percent2DScreen=percent;} + +protected: + //re-implemented widget event handlers + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent* event); + +private: + + void MakeFrequencyStrs(); + int XfromFreq(float f); + float FreqfromX(int x); + qint64 RoundFreq(qint64 freq, int resolution); + + QPixmap m_2DPixmap; + QPixmap m_ScalePixmap; + QPixmap m_OverlayPixmap; + QSize m_Size; + QString m_Str; + QString m_HDivText[483]; + + double m_fftBinWidth; + + qint64 m_StartFreq; + + qint32 m_dBStepSize; + qint32 m_hdivs; + qint32 m_line; + qint32 m_freqPerDiv; + qint32 m_Percent2DScreen; + qint32 m_h; + qint32 m_h1; + qint32 m_h2; + + bool m_Running; + bool m_paintEventBusy; + +}; + +extern "C" { +//--------------------------------------------------- C and Fortran routines + +void smo121_(float x[], int* npts); +} +#endif // EPLOTTER_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 903980dd9..8b2ed0767 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -20,6 +20,8 @@ #include "revision_utils.hpp" #include "soundout.h" #include "plotter.h" +#include "echoplot.h" +#include "echograph.h" #include "about.h" #include "astro.h" #include "messageaveraging.h" @@ -72,6 +74,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme m_config {settings, this}, m_WSPR_band_hopping {settings, &m_config, this}, m_wideGraph (new WideGraph (settings)), + m_echoGraph (new EchoGraph), m_logDlg (new LogQSO (program_title (), settings, this)), m_dialFreq {std::numeric_limits::max ()}, m_detector (RX_SAMPLE_RATE, NTMAX, 6912 / 2, downSampleFactor), @@ -218,6 +221,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme ui->actionJT4->setActionGroup(modeGroup); ui->actionWSPR_2->setActionGroup(modeGroup); ui->actionWSPR_15->setActionGroup(modeGroup); + ui->actionEcho->setActionGroup(modeGroup); QActionGroup* saveGroup = new QActionGroup(this); ui->actionNone->setActionGroup(saveGroup); @@ -1276,6 +1280,11 @@ void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls m_wideGraph->show(); } +void MainWindow::on_actionEcho_Graph_triggered() +{ + m_echoGraph->show(); +} + void MainWindow::on_actionAstronomical_data_triggered() { if (!m_astroWidget) @@ -3159,6 +3168,13 @@ void MainWindow::on_actionWSPR_15_triggered() switch_mode (Modes::WSPR); } +void MainWindow::on_actionEcho_triggered() +{ + m_mode="Echo"; + switch_mode(Modes::Echo); + if(!m_echoGraph->isVisible()) m_echoGraph->show(); +} + void MainWindow::switch_mode (Mode mode) { auto f = m_dialFreq; @@ -4306,3 +4322,4 @@ void MainWindow::on_tabWidget_currentChanged (int new_value) m_nonWSPRTab = new_value; } } + diff --git a/mainwindow.h b/mainwindow.h index a62d42a5c..42584a382 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -54,6 +54,7 @@ class QSettings; class QLineEdit; class QFont; class QHostInfo; +class EchoGraph; class WideGraph; class LogQSO; class Transceiver; @@ -230,6 +231,10 @@ private slots: void on_pbTxNext_clicked(bool b); void on_tabWidget_currentChanged (int); + void on_actionEcho_Graph_triggered(); + + void on_actionEcho_triggered(); + private: Q_SIGNAL void initializeAudioOutputStream (QAudioDeviceInfo, unsigned channels, unsigned msBuffered) const; @@ -266,6 +271,7 @@ private: QMessageBox m_rigErrorMessageBox; QScopedPointer m_wideGraph; + QScopedPointer m_echoGraph; QScopedPointer m_logDlg; QScopedPointer m_astroWidget; QScopedPointer m_shortcuts; diff --git a/mainwindow.ui b/mainwindow.ui index 99f7d4663..6a7ee82d3 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -910,7 +910,7 @@ Check to add 2.5 s to expected propagation delay. - EME + EME delay @@ -2736,6 +2736,7 @@ QLabel[oob="true"] { + @@ -2779,6 +2780,7 @@ QLabel[oob="true"] { + @@ -3183,6 +3185,25 @@ QLabel[oob="true"] { WSPR-15 + + + Echo Graph + + + F8 + + + + + true + + + Echo + + + EME Echo mode + + diff --git a/wsjtx.pro b/wsjtx.pro index 6cb7a73ae..4073b1a3c 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -91,7 +91,8 @@ SOURCES += \ main.cpp \ decodedtext.cpp \ wsprnet.cpp \ - messageaveraging.cpp + messageaveraging.cpp \ + echoplot.cpp echograph.cpp Modes.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -110,7 +111,8 @@ HEADERS += qt_helpers.hpp \ logbook/countrydat.h \ logbook/countriesworked.h \ logbook/adif.h \ - messageaveraging.h + messageaveraging.h \ + echoplot.h echograph.h Modes.hpp INCLUDEPATH += qmake_only @@ -121,7 +123,7 @@ HEADERS += OmniRigTransceiver.hpp FORMS += mainwindow.ui about.ui Configuration.ui widegraph.ui astro.ui \ logqso.ui wf_palette_design_dialog.ui \ - messageaveraging.ui + messageaveraging.ui echograph.ui RC_FILE = wsjtx.rc RESOURCES = wsjtx.qrc