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
This commit is contained in:
Joe Taylor 2012-07-07 15:49:41 +00:00
parent e93c08dfd9
commit 2393e3eecd
8 changed files with 76 additions and 268 deletions

25
libm65/analytic.f90 Normal file
View File

@ -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

5
libm65/db.f90 Normal file
View File

@ -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

View File

@ -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;

View File

@ -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; i<w; i++) { //Paint the top row
painter2.setPen(m_ColorTbl[m_zwf[x0+i]]);
painter2.drawPoint(i,0);
}
if(m_paintAllZoom or (x0 != x00 and x00 != -99)) {
// If new fQSO, paint all rows
int k=x0;
for(int j=1; j<h; j++) {
k += 32768;
for(int i=0; i<w; i++) {
painter2.setPen(m_ColorTbl[m_zwf[i+k]]);
painter2.drawPoint(i,j);
}
if(j == 15) {
painter2.setPen(m_ColorTbl[255]);
painter2.drawText(5,10,m_sutc);
}
}
} else if(m_line == 15) {
painter2.setPen(m_ColorTbl[255]);
UTCstr();
painter2.drawText(5,10,m_sutc);
}
m_paintAllZoom=false;
x00=x0;
@ -207,36 +181,14 @@ void CPlotter::draw(float s[], int i0, float splot[]) //dr
if(s[0]>1.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; i<m_hdivs; i++) { //major ticks
x = (int)( (float)i*pixperdiv );
painter0.drawLine(x,18,x,30);
@ -272,7 +223,7 @@ void CPlotter::DrawOverlay() //DrawOverlay()
}
//draw frequency values
MakeFrequencyStrs();
MakeTimeStrs();
for( int i=0; i<=m_hdivs; i++) {
if(0==i) {
//left justify the leftmost text
@ -295,90 +246,22 @@ void CPlotter::DrawOverlay() //DrawOverlay()
m_HDivText[i]);
}
}
if(m_2Dspec) {
QPen pen0(Qt::green, 3); //Mark Cal Freq with green tick
painter0.setPen(pen0);
x = m_xClick;
painter0.drawLine(x,15,x,30);
int x0=(16384-m_i0)/m_binsPerPixel;
m_fGreen=(x-x0)*df;
x0 += (x0-x);
QPen pen3(Qt::red, 3);
painter0.setPen(pen3);
if(x0>0 and x0<w) painter0.drawLine(x0,15,x0,30);
} else {
QPen pen0(Qt::green, 3); //Mark fQSO with green tick
painter0.setPen(pen0);
x = XfromFreq(float(fQSO()));
painter0.drawLine(x,15,x,30);
}
// Now make the zoomed scale, using m_ZoomScalePixmap and painter3
QRect rect1;
QPainter painter3(&m_ZoomScalePixmap);
painter3.initFrom(this);
painter3.setFont(Font);
painter3.setPen(Qt::black);
FreqPerDiv=0.2;
df = 0.001*m_fSample/32768.0;
m_hdivs = 32768*df/FreqPerDiv + 0.9999;
int nlabs=df*w/0.2 + 1.0;
m_ZoomScalePixmap.fill(Qt::white);
painter3.drawRect(0, 0, w, 30);
pixperdiv = FreqPerDiv/df;
for( int i=0; i<10*nlabs; i++) {
x = i*pixperdiv/10;
y=24;
if ((i%5) == 0) y=18;
painter3.drawLine(x,y,x,30);
}
//draw frequency values
MakeFrequencyStrs();
for( int i=0; i<=nlabs; i++) {
x = (int)( (float)i*pixperdiv - pixperdiv/2);
rect1.setRect(x,0, (int)pixperdiv, 20);
painter3.drawText(rect1, Qt::AlignHCenter|Qt::AlignVCenter,
m_HDivText[i]);
}
df=m_fSample/32768.0;
x = (m_DF + m_mode65*66*11025.0/4096.0 - m_ZoomStartFreq)/df;
QPen pen2(Qt::red, 3); //Mark top JT65B tone with red tick
painter3.setPen(pen2);
painter3.drawLine(x,15,x,30);
x = (m_DF - m_ZoomStartFreq)/df;
QPen pen1(Qt::green, 3); //Mark DF with a green tick
painter3.setPen(pen1);
painter3.drawLine(x,15,x,30);
for(int i=2; i<5; i++) { //Mark the shorthand freqs
x = (m_DF + m_mode65*10*i*11025.0/4096.0 - m_ZoomStartFreq)/df;
painter3.drawLine(x,20,x,30);
}
int x1=(m_DF - m_tol - m_ZoomStartFreq)/df;
int x2=(m_DF + m_tol - m_ZoomStartFreq)/df;
pen1.setWidth(6);
painter3.drawLine(x1,28,x2,28);
}
void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs
void CPlotter::MakeTimeStrs() //MakeTimeStrs
{
float StartFreq = m_StartFreq;
float StartFreq = 0.0;
float freq;
int i,j;
int FreqPerDiv=5;
int secPerDiv=5;
if(m_hdivs > 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;
}

View File

@ -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;

View File

@ -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();
}

View File

@ -33,7 +33,6 @@ public:
void setFcal(int n);
void setPalette(QString palette);
void setMode65(int n);
double fGreen();
qint32 m_qsoFreq;

View File

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>780</width>
<height>326</height>
<width>724</width>
<height>313</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
@ -22,15 +28,15 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>200</height>
<width>704</width>
<height>250</height>
</size>
</property>
<property name="frameShape">