From 2007ebb8e431d1341583a03c22d440a7d0f79194 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 5 Oct 2015 14:20:47 -0300 Subject: Re-added effectiveness observer (still needs work). --- main.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 559d554..5dbbe8b 100644 --- a/main.cpp +++ b/main.cpp @@ -39,10 +39,10 @@ int main(int argc, char **argv) arma::vec labels = dataset.col(dataset.n_cols - 1); arma::uword n = dataset.n_rows; - arma::uword subsampleSize = (arma::uword) sqrt(n) * 3; + arma::uword subsampleSize = (arma::uword) n / 10.f; arma::uvec sampleIndices = arma::randi(subsampleSize, arma::distr_param(0, n-1)); arma::mat Ys(subsampleSize, 2, arma::fill::randn); - Ys = mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys); + mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys); ColorScale colorScale{ QColor("#1f77b4"), @@ -60,7 +60,6 @@ int main(int argc, char **argv) //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->setColorData(arma::zeros(subsampleSize)); subsamplePlot->setColorScale(&colorScale); @@ -74,18 +73,21 @@ 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(xyInteractivelyChanged(const arma::mat &)), - history, SLOT(addHistoryItem(const arma::mat &))); - QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)), - subsamplePlot, SLOT(setXY(const arma::mat &))); + // linking between selections in subsample plot and full dataset plot SelectionHandler selectionHandler(sampleIndices); QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet &)), &selectionHandler, SLOT(setSelection(const QSet &))); QObject::connect(&selectionHandler, SIGNAL(selectionChanged(const QSet &)), plot, SLOT(setSelection(const QSet &))); - /* + HistoryGraph *history = engine.rootObjects()[0]->findChild("history"); + // connections between history graph and subsample plot + QObject::connect(subsamplePlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)), + history, SLOT(addHistoryItem(const arma::mat &))); + QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)), + subsamplePlot, SLOT(setXY(const arma::mat &))); + DistortionObserver distortionObs(X, sampleIndices); std::unique_ptr distortionMeasure(new NPDistortion()); distortionObs.setMeasure(distortionMeasure.get()); @@ -95,13 +97,12 @@ int main(int argc, char **argv) plot, SLOT(setColorData(const arma::vec &))); EffectiveInteractionEnforcer enforcer(sampleIndices); - QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const arma::uvec &)), - &enforcer, SLOT(setSelection(const arma::uvec &))); + QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet &)), + &enforcer, SLOT(setSelection(const QSet &))); QObject::connect(plot, SIGNAL(colorDataChanged(const arma::vec &)), &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); @@ -109,11 +110,11 @@ int main(int argc, char **argv) plot->setColorScale(&ccolorScale); */ plot->setColorScale(&colorScale); - plot->setColorData(labels); history->addHistoryItem(Ys); subsamplePlot->setXY(Ys); subsamplePlot->setColorData(labels(sampleIndices)); + plot->setColorData(labels); return app.exec(); } -- cgit v1.2.3