From 0bdc4110ac010685ee3e81552041bc553d848294 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 4 Apr 2016 17:16:08 -0300 Subject: LinePlot: working properly (and updates settings). Added the several options to the bundling (from CUBu) as properties of the LinePlot component, which are set from the options UI. In addition, many changes to the UI regarding those options. Added a new shortcut to hide options (for cleaner demos). --- main.cpp | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index c7a6f5c..bf9042a 100644 --- a/main.cpp +++ b/main.cpp @@ -153,9 +153,10 @@ int main(int argc, char **argv) // Initialize pointers to visual components m->cpPlot = engine.rootObjects()[0]->findChild("cpPlot"); m->rpPlot = engine.rootObjects()[0]->findChild("rpPlot"); + m->splat = engine.rootObjects()[0]->findChild("splat"); + m->bundlePlot = engine.rootObjects()[0]->findChild("bundlePlot"); m->cpColormap = engine.rootObjects()[0]->findChild("cpColormap"); m->rpColormap = engine.rootObjects()[0]->findChild("rpColormap"); - m->splat = engine.rootObjects()[0]->findChild("splat"); m->cpBarChart = engine.rootObjects()[0]->findChild("cpBarChart"); m->rpBarChart = engine.rootObjects()[0]->findChild("rpBarChart"); TransitionControl *plotTC = engine.rootObjects()[0]->findChild("plotTC"); @@ -170,6 +171,20 @@ int main(int argc, char **argv) QObject::connect(m->cpPlot, &Scatterplot::xyInteractivelyChanged, m, &Main::setCP); + // Keep both scatterplots, the splat and line plot scaled equally and + // relative to the full plot + MapScaleHandler mapScaleHandler; + QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, + m->cpPlot, &Scatterplot::setScale); + QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, + m->rpPlot, &Scatterplot::setScale); + QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, + m->splat, &VoronoiSplat::setScale); + QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, + m->bundlePlot, &LinePlot::setScale); + QObject::connect(m->projectionHistory, &ProjectionHistory::currentMapChanged, + &mapScaleHandler, &MapScaleHandler::scaleToMap); + // Update projection as the cp are modified (either directly in the // manipulationHandler object or interactively in cpPlot ManipulationHandler manipulationHandler(X, cpIndices); @@ -183,18 +198,32 @@ int main(int argc, char **argv) // ... and update visual components whenever the history changes QObject::connect(m->projectionHistory, &ProjectionHistory::currentMapChanged, m, &Main::updateMap); - - // Keep both scatterplots and the splat scaled equally and relative to the - // full plot - MapScaleHandler mapScaleHandler; - QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, - m->cpPlot, &Scatterplot::setScale); - QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, - m->rpPlot, &Scatterplot::setScale); - QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, - m->splat, &VoronoiSplat::setScale); QObject::connect(m->projectionHistory, &ProjectionHistory::currentMapChanged, - &mapScaleHandler, &MapScaleHandler::scaleToMap); + [m](const arma::mat &Y) { + // ... and bundling + const arma::mat &unreliability = m->projectionHistory->unreliability(); + arma::uvec indicesLargest = arma::sort_index(unreliability, "descending"); + auto numLargest = Y.n_rows * 0.1f; + indicesLargest = indicesLargest.subvec(0, numLargest-1); + m->bundlePlot->setValues(unreliability(indicesLargest)); + + const arma::uvec &cpIndices = m->projectionHistory->cpIndices(); + arma::uvec CPs = cpIndices(indicesLargest / unreliability.n_rows); + + const arma::uvec &rpIndices = m->projectionHistory->rpIndices(); + arma::uvec RPs = indicesLargest; + RPs.transform([&unreliability](arma::uword v) { + return v % unreliability.n_rows; + }); + RPs = rpIndices(RPs); + + arma::uvec indices(CPs.n_elem + RPs.n_elem); + for (arma::uword i = 0; i < CPs.n_elem; i++) { + indices(2*i + 0) = CPs(i); + indices(2*i + 1) = RPs(i); + } + m->bundlePlot->setLines(indices, Y); + }); // Linking between selections SelectionHandler cpSelectionHandler(cpIndices.n_elem); -- cgit v1.2.3