Initial Commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************
|
||||
** **
|
||||
** QCustomPlot, an easy to use, modern plotting widget for Qt **
|
||||
** Copyright (C) 2011-2016 Emanuel Eichhammer **
|
||||
** **
|
||||
** This program is free software: you can redistribute it and/or modify **
|
||||
** it under the terms of the GNU General Public License as published by **
|
||||
** the Free Software Foundation, either version 3 of the License, or **
|
||||
** (at your option) any later version. **
|
||||
** **
|
||||
** This program is distributed in the hope that it will be useful, **
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
|
||||
** GNU General Public License for more details. **
|
||||
** **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see http://www.gnu.org/licenses/. **
|
||||
** **
|
||||
****************************************************************************
|
||||
** Author: Emanuel Eichhammer **
|
||||
** Website/Contact: http://www.qcustomplot.com/ **
|
||||
** Date: 13.09.16 **
|
||||
** Version: 2.0.0-beta **
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
QApplication::setGraphicsSystem("raster");
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include "qcustomplot.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
void setupPlot();
|
||||
void plotspec(QCustomPlot *customPlot);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>548</width>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QCustomPlot plot examples</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCustomPlot" name="customPlot" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QCustomPlot</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+29756
File diff suppressed because it is too large
Load Diff
+6628
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# QCustomPlot Plot Examples
|
||||
#
|
||||
|
||||
QT += core gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = refspec
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp mainwindow.cpp qcustomplot.cpp
|
||||
|
||||
HEADERS += mainwindow.h qcustomplot.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
Reference in New Issue
Block a user