aboutsummaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-02-11 12:03:59 -0200
committerSamuel Fadel <samuelfadel@gmail.com>2016-02-11 12:03:59 -0200
commitb5ca997b2d2a64f955b78208d0362cba0278f8d3 (patch)
tree0dbd235d7c91c11968946142e8ed7df155471c7e /main.h
parentff08c0541156faf8a220a62b4192a80803b86da3 (diff)
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
Diffstat (limited to 'main.h')
-rw-r--r--main.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/main.h b/main.h
index 7d94770..904b458 100644
--- a/main.h
+++ b/main.h
@@ -4,12 +4,13 @@
#include <QObject>
#include <armadillo>
-#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<arma::uword> 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 &regularPoints = 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;
};