aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 3e62963..81362a6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -139,13 +139,13 @@ int main(int argc, char **argv)
fmt.setSamples(8);
QSurfaceFormat::setDefaultFormat(fmt);
+ // Register our custom QML types & init QML engine
qmlRegisterType<Scatterplot>("PM", 1, 0, "Scatterplot");
qmlRegisterType<BarChart>("PM", 1, 0, "BarChart");
qmlRegisterType<VoronoiSplat>("PM", 1, 0, "VoronoiSplat");
qmlRegisterType<Colormap>("PM", 1, 0, "Colormap");
qmlRegisterType<TransitionControl>("PM", 1, 0, "TransitionControl");
qmlRegisterSingletonType<Main>("PM", 1, 0, "Main", mainProvider);
-
QQmlApplicationEngine engine(QUrl("qrc:///main_view.qml"));
// Initialize pointers to visual components
@@ -157,6 +157,10 @@ int main(int argc, char **argv)
m->rpBarChart = engine.rootObjects()[0]->findChild<BarChart *>("rpBarChart");
TransitionControl *plotTC = engine.rootObjects()[0]->findChild<TransitionControl *>("plotTC");
+ // Shared object which stores modifications to projections
+ ProjectionHistory history;
+ m->projectionHistory = &history;
+
// Keep track of the current cp (in order to save them later, if requested)
QObject::connect(m->cpPlot, &Scatterplot::xyChanged,
m, &Main::setCP);
@@ -165,7 +169,7 @@ int main(int argc, char **argv)
// Update projection as the cp are modified (either directly in the
// manipulationHandler object or interactively in cpPlot
- ManipulationHandler manipulationHandler(X, cpIndices);
+ ManipulationHandler manipulationHandler(X, cpIndices, m->projectionHistory);
QObject::connect(m->cpPlot, &Scatterplot::xyInteractivelyChanged,
&manipulationHandler, &ManipulationHandler::setCP);
QObject::connect(&manipulationHandler, &ManipulationHandler::cpChanged,
@@ -175,6 +179,10 @@ int main(int argc, char **argv)
QObject::connect(&manipulationHandler, &ManipulationHandler::rpChanged,
m->splat, &VoronoiSplat::setSites);
+ // Update history whenever a new projection is computed
+ QObject::connect(&manipulationHandler, &ManipulationHandler::mapChanged,
+ m->projectionHistory, &ProjectionHistory::addMap);
+
// Keep both scatterplots and the splat scaled equally and relative to the
// full plot
MapScaleHandler mapScaleHandler;
@@ -229,7 +237,7 @@ int main(int argc, char **argv)
m->rpBarChart, &BarChart::brushItem);
// Recompute values whenever projection changes
- ProjectionObserver projectionObserver(X, cpIndices);
+ ProjectionObserver projectionObserver(X, cpIndices, m->projectionHistory);
m->projectionObserver = &projectionObserver;
QObject::connect(&manipulationHandler, &ManipulationHandler::mapChanged,
m->projectionObserver, &ProjectionObserver::setMap);