From 7ad4b526899f8bc764192e88e65306c788a9ed32 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Fri, 15 Jan 2016 22:35:13 +0100 Subject: VoronoiSplat & Scatterplot: splatting is now a separate component. The change was due to future functionality requirements, this separation provides grater flexibility. As a nice side effect, the cropping bug when first rendering the splat is now gone. --- main.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 22b8d67..4d43c4c 100644 --- a/main.cpp +++ b/main.cpp @@ -96,6 +96,7 @@ int main(int argc, char **argv) qmlRegisterType("PM", 1, 0, "Scatterplot"); qmlRegisterType("PM", 1, 0, "HistoryGraph"); qmlRegisterType("PM", 1, 0, "BarChart"); + qmlRegisterType("PM", 1, 0, "VoronoiSplat"); qmlRegisterType("PM", 1, 0, "InteractionHandler"); qmlRegisterSingletonType
("PM", 1, 0, "Main", mainProvider); @@ -112,28 +113,28 @@ int main(int argc, char **argv) QQmlApplicationEngine engine(QUrl("qrc:///main_view.qml")); - ColorScale colorScale{ - QColor("#1f77b4"), - QColor("#ff7f0e"), - QColor("#2ca02c"), - QColor("#d62728"), - QColor("#9467bd"), - QColor("#8c564b"), - QColor("#e377c2"), - QColor("#17becf"), - QColor("#7f7f7f"), - }; + //ColorScale colorScale{ + // QColor("#1f77b4"), + // QColor("#ff7f0e"), + // QColor("#2ca02c"), + // QColor("#d62728"), + // QColor("#9467bd"), + // QColor("#8c564b"), + // QColor("#e377c2"), + // QColor("#17becf"), + // QColor("#7f7f7f"), + //}; + //colorScale.setExtents(labels.min(), labels.max()); + + ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); colorScale.setExtents(labels.min(), labels.max()); - - //ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); - //colorScale.setExtents(-1, 1); Scatterplot *cpPlot = engine.rootObjects()[0]->findChild("cpPlot"); - cpPlot->setDisplaySplat(false); cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); // cpPlot->setColorData(arma::zeros(cpSize)); cpPlot->setColorScale(&colorScale); Scatterplot *plot = engine.rootObjects()[0]->findChild("plot"); - skelft2DInitialization(plot->width()); + VoronoiSplat *splat = engine.rootObjects()[0]->findChild("splat"); + skelft2DInitialization(splat->width()); // Keep track of the current cp (in order to save them later, if requested) QObject::connect(cpPlot, SIGNAL(xyChanged(const arma::mat &)), @@ -150,6 +151,8 @@ int main(int argc, char **argv) &interactionHandler, SLOT(setCP(const arma::mat &))); QObject::connect(&interactionHandler, SIGNAL(cpChanged(const arma::mat &)), plot, SLOT(setXY(const arma::mat &))); + QObject::connect(&interactionHandler, SIGNAL(cpChanged(const arma::mat &)), + splat, SLOT(setSites(const arma::mat &))); m->setTechnique(InteractionHandler::TECHNIQUE_LAMP); // Linking between selections in cp plot and full dataset plot @@ -175,6 +178,8 @@ int main(int argc, char **argv) //history->addHistoryItem(Ys); plot->setColorScale(&colorScale); plot->setColorData(labels, false); + splat->setValues(labels); + splat->update(); cpPlot->setAutoScale(false); cpPlot->setColorData(labels(cpIndices), false); -- cgit v1.2.3