Exemple #1
0
void IntDialog::accept() {
  QString formula = boxName->toPlainText().remove("\n");
  Integration *i =
      new Integration(formula, boxVariable->text(),
                      dynamic_cast<ApplicationWindow *>(this->parent()),
                      d_graph, boxStart->value(), boxEnd->value());
  i->setTolerance(boxTol->text().toDouble());
  i->setMaximumIterations(boxSteps->value());
  i->setMethodOrder(boxOrder->value());
  if (d_graph && boxPlot->isChecked())
    i->enableGraphicsDisplay(true, d_graph);
  i->run();
  delete i;
}
void IntDialog::accept()
{
QString curveName = boxName->currentText();
QwtPlotCurve *c = graph->curve(curveName);
QStringList curvesList = graph->analysableCurvesList();
if (!c || !curvesList.contains(curveName))
	{
	QMessageBox::critical((ApplicationWindow *)parent(), tr("QtiPlot") +" - "+ tr("Warning"),
		tr("The curve <b> %1 </b> doesn't exist anymore! Operation aborted!").arg(curveName));
	boxName->clear();
	boxName->insertStringList(curvesList);
	return;
	}

try
	{
	mu::Parser parser;
	parser.SetExpr(boxTol->text().ascii());
	parser.Eval();
	}
catch(mu::ParserError &e)
	{
	QMessageBox::critical((ApplicationWindow *)parent(),tr("QtiPlot - Tolerance value error"),QString::fromStdString(e.GetMsg()));
	boxTol->clear();
	boxTol->setFocus();
	return;
	}

double start = 0, stop = 0;
double minx = c->minXValue();
double maxx = c->maxXValue();

// Check the Xmin
QString from = boxStart->text().lower();
if(from=="min")
	{
	boxStart->setText(QString::number(minx));
	return;
	}
else if(from=="max")
	{
	boxStart->setText(QString::number(maxx));
	return;
	}
else
	{
	try
		{
		MyParser parser;
		parser.SetExpr((boxStart->text()).ascii());
		start=parser.Eval();

		if(start<minx)
			{
			QMessageBox::warning((ApplicationWindow *)parent(), tr("QtiPlot - Input error"),
				tr("Please give a number larger or equal to the minimum value of X, for the lower limit.\n If you do not know that value, type min in the box."));
			boxStart->clear();
			boxStart->setFocus();
			return;
		}
		if(start > maxx)
			{
			QMessageBox::warning((ApplicationWindow *)parent(), tr("QtiPlot - Input error"),
				tr("Please give a number smaller or equal to the maximum value of X, for the lower limit.\n If you do not know that value, type max in the box."));
			boxStart->clear();
			boxStart->setFocus();
			return;
			}
		}
	catch(mu::ParserError &e)
		{
		QMessageBox::critical((ApplicationWindow *)parent(),tr("QtiPlot - Start limit error"),QString::fromStdString(e.GetMsg()));
		boxStart->clear();
		boxStart->setFocus();
		return;
		}
	}

// Check Xmax
QString end=boxEnd->text().lower();
if(end=="min")
	{
	boxEnd->setText(QString::number(minx));
	return;
	}
else if(end=="max")
	{
	boxEnd->setText(QString::number(maxx));
	return;
	}
else
	{
	try
		{
		MyParser parser;
		parser.SetExpr((boxEnd->text()).ascii());
		stop = parser.Eval();
		if(stop > maxx)
			{
			//FIXME: I don't understand why this doesn't work for FunctionCurves!!(Ion)
			/*QMessageBox::warning((ApplicationWindow *)parent(), tr("QtiPlot - Input error"),
				tr("Please give a number smaller or equal to the maximum value of X, for the upper limit.\n If you do not know that value, type max in the box."));
			boxEnd->clear();
			boxEnd->setFocus();
			return;
			*/
			boxEnd->setText(QString::number(maxx));
			}
		if(stop < minx)
			{
			QMessageBox::warning((ApplicationWindow *)parent(), tr("QtiPlot - Input error"),
				tr("Please give a number larger or equal to the minimum value of X, for the upper limit.\n If you do not know that value, type min in the box."));
			boxEnd->clear();
			boxEnd->setFocus();
			return;
			}
		}
	catch(mu::ParserError &e)
		{
		QMessageBox::critical((ApplicationWindow *)parent(), tr("QtiPlot - End limit error"),QString::fromStdString(e.GetMsg()));
		boxEnd->clear();
		boxEnd->setFocus();
		return;
		}
	}

Integration *i = new Integration((ApplicationWindow *)this->parent(), graph, curveName,
                                 boxStart->text().toDouble(), boxEnd->text().toDouble());
i->setTolerance(boxTol->text().toDouble());
i->setMaximumIterations(boxSteps->value());
i->setMethod(boxOrder->value());
i->run();
delete i;
}