From b5ca997b2d2a64f955b78208d0362cba0278f8d3 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 11 Feb 2016 12:03:59 -0200 Subject: Modified the way the history interacts with other components. * Main class is now responsible for updating map components whenever the current map changes (even rewinding): this simplifies other objects because they don't have to know anything about how the data is being displayed later (no CP/RP juggling everywhere) * Added undo/reset actions to main view, including menu items * ProjectionHistory now has specific signals for each change happening to the history --- main.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index 7d94770..904b458 100644 --- a/main.h +++ b/main.h @@ -4,12 +4,13 @@ #include #include -#include "barchart.h" -#include "colormap.h" #include "colorscale.h" #include "continuouscolorscale.h" #include "projectionobserver.h" #include "projectionhistory.h" +#include "numericrange.h" +#include "barchart.h" +#include "colormap.h" #include "scatterplot.h" #include "voronoisplat.h" @@ -134,10 +135,18 @@ public: // Shared object that controls manipulation history ProjectionHistory *projectionHistory; Q_INVOKABLE void undoManipulation() { projectionHistory->undo(); } - Q_INVOKABLE void resetManipulation() { projectionHistory->undoAll(); } + Q_INVOKABLE void resetManipulation() { projectionHistory->reset(); } public slots: - void setCPIndices(const arma::uvec &indices) { m_cpIndices = indices; } + void setCPIndices(const arma::uvec &indices) { + m_cpIndices = indices; + + m_rpIndices.set_size(m_dataset.n_rows - m_cpIndices.n_elem); + NumericRange allIndices(0, m_dataset.n_rows); + std::set_symmetric_difference(allIndices.cbegin(), allIndices.cend(), + m_cpIndices.cbegin(), m_cpIndices.cend(), m_rpIndices.begin()); + } + void setCP(const arma::mat &cp) { if (cp.n_cols != 2 || cp.n_rows != m_cpIndices.n_elem) { @@ -147,6 +156,14 @@ public slots: m_cp = cp; } + void updateMap(const arma::mat &Y) { + cpPlot->setXY(Y.rows(m_cpIndices)); + + const arma::mat ®ularPoints = Y.rows(m_rpIndices); + rpPlot->setXY(regularPoints); + splat->setSites(regularPoints); + } + private: Main(QObject *parent = 0) : QObject(parent) @@ -163,8 +180,11 @@ private: , cpPlot(0) , rpPlot(0) , splat(0) + , projectionObserver(0) + , projectionHistory(0) { } + ~Main() {} ColorScale &getColorScale(ColorScaleType colorScaleType) { @@ -183,7 +203,7 @@ private: } arma::mat m_dataset, m_cp; - arma::uvec m_cpIndices; + arma::uvec m_cpIndices, m_rpIndices; std::string m_indicesSavePath, m_cpSavePath; }; -- cgit v1.2.3