File: mainwindow.cpp

package info (click to toggle)
wsjtx 2.0.0%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 192,624 kB
  • sloc: cpp: 1,071,838; ansic: 60,751; f90: 25,266; python: 20,318; sh: 10,636; xml: 8,148; cs: 2,121; fortran: 2,051; yacc: 472; asm: 353; makefile: 316; perl: 19
file content (58 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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);
}