From 41e1b2bfb8e2ba3d0e74180200e7cc109171213e Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 26 Jan 2016 18:15:50 +0100 Subject: Scatterplot & BarChart: initial brushing mechanism. * Both components now support brushing (support in Scatterplot for activating a brush is still incomplete, though it can be brushed on by other components) * Added a handler for linking the brushing between components * Added crosshair geometry handler to geometry lib * Fixed issue #15 --- main.cpp | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 58d0f5a..a4f2bf0 100644 --- a/main.cpp +++ b/main.cpp @@ -13,12 +13,12 @@ #include "continuouscolorscale.h" #include "scatterplot.h" #include "voronoisplat.h" -#include "historygraph.h" #include "barchart.h" #include "colormap.h" #include "manipulationhandler.h" #include "mapscalehandler.h" #include "selectionhandler.h" +#include "brushinghandler.h" #include "projectionobserver.h" static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine) @@ -111,13 +111,6 @@ int main(int argc, char **argv) m->setCPIndices(cpIndices); m->setCP(Ys); - qmlRegisterType("PM", 1, 0, "Scatterplot"); - qmlRegisterType("PM", 1, 0, "HistoryGraph"); - qmlRegisterType("PM", 1, 0, "BarChart"); - qmlRegisterType("PM", 1, 0, "VoronoiSplat"); - qmlRegisterType("PM", 1, 0, "Colormap"); - qmlRegisterSingletonType
("PM", 1, 0, "Main", mainProvider); - // Set up multisampling QSurfaceFormat fmt; fmt.setRenderableType(QSurfaceFormat::OpenGL); @@ -129,6 +122,12 @@ int main(int argc, char **argv) fmt.setSamples(8); QSurfaceFormat::setDefaultFormat(fmt); + qmlRegisterType("PM", 1, 0, "Scatterplot"); + qmlRegisterType("PM", 1, 0, "BarChart"); + qmlRegisterType("PM", 1, 0, "VoronoiSplat"); + qmlRegisterType("PM", 1, 0, "Colormap"); + qmlRegisterSingletonType
("PM", 1, 0, "Main", mainProvider); + QQmlApplicationEngine engine(QUrl("qrc:///main_view.qml")); // Initialize pointers to visual components @@ -157,13 +156,6 @@ int main(int argc, char **argv) QObject::connect(&manipulationHandler, SIGNAL(rpChanged(const arma::mat &)), m->splat, SLOT(setSites(const arma::mat &))); - // Connections between history graph and cp plot - //HistoryGraph *history = engine.rootObjects()[0]->findChild("history"); - //QObject::connect(cpPlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)), - // history, SLOT(addHistoryItem(const arma::mat &))); - //QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)), - // cpPlot, SLOT(setXY(const arma::mat &))); - // Keep both scatterplots and the splat scaled equally and relative to the // full plot MapScaleHandler mapScaleHandler; @@ -196,6 +188,27 @@ int main(int argc, char **argv) QObject::connect(&rpSelectionHandler, SIGNAL(selectionChanged(const std::vector &)), m->rpPlot, SLOT(setSelection(const std::vector &))); + // Brushing between bar chart and respective scatterplot + BrushingHandler cpBrushHandler; + QObject::connect(m->cpPlot, SIGNAL(itemInteractivelyBrushed(int)), + &cpBrushHandler, SLOT(brushItem(int))); + QObject::connect(m->cpBarChart, SIGNAL(itemInteractivelyBrushed(int)), + &cpBrushHandler, SLOT(brushItem(int))); + QObject::connect(&cpBrushHandler, SIGNAL(itemBrushed(int)), + m->cpPlot, SLOT(brushItem(int))); + QObject::connect(&cpBrushHandler, SIGNAL(itemBrushed(int)), + m->cpBarChart, SLOT(brushItem(int))); + + BrushingHandler rpBrushHandler; + QObject::connect(m->rpPlot, SIGNAL(itemInteractivelyBrushed(int)), + &rpBrushHandler, SLOT(brushItem(int))); + QObject::connect(m->rpBarChart, SIGNAL(itemInteractivelyBrushed(int)), + &rpBrushHandler, SLOT(brushItem(int))); + QObject::connect(&rpBrushHandler, SIGNAL(itemBrushed(int)), + m->rpPlot, SLOT(brushItem(int))); + QObject::connect(&rpBrushHandler, SIGNAL(itemBrushed(int)), + m->rpBarChart, SLOT(brushItem(int))); + // Recompute values whenever projection changes ProjectionObserver projectionObserver(X, cpIndices); m->projectionObserver = &projectionObserver; @@ -210,6 +223,7 @@ int main(int argc, char **argv) QObject::connect(m->projectionObserver, SIGNAL(rpValuesChanged(const arma::vec &)), m->rpBarChart, SLOT(setValues(const arma::vec &))); + // General component set up m->cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); m->cpBarChart->setAcceptedMouseButtons(Qt::LeftButton); m->rpBarChart->setAcceptedMouseButtons(Qt::LeftButton); @@ -224,6 +238,7 @@ int main(int argc, char **argv) m->cpPlot->setAutoScale(false); m->rpPlot->setAutoScale(false); m->cpPlot->setColorData(labels(cpIndices), false); + //m->cpPlot->brushItem(0); manipulationHandler.setCP(Ys); -- cgit v1.2.3