2018-12-29 00:46:47 +08:00
|
|
|
|
#include "TestWidgetLogGraphs.h"
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDate>
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define N2 50
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestWidgetLogGraphs::TestWidgetLogGraphs(QWidget *parent) :
|
|
|
|
|
QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
|
JKQTPlotter* plotLOG=new JKQTPlotter(this);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->setPlotUpdateEnabled(false);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
plotLOG->setObjectName("plotLOG");
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->getPlotter()->setUserSettigsFilename(QApplication::applicationDirPath()+"/usersettings.ini", "plotLOG/");
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
|
JKQTPDatastore* ds=plotLOG->getPlotter()->getDatastore();
|
2018-12-29 00:46:47 +08:00
|
|
|
|
QVector<double> x,y;
|
|
|
|
|
for (unsigned int i=0; i<N2; i++) {
|
|
|
|
|
const double xx=static_cast<double>(i+1)/static_cast<double>(N2)*15.0;
|
|
|
|
|
x<<xx;
|
|
|
|
|
y<<pow(5,xx/5.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t cx2=ds->addCopiedColumn(x, "x2");
|
|
|
|
|
size_t cy23=ds->addCopiedColumn(y, "y23");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* layout=new QVBoxLayout();
|
|
|
|
|
layout->addWidget(plotLOG);
|
|
|
|
|
QFormLayout* layWid=new QFormLayout;
|
|
|
|
|
layout->addLayout(layWid);
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
resize(1000, 800);
|
|
|
|
|
|
|
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->getPlotter()->addGraph(cx2, cy23, "data, $f(x)=5^{x/5}$", JKQTPLines);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
|
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->setPlotUpdateEnabled(true);
|
|
|
|
|
plotLOG->getPlotter()->zoomToFit(true, true);//, true);
|
|
|
|
|
plotLOG->getPlotter()->setKeyAutosize(true);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
|
|
|
|
QCheckBox* chklogX=new QCheckBox("logarithmic X-axis", this);
|
|
|
|
|
QCheckBox* chklogY=new QCheckBox("logarithmic Y-axis", this);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(chklogX, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getXAxis(), SLOT(set_logAxis(bool)));
|
|
|
|
|
connect(chklogY, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getYAxis(), SLOT(set_logAxis(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addWidget(chklogX);
|
|
|
|
|
layWid->addWidget(chklogY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QCheckBox* chkXMinorTicks=new QCheckBox("minor X-tick labels", this);
|
|
|
|
|
QCheckBox* chkYMinorTicks=new QCheckBox("minor Y-tick labels", this);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(chkXMinorTicks, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getXAxis(), SLOT(set_minorTickLabelsEnabled(bool)));
|
|
|
|
|
connect(chkYMinorTicks, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getYAxis(), SLOT(set_minorTickLabelsEnabled(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addWidget(chkXMinorTicks);
|
|
|
|
|
layWid->addWidget(chkYMinorTicks);
|
|
|
|
|
|
|
|
|
|
QCheckBox* chkFullNumberMinor=new QCheckBox("full minor numbers", this);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(chkFullNumberMinor, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getXAxis(), SLOT(set_minorTickLabelFullNumber(bool)));
|
|
|
|
|
connect(chkFullNumberMinor, SIGNAL(toggled(bool)), plotLOG->getPlotter()->getYAxis(), SLOT(set_minorTickLabelFullNumber(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addWidget(chkFullNumberMinor);
|
|
|
|
|
|
|
|
|
|
QComboBox* cmbTickMode=new QComboBox(this);
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMLinOrLog");
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMLin");
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMPower");
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(cmbTickMode, SIGNAL(currentIndexChanged(int)), plotLOG->getPlotter()->getXAxis(), SLOT(set_tickMode(int)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addRow("X-Axis TickMode", cmbTickMode);
|
|
|
|
|
|
|
|
|
|
cmbTickMode=new QComboBox(this);
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMLinOrLog");
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMLin");
|
|
|
|
|
cmbTickMode->addItem("JKQTPLTMPower");
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(cmbTickMode, SIGNAL(currentIndexChanged(int)), plotLOG->getPlotter()->getYAxis(), SLOT(set_tickMode(int)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addRow("Y-Axis TickMode", cmbTickMode);
|
|
|
|
|
cmbTickMode->setCurrentIndex(0);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->getPlotter()->getYAxis()->set_tickMode(JKQTPLTMLinOrPower);
|
|
|
|
|
plotLOG->getPlotter()->getYAxis()->set_minorTicks(1);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
|
plotLOG->getPlotter()->getYAxis()->set_drawMode2(JKQTPCADMcomplete);
|
|
|
|
|
plotLOG->getPlotter()->getXAxis()->set_drawMode2(JKQTPCADMcomplete);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSpinBox* spinMinTicks=new QSpinBox(this);
|
|
|
|
|
spinMinTicks->setRange(0,999);
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(spinMinTicks, SIGNAL(valueChanged(int)), plotLOG->getPlotter()->getXAxis(), SLOT(set_minorTicks(int)));
|
|
|
|
|
connect(spinMinTicks, SIGNAL(valueChanged(int)), plotLOG->getPlotter()->getYAxis(), SLOT(set_minorTicks(int)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addRow("X/Y-axis minor tick count", spinMinTicks);
|
|
|
|
|
spinMinTicks->setValue(1);
|
|
|
|
|
|
|
|
|
|
QDoubleSpinBox* spinLOGAngle=new QDoubleSpinBox(this);
|
|
|
|
|
spinLOGAngle->setRange(-90,90);
|
|
|
|
|
spinLOGAngle->setSuffix(QLatin1String("<EFBFBD>"));
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(spinLOGAngle, SIGNAL(valueChanged(double)), plotLOG->getPlotter()->getXAxis(), SLOT(set_tickLabelAngle(double)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addRow("X-Axis tick label angle", spinLOGAngle);
|
|
|
|
|
spinLOGAngle->setValue(0);
|
|
|
|
|
|
|
|
|
|
spinLOGAngle=new QDoubleSpinBox(this);
|
|
|
|
|
spinLOGAngle->setRange(-90,90);
|
|
|
|
|
spinLOGAngle->setSuffix(QLatin1String("<EFBFBD>"));
|
2019-01-26 03:16:04 +08:00
|
|
|
|
connect(spinLOGAngle, SIGNAL(valueChanged(double)), plotLOG->getPlotter()->getYAxis(), SLOT(set_tickLabelAngle(double)));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
layWid->addRow(tr("Y-axis label angle = "), spinLOGAngle);
|
|
|
|
|
spinLOGAngle->setValue(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|