From 0b6df071d94ae8f7c9cdd3c96506a1420129e471 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Fri, 15 May 2015 18:10:52 -0300 Subject: Initial commit. ForceScheme seems bugged. --- main.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..863a20d --- /dev/null +++ b/main.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +#include "mp.h" +#include "glyph.h" +#include "scatterplot.h" + +arma::uvec getSample(arma::uword n) +{ + return arma::randi((arma::uword) 3*sqrt(n), arma::distr_param(0, n-1)); +} + +arma::mat getProjection(const arma::mat &X) +{ + arma::uword n = X.n_rows; + arma::uvec sampleIndices = getSample(n); + arma::mat Ys = arma::randn(sampleIndices.n_elem, 2); + Ys = mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys); + return mp::lamp(X, sampleIndices, Ys); +} + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("PM", 1, 0, "Scatterplot"); + qmlRegisterType("PM", 1, 0, "Glyph"); + + QQuickView view; + QSurfaceFormat format = view.format(); + format.setSamples(16); + view.setFormat(format); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///main_view.qml")); + + if (argc > 1) { + arma::mat X; + X.load(argv[1], arma::raw_ascii); + arma::mat projection = getProjection(X); + Scatterplot *plot = view.rootObject()->findChild("plot", Qt::FindDirectChildrenOnly); + plot->setData(projection); + } + + view.show(); + + return app.exec(); +} -- cgit v1.2.3