diff options
-rw-r--r-- | src/datavisualization/data/abstractrenderitem_p.h | 1 | ||||
-rw-r--r-- | src/datavisualization/data/qabstract3dseries.cpp | 2 | ||||
-rw-r--r-- | src/datavisualization/data/qabstract3dseries.h | 1 | ||||
-rw-r--r-- | src/datavisualization/data/qscatterdataitem.h | 4 | ||||
-rw-r--r-- | src/datavisualization/data/scatterrenderitem_p.h | 10 | ||||
-rw-r--r-- | src/datavisualization/engine/engine.qrc | 2 | ||||
-rw-r--r-- | src/datavisualization/engine/meshes/arrowFlat.obj | 403 | ||||
-rw-r--r-- | src/datavisualization/engine/meshes/arrowSmooth.obj | 422 | ||||
-rw-r--r-- | src/datavisualization/engine/scatter3drenderer.cpp | 12 | ||||
-rw-r--r-- | src/datavisualization/engine/seriesrendercache.cpp | 3 | ||||
-rw-r--r-- | tests/directional/directional.pro | 10 | ||||
-rw-r--r-- | tests/directional/main.cpp | 164 | ||||
-rw-r--r-- | tests/directional/scatterdatamodifier.cpp | 181 | ||||
-rw-r--r-- | tests/directional/scatterdatamodifier.h | 64 |
14 files changed, 1277 insertions, 2 deletions
diff --git a/src/datavisualization/data/abstractrenderitem_p.h b/src/datavisualization/data/abstractrenderitem_p.h index 5f623c41..ca71c0b0 100644 --- a/src/datavisualization/data/abstractrenderitem_p.h +++ b/src/datavisualization/data/abstractrenderitem_p.h @@ -35,6 +35,7 @@ #include <QOpenGLFunctions> #include <QString> #include <QVector3D> +#include <QQuaternion> QT_DATAVISUALIZATION_BEGIN_NAMESPACE diff --git a/src/datavisualization/data/qabstract3dseries.cpp b/src/datavisualization/data/qabstract3dseries.cpp index 2c869574..81a2f1b8 100644 --- a/src/datavisualization/data/qabstract3dseries.cpp +++ b/src/datavisualization/data/qabstract3dseries.cpp @@ -198,6 +198,8 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE * Sphere. * \value MeshMinimal * The minimal 3D mesh: a triangular pyramid. Usable only with Q3DScatter. + * \value MeshArrow + * Arrow pointing upwards. * \value MeshPoint * 2D point. Usable only with Q3DScatter. * \b Note: Shadows and color gradients do not affect this style. diff --git a/src/datavisualization/data/qabstract3dseries.h b/src/datavisualization/data/qabstract3dseries.h index ebe73510..b03b574d 100644 --- a/src/datavisualization/data/qabstract3dseries.h +++ b/src/datavisualization/data/qabstract3dseries.h @@ -67,6 +67,7 @@ public: MeshBevelCube, MeshSphere, MeshMinimal, + MeshArrow, MeshPoint }; diff --git a/src/datavisualization/data/qscatterdataitem.h b/src/datavisualization/data/qscatterdataitem.h index 7992864c..f139abd4 100644 --- a/src/datavisualization/data/qscatterdataitem.h +++ b/src/datavisualization/data/qscatterdataitem.h @@ -21,6 +21,7 @@ #include <QtDataVisualization/qdatavisualizationenums.h> #include <QVector3D> +#include <QQuaternion> QT_DATAVISUALIZATION_BEGIN_NAMESPACE @@ -38,6 +39,8 @@ public: inline void setPosition(const QVector3D &position) { m_position = position; } inline QVector3D position() const { return m_position; } + inline void setRotation(const QQuaternion &rotation) { m_rotation = rotation; } + inline QQuaternion rotation() const { return m_rotation; } inline void setX(float value) { m_position.setX(value); } inline void setY(float value) { m_position.setY(value); } inline void setZ(float value) { m_position.setZ(value); } @@ -52,6 +55,7 @@ protected: private: QVector3D m_position; + QQuaternion m_rotation; }; QT_DATAVISUALIZATION_END_NAMESPACE diff --git a/src/datavisualization/data/scatterrenderitem_p.h b/src/datavisualization/data/scatterrenderitem_p.h index 5a97c1e9..047caeb6 100644 --- a/src/datavisualization/data/scatterrenderitem_p.h +++ b/src/datavisualization/data/scatterrenderitem_p.h @@ -45,6 +45,9 @@ public: inline const QVector3D &position() const { return m_position; } inline void setPosition(const QVector3D &pos); + inline QQuaternion rotation() const { return m_rotation; } + inline void setRotation(const QQuaternion &rotation); + inline bool isVisible() const { return m_visible; } inline void setVisible(bool visible) { m_visible = visible; } @@ -54,6 +57,7 @@ public: protected: QVector3D m_position; + QQuaternion m_rotation; bool m_visible; //float m_size; // TODO in case we need a fourth variable that adjusts scatter item size @@ -70,6 +74,12 @@ void ScatterRenderItem::setPosition(const QVector3D &pos) } } +void ScatterRenderItem::setRotation(const QQuaternion &rotation) +{ + if (m_rotation != rotation) + m_rotation = rotation; +} + typedef QVector<ScatterRenderItem> ScatterRenderItemArray; QT_DATAVISUALIZATION_END_NAMESPACE diff --git a/src/datavisualization/engine/engine.qrc b/src/datavisualization/engine/engine.qrc index 8fcaecec..073c7450 100644 --- a/src/datavisualization/engine/engine.qrc +++ b/src/datavisualization/engine/engine.qrc @@ -27,6 +27,8 @@ <file alias="negativeBackground">meshes/backgroundNegatives.obj</file> <file alias="minimal">meshes/minimalFlat.obj</file> <file alias="minimalSmooth">meshes/minimalSmooth.obj</file> + <file alias="arrowFull">meshes/arrowFlat.obj</file> + <file alias="arrowSmoothFull">meshes/arrowSmooth.obj</file> </qresource> <qresource prefix="/shaders"> <file alias="fragment">shaders/default.frag</file> diff --git a/src/datavisualization/engine/meshes/arrowFlat.obj b/src/datavisualization/engine/meshes/arrowFlat.obj new file mode 100644 index 00000000..bb9762d6 --- /dev/null +++ b/src/datavisualization/engine/meshes/arrowFlat.obj @@ -0,0 +1,403 @@ +# Blender v2.69 (sub 0) OBJ File: 'arrow.blend' +# www.blender.org +v 0.000000 1.000000 0.000000 +v 0.000000 0.000000 -1.000000 +v -0.195090 0.000000 -0.980785 +v -0.382683 0.000000 -0.923880 +v -0.555570 0.000000 -0.831470 +v -0.707107 0.000000 -0.707107 +v -0.831470 0.000000 -0.555570 +v -0.923880 0.000000 -0.382683 +v -0.980785 0.000000 -0.195090 +v -1.000000 0.000000 -0.000000 +v -0.980785 0.000000 0.195090 +v -0.923880 0.000000 0.382683 +v -0.831470 0.000000 0.555570 +v -0.707107 0.000000 0.707107 +v -0.555570 0.000000 0.831470 +v -0.382683 0.000000 0.923880 +v -0.195090 0.000000 0.980785 +v 0.000000 0.000000 1.000000 +v 0.195091 0.000000 0.980785 +v 0.382684 0.000000 0.923879 +v 0.555571 0.000000 0.831469 +v 0.707107 0.000000 0.707106 +v 0.831470 0.000000 0.555570 +v 0.923880 0.000000 0.382683 +v 0.980785 0.000000 0.195089 +v 1.000000 0.000000 -0.000001 +v 0.980785 0.000000 -0.195091 +v 0.923879 0.000000 -0.382684 +v 0.831469 0.000000 -0.555571 +v 0.707106 0.000000 -0.707108 +v 0.555569 0.000000 -0.831470 +v 0.382682 0.000000 -0.923880 +v 0.195089 0.000000 -0.980786 +v 0.000000 0.000000 0.000000 +v 0.000000 0.000000 0.000000 +v -0.000000 0.000000 -0.578860 +v -0.112930 0.000000 -0.567737 +v -0.221520 0.000000 -0.534796 +v -0.321597 0.000000 -0.481304 +v -0.409315 0.000000 -0.409316 +v -0.481304 0.000000 -0.321597 +v -0.534796 0.000000 -0.221520 +v -0.567737 0.000000 -0.112930 +v -0.578859 0.000000 -0.000000 +v -0.567737 0.000000 0.112930 +v -0.534796 0.000000 0.221520 +v -0.481304 0.000000 0.321597 +v -0.409315 0.000000 0.409315 +v -0.321597 0.000000 0.481304 +v -0.221520 0.000000 0.534796 +v -0.112930 0.000000 0.567737 +v 0.000000 0.000000 0.578859 +v 0.112930 0.000000 0.567737 +v 0.221520 0.000000 0.534796 +v 0.321597 0.000000 0.481304 +v 0.409316 0.000000 0.409315 +v 0.481304 0.000000 0.321597 +v 0.534796 0.000000 0.221519 +v 0.567737 0.000000 0.112929 +v 0.578859 0.000000 -0.000001 +v 0.567737 0.000000 -0.112931 +v 0.534796 0.000000 -0.221521 +v 0.481304 0.000000 -0.321598 +v 0.409315 0.000000 -0.409316 +v 0.321596 0.000000 -0.481305 +v 0.221519 0.000000 -0.534797 +v 0.112929 0.000000 -0.567737 +v 0.578859 -1.000000 -0.000001 +v 0.567737 -1.000000 0.112929 +v -0.221520 -1.000000 -0.534796 +v -0.112930 -1.000000 -0.567737 +v -0.321597 -1.000000 0.481304 +v -0.409315 -1.000000 0.409315 +v 0.534796 -1.000000 0.221519 +v 0.481304 -1.000000 0.321597 +v -0.481304 -1.000000 0.321597 +v -0.534796 -1.000000 0.221520 +v 0.112929 -1.000000 -0.567737 +v 0.221519 -1.000000 -0.534797 +v 0.409316 -1.000000 0.409315 +v 0.321597 -1.000000 0.481304 +v -0.567737 -1.000000 0.112930 +v -0.578859 -1.000000 -0.000000 +v 0.321596 -1.000000 -0.481305 +v 0.409315 -1.000000 -0.409316 +v 0.221520 -1.000000 0.534796 +v 0.112930 -1.000000 0.567737 +v -0.567737 -1.000000 -0.112930 +v -0.534796 -1.000000 -0.221520 +v 0.481304 -1.000000 -0.321598 +v 0.534796 -1.000000 -0.221521 +v -0.481304 -1.000000 -0.321597 +v -0.409315 -1.000000 -0.409316 +v 0.000000 -1.000000 0.578859 +v -0.112930 -1.000000 0.567737 +v 0.567737 -1.000000 -0.112931 +v -0.321597 -1.000000 -0.481304 +v -0.221520 -1.000000 0.534796 +v -0.000000 -1.000000 -0.578860 +vt 0.000000 0.000000 +vt 0.549236 0.999900 +vt 0.450764 0.999900 +vt 0.645815 0.980689 +vt 0.354184 0.980689 +vt 0.263208 0.943005 +vt 0.181332 0.888297 +vt 0.111702 0.818667 +vt 0.056994 0.736790 +vt 0.019311 0.645815 +vt 0.000100 0.549235 +vt 0.000100 0.450763 +vt 0.019310 0.354184 +vt 0.056994 0.263208 +vt 0.111702 0.181332 +vt 0.943005 0.263208 +vt 0.818666 0.111702 +vt 0.888296 0.181332 +vt 0.980688 0.354184 +vt 0.999899 0.549236 +vt 0.999899 0.450764 +vt 0.943005 0.736791 +vt 0.980689 0.645815 +vt 0.181332 0.111702 +vt 0.736791 0.943006 +vt 0.263209 0.056994 +vt 0.354185 0.019311 +vt 0.450764 0.000100 +vt 0.818667 0.888298 +vt 0.888297 0.818668 +vt 0.549235 0.000100 +vt 0.645815 0.019311 +vt 0.736791 0.056994 +vn -0.069476 0.705398 -0.705398 +vn -0.205757 0.705398 -0.678290 +vn -0.334131 0.705398 -0.625116 +vn -0.449665 0.705398 -0.547918 +vn -0.547918 0.705398 -0.449665 +vn -0.625116 0.705398 -0.334131 +vn -0.678290 0.705398 -0.205757 +vn -0.705398 0.705398 -0.069476 +vn -0.705398 0.705398 0.069476 +vn -0.678290 0.705398 0.205757 +vn -0.625116 0.705398 0.334131 +vn -0.547918 0.705398 0.449665 +vn -0.449665 0.705398 0.547918 +vn -0.334131 0.705398 0.625116 +vn -0.205757 0.705398 0.678290 +vn -0.069476 0.705398 0.705398 +vn 0.069476 0.705398 0.705398 +vn 0.205757 0.705398 0.678290 +vn 0.334132 0.705398 0.625116 +vn 0.449665 0.705398 0.547918 +vn 0.547919 0.705398 0.449665 +vn 0.625116 0.705398 0.334131 +vn 0.678290 0.705398 0.205756 +vn 0.705398 0.705398 0.069475 +vn 0.705398 0.705398 -0.069476 +vn 0.678290 0.705398 -0.205758 +vn 0.625115 0.705398 -0.334132 +vn 0.547918 0.705398 -0.449666 +vn 0.449664 0.705398 -0.547919 +vn 0.334130 0.705398 -0.625116 +vn 0.205756 0.705398 -0.678290 +vn 0.069475 0.705398 -0.705398 +vn 0.000000 -1.000000 0.000000 +vn -0.290284 0.000000 0.956940 +vn -0.098016 0.000000 0.995185 +vn -0.634393 0.000000 -0.773010 +vn -0.773011 0.000000 -0.634393 +vn 0.956940 0.000000 -0.290286 +vn 0.881921 0.000000 -0.471398 +vn -0.881922 0.000000 -0.471396 +vn -0.956940 0.000000 -0.290285 +vn 0.098017 0.000000 0.995185 +vn 0.290284 0.000000 0.956940 +vn 0.773010 0.000000 -0.634394 +vn 0.634392 0.000000 -0.773011 +vn -0.995185 0.000000 -0.098017 +vn -0.995185 0.000000 0.098017 +vn 0.471397 0.000000 0.881921 +vn 0.634394 0.000000 0.773010 +vn 0.471395 0.000000 -0.881922 +vn 0.290283 0.000000 -0.956941 +vn 0.098017 0.000000 -0.995185 +vn -0.956940 0.000000 0.290285 +vn -0.881921 0.000000 0.471396 +vn 0.773011 0.000000 0.634393 +vn 0.881922 0.000000 0.471396 +vn -0.773010 0.000000 0.634393 +vn -0.634393 0.000000 0.773010 +vn -0.471397 0.000000 0.881921 +vn -0.098018 0.000000 -0.995185 +vn -0.290284 0.000000 -0.956940 +vn -0.471397 0.000000 -0.881921 +vn 0.956941 0.000000 0.290284 +vn 0.995185 0.000000 0.098016 +vn 0.995185 0.000000 -0.098018 +vn 0.000000 -1.000000 -0.000004 +vn 0.000000 -1.000000 -0.000001 +vn 0.000000 -1.000000 0.000001 +vn -0.098017 0.000000 0.995185 +vn -0.773010 0.000000 -0.634393 +vn -0.881921 0.000000 -0.471396 +vn 0.098018 0.000000 0.995185 +vn 0.290285 0.000000 0.956940 +vn 0.773009 0.000000 -0.634394 +vn 0.471396 0.000000 -0.881922 +vn -0.881921 0.000000 0.471397 +vn -0.098017 0.000000 -0.995185 +vn -0.471396 0.000000 -0.881921 +s off +f 1/1/1 2/1/1 3/1/1 +f 1/1/2 3/1/2 4/1/2 +f 1/1/3 4/1/3 5/1/3 +f 1/1/4 5/1/4 6/1/4 +f 1/1/5 6/1/5 7/1/5 +f 1/1/6 7/1/6 8/1/6 +f 1/1/7 8/1/7 9/1/7 +f 1/1/8 9/1/8 10/1/8 +f 1/1/9 10/1/9 11/1/9 +f 1/1/10 11/1/10 12/1/10 +f 1/1/11 12/1/11 13/1/11 +f 1/1/12 13/1/12 14/1/12 +f 1/1/13 14/1/13 15/1/13 +f 1/1/14 15/1/14 16/1/14 +f 1/1/15 16/1/15 17/1/15 +f 1/1/16 17/1/16 18/1/16 +f 1/1/17 18/1/17 19/1/17 +f 1/1/18 19/1/18 20/1/18 +f 1/1/19 20/1/19 21/1/19 +f 1/1/20 21/1/20 22/1/20 +f 1/1/21 22/1/21 23/1/21 +f 1/1/22 23/1/22 24/1/22 +f 1/1/23 24/1/23 25/1/23 +f 1/1/24 25/1/24 26/1/24 +f 1/1/25 26/1/25 27/1/25 +f 1/1/26 27/1/26 28/1/26 +f 1/1/27 28/1/27 29/1/27 +f 1/1/28 29/1/28 30/1/28 +f 1/1/29 30/1/29 31/1/29 +f 1/1/30 31/1/30 32/1/30 +f 1/1/31 32/1/31 33/1/31 +f 1/1/32 33/1/32 2/1/32 +f 24/1/33 23/1/33 58/1/33 +f 13/1/33 12/1/33 47/1/33 +f 2/1/33 33/1/33 36/1/33 +f 23/1/33 22/1/33 57/1/33 +f 12/1/33 11/1/33 46/1/33 +f 33/1/33 32/1/33 67/1/33 +f 22/1/33 21/1/33 56/1/33 +f 11/1/33 10/1/33 45/1/33 +f 32/1/33 31/1/33 66/1/33 +f 21/1/33 20/1/33 55/1/33 +f 10/1/33 9/1/33 44/1/33 +f 31/1/33 30/1/33 65/1/33 +f 20/1/33 19/1/33 54/1/33 +f 9/1/33 8/1/33 43/1/33 +f 30/1/33 29/1/33 64/1/33 +f 19/1/33 18/1/33 53/1/33 +f 3/1/33 2/1/33 37/1/33 +f 8/1/33 7/1/33 42/1/33 +f 29/1/33 28/1/33 63/1/33 +f 7/1/33 6/1/33 41/1/33 +f 18/1/33 17/1/33 52/1/33 +f 28/1/33 27/1/33 62/1/33 +f 6/1/33 5/1/33 40/1/33 +f 17/1/33 16/1/33 51/1/33 +f 27/1/33 26/1/33 61/1/33 +f 5/1/33 4/1/33 39/1/33 +f 16/1/33 15/1/33 50/1/33 +f 26/1/33 25/1/33 60/1/33 +f 4/1/33 3/1/33 38/1/33 +f 15/1/33 14/1/33 49/1/33 +f 25/1/33 24/1/33 59/1/33 +f 14/1/33 13/1/33 48/1/33 +f 81/2/33 86/3/33 80/4/33 +f 51/1/34 50/1/34 95/1/34 +f 52/1/35 51/1/35 94/1/35 +f 40/1/36 39/1/36 93/1/36 +f 41/1/37 40/1/37 92/1/37 +f 62/1/38 61/1/38 91/1/38 +f 63/1/39 62/1/39 90/1/39 +f 42/1/40 41/1/40 89/1/40 +f 43/1/41 42/1/41 88/1/41 +f 53/1/42 52/1/42 87/1/42 +f 54/1/43 53/1/43 86/1/43 +f 64/1/44 63/1/44 85/1/44 +f 65/1/45 64/1/45 84/1/45 +f 44/1/46 43/1/46 83/1/46 +f 45/1/47 44/1/47 82/1/47 +f 55/1/48 54/1/48 81/1/48 +f 56/1/49 55/1/49 80/1/49 +f 66/1/50 65/1/50 79/1/50 +f 67/1/51 66/1/51 78/1/51 +f 36/1/52 67/1/52 99/1/52 +f 46/1/53 45/1/53 77/1/53 +f 47/1/54 46/1/54 76/1/54 +f 57/1/55 56/1/55 75/1/55 +f 58/1/56 57/1/56 74/1/56 +f 48/1/57 47/1/57 73/1/57 +f 49/1/58 48/1/58 72/1/58 +f 50/1/59 49/1/59 98/1/59 +f 37/1/60 36/1/60 71/1/60 +f 38/1/61 37/1/61 70/1/61 +f 39/1/62 38/1/62 97/1/62 +f 59/1/63 58/1/63 69/1/63 +f 60/1/64 59/1/64 68/1/64 +f 61/1/65 60/1/65 96/1/65 +f 23/1/33 57/1/33 58/1/33 +f 12/1/33 46/1/33 47/1/33 +f 33/1/33 67/1/33 36/1/33 +f 22/1/33 56/1/33 57/1/33 +f 11/1/33 45/1/33 46/1/33 +f 32/1/33 66/1/33 67/1/33 +f 21/1/33 55/1/33 56/1/33 +f 10/1/33 44/1/33 45/1/33 +f 31/1/33 65/1/33 66/1/33 +f 20/1/33 54/1/33 55/1/33 +f 9/1/33 43/1/33 44/1/33 +f 30/1/33 64/1/33 65/1/33 +f 19/1/33 53/1/33 54/1/33 +f 8/1/33 42/1/33 43/1/33 +f 29/1/33 63/1/33 64/1/33 +f 18/1/33 52/1/33 53/1/33 +f 2/1/33 36/1/33 37/1/33 +f 7/1/33 41/1/33 42/1/33 +f 28/1/33 62/1/33 63/1/33 +f 6/1/33 40/1/33 41/1/33 +f 17/1/33 51/1/33 52/1/33 +f 27/1/33 61/1/33 62/1/33 +f 5/1/33 39/1/33 40/1/33 +f 16/1/33 50/1/33 51/1/33 +f 26/1/33 60/1/33 61/1/33 +f 4/1/33 38/1/33 39/1/33 +f 15/1/33 49/1/33 50/1/33 +f 25/1/33 59/1/33 60/1/33 +f 3/1/33 37/1/33 38/1/33 +f 14/1/33 48/1/33 49/1/33 +f 24/1/33 58/1/33 59/1/33 +f 13/1/33 47/1/33 48/1/33 +f 86/3/33 87/5/33 80/4/33 +f 87/5/66 94/6/66 80/4/66 +f 94/6/33 95/7/33 80/4/33 +f 95/7/33 98/8/33 80/4/33 +f 98/8/33 72/9/33 80/4/33 +f 72/9/33 73/10/33 80/4/33 +f 73/10/33 76/11/33 80/4/33 +f 76/11/33 77/12/33 80/4/33 +f 77/12/67 82/13/67 80/4/67 +f 82/13/33 83/14/33 80/4/33 +f 83/14/68 88/15/68 80/4/68 +f 84/16/33 78/17/33 79/18/33 +f 85/19/66 78/17/66 84/16/66 +f 91/20/33 85/19/33 90/21/33 +f 91/20/33 78/17/33 85/19/33 +f 68/22/33 91/20/33 96/23/33 +f 68/22/33 78/17/33 91/20/33 +f 88/15/67 89/24/67 80/4/67 +f 80/4/33 89/24/33 75/25/33 +f 89/24/33 92/26/33 75/25/33 +f 92/26/68 93/27/68 75/25/68 +f 93/27/33 97/28/33 75/25/33 +f 75/25/33 97/28/33 74/29/33 +f 69/30/33 78/17/33 68/22/33 +f 74/29/33 97/28/33 69/30/33 +f 97/28/33 70/31/33 69/30/33 +f 70/31/68 71/32/68 69/30/68 +f 71/32/33 99/33/33 69/30/33 +f 99/33/33 78/17/33 69/30/33 +f 50/1/34 98/1/34 95/1/34 +f 51/1/69 95/1/69 94/1/69 +f 39/1/36 97/1/36 93/1/36 +f 40/1/70 93/1/70 92/1/70 +f 61/1/38 96/1/38 91/1/38 +f 62/1/39 91/1/39 90/1/39 +f 41/1/71 92/1/71 89/1/71 +f 42/1/41 89/1/41 88/1/41 +f 52/1/72 94/1/72 87/1/72 +f 53/1/73 87/1/73 86/1/73 +f 63/1/74 90/1/74 85/1/74 +f 64/1/45 85/1/45 84/1/45 +f 43/1/46 88/1/46 83/1/46 +f 44/1/47 83/1/47 82/1/47 +f 54/1/48 86/1/48 81/1/48 +f 55/1/49 81/1/49 80/1/49 +f 65/1/75 84/1/75 79/1/75 +f 66/1/51 79/1/51 78/1/51 +f 67/1/52 78/1/52 99/1/52 +f 45/1/53 82/1/53 77/1/53 +f 46/1/76 77/1/76 76/1/76 +f 56/1/55 80/1/55 75/1/55 +f 57/1/56 75/1/56 74/1/56 +f 47/1/57 76/1/57 73/1/57 +f 48/1/58 73/1/58 72/1/58 +f 49/1/59 72/1/59 98/1/59 +f 36/1/77 99/1/77 71/1/77 +f 37/1/61 71/1/61 70/1/61 +f 38/1/78 70/1/78 97/1/78 +f 58/1/63 74/1/63 69/1/63 +f 59/1/64 69/1/64 68/1/64 +f 60/1/65 68/1/65 96/1/65 diff --git a/src/datavisualization/engine/meshes/arrowSmooth.obj b/src/datavisualization/engine/meshes/arrowSmooth.obj new file mode 100644 index 00000000..898c4a2b --- /dev/null +++ b/src/datavisualization/engine/meshes/arrowSmooth.obj @@ -0,0 +1,422 @@ +# Blender v2.69 (sub 0) OBJ File: 'arrow.blend' +# www.blender.org +v 0.000000 1.000000 0.000000 +v 0.000000 0.000000 -1.000000 +v -0.195090 0.000000 -0.980785 +v -0.382683 0.000000 -0.923880 +v -0.555570 0.000000 -0.831470 +v -0.707107 0.000000 -0.707107 +v -0.831470 0.000000 -0.555570 +v -0.923880 0.000000 -0.382683 +v -0.980785 0.000000 -0.195090 +v -1.000000 0.000000 -0.000000 +v -0.980785 0.000000 0.195090 +v -0.923880 0.000000 0.382683 +v -0.831470 0.000000 0.555570 +v -0.707107 0.000000 0.707107 +v -0.555570 0.000000 0.831470 +v -0.382683 0.000000 0.923880 +v -0.195090 0.000000 0.980785 +v 0.000000 0.000000 1.000000 +v 0.195091 0.000000 0.980785 +v 0.382684 0.000000 0.923879 +v 0.555571 0.000000 0.831469 +v 0.707107 0.000000 0.707106 +v 0.831470 0.000000 0.555570 +v 0.923880 0.000000 0.382683 +v 0.980785 0.000000 0.195089 +v 1.000000 0.000000 -0.000001 +v 0.980785 0.000000 -0.195091 +v 0.923879 0.000000 -0.382684 +v 0.831469 0.000000 -0.555571 +v 0.707106 0.000000 -0.707108 +v 0.555569 0.000000 -0.831470 +v 0.382682 0.000000 -0.923880 +v 0.195089 0.000000 -0.980786 +v 0.000000 0.000000 0.000000 +v 0.000000 0.000000 0.000000 +v -0.000000 0.000000 -0.578860 +v -0.112930 0.000000 -0.567737 +v -0.221520 0.000000 -0.534796 +v -0.321597 0.000000 -0.481304 +v -0.409315 0.000000 -0.409316 +v -0.481304 0.000000 -0.321597 +v -0.534796 0.000000 -0.221520 +v -0.567737 0.000000 -0.112930 +v -0.578859 0.000000 -0.000000 +v -0.567737 0.000000 0.112930 +v -0.534796 0.000000 0.221520 +v -0.481304 0.000000 0.321597 +v -0.409315 0.000000 0.409315 +v -0.321597 0.000000 0.481304 +v -0.221520 0.000000 0.534796 +v -0.112930 0.000000 0.567737 +v 0.000000 0.000000 0.578859 +v 0.112930 0.000000 0.567737 +v 0.221520 0.000000 0.534796 +v 0.321597 0.000000 0.481304 +v 0.409316 0.000000 0.409315 +v 0.481304 0.000000 0.321597 +v 0.534796 0.000000 0.221519 +v 0.567737 0.000000 0.112929 +v 0.578859 0.000000 -0.000001 +v 0.567737 0.000000 -0.112931 +v 0.534796 0.000000 -0.221521 +v 0.481304 0.000000 -0.321598 +v 0.409315 0.000000 -0.409316 +v 0.321596 0.000000 -0.481305 +v 0.221519 0.000000 -0.534797 +v 0.112929 0.000000 -0.567737 +v 0.578859 -1.000000 -0.000001 +v 0.567737 -1.000000 0.112929 +v -0.221520 -1.000000 -0.534796 +v -0.112930 -1.000000 -0.567737 +v -0.321597 -1.000000 0.481304 +v -0.409315 -1.000000 0.409315 +v 0.534796 -1.000000 0.221519 +v 0.481304 -1.000000 0.321597 +v -0.481304 -1.000000 0.321597 +v -0.534796 -1.000000 0.221520 +v 0.112929 -1.000000 -0.567737 +v 0.221519 -1.000000 -0.534797 +v 0.409316 -1.000000 0.409315 +v 0.321597 -1.000000 0.481304 +v -0.567737 -1.000000 0.112930 +v -0.578859 -1.000000 -0.000000 +v 0.321596 -1.000000 -0.481305 +v 0.409315 -1.000000 -0.409316 +v 0.221520 -1.000000 0.534796 +v 0.112930 -1.000000 0.567737 +v -0.567737 -1.000000 -0.112930 +v -0.534796 -1.000000 -0.221520 +v 0.481304 -1.000000 -0.321598 +v 0.534796 -1.000000 -0.221521 +v -0.481304 -1.000000 -0.321597 +v -0.409315 -1.000000 -0.409316 +v 0.000000 -1.000000 0.578859 +v -0.112930 -1.000000 0.567737 +v 0.567737 -1.000000 -0.112931 +v -0.321597 -1.000000 -0.481304 +v -0.221520 -1.000000 0.534796 +v -0.000000 -1.000000 -0.578860 +vt 0.000000 0.000000 +vt 0.549236 0.999900 +vt 0.450764 0.999900 +vt 0.645815 0.980689 +vt 0.354184 0.980689 +vt 0.263208 0.943005 +vt 0.181332 0.888297 +vt 0.111702 0.818667 +vt 0.056994 0.736790 +vt 0.019311 0.645815 +vt 0.000100 0.549235 +vt 0.000100 0.450763 +vt 0.019310 0.354184 +vt 0.056994 0.263208 +vt 0.111702 0.181332 +vt 0.943005 0.263208 +vt 0.818666 0.111702 +vt 0.888296 0.181332 +vt 0.980688 0.354184 +vt 0.999899 0.549236 +vt 0.999899 0.450764 +vt 0.943005 0.736791 +vt 0.980689 0.645815 +vt 0.181332 0.111702 +vt 0.736791 0.943006 +vt 0.263209 0.056994 +vt 0.354185 0.019311 +vt 0.450764 0.000100 +vt 0.818667 0.888298 +vt 0.888297 0.818668 +vt 0.549235 0.000100 +vt 0.645815 0.019311 +vt 0.736791 0.056994 +vn 0.000000 1.000000 0.000000 +vn 0.000000 -0.363689 -0.931516 +vn -0.181707 -0.363689 -0.913602 +vn -0.356456 -0.363689 -0.860591 +vn -0.517502 -0.363689 -0.774499 +vn -0.658681 -0.363689 -0.658681 +vn -0.774499 -0.363689 -0.517502 +vn -0.860591 -0.363689 -0.356456 +vn -0.913602 -0.363689 -0.181707 +vn -0.931516 -0.363689 0.000000 +vn -0.913602 -0.363689 0.181707 +vn -0.860591 -0.363689 0.356456 +vn -0.774499 -0.363689 0.517502 +vn -0.658681 -0.363689 0.658681 +vn -0.517502 -0.363689 0.774499 +vn -0.356456 -0.363689 0.860591 +vn -0.181707 -0.363689 0.913602 +vn 0.000000 -0.363689 0.931516 +vn 0.181707 -0.363689 0.913602 +vn 0.356456 -0.363689 0.860591 +vn 0.517502 -0.363689 0.774499 +vn 0.658681 -0.363689 0.658681 +vn 0.774499 -0.363689 0.517502 +vn 0.860591 -0.363689 0.356456 +vn 0.913602 -0.363689 0.181707 +vn 0.931516 -0.363689 0.000000 +vn 0.913602 -0.363689 -0.181707 +vn 0.860591 -0.363689 -0.356456 +vn 0.774499 -0.363689 -0.517502 +vn 0.658681 -0.363689 -0.658681 +vn 0.517502 -0.363689 -0.774499 +vn 0.356456 -0.363689 -0.860591 +vn 0.181707 -0.363689 -0.913602 +vn 0.631550 -0.729820 0.261605 +vn -0.568377 -0.729820 0.379772 +vn 0.000000 -0.729820 -0.683584 +vn 0.568377 -0.729820 0.379772 +vn -0.631550 -0.729820 0.261605 +vn 0.133335 -0.729820 -0.670461 +vn 0.483383 -0.729820 0.483383 +vn -0.670461 -0.729820 0.133335 +vn 0.261574 -0.729820 -0.631550 +vn 0.379772 -0.729820 0.568377 +vn -0.683584 -0.729820 0.000000 +vn 0.379772 -0.729820 -0.568377 +vn 0.261605 -0.729820 0.631550 +vn -0.670461 -0.729820 -0.133335 +vn 0.483383 -0.729820 -0.483383 +vn 0.133335 -0.729820 0.670461 +vn -0.133335 -0.729820 -0.670461 +vn -0.631550 -0.729820 -0.261605 +vn 0.568377 -0.729820 -0.379772 +vn -0.568377 -0.729820 -0.379772 +vn 0.000000 -0.729820 0.683584 +vn 0.631550 -0.729820 -0.261605 +vn -0.483383 -0.729820 -0.483383 +vn -0.133335 -0.729820 0.670461 +vn 0.670461 -0.729820 -0.133366 +vn -0.379772 -0.729820 -0.568377 +vn -0.261605 -0.729820 0.631550 +vn 0.683584 -0.729820 0.000000 +vn -0.261605 -0.729820 -0.631550 +vn -0.379772 -0.729820 0.568377 +vn 0.670461 -0.729820 0.133335 +vn -0.483383 -0.729820 0.483383 +vn 0.404370 -0.685690 0.605213 +vn 0.278542 -0.685690 0.672475 +vn 0.514695 -0.685690 0.514664 +vn -0.142003 -0.685690 0.713889 +vn 0.000000 -0.685690 0.727866 +vn -0.514664 -0.685690 -0.514664 +vn -0.605213 -0.685690 -0.404370 +vn 0.672475 -0.685690 -0.278542 +vn 0.605213 -0.685690 -0.404370 +vn -0.672475 -0.685690 -0.278542 +vn -0.713889 -0.685690 -0.142003 +vn 0.142003 -0.685690 0.713889 +vn 0.514664 -0.685690 -0.514695 +vn 0.404370 -0.685690 -0.605213 +vn -0.727866 -0.685690 0.000000 +vn -0.713889 -0.685690 0.142003 +vn 0.278542 -0.685690 -0.672475 +vn 0.142003 -0.685690 -0.713889 +vn 0.000000 -0.685690 -0.727866 +vn -0.672475 -0.685690 0.278542 +vn -0.605213 -0.685690 0.404370 +vn 0.605213 -0.685690 0.404370 +vn 0.672475 -0.685690 0.278542 +vn -0.514664 -0.685690 0.514664 +vn -0.404370 -0.685690 0.605213 +vn -0.278542 -0.685690 0.672475 +vn -0.142003 -0.685690 -0.713889 +vn -0.278542 -0.685690 -0.672475 +vn -0.404370 -0.685690 -0.605213 +vn 0.713889 -0.685690 0.142003 +vn 0.727866 -0.685690 0.000000 +vn 0.713889 -0.685690 -0.142003 +s 1 +f 1/1/1 2/1/2 3/1/3 +f 1/1/1 3/1/3 4/1/4 +f 1/1/1 4/1/4 5/1/5 +f 1/1/1 5/1/5 6/1/6 +f 1/1/1 6/1/6 7/1/7 +f 1/1/1 7/1/7 8/1/8 +f 1/1/1 8/1/8 9/1/9 +f 1/1/1 9/1/9 10/1/10 +f 1/1/1 10/1/10 11/1/11 +f 1/1/1 11/1/11 12/1/12 +f 1/1/1 12/1/12 13/1/13 +f 1/1/1 13/1/13 14/1/14 +f 1/1/1 14/1/14 15/1/15 +f 1/1/1 15/1/15 16/1/16 +f 1/1/1 16/1/16 17/1/17 +f 1/1/1 17/1/17 18/1/18 +f 1/1/1 18/1/18 19/1/19 +f 1/1/1 19/1/19 20/1/20 +f 1/1/1 20/1/20 21/1/21 +f 1/1/1 21/1/21 22/1/22 +f 1/1/1 22/1/22 23/1/23 +f 1/1/1 23/1/23 24/1/24 +f 1/1/1 24/1/24 25/1/25 +f 1/1/1 25/1/25 26/1/26 +f 1/1/1 26/1/26 27/1/27 +f 1/1/1 27/1/27 28/1/28 +f 1/1/1 28/1/28 29/1/29 +f 1/1/1 29/1/29 30/1/30 +f 1/1/1 30/1/30 31/1/31 +f 1/1/1 31/1/31 32/1/32 +f 1/1/1 32/1/32 33/1/33 +f 1/1/1 33/1/33 2/1/2 +f 24/1/24 23/1/23 58/1/34 +f 13/1/13 12/1/12 47/1/35 +f 2/1/2 33/1/33 36/1/36 +f 23/1/23 22/1/22 57/1/37 +f 12/1/12 11/1/11 46/1/38 +f 33/1/33 32/1/32 67/1/39 +f 22/1/22 21/1/21 56/1/40 +f 11/1/11 10/1/10 45/1/41 +f 32/1/32 31/1/31 66/1/42 +f 21/1/21 20/1/20 55/1/43 +f 10/1/10 9/1/9 44/1/44 +f 31/1/31 30/1/30 65/1/45 +f 20/1/20 19/1/19 54/1/46 +f 9/1/9 8/1/8 43/1/47 +f 30/1/30 29/1/29 64/1/48 +f 19/1/19 18/1/18 53/1/49 +f 3/1/3 2/1/2 37/1/50 +f 8/1/8 7/1/7 42/1/51 +f 29/1/29 28/1/28 63/1/52 +f 7/1/7 6/1/6 41/1/53 +f 18/1/18 17/1/17 52/1/54 +f 28/1/28 27/1/27 62/1/55 +f 6/1/6 5/1/5 40/1/56 +f 17/1/17 16/1/16 51/1/57 +f 27/1/27 26/1/26 61/1/58 +f 5/1/5 4/1/4 39/1/59 +f 16/1/16 15/1/15 50/1/60 +f 26/1/26 25/1/25 60/1/61 +f 4/1/4 3/1/3 38/1/62 +f 15/1/15 14/1/14 49/1/63 +f 25/1/25 24/1/24 59/1/64 +f 14/1/14 13/1/13 48/1/65 +f 81/2/66 86/3/67 80/4/68 +f 51/1/57 50/1/60 95/1/69 +f 52/1/54 51/1/57 94/1/70 +f 40/1/56 39/1/59 93/1/71 +f 41/1/53 40/1/56 92/1/72 +f 62/1/55 61/1/58 91/1/73 +f 63/1/52 62/1/55 90/1/74 +f 42/1/51 41/1/53 89/1/75 +f 43/1/47 42/1/51 88/1/76 +f 53/1/49 52/1/54 87/1/77 +f 54/1/46 53/1/49 86/1/67 +f 64/1/48 63/1/52 85/1/78 +f 65/1/45 64/1/48 84/1/79 +f 44/1/44 43/1/47 83/1/80 +f 45/1/41 44/1/44 82/1/81 +f 55/1/43 54/1/46 81/1/66 +f 56/1/40 55/1/43 80/1/68 +f 66/1/42 65/1/45 79/1/82 +f 67/1/39 66/1/42 78/1/83 +f 36/1/36 67/1/39 99/1/84 +f 46/1/38 45/1/41 77/1/85 +f 47/1/35 46/1/38 76/1/86 +f 57/1/37 56/1/40 75/1/87 +f 58/1/34 57/1/37 74/1/88 +f 48/1/65 47/1/35 73/1/89 +f 49/1/63 48/1/65 72/1/90 +f 50/1/60 49/1/63 98/1/91 +f 37/1/50 36/1/36 71/1/92 +f 38/1/62 37/1/50 70/1/93 +f 39/1/59 38/1/62 97/1/94 +f 59/1/64 58/1/34 69/1/95 +f 60/1/61 59/1/64 68/1/96 +f 61/1/58 60/1/61 96/1/97 +f 23/1/23 57/1/37 58/1/34 +f 12/1/12 46/1/38 47/1/35 +f 33/1/33 67/1/39 36/1/36 +f 22/1/22 56/1/40 57/1/37 +f 11/1/11 45/1/41 46/1/38 +f 32/1/32 66/1/42 67/1/39 +f 21/1/21 55/1/43 56/1/40 +f 10/1/10 44/1/44 45/1/41 +f 31/1/31 65/1/45 66/1/42 +f 20/1/20 54/1/46 55/1/43 +f 9/1/9 43/1/47 44/1/44 +f 30/1/30 64/1/48 65/1/45 +f 19/1/19 53/1/49 54/1/46 +f 8/1/8 42/1/51 43/1/47 +f 29/1/29 63/1/52 64/1/48 +f 18/1/18 52/1/54 53/1/49 +f 2/1/2 36/1/36 37/1/50 +f 7/1/7 41/1/53 42/1/51 +f 28/1/28 62/1/55 63/1/52 +f 6/1/6 40/1/56 41/1/53 +f 17/1/17 51/1/57 52/1/54 +f 27/1/27 61/1/58 62/1/55 +f 5/1/5 39/1/59 40/1/56 +f 16/1/16 50/1/60 51/1/57 +f 26/1/26 60/1/61 61/1/58 +f 4/1/4 38/1/62 39/1/59 +f 15/1/15 49/1/63 50/1/60 +f 25/1/25 59/1/64 60/1/61 +f 3/1/3 37/1/50 38/1/62 +f 14/1/14 48/1/65 49/1/63 +f 24/1/24 58/1/34 59/1/64 +f 13/1/13 47/1/35 48/1/65 +f 86/3/67 87/5/77 80/4/68 +f 87/5/77 94/6/70 80/4/68 +f 94/6/70 95/7/69 80/4/68 +f 95/7/69 98/8/91 80/4/68 +f 98/8/91 72/9/90 80/4/68 +f 72/9/90 73/10/89 80/4/68 +f 73/10/89 76/11/86 80/4/68 +f 76/11/86 77/12/85 80/4/68 +f 77/12/85 82/13/81 80/4/68 +f 82/13/81 83/14/80 80/4/68 +f 83/14/80 88/15/76 80/4/68 +f 84/16/79 78/17/83 79/18/82 +f 85/19/78 78/17/83 84/16/79 +f 91/20/73 85/19/78 90/21/74 +f 91/20/73 78/17/83 85/19/78 +f 68/22/96 91/20/73 96/23/97 +f 68/22/96 78/17/83 91/20/73 +f 88/15/76 89/24/75 80/4/68 +f 80/4/68 89/24/75 75/25/87 +f 89/24/75 92/26/72 75/25/87 +f 92/26/72 93/27/71 75/25/87 +f 93/27/71 97/28/94 75/25/87 +f 75/25/87 97/28/94 74/29/88 +f 69/30/95 78/17/83 68/22/96 +f 74/29/88 97/28/94 69/30/95 +f 97/28/94 70/31/93 69/30/95 +f 70/31/93 71/32/92 69/30/95 +f 71/32/92 99/33/84 69/30/95 +f 99/33/84 78/17/83 69/30/95 +f 50/1/60 98/1/91 95/1/69 +f 51/1/57 95/1/69 94/1/70 +f 39/1/59 97/1/94 93/1/71 +f 40/1/56 93/1/71 92/1/72 +f 61/1/58 96/1/97 91/1/73 +f 62/1/55 91/1/73 90/1/74 +f 41/1/53 92/1/72 89/1/75 +f 42/1/51 89/1/75 88/1/76 +f 52/1/54 94/1/70 87/1/77 +f 53/1/49 87/1/77 86/1/67 +f 63/1/52 90/1/74 85/1/78 +f 64/1/48 85/1/78 84/1/79 +f 43/1/47 88/1/76 83/1/80 +f 44/1/44 83/1/80 82/1/81 +f 54/1/46 86/1/67 81/1/66 +f 55/1/43 81/1/66 80/1/68 +f 65/1/45 84/1/79 79/1/82 +f 66/1/42 79/1/82 78/1/83 +f 67/1/39 78/1/83 99/1/84 +f 45/1/41 82/1/81 77/1/85 +f 46/1/38 77/1/85 76/1/86 +f 56/1/40 80/1/68 75/1/87 +f 57/1/37 75/1/87 74/1/88 +f 47/1/35 76/1/86 73/1/89 +f 48/1/65 73/1/89 72/1/90 +f 49/1/63 72/1/90 98/1/91 +f 36/1/36 99/1/84 71/1/92 +f 37/1/50 71/1/92 70/1/93 +f 38/1/62 70/1/93 97/1/94 +f 58/1/34 74/1/88 69/1/95 +f 59/1/64 69/1/95 68/1/96 +f 60/1/61 68/1/96 96/1/97 diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index 6a08c934..9973069b 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -208,6 +208,7 @@ void Scatter3DRenderer::updateData() && (dotPos.z() >= minZ && dotPos.z() <= maxZ)) { m_renderingArrays[series][i].setPosition(dotPos); m_renderingArrays[series][i].setVisible(true); + m_renderingArrays[series][i].setRotation(dataArray.at(i).rotation()); calculateTranslation(m_renderingArrays[series][i]); } else { m_renderingArrays[series][i].setVisible(false); @@ -387,8 +388,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) QMatrix4x4 MVPMatrix; modelMatrix.translate(item.translation()); - if (!drawingPoints) + if (!drawingPoints) { + modelMatrix.rotate(item.rotation()); modelMatrix.scale(modelScaler); + } MVPMatrix = depthProjectionViewMatrix * modelMatrix; @@ -512,8 +515,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) QMatrix4x4 MVPMatrix; modelMatrix.translate(item.translation()); - if (!drawingPoints) + if (!drawingPoints) { + modelMatrix.rotate(item.rotation()); modelMatrix.scale(modelScaler); + } MVPMatrix = projectionViewMatrix * modelMatrix; @@ -682,8 +687,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) modelMatrix.translate(item.translation()); if (!drawingPoints) { + modelMatrix.rotate(item.rotation()); modelMatrix.scale(modelScaler); itModelMatrix.scale(modelScaler); + itModelMatrix.rotate(item.rotation()); } #ifdef SHOW_DEPTH_TEXTURE_SCENE MVPMatrix = depthProjectionViewMatrix * modelMatrix; @@ -714,6 +721,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) dotShader->setUniformValue(dotShader->nModel(), itModelMatrix.inverted().transposed()); } + dotShader->setUniformValue(dotShader->MVP(), MVPMatrix); if (useColor) { dotShader->setUniformValue(dotShader->color(), dotColor); diff --git a/src/datavisualization/engine/seriesrendercache.cpp b/src/datavisualization/engine/seriesrendercache.cpp index 04b2249d..7526ac03 100644 --- a/src/datavisualization/engine/seriesrendercache.cpp +++ b/src/datavisualization/engine/seriesrendercache.cpp @@ -96,6 +96,9 @@ void SeriesRenderCache::populate(QAbstract3DSeries *series, Abstract3DRenderer * case QAbstract3DSeries::MeshMinimal: meshFileName = QStringLiteral(":/defaultMeshes/minimal"); break; + case QAbstract3DSeries::MeshArrow: + meshFileName = QStringLiteral(":/defaultMeshes/arrow"); + break; case QAbstract3DSeries::MeshPoint: #if defined(QT_OPENGL_ES_2) qWarning("QAbstract3DSeries::MeshPoint is not fully supported on OpenGL ES2"); diff --git a/tests/directional/directional.pro b/tests/directional/directional.pro new file mode 100644 index 00000000..7138e1f2 --- /dev/null +++ b/tests/directional/directional.pro @@ -0,0 +1,10 @@ +!include( ../tests.pri ) { + error( "Couldn't find the tests.pri file!" ) +} + +SOURCES += main.cpp scatterdatamodifier.cpp +HEADERS += scatterdatamodifier.h + +QT += widgets + +INSTALLS += target diff --git a/tests/directional/main.cpp b/tests/directional/main.cpp new file mode 100644 index 00000000..359868cc --- /dev/null +++ b/tests/directional/main.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "scatterdatamodifier.h" + +#include <QApplication> +#include <QWidget> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QPushButton> +#include <QCheckBox> +#include <QComboBox> +#include <QFontComboBox> +#include <QLabel> +#include <QScreen> +#include <QFontDatabase> + +int main(int argc, char **argv) +{ + //! [0] + QApplication app(argc, argv); + Q3DScatter *graph = new Q3DScatter(); + QWidget *container = QWidget::createWindowContainer(graph); + //! [0] + + QSize screenSize = graph->screen()->size(); + container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); + container->setMaximumSize(screenSize); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + container->setFocusPolicy(Qt::StrongFocus); + + //! [1] + QWidget *widget = new QWidget; + QHBoxLayout *hLayout = new QHBoxLayout(widget); + QVBoxLayout *vLayout = new QVBoxLayout(); + hLayout->addWidget(container, 1); + hLayout->addLayout(vLayout); + //! [1] + + widget->setWindowTitle(QStringLiteral("Directional scatter")); + + //! [4] + QComboBox *themeList = new QComboBox(widget); + themeList->addItem(QStringLiteral("Qt")); + themeList->addItem(QStringLiteral("Primary Colors")); + themeList->addItem(QStringLiteral("Digia")); + themeList->addItem(QStringLiteral("Stone Moss")); + themeList->addItem(QStringLiteral("Army Blue")); + themeList->addItem(QStringLiteral("Retro")); + themeList->addItem(QStringLiteral("Ebony")); + themeList->addItem(QStringLiteral("Isabelle")); + themeList->setCurrentIndex(6); + + QPushButton *labelButton = new QPushButton(widget); + labelButton->setText(QStringLiteral("Change label style")); + + QComboBox *itemStyleList = new QComboBox(widget); + itemStyleList->addItem(QStringLiteral("Arrow"), int(QAbstract3DSeries::MeshArrow)); + itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); + itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); + itemStyleList->setCurrentIndex(-1); + + QPushButton *cameraButton = new QPushButton(widget); + cameraButton->setText(QStringLiteral("Change camera preset")); + + QCheckBox *backgroundCheckBox = new QCheckBox(widget); + backgroundCheckBox->setText(QStringLiteral("Show background")); + backgroundCheckBox->setChecked(true); + + QCheckBox *gridCheckBox = new QCheckBox(widget); + gridCheckBox->setText(QStringLiteral("Show grid")); + gridCheckBox->setChecked(true); + + QComboBox *shadowQuality = new QComboBox(widget); + shadowQuality->addItem(QStringLiteral("None")); + shadowQuality->addItem(QStringLiteral("Low")); + shadowQuality->addItem(QStringLiteral("Medium")); + shadowQuality->addItem(QStringLiteral("High")); + shadowQuality->addItem(QStringLiteral("Low Soft")); + shadowQuality->addItem(QStringLiteral("Medium Soft")); + shadowQuality->addItem(QStringLiteral("High Soft")); + shadowQuality->setCurrentIndex(4); + + QFontComboBox *fontList = new QFontComboBox(widget); + fontList->setCurrentFont(QFont("Arial")); + //! [4] + + //! [5] + vLayout->addWidget(labelButton, 0, Qt::AlignTop); + vLayout->addWidget(cameraButton, 0, Qt::AlignTop); + vLayout->addWidget(backgroundCheckBox); + vLayout->addWidget(gridCheckBox); + vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); + vLayout->addWidget(itemStyleList); + vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); + vLayout->addWidget(themeList); + vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); + vLayout->addWidget(shadowQuality); + vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); + vLayout->addWidget(fontList, 1, Qt::AlignTop); + //! [5] + + //! [2] + ScatterDataModifier *modifier = new ScatterDataModifier(graph); + //! [2] + + //! [6] + QObject::connect(cameraButton, &QPushButton::clicked, modifier, + &ScatterDataModifier::changePresetCamera); + QObject::connect(labelButton, &QPushButton::clicked, modifier, + &ScatterDataModifier::changeLabelStyle); + + QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, + &ScatterDataModifier::setBackgroundEnabled); + QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, + &ScatterDataModifier::setGridEnabled); + + QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged, + backgroundCheckBox, &QCheckBox::setChecked); + QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged, + gridCheckBox, &QCheckBox::setChecked); + QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeStyle(int))); + + QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeTheme(int))); + + QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeShadowQuality(int))); + + QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, + &QComboBox::setCurrentIndex); + QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier, + &ScatterDataModifier::shadowQualityUpdatedByVisual); + + QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, + &ScatterDataModifier::changeFont); + + QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList, + &QFontComboBox::setCurrentFont); + //! [6] + + itemStyleList->setCurrentIndex(0); + + //! [3] + widget->show(); + return app.exec(); + //! [3] +} diff --git a/tests/directional/scatterdatamodifier.cpp b/tests/directional/scatterdatamodifier.cpp new file mode 100644 index 00000000..065d9a89 --- /dev/null +++ b/tests/directional/scatterdatamodifier.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "scatterdatamodifier.h" +#include <QtDataVisualization/qscatterdataproxy.h> +#include <QtDataVisualization/qvalue3daxis.h> +#include <QtDataVisualization/q3dscene.h> +#include <QtDataVisualization/q3dcamera.h> +#include <QtDataVisualization/qscatter3dseries.h> +#include <QtDataVisualization/q3dtheme.h> +#include <qmath.h> +#include <QComboBox> + +using namespace QtDataVisualization; + +const int numberOfCols = 8; +const int numberOfRows = 8; +const float limit = 8.0f; +const float PI = 3.14159f; +//#define HEDGEHOG + +ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) + : m_graph(scatter), + m_fontSize(40.0f), + m_style(QAbstract3DSeries::MeshUserDefined), + m_smooth(true) +{ + m_graph->activeTheme()->setType(Q3DTheme::ThemeEbony); + QFont font = m_graph->activeTheme()->font(); + font.setPointSize(m_fontSize); + m_graph->activeTheme()->setFont(font); + m_graph->setShadowQuality(QDataVis::ShadowQualitySoftLow); + m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront); + + m_graph->setAxisX(new QValue3DAxis); + m_graph->setAxisY(new QValue3DAxis); + m_graph->setAxisZ(new QValue3DAxis); + + QScatterDataProxy *proxy = new QScatterDataProxy; + QScatter3DSeries *series = new QScatter3DSeries(proxy); + series->setItemLabelFormat("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"); + m_graph->addSeries(series); + + addData(); +} + +ScatterDataModifier::~ScatterDataModifier() +{ + delete m_graph; +} + +void ScatterDataModifier::addData() +{ + // Configure the axes according to the data + m_graph->axisX()->setTitle("X"); + m_graph->axisY()->setTitle("Y"); + m_graph->axisZ()->setTitle("Z"); + m_graph->axisX()->setRange(-limit, limit); + m_graph->axisY()->setRange(-1.0f, 1.0f); + m_graph->axisZ()->setRange(-limit, limit); + + QScatterDataArray *dataArray = new QScatterDataArray; + dataArray->resize(numberOfCols * numberOfRows); + QScatterDataItem *ptrToDataArray = &dataArray->first(); + + float angleStep = 360.0f / float(numberOfCols); + float latAngleStep = 100.0f / float(numberOfRows); + + for (float i = 0; i < numberOfRows; i++) { + float latAngle = float(i) * latAngleStep + 40.0f; + float radius = qSin(latAngle * PI / 180.0f) * limit; + float y = qCos(latAngle * PI / 180.0f) * 1.0f; +#ifdef HEDGEHOG + float angleZ = (qAtan((y * limit / 2.0f) / radius) * 180.0f / PI); + QQuaternion rotationZ = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 0.0f, 1.0f), angleZ - 90.0f); +#endif + for (float j = 0; j < numberOfCols; j++) { + float angle = float(j) * angleStep; + float x = qCos(angle * PI / 180.0f) * radius; + float z = qSin(angle * PI / 180.0f) * radius; + + float angleY = (qAtan(z / x) * 180.0f / PI); + if (x < 0) + angleY = 180.0f + angleY; + if (x > 0 && z < 0) + angleY = 360.0f + angleY; +#ifdef HEDGEHOG + QQuaternion rotationY = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), angleY); + QQuaternion rotation = rotationY * rotationZ; +#else + QQuaternion rotation = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), angleY) * + QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), -90.0f); +#endif + + ptrToDataArray->setPosition(QVector3D(x, y, z)); + ptrToDataArray->setRotation(rotation); + ptrToDataArray++; + } + } + + m_graph->seriesList().at(0)->dataProxy()->resetArray(dataArray); +} + +//! [8] +void ScatterDataModifier::changeStyle(int style) +{ + QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); + if (comboBox) { + m_style = QAbstract3DSeries::Mesh(comboBox->itemData(style).toInt()); + if (m_graph->seriesList().size()) + m_graph->seriesList().at(0)->setMesh(m_style); + } +} + +void ScatterDataModifier::changeTheme(int theme) +{ + Q3DTheme *currentTheme = m_graph->activeTheme(); + currentTheme->setType(Q3DTheme::Theme(theme)); + emit backgroundEnabledChanged(currentTheme->isBackgroundEnabled()); + emit gridEnabledChanged(currentTheme->isGridEnabled()); + emit fontChanged(currentTheme->font()); +} + +void ScatterDataModifier::changePresetCamera() +{ + static int preset = Q3DCamera::CameraPresetFrontLow; + + m_graph->scene()->activeCamera()->setCameraPreset((Q3DCamera::CameraPreset)preset); + + if (++preset > Q3DCamera::CameraPresetDirectlyBelow) + preset = Q3DCamera::CameraPresetFrontLow; +} + +void ScatterDataModifier::changeLabelStyle() +{ + m_graph->activeTheme()->setLabelBackgroundEnabled(!m_graph->activeTheme()->isLabelBackgroundEnabled()); +} + +void ScatterDataModifier::changeFont(const QFont &font) +{ + QFont newFont = font; + newFont.setPointSizeF(m_fontSize); + m_graph->activeTheme()->setFont(newFont); +} + +void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) +{ + int quality = int(sq); + emit shadowQualityChanged(quality); // connected to a checkbox in main.cpp +} + +void ScatterDataModifier::changeShadowQuality(int quality) +{ + QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality); + m_graph->setShadowQuality(sq); +} + +void ScatterDataModifier::setBackgroundEnabled(int enabled) +{ + m_graph->activeTheme()->setBackgroundEnabled((bool)enabled); +} + +void ScatterDataModifier::setGridEnabled(int enabled) +{ + m_graph->activeTheme()->setGridEnabled((bool)enabled); +} diff --git a/tests/directional/scatterdatamodifier.h b/tests/directional/scatterdatamodifier.h new file mode 100644 index 00000000..fbb92e86 --- /dev/null +++ b/tests/directional/scatterdatamodifier.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#ifndef SCATTERDATAMODIFIER_H +#define SCATTERDATAMODIFIER_H + +#include <QtDataVisualization/q3dscatter.h> +#include <QtDataVisualization/qabstract3dseries.h> +#include <QtGui/QFont> + +using namespace QtDataVisualization; + +class ScatterDataModifier : public QObject +{ + Q_OBJECT +public: + explicit ScatterDataModifier(Q3DScatter *scatter); + ~ScatterDataModifier(); + + void addData(); + void changeStyle(); + void changePresetCamera(); + void changeLabelStyle(); + void changeFont(const QFont &font); + void changeFontSize(int fontsize); + void setBackgroundEnabled(int enabled); + void setGridEnabled(int enabled); + void start(); + +public slots: + void changeStyle(int style); + void changeTheme(int theme); + void changeShadowQuality(int quality); + void shadowQualityUpdatedByVisual(QDataVis::ShadowQuality shadowQuality); + +signals: + void backgroundEnabledChanged(bool enabled); + void gridEnabledChanged(bool enabled); + void shadowQualityChanged(int quality); + void fontChanged(QFont font); + +private: + Q3DScatter *m_graph; + int m_fontSize; + QAbstract3DSeries::Mesh m_style; + bool m_smooth; +}; + +#endif |