[interactive_curve_view_range] Move status update

The methods setDefault and normalize now update the zoomAuto and
zoomNormalize status.

Change-Id: I0400c22816c17d38fd1b3dee5c8a2f1ccfa79340
This commit is contained in:
Gabriel Ozouf
2020-10-15 14:22:34 +02:00
committed by Émilie Feral
parent 958b172d08
commit 3ba4f974f7
4 changed files with 9 additions and 15 deletions

View File

@@ -151,7 +151,6 @@ void InteractiveCurveViewController::viewWillAppear() {
if (m_interactiveRange->zoomAuto()) {
m_interactiveRange->setDefault();
m_interactiveRange->checkForNormalizedRange();
}
/* Warning: init cursor parameter before reloading banner view. Indeed,
@@ -298,8 +297,6 @@ bool InteractiveCurveViewController::autoButtonAction() {
m_interactiveRange->setZoomAuto(false);
} else {
m_interactiveRange->setDefault();
m_interactiveRange->setZoomAuto(true);
m_interactiveRange->checkForNormalizedRange();
initCursorParameters();
setCurveViewAsMainView();
}
@@ -310,9 +307,8 @@ bool InteractiveCurveViewController::normalizeButtonAction() {
if (m_interactiveRange->zoomNormalize()) {
m_interactiveRange->setZoomNormalize(false);
} else {
m_interactiveRange->normalize();
m_interactiveRange->setZoomAuto(false);
m_interactiveRange->setZoomNormalize(true);
m_interactiveRange->normalize();
setCurveViewAsMainView();
}
return m_interactiveRange->zoomNormalize();

View File

@@ -102,6 +102,9 @@ void InteractiveCurveViewRange::normalize() {
MemoizedCurveViewRange::protectedSetXMax(newXMax, k_lowerMaxFloat, k_upperMaxFloat);
m_yRange.setMin(newYMin, k_lowerMaxFloat, k_upperMaxFloat);
MemoizedCurveViewRange::protectedSetYMax(newYMax, k_lowerMaxFloat, k_upperMaxFloat);
assert(isOrthonormal());
setZoomNormalize(true);
}
void InteractiveCurveViewRange::setDefault() {
@@ -126,12 +129,12 @@ void InteractiveCurveViewRange::setDefault() {
m_yRange.setMin(m_delegate->addMargin(yMin(), yRange, true, true), k_lowerMaxFloat, k_upperMaxFloat);
MemoizedCurveViewRange::protectedSetYMax(m_delegate->addMargin(yMax(), yRange, true, false), k_lowerMaxFloat, k_upperMaxFloat);
if (!(m_delegate->defaultRangeIsNormalized() || revertToNormalized)) {
return;
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
normalize();
setZoomAuto(true);
}
void InteractiveCurveViewRange::setNullRange() {
@@ -201,10 +204,6 @@ void InteractiveCurveViewRange::panToMakePointVisible(float x, float y, float to
}
}
void InteractiveCurveViewRange::checkForNormalizedRange() {
setZoomNormalize(isOrthonormal());
}
bool InteractiveCurveViewRange::isOrthonormal(float tolerance) const {
float ratio = (yMax() - yMin()) / (xMax() - xMin());
float ratioDifference = std::fabs(std::log(ratio / NormalYXRatio()));

View File

@@ -47,7 +47,6 @@ public:
void setNullRange();
void centerAxisAround(Axis axis, float position);
void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation, float pixelWidth);
void checkForNormalizedRange();
protected:
constexpr static float k_upperMaxFloat = 1E+8f;

View File

@@ -86,7 +86,7 @@ int RangeParameterController::reusableParameterCellCount(int type) {
void RangeParameterController::buttonAction() {
*m_interactiveRange = m_tempInteractiveRange;
m_interactiveRange->setZoomAuto(false);
m_interactiveRange->checkForNormalizedRange();
m_interactiveRange->setZoomNormalize(m_interactiveRange->isOrthonormal());
StackViewController * stack = stackController();
stack->pop();