diff --git a/apps/sequence/graph/graph_controller.cpp b/apps/sequence/graph/graph_controller.cpp index b4350209a..b18c26941 100644 --- a/apps/sequence/graph/graph_controller.cpp +++ b/apps/sequence/graph/graph_controller.cpp @@ -48,6 +48,9 @@ bool GraphController::moveCursorHorizontally(int direction) { if (direction < 0 && xCursorPosition <= 0) { return false; } + /* The cursor moves by step of at minimum 1. If the windowRange is to large + * compared to the resolution, the cursor takes bigger round step to cross + * the window in approximatively resolution steps. */ float step = ceilf((interactiveCurveViewRange()->xMax()-interactiveCurveViewRange()->xMin())/m_view.resolution()); step = step < 1.0f ? 1.0f : step; float x = direction > 0 ? xCursorPosition + step: diff --git a/apps/sequence/graph/graph_view.cpp b/apps/sequence/graph/graph_view.cpp index cd89c8cf3..ab5a98bee 100644 --- a/apps/sequence/graph/graph_view.cpp +++ b/apps/sequence/graph/graph_view.cpp @@ -22,7 +22,9 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const { Sequence * s = m_sequenceStore->activeFunctionAtIndex(i); float rectMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin); float rectMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin); - int step = ceilf((rectMax - rectMin)/k_sequenceResolution); + /* We draw a dot at every integer WindowRange/Resolution < 1. Otherwise, we + * draw a dot every step where step is an integer. */ + int step = ceilf((rectMax - rectMin)/resolution()); for (int x = rectMin; x < rectMax; x += step) { float y = evaluateModelWithParameter(s, x); if (isnan(y)) { @@ -81,8 +83,8 @@ void GraphView::setHighlightColor(bool highlightColor) { } } -float GraphView::resolution() const { - return k_sequenceResolution; +float GraphView::samplingRatio() const { + return 0.8f; } float GraphView::evaluateModelWithParameter(Model * curve, float abscissa) const { diff --git a/apps/sequence/graph/graph_view.h b/apps/sequence/graph/graph_view.h index 7d3ef3a5d..0c8486faa 100644 --- a/apps/sequence/graph/graph_view.h +++ b/apps/sequence/graph/graph_view.h @@ -16,9 +16,8 @@ public: void selectSequence(Sequence * sequence); void setHighlight(int start, int end); void setHighlightColor(bool highlightColor); - float resolution() const override; private: - constexpr static float k_sequenceResolution = 250.0f; + float samplingRatio() const override; float evaluateModelWithParameter(Model * expression, float abscissa) const override; KDSize cursorSize() override; SequenceStore * m_sequenceStore; diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index e38d6321f..ea3a34ac3 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -65,7 +65,11 @@ void CurveView::setOkView(View * okView) { } float CurveView::resolution() const { - return k_resolution; + return bounds().width()*samplingRatio(); +} + +float CurveView::samplingRatio() const { + return 1.1f; } float CurveView::min(Axis axis) const { @@ -280,7 +284,7 @@ constexpr static int k_maxNumberOfIterations = 10; void CurveView::drawCurve(KDContext * ctx, KDRect rect, Model * curve, KDColor color, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, bool continuously) const { float xMin = min(Axis::Horizontal); float xMax = max(Axis::Horizontal); - float xStep = (xMax-xMin)/k_resolution; + float xStep = (xMax-xMin)/resolution(); float rectMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin); float rectMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin); for (float x = rectMin; x < rectMax; x += xStep) { diff --git a/apps/shared/curve_view.h b/apps/shared/curve_view.h index 2ba4a08f0..deb7997a2 100644 --- a/apps/shared/curve_view.h +++ b/apps/shared/curve_view.h @@ -26,11 +26,11 @@ public: void setCursorView(View * cursorView); void setBannerView(BannerView * bannerView); void setOkView(View * okView); - virtual float resolution() const; + float resolution() const; protected: void setCurveViewRange(CurveViewRange * curveViewRange); // Drawing methods - constexpr static int k_resolution = 350.0f; + virtual float samplingRatio() const; constexpr static KDCoordinate k_labelMargin = 4; constexpr static KDCoordinate k_okMargin = 10; constexpr static KDCoordinate k_labelGraduationLength = 6;