From b45a21976bece19da81166324dc1cc4260a0e0f4 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Wed, 10 Feb 2016 18:31:48 -0200 Subject: Added ProjectionHistory object for history tracking. --- manipulationhandler.cpp | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) (limited to 'manipulationhandler.cpp') diff --git a/manipulationhandler.cpp b/manipulationhandler.cpp index 5bd916a..f764eaf 100644 --- a/manipulationhandler.cpp +++ b/manipulationhandler.cpp @@ -6,72 +6,51 @@ #include "numericrange.h" ManipulationHandler::ManipulationHandler(const arma::mat &X, - const arma::uvec &cpIndices) + const arma::uvec &cpIndices, + ProjectionHistory *history) : m_X(X) - , m_Y(X.n_rows, 2) - , m_firstY(X.n_rows, 2) - , m_prevY(X.n_rows, 2) , m_cpIndices(cpIndices) , m_rpIndices(X.n_rows - cpIndices.n_elem) - , m_hasFirst(false) - , m_hasPrev(false) + , m_history(history) , m_technique(TECHNIQUE_LAMP) { - NumericRange range(0, m_X.n_rows); - std::set_symmetric_difference(range.cbegin(), range.cend(), - m_cpIndices.cbegin(), m_cpIndices.cend(), m_rpIndices.begin()); -} - -void ManipulationHandler::setTechnique(ManipulationHandler::Technique technique) -{ - if (m_technique == technique) - return; + Q_ASSERT(history); - m_technique = technique; + NumericRange allIndices(0, m_X.n_rows); + std::set_symmetric_difference(allIndices.cbegin(), allIndices.cend(), + m_cpIndices.cbegin(), m_cpIndices.cend(), m_rpIndices.begin()); } void ManipulationHandler::setCP(const arma::mat &Ys) { - if (m_hasFirst) { - m_prevY = m_Y; - m_hasPrev = true; - } - + arma::mat Y(m_X.n_rows, 2); switch (m_technique) { case TECHNIQUE_PLMP: // TODO? - // mp::plmp(m_X, m_cpIndices, Ys, m_Y); break; case TECHNIQUE_LSP: // TODO? - // mp::lsp(m_X, m_cpIndices, Ys, m_Y); break; case TECHNIQUE_LAMP: - mp::lamp(m_X, m_cpIndices, Ys, m_Y); + mp::lamp(m_X, m_cpIndices, Ys, Y); break; case TECHNIQUE_PEKALSKA: // TODO? - // mp::pekalska(m_X, m_cpIndices, Ys, m_Y); break; } - if (!m_hasFirst) { - m_hasFirst = true; - m_firstY = m_Y; - } - - emit cpChanged(m_Y.rows(m_cpIndices)); - emit rpChanged(m_Y.rows(m_rpIndices)); - emit mapChanged(m_Y); + emit cpChanged(Y.rows(m_cpIndices)); + emit rpChanged(Y.rows(m_rpIndices)); + emit mapChanged(Y); } void ManipulationHandler::setRewind(double t) { - if (!m_hasPrev) { + if (!m_history->hasPrev()) { return; } - arma::mat Y = m_Y * t + m_prevY * (1.0 - t); + arma::mat Y = m_history->Y() * t + m_history->prev() * (1.0 - t); emit cpRewound(Y.rows(m_cpIndices)); emit rpRewound(Y.rows(m_rpIndices)); emit mapRewound(Y); -- cgit v1.2.3