From 2393e3eecd11820b0452f6f2bc42b02636987560 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Sat, 7 Jul 2012 15:49:41 +0000 Subject: [PATCH] Remove a lot of unused stuff from CPlotter, WideGraph. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2499 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- libm65/analytic.f90 | 25 +++++ libm65/db.f90 | 5 + mainwindow.cpp | 2 - plotter.cpp | 235 +++++--------------------------------------- plotter.h | 15 +-- widegraph.cpp | 45 +-------- widegraph.h | 1 - widegraph.ui | 16 ++- 8 files changed, 76 insertions(+), 268 deletions(-) create mode 100644 libm65/analytic.f90 create mode 100644 libm65/db.f90 diff --git a/libm65/analytic.f90 b/libm65/analytic.f90 new file mode 100644 index 000000000..d2153a908 --- /dev/null +++ b/libm65/analytic.f90 @@ -0,0 +1,25 @@ +subroutine analytic(d,npts,nfft,s,c) + +! Convert real data to analytic signal + + parameter (NMAX=512*1024) + real d(npts) + real s(NMAX) + complex c(NMAX) + + nh=nfft/2 + fac=2.0/nfft + c(1:npts)=fac*d(1:npts) + c(npts+1:nfft)=0. + call four2a(c,nfft,1,-1,1) !Forward c2c FFT + + do i=1,nh + s(i)=real(c(i))**2 + aimag(c(i))**2 + enddo + + c(1)=0.5*c(1) + c(nh+2:nfft)=0. + call four2a(c,nfft,1,1,1) !Inverse c2c FFT + + return +end subroutine analytic diff --git a/libm65/db.f90 b/libm65/db.f90 new file mode 100644 index 000000000..aa58f43f1 --- /dev/null +++ b/libm65/db.f90 @@ -0,0 +1,5 @@ +real function db(x) + db=-99.0 + if(x.gt.1.259e-10) db=10.0*log10(x) + return +end function db diff --git a/mainwindow.cpp b/mainwindow.cpp index a82203d2a..0b1d8f4cf 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -391,7 +391,6 @@ void MainWindow::dataSink(int k) static int ndiskdat; static int nwrite=0; static int k0=99999999; - static int n300z=9999; static float px=0.0; static float sq0=0.0; static float sqave=1000.0; @@ -497,7 +496,6 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog m_pttPort=dlg.m_pttPort; m_saveDir=dlg.m_saveDir; m_dxccPfx=dlg.m_dxccPfx; - g_pWideGraph->setFcal(m_fCal); m_nDevIn=dlg.m_nDevIn; m_paInDevice=dlg.m_paInDevice; m_nDevOut=dlg.m_nDevOut; diff --git a/plotter.cpp b/plotter.cpp index f1db0620d..a16d8de63 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -15,9 +15,6 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_NoSystemBackground, true); - m_StartFreq = 100; - m_nSpan=65; //Units: kHz - m_fSpan=(float)m_nSpan; m_hdivs = HORZ_DIVS; m_FreqUnits = 1; m_Running = false; @@ -28,7 +25,6 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor m_ScalePixmap = QPixmap(0,0); m_ZoomScalePixmap = QPixmap(0,0); m_Size = QSize(0,0); - m_fQSO = 125; m_line = 0; m_fSample = 96000; m_paintAllZoom = false; @@ -64,9 +60,9 @@ void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() m_ScalePixmap = QPixmap(w,30); m_ZoomScalePixmap = QPixmap(w,30); //(no change on resize...) m_ScalePixmap.fill(Qt::white); - m_ZoomScalePixmap.fill(Qt::yellow); +// m_ZoomScalePixmap.fill(Qt::yellow); + m_ZoomScalePixmap.fill(Qt::black); } - SetCenterFreq(-1); DrawOverlay(); } @@ -95,34 +91,12 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent() QRect source(0,0,w,30); painter.drawPixmap(target,m_ZoomScalePixmap,source); - float df=m_fSample/32768.0; - int x0=16384 + (0.001*(m_ZoomStartFreq+m_fCal)+m_fQSO-m_nkhz+1.27046) * \ - 1000.0/df + 0.5; - + int x0=0; QPainter painter2(&m_ZoomWaterfallPixmap); for(int i=0; i1.0e29) m_line=0; m_line++; - if(m_line == 15) { - UTCstr(); - painter1.setPen(m_ColorTbl[255]); - painter1.drawText(5,10,m_sutc); - } update(); //trigger a new paintEvent } -void CPlotter::UTCstr() -{ - /* - int ihr,imin; - if(datcom_.ndiskdat != 0) { - ihr=datcom_.nutc/100; - imin=datcom_.nutc%100; - } else { - qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; - imin=ms/60000; - ihr=imin/60; - imin=imin % 60; - } - sprintf(m_sutc,"%2.2d:%2.2d",ihr,imin); - */ -} - void CPlotter::DrawOverlay() //DrawOverlay() { if(m_WaterfallPixmap.isNull()) return; int w = m_WaterfallPixmap.width(); - int x,y; + int x; float pixperdiv; QRect rect0; @@ -251,17 +203,16 @@ void CPlotter::DrawOverlay() //DrawOverlay() painter0.setFont(Font); painter0.setPen(Qt::black); - m_binsPerPixel = m_nSpan * 32768.0/(w*0.001*m_fSample) + 0.5; - double FreqPerDiv=5.0; - double df = m_binsPerPixel*0.001*m_fSample/32768.0; - m_hdivs = w*df/FreqPerDiv + 0.9999; - m_fSpan = w*df; +// m_binsPerPixel = m_nSpan * 32768.0/(w*0.001*m_fSample) + 0.5; + double secPerDiv=5.0; + double dt=2048.0/48000.0; + m_hdivs = w*dt/secPerDiv; +// m_fSpan = w*dt; m_ScalePixmap.fill(Qt::white); painter0.drawRect(0, 0, w, 30); //draw tick marks on wideband (upper) scale - pixperdiv = FreqPerDiv/df; - qDebug() << w << m_hdivs << pixperdiv; + pixperdiv = secPerDiv/dt; for( int i=1; i0 and x0 100) { m_FreqUnits = 1; - FreqPerDiv = 200; + secPerDiv = 200; int w = m_WaterfallPixmap.width(); float df=m_fSample/32768.0; StartFreq = -w*df/2; - int n=StartFreq/FreqPerDiv; + int n=StartFreq/secPerDiv; StartFreq=n*200; m_ZoomStartFreq = (int)StartFreq; } @@ -389,7 +272,7 @@ void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs for(int i=0; i<=m_hdivs; i++) { freq = StartFreq/(float)m_FreqUnits; m_HDivText[i].setNum((int)freq); - StartFreq += FreqPerDiv; + StartFreq += secPerDiv; } return; } @@ -398,7 +281,7 @@ void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs for(int i=0; i<=m_hdivs; i++) { freq = StartFreq/(float)m_FreqUnits; m_HDivText[i].setNum(freq,'f', numfractdigits); - StartFreq += FreqPerDiv; + StartFreq += secPerDiv; } //now find the division text with the longest non-zero digit //to the right of the decimal point. @@ -414,28 +297,28 @@ void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs max = j-dp; } //truncate all strings to maximum fractional length - StartFreq = m_CenterFreq - 0.5*m_fSpan; + StartFreq = 0; for( i=0; i<=m_hdivs; i++) { freq = (float)StartFreq/(float)m_FreqUnits; m_HDivText[i].setNum(freq,'f', max); - StartFreq += FreqPerDiv; + StartFreq += secPerDiv; } } -int CPlotter::XfromFreq(float f) //XfromFreq() +int CPlotter::xFromTime(float t) //xFromTime() { float w = m_WaterfallPixmap.width(); - int x = (int) w * (f - m_StartFreq)/m_fSpan; + int x = (int) w * t/30.0; if(x<0 ) return 0; if(x>(int)w) return m_WaterfallPixmap.width(); return x; } -float CPlotter::FreqfromX(int x) //FreqfromX() +float CPlotter::timeFromX(int x) //timeFromX() { float w = m_WaterfallPixmap.width(); - float f =m_CenterFreq - 0.5*m_fSpan + m_fSpan * x/w; - return f; + float t = 30.0 * x/w; + return t; } void CPlotter::SetRunningState(bool running) //SetRunningState() @@ -463,39 +346,6 @@ int CPlotter::getPlotGain() //getPlotGain() return m_plotGain; } -void CPlotter::SetCenterFreq(int f) //setCenterFreq() -{ -// f is the integer kHz portion of cfreq, from Linrad packets - if(f<0) f=m_nkhz; - int ns = (f+m_FreqOffset-0.5*m_fSpan)/5.0 + 0.5; - double fs = 5*ns; - m_CenterFreq = fs + 0.5*m_fSpan; -} - -qint64 CPlotter::centerFreq() //centerFreq() -{ - return m_CenterFreq; -} - -void CPlotter::SetStartFreq(quint64 f) //SetStartFreq() -{ - m_StartFreq=f; -// resizeEvent(NULL); - DrawOverlay(); -} - -qint64 CPlotter::startFreq() //startFreq() -{ - return m_StartFreq; -} - -void CPlotter::SetFreqOffset(quint64 f) //SetFreqOffset() -{ - m_FreqOffset=f; - DrawOverlay(); -} - -qint64 CPlotter::freqOffset() {return m_FreqOffset;} //freqOffset() int CPlotter::plotWidth(){return m_WaterfallPixmap.width();} void CPlotter::UpdateOverlay() {DrawOverlay();} void CPlotter::setDataFromDisk(bool b) {m_dataFromDisk=b;} @@ -510,32 +360,11 @@ void CPlotter::setBinsPerPixel(int n) {m_binsPerPixel = n;} //set nbpp int CPlotter::binsPerPixel(){return m_binsPerPixel;} //get nbpp -void CPlotter::setFQSO(int x, bool bf) //setFQSO() -{ - if(bf) { - m_fQSO=x; // x is freq in kHz - } else { - if(x<0) x=0; // x is pixel number - if(x>m_Size.width()) x=m_Size.width(); - m_fQSO = int(FreqfromX(x)+0.5); - m_xClick=x; - } - DrawOverlay(); - update(); -} - -void CPlotter::setFcal(int n) //setFcal() -{ - m_fCal=n; -} - void CPlotter::setNkhz(int n) //setNkhz() { m_nkhz=n; } -int CPlotter::fQSO() {return m_fQSO;} //get fQSO - int CPlotter::DF() {return m_DF;} // get DF void CPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent @@ -544,7 +373,7 @@ void CPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent int x=event->x(); int y=event->y(); if(y < h+30) { - setFQSO(x,false); // Wideband waterfall +// setFQSO(x,false); // Wideband waterfall } else { m_DF=int(m_ZoomStartFreq + x*m_fSample/32768.0); // Zoomed waterfall DrawOverlay(); @@ -559,7 +388,7 @@ void CPlotter::mouseDoubleClickEvent(QMouseEvent *event) //mouse2click int y=event->y(); if(y < h+30) { m_DF=0; - setFQSO(x,false); +// setFQSO(x,false); emit freezeDecode1(2); //### ??? } else { float f = m_ZoomStartFreq + x*m_fSample/32768.0; @@ -596,11 +425,6 @@ int CPlotter::autoZero() //autoZero() return m_plotZero; } -void CPlotter::setNSpan(int n) //setNSpan() -{ - m_nSpan=n; -} - void CPlotter::setPalette(QString palette) //setPalette() { if(palette=="Linrad") { @@ -705,8 +529,3 @@ void CPlotter::set2Dspec(bool b) DrawOverlay(); //Redraw scales and ticks update(); //trigger a new paintEvent} } - -double CPlotter::fGreen() -{ - return m_fGreen; -} diff --git a/plotter.h b/plotter.h index 4e3763a32..50235180c 100644 --- a/plotter.h +++ b/plotter.h @@ -28,13 +28,9 @@ public: QColor m_ColorTbl[256]; int m_plotZero; int m_plotGain; - float m_fSpan; - qint32 m_nSpan; qint32 m_binsPerPixel; - qint32 m_fQSO; qint32 m_DF; qint32 m_tol; - qint32 m_fCal; void draw(float sw[], int i0, float splot[]); //Update the waterfalls void SetRunningState(bool running); @@ -55,7 +51,6 @@ public: void setTol(int n); void setBinsPerPixel(int n); int binsPerPixel(); - void setFQSO(int n, bool bf); void setFcal(int n); void setNkhz(int n); void DrawOverlay(); @@ -66,7 +61,6 @@ public: void setFsample(int n); void setMode65(int n); void set2Dspec(bool b); - double fGreen(); signals: void freezeDecode0(int n); @@ -79,10 +73,9 @@ protected: private: - void MakeFrequencyStrs(); - void UTCstr(); - int XfromFreq(float f); - float FreqfromX(int x); + void MakeTimeStrs(); + int xFromTime(float f); + float timeFromX(int x); qint64 RoundFreq(qint64 freq, int resolution); QPixmap m_WaterfallPixmap; @@ -99,8 +92,6 @@ private: bool m_2Dspec; bool m_paintAllZoom; double m_CenterFreq; - double m_fGreen; - qint64 m_StartFreq; qint64 m_ZoomStartFreq; qint64 m_FreqOffset; qint32 m_dBStepSize; diff --git a/widegraph.cpp b/widegraph.cpp index a80b07fd6..8e3123bde 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -31,7 +31,7 @@ WideGraph::WideGraph(QWidget *parent) : int n = settings.value("FreqSpan",60).toInt(); int w = settings.value("PlotWidth",1000).toInt(); ui->freqSpanSpinBox->setValue(n); - ui->widePlot->setNSpan(n); +// ui->widePlot->setNSpan(n); int nbpp = n * 32768.0/(w*96.0) + 0.5; ui->widePlot->setBinsPerPixel(nbpp); m_waterfallAvg = settings.value("WaterfallAvg",10).toInt(); @@ -59,15 +59,13 @@ void WideGraph::saveSettings() settings.setValue("PlotWidth",ui->widePlot->plotWidth()); settings.setValue("FreqSpan",ui->freqSpanSpinBox->value()); settings.setValue("WaterfallAvg",ui->waterfallAvgSpinBox->value()); - settings.setValue("FreqOffset",ui->widePlot->freqOffset()); - settings.setValue("ForceCenterFreqBool",m_bForceCenterFreq); - settings.setValue("ForceCenterFreqMHz",m_dForceCenterFreq); settings.endGroup(); } void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, uchar lstrong[]) { + /* static float splot[NFFT]; float swide[2048]; float smax; @@ -77,6 +75,7 @@ void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, static int nkhz0=-999; static int n60z=0; + df = m_fSample/32768.0; if(nkhz != nkhz0) { ui->widePlot->setNkhz(nkhz); //Why do we need both? @@ -131,17 +130,15 @@ void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, n60z=n60; ui->widePlot->draw(swide,i0,splot); } + */ } void WideGraph::on_freqSpanSpinBox_valueChanged(int n) { - ui->widePlot->setNSpan(n); +// ui->widePlot->setNSpan(n); int w = ui->widePlot->plotWidth(); int nbpp = n * 32768.0/(w*96.0) + 0.5; if(nbpp < 1) nbpp=1; - if(w > 0) { - ui->widePlot->setBinsPerPixel(nbpp); - } } void WideGraph::on_waterfallAvgSpinBox_valueChanged(int n) @@ -174,26 +171,6 @@ void WideGraph::keyPressEvent(QKeyEvent *e) } } -int WideGraph::QSOfreq() -{ - return ui->widePlot->fQSO(); -} - -int WideGraph::nSpan() -{ - return ui->widePlot->m_nSpan; -} - -float WideGraph::fSpan() -{ - return ui->widePlot->m_fSpan; -} - -int WideGraph::nStartFreq() -{ - return ui->widePlot->startFreq(); -} - void WideGraph::wideFreezeDecode(int n) { emit freezeDecode2(n); @@ -218,13 +195,6 @@ void WideGraph::setDF(int n) ui->widePlot->update(); } -void WideGraph::setFcal(int n) -{ - m_fCal=n; - ui->widePlot->setFcal(n); -} - - int WideGraph::DF() { return ui->widePlot->m_DF; @@ -245,8 +215,3 @@ void WideGraph::on_cbSpec2d_toggled(bool b) { ui->widePlot->set2Dspec(b); } - -double WideGraph::fGreen() -{ - return ui->widePlot->fGreen(); -} diff --git a/widegraph.h b/widegraph.h index 21fac07cf..9ff10c4d1 100644 --- a/widegraph.h +++ b/widegraph.h @@ -33,7 +33,6 @@ public: void setFcal(int n); void setPalette(QString palette); void setMode65(int n); - double fGreen(); qint32 m_qsoFreq; diff --git a/widegraph.ui b/widegraph.ui index eb5a1dd8a..92c6c1716 100644 --- a/widegraph.ui +++ b/widegraph.ui @@ -6,10 +6,16 @@ 0 0 - 780 - 326 + 724 + 313 + + + 0 + 0 + + Dialog @@ -22,15 +28,15 @@ true - + 0 0 - 400 - 200 + 704 + 250