aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-04-04 17:16:08 -0300
committerSamuel Fadel <samuelfadel@gmail.com>2016-04-04 17:16:08 -0300
commit0bdc4110ac010685ee3e81552041bc553d848294 (patch)
treede0f68c45bdf85b14d830796239ef14ce0a8e411 /main.cpp
parent0615b37b56f3c2ffaf46255808a60f16b1d5be7c (diff)
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).
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp53
1 files changed, 41 insertions, 12 deletions
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<Scatterplot *>("cpPlot");
m->rpPlot = engine.rootObjects()[0]->findChild<Scatterplot *>("rpPlot");
+ m->splat = engine.rootObjects()[0]->findChild<VoronoiSplat *>("splat");
+ m->bundlePlot = engine.rootObjects()[0]->findChild<LinePlot *>("bundlePlot");
m->cpColormap = engine.rootObjects()[0]->findChild<Colormap *>("cpColormap");
m->rpColormap = engine.rootObjects()[0]->findChild<Colormap *>("rpColormap");
- m->splat = engine.rootObjects()[0]->findChild<VoronoiSplat *>("splat");
m->cpBarChart = engine.rootObjects()[0]->findChild<BarChart *>("cpBarChart");
m->rpBarChart = engine.rootObjects()[0]->findChild<BarChart *>("rpBarChart");
TransitionControl *plotTC = engine.rootObjects()[0]->findChild<TransitionControl *>("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);