diff --git a/plots/mainwindow.cpp b/plots/mainwindow.cpp index b80e3b888..775f1f354 100644 --- a/plots/mainwindow.cpp +++ b/plots/mainwindow.cpp @@ -1,44 +1,3 @@ -/*************************************************************************** -** ** -** 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 ** -****************************************************************************/ - -/************************************************************************************************************ -** ** -** This is the example code for QCustomPlot. ** -** ** -** It demonstrates basic and some advanced capabilities of the widget. The interesting code is inside ** -** the "setup(...)Demo" functions of MainWindow. ** -** ** -** In order to see a demo in action, call the respective "setup(...)Demo" function inside the ** -** MainWindow constructor. Alternatively you may call setupDemo(i) where i is the index of the demo ** -** you want (for those, see MainWindow constructor comments). All other functions here are merely a ** -** way to easily create screenshots of all demos for the website. I.e. a timer is set to successively ** -** setup all the demos and make a screenshot of the window area and save it in the ./screenshots ** -** directory. ** -** ** -*************************************************************************************************************/ - #include "mainwindow.h" #include "ui_mainwindow.h" #include @@ -51,6 +10,7 @@ #include using namespace std; +#define NPTS 3456 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -59,7 +19,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); setGeometry(400, 250, 542, 390); - setupDemo(0); + setupPlot(); } MainWindow::~MainWindow() @@ -67,24 +27,16 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::setupDemo(int demoIndex) +void MainWindow::setupPlot() { - switch (demoIndex) - { - case 0: setupQuadraticDemo(ui->customPlot); break; - } - setWindowTitle("QCustomPlot: "+demoName); + plotspec(ui->customPlot); + setWindowTitle("Reference Spectrum"); statusBar()->clearMessage(); - currentDemoIndex = demoIndex; ui->customPlot->replot(); } -void MainWindow::setupQuadraticDemo(QCustomPlot *customPlot) +void MainWindow::plotspec(QCustomPlot *customPlot) { - demoName = "Reference Spectrum"; - -#define NPTS 3456 - QVector x(NPTS), y1(NPTS), y2(NPTS), y3(NPTS), y4(NPTS); ifstream inFile; double ymin=1.0e30; @@ -96,6 +48,7 @@ void MainWindow::setupQuadraticDemo(QCustomPlot *customPlot) if(y2[i]>ymax) ymax=y2[i]; if(y2[i]addGraph(); customPlot->graph(0)->setData(x, y2); customPlot->xAxis->setLabel("Frequency (Hz)"); diff --git a/plots/mainwindow.h b/plots/mainwindow.h index e322bffb7..cd8d4569e 100644 --- a/plots/mainwindow.h +++ b/plots/mainwindow.h @@ -1,50 +1,9 @@ -/*************************************************************************** -** ** -** 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 ** -****************************************************************************/ - -/************************************************************************************************************ -** ** -** This is the example code for QCustomPlot. ** -** ** -** It demonstrates basic and some advanced capabilities of the widget. The interesting code is inside ** -** the "setup(...)Demo" functions of MainWindow. ** -** ** -** In order to see a demo in action, call the respective "setup(...)Demo" function inside the ** -** MainWindow constructor. Alternatively you may call setupDemo(i) where i is the index of the demo ** -** you want (for those, see MainWindow constructor comments). All other functions here are merely a ** -** way to easily create screenshots of all demos for the website. I.e. a timer is set to successively ** -** setup all the demos and make a screenshot of the window area and save it in the ./screenshots ** -** directory. ** -** ** -*************************************************************************************************************/ - #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include -#include "qcustomplot.h" // the header file of QCustomPlot. Don't forget to add it to your project, if you use an IDE, so it gets compiled. +#include "qcustomplot.h" namespace Ui { class MainWindow; @@ -58,15 +17,11 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); - void setupDemo(int demoIndex); - void setupQuadraticDemo(QCustomPlot *customPlot); + void setupPlot(); + void plotspec(QCustomPlot *customPlot); private: Ui::MainWindow *ui; - QString demoName; - QTimer dataTimer; - QCPItemTracer *itemDemoPhaseTracer; - int currentDemoIndex; }; #endif // MAINWINDOW_H diff --git a/plots/plot-examples.pro.user b/plots/plot-examples.pro.user index 09e24a08e..03549af97 100644 --- a/plots/plot-examples.pro.user +++ b/plots/plot-examples.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId