From c853b44dd138fd99e430580ec1bb1d0bd25293ff Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 11 Jan 2016 13:19:51 +0100 Subject: Scatterplot: control whether splat is displayed. * Subsample plot no longer displays splat --- scatterplot.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'scatterplot.cpp') 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(root->firstChild()->nextSibling()->nextSibling()); + QSGSimpleRectNode *selectionNode = static_cast(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(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(texNode->texture()); - if (m_shouldUpdateGeometry) { tex->setSites(m_xy); } @@ -439,6 +451,18 @@ void Scatterplot::setSelection(const QSet &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(); -- cgit v1.2.3