diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2015-05-22 12:17:09 -0300 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2015-05-22 12:17:09 -0300 |
commit | 49b32975e9963de01b2ecc102b95488e4fdbf975 (patch) | |
tree | 7ea80fa21e515dbdbc1b239e09c8608fc6f527cd | |
parent | e8bb632cae4e7c9a320a3412cbd487f859ae104c (diff) |
Optimized InteractionHandler to minimze allocations; view updates now happen whenever a point is moved.
-rw-r--r-- | interactionhandler.cpp | 11 | ||||
-rw-r--r-- | interactionhandler.h | 2 | ||||
-rw-r--r-- | scatterplot.cpp | 6 |
3 files changed, 10 insertions, 9 deletions
diff --git a/interactionhandler.cpp b/interactionhandler.cpp index 217f4a5..5225be9 100644 --- a/interactionhandler.cpp +++ b/interactionhandler.cpp @@ -8,24 +8,21 @@ InteractionHandler::InteractionHandler(const arma::mat &X, : m_X(X) , m_labels(labels) , m_sampleIndices(sampleIndices) + , m_Y(X.n_rows, 3) , m_technique(TECHNIQUE_LAMP) { + m_Y.col(2) = m_labels; } void InteractionHandler::setSubsample(const arma::mat &Ys) { - arma::mat embedding(m_X.n_rows, Ys.n_cols); switch (m_technique) { case TECHNIQUE_PLMP: case TECHNIQUE_LSP: case TECHNIQUE_LAMP: - embedding = mp::lamp(m_X, m_sampleIndices, Ys); + m_Y.cols(0, 1) = mp::lamp(m_X, m_sampleIndices, Ys); break; } - arma::mat Y(embedding.n_rows, embedding.n_cols + 1); - Y.cols(0, embedding.n_cols - 1) = embedding; - Y.col(Y.n_cols - 1) = m_labels; - - emit subsampleChanged(Y); + emit subsampleChanged(m_Y); } diff --git a/interactionhandler.h b/interactionhandler.h index 3dbeb8a..5468dab 100644 --- a/interactionhandler.h +++ b/interactionhandler.h @@ -24,7 +24,7 @@ public slots: void setSubsample(const arma::mat &Ys); private: - arma::mat m_X; + arma::mat m_X, m_Y; arma::vec m_labels; arma::uvec m_sampleIndices; InteractiveTechnique m_technique; diff --git a/scatterplot.cpp b/scatterplot.cpp index b0c8034..284f17b 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -214,9 +214,14 @@ void Scatterplot::mouseMoveEvent(QMouseEvent *event) case INTERACTION_SELECTED: return; case INTERACTION_SELECTING: + m_dragCurrentPos = event->localPos(); + update(); + break; case INTERACTION_MOVING: m_dragCurrentPos = event->localPos(); + updateData(); update(); + m_dragOriginPos = m_dragCurrentPos; break; } } @@ -235,7 +240,6 @@ void Scatterplot::mouseReleaseEvent(QMouseEvent *event) case INTERACTION_MOVING: m_currentState = INTERACTION_SELECTED; - updateData(); update(); break; case INTERACTION_NONE: |