From d7dd95cd9eaa223ff8b86e84e6b1b488ff79bcd5 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sat, 19 Dec 2015 12:29:33 +0100 Subject: New rendering (VoronoiSplat) -- incomplete. * Added voronoi-like splatting to points: the same technique from Messias et al., (2014) * It is now possible to change the projection technique during runtime (possible, but still requires some work) --- main.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 81498a7..64560d3 100644 --- a/main.cpp +++ b/main.cpp @@ -12,12 +12,14 @@ #include "mp.h" #include "continuouscolorscale.h" #include "scatterplot.h" +#include "voronoisplat.h" #include "historygraph.h" #include "interactionhandler.h" #include "selectionhandler.h" #include "effectivenessobserver.h" #include "distortionobserver.h" #include "npdistortion.h" +#include "skelft.h" static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { @@ -155,12 +157,16 @@ int main(int argc, char **argv) m->setSubsample(Ys); qmlRegisterType("PM", 1, 0, "Scatterplot"); + qmlRegisterType("PM", 1, 0, "VoronoiSplat"); qmlRegisterType("PM", 1, 0, "HistoryGraph"); + qmlRegisterType("PM", 1, 0, "InteractionHandler"); qmlRegisterSingletonType
("PM", 1, 0, "Main", mainProvider); // Set up multisampling QSurfaceFormat fmt; fmt.setSamples(16); + fmt.setRenderableType(QSurfaceFormat::OpenGL); + fmt.setVersion(4, 5); QSurfaceFormat::setDefaultFormat(fmt); QQmlApplicationEngine engine(QUrl("qrc:///main_view.qml")); @@ -184,6 +190,8 @@ int main(int argc, char **argv) // subsamplePlot->setColorData(arma::zeros(subsampleSize)); subsamplePlot->setColorScale(&colorScale); Scatterplot *plot = engine.rootObjects()[0]->findChild("plot"); + VoronoiSplat *splat = engine.rootObjects()[0]->findChild("splat"); + skelft2DInitialization(splat->width()); // Keep track of the current subsample (in order to save them later, if requested) QObject::connect(subsamplePlot, SIGNAL(xyChanged(const arma::mat &)), @@ -191,15 +199,22 @@ int main(int argc, char **argv) QObject::connect(subsamplePlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)), m, SLOT(setSubsample(const arma::mat &))); - // Update LAMP projection as the subsample is modified + // Update projection as the subsample is modified InteractionHandler interactionHandler(X, sampleIndices); - interactionHandler.setTechnique(InteractionHandler::TECHNIQUE_LAMP); + m->setInteractionHandler(&interactionHandler); QObject::connect(subsamplePlot, SIGNAL(xyChanged(const arma::mat &)), &interactionHandler, SLOT(setSubsample(const arma::mat &))); QObject::connect(subsamplePlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)), &interactionHandler, SLOT(setSubsample(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)), plot, SLOT(setXY(const arma::mat &))); + m->setTechnique(InteractionHandler::TECHNIQUE_LAMP); + + // Update splat whenever the main plot is also updated + QObject::connect(plot, SIGNAL(xyChanged(const arma::mat &)), + splat, SLOT(setPoints(const arma::mat &))); + QObject::connect(plot, SIGNAL(colorDataChanged(const arma::vec &)), + splat, SLOT(setValues(const arma::vec &))); // Linking between selections in subsample plot and full dataset plot SelectionHandler selectionHandler(sampleIndices); @@ -237,7 +252,11 @@ int main(int argc, char **argv) subsamplePlot->setXY(Ys); subsamplePlot->setColorData(labels(sampleIndices)); plot->setColorScale(&colorScale); + splat->setColorScale(&colorScale); plot->setColorData(labels); - return app.exec(); + auto ret = app.exec(); + + skelft2DDeinitialization(); + return ret; } -- cgit v1.2.3