mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/zoom] Remove tuneXRange argument
The ability to perform a range search without changing the X range was only there to accomodate the Yauto feature. Change-Id: I8c2b61b447fbd3dc1f4e303dff06d1a8d6e7a4f2
This commit is contained in:
committed by
Émilie Feral
parent
07c52139b9
commit
ad6edffc07
@@ -261,9 +261,9 @@ void ContinuousFunction::setTMax(float tMax) {
|
||||
setCache(nullptr);
|
||||
}
|
||||
|
||||
void ContinuousFunction::rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange) const {
|
||||
void ContinuousFunction::rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context) const {
|
||||
if (plotType() == PlotType::Cartesian) {
|
||||
protectedRangeForDisplay(xMin, xMax, yMin, yMax, context, tuneXRange, true);
|
||||
protectedRangeForDisplay(xMin, xMax, yMin, yMax, context, true);
|
||||
} else {
|
||||
fullXYRange(xMin, xMax, yMin, yMax, context);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
void setTMax(float tMax);
|
||||
float rangeStep() const override { return plotType() == PlotType::Cartesian ? NAN : (tMax() - tMin())/k_polarParamRangeSearchNumberOfPoints; }
|
||||
|
||||
void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange = true) const override;
|
||||
void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context) const override;
|
||||
|
||||
// Extremum
|
||||
Poincare::Coordinate2D<double> nextMinimumFrom(double start, double step, double max, Poincare::Context * context) const;
|
||||
|
||||
@@ -79,7 +79,7 @@ Function::RecordDataBuffer * Function::recordData() const {
|
||||
return reinterpret_cast<RecordDataBuffer *>(const_cast<void *>(d.buffer));
|
||||
}
|
||||
|
||||
void Function::protectedRangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange, bool boundByMagnitude) const {
|
||||
void Function::protectedRangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool boundByMagnitude) const {
|
||||
Zoom::ValueAtAbscissa evaluation = [](float x, Context * context, const void * auxiliary) {
|
||||
/* When evaluating sin(x)/x close to zero using the standard sine function,
|
||||
* one can detect small variations, while the cardinal sine is supposed to be
|
||||
@@ -89,7 +89,7 @@ void Function::protectedRangeForDisplay(float * xMin, float * xMax, float * yMin
|
||||
constexpr float precision = 1e-5;
|
||||
return precision * std::round(static_cast<const Function *>(auxiliary)->evaluateXYAtParameter(x, context).x2() / precision);
|
||||
};
|
||||
Zoom::InterestingRangesForDisplay(evaluation, xMin, xMax, yMin, yMax, tMin(), tMax(), context, this, tuneXRange);
|
||||
Zoom::InterestingRangesForDisplay(evaluation, xMin, xMax, yMin, yMax, tMin(), tMax(), context, this);
|
||||
|
||||
evaluation = [](float x, Context * context, const void * auxiliary) {
|
||||
return static_cast<const Function *>(auxiliary)->evaluateXYAtParameter(x, context).x2();
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
virtual Poincare::Expression sumBetweenBounds(double start, double end, Poincare::Context * context) const = 0;
|
||||
|
||||
// Range
|
||||
virtual void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange = true) const = 0;
|
||||
virtual void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context) const = 0;
|
||||
|
||||
protected:
|
||||
/* RecordDataBuffer is the layout of the data buffer of Record
|
||||
@@ -93,7 +93,7 @@ protected:
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
void protectedRangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange, bool boundByMagnitude) const;
|
||||
void protectedRangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool boundByMagnitude) const;
|
||||
|
||||
private:
|
||||
RecordDataBuffer * recordData() const;
|
||||
|
||||
@@ -137,20 +137,16 @@ int FunctionGraphController::numberOfCurves() const {
|
||||
}
|
||||
|
||||
void FunctionGraphController::interestingRanges(InteractiveCurveViewRange * range) const {
|
||||
privateComputeRanges(true, range);
|
||||
}
|
||||
|
||||
void FunctionGraphController::privateComputeRanges(bool tuneXRange, InteractiveCurveViewRange * range) const {
|
||||
Poincare::Context * context = textFieldDelegateApp()->localContext();
|
||||
float resultXMin = tuneXRange ? FLT_MAX : range->xMin();
|
||||
float resultXMax = tuneXRange ? -FLT_MAX : range->xMax();
|
||||
float resultXMin = FLT_MAX;
|
||||
float resultXMax = -FLT_MAX;
|
||||
float resultYMin = FLT_MAX;
|
||||
float resultYMax = -FLT_MAX;
|
||||
assert(functionStore()->numberOfActiveFunctions() > 0);
|
||||
int functionsCount = functionStore()->numberOfActiveFunctions();
|
||||
for (int i = 0; i < functionsCount; i++) {
|
||||
ExpiringPointer<Function> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
|
||||
f->rangeForDisplay(&resultXMin, &resultXMax, &resultYMin, &resultYMax, context, tuneXRange);
|
||||
f->rangeForDisplay(&resultXMin, &resultXMax, &resultYMin, &resultYMax, context);
|
||||
}
|
||||
|
||||
range->setXMin(resultXMin);
|
||||
|
||||
@@ -39,7 +39,6 @@ protected:
|
||||
void initCursorParameters() override;
|
||||
CurveView * curveView() override;
|
||||
|
||||
void privateComputeRanges(bool tuneXRange, Shared::InteractiveCurveViewRange * range) const;
|
||||
void yRangeForCursorFirstMove(Shared::InteractiveCurveViewRange * range) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
constexpr static int k_initialRankNumberOfDigits = 3; // m_initialRank is capped by 999
|
||||
|
||||
//Range
|
||||
void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context, bool tuneXRange = true) const override { protectedRangeForDisplay(xMin, xMax, yMin, yMax, context, tuneXRange, false); };
|
||||
void rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context) const override { protectedRangeForDisplay(xMin, xMax, yMin, yMax, context, false); };
|
||||
|
||||
private:
|
||||
constexpr static const KDFont * k_layoutFont = KDFont::LargeFont;
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
|
||||
typedef float (*ValueAtAbscissa)(float abscissa, Context * context, const void * auxiliary);
|
||||
|
||||
static void InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary, bool tuneXRange = false);
|
||||
static void InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary);
|
||||
static void RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float xMax, float * yMin, float * yMax, Context * context, const void * auxiliary, bool boundByMagnitude = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,15 +17,12 @@ constexpr float
|
||||
Zoom::k_defaultHalfRange,
|
||||
Zoom::k_maxRatioBetweenPointsOfInterest;
|
||||
|
||||
void Zoom::InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary, bool tuneXRange) {
|
||||
void Zoom::InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary) {
|
||||
assert(xMin && xMax && yMin && yMax);
|
||||
|
||||
const bool hasIntervalOfDefinition = std::isfinite(tMin) && std::isfinite(tMax);
|
||||
float center, maxDistance;
|
||||
if (!tuneXRange) {
|
||||
center = (*xMax + *xMin) / 2.f;
|
||||
maxDistance = (*xMax - *xMin) / 2.f;
|
||||
} else if (hasIntervalOfDefinition) {
|
||||
if (hasIntervalOfDefinition) {
|
||||
center = (tMax + tMin) / 2.f;
|
||||
maxDistance = (tMax - tMin) / 2.f;
|
||||
} else {
|
||||
@@ -132,26 +129,25 @@ void Zoom::InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin,
|
||||
}
|
||||
}
|
||||
|
||||
if (tuneXRange) {
|
||||
/* Cut after horizontal asymptotes. */
|
||||
resultX[0] = std::min(resultX[0], asymptote[0]);
|
||||
resultX[1] = std::max(resultX[1], asymptote[1]);
|
||||
if (resultX[0] >= resultX[1]) {
|
||||
/* Fallback to default range. */
|
||||
resultX[0] = - k_defaultHalfRange;
|
||||
resultX[1] = k_defaultHalfRange;
|
||||
} else {
|
||||
/* Add breathing room around points of interest. */
|
||||
float xRange = resultX[1] - resultX[0];
|
||||
resultX[0] -= k_breathingRoom * xRange;
|
||||
resultX[1] += k_breathingRoom * xRange;
|
||||
/* Round to the next integer. */
|
||||
resultX[0] = std::floor(resultX[0]);
|
||||
resultX[1] = std::ceil(resultX[1]);
|
||||
}
|
||||
*xMin = std::min(resultX[0], *xMin);
|
||||
*xMax = std::max(resultX[1], *xMax);
|
||||
/* Cut after horizontal asymptotes. */
|
||||
resultX[0] = std::min(resultX[0], asymptote[0]);
|
||||
resultX[1] = std::max(resultX[1], asymptote[1]);
|
||||
if (resultX[0] >= resultX[1]) {
|
||||
/* Fallback to default range. */
|
||||
resultX[0] = - k_defaultHalfRange;
|
||||
resultX[1] = k_defaultHalfRange;
|
||||
} else {
|
||||
/* Add breathing room around points of interest. */
|
||||
float xRange = resultX[1] - resultX[0];
|
||||
resultX[0] -= k_breathingRoom * xRange;
|
||||
resultX[1] += k_breathingRoom * xRange;
|
||||
/* Round to the next integer. */
|
||||
resultX[0] = std::floor(resultX[0]);
|
||||
resultX[1] = std::ceil(resultX[1]);
|
||||
}
|
||||
*xMin = std::min(resultX[0], *xMin);
|
||||
*xMax = std::max(resultX[1], *xMax);
|
||||
|
||||
*yMin = std::min(resultYMin, *yMin);
|
||||
*yMax = std::max(resultYMax, *yMax);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user