From 76d8f8a5d3a6229c49b072c5872cd99649210107 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 11 Jun 2013 20:47:54 +0200 Subject: [PATCH] Graph example Change-Id: I4a7b52f6e14182aed31354dc3860ef187e1899a4 Reviewed-by: Alan Alpert --- .../scenegraph/graph/doc/images/graph-example.jpg | Bin 0 -> 18923 bytes examples/quick/scenegraph/graph/doc/src/graph.qdoc | 38 ++++++ examples/quick/scenegraph/graph/graph.cpp | 128 +++++++++++++++++ examples/quick/scenegraph/graph/graph.h | 67 +++++++++ examples/quick/scenegraph/graph/graph.pro | 34 +++++ examples/quick/scenegraph/graph/graph.qrc | 9 ++ examples/quick/scenegraph/graph/gridnode.cpp | 95 +++++++++++++ examples/quick/scenegraph/graph/gridnode.h | 59 ++++++++ examples/quick/scenegraph/graph/linenode.cpp | 151 +++++++++++++++++++++ examples/quick/scenegraph/graph/linenode.h | 58 ++++++++ examples/quick/scenegraph/graph/main.cpp | 60 ++++++++ examples/quick/scenegraph/graph/main.qml | 85 ++++++++++++ examples/quick/scenegraph/graph/noisynode.cpp | 142 +++++++++++++++++++ examples/quick/scenegraph/graph/noisynode.h | 56 ++++++++ examples/quick/scenegraph/graph/shaders/line.fsh | 54 ++++++++ examples/quick/scenegraph/graph/shaders/line.vsh | 56 ++++++++ examples/quick/scenegraph/graph/shaders/noisy.fsh | 55 ++++++++ examples/quick/scenegraph/graph/shaders/noisy.vsh | 54 ++++++++ 18 files changed, 1201 insertions(+) create mode 100644 examples/quick/scenegraph/graph/doc/images/graph-example.jpg create mode 100644 examples/quick/scenegraph/graph/doc/src/graph.qdoc create mode 100644 examples/quick/scenegraph/graph/graph.cpp create mode 100644 examples/quick/scenegraph/graph/graph.h create mode 100644 examples/quick/scenegraph/graph/graph.pro create mode 100644 examples/quick/scenegraph/graph/graph.qrc create mode 100644 examples/quick/scenegraph/graph/gridnode.cpp create mode 100644 examples/quick/scenegraph/graph/gridnode.h create mode 100644 examples/quick/scenegraph/graph/linenode.cpp create mode 100644 examples/quick/scenegraph/graph/linenode.h create mode 100644 examples/quick/scenegraph/graph/main.cpp create mode 100644 examples/quick/scenegraph/graph/main.qml create mode 100644 examples/quick/scenegraph/graph/noisynode.cpp create mode 100644 examples/quick/scenegraph/graph/noisynode.h create mode 100644 examples/quick/scenegraph/graph/shaders/line.fsh create mode 100644 examples/quick/scenegraph/graph/shaders/line.vsh create mode 100644 examples/quick/scenegraph/graph/shaders/noisy.fsh create mode 100644 examples/quick/scenegraph/graph/shaders/noisy.vsh diff --git a/examples/quick/scenegraph/graph/doc/images/graph-example.jpg b/examples/quick/scenegraph/graph/doc/images/graph-example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..74975ee7c4a3692f732715ea7ca85c2330a06f33 GIT binary patch literal 18923 zcmb@s1z40__cwaa4BbeVAgxGC3Je{BAYDo$-HmihiwY>IAV^7vbcc#amvl%obPjy? zsL%7h|MQ*iy3RS*xxJWK?tAUM*IIk;wbyU0xt_S52Z$cXE6D>82n0|B{{h#F)SXH) zGRBWI)Z~>^}(Gu0ssd`cUKJsX$C!g0|v|)01bcw1i(E&)YRO~S?bXv z72yB)9FGCuNB}U*i5lzw$o7B#g4n{+%^UzAkHFVv7H;MaAYBCjusU;RS9btFM~%nq zvw2zFxtX$f;{Qwz`*CLqsU2L~q<9ShRzX8$#g)ql~Zre^<+X=-ZqFa1Xs zuqQaNtc{zqy{XUd|NQ^?;b89p+Uxgo6a2(;v(r=tzsW(nd7GQcX@WE*NXJ`SDyjT! z&vSN{*7)1rXydM=1=6G-&xo~$qV`{U&BIPx3Z!Yl_Dee_WfVVXCn%+(nW`E{-vDW5 zb2k~#_Ncj_g1**Tx_^08EG%W^KpNadP(4>Cjeq#9-8?n_Y4`QDmQnqO-`4a2YP|_S z{%BKIkoqkTG}Y2x0W~ip*k0`H{s<)}YOe2&_Nsq%fi6FFl}GWQ+RrWBe(Q^p&Dz~s z3*6%{!+spwcz#jZ_Wgz_L z4f-njAo?QuDEd75T z75}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bm+cx5kL!n425O5@;%8|Icu^`cIP9k{{&{*VSwQ zrsZN#S`Ik-yYf%`q*Dns<{vKeO0r9(UI#9 ze!uwJ=O6uc1kPt3GXHR~E@)5Ybh~y)c!~VGS1(a8|D%5mFhhjT|H&5ftN!}gn&RJ1 y|1Q)S|Cs!7xzF{jXN?bin?B*i#Hdvf(Y`XNVv%!%q{1vu&-=@;sLQwU|4jfd9(oldNode); + + QRectF rect = boundingRect(); + + if (rect.isEmpty()) { + delete n; + return 0; + } + + if (!n) { + n = new GraphNode(); + + n->background = new NoisyNode(window()); + n->grid = new GridNode(); + n->line = new LineNode(10, 0.5, QColor("steelblue")); + n->shadow = new LineNode(20, 0.2, QColor::fromRgbF(0.2, 0.2, 0.2, 0.4)); + + n->appendChildNode(n->background); + n->appendChildNode(n->grid); + n->appendChildNode(n->shadow); + n->appendChildNode(n->line); + } + + if (m_geometryChanged) { + n->background->setRect(rect); + n->grid->setRect(rect); + } + + if (m_geometryChanged || m_samplesChanged) { + n->line->updateGeometry(rect, m_samples); + // We don't need to calculate the geometry twice, so just steal it from the other one... + n->shadow->setGeometry(n->line->geometry()); + } + + m_geometryChanged = false; + m_samplesChanged = false; + + return n; +} diff --git a/examples/quick/scenegraph/graph/graph.h b/examples/quick/scenegraph/graph/graph.h new file mode 100644 index 0000000..28d14f1 --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPH_H +#define GRAPH_H + +#include + +class Graph : public QQuickItem +{ + Q_OBJECT +public: + Graph(); + +protected: + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + +public slots: + void appendSample(qreal value); + void removeFirstSample(); + +private: + QList m_samples; + + bool m_samplesChanged; + bool m_geometryChanged; +}; + +#endif // GRAPH_H diff --git a/examples/quick/scenegraph/graph/graph.pro b/examples/quick/scenegraph/graph/graph.pro new file mode 100644 index 0000000..5991f79 --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-06-11T13:13:18 +# +#------------------------------------------------- + +QT += core gui quick + +TARGET = graph + +TEMPLATE = app + +SOURCES += main.cpp \ + graph.cpp \ + noisynode.cpp \ + gridnode.cpp \ + linenode.cpp + +HEADERS += \ + graph.h \ + noisynode.h \ + gridnode.h \ + linenode.h + +RESOURCES += \ + graph.qrc + +OTHER_FILES += \ + main.qml \ + shaders/noisy.vsh \ + shaders/noisy.fsh \ + shaders/line.fsh \ + shaders/line.vsh + diff --git a/examples/quick/scenegraph/graph/graph.qrc b/examples/quick/scenegraph/graph/graph.qrc new file mode 100644 index 0000000..2adaeac --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.qrc @@ -0,0 +1,9 @@ + + + main.qml + shaders/noisy.vsh + shaders/noisy.fsh + shaders/line.vsh + shaders/line.fsh + + diff --git a/examples/quick/scenegraph/graph/gridnode.cpp b/examples/quick/scenegraph/graph/gridnode.cpp new file mode 100644 index 0000000..2b5e8ca --- /dev/null +++ b/examples/quick/scenegraph/graph/gridnode.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "gridnode.h" + +#include "qmath.h" + +#define GRID_SIZE 32 + +GridNode::GridNode() + : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0) +{ + setGeometry(&m_geometry); + m_geometry.setDrawingMode(GL_LINES); + + setMaterial(&m_material); + m_material.setColor(Qt::gray); +} + +/* + * The function hardcodes a fixed set of grid lines and scales + * those to the bounding rect. + */ +void GridNode::setRect(const QRectF &rect) +{ + int vCount = int((rect.width() - 1) / GRID_SIZE); + int hCount = int((rect.height() - 1) / GRID_SIZE); + + int lineCount = vCount + hCount; + + QSGGeometry *g = geometry(); + + g->allocate(lineCount * 2); + + float x = rect.x(); + float y = rect.y(); + float w = rect.width(); + float h = rect.height(); + + QSGGeometry::Point2D *v = g->vertexDataAsPoint2D(); + + // Then write the vertical lines + for (int i=0; i +#include + +class GridNode : public QSGGeometryNode +{ +public: + GridNode(); + + void setRect(const QRectF &rect); + +private: + QSGFlatColorMaterial m_material; + QSGGeometry m_geometry; +}; + +#endif // GRIDNODE_H diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp new file mode 100644 index 0000000..0d1229c --- /dev/null +++ b/examples/quick/scenegraph/graph/linenode.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "linenode.h" + +#include + +#include + +#include + +struct LineMaterial +{ + QColor color; + float spread; + float size; +}; + +class LineShader : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial) + +public: + const char *vertexShader() const { + QResource r(":/scenegraph/graph/shaders/line.vsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + const char *fragmentShader() const { + QResource r(":/scenegraph/graph/shaders/line.fsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + QList attributes() const { return QList() << "pos" << "t"; } + + void updateState(const LineMaterial *m, const LineMaterial *) { + program()->setUniformValue(id_color, m->color); + program()->setUniformValue(id_spread, m->spread); + program()->setUniformValue(id_size, m->size); + } + + void resolveUniforms() { + id_spread = program()->uniformLocation("spread"); + id_size = program()->uniformLocation("size"); + id_color = program()->uniformLocation("color"); + } + +private: + int id_color; + int id_spread; + int id_size; +}; + +struct LineVertex { + float x; + float y; + float t; + inline void set(float xx, float yy, float tt) { x = xx; y = yy; t = tt; } +}; + +static const QSGGeometry::AttributeSet &attributes() +{ + static QSGGeometry::Attribute attr[] = { + QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), + QSGGeometry::Attribute::create(1, 1, GL_FLOAT) + }; + static QSGGeometry::AttributeSet set = { 2, 3 * sizeof(float), attr }; + return set; +} + +LineNode::LineNode(float size, float spread, const QColor &color) + : m_geometry(attributes(), 0) +{ + setGeometry(&m_geometry); + m_geometry.setDrawingMode(GL_TRIANGLE_STRIP); + + QSGSimpleMaterial *m = LineShader::createMaterial(); + m->state()->color = color; + m->state()->size = size; + m->state()->spread = spread; + m->setFlag(QSGMaterial::Blending); + setMaterial(m); + setFlag(OwnsMaterial); +} + +/* + * Assumes that samples have values in the range of 0 to 1 and scales them to + * the height of bounds. The samples are stretched out horizontally along the + * width of the bounds. + * + * The position of each pair of points is identical, but we use the third value + * "t" to shift the point up or down and to add antialiasing. + */ +void LineNode::updateGeometry(const QRectF &bounds, const QList &samples) +{ + m_geometry.allocate(samples.size() * 2); + + float x = bounds.x(); + float y = bounds.y(); + float w = bounds.width(); + float h = bounds.height(); + + float dx = w / (samples.size() - 1); + + LineVertex *v = (LineVertex *) m_geometry.vertexData(); + for (int i=0; i + +class LineNode : public QSGGeometryNode +{ +public: + LineNode(float size, float spread, const QColor &color); + + void updateGeometry(const QRectF &bounds, const QList &samples); + +private: + QSGGeometry m_geometry; + +}; + +#endif // LINENODE_H diff --git a/examples/quick/scenegraph/graph/main.cpp b/examples/quick/scenegraph/graph/main.cpp new file mode 100644 index 0000000..ed54ae5 --- /dev/null +++ b/examples/quick/scenegraph/graph/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "graph.h" +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication a(argc, argv); + + qmlRegisterType("Graph", 1, 0, "Graph"); + + QQuickView view; + view.resize(800, 400); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///scenegraph/graph/main.qml")); + view.show(); + + return a.exec(); +} diff --git a/examples/quick/scenegraph/graph/main.qml b/examples/quick/scenegraph/graph/main.qml new file mode 100644 index 0000000..ad952bc --- /dev/null +++ b/examples/quick/scenegraph/graph/main.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import Graph 1.0 + +Item { + width: 800 + height: 400 + + Graph { + id: graph + anchors.fill: parent + anchors.margins: 100 + + function newSample(i) { + return (Math.sin(i / 100.0 * Math.PI * 2) + 1) * 0.4 + Math.random() * 0.05; + } + + Component.onCompleted: { + for (var i=0; i<100; ++i) + appendSample(newSample(i)); + } + + property int offset: 100; + } + + Timer { + id: timer + interval: 500 + repeat: true + running: true + onTriggered: { + graph.removeFirstSample(); + graph.appendSample(graph.newSample(++graph.offset)); + } + + } + + Rectangle { + anchors.fill: graph + color: "transparent" + border.color: "black" + border.width: 2 + } + +} diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp new file mode 100644 index 0000000..1fc87a2 --- /dev/null +++ b/examples/quick/scenegraph/graph/noisynode.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "noisynode.h" + +#include + +#include +#include +#include + +#define NOISE_SIZE 64 + +struct NoisyMaterial +{ + ~NoisyMaterial() { + delete texture; + } + + QColor color; + QSGTexture *texture; +}; + +class NoisyShader : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial) + +public: + const char *vertexShader() const { + QResource r(":/scenegraph/graph/shaders/noisy.vsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + const char *fragmentShader() const { + QResource r(":/scenegraph/graph/shaders/noisy.fsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + QList attributes() const { return QList() << "aVertex" << "aTexCoord"; } + + void updateState(const NoisyMaterial *m, const NoisyMaterial *) { + + // Set the color + program()->setUniformValue(id_color, m->color); + + // Bind the texture and set program to use texture unit 0 (the default) + m->texture->bind(); + + // Then set the texture size so we can adjust the texture coordinates accordingly in the + // vertex shader.. + QSize s = m->texture->textureSize(); + program()->setUniformValue(id_textureSize, QSizeF(1.0 / s.width(), 1.0 / s.height())); + } + + void resolveUniforms() { + id_texture = program()->uniformLocation("texture"); + id_textureSize = program()->uniformLocation("textureSize"); + id_color = program()->uniformLocation("color"); + + // We will only use texture unit 0, so set it only once. + program()->setUniformValue(id_texture, 0); + } + +private: + int id_color; + int id_texture; + int id_textureSize; +}; + +NoisyNode::NoisyNode(QQuickWindow *window) +{ + // Make some noise... + QImage image(NOISE_SIZE, NOISE_SIZE, QImage::Format_RGB32); + uint *data = (uint *) image.bits(); + for (int i=0; icreateTextureFromImage(image); + t->setFiltering(QSGTexture::Nearest); + t->setHorizontalWrapMode(QSGTexture::Repeat); + t->setVerticalWrapMode(QSGTexture::Repeat); + + QSGSimpleMaterial *m = NoisyShader::createMaterial(); + m->state()->texture = t; + m->state()->color = QColor::fromRgbF(0.95, 0.95, 0.97); + m->setFlag(QSGMaterial::Blending); + + setMaterial(m); + setFlag(OwnsMaterial, true); + + QSGGeometry *g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); + QSGGeometry::updateTexturedRectGeometry(g, QRect(), QRect()); + setGeometry(g); + setFlag(OwnsGeometry, true); +} + +void NoisyNode::setRect(const QRectF &bounds) +{ + QSGGeometry::updateTexturedRectGeometry(geometry(), bounds, QRectF(0, 0, 1, 1)); + markDirty(QSGNode::DirtyGeometry); +} diff --git a/examples/quick/scenegraph/graph/noisynode.h b/examples/quick/scenegraph/graph/noisynode.h new file mode 100644 index 0000000..b5a2913 --- /dev/null +++ b/examples/quick/scenegraph/graph/noisynode.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef NOISYNODE_H +#define NOISYNODE_H + +#include + +class QQuickWindow; + +class NoisyNode : public QSGGeometryNode +{ +public: + NoisyNode(QQuickWindow *window); + + void setRect(const QRectF &bounds); +}; + +#endif // NOISYNODE_H diff --git a/examples/quick/scenegraph/graph/shaders/line.fsh b/examples/quick/scenegraph/graph/shaders/line.fsh new file mode 100644 index 0000000..b07558c --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/line.fsh @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +uniform lowp vec4 color; +uniform lowp float qt_Opacity; +uniform lowp float spread; + +varying lowp float vT; + +#define PI 3.14159265359 + +void main(void) +{ + lowp float tt = smoothstep(spread, 1.0, sin(vT * PI)); + + gl_FragColor = color * qt_Opacity * tt; +} diff --git a/examples/quick/scenegraph/graph/shaders/line.vsh b/examples/quick/scenegraph/graph/shaders/line.vsh new file mode 100644 index 0000000..84353b8 --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/line.vsh @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +attribute highp vec4 pos; +attribute highp float t; + +uniform lowp float size; +uniform highp mat4 qt_Matrix; + +varying lowp float vT; + +void main(void) +{ + vec4 adjustedPos = pos; + adjustedPos.y += (t * size); + gl_Position = qt_Matrix * adjustedPos; + + vT = t; +} diff --git a/examples/quick/scenegraph/graph/shaders/noisy.fsh b/examples/quick/scenegraph/graph/shaders/noisy.fsh new file mode 100644 index 0000000..227c2b5 --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/noisy.fsh @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +uniform sampler2D texture; +uniform lowp float qt_Opacity; +uniform lowp vec4 color; + +varying highp vec2 vTexCoord; +varying lowp vec2 vShadeCoord; + +#define PI 3.14159265359 + +void main() +{ + lowp float shade = texture2D(texture, vTexCoord).r * 0.05 - length(vec2(0.5, 0.4) - vShadeCoord) * 0.3; + lowp vec4 c = vec4(color.xyz + shade, color.w); + gl_FragColor = c * qt_Opacity; +} diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vsh b/examples/quick/scenegraph/graph/shaders/noisy.vsh new file mode 100644 index 0000000..ce648e5 --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/noisy.vsh @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +attribute highp vec4 aVertex; +attribute highp vec2 aTexCoord; + +uniform highp mat4 qt_Matrix; +uniform highp vec2 textureSize; + +varying highp vec2 vTexCoord; +varying lowp vec2 vShadeCoord; + +void main() { + gl_Position = qt_Matrix * aVertex; + vTexCoord = aVertex.xy * textureSize; + vShadeCoord = aTexCoord; +} -- 2.7.4