From b5ca997b2d2a64f955b78208d0362cba0278f8d3 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 11 Feb 2016 12:03:59 -0200 Subject: Modified the way the history interacts with other components. * Main class is now responsible for updating map components whenever the current map changes (even rewinding): this simplifies other objects because they don't have to know anything about how the data is being displayed later (no CP/RP juggling everywhere) * Added undo/reset actions to main view, including menu items * ProjectionHistory now has specific signals for each change happening to the history --- main.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index f34f7be..cf752a0 100644 --- a/main.cpp +++ b/main.cpp @@ -172,21 +172,27 @@ int main(int argc, char **argv) ManipulationHandler manipulationHandler(X, cpIndices, m->projectionHistory); QObject::connect(m->cpPlot, &Scatterplot::xyInteractivelyChanged, &manipulationHandler, &ManipulationHandler::setCP); - QObject::connect(&manipulationHandler, &ManipulationHandler::cpChanged, - m->cpPlot, &Scatterplot::setXY); - QObject::connect(&manipulationHandler, &ManipulationHandler::rpChanged, - m->rpPlot, &Scatterplot::setXY); - QObject::connect(&manipulationHandler, &ManipulationHandler::rpChanged, - m->splat, &VoronoiSplat::setSites); - - // Update history whenever a new projection is computed + + // Update history whenever a new projection is computed... QObject::connect(&manipulationHandler, &ManipulationHandler::mapChanged, m->projectionHistory, &ProjectionHistory::addMap); + // ... and update visual components whenever the history changes + QObject::connect(m->projectionHistory, &ProjectionHistory::mapAdded, + m, &Main::updateMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::undoPerformed, + m, &Main::updateMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::resetPerformed, + m, &Main::updateMap); + // Keep both scatterplots and the splat scaled equally and relative to the // full plot MapScaleHandler mapScaleHandler; - QObject::connect(&manipulationHandler, &ManipulationHandler::mapChanged, + QObject::connect(m->projectionHistory, &ProjectionHistory::mapAdded, + &mapScaleHandler, &MapScaleHandler::scaleToMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::undoPerformed, + &mapScaleHandler, &MapScaleHandler::scaleToMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::resetPerformed, &mapScaleHandler, &MapScaleHandler::scaleToMap); QObject::connect(&mapScaleHandler, &MapScaleHandler::scaleChanged, m->cpPlot, &Scatterplot::setScale); @@ -239,7 +245,11 @@ int main(int argc, char **argv) // Recompute values whenever projection changes ProjectionObserver projectionObserver(X, cpIndices, m->projectionHistory); m->projectionObserver = &projectionObserver; - QObject::connect(&manipulationHandler, &ManipulationHandler::mapChanged, + QObject::connect(m->projectionHistory, &ProjectionHistory::mapAdded, + m->projectionObserver, &ProjectionObserver::setMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::undoPerformed, + m->projectionObserver, &ProjectionObserver::setMap); + QObject::connect(m->projectionHistory, &ProjectionHistory::resetPerformed, m->projectionObserver, &ProjectionObserver::setMap); QObject::connect(m->projectionObserver, &ProjectionObserver::cpValuesChanged, m->cpPlot, &Scatterplot::setColorData); @@ -256,15 +266,11 @@ int main(int argc, char **argv) QObject::connect(&rpSelectionHandler, &SelectionHandler::selectionChanged, &projectionObserver, &ProjectionObserver::setRPSelection); - // Connect visual components (but not barcharts) to rewinding mechanism + // Connect projection components to rewinding mechanism QObject::connect(plotTC, &TransitionControl::tChanged, &manipulationHandler, &ManipulationHandler::setRewind); - QObject::connect(&manipulationHandler, &ManipulationHandler::cpRewound, - m->cpPlot, &Scatterplot::setXY); - QObject::connect(&manipulationHandler, &ManipulationHandler::rpRewound, - m->rpPlot, &Scatterplot::setXY); - QObject::connect(&manipulationHandler, &ManipulationHandler::rpRewound, - m->splat, &VoronoiSplat::setSites); + QObject::connect(&manipulationHandler, &ManipulationHandler::mapRewound, + m, &Main::updateMap); QObject::connect(plotTC, &TransitionControl::tChanged, m->projectionObserver, &ProjectionObserver::setRewind); -- cgit v1.2.3