diff --git a/apps/shared/curve_view_range.h b/apps/shared/curve_view_range.h index 40c0709bb..5867ab566 100644 --- a/apps/shared/curve_view_range.h +++ b/apps/shared/curve_view_range.h @@ -24,7 +24,7 @@ public: return computeGridUnit(k_minNumberOfXGridUnits, k_maxNumberOfXGridUnits, xMax() - xMin()); } virtual float yGridUnit() const { - return computeGridUnit(k_minNumberOfYGridUnits, k_maxNumberOfYGridUnits, yMax() - yMin()); + return computeGridUnit(k_minNumberOfYGridUnits, k_maxNumberOfYGridUnits, yMax() - yMin() + offscreenYAxis()); } constexpr static float k_maxNumberOfXGridUnits = 18.0f; constexpr static float k_maxNumberOfYGridUnits = 13.0f; @@ -32,6 +32,7 @@ protected: constexpr static float k_minNumberOfXGridUnits = 7.0f; constexpr static float k_minNumberOfYGridUnits = 5.0f; private: + virtual float offscreenYAxis() const { return 0.f; } /* 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.*/ diff --git a/apps/shared/function_zoom_and_pan_curve_view_controller.cpp b/apps/shared/function_zoom_and_pan_curve_view_controller.cpp index cd1edbf60..72fb708ed 100644 --- a/apps/shared/function_zoom_and_pan_curve_view_controller.cpp +++ b/apps/shared/function_zoom_and_pan_curve_view_controller.cpp @@ -37,9 +37,12 @@ void FunctionZoomAndPanCurveViewController::adaptCurveRange(bool viewWillAppear) float currentRange = m_interactiveRange->yMax() - m_interactiveRange->yMin(); float newYMin = 0; if (viewWillAppear) { - newYMin = currentYMin + ((float)ContentView::k_legendHeight)/((float)k_standardViewHeight)*currentRange; + float rangeOffscreen = ((float)ContentView::k_legendHeight)/((float)k_standardViewHeight)*currentRange; + newYMin = currentYMin + rangeOffscreen; + m_interactiveRange->setOffscreenYAxis(rangeOffscreen); } else { newYMin = m_interactiveRange->yMax() - currentRange*((float)k_standardViewHeight)/(((float)k_standardViewHeight)-((float)ContentView::k_legendHeight)); + m_interactiveRange->setOffscreenYAxis(0.f); } m_interactiveRange->setYMin(newYMin); m_contentView.curveView()->reload(); diff --git a/apps/shared/interactive_curve_view_range.h b/apps/shared/interactive_curve_view_range.h index a44169986..ced28f46d 100644 --- a/apps/shared/interactive_curve_view_range.h +++ b/apps/shared/interactive_curve_view_range.h @@ -46,6 +46,8 @@ public: void setYMin(float f) override; void setYMax(float f) override; + void setOffscreenYAxis(float f) { m_offscreenYAxis = f; } + // Window void zoom(float ratio, float x, float y); void panWithVector(float x, float y); @@ -77,6 +79,9 @@ protected: constexpr static float NormalizedYHalfRange(float unit) { return 3.06f * unit; } InteractiveCurveViewRangeDelegate * m_delegate; private: + float offscreenYAxis() const override { return m_offscreenYAxis; } + + float m_offscreenYAxis; bool m_zoomAuto; bool m_zoomNormalize; };