mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-16 02:25:50 +08:00
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
/** \example formwithjkqtplotter.cpp
|
|
* JKQTPlotter: Examples: Using a JKQTPlotter inside a Qt User Interface Designer (UI) File
|
|
*
|
|
* \ref JKQTPlotterQtCreator
|
|
*/
|
|
|
|
#include "formwithjkqtplotter.h"
|
|
#include "ui_formwithjkqtplotter.h"
|
|
|
|
FormWithJKQTPlotter::FormWithJKQTPlotter(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::FormWithJKQTPlotter)
|
|
{
|
|
ui->setupUi(this);
|
|
graph=new JKQTPXParsedFunctionLineGraph(ui->plot);
|
|
graph->set_function(ui->edtEquation->text());
|
|
graph->set_title(ui->edtEquation->text());
|
|
ui->plot->addGraph(graph);
|
|
ui->plot->setXY(-10,10,-10,10);
|
|
}
|
|
|
|
FormWithJKQTPlotter::~FormWithJKQTPlotter()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void FormWithJKQTPlotter::on_chkLogX_toggled(bool checked)
|
|
{
|
|
ui->plot->getXAxis()->set_logAxis(checked);
|
|
if (checked) {
|
|
ui->plot->setX(1e-3,10);
|
|
} else {
|
|
ui->plot->setX(-10,10);
|
|
}
|
|
}
|
|
|
|
void FormWithJKQTPlotter::on_chkLogY_toggled(bool checked)
|
|
{
|
|
ui->plot->getYAxis()->set_logAxis(checked);
|
|
if (checked) {
|
|
ui->plot->setY(1e-3,10);
|
|
} else {
|
|
ui->plot->setY(-10,10);
|
|
}
|
|
}
|
|
|
|
void FormWithJKQTPlotter::on_btnReplot_clicked()
|
|
{
|
|
graph->set_function(ui->edtEquation->text());
|
|
graph->set_title(ui->edtEquation->text());
|
|
ui->plot->redrawPlot();
|
|
}
|