aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-01-26 18:15:50 +0100
committerSamuel Fadel <samuelfadel@gmail.com>2016-01-26 18:15:50 +0100
commit41e1b2bfb8e2ba3d0e74180200e7cc109171213e (patch)
tree27c7dbaa8fcdcc7efb300c0ea0a44b28d2ac76c0 /main.cpp
parent7f0f945c35bc8c12d55efbce7545995fc76892c1 (diff)
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
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp45
1 files changed, 30 insertions, 15 deletions
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<Scatterplot>("PM", 1, 0, "Scatterplot");
- qmlRegisterType<HistoryGraph>("PM", 1, 0, "HistoryGraph");
- qmlRegisterType<BarChart>("PM", 1, 0, "BarChart");
- qmlRegisterType<VoronoiSplat>("PM", 1, 0, "VoronoiSplat");
- qmlRegisterType<Colormap>("PM", 1, 0, "Colormap");
- qmlRegisterSingletonType<Main>("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<Scatterplot>("PM", 1, 0, "Scatterplot");
+ qmlRegisterType<BarChart>("PM", 1, 0, "BarChart");
+ qmlRegisterType<VoronoiSplat>("PM", 1, 0, "VoronoiSplat");
+ qmlRegisterType<Colormap>("PM", 1, 0, "Colormap");
+ qmlRegisterSingletonType<Main>("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<HistoryGraph *>("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<bool> &)),
m->rpPlot, SLOT(setSelection(const std::vector<bool> &)));
+ // 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);