From 8cc4c24249600392871cc802f3ac4dd27368d335 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 18 Jan 2016 15:46:05 +0100 Subject: Added observer to update values displayed based on some metric. * Modified main() function to connect signals/slots to display calculated values * Color scales are no longer shared; they are also normalized to each component's own data * Stub mouse handling in BarChart (changes cursor shape) --- main.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index d2eb5f6..c58d216 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,7 @@ #include "barchart.h" #include "colormap.h" #include "interactionhandler.h" -#include "selectionhandler.h" +#include "projectionobserver.h" #include "skelft.h" static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine) @@ -130,14 +130,12 @@ int main(int argc, char **argv) //}; //colorScale.setExtents(labels.min(), labels.max()); - ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RAINBOW); - colorScale.setExtents(labels.min(), labels.max()); + ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS); Scatterplot *cpPlot = engine.rootObjects()[0]->findChild("cpPlot"); + Scatterplot *rpPlot = engine.rootObjects()[0]->findChild("rpPlot"); cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); // cpPlot->setColorData(arma::zeros(cpSize)); - cpPlot->setColorScale(&colorScale); - Scatterplot *plot = engine.rootObjects()[0]->findChild("plot"); VoronoiSplat *splat = engine.rootObjects()[0]->findChild("splat"); skelft2DInitialization(splat->width()); Colormap *colormap = engine.rootObjects()[0]->findChild("colormap"); @@ -151,17 +149,17 @@ int main(int argc, char **argv) // Update projection as the cp are modified InteractionHandler interactionHandler(X, cpIndices); m->setInteractionHandler(&interactionHandler); + m->setTechnique(InteractionHandler::TECHNIQUE_LAMP); QObject::connect(cpPlot, SIGNAL(xyChanged(const arma::mat &)), &interactionHandler, SLOT(setCP(const arma::mat &))); QObject::connect(cpPlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)), &interactionHandler, SLOT(setCP(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(cpChanged(const arma::mat &)), - plot, SLOT(setXY(const arma::mat &))); + rpPlot, SLOT(setXY(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(cpChanged(const arma::mat &)), splat, SLOT(setSites(const arma::mat &))); - m->setTechnique(InteractionHandler::TECHNIQUE_LAMP); - // Linking between selections in cp plot and full dataset plot + // Linking between selections in cp plot and rp plot //SelectionHandler selectionHandler(cpIndices); //QObject::connect(cpPlot, SIGNAL(selectionChanged(const QSet &)), // &selectionHandler, SLOT(setSelection(const QSet &))); @@ -175,30 +173,34 @@ int main(int argc, char **argv) //QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)), // cpPlot, SLOT(setXY(const arma::mat &))); - QObject::connect(plot, SIGNAL(scaleChanged(const LinearScale &, const LinearScale &)), + QObject::connect(rpPlot, SIGNAL(scaleChanged(const LinearScale &, const LinearScale &)), cpPlot, SLOT(setScale(const LinearScale &, const LinearScale &))); BarChart *barChart = engine.rootObjects()[0]->findChild("barChart"); - barChart->setColorScale(&colorScale); - barChart->setValues(labels); + barChart->setAcceptedMouseButtons(Qt::LeftButton); + barChart->setColorScale(colorScale); + + ProjectionObserver projectionObserver(X, cpIndices); + QObject::connect(&interactionHandler, SIGNAL(cpChanged(const arma::mat &)), + &projectionObserver, SLOT(setMap(const arma::mat &))); + QObject::connect(&projectionObserver, SIGNAL(mapChanged(const arma::vec &)), + rpPlot, SLOT(setColorData(const arma::vec &))); + QObject::connect(&projectionObserver, SIGNAL(mapChanged(const arma::vec &)), + splat, SLOT(setValues(const arma::vec &))); + QObject::connect(&projectionObserver, SIGNAL(mapChanged(const arma::vec &)), + barChart, SLOT(setValues(const arma::vec &))); //history->addHistoryItem(Ys); colormap->setColorScale(colorScale); - plot->setColorScale(&colorScale); - plot->setColorData(labels, false); + rpPlot->setColorScale(colorScale); splat->setColorScale(colorScale); - splat->setValues(labels); + cpPlot->setColorScale(colorScale); cpPlot->setAutoScale(false); cpPlot->setColorData(labels(cpIndices), false); cpPlot->setXY(Ys, false); cpPlot->update(); - arma::vec plotOpacities(X.n_rows); - plotOpacities.fill(0.0f); - plotOpacities(cpIndices).fill(0.0f); - plot->setOpacityData(plotOpacities); - auto ret = app.exec(); skelft2DDeinitialization(); -- cgit v1.2.3