2019-01-13 01:53:16 +08:00
|
|
|
/** \example formwithjkqtplotter.cpp
|
2019-01-20 23:15:10 +08:00
|
|
|
* JKQTPlotter: Examples: Using a JKQTPlotter inside a Qt User Interface Designer (UI) File
|
2019-01-13 01:53:16 +08:00
|
|
|
*
|
2019-01-20 23:15:10 +08:00
|
|
|
* \ref JKQTPlotterQtCreator
|
2019-01-13 01:53:16 +08:00
|
|
|
*/
|
|
|
|
|
2022-08-27 04:32:48 +08:00
|
|
|
#include "jkqtpexampleapplication.h"
|
2019-01-09 03:02:05 +08:00
|
|
|
#include "formwithjkqtplotter.h"
|
|
|
|
#include "ui_formwithjkqtplotter.h"
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
FormWithJKQTPlotter::FormWithJKQTPlotter(QWidget *parent) :
|
2019-01-09 03:02:05 +08:00
|
|
|
QWidget(parent),
|
2019-01-20 23:15:10 +08:00
|
|
|
ui(new Ui::FormWithJKQTPlotter)
|
2019-01-09 03:02:05 +08:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2019-01-20 17:49:29 +08:00
|
|
|
graph=new JKQTPXParsedFunctionLineGraph(ui->plot);
|
2019-01-26 20:00:40 +08:00
|
|
|
graph->setFunction(ui->edtEquation->text());
|
|
|
|
graph->setTitle(ui->edtEquation->text());
|
2019-01-09 03:02:05 +08:00
|
|
|
ui->plot->addGraph(graph);
|
|
|
|
ui->plot->setXY(-10,10,-10,10);
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
FormWithJKQTPlotter::~FormWithJKQTPlotter()
|
2019-01-09 03:02:05 +08:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
void FormWithJKQTPlotter::on_chkLogX_toggled(bool checked)
|
2019-01-09 03:02:05 +08:00
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
ui->plot->getXAxis()->setLogAxis(checked);
|
2019-01-09 03:02:05 +08:00
|
|
|
if (checked) {
|
|
|
|
ui->plot->setX(1e-3,10);
|
|
|
|
} else {
|
|
|
|
ui->plot->setX(-10,10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
void FormWithJKQTPlotter::on_chkLogY_toggled(bool checked)
|
2019-01-09 03:02:05 +08:00
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
ui->plot->getYAxis()->setLogAxis(checked);
|
2019-01-09 03:02:05 +08:00
|
|
|
if (checked) {
|
|
|
|
ui->plot->setY(1e-3,10);
|
|
|
|
} else {
|
|
|
|
ui->plot->setY(-10,10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
void FormWithJKQTPlotter::on_btnReplot_clicked()
|
2019-01-09 03:02:05 +08:00
|
|
|
{
|
2019-01-26 20:00:40 +08:00
|
|
|
graph->setFunction(ui->edtEquation->text());
|
|
|
|
graph->setTitle(ui->edtEquation->text());
|
2019-01-26 19:28:44 +08:00
|
|
|
ui->plot->redrawPlot();
|
2019-01-09 03:02:05 +08:00
|
|
|
}
|