summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/data
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-28 08:19:37 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-29 09:53:48 +0200
commit527113321ff103835b89543c5d6f670f55b5b0d5 (patch)
tree01b242ef7b1f30a414b718f99f155f19235951bd /src/datavisualization/data
parent85dda87df2d420dc53959e549d24c4b09ce93d57 (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')
-rw-r--r--src/datavisualization/data/barrenderitem.cpp4
-rw-r--r--src/datavisualization/data/barrenderitem_p.h6
-rw-r--r--src/datavisualization/data/qabstract3dseries.cpp156
-rw-r--r--src/datavisualization/data/qabstract3dseries.h31
-rw-r--r--src/datavisualization/data/qabstract3dseries_p.h38
-rw-r--r--src/datavisualization/data/qbar3dseries.cpp3
-rw-r--r--src/datavisualization/data/qscatter3dseries.cpp4
-rw-r--r--src/datavisualization/data/qsurface3dseries.cpp7
8 files changed, 215 insertions, 34 deletions
diff --git a/src/datavisualization/data/barrenderitem.cpp b/src/datavisualization/data/barrenderitem.cpp
index 558e2f96..67029c60 100644
--- a/src/datavisualization/data/barrenderitem.cpp
+++ b/src/datavisualization/data/barrenderitem.cpp
@@ -25,7 +25,8 @@ BarRenderItem::BarRenderItem()
: AbstractRenderItem(),
m_value(0),
m_height(0.0f),
- m_sliceLabelItem(0)
+ m_sliceLabelItem(0),
+ m_seriesIndex(0)
{
}
@@ -37,6 +38,7 @@ BarRenderItem::BarRenderItem(const BarRenderItem &other)
m_height = other.m_height;
m_sliceLabel = other.m_sliceLabel;
m_sliceLabelItem = 0;
+ m_seriesIndex = other.m_seriesIndex;
}
BarRenderItem::~BarRenderItem()
diff --git a/src/datavisualization/data/barrenderitem_p.h b/src/datavisualization/data/barrenderitem_p.h
index a837ff2c..480d5049 100644
--- a/src/datavisualization/data/barrenderitem_p.h
+++ b/src/datavisualization/data/barrenderitem_p.h
@@ -61,12 +61,18 @@ public:
void setSliceLabel(const QString &label);
QString &sliceLabel(); // Formats label if not previously formatted
+ // Series index in visual series that this item belongs to.
+ // This is only utilized by slicing, so it may not be up to date on all items.
+ inline void setSeriesIndex(int seriesIndex) { m_seriesIndex = seriesIndex; }
+ inline int seriesIndex() { return m_seriesIndex; }
+
protected:
float m_value;
QPoint m_position; // x = row, y = column
GLfloat m_height;
QString m_sliceLabel;
LabelItem *m_sliceLabelItem;
+ int m_seriesIndex;
friend class QBarDataItem;
};
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
diff --git a/src/datavisualization/data/qabstract3dseries.h b/src/datavisualization/data/qabstract3dseries.h
index ccd93ad2..4d971749 100644
--- a/src/datavisualization/data/qabstract3dseries.h
+++ b/src/datavisualization/data/qabstract3dseries.h
@@ -31,9 +31,13 @@ class QT_DATAVISUALIZATION_EXPORT QAbstract3DSeries : public QObject
{
Q_OBJECT
Q_ENUMS(SeriesType)
+ Q_ENUMS(Mesh)
Q_PROPERTY(SeriesType type READ type)
Q_PROPERTY(QString itemLabelFormat READ itemLabelFormat WRITE setItemLabelFormat NOTIFY itemLabelFormatChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged)
+ Q_PROPERTY(Mesh mesh READ mesh WRITE setMesh NOTIFY meshChanged)
+ Q_PROPERTY(bool meshSmooth READ isMeshSmooth WRITE setMeshSmooth NOTIFY meshSmoothChanged)
+ Q_PROPERTY(QString userDefinedMesh READ userDefinedMesh WRITE setUserDefinedMesh NOTIFY userDefinedMeshChanged)
public:
enum SeriesType {
@@ -43,6 +47,20 @@ public:
SeriesTypeSurface = 4
};
+ enum Mesh {
+ MeshUserDefined = 0,
+ MeshBar,
+ MeshCube,
+ MeshPyramid,
+ MeshCone,
+ MeshCylinder,
+ MeshBevelBar,
+ MeshBevelCube,
+ MeshSphere,
+ MeshMinimal,
+ MeshPoint
+ };
+
protected:
explicit QAbstract3DSeries(QAbstract3DSeriesPrivate *d, QObject *parent = 0);
@@ -57,9 +75,21 @@ public:
void setVisible(bool visible);
bool isVisible() const;
+ void setMesh(Mesh mesh);
+ Mesh mesh() const;
+
+ void setMeshSmooth(bool enable);
+ bool isMeshSmooth() const;
+
+ void setUserDefinedMesh(const QString &fileName);
+ QString userDefinedMesh() const;
+
signals:
void itemLabelFormatChanged(QString format);
void visibilityChanged(bool visible);
+ void meshChanged(Mesh mesh);
+ void meshSmoothChanged(bool enabled);
+ void userDefinedMeshChanged(QString fileName);
protected:
QScopedPointer<QAbstract3DSeriesPrivate> d_ptr;
@@ -80,6 +110,7 @@ private:
friend class Surface3DController;
friend class Scatter3DController;
friend class QBar3DSeries;
+ friend class SeriesRenderCache;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/data/qabstract3dseries_p.h b/src/datavisualization/data/qabstract3dseries_p.h
index a5dbe867..d37df562 100644
--- a/src/datavisualization/data/qabstract3dseries_p.h
+++ b/src/datavisualization/data/qabstract3dseries_p.h
@@ -38,6 +38,21 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
class QAbstractDataProxy;
class Abstract3DController;
+struct QAbstract3DSeriesChangeBitField {
+ bool itemLabelFormatChanged : 1;
+ bool meshChanged : 1;
+ bool meshSmoothChanged : 1;
+ bool userDefinedMeshChanged : 1;
+
+ QAbstract3DSeriesChangeBitField()
+ : itemLabelFormatChanged(true),
+ meshChanged(true),
+ meshSmoothChanged(true),
+ userDefinedMeshChanged(true)
+ {
+ }
+};
+
class QAbstract3DSeriesPrivate : public QObject
{
Q_OBJECT
@@ -45,30 +60,27 @@ public:
QAbstract3DSeriesPrivate(QAbstract3DSeries *q, QAbstract3DSeries::SeriesType type);
virtual ~QAbstract3DSeriesPrivate();
- void setItemLabelFormat(const QString &format);
-
QAbstractDataProxy *dataProxy() const;
virtual void setDataProxy(QAbstractDataProxy *proxy);
virtual void setController(Abstract3DController *controller);
virtual void connectControllerAndProxy(Abstract3DController *newController) = 0;
-protected:
+ void setItemLabelFormat(const QString &format);
+ void setVisible(bool visible);
+ void setMesh(QAbstract3DSeries::Mesh mesh);
+ void setMeshSmooth(bool enable);
+ void setUserDefinedMesh(const QString &meshFile);
+
+ QAbstract3DSeriesChangeBitField m_changeTracker;
QAbstract3DSeries *q_ptr;
QAbstract3DSeries::SeriesType m_type;
QString m_itemLabelFormat;
QAbstractDataProxy *m_dataProxy;
bool m_visible;
Abstract3DController *m_controller;
-
-private:
- friend class QAbstract3DSeries;
- friend class Abstract3DController;
- friend class Bars3DController;
- friend class Surface3DController;
- friend class Scatter3DController;
- friend class QBar3DSeries;
- friend class QScatter3DSeries;
- friend class QSurface3DSeries;
+ QAbstract3DSeries::Mesh m_mesh;
+ bool m_meshSmooth;
+ QString m_userDefinedMesh;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp
index 301f36f1..18e8b2ed 100644
--- a/src/datavisualization/data/qbar3dseries.cpp
+++ b/src/datavisualization/data/qbar3dseries.cpp
@@ -213,6 +213,7 @@ QBar3DSeriesPrivate::QBar3DSeriesPrivate(QBar3DSeries *q)
m_selectedBar(Bars3DController::invalidSelectionPosition())
{
m_itemLabelFormat = QStringLiteral("@valueTitle: @valueLabel");
+ m_mesh = QAbstract3DSeries::MeshBevelBar;
}
QBar3DSeriesPrivate::~QBar3DSeriesPrivate()
@@ -261,8 +262,6 @@ void QBar3DSeriesPrivate::connectControllerAndProxy(Abstract3DController *newCon
&Bars3DController::handleDataRowLabelsChanged);
QObject::connect(barDataProxy, &QBarDataProxy::columnLabelsChanged, controller,
&Bars3DController::handleDataColumnLabelsChanged);
- QObject::connect(q_ptr, &QAbstract3DSeries::visibilityChanged, controller,
- &Abstract3DController::handleSeriesVisibilityChanged);
}
}
diff --git a/src/datavisualization/data/qscatter3dseries.cpp b/src/datavisualization/data/qscatter3dseries.cpp
index 4d9eb01a..25e32ffe 100644
--- a/src/datavisualization/data/qscatter3dseries.cpp
+++ b/src/datavisualization/data/qscatter3dseries.cpp
@@ -207,6 +207,7 @@ QScatter3DSeriesPrivate::QScatter3DSeriesPrivate(QScatter3DSeries *q)
m_selectedItem(Scatter3DController::invalidSelectionIndex())
{
m_itemLabelFormat = QStringLiteral("@valueTitle: @valueLabel");
+ m_mesh = QAbstract3DSeries::MeshSphere;
}
QScatter3DSeriesPrivate::~QScatter3DSeriesPrivate()
@@ -249,9 +250,6 @@ void QScatter3DSeriesPrivate::connectControllerAndProxy(Abstract3DController *ne
controller, &Scatter3DController::handleItemsRemoved);
QObject::connect(scatterDataProxy, &QScatterDataProxy::itemsInserted,
controller, &Scatter3DController::handleItemsInserted);
-
- QObject::connect(q_ptr, &QAbstract3DSeries::visibilityChanged, controller,
- &Abstract3DController::handleSeriesVisibilityChanged);
}
}
diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp
index 2e850b03..baae3a78 100644
--- a/src/datavisualization/data/qsurface3dseries.cpp
+++ b/src/datavisualization/data/qsurface3dseries.cpp
@@ -33,6 +33,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* If no data proxy is set explicitly for the series, the series creates a default
* proxy. Setting another proxy will destroy the existing proxy and all data added to it.
*
+ * The object mesh set via QAbstract3DSeries::mesh property defines the selection
+ * pointer shape in surface series.
+ *
* QSurface3DSeries supports the following format tags for QAbstract3DSeries::setItemLabelFormat():
* \table
* \row
@@ -207,6 +210,7 @@ QSurface3DSeriesPrivate::QSurface3DSeriesPrivate(QSurface3DSeries *q)
m_selectedPoint(Surface3DController::invalidSelectionPosition())
{
m_itemLabelFormat = QStringLiteral("(@xLabel, @yLabel, @zLabel)");
+ m_mesh = QAbstract3DSeries::MeshSphere;
}
QSurface3DSeriesPrivate::~QSurface3DSeriesPrivate()
@@ -244,9 +248,6 @@ void QSurface3DSeriesPrivate::connectControllerAndProxy(Abstract3DController *ne
&Surface3DController::handleArrayReset);
QObject::connect(surfaceDataProxy, &QSurfaceDataProxy::rowsChanged, controller,
&Surface3DController::handleRowsChanged);
-
- QObject::connect(q_ptr, &QAbstract3DSeries::visibilityChanged, controller,
- &Abstract3DController::handleSeriesVisibilityChanged);
}
}