diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-11 13:19:51 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-11 13:19:51 +0100 |
commit | c853b44dd138fd99e430580ec1bb1d0bd25293ff (patch) | |
tree | 0e890372f58586bf4537e5f9f56726d906c8b7d3 | |
parent | caa8c6f2dc8bbf8eca0e6fe137d0654104601690 (diff) |
Scatterplot: control whether splat is displayed.
* Subsample plot no longer displays splat
-rw-r--r-- | main.cpp | 1 | ||||
-rw-r--r-- | scatterplot.cpp | 44 | ||||
-rw-r--r-- | scatterplot.h | 3 |
3 files changed, 38 insertions, 10 deletions
@@ -187,6 +187,7 @@ int main(int argc, char **argv) //ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE); //colorScale.setExtents(-1, 1); Scatterplot *subsamplePlot = engine.rootObjects()[0]->findChild<Scatterplot *>("subsamplePlot"); + subsamplePlot->setDisplaySplat(false); subsamplePlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); // subsamplePlot->setColorData(arma::zeros<arma::vec>(subsampleSize)); subsamplePlot->setColorScale(&colorScale); diff --git a/scatterplot.cpp b/scatterplot.cpp index 2c9a57a..7505e88 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -20,6 +20,7 @@ Scatterplot::Scatterplot(QQuickItem *parent) , m_currentInteractionState(INTERACTION_NONE) , m_shouldUpdateGeometry(false) , m_shouldUpdateMaterials(false) + , m_displaySplat(true) , m_animationEasing(QEasingCurve::InOutQuart) { setClip(true); @@ -206,11 +207,14 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) return root; } - QSGNode *splatNode = root->firstChild(); - updateSplat(splatNode); + // This keeps track of where we are in the scene when updating + QSGNode *node = root->firstChild(); - QSGNode *glyphsRootNode = root->firstChild()->nextSibling(); - updateGlyphs(glyphsRootNode->firstChild()); + updateSplat(node); + node = node->nextSibling(); + + updateGlyphs(node->firstChild()); + node = node->nextSibling(); // Change update hints to false; the splat and glyphs were just updated if (m_shouldUpdateGeometry) { @@ -221,15 +225,15 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) } // Selection - QSGSimpleRectNode *selectionRectNode = - static_cast<QSGSimpleRectNode *>(root->firstChild()->nextSibling()->nextSibling()); + QSGSimpleRectNode *selectionNode = static_cast<QSGSimpleRectNode *>(node); if (m_currentInteractionState == INTERACTION_SELECTING) { - selectionRectNode->setRect(QRectF(m_dragOriginPos, m_dragCurrentPos)); - selectionRectNode->markDirty(QSGNode::DirtyGeometry); + selectionNode->setRect(QRectF(m_dragOriginPos, m_dragCurrentPos)); + selectionNode->markDirty(QSGNode::DirtyGeometry); } else { // Hide selection rect - selectionRectNode->setRect(QRectF(-1, -1, 0, 0)); + selectionNode->setRect(QRectF(-1, -1, 0, 0)); } + node = node->nextSibling(); animationTick(); return root; @@ -238,9 +242,17 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) void Scatterplot::updateSplat(QSGNode *node) { QSGSimpleTextureNode *texNode = static_cast<QSGSimpleTextureNode *>(node); + + if (!m_displaySplat) { + // Hide the splat and return, ignoring update requests + texNode->setRect(0, 0, 0, 0); + return; + } + + texNode->setRect(x(), y(), width(), height()); + VoronoiSplatTexture *tex = static_cast<VoronoiSplatTexture *>(texNode->texture()); - if (m_shouldUpdateGeometry) { tex->setSites(m_xy); } @@ -439,6 +451,18 @@ void Scatterplot::setSelection(const QSet<int> &selection) emit selectionChanged(selection); } +void Scatterplot::setDisplaySplat(bool displaySplat) +{ + if (m_displaySplat != displaySplat) { + m_displaySplat = displaySplat; + m_shouldUpdateGeometry = true; + m_shouldUpdateMaterials = true; + update(); + + emit displaySplatChanged(displaySplat); + } +} + void Scatterplot::applyManipulation() { m_sx.inverse(); diff --git a/scatterplot.h b/scatterplot.h index 50af274..8f2c8c4 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -25,11 +25,13 @@ signals: void xyInteractivelyChanged(const arma::mat &XY) const; void colorDataChanged(const arma::vec &colorData) const; void selectionChanged(const QSet<int> &selection) const; + void displaySplatChanged(bool displaySplat) const; public slots: void setXY(const arma::mat &xy); void setColorData(const arma::vec &colorData); void setSelection(const QSet<int> &selection); + void setDisplaySplat(bool displaySplat); protected: QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); @@ -72,6 +74,7 @@ private: bool m_shouldUpdateGeometry, m_shouldUpdateMaterials; + bool m_displaySplat; arma::vec m_colorData; ColorScale *m_colorScale; |