diff --git a/apps/sequence/graph/graph_view.cpp b/apps/sequence/graph/graph_view.cpp index 18ada18e1..a000de9b1 100644 --- a/apps/sequence/graph/graph_view.cpp +++ b/apps/sequence/graph/graph_view.cpp @@ -12,8 +12,7 @@ GraphView::GraphView(SequenceStore * sequenceStore, InteractiveCurveViewRange * m_verticalCursor(false), m_highlightedDotStart(-1), m_highlightedDotEnd(-1), - m_shouldColorHighlighted(false), - m_selectedSequence(nullptr) + m_shouldColorHighlighted(false) { } @@ -34,7 +33,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const { continue; } drawDot(ctx, rect, x, y, s->color()); - if (x >= m_highlightedDotStart && x <= m_highlightedDotEnd && s == m_selectedSequence) { + if (x >= m_highlightedDotStart && x <= m_highlightedDotEnd && s == m_selectedFunction) { KDColor color = m_shouldColorHighlighted ? s->color() : KDColorBlack; if (y >= 0.0f) { drawSegment(ctx, rect, Axis::Vertical, x, 0.0f, y, color, 1); @@ -63,14 +62,6 @@ void GraphView::reload() { } } -void GraphView::selectSequence(Sequence * sequence) { - if (m_selectedSequence != sequence) { - reload(); - m_selectedSequence = sequence; - reload(); - } -} - void GraphView::setHighlight(int start, int end) { if (m_highlightedDotStart != start || m_highlightedDotEnd != end) { reload(); diff --git a/apps/sequence/graph/graph_view.h b/apps/sequence/graph/graph_view.h index b5723689d..722466205 100644 --- a/apps/sequence/graph/graph_view.h +++ b/apps/sequence/graph/graph_view.h @@ -13,7 +13,6 @@ public: void drawRect(KDContext * ctx, KDRect rect) const override; void setVerticalCursor(bool verticalCursor); void reload() override; - void selectSequence(Sequence * sequence); void setHighlight(int start, int end); void setHighlightColor(bool highlightColor); private: @@ -24,7 +23,6 @@ private: int m_highlightedDotStart; int m_highlightedDotEnd; bool m_shouldColorHighlighted; - Sequence * m_selectedSequence; }; } diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index a22e729e0..a58b17f91 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -159,7 +159,7 @@ bool TermSumController::moveCursorHorizontallyToPosition(int position) { } void TermSumController::setSequence(Sequence * sequence) { - m_graphView->selectSequence(sequence); + m_graphView->selectFunction(sequence); m_sequence = sequence; } diff --git a/apps/shared/function_graph_view.cpp b/apps/shared/function_graph_view.cpp index 47d7359eb..40e2d59b3 100644 --- a/apps/shared/function_graph_view.cpp +++ b/apps/shared/function_graph_view.cpp @@ -9,6 +9,7 @@ namespace Shared { FunctionGraphView::FunctionGraphView(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, BannerView * bannerView, View * cursorView) : CurveView(graphRange, cursor, bannerView, cursorView), + m_selectedFunction(nullptr), m_xLabels{}, m_yLabels{}, m_context(nullptr) @@ -32,6 +33,14 @@ Context * FunctionGraphView::context() const { return m_context; } +void FunctionGraphView::selectFunction(Function * function) { + if (m_selectedFunction != function) { + reload(); + m_selectedFunction = function; + reload(); + } +} + char * FunctionGraphView::label(Axis axis, int index) const { return (axis == Axis::Horizontal ? (char *)m_xLabels[index] : (char *)m_yLabels[index]); } diff --git a/apps/shared/function_graph_view.h b/apps/shared/function_graph_view.h index 281db74a5..1a03e91d6 100644 --- a/apps/shared/function_graph_view.h +++ b/apps/shared/function_graph_view.h @@ -3,6 +3,7 @@ #include #include "curve_view.h" +#include "function.h" #include "../constant.h" #include "interactive_curve_view_range.h" @@ -15,6 +16,9 @@ public: void drawRect(KDContext * ctx, KDRect rect) const override; void setContext(Poincare::Context * context); Poincare::Context * context() const; + void selectFunction(Function * function); +protected: + Function * m_selectedFunction; private: char * label(Axis axis, int index) const override; char m_xLabels[k_maxNumberOfXLabels][Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];