[apps/regression] Fix cursor redrawing when changing cursor type

Scenario:
double x[numberOfPoints] = {0.0, 0.975, 1.97, 2.945, 3.971, 4.887, 5.924, 6.964, 7.979, 8.974, 9.998};
double y[numberOfPoints] = {-23.784, -23.322, -28.322, -18.422, -4.813206, 7.146241, 16.631, 16.632, 9.209189, -6.050863, -19.659};
Quadratic regression, navigate on the points then go on the
regressioncurve -> there is a drawing glitch
This commit is contained in:
Léa Saviot
2019-09-27 17:37:11 +02:00
committed by EmilieNumworks
parent 1868e47b19
commit 2dee8f2b1f
3 changed files with 19 additions and 4 deletions

View File

@@ -82,16 +82,16 @@ void GraphController::viewWillAppear() {
/* Since *m_selectedDotIndex is altered by initCursorParameters(),
* the following must absolutely come at the end. */
if (*m_selectedDotIndex >= 0) {
m_view.setCursorView(static_cast<Shared::CursorView *>(&m_crossCursorView));
setRoundCrossCursorView(false);
} else {
m_view.setCursorView(static_cast<Shared::CursorView *>(&m_roundCursorView));
setRoundCrossCursorView(true);
m_roundCursorView.setColor(Palette::DataColor[*m_selectedSeriesIndex]);
}
}
void GraphController::selectRegressionCurve() {
*m_selectedDotIndex = -1;
m_view.setCursorView(&m_roundCursorView);
setRoundCrossCursorView(true);
m_roundCursorView.setColor(Palette::DataColor[*m_selectedSeriesIndex]);
}
@@ -334,7 +334,7 @@ bool GraphController::moveCursorVertically(int direction) {
if (validDot) {
// Select the dot
m_view.setCursorView(&m_crossCursorView);
setRoundCrossCursorView(false);
*m_selectedSeriesIndex = closestDotSeries;
*m_selectedDotIndex = dotSelected;
if (dotSelected == m_store->numberOfPairsOfSeries(*m_selectedSeriesIndex)) {
@@ -404,4 +404,15 @@ InteractiveCurveViewRangeDelegate::Range GraphController::computeYRange(Interact
return range;
}
void GraphController::setRoundCrossCursorView(bool round) {
CursorView * nextCursorView = round ? static_cast<Shared::CursorView *>(&m_roundCursorView) : static_cast<Shared::CursorView *>(&m_crossCursorView);
if (m_view.cursorView() == nextCursorView) {
return;
}
#ifdef GRAPH_CURSOR_SPEEDUP
m_roundCursorView.resetMemoization();
#endif
m_view.setCursorView(nextCursorView);
}
}

View File

@@ -55,6 +55,7 @@ private:
// InteractiveCurveViewRangeDelegate
Shared::InteractiveCurveViewRangeDelegate::Range computeYRange(Shared::InteractiveCurveViewRange * interactiveCurveViewRange) override;
void setRoundCrossCursorView(bool round);
Shared::CursorView m_crossCursorView;
Shared::RoundCursorView m_roundCursorView;
BannerView m_bannerView;

View File

@@ -14,6 +14,9 @@ public:
KDSize minimalSizeForOptimalDisplay() const override;
void setColor(KDColor color);
void setCursorFrame(KDRect frame) override;
#ifdef GRAPH_CURSOR_SPEEDUP
void resetMemoization() const { m_underneathPixelBufferLoaded = false; }
#endif
private:
#ifdef GRAPH_CURSOR_SPEEDUP
bool eraseCursorIfPossible();