diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-11-28 08:19:37 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-11-29 09:53:48 +0200 |
commit | 527113321ff103835b89543c5d6f670f55b5b0d5 (patch) | |
tree | 01b242ef7b1f30a414b718f99f155f19235951bd /src/datavisualization/data/qabstract3dseries.cpp | |
parent | 85dda87df2d420dc53959e549d24c4b09ce93d57 (diff) |
Move series specific visual elements to series, part 1
Meshes moved to series.
Task-number: QTRD-2557
Change-Id: I80050e413faf3bc942eb5a5627a66747de5805d8
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/data/qabstract3dseries.cpp')
-rw-r--r-- | src/datavisualization/data/qabstract3dseries.cpp | 156 |
1 files changed, 144 insertions, 12 deletions
diff --git a/src/datavisualization/data/qabstract3dseries.cpp b/src/datavisualization/data/qabstract3dseries.cpp index 579e1dec..d5c4c6b8 100644 --- a/src/datavisualization/data/qabstract3dseries.cpp +++ b/src/datavisualization/data/qabstract3dseries.cpp @@ -79,6 +79,36 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE */ /*! + \enum QAbstract3DSeries::Mesh + + Predefined mesh types. All styles are not usable with all visualization types. + + \value MeshUserDefined + User defined mesh, set via QAbstract3DSeries::userDefinedMesh property. + \value MeshBar + Basic rectangular bar. + \value MeshCube + Basic cube. + \value MeshPyramid + Four-sided pyramid. + \value MeshCone + Basic cone. + \value MeshCylinder + Basic cylinder. + \value MeshBevelBar + Slightly beveled (rounded) rectangular bar. + \value MeshBevelCube + Slightly beveled (rounded) cube. + \value MeshSphere + Sphere. + \value MeshMinimal + The minimal 3D mesh: a triangular pyramid. Usable only with Q3DScatter. + \value MeshPoint + 2D point. Usable only with Q3DScatter. + \b Note: Shadows and color gradients do not affect this style. +*/ + +/*! * \internal */ QAbstract3DSeries::QAbstract3DSeries(QAbstract3DSeriesPrivate *d, QObject *parent) : @@ -115,7 +145,7 @@ QAbstract3DSeries::SeriesType QAbstract3DSeries::type() const */ void QAbstract3DSeries::setItemLabelFormat(const QString &format) { - if (format != itemLabelFormat()) { + if (d_ptr->m_itemLabelFormat != format) { d_ptr->setItemLabelFormat(format); emit itemLabelFormatChanged(format); } @@ -134,8 +164,10 @@ QString QAbstract3DSeries::itemLabelFormat() const */ void QAbstract3DSeries::setVisible(bool visible) { - d_ptr->m_visible = visible; - emit visibilityChanged(visible); + if (d_ptr->m_visible != visible) { + d_ptr->setVisible(visible); + emit visibilityChanged(visible); + } } bool QAbstract3DSeries::isVisible() const @@ -143,6 +175,70 @@ bool QAbstract3DSeries::isVisible() const return d_ptr->m_visible; } +/*! + * \property QAbstract3DSeries::mesh + * + * Sets the mesh of the items in the series, or the selection pointer in case of + * QSurface3DSeries. If the \a mesh is MeshUserDefined, then the userDefinedMesh property + * must also be set for items to render properly. The default value depends on the graph type. + */ +void QAbstract3DSeries::setMesh(QAbstract3DSeries::Mesh mesh) +{ + if ((mesh == QAbstract3DSeries::MeshPoint || mesh == QAbstract3DSeries::MeshMinimal) + && type() != QAbstract3DSeries::SeriesTypeScatter) { + qWarning() << "Specified style is only supported for QScatter3DSeries."; + } else if (d_ptr->m_mesh != mesh) { + d_ptr->setMesh(mesh); + emit meshChanged(mesh); + } +} + +QAbstract3DSeries::Mesh QAbstract3DSeries::mesh() const +{ + return d_ptr->m_mesh; +} + +/*! + * \property QAbstract3DSeries::meshSmooth + * + * If \a enable is true, smooth versions of predefined meshes set via mesh property are used. + * This property doesn't affect custom meshes used when mesh is MeshUserDefined. + * Defaults to false. + */ +void QAbstract3DSeries::setMeshSmooth(bool enable) +{ + if (d_ptr->m_meshSmooth != enable) { + d_ptr->setMeshSmooth(enable); + emit meshSmoothChanged(enable); + } +} + +bool QAbstract3DSeries::isMeshSmooth() const +{ + return d_ptr->m_meshSmooth; +} + +/*! + * \property QAbstract3DSeries::userDefinedMesh + * + * Sets the \a fileName for user defined custom mesh for objects that is used when mesh + * is MeshUserDefined. + * \note The file specified by \a fileName needs to be in Wavefront obj format and include + * vertices, normals and UVs. It also needs to be in triangles. + */ +void QAbstract3DSeries::setUserDefinedMesh(const QString &fileName) +{ + if (d_ptr->m_userDefinedMesh != fileName) { + d_ptr->setUserDefinedMesh(fileName); + emit userDefinedMeshChanged(fileName); + } +} + +QString QAbstract3DSeries::userDefinedMesh() const +{ + return d_ptr->m_userDefinedMesh; +} + // QAbstract3DSeriesPrivate QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q, QAbstract3DSeries::SeriesType type) @@ -151,7 +247,9 @@ QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q, QAbstra m_type(type), m_dataProxy(0), m_visible(true), - m_controller(0) + m_controller(0), + m_mesh(QAbstract3DSeries::MeshCube), + m_meshSmooth(false) { } @@ -159,13 +257,6 @@ QAbstract3DSeriesPrivate::~QAbstract3DSeriesPrivate() { } -void QAbstract3DSeriesPrivate::setItemLabelFormat(const QString &format) -{ - m_itemLabelFormat = format; - if (m_controller) - m_controller->setSeriesDirty(); -} - QAbstractDataProxy *QAbstract3DSeriesPrivate::dataProxy() const { return m_dataProxy; @@ -180,8 +271,10 @@ void QAbstract3DSeriesPrivate::setDataProxy(QAbstractDataProxy *proxy) proxy->d_ptr->setSeries(q_ptr); // also sets parent - if (m_controller) + if (m_controller) { connectControllerAndProxy(m_controller); + m_controller->markDataDirty(); + } } void QAbstract3DSeriesPrivate::setController(Abstract3DController *controller) @@ -191,4 +284,43 @@ void QAbstract3DSeriesPrivate::setController(Abstract3DController *controller) q_ptr->setParent(controller); } +void QAbstract3DSeriesPrivate::setItemLabelFormat(const QString &format) +{ + m_itemLabelFormat = format; + m_changeTracker.itemLabelFormatChanged = true; + if (m_controller) + m_controller->markSeriesVisualsDirty(); +} + +void QAbstract3DSeriesPrivate::setVisible(bool visible) +{ + m_visible = visible; + if (m_controller) + m_controller->markSeriesVisualsDirty(); +} + +void QAbstract3DSeriesPrivate::setMesh(QAbstract3DSeries::Mesh mesh) +{ + m_mesh = mesh; + m_changeTracker.meshChanged = true; + if (m_controller) + m_controller->markSeriesVisualsDirty(); +} + +void QAbstract3DSeriesPrivate::setMeshSmooth(bool enable) +{ + m_meshSmooth = enable; + m_changeTracker.meshSmoothChanged = true; + if (m_controller) + m_controller->markSeriesVisualsDirty(); +} + +void QAbstract3DSeriesPrivate::setUserDefinedMesh(const QString &meshFile) +{ + m_userDefinedMesh = meshFile; + m_changeTracker.userDefinedMeshChanged = true; + if (m_controller) + m_controller->markSeriesVisualsDirty(); +} + QT_DATAVISUALIZATION_END_NAMESPACE |