From 60a0bfb863aa2a05bafd943423c284f5c2d68863 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 25 Jan 2016 19:55:52 +0100 Subject: Scatterplots & splat now share the same scaling. --- manipulationhandler.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 manipulationhandler.cpp (limited to 'manipulationhandler.cpp') diff --git a/manipulationhandler.cpp b/manipulationhandler.cpp new file mode 100644 index 0000000..bb0e043 --- /dev/null +++ b/manipulationhandler.cpp @@ -0,0 +1,53 @@ +#include "manipulationhandler.h" + +#include +#include +#include + +#include "mp.h" +#include "numericrange.h" + +ManipulationHandler::ManipulationHandler(const arma::mat &X, + const arma::uvec &cpIndices) + : m_X(X) + , m_Y(X.n_rows, 2) + , m_cpIndices(cpIndices) + , m_rpIndices(X.n_rows - cpIndices.n_elem) + , 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; + + m_technique = technique; +} + +void ManipulationHandler::setCP(const arma::mat &Ys) +{ + switch (m_technique) { + case TECHNIQUE_PLMP: + 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); + break; + case TECHNIQUE_PEKALSKA: + // TODO + // mp::pekalska(m_X, m_cpIndices, Ys, m_Y); + break; + } + + emit cpChanged(m_Y.rows(m_cpIndices)); + emit rpChanged(m_Y.rows(m_rpIndices)); + emit mapChanged(m_Y); +} -- cgit v1.2.3