diff --git a/lib/plotsave.f90 b/lib/plotsave.f90 index ef5da4c09..8db68f97d 100644 --- a/lib/plotsave.f90 +++ b/lib/plotsave.f90 @@ -1,43 +1,29 @@ -subroutine plotsave(splot,ka,nbpp,irow,jz,swide) +subroutine plotsave(swide,nw,nh,irow) parameter (NSMAX=6827,NYMAX=64) - real splot(NSMAX) - real spsave(NSMAX,NYMAX) - real swide(jz) - real s(NSMAX),tmp(NSMAX) - data ncall/0/ - save ncall,spsave + real, dimension(:,:), allocatable :: sw + real swide(0:nw-1) + data nw0/-1/,nh0/-1/ + save nw0,nh0,sw + + if(nw.ne.nw0 .or. nh.ne.nh0) then + if(nw0.ne.-1) deallocate(sw) + allocate(sw(0:nw-1,0:nh-1)) + sw=0. + nw0=nw + nh0=nh + endif df=12000.0/16384 if(irow.lt.0) then -! Save a new row of data - ncall=ncall+1 - k=mod(ncall-1,NYMAX) + 1 - spsave(1:NSMAX,k)=splot - rewind 61 - do i=1,NSMAX - write(61,3061) i,splot(i),ncall -3061 format(i8,f12.3,i8) +! Push a new row of data into sw + do j=nh-1,1,-1 + sw(0:nw-1,j)=sw(0:nw-1,j-1) enddo + sw(0:nw-1,0)=swide else -! Process and return the saved "irow" as swide(), for a waterfall replot. - k=mod(NYMAX+ncall-1-irow,NYMAX) + 1 - if(nbpp.eq.1) then - swide=spsave(1:jz,k) - else - s=spsave(1:NSMAX,k) - call smo(s,NSMAX,tmp,nbpp) - k=ka - do j=1,jz - smax=0. - do i=1,nbpp - k=k+1 - if(k.lt.1 .or. k.gt.NSMAX) exit - smax=max(smax,s(k)) - enddo - swide(j)=smax - enddo - endif +! Return the saved "irow" as swide(), for a waterfall replot. + swide=sw(0:nw-1,irow) endif return diff --git a/plotter.cpp b/plotter.cpp index 54a9e9b97..4d763f96a 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -43,6 +43,7 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor setAutoFillBackground(false); setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_NoSystemBackground, true); + m_bReplot=false; // contextual pop up menu setContextMenuPolicy (Qt::CustomContextMenu); @@ -83,6 +84,7 @@ void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() if(m_bReference) m_h2=m_h-30; if(m_h2<1) m_h2=1; m_h1=m_h-m_h2; +// m_line=0; m_2DPixmap = QPixmap(m_Size.width(), m_h2); m_2DPixmap.fill(Qt::black); m_WaterfallPixmap = QPixmap(m_Size.width(), m_h1); @@ -116,13 +118,12 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) double fac = sqrt(m_binsPerPixel*m_waterfallAvg/15.0); double gain = fac*pow(10.0,0.02*m_plotGain); double gain2d = pow(10.0,0.02*(m_plot2dGain)); - bool bReplot=swide[MAX_SCREENSIZE-1] == -99.0; if(m_bReference != m_bReference0) resizeEvent(NULL); m_bReference0=m_bReference; //move current data down one line (must do this before attaching a QPainter object) - if(bScroll and !bReplot) m_WaterfallPixmap.scroll(0,1,0,0,m_w,m_h1); + if(bScroll and !m_bReplot) m_WaterfallPixmap.scroll(0,1,0,0,m_w,m_h1); QPainter painter1(&m_WaterfallPixmap); m_2DPixmap = m_OverlayPixmap.copy(0,0,m_w,m_h2); QPainter painter2D(&m_2DPixmap); @@ -149,13 +150,17 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) if(bScroll and swide[0]<1.e29) { flat4_(swide,&iz,&m_Flatten); - if(!bReplot) flat4_(&dec_data.savg[j0],&jz,&m_Flatten); + if(!m_bReplot) flat4_(&dec_data.savg[j0],&jz,&m_Flatten); } ymin=1.e30; if(swide[0]>1.e29 and swide[0]< 1.5e30) painter1.setPen(Qt::green); if(swide[0]>1.4e30) painter1.setPen(Qt::yellow); - if(!bReplot) m_j=0; + if(!m_bReplot) { + m_j=0; + int irow=-1; + plotsave_(swide,&m_w,&m_h1,&irow); + } for(int i=0; i g_ColorTbl; extern "C" { void flat4_(float swide[], int* iz, int* nflatten); + void plotsave_(float swide[], int* m_w , int* m_h1, int* irow); } #endif // PLOTTER_H diff --git a/widegraph.cpp b/widegraph.cpp index adf2c5055..8ab0de518 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -198,9 +198,6 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat } m_ntr0=ntr; ui->widePlot->draw(swide,true,false); - int irow=-1; - int ka=0; - plotsave_(splot,&ka,&nbpp,&irow,&jz,swide); } } @@ -465,15 +462,7 @@ void WideGraph::on_gainSlider_valueChanged(int value) //Gain void WideGraph::replot() { - if(!ui->widePlot->scaleOK()) return; - int nbpp = ui->widePlot->binsPerPixel(); - float splot=0.0; - int ka=int(ui->widePlot->startFreq()/0.732422 + 0.5) - 1; - for(int irow=0; irow<64; irow++) { - plotsave_(&splot,&ka,&nbpp,&irow,&m_jz,swide); - swide[MAX_SCREENSIZE-1]=-99.0; - ui->widePlot->replot(swide,true,false,irow); - } + if(ui->widePlot->scaleOK()) ui->widePlot->replot(); } void WideGraph::on_zeroSlider_valueChanged(int value) //Zero diff --git a/widegraph.h b/widegraph.h index 4533df1fc..f5e57f8dc 100644 --- a/widegraph.h +++ b/widegraph.h @@ -116,9 +116,4 @@ private: QString m_waterfallPalette; }; -extern "C" { - void plotsave_(float splot[], int* ka, int* nbpp, int* irow, int* jz, float swide[]); -} - - #endif // WIDEGRAPH_H