summaryrefslogtreecommitdiff
path: root/plots/mainwindow.cpp
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2018-02-16 15:18:44 +0000
committerhibby <d@vehibberd.com>2018-02-16 15:18:44 +0000
commit368f5331a7641772aa7e0cd1feea57d09a394a36 (patch)
treeb421ac60cc6eb726896ea268ea24e47fc4ce7c88 /plots/mainwindow.cpp
parent71c717edc92fa771c857b3c2e5ed65f523f68f90 (diff)
parent37f727ac0746fd85504aa46c1f023c09b3eff33a (diff)
Update upstream source from tag 'upstream/1.8.0+repack'
Update to upstream version '1.8.0+repack' with Debian dir a83ef78cb70a32d1211871fdc08f3ffa295e45a8
Diffstat (limited to 'plots/mainwindow.cpp')
-rw-r--r--plots/mainwindow.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/plots/mainwindow.cpp b/plots/mainwindow.cpp
new file mode 100644
index 00000000..775f1f35
--- /dev/null
+++ b/plots/mainwindow.cpp
@@ -0,0 +1,58 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include <QDebug>
+#include <QDesktopWidget>
+#include <QScreen>
+#include <QMessageBox>
+#include <QMetaEnum>
+
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+#define NPTS 3456
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+ setGeometry(400, 250, 542, 390);
+
+ setupPlot();
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::setupPlot()
+{
+ plotspec(ui->customPlot);
+ setWindowTitle("Reference Spectrum");
+ statusBar()->clearMessage();
+ ui->customPlot->replot();
+}
+
+void MainWindow::plotspec(QCustomPlot *customPlot)
+{
+ QVector<double> x(NPTS), y1(NPTS), y2(NPTS), y3(NPTS), y4(NPTS);
+ ifstream inFile;
+ double ymin=1.0e30;
+ double ymax=-ymin;
+ inFile.open("c:/users/joe/appdata/local/WSJT-X/refspec.dat");
+
+ for (int i = 0; i < NPTS; i++) {
+ inFile >> x[i] >> y1[i] >> y2[i] >> y3[3] >> y4[4];
+ if(y2[i]>ymax) ymax=y2[i];
+ if(y2[i]<ymin) ymin=y2[i];
+ }
+
+ customPlot->addGraph();
+ customPlot->graph(0)->setData(x, y2);
+ customPlot->xAxis->setLabel("Frequency (Hz)");
+ customPlot->yAxis->setLabel("Relative power (dB)");
+ customPlot->xAxis->setRange(0, 6000);
+ customPlot->yAxis->setRange(ymin, ymax);
+}