diff options
Diffstat (limited to 'src')
4 files changed, 75 insertions, 9 deletions
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc index e6e3e881..36c812f1 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc @@ -149,3 +149,43 @@ * Clears selection from all attached series. */ +/*! + * \qmlmethod int AbstractGraph3D::addCustomItem(string meshFile, vector3d position, vector3d scaling, quaternion rotation, string textureFile) + * + * Adds a custom mesh item located in \a meshFile to a graph at \a position with \a {scaling}, + * \a rotation and optional image for a texture located at \a textureFile. Item must be in + * Wavefront obj format and include vertices, normals and UVs. It also needs to be in triangles. + * Item position is given in data coordinates. + * + * \return index to the added item. + * + * \note No validity checks are made for the position of the item, so it is up to the user to + * provide a valid position. Items positioned outside axis ranges are still rendered. + * + * \sa removeCustomItemAt() + * + * \since Qt Data Visualization 1.1 + */ + +/*! + * \qmlmethod void AbstractGraph3D::removeCustomItemAt(int index) + * + * Removes the custom item at \a {index}. Deletes the resources allocated to it. + * + * \note The index of the remaining items will change if the item removed is other than + * the last. + * + * \since Qt Data Visualization 1.1 + */ + +/*! + * \qmlmethod void AbstractGraph3D::removeCustomItemAt(vector3d position) + * + * Removes the custom item at \a {position}. Deletes the resources allocated to it. + * + * \note The index of the remaining items will change if an item is removed from a position that + * is not at the last index. + * + * \since Qt Data Visualization 1.1 + */ + diff --git a/src/datavisualization/engine/qabstract3dgraph.cpp b/src/datavisualization/engine/qabstract3dgraph.cpp index 1c46427d..e143e756 100644 --- a/src/datavisualization/engine/qabstract3dgraph.cpp +++ b/src/datavisualization/engine/qabstract3dgraph.cpp @@ -405,7 +405,7 @@ int QAbstract3DGraph::addCustomItem(const QString &meshFile, const QVector3D &po } /*! - * Removes the custom item at \a {index}. Deletes the resource allocated to it. + * Removes the custom item at \a {index}. Deletes the resources allocated to it. * * \note The index of the remaining items will change if the item removed is other than * the last. @@ -418,7 +418,7 @@ void QAbstract3DGraph::removeCustomItemAt(int index) } /*! - * Removes the custom item at \a {position}. Deletes the resource allocated to it. + * Removes the custom item at \a {position}. Deletes the resources allocated to it. * * \note The index of the remaining items will change if an item is removed from a position that * is not at the last index. diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp index 881a7860..2a02ad24 100644 --- a/src/datavisualizationqml2/abstractdeclarative.cpp +++ b/src/datavisualizationqml2/abstractdeclarative.cpp @@ -37,18 +37,18 @@ AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) : m_controller(0), m_contextWindow(0), m_renderMode(RenderIndirect), -#if defined(QT_OPENGL_ES_2) + #if defined(QT_OPENGL_ES_2) m_samples(0), -#else + #else m_samples(4), -#endif + #endif m_windowSamples(0), m_initialisedSize(0, 0), -#ifdef USE_SHARED_CONTEXT + #ifdef USE_SHARED_CONTEXT m_context(0), -#else + #else m_stateStore(0), -#endif + #endif m_qtContext(0), m_mainThread(QThread::currentThread()), m_contextThread(0) @@ -211,6 +211,26 @@ bool AbstractDeclarative::shadowsSupported() const return m_controller->shadowsSupported(); } +int AbstractDeclarative::addCustomItem(const QString &meshFile, const QVector3D &position, + const QVector3D &scaling, const QQuaternion &rotation, + const QString &textureFile) +{ + QImage textureImage; + if (!textureFile.isNull()) + textureImage = QImage(textureFile); + return m_controller->addCustomItem(meshFile, position, scaling, rotation, textureImage); +} + +void AbstractDeclarative::removeCustomItemAt(int index) +{ + m_controller->deleteCustomItem(index); +} + +void AbstractDeclarative::removeCustomItemAt(const QVector3D &position) +{ + m_controller->deleteCustomItem(position); +} + void AbstractDeclarative::setSharedController(Abstract3DController *controller) { Q_ASSERT(controller); diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h index 8ba86b11..4f73380f 100644 --- a/src/datavisualizationqml2/abstractdeclarative_p.h +++ b/src/datavisualizationqml2/abstractdeclarative_p.h @@ -128,7 +128,13 @@ public: Q_INVOKABLE virtual void clearSelection(); - virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); + Q_INVOKABLE virtual int addCustomItem(const QString &meshFile, const QVector3D &position, + const QVector3D &scaling, const QQuaternion &rotation, + const QString &textureFile = 0); + Q_INVOKABLE virtual void removeCustomItemAt(int index); + Q_INVOKABLE virtual void removeCustomItemAt(const QVector3D &position); + + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); void setSharedController(Abstract3DController *controller); // Used to synch up data model from controller to renderer while main thread is locked |