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
|
|
|
*/
|
|
|
|
|
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-09 03:02:05 +08:00
|
|
|
graph->set_function(ui->edtEquation->text());
|
|
|
|
graph->set_title(ui->edtEquation->text());
|
|
|
|
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 03:16:04 +08:00
|
|
|
ui->plot->getXAxis()->set_logAxis(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 03:16:04 +08:00
|
|
|
ui->plot->getYAxis()->set_logAxis(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
|
|
|
{
|
|
|
|
graph->set_function(ui->edtEquation->text());
|
|
|
|
graph->set_title(ui->edtEquation->text());
|
2019-01-26 03:16:04 +08:00
|
|
|
ui->plot->replotPlot();
|
2019-01-09 03:02:05 +08:00
|
|
|
}
|