Working on wide graph displays.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2609 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-09-29 13:02:19 +00:00
parent d9df62b9e9
commit 2232d88405
8 changed files with 42 additions and 131 deletions

View File

@ -1,7 +1,7 @@
#ifndef COMMONS_H #ifndef COMMONS_H
#define COMMONS_H #define COMMONS_H
#define NSMAX 15750 #define NSMAX 10000
extern "C" { extern "C" {

View File

@ -12,7 +12,7 @@ subroutine symspecx(k,nsps,ndiskdat,nb,nbslider,pxdb,s,nkhz,ihsym, &
! nzap number of samples zero'ed by noise blanker ! nzap number of samples zero'ed by noise blanker
parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes
parameter (NSMAX=15750) !Max length of saved spectra parameter (NSMAX=10000) !Max length of saved spectra
parameter (MAXFFT=262144) !Max length of FFTs parameter (MAXFFT=262144) !Max length of FFTs
integer*2 id2 integer*2 id2
real*8 ts,hsym real*8 ts,hsym
@ -66,20 +66,19 @@ subroutine symspecx(k,nsps,ndiskdat,nb,nbslider,pxdb,s,nkhz,ihsym, &
ihsym=ihsym+1 ihsym=ihsym+1
call four2a(x,nfft,1,-1,0) !Forward FFT of symbol length call four2a(x,nfft,1,-1,0) !Forward FFT of symbol length
df=12000.0/nfft df=12000.0/nfft
nzh=min(nint(500.0/df),2200) i0=nint(1000.0/df)
nz=2*nzh nz=min(NSMAX,nfft/2)
i0=nint(1500.0/df) - nzh ! rewind 71
rewind 71
do i=1,nz do i=1,nz
sx=real(cx(i0+i))**2 + aimag(cx(i0+i))**2 sx=real(cx(i0+i))**2 + aimag(cx(i0+i))**2
sx=1.e-8*sx sx=1.e-8*sx
s(i)=sx s(i)=sx
savg(i)=savg(i) + sx savg(i)=savg(i) + sx
if(ihsym.le.184) ss(ihsym,i)=sx if(ihsym.le.184) ss(ihsym,i)=sx
write(71,3001) (i0+i-1)*df,savg(i),db(savg(i)) ! write(71,3001) (i0+i-1)*df,savg(i),db(savg(i))
3001 format(f12.6,2f12.3) !3001 format(f12.6,2f12.3)
enddo enddo
flush(71) ! flush(71)
nkhz=100 nkhz=100

View File

@ -298,7 +298,7 @@ void MainWindow::readSettings()
//-------------------------------------------------------------- dataSink() //-------------------------------------------------------------- dataSink()
void MainWindow::dataSink(int k) void MainWindow::dataSink(int k)
{ {
static float s[NFFT],splot[NFFT]; static float s[NSMAX],splot[NSMAX];
static int n=0; static int n=0;
static int ihsym=0; static int ihsym=0;
static int nzap=0; static int nzap=0;
@ -336,16 +336,16 @@ void MainWindow::dataSink(int k)
//Average over specified number of spectra //Average over specified number of spectra
if (n==0) { if (n==0) {
for (int i=0; i<NFFT; i++) for (int i=0; i<NSMAX; i++)
splot[i]=s[i]; splot[i]=s[i];
} else { } else {
for (int i=0; i<NFFT; i++) for (int i=0; i<NSMAX; i++)
splot[i] += s[i]; splot[i] += s[i];
} }
n++; n++;
if (n>=m_waterfallAvg) { if (n>=m_waterfallAvg) {
for (int i=0; i<NFFT; i++) { for (int i=0; i<NSMAX; i++) {
splot[i] /= n; //Normalize the average splot[i] /= n; //Normalize the average
} }
@ -353,7 +353,7 @@ void MainWindow::dataSink(int k)
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int ntr = (ms/1000) % m_TRperiod; int ntr = (ms/1000) % m_TRperiod;
if((m_diskData && ihsym <= m_waterfallAvg) || (!m_diskData && ntr<ntr0)) { if((m_diskData && ihsym <= m_waterfallAvg) || (!m_diskData && ntr<ntr0)) {
for (int i=0; i<NFFT; i++) { for (int i=0; i<NSMAX; i++) {
splot[i] = 1.e30; splot[i] = 1.e30;
} }
} }

View File

@ -11,7 +11,6 @@
#include "sleep.h" #include "sleep.h"
#define NFFT 32768 #define NFFT 32768
#define NSMAX 5760000
//--------------------------------------------------------------- MainWindow //--------------------------------------------------------------- MainWindow
namespace Ui { namespace Ui {

View File

@ -83,62 +83,12 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
int h = (m_Size.height()-60)/2; int h = (m_Size.height()-60)/2;
painter.drawPixmap(0,0,m_ScalePixmap); painter.drawPixmap(0,0,m_ScalePixmap);
painter.drawPixmap(0,30,m_WaterfallPixmap); painter.drawPixmap(0,30,m_WaterfallPixmap);
if(m_2Dspec) { painter.drawPixmap(0,h+30,m_ScalePixmap);
painter.drawPixmap(0,h+30,m_ScalePixmap); painter.drawPixmap(0,h+60,m_2DPixmap);
painter.drawPixmap(0,h+60,m_2DPixmap);
m_paintEventBusy=false;
return;
}
painter.drawPixmap(0,h+30,m_ZoomScalePixmap);
painter.drawPixmap(0,h+60,m_ZoomWaterfallPixmap);
QRect target(0,h+30,w,30); // (x,y,width,height)
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;
float df=12000.0/m_nsps;
int x0=0; //### TEMP ###
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;
if(x0 != x00 and x00 != -99) {
for(int i=0; i<w; i++) {
painter2.setPen(m_ColorTbl[m_zwf[i+k]]);
painter2.drawPoint(i,j);
}
}
if(j == 13 and x0 == x00) {
painter2.setPen(m_ColorTbl[255]);
painter2.drawText(5,10,m_sutc);
}
}
} else if(m_line == 13) {
painter2.setPen(m_ColorTbl[255]);
UTCstr();
painter2.drawText(5,10,m_sutc);
}
m_paintAllZoom=false;
x00=x0;
QRect target2(0,h+60,w,h); // (x,y,width,height)
QRect source2(0,0,w,h);
painter.drawPixmap(target2,m_ZoomWaterfallPixmap,source2);
m_paintEventBusy=false; m_paintEventBusy=false;
} }
void CPlotter::draw(float swide[], int i0, float splot[]) //draw() void CPlotter::draw(float swide[], int i0, float splot[]) //draw()
{ {
int i,j,w,h; int i,j,w,h;
float y; float y;
@ -183,22 +133,20 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw
m_hist1[y1]++; m_hist1[y1]++;
painter1.setPen(m_ColorTbl[y1]); painter1.setPen(m_ColorTbl[y1]);
painter1.drawPoint(i,0); painter1.drawPoint(i,0);
if(m_2Dspec) { int y2 = gain*(y + 34 -m_plotZero);
int y2 = gain*(y + 34 -m_plotZero); if (y2<0) y2=0;
if (y2<0) y2=0; if (y2>254) y2=254;
if (y2>254) y2=254; if (swide[i]>1.e29) y2=255;
if (swide[i]>1.e29) y2=255; if(strong != strong0 or i==w-1) {
if(strong != strong0 or i==w-1) { painter2D.drawPolyline(LineBuf,j);
painter2D.drawPolyline(LineBuf,j); j=0;
j=0; strong0=strong;
strong0=strong; if(strong0) painter2D.setPen(Qt::red);
if(strong0) painter2D.setPen(Qt::red); if(!strong0) painter2D.setPen(Qt::green);
if(!strong0) painter2D.setPen(Qt::green);
}
LineBuf[j].setX(i);
LineBuf[j].setY(h-y2);
j++;
} }
LineBuf[j].setX(i);
LineBuf[j].setY(h-y2);
j++;
} }
for(i=0; i<NSMAX; i++) { for(i=0; i<NSMAX; i++) {
@ -308,23 +256,16 @@ void CPlotter::DrawOverlay() //DrawOverlay()
} }
if(m_2Dspec) { QPen pen0(Qt::green, 3); //Mark Cal Freq with green tick
QPen pen0(Qt::green, 3); //Mark Cal Freq with green tick painter0.setPen(pen0);
painter0.setPen(pen0); x = m_xClick;
x = m_xClick; painter0.drawLine(x,15,x,30);
painter0.drawLine(x,15,x,30); int x0=(16384-m_i0)/m_binsPerPixel;
int x0=(16384-m_i0)/m_binsPerPixel; m_fGreen=(x-x0)*df;
m_fGreen=(x-x0)*df; x0 += (x0-x);
x0 += (x0-x); QPen pen3(Qt::red, 3);
QPen pen3(Qt::red, 3); painter0.setPen(pen3);
painter0.setPen(pen3); if(x0>0 and x0<w) painter0.drawLine(x0,15,x0,30);
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 // Now make the zoomed scale, using m_ZoomScalePixmap and painter3
QRect rect1; QRect rect1;
@ -669,7 +610,7 @@ void CPlotter::setMode65(int n)
void CPlotter::set2Dspec(bool b) void CPlotter::set2Dspec(bool b)
{ {
m_2Dspec=b; // m_2Dspec=b;
m_paintAllZoom=!b; m_paintAllZoom=!b;
DrawOverlay(); //Redraw scales and ticks DrawOverlay(); //Redraw scales and ticks
update(); //trigger a new paintEvent} update(); //trigger a new paintEvent}

View File

@ -2,7 +2,7 @@
#include <stdexcept> #include <stdexcept>
#define FRAMES_PER_BUFFER 1024 #define FRAMES_PER_BUFFER 1024
#define NSMAX 15750 #define NSMAX 10000
extern "C" { extern "C" {
#include <portaudio.h> #include <portaudio.h>

View File

@ -1,7 +1,7 @@
#include "widegraph.h" #include "widegraph.h"
#include "ui_widegraph.h" #include "ui_widegraph.h"
#define NSMAX 15750 #define NSMAX 10000
WideGraph::WideGraph(QWidget *parent) : WideGraph::WideGraph(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -283,11 +283,6 @@ void WideGraph::initIQplus()
{ {
} }
void WideGraph::on_cbSpec2d_toggled(bool b)
{
ui->widePlot->set2Dspec(b);
}
double WideGraph::fGreen() double WideGraph::fGreen()
{ {
return ui->widePlot->fGreen(); return ui->widePlot->fGreen();

View File

@ -324,29 +324,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbSpec2d">
<property name="text">
<string>2D Spectrum</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">