mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[graph] Preserve default X range
When computing the automatic zoom, if the X axis has integer bounds (most likely because the range has been built to be orthonormal), do not add margins to the X axis, so that it keeps user friendly values. Change-Id: I49d99b79c68fbd8a49e5c2521b250c40aad75d48
This commit is contained in:
committed by
LeaNumworks
parent
6e9195fafa
commit
ff220b7103
@@ -182,19 +182,29 @@ void InteractiveCurveViewRange::setDefault() {
|
||||
// Compute the interesting range
|
||||
m_delegate->interestingRanges(this);
|
||||
bool revertToNormalized = isOrthonormal(k_orthonormalTolerance);
|
||||
/* If the horizontal bounds are integers, they are preset values and should
|
||||
* not be changed. */
|
||||
bool isDefaultRange = (xMin() == std::round(xMin())) && (xMax() == std::round(xMax()));
|
||||
|
||||
// Add margins, then round limits.
|
||||
float xRange = xMax() - xMin();
|
||||
float yRange = yMax() - yMin();
|
||||
m_xRange.setMin(roundLimit(m_delegate->addMargin(xMin(), xRange, false, true), xRange, true), k_lowerMaxFloat, k_upperMaxFloat);
|
||||
float newXMin = xMin(), newXMax = xMax();
|
||||
if (!isDefaultRange) {
|
||||
float xRange = xMax() - xMin();
|
||||
newXMin = roundLimit(m_delegate->addMargin(xMin(), xRange, false, true), xRange, true);
|
||||
newXMax = roundLimit(m_delegate->addMargin(xMax(), xRange, false, false), xRange, false);
|
||||
}
|
||||
m_xRange.setMin(newXMin, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
// Use MemoizedCurveViewRange::protectedSetXMax to update xGridUnit
|
||||
MemoizedCurveViewRange::protectedSetXMax(roundLimit(m_delegate->addMargin(xMax(), xRange, false, false), xRange, false), k_lowerMaxFloat, k_upperMaxFloat);
|
||||
MemoizedCurveViewRange::protectedSetXMax(newXMax, k_lowerMaxFloat, k_upperMaxFloat);
|
||||
float yRange = yMax() - yMin();
|
||||
m_yRange.setMin(roundLimit(m_delegate->addMargin(yMin(), yRange, true , true), yRange, true), k_lowerMaxFloat, k_upperMaxFloat);
|
||||
MemoizedCurveViewRange::protectedSetYMax(roundLimit(m_delegate->addMargin(yMax(), yRange, true , false), yRange, false), k_lowerMaxFloat, k_upperMaxFloat);
|
||||
|
||||
if (m_delegate->defaultRangeIsNormalized() || revertToNormalized) {
|
||||
// Normalize the axes, so that a polar circle is displayed as a circle
|
||||
normalize();
|
||||
/* Normalize the axes, so that a polar circle is displayed as a circle.
|
||||
* If we are displaying cartesian functions with a default range, we want
|
||||
* the X bounds untouched. */
|
||||
normalize(isDefaultRange && !m_delegate->defaultRangeIsNormalized());
|
||||
}
|
||||
|
||||
setZoomAuto(true);
|
||||
|
||||
Reference in New Issue
Block a user