Пример #1
0
void FilterDialog::filter()
{
	double from = boxStart->value();
	double to = 0.0;
	if (filter_type >= FFTFilter::BandPass){
		to = boxEnd->value();
		if (from >= to){
			QMessageBox::critical(this, tr("QtiPlot - Frequency input error"),
				tr("Please enter frequency limits that satisfy: Low < High !"));
			boxEnd->setFocus();
			return;
		}
	}

	FFTFilter *f = new FFTFilter((ApplicationWindow *)this->parent(), graph, boxName->currentText(), filter_type);
	if (filter_type == FFTFilter::BandPass){
    	f->setBand(from, to);
    	f->enableOffset(boxOffset->isChecked());
    } else if (filter_type == FFTFilter::BandBlock){
    	f->setBand(from, to);
    	f->enableOffset(!boxOffset->isChecked());
    } else
    	f->setCutoff(from);

	f->setColor(boxColor->color());
	f->run();
	delete f;
}
Пример #2
0
void FilterDialog::filter() {
  double from = 0.0, to = 0.0;
  try {
    MyParser parser;
    parser.SetExpr(boxStart->text().replace(",", ".").toAscii().constData());
    from = parser.Eval();
  } catch (mu::ParserError &e) {
    QMessageBox::critical(this, tr("MantidPlot - Frequency input error"),
                          QString::fromStdString(e.GetMsg()));
    boxStart->setFocus();
    return;
  }

  if (from < 0) {
    QMessageBox::critical(this, tr("MantidPlot - Frequency input error"),
                          tr("Please enter positive frequency values!"));
    boxStart->setFocus();
    return;
  }

  if (filter_type >= FFTFilter::BandPass) {
    try {
      MyParser parser;
      parser.SetExpr(boxEnd->text().replace(",", ".").toAscii().constData());
      to = parser.Eval();
    } catch (mu::ParserError &e) {
      QMessageBox::critical(this, tr("MantidPlot - High Frequency input error"),
                            QString::fromStdString(e.GetMsg()));
      boxEnd->setFocus();
      return;
    }

    if (to < 0) {
      QMessageBox::critical(this, tr("MantidPlot - High Frequency input error"),
                            tr("Please enter positive frequency values!"));
      boxEnd->setFocus();
      return;
    }

    if (from >= to) {
      QMessageBox::critical(
          this, tr("MantidPlot - Frequency input error"),
          tr("Please enter frequency limits that satisfy: Low < High !"));
      boxEnd->setFocus();
      return;
    }
  }

  FFTFilter *f = new FFTFilter(dynamic_cast<ApplicationWindow *>(parent()),
                               graph, boxName->currentText(), filter_type);
  if (filter_type == FFTFilter::BandPass) {
    f->setBand(from, to);
    f->enableOffset(boxOffset->isChecked());
  } else if (filter_type == FFTFilter::BandBlock) {
    f->setBand(from, to);
    f->enableOffset(!boxOffset->isChecked());
  } else
    f->setCutoff(from);

  f->setColor(boxColor->currentIndex());
  f->run();
  delete f;
}