mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/zoom] Factor constants
The mantissas {1, 2, 5} used in CurveViewRange to compute the grid units
can be factored in Zoom.
Change-Id: I2bcc9b9df1ff6b6df82092a5d78ed3db132bf63a
This commit is contained in:
committed by
Émilie Feral
parent
88ea32bd0d
commit
a525c35ebb
@@ -2,6 +2,7 @@
|
||||
#define SHARED_CURVE_VIEW_RANGE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <poincare/zoom.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
@@ -34,9 +35,9 @@ private:
|
||||
/* The grid units is constrained to be a number of type: k*10^n with k = 1,2 or 5
|
||||
* and n a relative integer. The choice of x and y grid units depend on the
|
||||
* grid range.*/
|
||||
constexpr static float k_smallGridUnitMantissa = 1.0f;
|
||||
constexpr static float k_mediumGridUnitMantissa = 2.0f;
|
||||
constexpr static float k_largeGridUnitMantissa = 5.0f;
|
||||
constexpr static float k_smallGridUnitMantissa = Poincare::Zoom::k_smallUnitMantissa;
|
||||
constexpr static float k_mediumGridUnitMantissa = Poincare::Zoom::k_mediumUnitMantissa;
|
||||
constexpr static float k_largeGridUnitMantissa = Poincare::Zoom::k_largeUnitMantissa;
|
||||
float computeGridUnit(float minNumberOfUnits, float maxNumberOfUnits, float range) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace Poincare {
|
||||
class Zoom {
|
||||
public:
|
||||
static constexpr float k_defaultHalfRange = 10.f;
|
||||
static constexpr float k_smallUnitMantissa = 1.f;
|
||||
static constexpr float k_mediumUnitMantissa = 2.f;
|
||||
static constexpr float k_largeUnitMantissa = 5.f;
|
||||
|
||||
typedef float (*ValueAtAbscissa)(float abscissa, Context * context, const void * auxiliary);
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ constexpr float
|
||||
Zoom::k_breathingRoom,
|
||||
Zoom::k_forceXAxisThreshold,
|
||||
Zoom::k_defaultHalfRange,
|
||||
Zoom::k_maxRatioBetweenPointsOfInterest;
|
||||
Zoom::k_maxRatioBetweenPointsOfInterest,
|
||||
Zoom::k_smallUnitMantissa,
|
||||
Zoom::k_mediumUnitMantissa,
|
||||
Zoom::k_largeUnitMantissa;
|
||||
|
||||
bool 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);
|
||||
@@ -226,7 +229,7 @@ void Zoom::SetToRatio(float yxRatio, float * xMin, float * xMax, float * yMin, f
|
||||
}
|
||||
|
||||
void Zoom::RangeWithRatioForDisplay(ValueAtAbscissa evaluation, float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary) {
|
||||
constexpr float units[] = {1.f, 2.f, 5.f};
|
||||
constexpr float units[] = {k_smallUnitMantissa, k_mediumUnitMantissa, k_largeUnitMantissa};
|
||||
constexpr float rangeMagnitudeWeight = 0.2f;
|
||||
constexpr float maxMagnitudeDifference = 1.2f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user