From 6d2e42914415a6b76db7bff75f3213864a9aa401 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Sun, 30 Sep 2012 01:03:18 +0000 Subject: [PATCH] Now have gradient fill in 2D spectrum, and 30% height. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2621 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 2 +- plotter.cpp | 127 +++++++++++++++++++++++++++++++++++-------------- plotter.h | 10 +++- 3 files changed, 101 insertions(+), 38 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 6c1db481a..b4b246613 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,4 @@ -//---------------------------------------------------------------- MainWindow +//--------------------------------------------------------------- MainWindow #include "mainwindow.h" #include "ui_mainwindow.h" #include "devsetup.h" diff --git a/plotter.cpp b/plotter.cpp index 7266c712d..75912f814 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -25,12 +25,14 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor m_WaterfallPixmap = QPixmap(0,0); m_2DPixmap = QPixmap(0,0); m_ScalePixmap = QPixmap(0,0); - m_LowerScalePixmap = QPixmap(0,0); + m_OverlayPixmap = QPixmap(0,0); m_Size = QSize(0,0); m_fQSO = 125; m_line = 0; m_fSample = 12000; m_nsps=6912; + m_dBStepSize=10; + m_Percent2DScreen = 30; //percent of screen used for 2D display } CPlotter::~CPlotter() { } // Destructor @@ -48,19 +50,23 @@ QSize CPlotter::sizeHint() const void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() { if(!size().isValid()) return; - if( m_Size != size() ) { - //if changed, resize pixmaps to new screensize + if( m_Size != size() ) { //if changed, resize pixmaps to new screensize m_Size = size(); - int w = m_Size.width(); - int h = (m_Size.height()-60)/2; - m_WaterfallPixmap = QPixmap(w,h); - m_2DPixmap = QPixmap(w,h); + m_w = m_Size.width(); + m_h = m_Size.height(); + m_h1 = (100-m_Percent2DScreen)*(m_Size.height()-30)/100; + m_h2 = (m_Percent2DScreen)*(m_Size.height()-30)/100; + + 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(w,30); - m_LowerScalePixmap = QPixmap(w,30); //(no change on resize...) + m_ScalePixmap = QPixmap(m_w,30); m_ScalePixmap.fill(Qt::white); - m_LowerScalePixmap.fill(Qt::yellow); } DrawOverlay(); } @@ -72,44 +78,37 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent() if(m_paintEventBusy) return; m_paintEventBusy=true; QPainter painter(this); - int w = m_Size.width(); - int h = (m_Size.height()-60)/2; painter.drawPixmap(0,0,m_ScalePixmap); painter.drawPixmap(0,30,m_WaterfallPixmap); - painter.drawPixmap(0,h+30,m_ScalePixmap); - painter.drawPixmap(0,h+60,m_2DPixmap); + painter.drawPixmap(0,m_h1,m_2DPixmap); m_paintEventBusy=false; } void CPlotter::draw(float swide[], int i0, float splot[]) //draw() { - int i,j,w,h; + int j; float y; m_i0=i0; - w = m_WaterfallPixmap.width(); - h = m_WaterfallPixmap.height(); double gain = pow(10.0,0.05*(m_plotGain+7)); - //move current data down one line - //(must do this before attaching a QPainter object) - m_WaterfallPixmap.scroll(0,1,0,0,w,h); +//move current data down one line (must do this before attaching a QPainter object) + 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); - for(i=0; i<256; i++) { //Zero the histograms + for(int i=0; i<256; i++) { //Zero the histograms m_hist1[i]=0; } painter2D.setPen(Qt::green); - QRect tmp(0,0,w,h); - painter2D.fillRect(tmp,Qt::black); QPoint LineBuf[MAX_SCREENSIZE]; j=0; bool strong0=false; bool strong=false; - for(i=0; i254) y2=254; if (swide[i]>1.e29) y2=255; - if(strong != strong0 or i==w-1) { + if(strong != strong0 or i==m_w-1) { painter2D.drawPolyline(LineBuf,j); j=0; strong0=strong; @@ -135,7 +134,7 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw() if(!strong0) painter2D.setPen(Qt::green); } LineBuf[j].setX(i); - LineBuf[j].setY(h-y2); + LineBuf[j].setY(m_h-y2-320); j++; } @@ -168,12 +167,68 @@ void CPlotter::UTCstr() void CPlotter::DrawOverlay() //DrawOverlay() { + if(m_OverlayPixmap.isNull()) return; if(m_WaterfallPixmap.isNull()) return; int w = m_WaterfallPixmap.width(); int x,y; int nHzDiv[11]={0,50,100,200,200,200,500,500,500,500,500}; float pixperdiv; +//### + QRect rect; + QPainter painter(&m_OverlayPixmap); + painter.initFrom(this); + QLinearGradient gradient(0, 0, 0 ,m_h2); //fill background with gradient + gradient.setColorAt(1, Qt::black); + gradient.setColorAt(0, Qt::darkBlue); + painter.setBrush(gradient); + painter.drawRect(0, 0, m_w, m_h2); + painter.setBrush(Qt::SolidPattern); + + //draw vertical grids + double df = m_binsPerPixel*m_fftBinWidth; + pixperdiv = m_freqPerDiv/df; + y = m_h2 - m_h2/VERT_DIVS; + for( int i=1; i