From a8d0e2eeeb77cae2f0d1f8c6d175bb9dee16baea Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Sun, 22 Nov 2015 23:38:42 +0000 Subject: [PATCH] Add user option to set percentage of WideGraph height used for spectrum plot. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6156 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- plotter.cpp | 21 ++++++++++++++----- plotter.h | 3 ++- widegraph.cpp | 11 ++++++++-- widegraph.h | 4 +++- widegraph.ui | 57 +++++++++++++++++++++++++++++++++++---------------- 5 files changed, 69 insertions(+), 27 deletions(-) diff --git a/plotter.cpp b/plotter.cpp index a30ab7deb..05494aac5 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -33,6 +33,7 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor m_nsps=6912; m_dBStepSize=10; m_Percent2DScreen = 30; //percent of screen used for 2D display + m_Percent2DScreen0 = 0; m_txFreq=0; m_fftBinWidth=1500.0/2048.0; m_bScaleOK=false; @@ -53,24 +54,26 @@ QSize CPlotter::sizeHint() const void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() { if(!size().isValid()) return; - if( m_Size != size() or (m_bReference != m_bReference0)) { + if( m_Size != size() or (m_bReference != m_bReference0) or + m_Percent2DScreen != m_Percent2DScreen0) { m_Size = size(); m_w = m_Size.width(); m_h = m_Size.height(); - m_h2 = (m_Percent2DScreen)*(m_h)/100; - if(m_h2>100) m_h2=100; + m_h2 = m_Percent2DScreen*m_h/100.0; + if(m_h2>m_h-30) m_h2=m_h-30; if(m_bReference) m_h2=m_h-30; + if(m_h2<1) m_h2=1; m_h1=m_h-m_h2; m_2DPixmap = QPixmap(m_Size.width(), m_h2); m_2DPixmap.fill(Qt::black); m_WaterfallPixmap = QPixmap(m_Size.width(), m_h1); m_OverlayPixmap = QPixmap(m_Size.width(), m_h2); m_OverlayPixmap.fill(Qt::black); - m_WaterfallPixmap.fill(Qt::black); m_2DPixmap.fill(Qt::black); - m_ScalePixmap = QPixmap(m_w,30); + m_ScalePixmap = QPixmap(m_w,m_h2); m_ScalePixmap.fill(Qt::white); + m_Percent2DScreen0 = m_Percent2DScreen; } DrawOverlay(); } @@ -603,3 +606,11 @@ void CPlotter::setColours(QVector const& cl) { g_ColorTbl = cl; } + +void CPlotter::SetPercent2DScreen(int percent) +{ + m_Percent2DScreen=percent; + resizeEvent(NULL); +// DrawOverlay(); + update(); +} diff --git a/plotter.h b/plotter.h index bbd96e86e..25fa1de94 100644 --- a/plotter.h +++ b/plotter.h @@ -62,7 +62,7 @@ public: void setMode(QString mode); void setSubMode(int n); void setModeTx(QString modeTx); - void SetPercent2DScreen(int percent){m_Percent2DScreen=percent;} + void SetPercent2DScreen(int percent); int Fmax(); void setDialFreq(double d); void setCurrent(bool b) {m_bCurrent = b;} @@ -147,6 +147,7 @@ private: qint32 m_freqPerDiv; qint32 m_nsps; qint32 m_Percent2DScreen; + qint32 m_Percent2DScreen0; qint32 m_h; qint32 m_h1; qint32 m_h2; diff --git a/widegraph.cpp b/widegraph.cpp index 17b09d573..c47d44038 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -55,6 +55,8 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : ui->bppSpinBox->setValue(n); m_nsmo=m_settings->value("SmoothYellow",1).toInt(); ui->smoSpinBox->setValue(m_nsmo); + m_Percent2DScreen=m_settings->value("Percent2D",30).toInt(); + ui->sbPercent2dPlot->setValue(m_Percent2DScreen); m_waterfallAvg = m_settings->value("WaterfallAvg",5).toInt(); ui->waterfallAvgSpinBox->setValue(m_waterfallAvg); ui->widePlot->setWaterfallAvg(m_waterfallAvg); @@ -116,6 +118,7 @@ void WideGraph::saveSettings() //saveS m_settings->setValue ("PlotWidth", ui->widePlot->plotWidth ()); m_settings->setValue ("BinsPerPixel", ui->bppSpinBox->value ()); m_settings->setValue ("SmoothYellow", ui->smoSpinBox->value ()); + m_settings->setValue ("Percent2D",m_Percent2DScreen); m_settings->setValue ("WaterfallAvg", ui->waterfallAvgSpinBox->value ()); m_settings->setValue ("Current", ui->widePlot->current()); m_settings->setValue ("Cumulative", ui->widePlot->cumulative()); @@ -294,13 +297,11 @@ void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1) ui->widePlot->setLinearAvg(false); ui->widePlot->setReference(false); ui->smoSpinBox->setEnabled(false); - ui->labSmooth->setEnabled(false); if(arg1=="Current") ui->widePlot->setCurrent(true); if(arg1=="Cumulative") ui->widePlot->setCumulative(true); if(arg1=="Linear Avg") { ui->widePlot->setLinearAvg(true); ui->smoSpinBox->setEnabled(true); - ui->labSmooth->setEnabled(true); } if(arg1=="Reference") { ui->widePlot->setReference(true); @@ -441,3 +442,9 @@ void WideGraph::setWSPRtransmitted() { m_bHaveTransmitted=true; } + +void WideGraph::on_sbPercent2dPlot_valueChanged(int n) +{ + m_Percent2DScreen=n; + ui->widePlot->SetPercent2DScreen(n); +} diff --git a/widegraph.h b/widegraph.h index db71dabb7..ba05d813c 100644 --- a/widegraph.h +++ b/widegraph.h @@ -72,7 +72,8 @@ private slots: void on_zeroSlider_valueChanged(int value); void on_gain2dSlider_valueChanged(int value); void on_zero2dSlider_valueChanged(int value); - void on_smoSpinBox_valueChanged(int n); + void on_smoSpinBox_valueChanged(int n); + void on_sbPercent2dPlot_valueChanged(int n); private: void readPalette(); @@ -93,6 +94,7 @@ private: qint32 m_fMax; qint32 m_nSubMode; qint32 m_nsmo; + qint32 m_Percent2DScreen; bool m_lockTxFreq; bool m_bFlatten; diff --git a/widegraph.ui b/widegraph.ui index 99b7bc6bd..a55ec1a81 100644 --- a/widegraph.ui +++ b/widegraph.ui @@ -252,22 +252,6 @@ - - - - false - - - - 65 - 0 - - - - Smoothing - - - @@ -501,13 +485,13 @@ - 65 + 75 0 - 50 + 75 16777215 @@ -517,6 +501,12 @@ Qt::AlignCenter + + + + + Smooth + 1 @@ -540,6 +530,37 @@ + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + % + + + Spec + + + 100 + + + 5 + + + 30 + + +