diff options
Diffstat (limited to 'widgets/plotter.cpp')
| -rw-r--r-- | widgets/plotter.cpp | 86 |
1 files changed, 49 insertions, 37 deletions
diff --git a/widgets/plotter.cpp b/widgets/plotter.cpp index 14c13a50..8c2e9613 100644 --- a/widgets/plotter.cpp +++ b/widgets/plotter.cpp @@ -7,12 +7,13 @@ #include <QPen> #include <QMouseEvent> #include <QDebug> +#include "qt_helpers.hpp" #include "commons.h" #include "moc_plotter.cpp" #include <fstream> #include <iostream> -#define MAX_SCREENSIZE 2048 +#define MAX_SCREENSIZE 8192 extern "C" { void flat4_(float swide[], int* iz, int* nflatten); @@ -239,20 +240,22 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) if(y2>y2max) y2max=y2; j++; } - if(m_bReplot) return; + if(m_bReplot and m_mode!="Q65") return; if(swide[0]>1.0e29) m_line=0; if(m_mode=="FT4" and m_line==34) m_line=0; if(m_line == painter1.fontMetrics ().height ()) { painter1.setPen(Qt::white); QString t; - qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; - int n = fmod(0.001*ms,m_TRperiod); - QDateTime t1=QDateTime::currentDateTimeUtc().addSecs(-n); - if(m_TRperiod<60.0) { - t=t1.toString("hh:mm:ss") + " " + m_rxBand; + if(m_nUTC<0) { + auto start = qt_truncate_date_time_to (QDateTime::currentDateTimeUtc(), m_TRperiod * 1e3) + .toString (m_TRperiod < 60. ? "hh:mm:ss" : "hh:mm"); + t = QString {"%1 %2"}.arg (start, m_rxBand); } else { - t=t1.toString("hh:mm") + " " + m_rxBand; + auto hr = m_nUTC / 10000; + auto start = QTime {hr, (m_nUTC - 10000 * hr) / 100, m_nUTC % 100} + .toString (m_TRperiod < 60. ? "hh:mm:ss" : "hh:mm"); + t = QString {"%1 %2"}.arg (start).arg (m_rxBand); } painter1.drawText (5, painter1.fontMetrics ().ascent (), t); } @@ -274,45 +277,47 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed) painter2D.drawText(x1-4,y,"73"); } - if(bRed and m_bQ65_Sync) { //Plot the Q65 red or orange sync curve + if(bRed and m_bQ65_Sync) { //Plot the Q65 red/orange sync curves int k=0; int k2=0; std::ifstream f; f.open(m_redFile.toLatin1()); if(f) { int x,y; - float freq,xdt,sync,sync2; - f >> xdt; - for(int i=0; i<99999; i++) { - f >> freq >> sync >> sync2; - if(f.eof()) break; - x=XfromFreq(freq); - if(sync > -99.0 and sync != 0.0) { - y=m_h2*(0.9 - 0.09*gain2d*sync) - m_plot2dZero - 10; - LineBuf2[k2].setX(x); //Red sync curve - LineBuf2[k2].setY(y); - k2++; + float freq,xdt,smin,smax,sync,sync2; + f >> xdt >> smin >> smax; + if(f) { + for(int i=0; i<99999; i++) { + f >> freq >> sync >> sync2; + if(!f or f.eof() or k>=MAX_SCREENSIZE or k2>=MAX_SCREENSIZE) break; + x=XfromFreq(freq); + if(sync > -99.0 and (smin!=0.0 or smax != 0.0)) { + y=m_h2*(0.9 - 0.09*gain2d*sync) - m_plot2dZero - 10; + LineBuf2[k2].setX(x); //Red sync curve + LineBuf2[k2].setY(y); + k2++; + } + y=m_h2*(0.9 - 0.09*gain2d*sync2) - m_plot2dZero; + LineBuf3[k].setX(x); //Orange sync curve + LineBuf3[k].setY(y); + k++; } - y=m_h2*(0.9 - 0.09*gain2d*sync2) - m_plot2dZero; - LineBuf3[k].setX(x); //Orange sync curve - LineBuf3[k].setY(y); - k++; } f.close(); - QPen pen0(Qt::red,2); + QPen pen0(Qt::red,2); painter2D.setPen(pen0); - painter2D.drawPolyline(LineBuf2,k2); + if(smin!=0.0 or smax != 0.0) { + painter2D.drawPolyline(LineBuf2,k2); + } pen0.setColor("orange"); painter2D.setPen(pen0); painter2D.drawPolyline(LineBuf3,k); - if(m_bQ65_Sync) { - QString t; - t = t.asprintf("DT = %6.2f",xdt); - painter2D.setPen(Qt::white); - Font.setWeight(QFont::Bold); - painter2D.setFont(Font); - painter2D.drawText(m_w-100,m_h2/2,t); - } + QString t; + t = t.asprintf("DT = %6.2f",xdt); + painter2D.setPen(Qt::white); + Font.setWeight(QFont::Bold); + painter2D.setFont(Font); + painter2D.drawText(m_w-100,m_h2/2,t); } } update(); //trigger a new paintEvent @@ -335,6 +340,9 @@ void CPlotter::replot() plotsave_(swide,&m_w,&m_h1,&irow); draw(swide,false,false); } + if(m_mode=="Q65" and m_bQ65_Sync) { + draw(swide,false,true); + } update(); //trigger a new paintEvent m_bReplot=false; } @@ -623,7 +631,6 @@ void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs int CPlotter::XfromFreq(float f) //XfromFreq() { -// float w = m_WaterfallPixmap.width(); int x = int(m_w * (f - m_startFreq)/m_fSpan + 0.5); if(x<0 ) return 0; if(x>m_w) return m_w; @@ -765,6 +772,7 @@ void CPlotter::mouseReleaseEvent (QMouseEvent * event) else { event->ignore (); // let parent handle } +// replot(); // ### Not needed? ### } void CPlotter::mouseDoubleClickEvent (QMouseEvent * event) @@ -774,8 +782,7 @@ void CPlotter::mouseDoubleClickEvent (QMouseEvent * event) int n=2; if(ctrl) n+=100; emit freezeDecode1(n); - } - else { + } else { event->ignore (); // let parent handle } } @@ -878,3 +885,8 @@ void CPlotter::setRedFile(QString fRed) { m_redFile=fRed; } + +void CPlotter::setDiskUTC(int nutc) +{ + m_nUTC=nutc; +} |
