QFDlgCSVParameters::QFDlgCSVParameters(QWidget* parent, QString columnSeparator, QString decimalSeparator, QString commentStart, QString headerStart): QFDialog(parent), ui(new Ui::QFDlgCSVParameters) { colselcombos=0; tabmodel=new QFTableModel(this); ui->setupUi(this); ui->widConfig->registerWidget("column_separator", ui->edtColumn); ui->widConfig->registerWidget("comment_start", ui->edtComment); ui->widConfig->registerWidget("decimal_separator", ui->edtDecimal); ui->widConfig->registerWidget("header_start", ui->edtHeader); ui->widConfig->setFilename(QFPluginServices::getInstance()->getConfigFileDirectory()+QString("/csvdlg_csvconfig.ini")); ui->edtColumn->setText(QString(columnSeparator)); //if (QString(columnSeparator).isEmpty()) ui->edtColumn->setEnabled(false); ui->edtDecimal->setText(QString(decimalSeparator)); //if (QString(decimalSeparator).isEmpty()) ui->edtDecimal->setEnabled(false); ui->edtComment->setText(QString(commentStart)); //if (QString(commentStart).isEmpty()) ui->edtComment->setEnabled(false); ui->edtHeader->setText(headerStart); //if (headerStart.isEmpty()) ui->edtHeader->setEnabled(false); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(checkValues())); ui->tableView->setModel(tabmodel); ProgramOptions::getConfigWindowGeometry(this, "QFDlgCSVParameters/window/"); ProgramOptions::getConfigQSplitter(ui->splitter, "QFDlgCSVParameters/splitter/"); ui->widConfig->setCurrentConfig(ProgramOptions::getConfigValue("QFDlgCSVParameters/config/", "").toString()); setShowColumnsSelection(false); ui->lstColumns->setModel(&colslistCheckable); guessParameters(); setWindowFlags(windowFlags()|Qt::WindowMinMaxButtonsHint); }
bool NonLinearFit::setFormula(const QString& s, bool guess) { if (s.isEmpty()){ QMessageBox::critical((ApplicationWindow *)parent(), tr("QtiPlot - Input function error"), tr("Please enter a valid non-empty expression! Operation aborted!")); d_init_err = true; return false; } if (d_formula == s) return true; if (guess) setParametersList(guessParameters(s)); if (!d_p){ QMessageBox::critical((ApplicationWindow *)parent(), tr("QtiPlot - Fit Error"), tr("There are no parameters specified for this fit operation. Please define a list of parameters first!")); d_init_err = true; return false; } try { double *param = new double[d_p]; MyParser parser; double xvar; parser.DefineVar("x", &xvar); for (int k = 0; k < (int)d_p; k++){ param[k] = gsl_vector_get(d_param_init, k); parser.DefineVar(d_param_names[k].ascii(), ¶m[k]); } QMapIterator<QString, double> i(d_constants); while (i.hasNext()) { i.next(); parser.DefineConst(i.key().ascii(), i.value()); } parser.SetExpr(s.ascii()); parser.Eval() ; delete[] param; } catch(mu::ParserError &e){ QMessageBox::critical((ApplicationWindow *)parent(), tr("QtiPlot - Input function error"), QString::fromStdString(e.GetMsg())); d_init_err = true; return false; } d_init_err = false; d_formula = s; return true; }
void QFDlgCSVParameters::setFileContents(const QString& filename) { QString preview=""; QFile file(filename); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while (!in.atEnd()) { preview=preview + in.readLine() +"\n"; } file.close(); } file_contents=preview; this->filename=filename; ui->txtContents->setPlainText(preview); guessParameters(); reloadCSV(); for (int i=0; i<colCmb.size(); i++) { colCmb[i]->setCurrentIndex(i); } }