void Fit::setDataCurve(int curve, double start, double end) { if (!d_graph) return; if (d_n > 0) delete[] d_w; Filter::setDataCurve(curve, start, end); d_w = new double[d_n]; PlotCurve *plotCurve = dynamic_cast<PlotCurve *>(d_curve); DataCurve *dataCurve = dynamic_cast<DataCurve *>(d_curve); // if it is a DataCurve (coming from a Table) if (plotCurve && dataCurve && plotCurve->type() != GraphOptions::Function) { QList<DataCurve *> lst = dataCurve->errorBarsList(); foreach (DataCurve *c, lst) { QwtErrorPlotCurve *er = dynamic_cast<QwtErrorPlotCurve *>(c); if (er && !er->xErrors()) { d_weighting = Instrumental; for (int i = 0; i < d_n; i++) d_w[i] = er->errorValue(i); // d_w are equal to the error bar values weighting_dataset = er->title().text(); return; } }
void Fit::setDataCurve(int curve, double start, double end) { Filter::setDataCurve(curve, start, end); if (!d_w){ d_w = (double *)malloc(d_n*sizeof(double)); if (!d_w){ memoryErrorMessage(); return; } } if (d_graph && d_curve && ((PlotCurve *)d_curve)->type() != Graph::Function) { QList<DataCurve *> lst = ((DataCurve *)d_curve)->errorBarsList(); foreach (DataCurve *c, lst){ QwtErrorPlotCurve *er = (QwtErrorPlotCurve *)c; if (!er->xErrors()){ d_weighting = Instrumental; for (int i=0; i<d_n; i++){ double e = er->errorValue(i); d_w[i] = 1.0/(e*e); } weighting_dataset = er->title().text(); return; } }
void Fit::setDataCurve(int curve, double start, double end) { if (d_n > 0) delete[] d_w; Filter::setDataCurve(curve, start, end); d_w = new double[d_n]; if (d_graph && d_curve && ((PlotCurve *)d_curve)->type() != Graph::Function) { QList<DataCurve *> lst = ((DataCurve *)d_curve)->errorBarsList(); foreach (DataCurve *c, lst){ QwtErrorPlotCurve *er = (QwtErrorPlotCurve *)c; if (!er->xErrors()){ d_weighting = Instrumental; for (int i=0; i<d_n; i++) d_w[i] = er->errorValue(i); //d_w are equal to the error bar values weighting_dataset = er->title().text(); return; } }
bool Fit::setYErrorSource(ErrorSource err, const QString &colName, bool fail_silently) { d_y_error_source = err; switch (d_y_error_source) { case UnknownErrors: { d_y_error_dataset = QString::null; // using 1.0 here is important for correct error estimates, // cmp. Fit::fitGslMultifit and Fit::fitGslMultimin for (int i = 0; i < d_n; i++) d_y_errors[i] = 1.0; } break; case AssociatedErrors: { bool error = true; QwtErrorPlotCurve *er = 0; if (d_curve && ((PlotCurve *)d_curve)->type() != Graph::Function) { QList<DataCurve *> lst = ((DataCurve *)d_curve)->errorBarsList(); foreach (DataCurve *c, lst) { er = (QwtErrorPlotCurve *)c; if (!er->xErrors()) { d_y_error_dataset = er->title().text(); error = false; break; } } } if (error) { if (!fail_silently) QMessageBox::critical( (ApplicationWindow *)parent(), tr("Error"), tr("The curve %1 has no associated Y error bars.") .arg(d_curve->title().text())); return false; } if (er) { for (int j = 0; j < d_n; j++) d_y_errors[j] = er->errorValue(j); } } break;
void AssociationsDialog::changePlotAssociation(int curve, const QString& text) { DataCurve *c = dynamic_cast<DataCurve *>(graph->curve(curve)); //c_keys[curve]); if (!c) return; if (c->plotAssociation() == text) return; QStringList lst = text.split(",", QString::SkipEmptyParts); if (lst.count() == 1){ c->setTitle(lst[0]); if (graph->curveType(curve) == Graph::Box) dynamic_cast<BoxCurve*>(c)->loadData(); else if (graph->curveType(curve) == Graph::Pie) dynamic_cast<QwtPieCurve*>(c)->loadData(); } else if (lst.count() == 2){ c->setXColumnName(lst[0].remove("(X)")); c->setTitle(lst[1].remove("(Y)")); c->loadData(); } else if (lst.count() == 3){//curve with error bars QwtErrorPlotCurve *er = dynamic_cast<QwtErrorPlotCurve *>(c); QString xColName = lst[0].remove("(X)"); QString yColName = lst[1].remove("(Y)"); QString erColName = lst[2].remove("(xErr)").remove("(yErr)"); DataCurve *master_curve = graph->masterCurve(xColName, yColName); if (!master_curve) return; int type = QwtErrorPlotCurve::Vertical; if (text.contains("(xErr)")) type = QwtErrorPlotCurve::Horizontal; er->setDirection(type); er->setTitle(erColName); if (master_curve != er->masterCurve()) er->setMasterCurve(master_curve); else er->loadData(); } else if (lst.count() == 4) { VectorCurve *v = dynamic_cast<VectorCurve *>(c); v->setXColumnName(lst[0].remove("(X)")); v->setTitle(lst[1].remove("(Y)")); QString xEndCol = lst[2].remove("(X)").remove("(A)"); QString yEndCol = lst[3].remove("(Y)").remove("(M)"); if (v->vectorEndXAColName() != xEndCol || v->vectorEndYMColName() != yEndCol) v->setVectorEnd(xEndCol, yEndCol); else v->loadData(); } graph->notifyChanges(); }