From 6da67a32e56c101b9334d2c6f33bd5238d082330 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Fri, 24 Jul 2015 13:01:16 -0300 Subject: Color mapping in Scatterplot and initial measures. - Scatterplot: can now map any floating point data to colors; - Scatterplot: somewhat optimized geometry/material updates; - Removed anything related to labels where it was not necessary; - Added observers to implement distortion (via measures) visualization; - Added skeleton implementations of NP and silhouette. --- main.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 84579b5..70499e7 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,8 @@ #include "mp.h" #include "scatterplot.h" #include "interactionhandler.h" +#include "distortionobserver.h" +#include "npdistortion.h" int main(int argc, char **argv) { @@ -35,21 +37,27 @@ int main(int argc, char **argv) arma::uvec sampleIndices = arma::randi(subsampleSize, arma::distr_param(0, n-1)); arma::mat Ys(subsampleSize, 2, arma::fill::randn); Ys = mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys); - arma::mat subsampleData(subsampleSize, 3); - subsampleData.cols(0, 1) = Ys; - subsampleData.col(2) = labels(sampleIndices); Scatterplot *subsamplePlot = engine.rootObjects()[0]->findChild("subsamplePlot"); subsamplePlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); - subsamplePlot->setData(subsampleData); + subsamplePlot->setXY(Ys); + subsamplePlot->setColorData(labels(sampleIndices)); Scatterplot *plot = engine.rootObjects()[0]->findChild("plot"); // connect both plots through interaction handler - InteractionHandler interactionHandler(X, labels, sampleIndices); - QObject::connect(subsamplePlot, SIGNAL(dataChanged(const arma::mat &)), + InteractionHandler interactionHandler(X, sampleIndices); + QObject::connect(subsamplePlot, SIGNAL(xyChanged(const arma::mat &)), &interactionHandler, SLOT(setSubsample(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)), - plot, SLOT(setData(const arma::mat &))); + plot, SLOT(setXY(const arma::mat &))); + + // TODO: works; though it needs measures implementation + // std::unique_ptr distortionObs(new NPDistortion(X, sampleIndices)); + // QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)), + // distortionObs.get(), SLOT(setMap(const arma::mat &))); + // QObject::connect(distortionObs.get(), SIGNAL(mapChanged(const arma::vec &)), + // plot, SLOT(setColorData(const arma::vec &))); + interactionHandler.setSubsample(Ys); return app.exec(); -- cgit v1.2.3