Commit 6e74ec55 authored by Stefan Gerlach's avatar Stefan Gerlach
Browse files

[fit] handle zero eval range

parent fd33b51f
......@@ -575,7 +575,7 @@ void AbstractColumn::replaceBigInt(int first, const QVector<qint64>& new_values)
}
/**
* Returns the properties hold by this column (no, monotonic increasing, monotonic decreasing,...)
* Returns the properties hold by this column (no, constant, monotonic increasing, monotonic decreasing,...)
* Is used in XYCurve to improve the search velocity for the y value for a specific x value
*/
AbstractColumn::Properties AbstractColumn::properties() const {
......
......@@ -1633,6 +1633,7 @@ void ColumnPrivate::replaceBigInt(int first, const QVector<qint64>& new_values)
* See where variable properties will be used.
*/
void ColumnPrivate::updateProperties() {
DEBUG("ColumnPrivate::updateProperties()")
// TODO: for double Properties::Constant will never be used. Use an epsilon (difference smaller than epsilon is zero)
if (rowCount() == 0) {
......@@ -1795,12 +1796,16 @@ void ColumnPrivate::updateProperties() {
}
properties = AbstractColumn::Properties::No;
if (monotonic_increasing > 0 && monotonic_decreasing > 0)
if (monotonic_increasing > 0 && monotonic_decreasing > 0) {
properties = AbstractColumn::Properties::Constant;
else if (monotonic_decreasing > 0)
DEBUG(" setting column CONSTANT")
} else if (monotonic_decreasing > 0) {
properties = AbstractColumn::Properties::MonotonicDecreasing;
else if (monotonic_increasing > 0)
DEBUG(" setting column MONTONIC DECREASING")
} else if (monotonic_increasing > 0) {
properties = AbstractColumn::Properties::MonotonicIncreasing;
DEBUG(" setting column MONTONIC INCREASING")
}
propertiesAvailable = true;
}
......
......@@ -1244,9 +1244,9 @@ void XYCurvePrivate::addLine(QPointF p0, QPointF p1, QPointF& lastPoint, int& pi
* @param pixelDiff x pixel distance between two points
*/
void XYCurvePrivate::addUniqueLine(QPointF p0, QPointF p1, QPointF& lastPoint, int& pixelDiff) {
//QDEBUG("XYCurvePrivate::addUniqueLine() :" << p0 << " ->" << p1 << ' ' << "minY =" << minY << ' ' << "maxY =" << maxY << ", lastPoint =" << lastPoint << ", pixelDiff =" << pixelDiff)
//QDEBUG("XYCurvePrivate::addUniqueLine() :" << p0 << " ->" << p1 << ", lastPoint =" << lastPoint << ", pixelDiff =" << pixelDiff)
if (pixelDiff == 0) {
//QDEBUG(" pixelDiff == 0!)
//QDEBUG(" pixelDiff == 0!")
if (isnan(lastPoint.x())) // save last point
lastPoint = p0;
} else { // pixelDiff > 0
......@@ -1346,6 +1346,7 @@ void XYCurvePrivate::updateLines() {
QPointF tempPoint1, tempPoint2; // used as temporaryPoints to interpolate datapoints if set
if (columnProperties == AbstractColumn::Properties::Constant) {
DEBUG(" CONSTANT column")
tempPoint1 = QPointF(plot->xMin(), plot->yMin());
tempPoint2 = QPointF(plot->xMin(), plot->yMax());
m_lines.append(QLineF(tempPoint1, tempPoint2));
......
......@@ -2120,13 +2120,12 @@ void XYFitCurvePrivate::evaluate(bool preview) {
}
ExpressionParser* parser = ExpressionParser::getInstance();
double xmin, xmax;
if (fitData.autoEvalRange) { // evaluate fit on full data range
xmin = tmpXDataColumn->minimum();
xmax = tmpXDataColumn->maximum();
} else { // use given range for evaluation
xmin = fitData.evalRange.first();
xmax = fitData.evalRange.last();
double xmin{tmpXDataColumn->minimum()}, xmax{tmpXDataColumn->maximum()}; // full data range
if (!fitData.autoEvalRange) { // use given range for evaluation
if (fitData.evalRange.last() != fitData.evalRange.first()) { // avoid zero range
xmin = fitData.evalRange.first();
xmax = fitData.evalRange.last();
}
}
DEBUG(" eval range = " << xmin << " .. " << xmax);
xVector->resize((int)fitData.evaluatedPoints);
......
......@@ -69,6 +69,7 @@ public:
bool autoRange{true}; // use all data points? (default)
bool autoEvalRange{true}; // evaluate fit function on full data range (default)
//TODO: QPoint?
QVector<double> fitRange{0., 0.}; // x fit range
QVector<double> evalRange{0., 0.}; // x evaluation range
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment