diff options
-rw-r--r-- | scatterplot.cpp | 46 | ||||
-rw-r--r-- | scatterplot.h | 9 |
2 files changed, 9 insertions, 46 deletions
diff --git a/scatterplot.cpp b/scatterplot.cpp index 919c75c..cad93c7 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -21,7 +21,6 @@ Scatterplot::Scatterplot(QQuickItem *parent) , m_shouldUpdateGeometry(false) , m_shouldUpdateMaterials(false) , m_displaySplat(true) - , m_animationEasing(QEasingCurve::InOutQuart) { setClip(true); setFlag(QQuickItem::ItemHasContents); @@ -60,26 +59,24 @@ void Scatterplot::setXY(const arma::mat &xy, bool updateView) } if (m_xy.n_elem != xy.n_elem) { - m_oldXY = xy; m_selectedGlyphs.clear(); - } else { - m_oldXY = m_xy; } m_xy = xy; - float min = std::min(m_xy.col(0).min(), m_oldXY.col(0).min()); - float max = std::max(m_xy.col(0).max(), m_oldXY.col(0).max()); + float min, max; + min = m_xy.col(0).min(); + max = m_xy.col(0).max(); m_sx.setDomain(min, max); - min = std::min(m_xy.col(1).min(), m_oldXY.col(1).min()); - max = std::max(m_xy.col(1).max(), m_oldXY.col(1).max()); + + min = m_xy.col(1).min(); + max = m_xy.col(1).max(); m_sy.setDomain(min, max); emit xyChanged(m_xy); if (updateView) { updateGeometry(); - startAnimation(); } } @@ -244,7 +241,6 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) } node = node->nextSibling(); - animationTick(); return root; } @@ -292,9 +288,7 @@ void Scatterplot::updateGlyphs(QSGNode *glyphsNode) m_sy.setRange(height() - PADDING, PADDING); QSGNode *node = glyphsNode->firstChild(); - float t = m_animationEasing.valueForProgress(m_t); for (arma::uword i = 0; i < m_xy.n_rows; i++) { - const arma::rowvec &oldRow = m_oldXY.row(i); const arma::rowvec &row = m_xy.row(i); bool isSelected = m_selectedGlyphs.contains(i); @@ -305,8 +299,8 @@ void Scatterplot::updateGlyphs(QSGNode *glyphsNode) QSGGeometryNode *glyphNode = static_cast<QSGGeometryNode *>(node->firstChild()->nextSibling()); if (m_shouldUpdateGeometry) { moveTranslationF = isSelected ? 1.0 : 0.0; - x = m_sx(t*row[0] + (1 - t)*oldRow[0]) + tx * moveTranslationF; - y = m_sy(t*row[1] + (1 - t)*oldRow[1]) + ty * moveTranslationF; + x = m_sx(row[0]) + tx * moveTranslationF; + y = m_sy(row[1]) + ty * moveTranslationF; QSGGeometry *geometry = glyphOutlineNode->geometry(); updateCircleGeometry(geometry, GLYPH_SIZE / 2, x, y); @@ -327,30 +321,6 @@ void Scatterplot::updateGlyphs(QSGNode *glyphsNode) } } -void Scatterplot::resetAnimation() -{ - m_t = 0; -} - -void Scatterplot::startAnimation() -{ - if (m_t < 1.0f) { - m_t = 1.0f; - return; - } - - resetAnimation(); - update(); -} - -void Scatterplot::animationTick() -{ - if (m_t < 1.0f) { - m_t += 0.1f; - updateGeometry(); - } -} - void Scatterplot::mousePressEvent(QMouseEvent *event) { switch (m_currentInteractionState) { diff --git a/scatterplot.h b/scatterplot.h index d0153c0..fb664a1 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -55,11 +55,7 @@ private: void updateSplat(QSGNode *node); void updateGlyphs(QSGNode *node); - void resetAnimation(); - void startAnimation(); - void animationTick(); - - arma::mat m_oldXY, m_xy; + arma::mat m_xy; LinearScale<float> m_sx, m_sy; enum InteractionState { @@ -79,9 +75,6 @@ private: bool m_displaySplat; arma::vec m_colorData; ColorScale *m_colorScale; - - QEasingCurve m_animationEasing; - float m_t; }; #endif // SCATTERPLOT_H |