void VectorCurve::loadData() { int xcol = d_table->colIndex(d_x_column); int ycol = d_table->colIndex(title().text()); int endXCol = d_table->colIndex(d_end_x_a); int endYCol = d_table->colIndex(d_end_y_m); int rows = abs(d_end_row - d_start_row) + 1; QVector<double> X(rows), Y(rows), X2(rows), Y2(rows); int size = 0; for (int i = d_start_row; i <= d_end_row; i++) { QString xval = d_table->text(i, xcol); QString yval = d_table->text(i, ycol); QString xend = d_table->text(i, endXCol); QString yend = d_table->text(i, endYCol); if (!xval.isEmpty() && !yval.isEmpty() && !xend.isEmpty() && !yend.isEmpty()) { Y[size] = yval.toDouble(); X[size] = xval.toDouble(); Y2[size] = yend.toDouble(); X2[size] = xend.toDouble(); size++; } } if (!size) return; X.resize(size); Y.resize(size); X2.resize(size); Y2.resize(size); setData(X.data(), Y.data(), size); foreach(DataCurve *c, d_error_bars) c->setData(X.data(), Y.data(), size); setVectorEnd(X2, Y2); }
void VectorCurve::loadData() { if (!plot()) return; int xcol = d_table->colIndex(d_x_column); int ycol = d_table->colIndex(title().text()); int endXCol = d_table->colIndex(d_end_x_a); int endYCol = d_table->colIndex(d_end_y_m); int rows = abs(d_end_row - d_start_row) + 1; QVector<double> X(rows), Y(rows), X2(rows), Y2(rows); int size = 0; QLocale locale = plot()->locale(); for (int i = d_start_row; i <= d_end_row; i++) { QString xval = d_table->text(i, xcol); QString yval = d_table->text(i, ycol); QString xend = d_table->text(i, endXCol); QString yend = d_table->text(i, endYCol); if (!xval.isEmpty() && !yval.isEmpty() && !xend.isEmpty() && !yend.isEmpty()) { bool valid_data = true; X[size] = locale.toDouble(xval, &valid_data); if (!valid_data) continue; Y[size] = locale.toDouble(yval, &valid_data); if (!valid_data) continue; X2[size] = locale.toDouble(xend, &valid_data); if (!valid_data) continue; Y2[size] = locale.toDouble(yend, &valid_data); if (valid_data) size++; } } if (!size) return; X.resize(size); Y.resize(size); X2.resize(size); Y2.resize(size); setData(X.data(), Y.data(), size); foreach (DataCurve *c, d_error_bars) c->setData(X.data(), Y.data(), size); setVectorEnd(X2, Y2); }