diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-15 12:01:47 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-16 06:09:57 +0300 |
commit | 6368dd9a1d9e51016dcef9c93137526c07adcbeb (patch) | |
tree | fcdf2ca833728538977c43b009b9ce8c2d9fe8b5 /examples/datavisualization/customitems/customitemgraph.cpp | |
parent | c9a3325e59b224c26d5e49688b29b2a57134e019 (diff) |
Dirty bits to custom item
Task-number: QTRD-3082
Change-Id: I1503b067edcc677904ca16c1501109187809f98b
Change-Id: I1503b067edcc677904ca16c1501109187809f98b
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'examples/datavisualization/customitems/customitemgraph.cpp')
-rw-r--r-- | examples/datavisualization/customitems/customitemgraph.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/datavisualization/customitems/customitemgraph.cpp b/examples/datavisualization/customitems/customitemgraph.cpp index 14117580..56187d14 100644 --- a/examples/datavisualization/customitems/customitemgraph.cpp +++ b/examples/datavisualization/customitems/customitemgraph.cpp @@ -91,6 +91,11 @@ CustomItemGraph::CustomItemGraph(Q3DSurface *surface, QLabel *label) connect(m_graph, &QAbstract3DGraph::elementSelected, this, &CustomItemGraph::handleElementSelected); + + m_selectionAnimation = new QPropertyAnimation(this); + m_selectionAnimation->setPropertyName("scaling"); + m_selectionAnimation->setDuration(500); + m_selectionAnimation->setLoopCount(-1); } CustomItemGraph::~CustomItemGraph() @@ -118,6 +123,7 @@ void CustomItemGraph::toggleItemOne(bool show) m_graph->addCustomItem(item); //! [3] } else { + resetSelection(); //! [4] m_graph->removeCustomItemAt(positionOne); //! [4] @@ -138,6 +144,7 @@ void CustomItemGraph::toggleItemTwo(bool show) item->setTextureImage(color); m_graph->addCustomItem(item); } else { + resetSelection(); m_graph->removeCustomItemAt(positionTwo); } } @@ -156,6 +163,7 @@ void CustomItemGraph::toggleItemThree(bool show) item->setTextureImage(color); m_graph->addCustomItem(item); } else { + resetSelection(); m_graph->removeCustomItemAt(positionThree); } } @@ -196,15 +204,22 @@ void CustomItemGraph::toggleShadows(bool shadows) void CustomItemGraph::handleElementSelected(QAbstract3DGraph::ElementType type) { + resetSelection(); if (type == QAbstract3DGraph::ElementCustomItem) { int index = m_graph->selectedCustomItemIndex(); QCustom3DItem *item = m_graph->selectedCustomItem(); + m_previouslyAnimatedItem = item; + m_previousScaling = item->scaling(); QString text; text.setNum(index); text.append(": "); QStringList split = item->meshFile().split("/"); text.append(split.last()); m_textField->setText(text); + m_selectionAnimation->setTargetObject(item); + m_selectionAnimation->setStartValue(item->scaling()); + m_selectionAnimation->setEndValue(item->scaling() * 1.5f); + m_selectionAnimation->start(); } else if (type == QAbstract3DGraph::ElementSeries) { QString text = "Surface ("; QSurface3DSeries *series = m_graph->selectedSeries(); @@ -226,3 +241,11 @@ void CustomItemGraph::handleElementSelected(QAbstract3DGraph::ElementType type) m_textField->setText("Nothing"); } } + +void CustomItemGraph::resetSelection() +{ + m_selectionAnimation->stop(); + if (m_previouslyAnimatedItem) + m_previouslyAnimatedItem->setScaling(m_previousScaling); + m_previouslyAnimatedItem = 0; +} |