summaryrefslogtreecommitdiffstats
path: root/src/datavis3d/engine
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-06-12 12:55:47 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-06-12 13:15:01 +0300
commit317f3f15fed855cfaa31a9b558bf1279583832e6 (patch)
tree458e2731abb52e97af9c18af3299d8135c3dbee7 /src/datavis3d/engine
parent05ac561f2a501cfc720b6b2b3cd199cff9c156b8 (diff)
Documentation added
Draft. Still a lot missing. Change-Id: I7b3ebc15bf4bf6dbcf5aa014acac1d500ead8448 Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Diffstat (limited to 'src/datavis3d/engine')
-rw-r--r--src/datavis3d/engine/bars3dshared.cpp314
-rw-r--r--src/datavis3d/engine/bars3dshared_p.h2
-rw-r--r--src/datavis3d/engine/drawer.cpp8
-rw-r--r--src/datavis3d/engine/drawer_p.h2
-rw-r--r--src/datavis3d/engine/q3dbars.cpp431
-rw-r--r--src/datavis3d/engine/q3dbars.h14
-rw-r--r--src/datavis3d/engine/q3dmaps.cpp65
-rw-r--r--src/datavis3d/engine/q3dmaps.h7
-rw-r--r--src/datavis3d/engine/q3dwindow.cpp44
-rw-r--r--src/datavis3d/engine/q3dwindow.h13
-rw-r--r--src/datavis3d/engine/qdataitem.cpp59
-rw-r--r--src/datavis3d/engine/qdataitem.h3
-rw-r--r--src/datavis3d/engine/qdatarow.cpp34
-rw-r--r--src/datavis3d/engine/qdatarow.h1
-rw-r--r--src/datavis3d/engine/qdataset.cpp40
-rw-r--r--src/datavis3d/engine/qdataset.h1
-rw-r--r--src/datavis3d/engine/theme_p.h1
17 files changed, 843 insertions, 196 deletions
diff --git a/src/datavis3d/engine/bars3dshared.cpp b/src/datavis3d/engine/bars3dshared.cpp
index 95af0056..55efb7cc 100644
--- a/src/datavis3d/engine/bars3dshared.cpp
+++ b/src/datavis3d/engine/bars3dshared.cpp
@@ -215,48 +215,53 @@ void Bars3dShared::initializeOpenGL()
if (m_isInitialized)
return;
+ initializeOpenGLFunctions();
+
m_textureHelper = new TextureHelper();
m_drawer->initializeOpenGL();
+ // Resize in case we've missed resize events
+ resizeNotify();
+
// Initialize shaders
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
// Init the depth buffer (for shadows)
initDepthBuffer();
} else {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnY"));
+ QStringLiteral(":/shaders/fragmentColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
#else
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
} else {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
#endif
initLabelShaders(QStringLiteral(":/shaders/vertexLabel"),
- QStringLiteral(":/shaders/fragmentLabel"));
+ QStringLiteral(":/shaders/fragmentLabel"));
#if !defined(QT_OPENGL_ES_2)
// Init depth shader (for shadows). Init in any case, easier to handle shadow activation if done via api.
@@ -419,12 +424,12 @@ void Bars3dShared::drawZoomScene()
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
m_barShader->setUniformValue(m_barShader->color(), barColor);
m_barShader->setUniformValue(m_barShader->lightS(), lightStrength);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_theme->m_ambientStrength);
+ m_theme->m_ambientStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_barObj);
@@ -453,42 +458,42 @@ void Bars3dShared::drawZoomScene()
LabelItem zoomSelectionLabel = m_zoomSelection->d_ptr->labelItem();
if (ModeZoomRow == m_selectionMode) {
m_drawer->drawLabel(*dummyItem, zoomSelectionLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelTop);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelTop);
m_drawer->drawLabel(*dummyItem, z, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelBottom);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelBottom);
} else {
m_drawer->drawLabel(*dummyItem, x, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelBottom);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelBottom);
m_drawer->drawLabel(*dummyItem, zoomSelectionLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelTop);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelTop);
}
m_drawer->drawLabel(*dummyItem, y, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 90.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelLeft);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 90.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelLeft);
// Draw labels for bars
for (int col = 0; col < m_zoomSelection->d_ptr->row().size(); col++) {
QDataItem *item = m_zoomSelection->d_ptr->getItem(col);
// Draw values
m_drawer->drawLabel(*item, item->d_ptr->label(), viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj);
// Draw labels
LabelItem labelItem;
if (ModeZoomRow == m_selectionMode) {
@@ -513,10 +518,10 @@ void Bars3dShared::drawZoomScene()
}
}
m_drawer->drawLabel(*item, labelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, -45.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, false, false, LabelBelow);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, -45.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, false, false, LabelBelow);
}
glDisable(GL_TEXTURE_2D);
@@ -722,7 +727,7 @@ void Bars3dShared::drawScene()
QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
m_drawer->drawObject(m_labelShader, m_labelObj,
- m_depthTexture);
+ m_depthTexture);
glDisable(GL_TEXTURE_2D);
m_labelShader->release();
#endif
@@ -779,20 +784,20 @@ void Bars3dShared::drawScene()
// TODO: Save position to qdataitem, so that we don't need to calculate it each time?
-//#if !defined(QT_OPENGL_ES_2)
-// QVector3D barColor = QVector3D((GLdouble)row / 32767.0,
-// (GLdouble)bar / 32767.0,
-// 0.0);
-//#else
+ //#if !defined(QT_OPENGL_ES_2)
+ // QVector3D barColor = QVector3D((GLdouble)row / 32767.0,
+ // (GLdouble)bar / 32767.0,
+ // 0.0);
+ //#else
QVector3D barColor = QVector3D((GLdouble)row / 255.0,
(GLdouble)bar / 255.0,
0.0);
-//#endif
+ //#endif
m_selectionShader->setUniformValue(m_selectionShader->MVP(),
- MVPMatrix);
+ MVPMatrix);
m_selectionShader->setUniformValue(m_selectionShader->color(),
- barColor);
+ barColor);
#ifdef USE_HAX0R_SELECTION
// 1st attribute buffer : vertices
@@ -862,7 +867,7 @@ void Bars3dShared::drawScene()
QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
m_drawer->drawObject(m_labelShader, m_labelObj,
- m_selectionTexture);
+ m_selectionTexture);
glDisable(GL_TEXTURE_2D);
m_labelShader->release();
#endif
@@ -931,7 +936,7 @@ void Bars3dShared::drawScene()
GLfloat lightStrength = m_theme->m_lightStrength;
if (m_selectionMode > ModeNone) {
Bars3dShared::SelectionType selectionType = isSelected(row, bar,
- selection);
+ selection);
switch (selectionType) {
case Bars3dShared::SelectionBar: {
barColor = Utils::vectorFromColor(m_theme->m_highlightBarColor);
@@ -1002,31 +1007,31 @@ void Bars3dShared::drawScene()
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.transposed().inverted());
+ itModelMatrix.transposed().inverted());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
m_barShader->setUniformValue(m_barShader->color(), barColor);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_theme->m_ambientStrength);
+ m_theme->m_ambientStrength);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_barShader->setUniformValue(m_barShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_barShader->setUniformValue(m_barShader->lightS(),
- lightStrength / 10.0f);
+ lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_barShader, m_barObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_barShader->setUniformValue(m_barShader->lightS(),
- lightStrength);
+ lightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_barObj);
@@ -1073,39 +1078,39 @@ void Bars3dShared::drawScene()
// Set shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightP(),
- lightPos);
+ lightPos);
m_backgroundShader->setUniformValue(m_backgroundShader->view(),
- viewMatrix);
+ viewMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->model(),
- modelMatrix);
+ modelMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_backgroundShader->setUniformValue(m_backgroundShader->MVP(),
- MVPMatrix);
+ MVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->color(),
- backgroundColor);
+ backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
- m_theme->m_ambientStrength * 2.0f);
+ m_theme->m_ambientStrength * 2.0f);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_backgroundShader->setUniformValue(m_backgroundShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_theme->m_lightStrength / 10.0f);
+ m_theme->m_lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_theme->m_lightStrength);
+ m_theme->m_lightStrength);
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj);
@@ -1135,7 +1140,7 @@ void Bars3dShared::drawScene()
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->color(), barColor);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_theme->m_ambientStrength);
+ m_theme->m_ambientStrength);
// Floor lines: rows
for (GLfloat row = 0.0f; row <= m_sampleCount.second; row++) {
@@ -1161,28 +1166,28 @@ void Bars3dShared::drawScene()
// Set the rest of the shader bindings
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_barShader->setUniformValue(m_barShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength / 10.0f);
+ m_theme->m_lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength);
+ m_theme->m_lightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj);
@@ -1214,28 +1219,28 @@ void Bars3dShared::drawScene()
// Set the rest of the shader bindings
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_barShader->setUniformValue(m_barShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength / 10.0f);
+ m_theme->m_lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength);
+ m_theme->m_lightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj);
@@ -1283,28 +1288,28 @@ void Bars3dShared::drawScene()
// Set the rest of the shader bindings
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_barShader->setUniformValue(m_barShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength / 10.0f);
+ m_theme->m_lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength);
+ m_theme->m_lightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj);
@@ -1341,28 +1346,28 @@ void Bars3dShared::drawScene()
// Set the rest of the shader bindings
m_barShader->setUniformValue(m_barShader->model(), modelMatrix);
m_barShader->setUniformValue(m_barShader->nModel(),
- itModelMatrix.inverted().transposed());
+ itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
#if !defined(QT_OPENGL_ES_2)
if (m_shadowQuality > ShadowNone) {
// Set shadow shader bindings
m_barShader->setUniformValue(m_barShader->shadowQ(),
- m_shadowQualityToShader);
+ m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(),
- depthMVPMatrix);
+ depthMVPMatrix);
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength / 10.0f);
+ m_theme->m_lightStrength / 10.0f);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj,
- 0, m_depthTexture);
+ 0, m_depthTexture);
} else
#endif
{
// Set shadowless shader bindings
m_barShader->setUniformValue(m_barShader->lightS(),
- m_theme->m_lightStrength);
+ m_theme->m_lightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_gridLineObj);
@@ -1421,11 +1426,11 @@ void Bars3dShared::drawScene()
}
m_drawer->drawLabel(*m_selectedBar, m_selectedBar->label(),
- viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, true);
+ viewMatrix, projectionMatrix,
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, true);
#else
static bool firstSelection = true;
// Draw the value string followed by row label and column label
@@ -1452,10 +1457,10 @@ void Bars3dShared::drawScene()
}
m_drawer->drawLabel(*m_selectedBar, labelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
- m_selectionMode, m_labelShader,
- m_labelObj, true, false);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(0.0f, 0.0f, 0.0f), m_heightNormalizer,
+ m_selectionMode, m_labelShader,
+ m_labelObj, true, false);
#endif
glDisable(GL_TEXTURE_2D);
if (m_labelTransparency > TransparencyNone)
@@ -1520,11 +1525,11 @@ void Bars3dShared::drawScene()
//qDebug() << "labelPos, row" << row + 1 << ":" << labelPos << m_dataSet->d_ptr->rowLabels().at(row);
m_drawer->drawLabel(*label, label->d_ptr->label(), viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- m_heightNormalizer, m_selectionMode,
- m_labelShader, m_labelObj, true, true, LabelMid,
- alignment);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(rotLabelX, rotLabelY, rotLabelZ),
+ m_heightNormalizer, m_selectionMode,
+ m_labelShader, m_labelObj, true, true, LabelMid,
+ alignment);
delete label;
}
@@ -1569,11 +1574,11 @@ void Bars3dShared::drawScene()
//qDebug() << "labelPos, col" << bar + 1 << ":" << labelPos << m_dataSet->d_ptr->columnLabels().at(bar);
m_drawer->drawLabel(*label, label->d_ptr->label(), viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- m_heightNormalizer, m_selectionMode,
- m_labelShader, m_labelObj, true, true, LabelMid,
- alignment);
+ QVector3D(0.0f, m_yAdjustment, zComp),
+ QVector3D(rotLabelX, rotLabelY, rotLabelZ),
+ m_heightNormalizer, m_selectionMode,
+ m_labelShader, m_labelObj, true, true, LabelMid,
+ alignment);
delete label;
}
@@ -1694,6 +1699,7 @@ void Bars3dShared::wheelEvent(QWheelEvent *event)
void Bars3dShared::resizeNotify()
{
qDebug() << "Bars3dShared::resizeEvent " << width() << "x" <<height();
+
// Set view port
if (m_zoomActivated)
m_sceneViewPort = QRect(0, height() - height() / 5, width() / 5, height() / 5);
@@ -1771,7 +1777,7 @@ void Bars3dShared::setMeshFileName(const QString &objFileName)
}
void Bars3dShared::setupSampleSpace(int samplesRow, int samplesColumn, const QString &labelRow,
- const QString &labelColumn, const QString &labelHeight)
+ const QString &labelColumn, const QString &labelHeight)
{
// Disable zoom mode if we're in it (causes crash if not, as zoom selection is deleted)
closeZoomMode();
@@ -1815,32 +1821,33 @@ void Bars3dShared::setTheme(ColorTheme theme)
if (m_shadowQuality > ShadowNone) {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
}
} else {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnY"));
+ QStringLiteral(":/shaders/fragmentColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
}
#else
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
} else {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
}
#endif
}
-void Bars3dShared::setBarColor(QColor baseColor, QColor heightColor, QColor depthColor, bool uniform)
+void Bars3dShared::setBarColor(QColor baseColor, QColor heightColor, QColor depthColor,
+ bool uniform)
{
m_theme->m_baseColor = baseColor;
m_theme->m_heightColor = heightColor;
@@ -1851,27 +1858,27 @@ void Bars3dShared::setBarColor(QColor baseColor, QColor heightColor, QColor dept
if (m_shadowQuality > ShadowNone) {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
}
} else {
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnY"));
+ QStringLiteral(":/shaders/fragmentColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
}
#else
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
} else {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
}
#endif
}
@@ -1975,35 +1982,35 @@ void Bars3dShared::setShadowQuality(ShadowQuality quality)
// Re-init shaders
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
} else {
// Re-init shaders
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnY"));
+ QStringLiteral(":/shaders/fragmentColorOnY"));
} else {
initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragment"));
}
#else
if (!m_theme->m_uniformColor) {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
} else {
initShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
}
initBackgroundShaders(QStringLiteral(":/shaders/vertexES2"),
- QStringLiteral(":/shaders/fragmentES2"));
+ QStringLiteral(":/shaders/fragmentES2"));
#endif
}
}
@@ -2024,7 +2031,7 @@ void Bars3dShared::setTickCount(GLint tickCount, GLfloat step, GLfloat minimum)
}
void Bars3dShared::addDataRow(const QVector<float> &dataRow, const QString &labelRow,
- const QVector<QString> &labelsColumn)
+ const QVector<QString> &labelsColumn)
{
// Convert to QDataRow and add to QDataSet
QDataRow *row = new QDataRow(labelRow);
@@ -2034,12 +2041,12 @@ void Bars3dShared::addDataRow(const QVector<float> &dataRow, const QString &labe
m_dataSet->addRow(row);
handleLimitChange();
m_dataSet->setLabels(m_axisLabelX, m_axisLabelZ, m_axisLabelY,
- QVector<QString>(), labelsColumn);
+ QVector<QString>(), labelsColumn);
m_dataSet->d_ptr->verifySize(m_sampleCount.second);
}
void Bars3dShared::addDataRow(const QVector<QDataItem*> &dataRow, const QString &labelRow,
- const QVector<QString> &labelsColumn)
+ const QVector<QString> &labelsColumn)
{
// Convert to QDataRow and add to QDataSet
QDataRow *row = new QDataRow(labelRow);
@@ -2049,7 +2056,7 @@ void Bars3dShared::addDataRow(const QVector<QDataItem*> &dataRow, const QString
m_dataSet->addRow(row);
handleLimitChange();
m_dataSet->setLabels(m_axisLabelX, m_axisLabelZ, m_axisLabelY,
- QVector<QString>(), labelsColumn);
+ QVector<QString>(), labelsColumn);
m_dataSet->d_ptr->verifySize(m_sampleCount.second);
}
@@ -2066,8 +2073,9 @@ void Bars3dShared::addDataRow(QDataRow *dataRow)
handleLimitChange();
}
-void Bars3dShared::addDataSet(const QVector< QVector<float> > &data, const QVector<QString> &labelsRow,
- const QVector<QString> &labelsColumn)
+void Bars3dShared::addDataSet(const QVector< QVector<float> > &data,
+ const QVector<QString> &labelsRow,
+ const QVector<QString> &labelsColumn)
{
// Copy axis labels
QString xAxis;
@@ -2100,8 +2108,8 @@ void Bars3dShared::addDataSet(const QVector< QVector<float> > &data, const QVect
}
void Bars3dShared::addDataSet(const QVector< QVector<QDataItem*> > &data,
- const QVector<QString> &labelsRow,
- const QVector<QString> &labelsColumn)
+ const QVector<QString> &labelsRow,
+ const QVector<QString> &labelsColumn)
{
// Copy axis labels
QString xAxis;
@@ -2165,7 +2173,7 @@ void Bars3dShared::setBoundingRect(const QRect boundingRect)
void Bars3dShared::setWidth(const int width)
{
- m_boundingRect.setWidth( width );
+ m_boundingRect.setWidth(width);
}
int Bars3dShared::width()
@@ -2175,7 +2183,7 @@ int Bars3dShared::width()
void Bars3dShared::setHeight(const int height)
{
- m_boundingRect.setHeight( height );
+ m_boundingRect.setHeight(height);
}
int Bars3dShared::height()
@@ -2298,7 +2306,7 @@ void Bars3dShared::initDepthBuffer()
#endif
void Bars3dShared::initBackgroundShaders(const QString &vertexShader,
- const QString &fragmentShader)
+ const QString &fragmentShader)
{
if (m_backgroundShader)
delete m_backgroundShader;
@@ -2343,7 +2351,7 @@ void Bars3dShared::calculateHeightAdjustment(const QPair<GLfloat, GLfloat> &limi
}
Bars3dShared::SelectionType Bars3dShared::isSelected(GLint row, GLint bar,
- const QVector3D &selection)
+ const QVector3D &selection)
{
//static QVector3D prevSel = selection; // TODO: For debugging
SelectionType isSelectedType = SelectionNone;
@@ -2354,11 +2362,11 @@ Bars3dShared::SelectionType Bars3dShared::isSelected(GLint row, GLint bar,
#endif
return isSelectedType; // skip window
-//#if !defined(QT_OPENGL_ES_2)
-// QVector3D current = QVector3D((GLuint)row, (GLuint)bar, 0);
-//#else
+ //#if !defined(QT_OPENGL_ES_2)
+ // QVector3D current = QVector3D((GLuint)row, (GLuint)bar, 0);
+ //#else
QVector3D current = QVector3D((GLubyte)row, (GLubyte)bar, 0);
-//#endif
+ //#endif
// TODO: For debugging
//if (selection != prevSel) {
diff --git a/src/datavis3d/engine/bars3dshared_p.h b/src/datavis3d/engine/bars3dshared_p.h
index 703d3d89..2250b7c4 100644
--- a/src/datavis3d/engine/bars3dshared_p.h
+++ b/src/datavis3d/engine/bars3dshared_p.h
@@ -80,7 +80,7 @@ class Drawer;
class LabelItem;
class Bars3dSharedPrivate;
-class QTENTERPRISE_DATAVIS3D_EXPORT Bars3dShared : public QObject
+class QTENTERPRISE_DATAVIS3D_EXPORT Bars3dShared : public QObject, public QOpenGLFunctions
{
Q_OBJECT
diff --git a/src/datavis3d/engine/drawer.cpp b/src/datavis3d/engine/drawer.cpp
index 7db12c16..3c4d30cf 100644
--- a/src/datavis3d/engine/drawer.cpp
+++ b/src/datavis3d/engine/drawer.cpp
@@ -74,12 +74,14 @@ Drawer::Drawer(const Theme &theme, const QFont &font, LabelTransparency transpar
Drawer::~Drawer()
{
-
}
void Drawer::initializeOpenGL()
{
- m_textureHelper = new TextureHelper();
+ if (!m_textureHelper) {
+ initializeOpenGLFunctions();
+ m_textureHelper = new TextureHelper();
+ }
}
void Drawer::setTheme(const Theme &theme)
@@ -293,6 +295,8 @@ void Drawer::generateLabelTexture(QDataItem *item)
void Drawer::generateLabelItem(LabelItem *item, const QString &text)
{
+ initializeOpenGL();
+
// Delete previous texture, if there is one
GLuint labelTexture = item->textureId();
if (labelTexture)
diff --git a/src/datavis3d/engine/drawer_p.h b/src/datavis3d/engine/drawer_p.h
index 35338cc3..e31ab0cb 100644
--- a/src/datavis3d/engine/drawer_p.h
+++ b/src/datavis3d/engine/drawer_p.h
@@ -66,7 +66,7 @@ class ShaderHelper;
class ObjectHelper;
class TextureHelper;
-class Drawer : public QObject
+class Drawer : public QObject, public QOpenGLFunctions
{
Q_OBJECT
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp
index dfbfab84..39750b38 100644
--- a/src/datavis3d/engine/q3dbars.cpp
+++ b/src/datavis3d/engine/q3dbars.cpp
@@ -54,68 +54,278 @@
QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+/*!
+ * \class Q3DBars
+ * \inmodule QtDataVis3D
+ * \brief The Q3DBars class provides methods for rendering 3D bar graphs.
+ * \since 1.0.0
+ *
+ * This class enables developers to render bar graphs in 3D and to view them by rotating the scene
+ * freely. Rotation is done by holding down the right mouse button and moving the mouse. Zooming
+ * is done by mouse wheel. Selection, if enabled, is done by left mouse button. The scene can be
+ * reset to default camera view by clicking mouse wheel. In touch devices rotation is done
+ * by tap-and-move, selection by tap-and-hold and zoom by pinch.
+ *
+ * Methods are provided for changing bar types, themes, bar selection modes and so on. See the
+ * methods for more detailed descriptions.
+ *
+ * \section1 How to construct a minimal Q3DBars chart
+ *
+ * After constructing Q3DBars, you need to set up sample space using setupSampleSpace(). Let's
+ * set the sample space to 5 rows and 5 columns:
+ *
+ * \snippet doc_src_q3dbars_construction.cpp 0
+ *
+ * Now Q3DBars is ready to receive data to be rendered. Add one row of 5 floats into the data
+ * set:
+ *
+ * \snippet doc_src_q3dbars_construction.cpp 1
+ *
+ * \note We set the sample space to 5 x 5, but we are inserting only one row of data. This is ok,
+ * the rest of the rows will just be blank.
+ *
+ * Finally you will need to set it visible:
+ *
+ * \snippet doc_src_q3dbars_construction.cpp 2
+ *
+ * The complete code needed to create and display this chart is:
+ *
+ * \snippet doc_src_q3dbars_construction.cpp 3
+ *
+ * And this is what those few lines of code produce:
+ *
+ * \image q3dbars-minimal.png
+ *
+ * The scene can be rotated and zoomed into, but no other interaction is included in this minimal
+ * code example. You can learn more by familiarizing yourself with the examples provided, like
+ * the \l{Rainfall Example} or the \l{Widget Example}.
+ *
+ * \sa Q3DMaps, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ \enum BarStyle
+
+ Predefined bar types.
+
+ \value Bars
+ Basic cubic bar.
+ \value Pyramids
+ Four -sided pyramid.
+ \value Cones
+ Basic cone.
+ \value Cylinders
+ Basic cylinder.
+ \value BevelBars
+ Slilghtly beveled (rounded) cubic bar.
+ \value Spheres
+ Sphere. Not usable in Q3DBars.
+*/
+
+/*!
+ \enum CameraPreset
+
+ Predefined positions for camera.
+
+ \value PresetFrontLow
+ \value PresetFront
+ \value PresetFrontHigh
+ \value PresetLeftLow
+ \value PresetLeft
+ \value PresetLeftHigh
+ \value PresetRightLow
+ \value PresetRight
+ \value PresetRightHigh
+ \value PresetBehindLow
+ \value PresetBehind
+ \value PresetBehindHigh
+ \value PresetIsometricLeft
+ \value PresetIsometricLeftHigh
+ \value PresetIsometricRight
+ \value PresetIsometricRightHigh
+ \value PresetDirectlyAbove
+ \value PresetDirectlyAboveCW45
+ \value PresetDirectlyAboveCCW45
+ \value PresetFrontBelow
+ From PresetFrontBelow onward these only work for graphs including negative values.
+ They act as Preset...Low for positive-only values.
+ \value PresetLeftBelow
+ \value PresetRightBelow
+ \value PresetBehindBelow
+ \value PresetDirectlyBelow
+ Acts as PresetFrontLow for positive -only bars.
+*/
+
+/*!
+ \enum ColorTheme
+
+ Predefined color themes.
+
+ \value ThemeSystem
+ \value ThemeBlueCerulean
+ \value ThemeBlueIcy
+ \value ThemeBlueNcs
+ \value ThemeBrownSand
+ \value ThemeDark
+ \value ThemeHighContrast
+ \value ThemeLight
+*/
+
+/*!
+ \enum SelectionMode
+
+ Bar selection modes.
+
+ \value ModeNone
+ Selection mode disabled.
+ \value ModeBar
+ Selection selects a single bar.
+ \value ModeBarAndRow
+ Selection selects a single bar and highlights the row it is on.
+ \value ModeBarAndColumn
+ Selection selects a single bar and highlights the column it is on.
+ \value ModeBarRowAndColumn
+ Selection selects a single bar and highlights the row and the column it is on.
+ \value ModeZoomRow
+ Selection selects a single bar and displays the row it is on in a separate view. The
+ original view is shrunk into upper left corner. Original view is restored by clicking
+ on it.
+ \value ModeZoomColumn
+ Selection selects a single bar and displays the column it is on in a separate view. The
+ original view is shrunk into upper left corner. Original view is restored by clicking
+ on it.
+*/
+
+/*!
+ \enum ShadowQuality
+
+ Quality of shadows.
+
+ \value ShadowNone
+ Shadows are disabled.
+ \value ShadowLow
+ Shadows are rendered in low quality.
+ \value ShadowMedium
+ Shadows are rendered in medium quality.
+ \value ShadowHigh
+ Shadows are rendered in high quality.
+*/
+
+/*!
+ \enum LabelTransparency
+
+ Label transparencies.
+
+ \value TransparencyNone
+ Full solid, using colors from theme.
+ \value TransparencyFromTheme
+ Use colors and transparencies from theme.
+ \value TransparencyNoBackground
+ Draw just text on transparent background.
+*/
+
+/*!
+ * \a fbohandle Handle to QML2 scene graph's framebuffer object. Developers should not need to
+ * ever use this directly. Not used when using C++ API.
+ *
+ * \a windowsize QML2 window size Developers should not need to ever use this directly. Not
+ * used when using C++ API.
+ *
+ * Constructs a new 3D bar window. Parameters are not used unless instantiating from Qt Quick 2.
+ */
Q3DBars::Q3DBars(GLuint fbohandle, const QSize &windowsize)
: d_ptr(new Q3DBarsPrivate(this, geometry(), fbohandle))
{
}
+/*!
+ * Destroys the 3d bar window.
+ */
Q3DBars::~Q3DBars()
{
}
+/*!
+ * \internal
+ */
void Q3DBars::initialize()
{
- qDebug() << "Q3DBars::initialize()";
d_ptr->m_shared->setWidth(width());
d_ptr->m_shared->setHeight(height());
d_ptr->m_shared->initializeOpenGL();
}
+/*!
+ * \internal
+ */
void Q3DBars::render()
{
d_ptr->m_shared->render();
}
#if defined(Q_OS_ANDROID)
+/*!
+ * \internal
+ */
void Q3DBars::mouseDoubleClickEvent(QMouseEvent *event)
{
d_ptr->m_shared->mouseDoubleClickEvent(event);
}
+/*!
+ * \internal
+ */
void Q3DBars::touchEvent(QTouchEvent *event)
{
d_ptr->m_shared->touchEvent(event);
}
#endif
+/*!
+ * \internal
+ */
void Q3DBars::mousePressEvent(QMouseEvent *event)
{
d_ptr->m_shared->mousePressEvent(event);
}
+/*!
+ * \internal
+ */
void Q3DBars::mouseReleaseEvent(QMouseEvent *event)
{
d_ptr->m_shared->mouseReleaseEvent(event);
}
+/*!
+ * \internal
+ */
void Q3DBars::mouseMoveEvent(QMouseEvent *event)
{
d_ptr->m_shared->mouseMoveEvent(event);
}
+/*!
+ * \internal
+ */
void Q3DBars::wheelEvent(QWheelEvent *event)
{
d_ptr->m_shared->wheelEvent(event);
}
+/*!
+ * \internal
+ */
void Q3DBars::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
d_ptr->m_shared->setWidth(width());
d_ptr->m_shared->setHeight(height());
- d_ptr->m_shared->resizeNotify();
+ if (d_ptr->m_shared->m_isInitialized)
+ d_ptr->m_shared->resizeNotify();
}
+// TODO: Document
// Size
void Q3DBars::setWidth(const int width)
{
@@ -129,53 +339,144 @@ void Q3DBars::setHeight(const int height)
QWindow::setHeight(height);
}
+/*!
+ * \a thickness Thickness of a bar in x and z axes.
+ *
+ * \a spacing Spacing between bars in x and z axes. If relative -flag is true, value of 0.0f
+ * means the bars are side-to-side and for example 1.0f means there is one thickness in between the
+ * bars.
+ *
+ * \a relative A flag to indicate if spacing is meant to be absolute or relative. \c true by
+ * default.
+ *
+ * Sets bar specifications. Bar thickness is relative, as scene is automatically scaled to fit into
+ * the view.
+ */
void Q3DBars::setBarSpecs(QSizeF thickness, QSizeF spacing, bool relative)
{
d_ptr->m_shared->setBarSpecs(thickness, spacing, relative);
}
+/*!
+ * \a style One of the values in \c BarStyle. \c Bars by default.
+ *
+ * \a smooth A flag to set shading to smooth. \c false by default.
+ *
+ * Sets the bar type to one of the supplied ones.
+ *
+ * \sa setMeshFileName()
+ */
void Q3DBars::setBarType(BarStyle style, bool smooth)
{
d_ptr->m_shared->setBarType(style, smooth);
}
+/*!
+ * \a samplesRow How many rows of data there will be.
+ *
+ * \a samplesColumn How many items there are per row.
+ *
+ * \a labelRow QString label for the rows, ie. x -axis label.
+ *
+ * \a labelColumn QString label for the columns, ie. z -axis label.
+ *
+ * \a labelHeight QString label for height, ie. y -axis label.
+ *
+ * Set up sample space. This must be called to initialize the sample space before adding data to the
+ * Q3DBars.
+ *
+ * \sa addDataRow(), addDataSet()
+ */
void Q3DBars::setupSampleSpace(int samplesRow, int samplesColumn, const QString &labelRow,
const QString &labelColumn, const QString &labelHeight)
{
- d_ptr->m_shared->setupSampleSpace(samplesRow, samplesColumn, labelRow, labelColumn, labelHeight);
+ d_ptr->m_shared->setupSampleSpace(samplesRow, samplesColumn, labelRow, labelColumn,
+ labelHeight);
}
-
+/*!
+ * \a preset Move camera to a predefined position from \c CameraPreset.
+ *
+ * Moves camera to a predefined position.
+ */
void Q3DBars::setCameraPreset(CameraPreset preset)
{
d_ptr->m_shared->setCameraPreset(preset);
}
+/*!
+ * \a horizontal Horizontal angle for camera.
+ *
+ * \a vertical Vertical angle for camera.
+ *
+ * \a distance Distance from the center. \c 100 by default.
+ *
+ * Move camera to a wanted position based on horizontal and veritcal angles. Angles are limited
+ * to -180...180 in horizontal direction and either -90...90 or 0...90 in vertical, depending
+ * on data values. Negative vertical angles are allowed only if there are negative bar values.
+ * Distance is adjustable between 10 and 500.
+ */
void Q3DBars::setCameraPosition(GLfloat horizontal, GLfloat vertical, GLint distance)
{
d_ptr->m_shared->setCameraPosition(horizontal, vertical, distance);
}
+/*!
+ * \a theme Apply a predefined theme from \c ColorTheme.
+ *
+ * Sets a predefined theme. Theme affects bar colors, label colors, text color, background color,
+ * window color and grid color. Lighting is also adjusted by themes.
+ */
void Q3DBars::setTheme(ColorTheme theme)
{
d_ptr->m_shared->setTheme(theme);
}
+/*!
+ * \a baseColor The base color of a bar. If all other colors are black, this sets the final color of
+ * the bar.
+ *
+ * \a heightColor This color is added to the bar based on its height. The higher the bar, the more
+ * prominent this color becomes. Setting this black keeps the color unchanged regardless of height.
+ *
+ * \a depthColor This color becomes more prominent the further away from the first row the bar is.
+ * Setting this black keeps bars the same color regardless of "depth" in the set.
+ *
+ * \a uniform A flag to define if color needs to be uniform throughout bar's length, or will the
+ * colors be applied by height. \c true by default.
+ *
+ * Set bar color using your own colors. This overrides colors from theme.
+ */
void Q3DBars::setBarColor(QColor baseColor, QColor heightColor, QColor depthColor, bool uniform)
{
d_ptr->m_shared->setBarColor(baseColor, heightColor, depthColor, uniform);
}
+/*!
+ * \a mode Set bar selection mode from \c SelectionMode. \c ModeBar by default.
+ *
+ * Sets bar selection mode to be used.
+ */
void Q3DBars::setSelectionMode(SelectionMode mode)
{
d_ptr->m_shared->setSelectionMode(mode);
}
+/*!
+ * \return \c SelectionMode.
+ */
SelectionMode Q3DBars::selectionMode()
{
return d_ptr->m_shared->selectionMode();
}
+/*!
+ * \property Q3DBars::windowTitle
+ *
+ * \a title QString label to be used as window title.
+ *
+ * Sets the window title. The default is application executable name.
+ */
void Q3DBars::setWindowTitle(const QString &title)
{
setTitle(title);
@@ -186,11 +487,24 @@ QString Q3DBars::windowTitle()
return title();
}
+/*!
+ * \a objFileName File name of a mesh object. Object needs to be in Wavefront obj format
+ * and include vertices, normals and UVs. It also needs to be in triangles.
+ *
+ * Override bar type with an object mesh. \sa setBarType()
+ */
void Q3DBars::setMeshFileName(const QString &objFileName)
{
d_ptr->m_shared->setMeshFileName(objFileName);
}
+/*!
+ * \property Q3DBars::fontSize
+ *
+ * \a fontsize Size of the font.
+ *
+ * Sets font size.
+ */
void Q3DBars::setFontSize(float fontsize)
{
d_ptr->m_shared->setFontSize(fontsize);
@@ -201,6 +515,13 @@ float Q3DBars::fontSize()
return d_ptr->m_shared->fontSize();
}
+/*!
+ * \property Q3DBars::font
+ *
+ * \a font QFont to be used for labels. \c Arial by default.
+ *
+ * Sets the font for labels.
+ */
void Q3DBars::setFont(const QFont &font)
{
d_ptr->m_shared->setFont(font);
@@ -211,16 +532,32 @@ QFont Q3DBars::font()
return d_ptr->m_shared->font();
}
+/*!
+ * \a transparency Transparency level of labels from \c LabelTransparency.
+ * \c TransparencyFromTheme by default.
+ *
+ * Sets label transparency.
+ */
void Q3DBars::setLabelTransparency(LabelTransparency transparency)
{
d_ptr->m_shared->setLabelTransparency(transparency);
}
+/*!
+ * \return \c LabelTransparency.
+ */
LabelTransparency Q3DBars::labelTransparency()
{
return d_ptr->m_shared->labelTransparency();
}
+/*!
+ * \property Q3DBars::grid
+ *
+ * \a enable Flag to enable or disable grid. \c true by default.
+ *
+ * Sets grid drawing on or off.
+ */
void Q3DBars::setGridEnabled(bool enable)
{
d_ptr->m_shared->setGridEnabled(enable);
@@ -231,6 +568,13 @@ bool Q3DBars::gridEnabled()
return d_ptr->m_shared->gridEnabled();
}
+/*!
+ * \property Q3DBars::background
+ *
+ * \a enable Flag to enable or disable background. \c true by default.
+ *
+ * Sets backround rendering on or off.
+ */
void Q3DBars::setBackgroundEnabled(bool enable)
{
d_ptr->m_shared->setBackgroundEnabled(enable);
@@ -241,44 +585,112 @@ bool Q3DBars::backgroundEnabled()
return d_ptr->m_shared->backgroundEnabled();
}
+/*!
+ * \a quality Shadow quality from \c ShadowQuality. \c ShadowLow by default.
+ */
void Q3DBars::setShadowQuality(ShadowQuality quality)
{
d_ptr->m_shared->setShadowQuality(quality);
}
+/*!
+ * \return \c ShadowQuality.
+ */
ShadowQuality Q3DBars::shadowQuality()
{
return d_ptr->m_shared->shadowQuality();
}
+/*!
+ * \a tickCount How many ticks will be drawn. \c 5 by default.
+ *
+ * \a step How large a step each tick is.
+ *
+ * \a minimum Minimum value a bar in data set can have. Setting this correctly is especially
+ * important if values can be negative, or autoscaling won't work correctly.
+ *
+ * Sets tick count and step. Note; tickCount * step should be the maximum possible value of data
+ * set.
+ */
void Q3DBars::setTickCount(GLint tickCount, GLfloat step, GLfloat minimum)
{
d_ptr->m_shared->setTickCount(tickCount, step, minimum);
}
+/*!
+ * \a dataRow A vector of floats representing a single row of data. Sample space must be large
+ * enough to hold the row.
+ *
+ * \a labelRow A QString label for the row.
+ *
+ * \a labelsColumn A vector of strings, one for each item in the row.
+ *
+ * Add a row of data. Each new row is added to the front of the sample space, moving previous
+ * rows back (if sample space is more than one row deep).
+ */
void Q3DBars::addDataRow(const QVector<float> &dataRow, const QString &labelRow,
const QVector<QString> &labelsColumn)
{
d_ptr->m_shared->addDataRow(dataRow, labelRow, labelsColumn);
}
+/*!
+ * \a dataRow A vector of QDataItems representing a single row of data. Sample space must be
+ * large enough to hold the row. Ownership of QDataItems is transferred to Q3DBars.
+ *
+ * \a labelRow A QString label for the row.
+ *
+ * \a labelsColumn A vector of strings, one for each item in the row.
+ *
+ * Add a row of data. Each new row is added to the front of the sample space, moving previous
+ * rows back (if sample space is more than one row deep).
+ */
void Q3DBars::addDataRow(const QVector<QDataItem*> &dataRow, const QString &labelRow,
const QVector<QString> &labelsColumn)
{
d_ptr->m_shared->addDataRow(dataRow, labelRow, labelsColumn);
}
+/*!
+ * \a dataRow A QDataRow instance representing a single row of data. Sample space must be
+ * large enough to hold the row. Ownership of QDataRow is transferred to Q3DBars.
+ *
+ * Add a row of data. Each new row is added to the front of the sample space, moving previous
+ * rows back (if sample space is more than one row deep).
+ */
void Q3DBars::addDataRow(QDataRow *dataRow)
{
d_ptr->m_shared->addDataRow(dataRow);
}
+/*!
+ * \a data A vector of vector of floats representing the whole data set. Sample space must be
+ * large enough to hold the set.
+ *
+ * \a labelsRow A vector of strings, one for each column in the row.
+ *
+ * \a labelsColumn A vector of strings, one for each row in the column.
+ *
+ * Adds a whole data set at once. If an old data set exists, it is deleted and replaced with the
+ * new one.
+ */
void Q3DBars::addDataSet(const QVector< QVector<float> > &data, const QVector<QString> &labelsRow,
const QVector<QString> &labelsColumn)
{
- d_ptr->m_shared->addDataSet(data, labelsRow,labelsColumn);
+ d_ptr->m_shared->addDataSet(data, labelsRow, labelsColumn);
}
+/*!
+ * \a data A vector of vector of QDataItems representing the whole data set. Sample space must
+ * be large enough to hold the set. Ownership of QDataItems is transferred to Q3DBars.
+ *
+ * \a labelsRow A vector of strings, one for each column in the row.
+ *
+ * \a labelsColumn A vector of strings, one for each row in the column.
+ *
+ * Adds a whole data set at once. If an old data set exists, it is deleted and replaced with the
+ * new one.
+ */
void Q3DBars::addDataSet(const QVector< QVector<QDataItem*> > &data,
const QVector<QString> &labelsRow,
const QVector<QString> &labelsColumn)
@@ -286,7 +698,14 @@ void Q3DBars::addDataSet(const QVector< QVector<QDataItem*> > &data,
d_ptr->m_shared->addDataSet(data, labelsRow, labelsColumn);
}
-void Q3DBars::addDataSet(QDataSet* dataSet)
+/*!
+ * \a dataSet A QDataSet instance holding the whole data set. Sample space must
+ * be large enough to hold the set. Ownership of QDataSet is transferred to Q3DBars.
+ *
+ * Adds a whole data set at once. If an old data set exists, it is deleted and replaced with the
+ * new one.
+ */
+void Q3DBars::addDataSet(QDataSet *dataSet)
{
d_ptr->m_shared->addDataSet(dataSet);
}
diff --git a/src/datavis3d/engine/q3dbars.h b/src/datavis3d/engine/q3dbars.h
index 9c7f6a54..03635e4d 100644
--- a/src/datavis3d/engine/q3dbars.h
+++ b/src/datavis3d/engine/q3dbars.h
@@ -60,24 +60,18 @@ class QTENTERPRISE_DATAVIS3D_EXPORT Q3DBars : public Q3DWindow
{
Q_OBJECT
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
-
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(float fontSize READ fontSize WRITE setFontSize)
Q_PROPERTY(bool grid READ gridEnabled WRITE setGridEnabled)
Q_PROPERTY(bool background READ backgroundEnabled WRITE setBackgroundEnabled)
-protected:
-
- void initialize();
- void render();
-
public:
explicit Q3DBars(GLuint fbohandle = 0, const QSize &windowsize = QSize());
~Q3DBars();
// Add a row of data. Each new row is added to the front of the sample space, moving previous
// rows back (if sample space is more than one row deep)
- Q_INVOKABLE void addDataRow(const QVector<GLfloat> &dataRow,
+ Q_INVOKABLE void addDataRow(const QVector<float> &dataRow,
const QString &labelRow = QString(),
const QVector<QString> &labelsColumn = QVector<QString>());
// ownership of dataItems is transferred
@@ -88,7 +82,7 @@ public:
Q_INVOKABLE void addDataRow(QDataRow *dataRow);
// Add complete data set at a time, as a vector of data rows
- Q_INVOKABLE void addDataSet(const QVector< QVector<GLfloat> > &data,
+ Q_INVOKABLE void addDataSet(const QVector< QVector<float> > &data,
const QVector<QString> &labelsRow = QVector<QString>(),
const QVector<QString> &labelsColumn = QVector<QString>());
@@ -165,6 +159,7 @@ public:
void setGridEnabled(bool enable);
bool gridEnabled();
+ // TODO: Do these need to be public? Where are they called from?
// Size
void setWidth(const int width);
void setHeight(const int height);
@@ -178,6 +173,9 @@ public:
ShadowQuality shadowQuality();
protected:
+ void initialize();
+ void render();
+
#if defined(Q_OS_ANDROID)
void mouseDoubleClickEvent(QMouseEvent *event);
void touchEvent(QTouchEvent *event);
diff --git a/src/datavis3d/engine/q3dmaps.cpp b/src/datavis3d/engine/q3dmaps.cpp
index c0f8a8c7..0a1ca7ff 100644
--- a/src/datavis3d/engine/q3dmaps.cpp
+++ b/src/datavis3d/engine/q3dmaps.cpp
@@ -85,15 +85,39 @@ const GLfloat gridLineWidth = 0.005f;
GLfloat distanceMod = 0.0f;
static QVector3D skipColor = QVector3D(255, 255, 255); // Selection texture's background color
+/*!
+ * \class Q3DMaps
+ * \inmodule QtDataVis3D
+ * \brief The Q3DMaps class provides methods for rendering 3D bars on maps or other planes.
+ * \since 1.0.0
+ *
+ * This class enables developers to render bars or objects on maps or other planes in 3D and to
+ * view them by rotating the scene freely. Methods are provided for changing object types, themes
+ * and so on.
+ *
+ * See methods themselves for more complete description.
+ *
+ * \sa Q3DBars, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ * Constructs Q3DMaps.
+ */
Q3DMaps::Q3DMaps()
: d_ptr(new Q3DMapsPrivate(this))
{
}
+/*!
+ * Destructs Q3DMaps.
+ */
Q3DMaps::~Q3DMaps()
{
}
+/*!
+ * \internal
+ */
void Q3DMaps::initialize()
{
// Initialize shaders
@@ -185,12 +209,17 @@ void Q3DMaps::initialize()
// Set initialized -flag
d_ptr->m_isInitialized = true;
+ d_ptr->m_drawer->initializeOpenGL();
+
// Update default light position
#ifndef USE_WIDER_SHADOWS
distanceMod = 1.0f;
#endif
}
+/*!
+ * \internal
+ */
void Q3DMaps::render()
{
if (!d_ptr->m_isInitialized)
@@ -219,6 +248,9 @@ void Q3DMaps::render()
drawScene();
}
+/*!
+ * \internal
+ */
void Q3DMaps::drawScene()
{
// Set clear color
@@ -923,6 +955,9 @@ void Q3DMaps::drawScene()
}
#if defined(Q_OS_ANDROID)
+/*!
+ * \internal
+ */
void Q3DMaps::mouseDoubleClickEvent(QMouseEvent *event)
{
if (!d_ptr->m_zoomActivated) {
@@ -932,6 +967,9 @@ void Q3DMaps::mouseDoubleClickEvent(QMouseEvent *event)
}
}
+/*!
+ * \internal
+ */
void Q3DMaps::touchEvent(QTouchEvent *event)
{
static int prevDistance = 0;
@@ -961,6 +999,9 @@ void Q3DMaps::touchEvent(QTouchEvent *event)
}
#endif
+/*!
+ * \internal
+ */
void Q3DMaps::mousePressEvent(QMouseEvent *event)
{
if (Qt::LeftButton == event->button()) {
@@ -999,6 +1040,9 @@ void Q3DMaps::mousePressEvent(QMouseEvent *event)
CameraHelper::updateMousePos(d_ptr->m_mousePos);
}
+/*!
+ * \internal
+ */
void Q3DMaps::mouseReleaseEvent(QMouseEvent *event)
{
//qDebug() << "mouse button released" << event->button();
@@ -1010,6 +1054,9 @@ void Q3DMaps::mouseReleaseEvent(QMouseEvent *event)
d_ptr->m_mousePressed = Q3DMapsPrivate::MouseNone;
}
+/*!
+ * \internal
+ */
void Q3DMaps::mouseMoveEvent(QMouseEvent *event)
{
if (Q3DMapsPrivate::MouseRotating == d_ptr->m_mousePressed) {
@@ -1033,6 +1080,9 @@ void Q3DMaps::mouseMoveEvent(QMouseEvent *event)
#endif
}
+/*!
+ * \internal
+ */
void Q3DMaps::wheelEvent(QWheelEvent *event)
{
if (d_ptr->m_zoomLevel > 100)
@@ -1047,6 +1097,9 @@ void Q3DMaps::wheelEvent(QWheelEvent *event)
d_ptr->m_zoomLevel = 10;
}
+/*!
+ * \internal
+ */
void Q3DMaps::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
@@ -1513,9 +1566,9 @@ Q3DMapsPrivate::Q3DMapsPrivate(Q3DMaps *q)
Q3DMapsPrivate::~Q3DMapsPrivate()
{
- glDeleteFramebuffers(1, &m_depthFrameBuffer);
- glDeleteFramebuffers(1, &m_selectionFrameBuffer);
- glDeleteRenderbuffers(1, &m_selectionDepthBuffer);
+ m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer);
+ m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer);
+ m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer);
m_textureHelper->deleteTexture(&m_selectionTexture);
m_textureHelper->deleteTexture(&m_bgrTexture);
delete m_data;
@@ -1582,8 +1635,8 @@ void Q3DMapsPrivate::initSelectionBuffer()
{
if (m_selectionTexture) {
- glDeleteFramebuffers(1, &m_selectionFrameBuffer);
- glDeleteRenderbuffers(1, &m_selectionDepthBuffer);
+ m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer);
+ m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer);
m_textureHelper->deleteTexture(&m_selectionTexture);
}
m_selectionTexture = m_textureHelper->createSelectionTexture(q_ptr->size(),
@@ -1604,7 +1657,7 @@ void Q3DMapsPrivate::initDepthShader()
void Q3DMapsPrivate::initDepthBuffer()
{
if (m_depthTexture) {
- glDeleteFramebuffers(1, &m_depthFrameBuffer);
+ m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer);
m_textureHelper->deleteTexture(&m_depthTexture);
}
m_depthTexture = m_textureHelper->createDepthTexture(q_ptr->size(), m_depthFrameBuffer,
diff --git a/src/datavis3d/engine/q3dmaps.h b/src/datavis3d/engine/q3dmaps.h
index d9880d3a..67c8860b 100644
--- a/src/datavis3d/engine/q3dmaps.h
+++ b/src/datavis3d/engine/q3dmaps.h
@@ -80,10 +80,6 @@ public:
explicit Q3DMaps();
~Q3DMaps();
- void initialize();
- void render();
- void render(QPainter *painter);
-
// Add data item. New data item is appended to old data.
// ownership of data is transferred
Q_INVOKABLE bool addDataItem(QDataItem *dataItem);
@@ -159,6 +155,9 @@ public:
ShadowQuality shadowQuality();
protected:
+ void initialize();
+ void render();
+
#if defined(Q_OS_ANDROID)
void mouseDoubleClickEvent(QMouseEvent *event);
void touchEvent(QTouchEvent *event);
diff --git a/src/datavis3d/engine/q3dwindow.cpp b/src/datavis3d/engine/q3dwindow.cpp
index 8e3af68a..af975cb1 100644
--- a/src/datavis3d/engine/q3dwindow.cpp
+++ b/src/datavis3d/engine/q3dwindow.cpp
@@ -52,6 +52,24 @@
QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+/*!
+ * \class Q3DWindow
+ * \inmodule QtDataVis3D
+ * \brief The Q3DWindow class provides a window and render loop.
+ * \since 1.0.0
+ *
+ * This class creates a QWindow and provides render loop for visualization types inheriting it.
+ * \warning This class is not intended to be used directly by developers.
+ *
+ * \sa Q3DBars, Q3DMaps, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ * \a parent A QWindow parent.
+ *
+ * Constructs Q3DWindow. It creates a QWindow and an OpenGL context. It also sets surface
+ * format and initializes OpenGL functions for use.
+ */
Q3DWindow::Q3DWindow(QWindow *parent)
: QWindow(parent),
d_ptr(new Q3DWindowPrivate(this))
@@ -80,13 +98,19 @@ Q3DWindow::Q3DWindow(QWindow *parent)
initialize();
}
+/*!
+ * Destroys Q3DWindow.
+ */
Q3DWindow::~Q3DWindow()
{
}
+/*!
+ * \internal
+ */
void Q3DWindow::initialize()
{
- const GLubyte* version = glGetString(GL_VERSION);
+ const GLubyte *version = glGetString(GL_VERSION);
qDebug() << "OpenGL version:" << (const char *)version;
version = glGetString(GL_SHADING_LANGUAGE_VERSION);
qDebug() << "GLSL version:" << (const char *)version;
@@ -99,10 +123,16 @@ void Q3DWindow::initialize()
setAnimating(true);
}
+/*!
+ * \internal
+ */
void Q3DWindow::render()
{
}
+/*!
+ * \internal
+ */
void Q3DWindow::renderLater()
{
if (!d_ptr->m_updatePending) {
@@ -111,6 +141,9 @@ void Q3DWindow::renderLater()
}
}
+/*!
+ * \internal
+ */
bool Q3DWindow::event(QEvent *event)
{
switch (event->type()) {
@@ -122,6 +155,9 @@ bool Q3DWindow::event(QEvent *event)
}
}
+/*!
+ * \internal
+ */
void Q3DWindow::exposeEvent(QExposeEvent *event)
{
Q_UNUSED(event);
@@ -130,6 +166,9 @@ void Q3DWindow::exposeEvent(QExposeEvent *event)
renderNow();
}
+/*!
+ * \internal
+ */
void Q3DWindow::renderNow()
{
if (!isExposed())
@@ -154,6 +193,9 @@ void Q3DWindow::renderNow()
renderLater();
}
+/*!
+ * \internal
+ */
void Q3DWindow::setAnimating(bool animating)
{
d_ptr->m_animating = animating;
diff --git a/src/datavis3d/engine/q3dwindow.h b/src/datavis3d/engine/q3dwindow.h
index edabcf76..bf7d8f74 100644
--- a/src/datavis3d/engine/q3dwindow.h
+++ b/src/datavis3d/engine/q3dwindow.h
@@ -56,21 +56,20 @@ class Q3DWindowPrivate;
class QTENTERPRISE_DATAVIS3D_EXPORT Q3DWindow : public QWindow, protected QOpenGLFunctions
{
Q_OBJECT
+
public:
explicit Q3DWindow(QWindow *parent = 0);
~Q3DWindow();
- virtual void render();
-
- virtual void initialize();
-
- void setAnimating(bool animating);
-
-public slots:
+private slots:
void renderLater();
void renderNow();
protected:
+ virtual void render();
+ virtual void initialize();
+
+ void setAnimating(bool animating);
bool event(QEvent *event);
void exposeEvent(QExposeEvent *event);
diff --git a/src/datavis3d/engine/qdataitem.cpp b/src/datavis3d/engine/qdataitem.cpp
index 8134fcb5..883c190c 100644
--- a/src/datavis3d/engine/qdataitem.cpp
+++ b/src/datavis3d/engine/qdataitem.cpp
@@ -47,15 +47,46 @@
QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+/*!
+ * \class QDataItem
+ * \inmodule QtDataVis3D
+ * \brief The QDataItem class provides a container for data to be added to graphs.
+ * \since 1.0.0
+ *
+ * A QDataItem holds data for a single bar in a Q3DMaps or Q3DBars graph.
+ *
+ * \sa QDataRow, QDataSet, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ * \a value A float value of the data item.
+ *
+ * \a label A QString label for the item.
+ *
+ * Constructs QDataItem.
+ */
QDataItem::QDataItem(float value, const QString &label)
: d_ptr(new QDataItemPrivate(this, value, label))
{
}
+/*!
+ * Destroys QDataItem.
+ */
QDataItem::~QDataItem()
{
}
+/*!
+ * \property QDataItem::label
+ *
+ * \a label A QString label for the data item. Unit, for example.
+ *
+ * \a prepend A flag to indicate if the label is to be prepended or appended to the value.
+ * \c false by default.
+ *
+ * Sets label for the data item.
+ */
void QDataItem::setLabel(const QString &label, bool prepend)
{
d_ptr->m_labelString = label;
@@ -67,11 +98,25 @@ QString QDataItem::label()
return d_ptr->m_labelString;
}
+/*!
+ * \property QDataItem::value
+ *
+ * \a value A float value for the data item.
+ *
+ * Sets value for the data item.
+ */
void QDataItem::setValue(float value)
{
d_ptr->m_value = value;
}
+/*!
+ * \overload QDataItem::value
+ *
+ * \a value An int value for the data item.
+ *
+ * Sets value for the data item.
+ */
void QDataItem::setValue(int value)
{
d_ptr->m_value = (float)value;
@@ -82,11 +127,25 @@ float QDataItem::value()
return d_ptr->m_value;
}
+/*!
+ * \property QDataItem::position
+ *
+ * \a position A QPointF position for the data item.
+ *
+ * Sets position for the data item. Has no effect in Q3DBars.
+ */
void QDataItem::setPosition(const QPointF &position)
{
d_ptr->m_position = position;
}
+/*!
+ * \overload QDataItem::position
+ *
+ * \a position A QPoint position for the data item.
+ *
+ * Sets position for the data item. Has no effect in Q3DBars.
+ */
void QDataItem::setPosition(const QPoint &position)
{
d_ptr->m_position = (QPointF)position;
diff --git a/src/datavis3d/engine/qdataitem.h b/src/datavis3d/engine/qdataitem.h
index 8a2797ae..7c8302f4 100644
--- a/src/datavis3d/engine/qdataitem.h
+++ b/src/datavis3d/engine/qdataitem.h
@@ -60,13 +60,13 @@ class QTENTERPRISE_DATAVIS3D_EXPORT QDataItem : public QObject
Q_PROPERTY(QString label READ label WRITE setLabel)
Q_PROPERTY(float value READ value WRITE setValue)
Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int value READ value WRITE setValue)
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
explicit QDataItem(float value = 0.0f, const QString &label = QString());
~QDataItem();
+ // TODO: Provide a Q_INVOKABLE version of this, or move prepend to it's own property.
void setLabel(const QString &label, bool prepend = false); // label for value, unit for example
QString label();
void setValue(float value);
@@ -80,7 +80,6 @@ public:
private:
QScopedPointer<QDataItemPrivate> d_ptr;
friend class Bars3dShared;
- friend class Bars3dSharedPrivate;
friend class Q3DMaps;
friend class Q3DMapsPrivate;
friend class QDataRowPrivate;
diff --git a/src/datavis3d/engine/qdatarow.cpp b/src/datavis3d/engine/qdatarow.cpp
index 79bc48e1..6bdd6d14 100644
--- a/src/datavis3d/engine/qdatarow.cpp
+++ b/src/datavis3d/engine/qdatarow.cpp
@@ -48,15 +48,44 @@
QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+/*!
+ * \class QDataRow
+ * \inmodule QtDataVis3D
+ * \brief The QDataRow class provides a container for data items to be added to graphs.
+ * \since 1.0.0
+ *
+ * A QDataRow is a container for all data to be added to a Q3DMaps instance, or a single row to
+ * be added to a QDataSet. It holds instances of QDataItem and has no knowledge of possible
+ * sample space sizes set for a Q3DBars instance. The ownership of QDataItem added is transferred
+ * to QDataRow.
+ *
+ * \sa QDataItem, QDataSet, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ * \a label A QString label for the row.
+ *
+ * Constructs QDataRow.
+ */
QDataRow::QDataRow(const QString &label)
: d_ptr(new QDataRowPrivate(this, label))
{
}
+/*!
+ * Destroys QDataRow and all instances of QDataItem it may hold.
+ */
QDataRow::~QDataRow()
{
}
+/*!
+ * \property QDataRow::label
+ *
+ * \a label A QString label for the row.
+ *
+ * Sets a label for the row.
+ */
void QDataRow::setLabel(const QString &label)
{
d_ptr->m_label = label;
@@ -67,6 +96,11 @@ QString QDataRow::label()
return d_ptr->m_label;
}
+/*!
+ * \a item A QDataItem instance.
+ *
+ * Adds a QDataItem to the QDataRow. Ownership of QDataItem is transferred to QDataRow.
+ */
void QDataRow::addItem(QDataItem *item)
{
d_ptr->m_row.prepend(item);
diff --git a/src/datavis3d/engine/qdatarow.h b/src/datavis3d/engine/qdatarow.h
index b4ee1d6b..72fa5f55 100644
--- a/src/datavis3d/engine/qdatarow.h
+++ b/src/datavis3d/engine/qdatarow.h
@@ -68,7 +68,6 @@ public:
private:
QScopedPointer<QDataRowPrivate> d_ptr;
friend class Bars3dShared;
- friend class Bars3dSharedPrivate;
friend class Q3DMaps;
friend class Q3DMapsPrivate;
friend class QDataSetPrivate;
diff --git a/src/datavis3d/engine/qdataset.cpp b/src/datavis3d/engine/qdataset.cpp
index ab892127..6fd59baf 100644
--- a/src/datavis3d/engine/qdataset.cpp
+++ b/src/datavis3d/engine/qdataset.cpp
@@ -53,17 +53,47 @@ QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
const QString empty;
+/*!
+ * \class QDataSet
+ * \inmodule QtDataVis3D
+ * \brief The QDataSet class provides a container for data rows to be added to graphs.
+ * \since 1.0.0
+ *
+ * A QDataSet is a container for data to be added into a Q3DBars instance. It holds instances of
+ * QDataRow and has no knowledge of sample space size set for Q3DBars. The ownership of QDataRow
+ * added is transferred to QDataSet.
+ *
+ * \sa QDataItem, QDataRow, {Qt Data Visualization 3D C++ Classes}
+ */
+
+/*!
+ * Constructs QDataSet.
+ */
QDataSet::QDataSet()
: d_ptr(new QDataSetPrivate(this))
{
- //qDebug("QDataSet");
}
+/*!
+ * Destroys QDataSet, including all QDataRow instances it may hold.
+ */
QDataSet::~QDataSet()
{
- //qDebug("~QDataSet");
}
+/*!
+ * \a xAxis A QString label for x axis.
+ *
+ * \a zAxis A QString label for z axis.
+ *
+ * \a yAxis A QString label for y axis.
+ *
+ * \a labelsRow A QVector of QStrings, one for each row.
+ *
+ * \a labelsColumn A QVector of QStrings, one for each column.
+ *
+ * Sets labels for the QDataSet.
+ */
void QDataSet::setLabels(const QString &xAxis,
const QString &zAxis,
const QString &yAxis,
@@ -106,6 +136,12 @@ void QDataSet::setLabels(const QString &xAxis,
}
}
+/*!
+ * \a row A QDataRow instance.
+ *
+ * Adds a QDataRow instance to QDataSet. Ownership of the QDataRow instance is transferred to
+ * QDataSet.
+ */
void QDataSet::addRow(QDataRow *row)
{
d_ptr->m_set.prepend(row);
diff --git a/src/datavis3d/engine/qdataset.h b/src/datavis3d/engine/qdataset.h
index a7a509a5..e645bc16 100644
--- a/src/datavis3d/engine/qdataset.h
+++ b/src/datavis3d/engine/qdataset.h
@@ -72,7 +72,6 @@ public:
private:
QScopedPointer<QDataSetPrivate> d_ptr;
friend class Bars3dShared;
- friend class Bars3dSharedPrivate;
friend class Q3DMaps;
friend class Q3DMapsPrivate;
};
diff --git a/src/datavis3d/engine/theme_p.h b/src/datavis3d/engine/theme_p.h
index 29a020e9..234d4709 100644
--- a/src/datavis3d/engine/theme_p.h
+++ b/src/datavis3d/engine/theme_p.h
@@ -70,7 +70,6 @@ public:
private:
friend class Bars3dShared;
- friend class Bars3dSharedPrivate;
friend class Q3DMaps;
friend class Q3DMapsPrivate;
friend class Drawer;