[apps/graph] Default window is -10..10 / -10..10

This commit is contained in:
Léa Saviot
2019-09-09 14:07:49 +02:00
parent 0d2c20bceb
commit 99aee59e5e
2 changed files with 13 additions and 2 deletions

View File

@@ -61,7 +61,8 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
float xMax = const_cast<GraphController *>(this)->interactiveCurveViewRange()->xMax();
assert(functionStore()->numberOfActiveFunctions() > 0);
if (displaysNonCartesianFunctions()) {
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
const int functionsCount = functionStore()->numberOfActiveFunctions();
for (int i = 0; i < functionsCount; i++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
if (f->plotType() == CartesianFunction::PlotType::Cartesian) {
continue;
@@ -75,6 +76,10 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
assert(!std::isnan(f->rangeStep()));
interestingFunctionRange(f, tMin, tMax, f->rangeStep(), &resultxMin, &resultxMax, &resultyMin, &resultyMax);
}
if (resultxMin > resultxMax) {
resultxMin = - Range1D::k_default;
resultxMax = Range1D::k_default;
}
} else {
resultxMin = xMin;
resultxMax = xMax;
@@ -96,6 +101,11 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
double tMax = minFloat(f->tMax(), xMax);
interestingFunctionRange(f, tMin, tMax, step, &resultxMin, &resultxMax, &resultyMin, &resultyMax);
}
if (resultyMin > resultyMax) {
resultyMin = - Range1D::k_default;
resultyMax = Range1D::k_default;
}
*xm = resultxMin;
*xM = resultxMax;
*ym = resultyMin;

View File

@@ -12,7 +12,8 @@ namespace Shared {
class __attribute__((packed)) Range1D final {
public:
constexpr static float k_minFloat = 1E-4f;
Range1D(float min = -10.0f, float max = 10.0f) :
constexpr static float k_default = 10.0f;
Range1D(float min = -k_default, float max = k_default) :
m_min(min),
m_max(max)
{}