From 30f327b2fd25104916bffe6fe76823f0dbe35a72 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 29 Sep 2015 14:59:59 -0300 Subject: Inital history graph implementation and using linear scales where applicable. - geometry.h for geometry calculation functions - scale.h for implementations of scales (currently only the linear scale) - updated main_view.qml for the new HistoryGraph component - HistoryGraph displays each subsample used as a mini scatterplot (no colors currently) - Scatterplot now uses scale.h for transformations - Code cleanup and some bug fixes --- main.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 58578ac..e8a826e 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,7 @@ #include "mp.h" #include "continuouscolorscale.h" #include "scatterplot.h" +#include "historygraph.h" #include "interactionhandler.h" #include "selectionhandler.h" #include "effectivenessobserver.h" @@ -19,6 +20,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); qmlRegisterType("PM", 1, 0, "Scatterplot"); + qmlRegisterType("PM", 1, 0, "HistoryGraph"); // Set up multisampling QSurfaceFormat fmt; @@ -42,7 +44,6 @@ int main(int argc, char **argv) arma::mat Ys(subsampleSize, 2, arma::fill::randn); Ys = mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys); - /* ColorScale colorScale{ QColor("#1f77b4"), QColor("#ff7f0e"), @@ -55,14 +56,13 @@ int main(int argc, char **argv) QColor("#7f7f7f"), }; colorScale.setExtents(labels.min(), labels.max()); - */ - ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); - colorScale.setExtents(-1, 1); + //ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); + //colorScale.setExtents(-1, 1); Scatterplot *subsamplePlot = engine.rootObjects()[0]->findChild("subsamplePlot"); + HistoryGraph *history = engine.rootObjects()[0]->findChild("history"); subsamplePlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); - subsamplePlot->setXY(Ys); - subsamplePlot->setColorData(arma::zeros(subsampleSize)); + // subsamplePlot->setColorData(arma::zeros(subsampleSize)); subsamplePlot->setColorScale(&colorScale); Scatterplot *plot = engine.rootObjects()[0]->findChild("plot"); @@ -72,13 +72,16 @@ int main(int argc, char **argv) &interactionHandler, SLOT(setSubsample(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)), plot, SLOT(setXY(const arma::mat &))); + QObject::connect(subsamplePlot, SIGNAL(xyChanged(const arma::mat &)), + history, SLOT(addHistoryItem(const arma::mat &))); SelectionHandler selectionHandler(sampleIndices); - QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const arma::uvec &)), - &selectionHandler, SLOT(setSelection(const arma::uvec &))); - QObject::connect(&selectionHandler, SIGNAL(selectionChanged(const arma::uvec &)), - plot, SLOT(setSelection(const arma::uvec &))); + QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet &)), + &selectionHandler, SLOT(setSelection(const QSet &))); + QObject::connect(&selectionHandler, SIGNAL(selectionChanged(const QSet &)), + plot, SLOT(setSelection(const QSet &))); + /* DistortionObserver distortionObs(X, sampleIndices); std::unique_ptr distortionMeasure(new NPDistortion()); distortionObs.setMeasure(distortionMeasure.get()); @@ -94,11 +97,19 @@ int main(int argc, char **argv) &enforcer, SLOT(setMeasureDifference(const arma::vec &))); QObject::connect(&enforcer, SIGNAL(effectivenessChanged(const arma::vec &)), subsamplePlot, SLOT(setColorData(const arma::vec &))); + */ + /* ContinuousColorScale ccolorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); ccolorScale.setExtents(-1, 1); plot->setColorScale(&ccolorScale); - interactionHandler.setSubsample(Ys); + */ + plot->setColorScale(&colorScale); + plot->setColorData(labels); + + //interactionHandler.setSubsample(Ys); + subsamplePlot->setXY(Ys); + subsamplePlot->setColorData(labels(sampleIndices)); return app.exec(); } -- cgit v1.2.3