summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/engine')
-rw-r--r--src/datavisualization/engine/q3dscene.h1
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp37
-rw-r--r--src/datavisualization/engine/q3dsurface.h10
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp80
-rw-r--r--src/datavisualization/engine/surface3dcontroller_p.h16
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp41
-rw-r--r--src/datavisualization/engine/surface3drenderer_p.h7
7 files changed, 58 insertions, 134 deletions
diff --git a/src/datavisualization/engine/q3dscene.h b/src/datavisualization/engine/q3dscene.h
index 14854361..8033b595 100644
--- a/src/datavisualization/engine/q3dscene.h
+++ b/src/datavisualization/engine/q3dscene.h
@@ -82,6 +82,7 @@ public:
float fixedRotation = 0.0f,
float distanceModifier = 0.0f);
private:
+ // TODO: Move to private
void emitNeedRender();
signals:
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp
index b678ba16..9a0fcd03 100644
--- a/src/datavisualization/engine/q3dsurface.cpp
+++ b/src/datavisualization/engine/q3dsurface.cpp
@@ -105,10 +105,6 @@ Q3DSurface::Q3DSurface()
&Q3DSurface::themeChanged);
QObject::connect(d_ptr->m_shared, &Abstract3DController::shadowQualityChanged, this,
&Q3DSurface::shadowQualityChanged);
- QObject::connect(d_ptr->m_shared, &Surface3DController::smoothSurfaceEnabledChanged, this,
- &Q3DSurface::smoothSurfaceEnabledChanged);
- QObject::connect(d_ptr->m_shared, &Surface3DController::surfaceGridEnabledChanged, this,
- &Q3DSurface::surfaceGridEnabledChanged);
QObject::connect(d_ptr->m_shared, &Abstract3DController::needRender, this,
&Q3DWindow::renderLater);
}
@@ -244,24 +240,6 @@ QDataVis::ShadowQuality Q3DSurface::shadowQuality() const
}
/*!
- * \property Q3DSurface::smoothSurfaceEnabled
- *
- * Sets surface smoothing to \a enabled. It is preset to \c false by default.
- * When enabled the normals on the surface are interpolated making edges looking round. If turned
- * off the normals are kept same on a triangle making the color of the triangle solid. This makes
- * the data more readable from the model.
- */
-void Q3DSurface::setSmoothSurfaceEnabled(bool enabled)
-{
- d_ptr->m_shared->setSmoothSurface(enabled);
-}
-
-bool Q3DSurface::isSmoothSurfaceEnabled() const
-{
- return d_ptr->m_shared->smoothSurface();
-}
-
-/*!
* \property Q3DSurface::selectionMode
*
* Sets point selection \a mode to one of \c QDataVis::SelectionMode. Surface supports
@@ -279,21 +257,6 @@ QDataVis::SelectionFlags Q3DSurface::selectionMode() const
}
/*!
- * \property Q3DSurface::surfaceGridEnabled
- *
- * Sets surface grid to \a enabled. It is preset to \c true by default.
- */
-void Q3DSurface::setSurfaceGridEnabled(bool enabled)
-{
- d_ptr->m_shared->setSurfaceGrid(enabled);
-}
-
-bool Q3DSurface::isSurfaceGridEnabled() const
-{
- return d_ptr->m_shared->surfaceGrid();
-}
-
-/*!
* \property Q3DSurface::gradient
*
* The current surface gradient. Setting this property replaces the previous gradient with
diff --git a/src/datavisualization/engine/q3dsurface.h b/src/datavisualization/engine/q3dsurface.h
index 2a4a56dd..bbe2d47a 100644
--- a/src/datavisualization/engine/q3dsurface.h
+++ b/src/datavisualization/engine/q3dsurface.h
@@ -38,8 +38,6 @@ class QT_DATAVISUALIZATION_EXPORT Q3DSurface : public Q3DWindow
Q_PROPERTY(QtDataVisualization::QDataVis::SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged)
Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(QtDataVisualization::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality NOTIFY shadowQualityChanged)
- Q_PROPERTY(bool smoothSurfaceEnabled READ isSmoothSurfaceEnabled WRITE setSmoothSurfaceEnabled NOTIFY smoothSurfaceEnabledChanged)
- Q_PROPERTY(bool surfaceGridEnabled READ isSurfaceGridEnabled WRITE setSurfaceGridEnabled NOTIFY surfaceGridEnabledChanged)
Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient)
Q_PROPERTY(Q3DScene* scene READ scene)
@@ -57,14 +55,8 @@ public:
void setShadowQuality(QDataVis::ShadowQuality quality);
QDataVis::ShadowQuality shadowQuality() const;
- void setSmoothSurfaceEnabled(bool enabled);
- bool isSmoothSurfaceEnabled() const;
-
void setSelectionMode(QDataVis::SelectionFlags mode);
QDataVis::SelectionFlags selectionMode() const;
- void setSurfaceGridEnabled(bool enabled);
- bool isSurfaceGridEnabled() const;
-
void setGradient(const QLinearGradient &gradient);
QLinearGradient gradient() const;
@@ -87,8 +79,6 @@ signals:
void selectionModeChanged(QDataVis::SelectionFlags mode);
void themeChanged(Q3DTheme *theme);
void shadowQualityChanged(QDataVis::ShadowQuality quality);
- void smoothSurfaceEnabledChanged(bool enabled);
- void surfaceGridEnabledChanged(bool visible);
protected:
void mouseDoubleClickEvent(QMouseEvent *event);
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index 5b603a62..b1586a78 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -24,6 +24,7 @@
#include "q3dcategoryaxis.h"
#include "qsurfacedataproxy_p.h"
#include "qsurface3dseries_p.h"
+#include "shaderhelper_p.h"
#include <QMatrix4x4>
@@ -34,13 +35,11 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
Surface3DController::Surface3DController(QRect rect)
: Abstract3DController(rect),
m_renderer(0),
- m_isSmoothSurfaceEnabled(false),
- m_isSurfaceEnabled(true),
- m_isSurfaceGridEnabled(true),
m_selectedPoint(invalidSelectionPosition()),
m_selectedSeries(0),
m_rowsChangeStartId(0),
- m_rowsChangeCount(0)
+ m_rowsChangeCount(0),
+ m_flatShadingSupported(true)
{
// Setting a null axis creates a new default axis according to orientation and graph type.
// Note: these cannot be set in the Abstract3DController constructor, as they will call virtual
@@ -68,8 +67,6 @@ void Surface3DController::initializeOpenGL()
synchDataToRenderer();
QObject::connect(m_renderer, &Surface3DRenderer::pointClicked, this,
&Surface3DController::handlePointClicked, Qt::QueuedConnection);
- QObject::connect(m_renderer, &Surface3DRenderer::requestSmoothSurface, this,
- &Surface3DController::handleRequestSmoothSurface, Qt::QueuedConnection);
emitNeedRender();
}
@@ -78,11 +75,6 @@ void Surface3DController::synchDataToRenderer()
if (!isInitialized())
return;
- if (m_changeTracker.surfaceGridChanged) {
- m_renderer->updateSurfaceGridStatus(m_isSurfaceGridEnabled);
- m_changeTracker.surfaceGridChanged = false;
- }
-
Abstract3DController::synchDataToRenderer();
// Notify changes to renderer
@@ -91,14 +83,6 @@ void Surface3DController::synchDataToRenderer()
m_changeTracker.gradientColorChanged = false;
}
- if (m_changeTracker.smoothStatusChanged) {
- bool oldSmoothStatus = m_isSmoothSurfaceEnabled;
- m_isSmoothSurfaceEnabled = m_renderer->updateSmoothStatus(m_isSmoothSurfaceEnabled);
- m_changeTracker.smoothStatusChanged = false;
- if (oldSmoothStatus != m_isSmoothSurfaceEnabled)
- emit smoothSurfaceEnabledChanged(m_isSmoothSurfaceEnabled);
- }
-
if (m_changeTracker.rowsChanged) {
m_renderer->updateRows(m_rowsChangeStartId, m_rowsChangeCount);
m_changeTracker.rowsChanged = false;
@@ -108,7 +92,6 @@ void Surface3DController::synchDataToRenderer()
m_renderer->updateSelectedPoint(m_selectedPoint, m_selectedSeries);
m_changeTracker.selectedPointChanged = false;
}
-
}
void Surface3DController::handleAxisAutoAdjustRangeChangedInOrientation(Q3DAbstractAxis::AxisOrientation orientation, bool autoAdjust)
@@ -142,6 +125,11 @@ QPoint Surface3DController::invalidSelectionPosition()
return invalidSelectionPoint;
}
+bool Surface3DController::isFlatShadingSupported()
+{
+ return m_flatShadingSupported;
+}
+
void Surface3DController::addSeries(QAbstract3DSeries *series)
{
Q_ASSERT(series && series->type() == QAbstract3DSeries::SeriesTypeSurface);
@@ -154,7 +142,7 @@ void Surface3DController::addSeries(QAbstract3DSeries *series)
qWarning("Surface graph only supports a single series.");
}
- QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(series);
+ QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(series);
if (surfaceSeries->selectedPoint() != invalidSelectionPosition())
setSelectedPoint(surfaceSeries->selectedPoint(), surfaceSeries);
}
@@ -184,37 +172,6 @@ QList<QSurface3DSeries *> Surface3DController::surfaceSeriesList()
return surfaceSeriesList;
}
-void Surface3DController::setSmoothSurface(bool enable)
-{
- if (enable != m_isSmoothSurfaceEnabled) {
- m_isSmoothSurfaceEnabled = enable;
- m_changeTracker.smoothStatusChanged = true;
- emit smoothSurfaceEnabledChanged(enable);
- emitNeedRender();
- }
-}
-
-bool Surface3DController::smoothSurface()
-{
- return m_isSmoothSurfaceEnabled;
-}
-
-void Surface3DController::setSurfaceGrid(bool enable)
-{
- if (enable != m_isSurfaceGridEnabled) {
- m_isSurfaceGridEnabled = enable;
- m_changeTracker.surfaceGridChanged = true;
- emit surfaceGridEnabledChanged(enable);
- emitNeedRender();
- m_isDataDirty = true;
- }
-}
-
-bool Surface3DController::surfaceGrid()
-{
- return m_isSurfaceGridEnabled;
-}
-
void Surface3DController::setGradient(const QLinearGradient &gradient)
{
if (gradient != m_userDefinedGradient) {
@@ -347,6 +304,19 @@ void Surface3DController::handlePointClicked(const QPoint &position, QSurface3DS
// TODO: Also hover needed? (QTRD-2131)
}
+void Surface3DController::handleFlatShadingSupportedChange(bool supported)
+{
+ // Handle renderer flat surface support indicator signal. This happens exactly once per renderer.
+ if (m_flatShadingSupported != supported) {
+ m_flatShadingSupported = supported;
+ // Emit the change for all added surfaces
+ foreach (QAbstract3DSeries *series, m_seriesList) {
+ QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(series);
+ emit surfaceSeries->flatShadingSupportedChanged(m_flatShadingSupported);
+ }
+ }
+}
+
void Surface3DController::handleRowsChanged(int startIndex, int count)
{
QSurfaceDataProxy *sender = static_cast<QSurfaceDataProxy *>(QObject::sender());
@@ -363,12 +333,6 @@ void Surface3DController::handleRowsChanged(int startIndex, int count)
}
}
-void Surface3DController::handleRequestSmoothSurface(bool enable)
-{
- setSmoothSurface(enable);
- emitNeedRender();
-}
-
void Surface3DController::adjustValueAxisRange()
{
if (m_seriesList.size()) {
diff --git a/src/datavisualization/engine/surface3dcontroller_p.h b/src/datavisualization/engine/surface3dcontroller_p.h
index ffc3b4f3..ef9c8494 100644
--- a/src/datavisualization/engine/surface3dcontroller_p.h
+++ b/src/datavisualization/engine/surface3dcontroller_p.h
@@ -63,15 +63,13 @@ class QT_DATAVISUALIZATION_EXPORT Surface3DController : public Abstract3DControl
private:
Surface3DChangeBitField m_changeTracker;
Surface3DRenderer *m_renderer;
- bool m_isSmoothSurfaceEnabled;
- bool m_isSurfaceEnabled;
- bool m_isSurfaceGridEnabled;
QLinearGradient m_userDefinedGradient;
QPoint m_selectedPoint;
QSurface3DSeries *m_selectedSeries; // Points to the series for which the point is selected in
// single series selection cases.
int m_rowsChangeStartId;
int m_rowsChangeCount;
+ bool m_flatShadingSupported;
public:
explicit Surface3DController(QRect rect);
@@ -80,12 +78,6 @@ public:
void initializeOpenGL();
virtual void synchDataToRenderer();
- void setSmoothSurface(bool enable);
- bool smoothSurface();
-
- void setSurfaceGrid(bool enable);
- bool surfaceGrid();
-
void setGradient(const QLinearGradient &gradient);
QLinearGradient gradient() const;
@@ -99,6 +91,7 @@ public:
virtual void handleSeriesVisibilityChangedBySender(QObject *sender);
static QPoint invalidSelectionPosition();
+ bool isFlatShadingSupported();
virtual void addSeries(QAbstract3DSeries *series);
virtual void removeSeries(QAbstract3DSeries *series);
@@ -110,11 +103,8 @@ public slots:
// Renderer callback handlers
void handlePointClicked(const QPoint &position, QSurface3DSeries *series);
- void handleRequestSmoothSurface(bool enable);
-signals:
- void smoothSurfaceEnabledChanged(bool enable);
- void surfaceGridEnabledChanged(bool enable);
+ void handleFlatShadingSupportedChange(bool supported);
private:
void adjustValueAxisRange();
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 5b9aa9d8..bb74e084 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -99,7 +99,7 @@ Surface3DRenderer::Surface3DRenderer(Surface3DController *controller)
m_selectionTexture(0),
m_selectionResultTexture(0),
m_shadowQualityToShader(33.3f),
- m_cachedSmoothSurface(true),
+ m_cachedFlatShading(false),
m_flatSupported(true),
m_cachedSurfaceVisible(true),
m_cachedSurfaceGridOn(true),
@@ -120,7 +120,9 @@ Surface3DRenderer::Surface3DRenderer(Surface3DController *controller)
QStringLiteral(":/shaders/fragmentSurfaceFlat"));
if (!tester.testCompile()) {
m_flatSupported = false;
- emit requestSmoothSurface(true);
+ connect(this, &Surface3DRenderer::flatShadingSupportedChanged,
+ controller, &Surface3DController::handleFlatShadingSupportedChange);
+ emit flatShadingSupportedChanged(m_flatSupported);
qWarning() << "Warning: Flat qualifier not supported on your platform's GLSL language."
" Requires at least GLSL version 1.2 with GL_EXT_gpu_shader4 extension.";
}
@@ -244,7 +246,7 @@ void Surface3DRenderer::updateData()
loadSurfaceObj();
// Note: Data setup can change sample space (as min width/height is 1)
- if (m_cachedSmoothSurface) {
+ if (!m_cachedFlatShading) {
m_surfaceObj->setUpSmoothData(m_dataArray, m_sampleSpace, m_heightNormalizer,
m_axisCacheY.min(), dimensionChanged);
} else {
@@ -270,6 +272,19 @@ void Surface3DRenderer::updateData()
updateSelectedPoint(m_selectedPoint, m_selectedSeries);
}
+void Surface3DRenderer::updateSeries(const QList<QAbstract3DSeries *> &seriesList, bool updateVisibility)
+{
+ Abstract3DRenderer::updateSeries(seriesList, updateVisibility);
+
+ // TODO: move to render cache when multiseries support implemented QTRD-2657
+ // TODO: until then just update them always.
+ if (m_visibleSeriesList.size()) {
+ QSurface3DSeries *series = static_cast<QSurface3DSeries *>(m_visibleSeriesList.at(0).series());
+ updateFlatStatus(series->isFlatShadingEnabled());
+ updateSurfaceGridStatus(series->isSurfaceGridEnabled());
+ }
+}
+
void Surface3DRenderer::updateRows(int startIndex, int count)
{
// TODO: Properly support non-straight rows and columns (QTRD-2643)
@@ -300,7 +315,7 @@ void Surface3DRenderer::updateRows(int startIndex, int count)
(*(m_dataArray.at(i)))[j] = array->at(i + m_sampleSpace.y())->at(j + m_sampleSpace.x());
}
- if (m_cachedSmoothSurface) {
+ if (!m_cachedFlatShading) {
m_surfaceObj->updateSmoothRows(m_dataArray, startIndex, endRow, m_heightNormalizer,
m_axisCacheY.min());
} else {
@@ -355,7 +370,7 @@ void Surface3DRenderer::updateSliceDataModel(const QPoint &point)
if (!m_sliceSurfaceObj)
loadSliceSurfaceObj();
- if (m_cachedSmoothSurface) {
+ if (!m_cachedFlatShading) {
m_sliceSurfaceObj->setUpSmoothData(m_sliceDataArray, sliceRect, m_heightNormalizer,
m_axisCacheY.min(), true);
} else {
@@ -1781,24 +1796,24 @@ void Surface3DRenderer::calculateSceneScalingFactors()
#endif
}
-bool Surface3DRenderer::updateSmoothStatus(bool enable)
+bool Surface3DRenderer::updateFlatStatus(bool enable)
{
- if (!enable && !m_flatSupported) {
+ if (enable && !m_flatSupported) {
qWarning() << "Warning: Flat qualifier not supported on your platform's GLSL language."
" Requires at least GLSL version 1.2 with GL_EXT_gpu_shader4 extension.";
- enable = true;
+ enable = false;
}
bool changed = false;
- if (enable != m_cachedSmoothSurface) {
- m_cachedSmoothSurface = enable;
+ if (enable != m_cachedFlatShading) {
+ m_cachedFlatShading = enable;
changed = true;
initSurfaceShaders();
}
// If no surface object created yet, don't try to update the object
if (m_surfaceObj && changed && m_sampleSpace.width() >= 2 && m_sampleSpace.height() >= 2) {
- if (m_cachedSmoothSurface) {
+ if (!m_cachedFlatShading) {
m_surfaceObj->setUpSmoothData(m_dataArray, m_sampleSpace, m_heightNormalizer,
m_axisCacheY.min(), true);
} else {
@@ -1807,7 +1822,7 @@ bool Surface3DRenderer::updateSmoothStatus(bool enable)
}
}
- return m_cachedSmoothSurface;
+ return m_cachedFlatShading;
}
void Surface3DRenderer::updateSelectedPoint(const QPoint &position, const QSurface3DSeries *series)
@@ -2050,7 +2065,7 @@ void Surface3DRenderer::initShaders(const QString &vertexShader, const QString &
if (m_surfaceShader)
delete m_surfaceShader;
#if !defined(QT_OPENGL_ES_2)
- if (m_cachedSmoothSurface) {
+ if (!m_cachedFlatShading) {
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
m_surfaceShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertexShadow"),
QStringLiteral(":/shaders/fragmentSurfaceShadowNoTex"));
diff --git a/src/datavisualization/engine/surface3drenderer_p.h b/src/datavisualization/engine/surface3drenderer_p.h
index ce49cf13..476ef78e 100644
--- a/src/datavisualization/engine/surface3drenderer_p.h
+++ b/src/datavisualization/engine/surface3drenderer_p.h
@@ -109,7 +109,7 @@ private:
GLuint m_selectionTexture;
GLuint m_selectionResultTexture;
GLfloat m_shadowQualityToShader;
- bool m_cachedSmoothSurface;
+ bool m_cachedFlatShading;
bool m_flatSupported;
bool m_cachedSurfaceVisible;
bool m_cachedSurfaceGridOn;
@@ -134,9 +134,10 @@ public:
~Surface3DRenderer();
void updateData();
+ void updateSeries(const QList<QAbstract3DSeries *> &seriesList, bool updateVisibility);
void updateRows(int startIndex, int count);
void updateScene(Q3DScene *scene);
- bool updateSmoothStatus(bool enable);
+ bool updateFlatStatus(bool enable);
void updateSurfaceGridStatus(bool enable);
void updateSurfaceGradient(const QLinearGradient &gradient);
void updateSlicingActive(bool isSlicing);
@@ -150,7 +151,7 @@ protected:
signals:
void pointClicked(QPoint position, QSurface3DSeries *series);
- void requestSmoothSurface(bool enable);
+ void flatShadingSupportedChanged(bool supported);
private:
void setViewPorts();