2018-12-29 00:46:47 +08:00
|
|
|
#include "TestWidgetFunctionPlots.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDate>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestWidgetFunctionPlots::TestWidgetFunctionPlots(QWidget *parent) :
|
|
|
|
QWidget(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* plotFuncLayout=new QVBoxLayout(this);
|
|
|
|
setLayout(plotFuncLayout);
|
2019-01-20 23:15:10 +08:00
|
|
|
plotFuncPlt=new JKQTPlotter(true, this);
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncLayout->addWidget(plotFuncPlt);
|
2019-01-26 03:16:04 +08:00
|
|
|
pfunc=new JKQTPXParsedFunctionLineGraph(plotFuncPlt->getPlotter());
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setFunction("x^2/10+sin(x*pi*10)");
|
|
|
|
pfunc->setErrorFunction("x^2/20");
|
|
|
|
pfunc->setDrawErrorPolygons(true);
|
2019-04-22 19:27:50 +08:00
|
|
|
pfunc->setLineStyle(Qt::DashLine);
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncPlt->addGraph(pfunc);
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
pfuncErrorStyle=new JKQTPErrorPlotstyleComboBox(this);
|
2018-12-29 00:46:47 +08:00
|
|
|
pfuncErrorStyle->setCurrentIndex(3);
|
|
|
|
plotFuncLayout->addWidget(pfuncErrorStyle);
|
|
|
|
connect(pfuncErrorStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setPFuncStyle()));
|
|
|
|
chkPFuncDrawSamples=new QCheckBox(tr("display samples"), this);
|
|
|
|
plotFuncLayout->addWidget(chkPFuncDrawSamples);
|
|
|
|
connect(chkPFuncDrawSamples, SIGNAL(toggled(bool)), this, SLOT(setPFuncStyle()));
|
|
|
|
chkPFuncDrawLine=new QCheckBox(tr("draw line"), this);
|
|
|
|
chkPFuncDrawLine->setChecked(true);
|
|
|
|
plotFuncLayout->addWidget(chkPFuncDrawLine);
|
|
|
|
connect(chkPFuncDrawLine, SIGNAL(toggled(bool)), this, SLOT(setPFuncStyle()));
|
|
|
|
QSpinBox* spinPFunc=new QSpinBox(this);
|
2019-01-26 20:00:40 +08:00
|
|
|
spinPFunc->setValue(pfunc->getMinSamples());
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncLayout->addWidget(new QLabel(tr("min samples:"), this));
|
|
|
|
plotFuncLayout->addWidget(spinPFunc);
|
|
|
|
connect(spinPFunc, SIGNAL(valueChanged(int)), this, SLOT(setPFuncMinPoint(int)));
|
|
|
|
spinPFunc=new QSpinBox(this);
|
2019-01-26 20:00:40 +08:00
|
|
|
spinPFunc->setValue(pfunc->getMaxRefinementDegree());
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncLayout->addWidget(new QLabel(tr("max refinement degree:"), this));
|
|
|
|
plotFuncLayout->addWidget(spinPFunc);
|
|
|
|
connect(spinPFunc, SIGNAL(valueChanged(int)), this, SLOT(setPFuncMaxRefine(int)));
|
|
|
|
QComboBox* edtPFunc=new QComboBox(this);
|
2019-01-26 20:00:40 +08:00
|
|
|
edtPFunc->addItem(pfunc->getFunction());
|
2018-12-29 00:46:47 +08:00
|
|
|
edtPFunc->addItem("x");
|
|
|
|
edtPFunc->addItem("x^2");
|
|
|
|
edtPFunc->addItem("x^2-x^3");
|
|
|
|
edtPFunc->addItem("sin(x)");
|
|
|
|
edtPFunc->setCurrentIndex(0);
|
|
|
|
plotFuncLayout->addWidget(new QLabel(tr("function:"), this));
|
|
|
|
plotFuncLayout->addWidget(edtPFunc);
|
|
|
|
connect(edtPFunc, SIGNAL(currentIndexChanged(QString)), this, SLOT(setPFunc(QString)));
|
|
|
|
edtPFunc=new QComboBox(this);
|
2019-01-26 20:00:40 +08:00
|
|
|
edtPFunc->addItem(pfunc->getErrorFunction());
|
2018-12-29 00:46:47 +08:00
|
|
|
edtPFunc->addItem("");
|
|
|
|
edtPFunc->addItem("x");
|
|
|
|
edtPFunc->addItem("cos(x)");
|
|
|
|
edtPFunc->addItem("1");
|
|
|
|
edtPFunc->setCurrentIndex(0);
|
|
|
|
plotFuncLayout->addWidget(new QLabel(tr("error function:"), this));
|
|
|
|
plotFuncLayout->addWidget(edtPFunc);
|
|
|
|
connect(edtPFunc, SIGNAL(currentIndexChanged(QString)), this, SLOT(setPFuncE(QString)));
|
|
|
|
QCheckBox* chkFLogX=new QCheckBox(tr("x-axis: log-scale"));
|
|
|
|
chkFLogX->setChecked(false);
|
2019-01-26 20:00:40 +08:00
|
|
|
connect(chkFLogX, SIGNAL(toggled(bool)), plotFuncPlt->getXAxis(), SLOT(setLogAxis(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncLayout->addWidget(chkFLogX);
|
|
|
|
QCheckBox* chkFLogY=new QCheckBox(tr("y-axis: log-scale"));
|
|
|
|
chkFLogY->setChecked(false);
|
2019-01-26 20:00:40 +08:00
|
|
|
connect(chkFLogY, SIGNAL(toggled(bool)), plotFuncPlt->getYAxis(), SLOT(setLogAxis(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
plotFuncLayout->addWidget(chkFLogY);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TestWidgetFunctionPlots::setPFuncStyle()
|
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setDrawErrorLines(false);
|
|
|
|
pfunc->setDrawErrorPolygons(false);
|
|
|
|
if (pfuncErrorStyle->getErrorStyle()==JKQTPErrorLines) pfunc->setDrawErrorLines(true);
|
|
|
|
if (pfuncErrorStyle->getErrorStyle()==JKQTPErrorPolygons) pfunc->setDrawErrorPolygons(true);
|
|
|
|
pfunc->setDrawLine(chkPFuncDrawLine->isChecked());
|
|
|
|
pfunc->setDisplaySamplePoints(chkPFuncDrawSamples->isChecked());
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWidgetFunctionPlots::setPFuncMinPoint(int value)
|
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setMinSamples(value);
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWidgetFunctionPlots::setPFuncMaxRefine(int value)
|
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setMaxRefinementDegree(value);
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWidgetFunctionPlots::setPFunc(const QString &expression)
|
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setFunction(expression);
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWidgetFunctionPlots::setPFuncE(const QString &expression)
|
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
pfunc->setErrorFunction(expression);
|
2019-01-26 19:28:44 +08:00
|
|
|
plotFuncPlt->redrawPlot();
|
2018-12-29 00:46:47 +08:00
|
|
|
}
|