[apps/graph] setDefault when changing models if non cartesian functions

This commit is contained in:
Léa Saviot
2019-09-12 09:54:02 +02:00
parent 2d38419989
commit 274795fcab
4 changed files with 7 additions and 1 deletions

View File

@@ -169,4 +169,8 @@ bool GraphController::displaysNonCartesianFunctions() const {
|| store->numberOfActiveFunctionsOfType(CartesianFunction::PlotType::Parametric) > 0;
}
bool GraphController::shouldSetDefaultOnModelChange() const {
return displaysNonCartesianFunctions();
}
}

View File

@@ -37,6 +37,7 @@ private:
bool displaysNonCartesianFunctions() const;
bool defautRangeIsNormalized() const override { return displaysNonCartesianFunctions(); }
void interestingFunctionRange(Shared::ExpiringPointer<Shared::CartesianFunction> f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const;
bool shouldSetDefaultOnModelChange() const override;
Shared::RoundCursorView m_cursorView;
BannerView m_bannerView;

View File

@@ -144,7 +144,7 @@ Responder * InteractiveCurveViewController::defaultController() {
void InteractiveCurveViewController::viewWillAppear() {
uint32_t newModelVersion = modelVersion();
if (*m_modelVersion != newModelVersion) {
if (*m_modelVersion == 0 || numberOfCurves() == 1) {
if (*m_modelVersion == 0 || numberOfCurves() == 1 || shouldSetDefaultOnModelChange()) {
interactiveCurveViewRange()->setDefault();
}
*m_modelVersion = newModelVersion;

View File

@@ -64,6 +64,7 @@ private:
// InteractiveCurveViewRangeDelegate
float addMargin(float x, float range, bool isVertical, bool isMin) override;
virtual bool shouldSetDefaultOnModelChange() const { return false; }
uint32_t * m_modelVersion;
uint32_t * m_rangeVersion;
RangeParameterController m_rangeParameterController;