mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Tweaked panning for better cache alignement
Method InteractiveCurveViewRange::panToMakePointVisible now moves the range of a whole number of pixels when panning horizontally. This allows the cache of cartesian functions not to be invalidated. Change-Id: Idb9904fef134dd13458e1f2287b0fe5145e8aec7
This commit is contained in:
committed by
Émilie Feral
parent
5bc19af196
commit
4007f4d452
@@ -199,20 +199,23 @@ void InteractiveCurveViewRange::centerAxisAround(Axis axis, float position) {
|
||||
}
|
||||
}
|
||||
|
||||
void InteractiveCurveViewRange::panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRatio, float leftMarginRatio) {
|
||||
void InteractiveCurveViewRange::panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRatio, float leftMarginRatio, float pixelWidth) {
|
||||
if (!std::isinf(x) && !std::isnan(x)) {
|
||||
const float xRange = xMax() - xMin();
|
||||
const float leftMargin = leftMarginRatio * xRange;
|
||||
if (x < xMin() + leftMargin) {
|
||||
m_yAuto = false;
|
||||
const float newXMin = x - leftMargin;
|
||||
/* The panning increment is a whole number of pixels so that the caching
|
||||
* for cartesian functions is not invalidated. */
|
||||
const float newXMin = std::floor((x - leftMargin - xMin()) / pixelWidth) * pixelWidth + xMin();
|
||||
m_xRange.setMax(newXMin + xRange, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
MemoizedCurveViewRange::protectedSetXMin(newXMin, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
}
|
||||
const float rightMargin = rightMarginRatio * xRange;
|
||||
if (x > xMax() - rightMargin) {
|
||||
m_yAuto = false;
|
||||
m_xRange.setMax(x + rightMargin, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
const float newXMax = std::ceil((x + rightMargin - xMax()) / pixelWidth) * pixelWidth + xMax();
|
||||
m_xRange.setMax(newXMax, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
MemoizedCurveViewRange::protectedSetXMin(xMax() - xRange, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user