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. --- scatterplot.cpp | 71 --------------------------------------------------------- 1 file changed, 71 deletions(-) (limited to 'scatterplot.cpp') diff --git a/scatterplot.cpp b/scatterplot.cpp index de96e6f..04a50cd 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -1,6 +1,5 @@ #include "scatterplot.h" -#include "voronoisplat.h" #include "geometry.h" #include @@ -23,7 +22,6 @@ Scatterplot::Scatterplot(QQuickItem *parent) , m_currentInteractionState(INTERACTION_NONE) , m_shouldUpdateGeometry(false) , m_shouldUpdateMaterials(false) - , m_displaySplat(true) { setClip(true); setFlag(QQuickItem::ItemHasContents); @@ -164,26 +162,6 @@ void Scatterplot::autoScale() emit scaleChanged(m_sx, m_sy); } -QSGNode *Scatterplot::newSplatNode() -{ - if (m_xy.n_rows < 1) { - return 0; - } - - QSGSimpleTextureNode *node = new QSGSimpleTextureNode; - VoronoiSplatTexture *tex = new VoronoiSplatTexture(QSize(width(), height())); - - tex->setSites(m_xy); - tex->setValues(m_colorData); - tex->setColormap(m_colorScale); - - node->setTexture(tex); - node->setOwnsTexture(true); - node->setSourceRect(0, 0, width(), height()); - - return node; -} - QSGNode *Scatterplot::newGlyphTree() { // NOTE: @@ -235,10 +213,6 @@ QSGNode *Scatterplot::newSceneGraph() // The hierarchy in the scene graph is as follows: // root [[splatNode] [glyphsRoot [glyph [...]]] [selectionNode]] QSGNode *root = new QSGNode; - QSGNode *splatNode = newSplatNode(); - if (splatNode) { - root->appendChildNode(splatNode); - } QSGNode *glyphTreeRoot = newGlyphTree(); if (glyphTreeRoot) { root->appendChildNode(glyphTreeRoot); @@ -262,9 +236,6 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) // This keeps track of where we are in the scene when updating QSGNode *node = root->firstChild(); - updateSplat(node); - node = node->nextSibling(); - updateGlyphs(node); node = node->nextSibling(); @@ -290,36 +261,6 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) return root; } -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); - } - - if (m_shouldUpdateMaterials) { - tex->setValues(m_colorData); - tex->setColormap(m_colorScale); - } - - bool updated = tex->updateTexture(); - if (updated) { - texNode->markDirty(QSGNode::DirtyMaterial); - window()->resetOpenGLState(); - } -} - void Scatterplot::updateGlyphs(QSGNode *glyphsNode) { qreal x, y, tx, ty, moveTranslationF; @@ -487,18 +428,6 @@ 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