| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | #include "widegraph.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <algorithm>
 | 
					
						
							|  |  |  | #include <QApplication>
 | 
					
						
							|  |  |  | #include <QSettings>
 | 
					
						
							|  |  |  | #include "ui_widegraph.h"
 | 
					
						
							|  |  |  | #include "commons.h"
 | 
					
						
							|  |  |  | #include "Configuration.hpp"
 | 
					
						
							|  |  |  | #include "MessageBox.hpp"
 | 
					
						
							|  |  |  | #include "SettingsGroup.hpp"
 | 
					
						
							| 
									
										
										
										
											2018-09-18 17:24:07 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DriftingDateTime.h"
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | #include "keyeater.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-18 17:24:07 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | #include "moc_widegraph.cpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   auto user_defined = QObject::tr ("User Defined"); | 
					
						
							|  |  |  |   float swide[MAX_SCREENSIZE]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WideGraph::WideGraph(QSettings * settings, QWidget *parent) : | 
					
						
							|  |  |  |   QDialog(parent), | 
					
						
							|  |  |  |   ui(new Ui::WideGraph), | 
					
						
							|  |  |  |   m_settings (settings), | 
					
						
							|  |  |  |   m_palettes_path {":/Palettes"}, | 
					
						
							|  |  |  |   m_ntr0 {0}, | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   m_n {0}, | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |   m_filterMinWidth {0}, | 
					
						
							|  |  |  |   m_filterMinimum {0}, | 
					
						
							|  |  |  |   m_filterMaximum {5000}, | 
					
						
							| 
									
										
										
										
											2019-12-16 13:59:10 -05:00
										 |  |  |   m_filterEnabled {false}, | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   m_bHaveTransmitted {false} | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | { | 
					
						
							|  |  |  |   ui->setupUi(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   setWindowTitle (QApplication::applicationName () + " - " + tr ("Wide Graph")); | 
					
						
							|  |  |  |   setWindowFlags (Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); | 
					
						
							|  |  |  |   setMaximumHeight (880); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-17 21:47:46 -05:00
										 |  |  |   ui->splitter->setChildrenCollapsible(false); | 
					
						
							| 
									
										
										
										
											2019-12-18 09:50:22 -05:00
										 |  |  |   ui->splitter->setCollapsible(ui->splitter->indexOf(ui->controls_widget), false); | 
					
						
							| 
									
										
										
										
											2019-12-17 21:47:46 -05:00
										 |  |  |   ui->splitter->updateGeometry(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |   auto filterEscapeEater = new KeyPressEater(); | 
					
						
							|  |  |  |   connect(filterEscapeEater, &KeyPressEater::keyPressed, this, [this](QObject */*obj*/, QKeyEvent *e, bool *pProcessed){ | 
					
						
							|  |  |  |       if(e->key() != Qt::Key_Escape){ | 
					
						
							|  |  |  |           return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |       setFilter(0, 5000); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |       if(pProcessed) *pProcessed=true; | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |   ui->filterMinSpinBox->installEventFilter(filterEscapeEater); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   ui->widePlot->setCursor(Qt::CrossCursor); | 
					
						
							| 
									
										
										
										
											2019-12-23 15:29:12 -05:00
										 |  |  |   ui->widePlot->setMaximumWidth(MAX_SCREENSIZE); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   ui->widePlot->setMaximumHeight(800); | 
					
						
							|  |  |  |   ui->widePlot->setCurrent(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-17 11:25:42 -05:00
										 |  |  |   ui->widePlot->setContextMenuPolicy(Qt::CustomContextMenu); | 
					
						
							|  |  |  |   connect(ui->widePlot, &CPlotter::customContextMenuRequested, this, [this](const QPoint &pos){ | 
					
						
							|  |  |  |       auto menu = new QMenu(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       int f = ui->widePlot->frequencyAt(pos.x()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-17 11:26:40 -05:00
										 |  |  |       auto offsetAction = menu->addAction(QString("Set &Offset to %1 Hz").arg(f)); | 
					
						
							| 
									
										
										
										
											2019-12-17 11:25:42 -05:00
										 |  |  |       connect(offsetAction, &QAction::triggered, this, [this, f](){ | 
					
						
							|  |  |  |         ui->offsetSpinBox->setValue(f); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       menu->addSeparator(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if(m_filterEnabled){ | 
					
						
							|  |  |  |           auto disableAction = menu->addAction(QString("&Disable Filter")); | 
					
						
							|  |  |  |           connect(disableAction, &QAction::triggered, this, [this](){ | 
					
						
							|  |  |  |             ui->filterCheckBox->setChecked(false); | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 12:31:14 -05:00
										 |  |  |       auto centerAction = menu->addAction(QString("Set Filter &Center to %1 Hz").arg(f)); | 
					
						
							|  |  |  |       connect(centerAction, &QAction::triggered, this, [this, f](){ | 
					
						
							|  |  |  |         ui->filterCenterSpinBox->setValue(f); | 
					
						
							|  |  |  |         ui->filterCheckBox->setChecked(true); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 21:38:01 -05:00
										 |  |  |       auto widthMenu = menu->addMenu("Set Filter &Width to..."); | 
					
						
							|  |  |  |       auto widths = QList<int>{ 25, 50, 75, 100, 250, 500, 750, 1000, 1500, 2000 }; | 
					
						
							|  |  |  |       foreach(auto width, widths){ | 
					
						
							|  |  |  |         if(width < m_filterMinWidth){ continue; } | 
					
						
							|  |  |  |         auto widthAction = widthMenu->addAction(QString("%1 Hz").arg(width)); | 
					
						
							|  |  |  |         connect(widthAction, &QAction::triggered, this, [this, width](){ | 
					
						
							|  |  |  |             ui->filterWidthSpinBox->setValue(width); | 
					
						
							|  |  |  |             ui->filterCheckBox->setChecked(true); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       auto minAction = menu->addAction(QString("Set Filter &Minimum to %1 Hz").arg(f)); | 
					
						
							|  |  |  |       connect(minAction, &QAction::triggered, this, [this, f](){ | 
					
						
							|  |  |  |         ui->filterMinSpinBox->setValue(f); | 
					
						
							|  |  |  |         ui->filterCheckBox->setChecked(true); | 
					
						
							| 
									
										
										
										
											2019-12-17 11:25:42 -05:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       menu->popup(ui->widePlot->mapToGlobal(pos)); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this, | 
					
						
							|  |  |  |           SLOT(wideFreezeDecode(int))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   connect(ui->widePlot, SIGNAL(setFreq1(int,int)),this, | 
					
						
							|  |  |  |           SLOT(setFreq2(int,int))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  |   connect(ui->widePlot, &CPlotter::qsy, this, [this](int hzDelta){ | 
					
						
							|  |  |  |     emit qsy(hzDelta); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     //Restore user's settings
 | 
					
						
							|  |  |  |     SettingsGroup g {m_settings, "WideGraph"}; | 
					
						
							|  |  |  |     restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); | 
					
						
							|  |  |  |     ui->widePlot->setPlotZero(m_settings->value("PlotZero", 0).toInt()); | 
					
						
							|  |  |  |     ui->widePlot->setPlotGain(m_settings->value("PlotGain", 0).toInt()); | 
					
						
							|  |  |  |     ui->widePlot->setPlot2dGain(m_settings->value("Plot2dGain", 0).toInt()); | 
					
						
							|  |  |  |     ui->widePlot->setPlot2dZero(m_settings->value("Plot2dZero", 0).toInt()); | 
					
						
							|  |  |  |     ui->zeroSlider->setValue(ui->widePlot->plotZero()); | 
					
						
							|  |  |  |     ui->gainSlider->setValue(ui->widePlot->plotGain()); | 
					
						
							|  |  |  |     ui->gain2dSlider->setValue(ui->widePlot->plot2dGain()); | 
					
						
							|  |  |  |     ui->zero2dSlider->setValue(ui->widePlot->plot2dZero()); | 
					
						
							|  |  |  |     int n = m_settings->value("BinsPerPixel",2).toInt(); | 
					
						
							|  |  |  |     m_bFlatten=m_settings->value("Flatten",true).toBool(); | 
					
						
							|  |  |  |     m_bRef=m_settings->value("UseRef",false).toBool(); | 
					
						
							|  |  |  |     ui->cbFlatten->setChecked(m_bFlatten); | 
					
						
							|  |  |  |     ui->widePlot->setFlatten(m_bFlatten,m_bRef); | 
					
						
							|  |  |  |     ui->cbRef->setChecked(m_bRef); | 
					
						
							|  |  |  |     ui->widePlot->setBreadth(m_settings->value("PlotWidth",1000).toInt()); | 
					
						
							|  |  |  |     ui->bppSpinBox->setValue(n); | 
					
						
							|  |  |  |     m_nsmo=m_settings->value("SmoothYellow",1).toInt(); | 
					
						
							|  |  |  |     ui->smoSpinBox->setValue(m_nsmo); | 
					
						
							| 
									
										
										
										
											2018-07-09 15:34:44 -04:00
										 |  |  |     m_Percent2DScreen=m_settings->value("Percent2D", 0).toInt(); | 
					
						
							|  |  |  |     m_waterfallAvg = m_settings->value("WaterfallAvg", 1).toInt(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     ui->waterfallAvgSpinBox->setValue(m_waterfallAvg); | 
					
						
							|  |  |  |     ui->widePlot->setWaterfallAvg(m_waterfallAvg); | 
					
						
							|  |  |  |     ui->widePlot->setCurrent(m_settings->value("Current",false).toBool()); | 
					
						
							|  |  |  |     ui->widePlot->setCumulative(m_settings->value("Cumulative",true).toBool()); | 
					
						
							|  |  |  |     ui->widePlot->setLinearAvg(m_settings->value("LinearAvg",false).toBool()); | 
					
						
							|  |  |  |     if(ui->widePlot->current()) ui->spec2dComboBox->setCurrentIndex(0); | 
					
						
							|  |  |  |     if(ui->widePlot->cumulative()) ui->spec2dComboBox->setCurrentIndex(1); | 
					
						
							|  |  |  |     if(ui->widePlot->linearAvg()) ui->spec2dComboBox->setCurrentIndex(2); | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #if JS8_USE_REFSPEC
 | 
					
						
							|  |  |  |     ui->widePlot->setReference(m_settings->value("Reference",false).toBool()); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     if(ui->widePlot->Reference()) ui->spec2dComboBox->setCurrentIndex(3); | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-10-05 10:23:28 -04:00
										 |  |  |     int nbpp=m_settings->value("BinsPerPixel", 2).toInt(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     ui->widePlot->setBinsPerPixel(nbpp); | 
					
						
							|  |  |  |     ui->sbPercent2dPlot->setValue(m_Percent2DScreen); | 
					
						
							| 
									
										
										
										
											2018-07-09 15:34:44 -04:00
										 |  |  |     ui->widePlot->SetPercent2DScreen(m_Percent2DScreen); | 
					
						
							| 
									
										
										
										
											2018-08-23 13:10:20 -04:00
										 |  |  |     ui->widePlot->setStartFreq(m_settings->value("StartFreq", 500).toInt()); | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  |     ui->centerSpinBox->setValue(m_settings->value("CenterOffset", 1500).toInt()); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     ui->fStartSpinBox->setValue(ui->widePlot->startFreq()); | 
					
						
							|  |  |  |     m_waterfallPalette=m_settings->value("WaterfallPalette","Default").toString(); | 
					
						
							|  |  |  |     m_userPalette = WFPalette {m_settings->value("UserPalette").value<WFPalette::Colours> ()}; | 
					
						
							|  |  |  |     m_fMinPerBand = m_settings->value ("FminPerBand").toHash (); | 
					
						
							|  |  |  |     setRxRange (); | 
					
						
							| 
									
										
										
										
											2018-08-23 13:10:20 -04:00
										 |  |  |     ui->controls_widget->setVisible(!m_settings->value("HideControls", false).toBool()); | 
					
						
							|  |  |  |     ui->cbControls->setChecked(!m_settings->value("HideControls", false).toBool()); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-17 10:39:18 -05:00
										 |  |  |     auto splitState = m_settings->value("SplitState").toByteArray(); | 
					
						
							|  |  |  |     if(!splitState.isEmpty()){ | 
					
						
							|  |  |  |         ui->splitter->restoreState(splitState); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     setFilter(m_settings->value("FilterMinimum", 500).toInt(), m_settings->value("FilterMaximum", 2500).toInt()); | 
					
						
							| 
									
										
										
										
											2019-12-19 10:06:37 -05:00
										 |  |  |     setFilterOpacityPercent(m_settings->value("FilterOpacityPercent", 50).toInt()); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |     setFilterEnabled(m_settings->value("FilterEnabled", false).toBool()); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   int index=0; | 
					
						
							|  |  |  |   for (QString const& file: | 
					
						
							|  |  |  |          m_palettes_path.entryList(QDir::NoDotAndDotDot | | 
					
						
							|  |  |  |                                    QDir::System | QDir::Hidden | | 
					
						
							|  |  |  |                                    QDir::AllDirs | QDir::Files, | 
					
						
							|  |  |  |                                    QDir::DirsFirst)) { | 
					
						
							|  |  |  |     QString t=file.mid(0,file.length()-4); | 
					
						
							|  |  |  |     ui->paletteComboBox->addItem(t); | 
					
						
							|  |  |  |     if(t==m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); | 
					
						
							|  |  |  |     index++; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   ui->paletteComboBox->addItem (user_defined); | 
					
						
							|  |  |  |   if (user_defined == m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); | 
					
						
							|  |  |  |   readPalette (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WideGraph::~WideGraph () | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::closeEvent (QCloseEvent * e) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   saveSettings (); | 
					
						
							|  |  |  |   QDialog::closeEvent (e); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::saveSettings()                                           //saveSettings
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   SettingsGroup g {m_settings, "WideGraph"}; | 
					
						
							|  |  |  |   m_settings->setValue ("geometry", saveGeometry ()); | 
					
						
							|  |  |  |   m_settings->setValue ("PlotZero", ui->widePlot->plotZero()); | 
					
						
							|  |  |  |   m_settings->setValue ("PlotGain", ui->widePlot->plotGain()); | 
					
						
							|  |  |  |   m_settings->setValue ("Plot2dGain", ui->widePlot->plot2dGain()); | 
					
						
							|  |  |  |   m_settings->setValue ("Plot2dZero", ui->widePlot->plot2dZero()); | 
					
						
							|  |  |  |   m_settings->setValue ("PlotWidth", ui->widePlot->plotWidth ()); | 
					
						
							|  |  |  |   m_settings->setValue ("BinsPerPixel", ui->bppSpinBox->value ()); | 
					
						
							|  |  |  |   m_settings->setValue ("SmoothYellow", ui->smoSpinBox->value ()); | 
					
						
							|  |  |  |   m_settings->setValue ("Percent2D",m_Percent2DScreen); | 
					
						
							|  |  |  |   m_settings->setValue ("WaterfallAvg", ui->waterfallAvgSpinBox->value ()); | 
					
						
							|  |  |  |   m_settings->setValue ("Current", ui->widePlot->current()); | 
					
						
							|  |  |  |   m_settings->setValue ("Cumulative", ui->widePlot->cumulative()); | 
					
						
							|  |  |  |   m_settings->setValue ("LinearAvg", ui->widePlot->linearAvg()); | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #if JS8_USE_REFSPEC
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   m_settings->setValue ("Reference", ui->widePlot->Reference()); | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   m_settings->setValue ("BinsPerPixel", ui->widePlot->binsPerPixel ()); | 
					
						
							|  |  |  |   m_settings->setValue ("StartFreq", ui->widePlot->startFreq ()); | 
					
						
							|  |  |  |   m_settings->setValue ("WaterfallPalette", m_waterfallPalette); | 
					
						
							|  |  |  |   m_settings->setValue ("UserPalette", QVariant::fromValue (m_userPalette.colours ())); | 
					
						
							| 
									
										
										
										
											2019-12-19 10:06:37 -05:00
										 |  |  |   m_settings->setValue ("Flatten",m_bFlatten); | 
					
						
							|  |  |  |   m_settings->setValue ("UseRef",m_bRef); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   m_settings->setValue ("HideControls", ui->controls_widget->isHidden ()); | 
					
						
							|  |  |  |   m_settings->setValue ("FminPerBand", m_fMinPerBand); | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  |   m_settings->setValue ("CenterOffset", ui->centerSpinBox->value()); | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |   m_settings->setValue ("FilterMinimum", m_filterMinimum); | 
					
						
							|  |  |  |   m_settings->setValue ("FilterMaximum", m_filterMaximum); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |   m_settings->setValue ("FilterEnabled", m_filterEnabled); | 
					
						
							| 
									
										
										
										
											2019-12-19 10:06:37 -05:00
										 |  |  |   m_settings->setValue ("FilterOpacityPercent", ui->filterOpacitySpinBox->value()); | 
					
						
							| 
									
										
										
										
											2019-12-17 10:39:18 -05:00
										 |  |  |   m_settings->setValue ("SplitState", ui->splitter->saveState()); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::drawRed(int ia, int ib) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->drawRed(ia,ib,swide); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata)  //dataSink2
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   static float splot[NSMAX]; | 
					
						
							|  |  |  |   int nbpp = ui->widePlot->binsPerPixel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Average spectra over specified number, m_waterfallAvg
 | 
					
						
							|  |  |  |   if (m_n==0) { | 
					
						
							|  |  |  |     for (int i=0; i<NSMAX; i++) | 
					
						
							|  |  |  |       splot[i]=s[i]; | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     for (int i=0; i<NSMAX; i++) | 
					
						
							|  |  |  |       splot[i] += s[i]; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   m_n++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (m_n>=m_waterfallAvg) { | 
					
						
							|  |  |  |     for (int i=0; i<NSMAX; i++) | 
					
						
							|  |  |  |         splot[i] /= m_n;        //Normalize the average
 | 
					
						
							|  |  |  |     m_n=0; | 
					
						
							|  |  |  |     int i=int(ui->widePlot->startFreq()/df3 + 0.5); | 
					
						
							|  |  |  |     int jz=5000.0/(nbpp*df3); | 
					
						
							|  |  |  | 		if(jz>MAX_SCREENSIZE) jz=MAX_SCREENSIZE; | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |     m_jz=jz; | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     for (int j=0; j<jz; j++) { | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |       float ss=0.0; | 
					
						
							|  |  |  |       float smax=0; | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |       for (int k=0; k<nbpp; k++) { | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |         float sp=splot[i++]; | 
					
						
							|  |  |  |         ss += sp; | 
					
						
							|  |  |  |         smax=qMax(smax,sp); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  | //      swide[j]=nbpp*smax;
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |       swide[j]=nbpp*ss; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Time according to this computer
 | 
					
						
							| 
									
										
										
										
											2018-09-18 17:24:07 -04:00
										 |  |  |     qint64 ms = DriftingDateTime::currentMSecsSinceEpoch() % 86400000; | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |     int ntr = (ms/1000) % m_TRperiod; | 
					
						
							|  |  |  |     if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<m_ntr0)) { | 
					
						
							|  |  |  |       float flagValue=1.0e30; | 
					
						
							|  |  |  |       if(m_bHaveTransmitted) flagValue=2.0e30; | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |       for(int i=0; i<MAX_SCREENSIZE; i++) { | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |         swide[i] = flagValue; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |       for(int i=0; i<NSMAX; i++) { | 
					
						
							|  |  |  |         splot[i] = flagValue; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |       m_bHaveTransmitted=false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     m_ntr0=ntr; | 
					
						
							|  |  |  |     ui->widePlot->draw(swide,true,false); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_bppSpinBox_valueChanged(int n)                            //bpp
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setBinsPerPixel(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  | void WideGraph::on_qsyPushButton_clicked(){ | 
					
						
							| 
									
										
										
										
											2018-09-11 13:35:29 -04:00
										 |  |  |     int hzDelta = rxFreq() - centerFreq(); | 
					
						
							| 
									
										
										
										
											2018-09-09 17:18:07 -04:00
										 |  |  |     emit qsy(hzDelta); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 09:31:18 -04:00
										 |  |  | void WideGraph::on_offsetSpinBox_valueChanged(int n){ | 
					
						
							|  |  |  |   if(n == rxFreq()){ | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-03 18:55:45 -04:00
										 |  |  |   // TODO: jsherer - here's where we'd set minimum frequency again (later?)
 | 
					
						
							|  |  |  |   n = qMax(0, n); | 
					
						
							| 
									
										
										
										
											2018-08-23 13:10:20 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 09:31:18 -04:00
										 |  |  |   setRxFreq(n); | 
					
						
							|  |  |  |   setTxFreq(n); | 
					
						
							| 
									
										
										
										
											2018-08-08 17:21:05 -04:00
										 |  |  |   setFreq2(n, n); | 
					
						
							| 
									
										
										
										
											2018-08-07 09:31:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | void WideGraph::on_waterfallAvgSpinBox_valueChanged(int n)                  //Navg
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_waterfallAvg = n; | 
					
						
							|  |  |  |   ui->widePlot->setWaterfallAvg(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::keyPressEvent(QKeyEvent *e)                                 //F11, F12
 | 
					
						
							|  |  |  | {   | 
					
						
							|  |  |  |   switch(e->key()) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |   int n; | 
					
						
							|  |  |  |   case Qt::Key_F11: | 
					
						
							|  |  |  |     n=11; | 
					
						
							|  |  |  |     if(e->modifiers() & Qt::ControlModifier) n+=100; | 
					
						
							|  |  |  |     emit f11f12(n); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case Qt::Key_F12: | 
					
						
							|  |  |  |     n=12; | 
					
						
							|  |  |  |     if(e->modifiers() & Qt::ControlModifier) n+=100; | 
					
						
							|  |  |  |     emit f11f12(n); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     QDialog::keyPressEvent (e); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setRxFreq(int n)                                           //setRxFreq
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setRxFreq(n); | 
					
						
							|  |  |  |   ui->widePlot->draw(swide,false,false); | 
					
						
							| 
									
										
										
										
											2018-08-07 09:31:18 -04:00
										 |  |  |   ui->offsetSpinBox->setValue(n); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WideGraph::rxFreq()                                                   //rxFreq
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->widePlot->rxFreq(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 13:35:29 -04:00
										 |  |  | int WideGraph::centerFreq() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->centerSpinBox->value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | int WideGraph::nStartFreq()                                             //nStartFreq
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->widePlot->startFreq(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::wideFreezeDecode(int n)                              //wideFreezeDecode
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit freezeDecode2(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setRxRange () | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setRxRange (Fmin ()); | 
					
						
							|  |  |  |   ui->widePlot->DrawOverlay(); | 
					
						
							|  |  |  |   ui->widePlot->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WideGraph::Fmin()                                              //Fmin
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return "60m" == m_rxBand ? 0 : m_fMinPerBand.value (m_rxBand, 2500).toUInt (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WideGraph::Fmax()                                              //Fmax
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return std::min(5000,ui->widePlot->Fmax()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  | int WideGraph::filterMinimum() | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     return std::max(0, m_filterMinimum); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WideGraph::filterMaximum() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return std::min(m_filterMaximum, 5000); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:59:10 -05:00
										 |  |  | bool WideGraph::filterEnabled() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_filterEnabled; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-26 15:11:32 -05:00
										 |  |  | void WideGraph::setFilterCenter(int n){ | 
					
						
							|  |  |  |     int delta = n - m_filterCenter; | 
					
						
							|  |  |  |     setFilter(m_filterMinimum + delta, m_filterMaximum + delta); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  | void WideGraph::setFilter(int a, int b){ | 
					
						
							|  |  |  |     int low = std::min(a, b); | 
					
						
							|  |  |  |     int high = std::max(a, b); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // ensure minimum filter width
 | 
					
						
							|  |  |  |     if(high-low < m_filterMinWidth){ | 
					
						
							|  |  |  |         high = low + m_filterMinWidth; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  |     int width = high - low; | 
					
						
							|  |  |  |     int center = low + width / 2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |     // update the filter history
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     m_filterMinimum = low; | 
					
						
							|  |  |  |     m_filterMaximum = high; | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  |     m_filterCenter = center; | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // update the spinner UI
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     bool blocked = false; | 
					
						
							|  |  |  |     blocked = ui->filterMinSpinBox->blockSignals(true); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:59:10 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |         ui->filterMinSpinBox->setValue(low); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:59:10 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     ui->filterMinSpinBox->blockSignals(blocked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  |     blocked = ui->filterCenterSpinBox->blockSignals(true); | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->filterCenterSpinBox->setValue(center); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->filterCenterSpinBox->blockSignals(blocked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 12:31:14 -05:00
										 |  |  |     blocked = ui->filterWidthSpinBox->blockSignals(true); | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->filterWidthSpinBox->setValue(width); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->filterWidthSpinBox->blockSignals(blocked); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  |     // update the wide plot UI
 | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  |     ui->widePlot->setFilterCenter(center); | 
					
						
							|  |  |  |     ui->widePlot->setFilterWidth(width); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  | void WideGraph::setFilterMinimumBandwidth(int width){ | 
					
						
							|  |  |  |     m_filterMinWidth = width; | 
					
						
							| 
									
										
										
										
											2019-12-23 21:38:01 -05:00
										 |  |  |     ui->filterWidthSpinBox->setMinimum(width); | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  |     setFilter(m_filterMinimum, std::max(m_filterMinimum+width, m_filterMaximum)); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setFilterEnabled(bool enabled){ | 
					
						
							|  |  |  |     m_filterEnabled = enabled; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 14:22:58 -05:00
										 |  |  |     // update the filter ui
 | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  |     ui->filterCenterSpinBox->setEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2019-12-27 14:22:58 -05:00
										 |  |  |     ui->filterCenterSyncButton->setEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2019-12-23 12:31:14 -05:00
										 |  |  |     ui->filterWidthSpinBox->setEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2019-12-27 14:22:58 -05:00
										 |  |  |     ui->filterMinSpinBox->setEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:59:10 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // update the checkbox ui
 | 
					
						
							|  |  |  |     bool blocked = ui->filterCheckBox->blockSignals(true); | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->filterCheckBox->setChecked(enabled); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->filterCheckBox->blockSignals(blocked); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // update the wideplot
 | 
					
						
							|  |  |  |     ui->widePlot->setFilterEnabled(enabled); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-19 10:06:37 -05:00
										 |  |  | void WideGraph::setFilterOpacityPercent(int n){ | 
					
						
							|  |  |  |     // update the spinbox
 | 
					
						
							|  |  |  |     bool blocked = ui->filterOpacitySpinBox->blockSignals(true); | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->filterOpacitySpinBox->setValue(n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->filterOpacitySpinBox->blockSignals(blocked); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // update the wide plot
 | 
					
						
							|  |  |  |     ui->widePlot->setFilterOpacity(int((float(n)/100.0)*255)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | int WideGraph::fSpan() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return ui->widePlot->fSpan (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setPeriod(int ntrperiod, int nsps)                  //SetPeriod
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_TRperiod=ntrperiod; | 
					
						
							|  |  |  |   m_nsps=nsps; | 
					
						
							|  |  |  |   ui->widePlot->setNsps(ntrperiod, nsps); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setTxFreq(int n)                                   //setTxFreq
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit setXIT2(n); | 
					
						
							|  |  |  |   ui->widePlot->setTxFreq(n); | 
					
						
							| 
									
										
										
										
											2018-08-07 09:31:18 -04:00
										 |  |  |   ui->offsetSpinBox->setValue(n); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setMode(QString mode)                              //setMode
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_mode=mode; | 
					
						
							|  |  |  |   ui->widePlot->setMode(mode); | 
					
						
							|  |  |  |   ui->widePlot->DrawOverlay(); | 
					
						
							|  |  |  |   ui->widePlot->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setSubMode(int n)                                  //setSubMode
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_nSubMode=n; | 
					
						
							|  |  |  |   ui->widePlot->setSubMode(n); | 
					
						
							|  |  |  |   ui->widePlot->DrawOverlay(); | 
					
						
							|  |  |  |   ui->widePlot->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | void WideGraph::setModeTx(QString modeTx)                          //setModeTx
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_modeTx=modeTx; | 
					
						
							|  |  |  |   ui->widePlot->setModeTx(modeTx); | 
					
						
							|  |  |  |   ui->widePlot->DrawOverlay(); | 
					
						
							|  |  |  |   ui->widePlot->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                                         //Current-Cumulative-Yellow
 | 
					
						
							|  |  |  | void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setCurrent(false); | 
					
						
							|  |  |  |   ui->widePlot->setCumulative(false); | 
					
						
							|  |  |  |   ui->widePlot->setLinearAvg(false); | 
					
						
							|  |  |  |   ui->smoSpinBox->setEnabled(false); | 
					
						
							|  |  |  |   if(arg1=="Current") ui->widePlot->setCurrent(true); | 
					
						
							|  |  |  |   if(arg1=="Cumulative") ui->widePlot->setCumulative(true); | 
					
						
							|  |  |  |   if(arg1=="Linear Avg") { | 
					
						
							|  |  |  |     ui->widePlot->setLinearAvg(true); | 
					
						
							|  |  |  |     ui->smoSpinBox->setEnabled(true); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #if JS8_USE_REFSPEC
 | 
					
						
							|  |  |  |   ui->widePlot->setReference(false); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  |   if(arg1=="Reference") { | 
					
						
							|  |  |  |     ui->widePlot->setReference(true); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-11-06 14:16:46 -05:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   replot(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setFreq2(int rxFreq, int txFreq)                  //setFreq2
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit setFreq3(rxFreq,txFreq); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setDialFreq(double d)                             //setDialFreq
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setDialFreq(d); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-01 18:26:10 -04:00
										 |  |  | void WideGraph::setControlsVisible(bool visible) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-17 14:32:46 -05:00
										 |  |  |   ui->cbControls->setChecked(!visible); | 
					
						
							| 
									
										
										
										
											2018-09-01 18:26:10 -04:00
										 |  |  |   ui->cbControls->setChecked(visible); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool WideGraph::controlsVisible(){ | 
					
						
							| 
									
										
										
										
											2019-12-17 14:32:46 -05:00
										 |  |  |   auto sizes = ui->splitter->sizes(); | 
					
						
							|  |  |  |   return ui->cbControls->isChecked() && sizes.last() > 0; | 
					
						
							| 
									
										
										
										
											2018-09-01 18:26:10 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | void WideGraph::setRxBand (QString const& band) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_rxBand = band; | 
					
						
							|  |  |  |   ui->widePlot->setRxBand(band); | 
					
						
							|  |  |  |   setRxRange (); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_fStartSpinBox_valueChanged(int n)             //fStart
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setStartFreq(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::readPalette ()                                   //readPalette
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       if (user_defined == m_waterfallPalette) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           ui->widePlot->setColours (WFPalette {m_userPalette}.interpolate ()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           ui->widePlot->setColours (WFPalette {m_palettes_path.absoluteFilePath (m_waterfallPalette + ".pal")}.interpolate()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   catch (std::exception const& e) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_paletteComboBox_activated (QString const& palette)    //palette selector
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_waterfallPalette = palette; | 
					
						
							|  |  |  |   readPalette(); | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   replot(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_cbFlatten_toggled(bool b)                          //Flatten On/Off
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_bFlatten=b; | 
					
						
							|  |  |  |   if(m_bRef and m_bFlatten) { | 
					
						
							|  |  |  |     m_bRef=false; | 
					
						
							|  |  |  |     ui->cbRef->setChecked(false); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   ui->widePlot->setFlatten(m_bFlatten,m_bRef); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_cbRef_toggled(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_bRef=b; | 
					
						
							|  |  |  |   if(m_bRef and m_bFlatten) { | 
					
						
							|  |  |  |     m_bFlatten=false; | 
					
						
							|  |  |  |     ui->cbFlatten->setChecked(false); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   ui->widePlot->setFlatten(m_bFlatten,m_bRef); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_cbControls_toggled(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->controls_widget->setVisible(b); | 
					
						
							| 
									
										
										
										
											2019-12-17 14:32:46 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   static int lastSize = ui->splitter->width()/4; | 
					
						
							|  |  |  |   auto sizes = ui->splitter->sizes(); | 
					
						
							|  |  |  |   if(b){ | 
					
						
							|  |  |  |       ui->splitter->setSizes({ sizes.first(), lastSize }); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |       // keep track of the last size of the control
 | 
					
						
							|  |  |  |       lastSize = qMax(sizes.last(), 100); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_adjust_palette_push_button_clicked (bool)   //Adjust Palette
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       if (m_userPalette.design ()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           m_waterfallPalette = user_defined; | 
					
						
							|  |  |  |           ui->paletteComboBox->setCurrentText (m_waterfallPalette); | 
					
						
							|  |  |  |           readPalette (); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   catch (std::exception const& e) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool WideGraph::flatten()                                              //Flatten
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return m_bFlatten; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool WideGraph::useRef()                                              //Flatten
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return m_bRef; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  | void WideGraph::replot() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if(ui->widePlot->scaleOK()) ui->widePlot->replot(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | void WideGraph::on_gainSlider_valueChanged(int value)                 //Gain
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setPlotGain(value); | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   replot(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_zeroSlider_valueChanged(int value)                 //Zero
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setPlotZero(value); | 
					
						
							| 
									
										
										
										
											2018-03-05 14:49:51 -05:00
										 |  |  |   replot(); | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_gain2dSlider_valueChanged(int value)               //Gain2
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setPlot2dGain(value); | 
					
						
							|  |  |  |   if(ui->widePlot->scaleOK ()) { | 
					
						
							|  |  |  |     ui->widePlot->draw(swide,false,false); | 
					
						
							|  |  |  |     if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_zero2dSlider_valueChanged(int value)               //Zero2
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setPlot2dZero(value); | 
					
						
							|  |  |  |   if(ui->widePlot->scaleOK ()) { | 
					
						
							|  |  |  |     ui->widePlot->draw(swide,false,false); | 
					
						
							|  |  |  |     if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setTol(int n)                                         //setTol
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setTol(n); | 
					
						
							|  |  |  |   ui->widePlot->DrawOverlay(); | 
					
						
							|  |  |  |   ui->widePlot->update(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_smoSpinBox_valueChanged(int n) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_nsmo=n; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int WideGraph::smoothYellow() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return m_nsmo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setWSPRtransmitted() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_bHaveTransmitted=true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setVHF(bool bVHF) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setVHF(bVHF); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_sbPercent2dPlot_valueChanged(int n) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_Percent2DScreen=n; | 
					
						
							|  |  |  |   ui->widePlot->SetPercent2DScreen(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 21:28:45 -05:00
										 |  |  | void WideGraph::on_filterMinSpinBox_valueChanged(int n){ | 
					
						
							| 
									
										
										
										
											2019-12-23 21:38:01 -05:00
										 |  |  |     int delta = n - m_filterMinimum; | 
					
						
							|  |  |  |     setFilter(m_filterMinimum + delta, m_filterMaximum + delta); | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  | void WideGraph::on_filterCenterSpinBox_valueChanged(int n){ | 
					
						
							| 
									
										
										
										
											2019-12-26 15:11:32 -05:00
										 |  |  |     setFilterCenter(n); | 
					
						
							| 
									
										
										
										
											2019-12-23 08:18:14 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 12:31:14 -05:00
										 |  |  | void WideGraph::on_filterWidthSpinBox_valueChanged(int n){ | 
					
						
							|  |  |  |     setFilter(m_filterCenter - n/2, m_filterCenter - n/2 + n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 14:22:58 -05:00
										 |  |  | void WideGraph::on_filterCenterSyncButton_clicked(){ | 
					
						
							|  |  |  |     setFilterCenter(ui->offsetSpinBox->value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-16 13:42:44 -05:00
										 |  |  | void WideGraph::on_filterCheckBox_toggled(bool b){ | 
					
						
							|  |  |  |     setFilterEnabled(b); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-19 10:06:37 -05:00
										 |  |  | void WideGraph::on_filterOpacitySpinBox_valueChanged(int n){ | 
					
						
							|  |  |  |     setFilterOpacityPercent(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 21:28:33 -05:00
										 |  |  | void WideGraph::setRedFile(QString fRed) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   ui->widePlot->setRedFile(fRed); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-04 22:37:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setTurbo(bool turbo){ | 
					
						
							|  |  |  |   ui->widePlot->setTurbo(turbo); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-17 10:39:18 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_driftSpinBox_valueChanged(int n){ | 
					
						
							|  |  |  |     if(n == DriftingDateTime::drift()){ | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setDrift(n); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_driftSyncButton_clicked(){ | 
					
						
							|  |  |  |     auto now = QDateTime::currentDateTimeUtc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int n = 0; | 
					
						
							|  |  |  |     int nPos = m_TRperiod - (now.time().second() % m_TRperiod); | 
					
						
							|  |  |  |     int nNeg = (now.time().second() % m_TRperiod) - m_TRperiod; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(abs(nNeg) < nPos){ | 
					
						
							|  |  |  |         n = nNeg; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         n = nPos; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setDrift(n * 1000); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_driftSyncEndButton_clicked(){ | 
					
						
							|  |  |  |     auto now = QDateTime::currentDateTimeUtc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int n = 0; | 
					
						
							|  |  |  |     int nPos = m_TRperiod - (now.time().second() % m_TRperiod); | 
					
						
							|  |  |  |     int nNeg = (now.time().second() % m_TRperiod) - m_TRperiod; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(abs(nNeg) < nPos){ | 
					
						
							|  |  |  |         n = nNeg + 2; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         n = nPos - 2; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setDrift(n * 1000); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_driftSyncMinuteButton_clicked(){ | 
					
						
							|  |  |  |     auto now = QDateTime::currentDateTimeUtc(); | 
					
						
							|  |  |  |     int n = 0; | 
					
						
							|  |  |  |     int s = now.time().second(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(s < 30){ | 
					
						
							|  |  |  |         n = -s; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         n = 60 - s; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setDrift(n * 1000); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::on_driftSyncResetButton_clicked(){ | 
					
						
							|  |  |  |     setDrift(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setDrift(int n){ | 
					
						
							|  |  |  |     DriftingDateTime::setDrift(n); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qDebug() << qSetRealNumberPrecision(12) << "Drift milliseconds:" << n; | 
					
						
							|  |  |  |     qDebug() << qSetRealNumberPrecision(12) << "Clock time:" << QDateTime::currentDateTimeUtc(); | 
					
						
							|  |  |  |     qDebug() << qSetRealNumberPrecision(12) << "Drifted time:" << DriftingDateTime::currentDateTimeUtc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(ui->driftSpinBox->value() != n){ | 
					
						
							|  |  |  |         ui->driftSpinBox->setValue(n); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-17 12:43:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | void WideGraph::setQSYEnabled(bool enabled){ | 
					
						
							|  |  |  |     ui->qsyPushButton->setEnabled(enabled); | 
					
						
							|  |  |  |     ui->centerSpinBox->setEnabled(enabled); | 
					
						
							|  |  |  | } |