init
This commit is contained in:
35496
dmplot/core/qcustomplot.cpp
Normal file
35496
dmplot/core/qcustomplot.cpp
Normal file
File diff suppressed because it is too large
Load Diff
7737
dmplot/core/qcustomplot.h
Normal file
7737
dmplot/core/qcustomplot.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
dmplot/plots/balboa.jpg
Normal file
BIN
dmplot/plots/balboa.jpg
Normal file
Binary file not shown.
39
dmplot/plots/main.cpp
Normal file
39
dmplot/plots/main.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************
|
||||
** **
|
||||
** QCustomPlot, an easy to use, modern plotting widget for Qt **
|
||||
** Copyright (C) 2011-2021 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: 29.03.21 **
|
||||
** Version: 2.1.0 **
|
||||
****************************************************************************/
|
||||
|
||||
#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();
|
||||
}
|
||||
22
dmplot/plots/plot-examples.pro
Normal file
22
dmplot/plots/plot-examples.pro
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# QCustomPlot Plot Examples
|
||||
#
|
||||
|
||||
QT += core gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11
|
||||
lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
TARGET = plot-examples
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
../../qcustomplot.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
../../qcustomplot.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
BIN
dmplot/plots/solarpanels.jpg
Normal file
BIN
dmplot/plots/solarpanels.jpg
Normal file
Binary file not shown.
BIN
dmplot/plots/sun.png
Normal file
BIN
dmplot/plots/sun.png
Normal file
Binary file not shown.
18
dmplot/ui/dmplot.cpp
Normal file
18
dmplot/ui/dmplot.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "dmplot.h"
|
||||
|
||||
DMPlot::DMPlot(const QString& title,QWidget* parent)
|
||||
:QDockWidget(title,parent)
|
||||
,plotWidget(new PlotWidget(this))
|
||||
{
|
||||
auto frame = new QFrame(this);
|
||||
auto layout = new QVBoxLayout;
|
||||
frame->setLayout(layout);
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(plotWidget);
|
||||
setWidget(frame);
|
||||
|
||||
connect(this,&DMPlot::appendValuetoPlotSGL,plotWidget,&PlotWidget::appentDataDisplaySlot);
|
||||
|
||||
}
|
||||
|
||||
22
dmplot/ui/dmplot.h
Normal file
22
dmplot/ui/dmplot.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DMPLOT_H
|
||||
#define DMPLOT_H
|
||||
|
||||
#include"plotwidget.h"
|
||||
#include <QDockWidget>
|
||||
|
||||
|
||||
class DMPlot: public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void appendValuetoPlotSGL(double value);
|
||||
|
||||
public:
|
||||
DMPlot(const QString& title,QWidget* parent = 0);
|
||||
protected:
|
||||
PlotWidget* plotWidget;
|
||||
|
||||
};
|
||||
|
||||
#endif // DMPLOT_H
|
||||
1599
dmplot/ui/mainwindow.cpp
Normal file
1599
dmplot/ui/mainwindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
100
dmplot/ui/mainwindow.h
Normal file
100
dmplot/ui/mainwindow.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
** **
|
||||
** QCustomPlot, an easy to use, modern plotting widget for Qt **
|
||||
** Copyright (C) 2011-2021 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: 29.03.21 **
|
||||
** Version: 2.1.0 **
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************************************
|
||||
** **
|
||||
** 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 <QMainWindow>
|
||||
#include <QTimer>
|
||||
#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.
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
void setupDemo(int demoIndex);
|
||||
void setupQuadraticDemo(QCustomPlot *customPlot);
|
||||
void setupSimpleDemo(QCustomPlot *customPlot);
|
||||
void setupSincScatterDemo(QCustomPlot *customPlot);
|
||||
void setupScatterStyleDemo(QCustomPlot *customPlot);
|
||||
void setupLineStyleDemo(QCustomPlot *customPlot);
|
||||
void setupScatterPixmapDemo(QCustomPlot *customPlot);
|
||||
void setupDateDemo(QCustomPlot *customPlot);
|
||||
void setupTextureBrushDemo(QCustomPlot *customPlot);
|
||||
void setupMultiAxisDemo(QCustomPlot *customPlot);
|
||||
void setupLogarithmicDemo(QCustomPlot *customPlot);
|
||||
void setupRealtimeDataDemo(QCustomPlot *customPlot);
|
||||
void setupParametricCurveDemo(QCustomPlot *customPlot);
|
||||
void setupBarChartDemo(QCustomPlot *customPlot);
|
||||
void setupStatisticalDemo(QCustomPlot *customPlot);
|
||||
void setupSimpleItemDemo(QCustomPlot *customPlot);
|
||||
void setupItemDemo(QCustomPlot *customPlot);
|
||||
void setupStyledDemo(QCustomPlot *customPlot);
|
||||
void setupAdvancedAxesDemo(QCustomPlot *customPlot);
|
||||
void setupColorMapDemo(QCustomPlot *customPlot);
|
||||
void setupFinancialDemo(QCustomPlot *customPlot);
|
||||
void setupPolarPlotDemo(QCustomPlot *customPlot);
|
||||
|
||||
void setupPlayground(QCustomPlot *customPlot);
|
||||
|
||||
private slots:
|
||||
void realtimeDataSlot();
|
||||
void bracketDataSlot();
|
||||
void screenShot();
|
||||
void allScreenShots();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QString demoName;
|
||||
QTimer dataTimer;
|
||||
QCPItemTracer *itemDemoPhaseTracer;
|
||||
int currentDemoIndex;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
36
dmplot/ui/mainwindow.ui
Normal file
36
dmplot/ui/mainwindow.ui
Normal file
@@ -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 location="global">qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
125
dmplot/ui/plotwidget.cpp
Normal file
125
dmplot/ui/plotwidget.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
#include "plotwidget.h"
|
||||
#include "ui_plotwidget.h"
|
||||
#include <QDebug>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
# include <QDesktopWidget>
|
||||
#endif
|
||||
#include <QScreen>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
|
||||
PlotWidget::PlotWidget(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::PlotWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setGeometry(400, 250, 542, 390);
|
||||
setupItemDemo(ui->customPlot);
|
||||
statusBar()->clearMessage();
|
||||
ui->customPlot->replot();
|
||||
}
|
||||
|
||||
|
||||
void PlotWidget::setupItemDemo(QCustomPlot *customPlot)
|
||||
{
|
||||
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
|
||||
QCPGraph *graph = customPlot->addGraph();
|
||||
|
||||
graph->setData(x, y);
|
||||
graph->setPen(QPen(Qt::blue));
|
||||
graph->rescaleKeyAxis();
|
||||
customPlot->yAxis->setRange(-1.45, 1.65);
|
||||
customPlot->xAxis->setRange(1,500);
|
||||
customPlot->xAxis->grid()->setZeroLinePen(Qt::NoPen);
|
||||
}
|
||||
|
||||
|
||||
void PlotWidget::appentDataDisplaySlot(double yValue)
|
||||
{
|
||||
double secs = QCPAxisTickerDateTime::dateTimeToKey(QDateTime::currentDateTime());
|
||||
|
||||
|
||||
if(0!=xNum)
|
||||
{
|
||||
y.append(yValue);
|
||||
x.insert(0,xNum);
|
||||
xNum--;
|
||||
}
|
||||
else
|
||||
{
|
||||
y.remove(0);
|
||||
y.append(yValue);
|
||||
}
|
||||
ui->customPlot->graph()->setData(x,y);
|
||||
ui->customPlot->replot();
|
||||
|
||||
// calculate frames per second:
|
||||
// double key = secs;
|
||||
// static double lastFpsKey;
|
||||
// static int frameCount;
|
||||
// ++frameCount;
|
||||
// if (key-lastFpsKey > 2) // average fps over 2 seconds
|
||||
// {
|
||||
// ui->statusBar->showMessage(
|
||||
// QString("%1 FPS, Total Data points: %2")
|
||||
// .arg(frameCount/(key-lastFpsKey), 0, 'f', 0)
|
||||
// .arg(ui->customPlot->graph(0)->data()->size())
|
||||
// , 0);
|
||||
// lastFpsKey = key;
|
||||
// frameCount = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
PlotWidget::~PlotWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PlotWidget::setPlotDataCount(int value)
|
||||
{
|
||||
n = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
33
dmplot/ui/plotwidget.h
Normal file
33
dmplot/ui/plotwidget.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef POLTWIDGET_H
|
||||
#define POLTWIDGET_H
|
||||
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include "qcustomplot.h"
|
||||
|
||||
namespace Ui {
|
||||
class PlotWidget;
|
||||
}
|
||||
|
||||
class PlotWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlotWidget(QWidget *parent = 0);
|
||||
~PlotWidget();
|
||||
void setupItemDemo(QCustomPlot *customPlot);
|
||||
|
||||
public slots:
|
||||
void appentDataDisplaySlot(double yValue=0);
|
||||
void setPlotDataCount(int value);
|
||||
|
||||
private:
|
||||
Ui::PlotWidget *ui;
|
||||
int n{500};
|
||||
int xNum{n};
|
||||
QVector<double> x, y;
|
||||
};
|
||||
|
||||
#endif // POLTWIDGET_H
|
||||
36
dmplot/ui/plotwidget.ui
Normal file
36
dmplot/ui/plotwidget.ui
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PlotWidget</class>
|
||||
<widget class="QMainWindow" name="PlotWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>238</width>
|
||||
<height>239</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 location="global">qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user