diff options
-rw-r--r-- | main.cpp | 34 | ||||
-rw-r--r-- | scatterplot.cpp | 27 | ||||
-rw-r--r-- | scatterplot.h | 2 |
3 files changed, 26 insertions, 37 deletions
@@ -17,9 +17,6 @@ #include "barchart.h" #include "interactionhandler.h" #include "selectionhandler.h" -#include "effectivenessobserver.h" -#include "distortionobserver.h" -#include "npdistortion.h" #include "skelft.h" static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine) @@ -211,12 +208,6 @@ int main(int argc, char **argv) plot, SLOT(setXY(const arma::mat &))); m->setTechnique(InteractionHandler::TECHNIQUE_LAMP); - // Update splat whenever the main plot is also updated - //QObject::connect(plot, SIGNAL(xyChanged(const arma::mat &)), - // splat, SLOT(setPoints(const arma::mat &))); - //QObject::connect(plot, SIGNAL(colorDataChanged(const arma::vec &)), - // splat, SLOT(setValues(const arma::vec &))); - // Linking between selections in subsample plot and full dataset plot SelectionHandler selectionHandler(sampleIndices); QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet<int> &)), @@ -234,29 +225,12 @@ int main(int argc, char **argv) BarChart *barChart = engine.rootObjects()[0]->findChild<BarChart *>("barChart"); barChart->setValues(arma::randn<arma::vec>(100)); - // Map distortion as the glyph color - //DistortionObserver distortionObs(X, sampleIndices); - //std::unique_ptr<DistortionMeasure> distortionMeasure(new NPDistortion()); - //distortionObs.setMeasure(distortionMeasure.get()); - //QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)), - // &distortionObs, SLOT(setMap(const arma::mat &))); - //QObject::connect(&distortionObs, SIGNAL(mapChanged(const arma::vec &)), - // plot, SLOT(setColorData(const arma::vec &))); - - //EffectiveInteractionEnforcer enforcer(sampleIndices); - //QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet<int> &)), - // &enforcer, SLOT(setSelection(const QSet<int> &))); - //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 &))); - //history->addHistoryItem(Ys); - subsamplePlot->setXY(Ys); - subsamplePlot->setColorData(labels(sampleIndices)); plot->setColorScale(&colorScale); - //splat->setColorScale(&colorScale); - plot->setColorData(labels); + plot->setColorData(labels, false); + subsamplePlot->setXY(Ys, false); + subsamplePlot->setColorData(labels(sampleIndices), false); + subsamplePlot->update(); auto ret = app.exec(); diff --git a/scatterplot.cpp b/scatterplot.cpp index 62a492b..96e9ecb 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -53,7 +53,7 @@ bool Scatterplot::saveToFile(const QUrl &url) return m_xy.save(url.path().toStdString(), arma::raw_ascii); } -void Scatterplot::setXY(const arma::mat &xy) +void Scatterplot::setXY(const arma::mat &xy, bool updateView) { if (xy.n_cols != 2) { return; @@ -75,23 +75,36 @@ void Scatterplot::setXY(const arma::mat &xy) max = std::max(m_xy.col(1).max(), m_oldXY.col(1).max()); m_sy.setDomain(min, max); - updateGeometry(); - emit xyChanged(m_xy); - startAnimation(); + if (updateView) { + updateGeometry(); + startAnimation(); + } } -void Scatterplot::setColorData(const arma::vec &colorData) +void Scatterplot::setXY(const arma::mat &xy) { - if (colorData.n_elem != m_xy.n_rows) { + setXY(xy, true); +} + +void Scatterplot::setColorData(const arma::vec &colorData, bool updateView) +{ + if (m_xy.n_rows > 0 && colorData.n_elem != m_xy.n_rows) { return; } m_colorData = colorData; emit colorDataChanged(m_colorData); - updateMaterials(); + if (updateView) { + updateMaterials(); + } +} + +void Scatterplot::setColorData(const arma::vec &colorData) +{ + setColorData(colorData, true); } void Scatterplot::updateGeometry() diff --git a/scatterplot.h b/scatterplot.h index 8f2c8c4..d0153c0 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -18,6 +18,8 @@ public: arma::mat XY() const; void setColorScale(ColorScale *colorScale); + void setXY(const arma::mat &xy, bool updateView); + void setColorData(const arma::vec &colorData, bool updateView); Q_INVOKABLE bool saveToFile(const QUrl &url); signals: |