summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-10-25 08:24:22 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-10-25 08:24:22 +0300
commitbcd7404809119111c437e0ec4c6b9b69bc5ccad5 (patch)
tree37a3f5953e09c3b96d2d33834962062970ee6cd9
parentdf8c7a37aee9a78de310bcb05e2eb0097ef4afb7 (diff)
parent986060cbcfd51c332c5832219147c3aff8f2141d (diff)
Merge remote-tracking branch 'origin/develop'
-rw-r--r--examples/audiolevels/audiolevels.cpp9
-rw-r--r--examples/audiolevels/audiolevelsiodevice.cpp3
-rw-r--r--examples/audiolevels/doc/src/audiolevels.qdoc4
-rw-r--r--examples/audiolevels/main.cpp2
-rw-r--r--examples/bars/doc/src/bars.qdoc2
-rw-r--r--examples/customproxy/doc/src/customproxy.qdoc6
-rw-r--r--examples/itemmodel/doc/src/itemmodel.qdoc8
-rw-r--r--examples/qmlbars/doc/src/qmlbars.qdoc2
-rw-r--r--examples/qmlbars/qml/qmlbars/main.qml2
-rw-r--r--examples/qmlscatter/doc/src/qmlscatter.qdoc6
-rw-r--r--examples/qmlsurface/doc/src/qmlsurface.qdoc6
-rw-r--r--examples/scatter/doc/src/scatter.qdoc6
-rw-r--r--examples/surface/doc/src/surface.qdoc17
-rw-r--r--examples/surface/main.cpp4
-rw-r--r--examples/surface/surfacegraph.cpp54
-rw-r--r--src/datavisualization/axis/q3dabstractaxis.cpp4
-rw-r--r--src/datavisualization/axis/q3dcategoryaxis.cpp10
-rw-r--r--src/datavisualization/axis/q3dvalueaxis.cpp4
-rw-r--r--src/datavisualization/data/qabstractdatamapping.cpp2
-rw-r--r--src/datavisualization/data/qabstractdataproxy.cpp8
-rw-r--r--src/datavisualization/data/qbardataitem.cpp2
-rw-r--r--src/datavisualization/data/qbardataproxy.cpp20
-rw-r--r--src/datavisualization/data/qheightmapsurfacedataproxy.cpp6
-rw-r--r--src/datavisualization/data/qitemmodelbardatamapping.cpp18
-rw-r--r--src/datavisualization/data/qitemmodelbardataproxy.cpp6
-rw-r--r--src/datavisualization/data/qitemmodelscatterdatamapping.cpp8
-rw-r--r--src/datavisualization/data/qitemmodelscatterdataproxy.cpp12
-rw-r--r--src/datavisualization/data/qitemmodelsurfacedatamapping.cpp16
-rw-r--r--src/datavisualization/data/qitemmodelsurfacedataproxy.cpp4
-rw-r--r--src/datavisualization/data/qscatterdataitem.cpp2
-rw-r--r--src/datavisualization/data/qscatterdataproxy.cpp14
-rw-r--r--src/datavisualization/data/qsurfacedataitem.cpp2
-rw-r--r--src/datavisualization/data/qsurfacedataproxy.cpp18
-rw-r--r--src/datavisualization/doc/qtdatavisualization.qdocconf2
-rw-r--r--src/datavisualization/doc/snippets/doc_src_q3dbars_construction.cpp14
-rw-r--r--src/datavisualization/doc/snippets/doc_src_q3dscatter_construction.cpp6
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-index.qdoc12
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc6
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc2
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-colorgradient.qdoc4
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc2
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc16
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization.qdoc54
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp573
-rw-r--r--src/datavisualization/engine/bars3drenderer_p.h2
-rw-r--r--src/datavisualization/engine/drawer.cpp10
-rw-r--r--src/datavisualization/engine/meshes/backgroudFlat.obj30
-rw-r--r--src/datavisualization/engine/meshes/backgroudNegatives.obj24
-rw-r--r--src/datavisualization/engine/meshes/backgroudSmooth.obj6
-rw-r--r--src/datavisualization/engine/q3dbars.cpp23
-rw-r--r--src/datavisualization/engine/q3dbox.cpp2
-rw-r--r--src/datavisualization/engine/q3dcamera.cpp27
-rw-r--r--src/datavisualization/engine/q3dlight.cpp2
-rw-r--r--src/datavisualization/engine/q3dobject.cpp2
-rw-r--r--src/datavisualization/engine/q3dscatter.cpp18
-rw-r--r--src/datavisualization/engine/q3dscene.cpp2
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp20
-rw-r--r--src/datavisualization/engine/q3dwindow.cpp4
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp562
-rw-r--r--src/datavisualization/engine/selectionpointer.cpp10
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.frag6
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.vert6
-rw-r--r--src/datavisualization/engine/shaders/surface_ES2.frag2
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp4
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp318
-rw-r--r--src/datavisualization/engine/theme.cpp2
-rw-r--r--src/datavisualization/global/datavisualizationglobal_p.h9
-rw-r--r--src/datavisualization/global/qtdatavisualizationenums.qdoc9
-rw-r--r--src/datavisualization/input/q3dinputhandler.cpp17
-rw-r--r--src/datavisualization/input/qabstract3dinputhandler.cpp14
-rw-r--r--src/datavisualization/input/qtouch3dinputhandler.cpp15
-rw-r--r--src/datavisualization/utils/surfaceobject.cpp4
-rw-r--r--src/datavisualization/utils/texturehelper.cpp49
-rw-r--r--src/datavisualization/utils/texturehelper_p.h2
-rw-r--r--src/datavisualization/utils/utils.cpp2
-rw-r--r--src/datavisualization/utils/vertexindexer.cpp2
-rw-r--r--src/datavisualizationqml2/declarativesurface.cpp2
-rw-r--r--tests/kinectsurface/QtKinectWrapper/QKinectWrapper.cpp4
79 files changed, 992 insertions, 1199 deletions
diff --git a/examples/audiolevels/audiolevels.cpp b/examples/audiolevels/audiolevels.cpp
index e1788936..d95536d2 100644
--- a/examples/audiolevels/audiolevels.cpp
+++ b/examples/audiolevels/audiolevels.cpp
@@ -38,11 +38,14 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent)
// Set up the graph
m_graph->setBarThickness(0.5);
m_graph->setBarSpacing(QSizeF(0.0, 1.0));
- m_graph->setGridVisible(false);
+ m_graph->setGridVisible(true);
m_graph->setBackgroundVisible(false);
- m_graph->valueAxis()->setRange(0.0, 2.0);
+ m_graph->valueAxis()->setRange(-100.0, 100.0);
+ m_graph->valueAxis()->setSegmentCount(20);
+ m_graph->valueAxis()->setLabelFormat(QStringLiteral("%d\%"));
m_graph->setShadowQuality(QDataVis::ShadowQualityNone);
- m_graph->scene()->activeCamera()->setCameraPosition(-20.0, 10.0, 20);
+ m_graph->setSelectionMode(QDataVis::SelectionModeNone);
+ m_graph->scene()->activeCamera()->setCameraPosition(-25.0, 10.0, 190.0);
m_graph->setTheme(QDataVis::ThemeIsabelle);
m_graph->setBarType(QDataVis::MeshStyleBars);
diff --git a/examples/audiolevels/audiolevelsiodevice.cpp b/examples/audiolevels/audiolevelsiodevice.cpp
index 11cba5aa..9fedd804 100644
--- a/examples/audiolevels/audiolevelsiodevice.cpp
+++ b/examples/audiolevels/audiolevelsiodevice.cpp
@@ -74,7 +74,8 @@ qint64 AudioLevelsIODevice::writeData(const char *data, qint64 maxSize)
int index = 0;
for (int i = newDataSize - 1; i >= newDataStartIndex; i--) {
// Add 0.01 to the value to avoid gaps in the graph (i.e. zero height bars).
- qreal value = qreal(quint8(data[resolution * i]) - 128) / 2.0 + 0.01;
+ // Also, scale to 0...100
+ qreal value = qreal(quint8(data[resolution * i]) - 128) / 1.28 + 0.01;
(*m_array->at(middleRow))[index].setValue(value);
// Insert a fractional value into front half of the rows.
for (int j = 1; j <= middleRow; j++) {
diff --git a/examples/audiolevels/doc/src/audiolevels.qdoc b/examples/audiolevels/doc/src/audiolevels.qdoc
index 3d392487..1aef9174 100644
--- a/examples/audiolevels/doc/src/audiolevels.qdoc
+++ b/examples/audiolevels/doc/src/audiolevels.qdoc
@@ -57,7 +57,7 @@
\snippet ../examples/audiolevels/audiolevelsiodevice.cpp 1
- The \c resolution constant indicates the sample rate, e.g. value 8 means every eighth
+ The \c resolution constant indicates the sample rate, for example, value 8 means every eighth
byte from audio input is visualized. This is necessary to make the data readable, as it would
otherwise make the graph scroll too fast.
@@ -71,7 +71,7 @@
\snippet ../examples/audiolevels/audiolevelsiodevice.cpp 2
- We use a couple of techniques here to improve performance. First off, we reuse
+ We use a couple of techniques here to improve performance. First, we reuse
the existing data array, as this allows us to avoid any extra memory allocations in our
application code. This also means the data array dimensions do not change, which further
improves efficiency in the bar graph renderer.
diff --git a/examples/audiolevels/main.cpp b/examples/audiolevels/main.cpp
index 9d16610c..524c53b1 100644
--- a/examples/audiolevels/main.cpp
+++ b/examples/audiolevels/main.cpp
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
Q3DBars window;
- window.resize(1024, 768);
+ window.resize(900, 1000);
window.setTitle("Qt Data Visualization - Microphone audio levels visualizer");
window.show();
diff --git a/examples/bars/doc/src/bars.qdoc b/examples/bars/doc/src/bars.qdoc
index 379aa871..e24b4d0f 100644
--- a/examples/bars/doc/src/bars.qdoc
+++ b/examples/bars/doc/src/bars.qdoc
@@ -33,6 +33,8 @@
It also demonstrates how having negative bar values affects the graph.
+ For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
+
\image bars-example.png
\section1 Creating the application
diff --git a/examples/customproxy/doc/src/customproxy.qdoc b/examples/customproxy/doc/src/customproxy.qdoc
index 288a7149..be2e2a96 100644
--- a/examples/customproxy/doc/src/customproxy.qdoc
+++ b/examples/customproxy/doc/src/customproxy.qdoc
@@ -32,7 +32,7 @@
This example defines a simple flexible data set \c VariantDataSet where each data item is a
a variant list. Each item can have multiple different values, identified by their index in
- the list. In this example, the data set is storing monthly rainfall data, where value in
+ the list. In this example, the data set is storing monthly rainfall data, where the value in
index one is the year, index two contains the month, and the third value has the amount
of rainfall in that month.
@@ -95,7 +95,7 @@
\snippet ../examples/customproxy/variantbardatamapping.h 3
The primary way to use a \c VariantBarDataMapping object is to give the mappings already at the
- constructor, though they can be set later individually or all together with \c remap() method.
+ constructor, though they can be set later individually or all together with the \c remap() method.
A signal is emitted if mapping changes. It is basically a simplified version of
QItemModelBarDataMapping adapted to work with variant lists instead of item models.
@@ -106,7 +106,7 @@
\snippet ../examples/customproxy/rainfallgraph.cpp 0
- Bulk of that method is used for populating the variant data set. Once the set is populated,
+ The bulk of that method is used for populating the variant data set. Once the set is populated,
visualizing the data is trivial with the help of our custom proxy:
\snippet ../examples/customproxy/rainfallgraph.cpp 1
diff --git a/examples/itemmodel/doc/src/itemmodel.qdoc b/examples/itemmodel/doc/src/itemmodel.qdoc
index f014bfea..682ebb1f 100644
--- a/examples/itemmodel/doc/src/itemmodel.qdoc
+++ b/examples/itemmodel/doc/src/itemmodel.qdoc
@@ -31,6 +31,8 @@
\li How to use a table widget to modify the data in the graph
\endlist
+ For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
+
\image itemmodel-example-2.png
\section1 Creating the application
@@ -55,7 +57,7 @@
\snippet ../examples/itemmodel/main.cpp 2
- Here we tell the mapping object to directly map model's rows and columns into proxy's rows and
+ Here we tell the mapping object to directly map the model's rows and columns into the proxy's rows and
columns instead of defining row and column roles to map for them. Then we give the model from
the table widget and the mapping object to the proxy. Finally we set the proxy as the active
data proxy for the graph.
@@ -63,7 +65,7 @@
Next, let's create another class to handle the data addition and other interaction with the
graph. Let's call it GraphDataGenerator (See \l {Setting up the graph} and
\l {Adding data to the graph} for details) and connect some signals between Q3DBars,
- GraphDataGenerator and QTableWidget (See \l {Interacting with the data} for a closer look):
+ GraphDataGenerator, and QTableWidget (See \l {Interacting with the data} for a closer look):
\snippet ../examples/itemmodel/main.cpp 3
@@ -90,7 +92,7 @@
displayed separately.
Next line sets the font to \c Impact. If your system doesn't have it, it will be replaced by
- system default.
+ the system default.
And finally, we set theme to \c Digia and camera position to \c {Preset Front}. Now the initial
graph settings are done.
diff --git a/examples/qmlbars/doc/src/qmlbars.qdoc b/examples/qmlbars/doc/src/qmlbars.qdoc
index 185956ea..9f51f89e 100644
--- a/examples/qmlbars/doc/src/qmlbars.qdoc
+++ b/examples/qmlbars/doc/src/qmlbars.qdoc
@@ -66,7 +66,7 @@
\snippet ../examples/qmlbars/qml/qmlbars/main.qml 0
- The axis change is done because income and expenses have different label format. The same could have
+ The axis change is done because income and expenses have a different label format. The same could have
been achieved using a single axis and just changing the label format.
The second interesting block is where we filter some of the rows away from the visualized data:
diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml
index 6f44fe63..f2278d83 100644
--- a/examples/qmlbars/qml/qmlbars/main.qml
+++ b/examples/qmlbars/qml/qmlbars/main.qml
@@ -72,6 +72,8 @@ Item {
var currentColRole = graphData.model.get(i).month
if (currentRowRole === rowRole && currentColRole === colRole) {
tableView.currentRow = i
+ tableView.selection.clear()
+ tableView.selection.select(i)
break
}
}
diff --git a/examples/qmlscatter/doc/src/qmlscatter.qdoc b/examples/qmlscatter/doc/src/qmlscatter.qdoc
index c0d207d8..92e7ba35 100644
--- a/examples/qmlscatter/doc/src/qmlscatter.qdoc
+++ b/examples/qmlscatter/doc/src/qmlscatter.qdoc
@@ -25,6 +25,8 @@
The Qt Quick 2 scatter example shows how to make a simple scatter graph visualization using
Scatter3D and Qt Quick 2.
+ For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
+
\image qmlscatter-example.png
\section1 Creating the application
@@ -96,14 +98,14 @@
\snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 2
- Now the graph is ready to use, but has no data. It also has the default proxy, axes and visual
+ Now the graph is ready for use, but has no data. It also has the default proxy, axes, and visual
properties.
Let's modify some visual properties first by adding the following inside \c {scatterGraph}:
\snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 3
- We changed the font, theme and shadow quality. We're happy with the other visual properties,
+ We changed the font, theme, and shadow quality. We're happy with the other visual properties,
so we won't change them.
Then it's time to start feeding the graph some data.
diff --git a/examples/qmlsurface/doc/src/qmlsurface.qdoc b/examples/qmlsurface/doc/src/qmlsurface.qdoc
index c93ed2d6..12e326c8 100644
--- a/examples/qmlsurface/doc/src/qmlsurface.qdoc
+++ b/examples/qmlsurface/doc/src/qmlsurface.qdoc
@@ -28,13 +28,13 @@
\image qmlsurface-example.png
The focus in this example is on generating a surface graph from height data, so in this section
- we skip explaining application creation. For more detailed QML example documentation,
+ we skip explaining the application creation. For more detailed QML example documentation,
see \l{Qt Quick 2 Scatter Example}.
\section1 Adding data to the graph
- This example shows two method to set data to surface graph, using the HeightMapSurfaceDataProxy
- and ItemModelSurfaceDataProxy. First we go through setting the data using height map specific
+ This example shows two methods to set data to surface graph, using the HeightMapSurfaceDataProxy
+ and ItemModelSurfaceDataProxy. First we go through setting the data using the height map specific
data proxy. It is done with the code snippet below. The \c heightMapFile property specifies the image
file containing the height data. The value properties defines the minimum and maximum values for
surface area width and depth. This example shows the terrain around Tycho crater at imaginary
diff --git a/examples/scatter/doc/src/scatter.qdoc b/examples/scatter/doc/src/scatter.qdoc
index 90410bc6..2016a052 100644
--- a/examples/scatter/doc/src/scatter.qdoc
+++ b/examples/scatter/doc/src/scatter.qdoc
@@ -32,6 +32,8 @@
\li Adjust some graph properties using widget controls
\endlist
+ For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
+
\image scatter-example.png
\section1 Creating the application
@@ -59,7 +61,7 @@
\snippet ../examples/scatter/main.cpp 2
- The application main is done and we can show the graph and start the event loop:
+ The application main is done. We can show the graph and start the event loop:
\snippet ../examples/scatter/main.cpp 3
@@ -107,7 +109,7 @@
\snippet ../examples/scatter/scatterdatamodifier.cpp 5
- And populate it:
+ and populate it:
\snippet ../examples/scatter/scatterdatamodifier.cpp 6
diff --git a/examples/surface/doc/src/surface.qdoc b/examples/surface/doc/src/surface.qdoc
index 12271fb8..e669948c 100644
--- a/examples/surface/doc/src/surface.qdoc
+++ b/examples/surface/doc/src/surface.qdoc
@@ -34,6 +34,9 @@
\li Theme usage on the surface graph.
\li How to set a custom surface gradient.
\endlist
+
+ For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
+
\image surface-example.png
\section1 Creating the application
@@ -97,9 +100,9 @@
\section1 Selection modes
- Q3Dsurface supports three different selection modes and these are demonstrated on the
- example with radio buttons which the user can use to activate suitable selection mode.
- Following inline methods are connected to radio buttons to activate the selected mode.
+ Q3Dsurface supports three different selection modes. These are demonstrated in the
+ example with radio buttons, which the user can use to activate a suitable selection mode.
+ The following inline methods are connected to radio buttons to activate the selected mode.
\snippet ../examples/surface/surfacegraph.h 0
@@ -107,17 +110,15 @@
The example has four slider controls for adjusting the min and max values for X and Z
axis. When selecting the proxy these sliders are adjusted so that one step on the slider
- moves the range by one segment step. The example has some code to keep the sliders on
- valid positions, like when the X axis minimum exceeds the maximum the maximum is increased
- and so on. Finally the ranges are set for the graph like this:
+ moves the range by one segment step. Finally the ranges are set for the graph like this:
\snippet ../examples/surface/surfacegraph.cpp 5
\section1 Themes
Q3Dsurface supports all the themes QtDatavisualization has. The example has a pull
- down menu for selecting the theme and the following code snippet is connected to the menu to
- activate the selected theme.
+ down menu for selecting the theme. The following code snippet is connected to the
+ menu to activate the selected theme.
\snippet ../examples/surface/surfacegraph.cpp 6
diff --git a/examples/surface/main.cpp b/examples/surface/main.cpp
index 69babe8a..e448af94 100644
--- a/examples/surface/main.cpp
+++ b/examples/surface/main.cpp
@@ -100,7 +100,7 @@ int main(int argc, char **argv)
axisMinSliderX->setTickInterval(1);
axisMinSliderX->setEnabled(true);
QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget);
- axisMaxSliderX->setMinimum(2);
+ axisMaxSliderX->setMinimum(1);
axisMaxSliderX->setTickInterval(1);
axisMaxSliderX->setEnabled(true);
QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget);
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
axisMinSliderZ->setTickInterval(1);
axisMinSliderZ->setEnabled(true);
QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget);
- axisMaxSliderZ->setMinimum(2);
+ axisMaxSliderZ->setMinimum(1);
axisMaxSliderZ->setTickInterval(1);
axisMaxSliderZ->setEnabled(true);
diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp
index a33f060b..bb07cb96 100644
--- a/examples/surface/surfacegraph.cpp
+++ b/examples/surface/surfacegraph.cpp
@@ -28,6 +28,8 @@ const int sampleCountX = 50;
const int sampleCountZ = 50;
const int heightMapGridStepX = 6;
const int heightMapGridStepZ = 6;
+const float sampleMin = -8.0f;
+const float sampleMax = 8.0f;
SurfaceGraph::SurfaceGraph(Q3DSurface *surface)
: m_graph(surface)
@@ -59,18 +61,20 @@ SurfaceGraph::~SurfaceGraph()
//! [1]
void SurfaceGraph::fillSqrtSinProxy()
{
- qreal stepX = 16.0 / qreal(sampleCountX);
- qreal stepZ = 16.0 / qreal(sampleCountZ);
+ float stepX = (sampleMax - sampleMin) / float(sampleCountX - 1);
+ float stepZ = (sampleMax - sampleMin) / float(sampleCountZ - 1);
QSurfaceDataArray *dataArray = new QSurfaceDataArray;
dataArray->reserve(sampleCountZ);
- for (qreal i = -8.0 + stepZ / 2.0 ; i < 8.0 ; i += stepZ) {
+ for (int i = 0 ; i < sampleCountZ ; i++) {
QSurfaceDataRow *newRow = new QSurfaceDataRow(sampleCountX);
+ float z = i * stepZ + sampleMin;
int index = 0;
- for (qreal j = -8.0 + stepX / 2.0; j < 8.0; j += stepX) {
- qreal R = qSqrt(i * i + j * j) + 0.01;
- qreal y = (qSin(R) / R + 0.24) * 1.61;
- (*newRow)[index++].setPosition(QVector3D(j, y, i));
+ for (int j = 0; j < sampleCountX; j++) {
+ float x = j * stepX + sampleMin;
+ float R = qSqrt(z * z + x * x) + 0.01;
+ float y = (qSin(R) / R + 0.24) * 1.61;
+ (*newRow)[index++].setPosition(QVector3D(x, y, z));
}
*dataArray << newRow;
}
@@ -87,23 +91,23 @@ void SurfaceGraph::enableSqrtSinModel()
m_graph->axisX()->setLabelFormat("%.2f");
m_graph->axisZ()->setLabelFormat("%.2f");
- m_graph->axisX()->setRange(-8.0, 8.0);
+ m_graph->axisX()->setRange(sampleMin, sampleMax);
m_graph->axisY()->setRange(0.0, 2.0);
- m_graph->axisZ()->setRange(-8.0, 8.0);
+ m_graph->axisZ()->setRange(sampleMin, sampleMax);
m_graph->setActiveDataProxy(sqrtSinProxy);
//! [3]
// Reset range sliders for Sqrt&Sin
- m_rangeMinX = -8.0;
- m_rangeMinZ = -8.0;
- m_stepX = 16.0 / qreal(sampleCountX - 1);
- m_stepZ = 16.0 / qreal(sampleCountZ - 1);
- m_axisMinSliderX->setMaximum(sampleCountX - 3);
+ m_rangeMinX = sampleMin;
+ m_rangeMinZ = sampleMin;
+ m_stepX = (sampleMax - sampleMin) / qreal(sampleCountX - 1);
+ m_stepZ = (sampleMax - sampleMin) / qreal(sampleCountZ - 1);
+ m_axisMinSliderX->setMaximum(sampleCountX - 2);
m_axisMinSliderX->setValue(0);
m_axisMaxSliderX->setMaximum(sampleCountX - 1);
m_axisMaxSliderX->setValue(sampleCountX - 1);
- m_axisMinSliderZ->setMaximum(sampleCountZ - 3);
+ m_axisMinSliderZ->setMaximum(sampleCountZ - 2);
m_axisMinSliderZ->setValue(0);
m_axisMaxSliderZ->setMaximum(sampleCountZ - 1);
m_axisMaxSliderZ->setValue(sampleCountZ - 1);
@@ -131,11 +135,11 @@ void SurfaceGraph::enableHeightMapModel()
m_rangeMinZ = 18.0;
m_stepX = 6.0 / qreal(mapGridCountX - 1);
m_stepZ = 6.0 / qreal(mapGridCountZ - 1);
- m_axisMinSliderX->setMaximum(mapGridCountX - 3);
+ m_axisMinSliderX->setMaximum(mapGridCountX - 2);
m_axisMinSliderX->setValue(0);
m_axisMaxSliderX->setMaximum(mapGridCountX - 1);
m_axisMaxSliderX->setValue(mapGridCountX - 1);
- m_axisMinSliderZ->setMaximum(mapGridCountZ - 3);
+ m_axisMinSliderZ->setMaximum(mapGridCountZ - 2);
m_axisMinSliderZ->setValue(0);
m_axisMaxSliderZ->setMaximum(mapGridCountZ - 1);
m_axisMaxSliderZ->setValue(mapGridCountZ - 1);
@@ -146,8 +150,8 @@ void SurfaceGraph::adjustXMin(int min)
qreal minX = m_stepX * qreal(min) + m_rangeMinX;
int max = m_axisMaxSliderX->value();
- if (min >= (max - 1)) {
- max = min + 2;
+ if (min >= max) {
+ max = min + 1;
m_axisMaxSliderX->setValue(max);
}
qreal maxX = m_stepX * max + m_rangeMinX;
@@ -160,8 +164,8 @@ void SurfaceGraph::adjustXMax(int max)
qreal maxX = m_stepX * qreal(max) + m_rangeMinX;
int min = m_axisMinSliderX->value();
- if (max <= (min + 1)) {
- min = max - 2;
+ if (max <= min) {
+ min = max - 1;
m_axisMinSliderX->setValue(min);
}
qreal minX = m_stepX * min + m_rangeMinX;
@@ -174,8 +178,8 @@ void SurfaceGraph::adjustZMin(int min)
qreal minZ = m_stepZ * qreal(min) + m_rangeMinZ;
int max = m_axisMaxSliderZ->value();
- if (min >= (max - 1)) {
- max = min + 2;
+ if (min >= max) {
+ max = min + 1;
m_axisMaxSliderZ->setValue(max);
}
qreal maxZ = m_stepZ * max + m_rangeMinZ;
@@ -188,8 +192,8 @@ void SurfaceGraph::adjustZMax(int max)
qreal maxX = m_stepZ * qreal(max) + m_rangeMinZ;
int min = m_axisMinSliderZ->value();
- if (max <= (min + 1)) {
- min = max - 2;
+ if (max <= min) {
+ min = max - 1;
m_axisMinSliderZ->setValue(min);
}
qreal minX = m_stepZ * min + m_rangeMinZ;
diff --git a/src/datavisualization/axis/q3dabstractaxis.cpp b/src/datavisualization/axis/q3dabstractaxis.cpp
index 07761d0c..8b07cd39 100644
--- a/src/datavisualization/axis/q3dabstractaxis.cpp
+++ b/src/datavisualization/axis/q3dabstractaxis.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DAbstractAxis
* \inmodule QtDataVisualization
* \brief Q3DAbstractAxis is base class for axes of a graph.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* You should not need to use this class directly, but one of its subclasses instead.
*
@@ -34,7 +34,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype AbstractAxis3D
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates Q3DAbstractAxis
diff --git a/src/datavisualization/axis/q3dcategoryaxis.cpp b/src/datavisualization/axis/q3dcategoryaxis.cpp
index 05f52cdc..866399f5 100644
--- a/src/datavisualization/axis/q3dcategoryaxis.cpp
+++ b/src/datavisualization/axis/q3dcategoryaxis.cpp
@@ -27,7 +27,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DCategoryAxis
* \inmodule QtDataVisualization
* \brief The Q3DCategoryAxis class is used for manipulating an axis of a graph.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* Q3DCategoryAxis provides an axis that can be given labels. The axis is divided into equal-sized
* categories based on the data window size defined by setting the axis range.
@@ -38,7 +38,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype CategoryAxis3D
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates Q3DCategoryAxis
@@ -51,7 +51,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmlproperty list CategoryAxis3D::categoryLabels
* Defines labels for axis applied to categories. If there are fewer labels than categories, the
- * remaining ones do not have a label. If category labels are not explicitly defined, labels are
+ * remaining ones do not have a label. If category labels are not defined explicitly, labels are
* generated from the data row and column labels.
*/
@@ -74,7 +74,7 @@ Q3DCategoryAxis::~Q3DCategoryAxis()
* \property Q3DCategoryAxis::categoryLabels
*
* Defines labels for axis applied to categories. If there are fewer labels than categories, the
- * remaining ones do not have a label. If category labels are not explicitly defined, labels are
+ * remaining ones do not have a label. If category labels are not defined explicitly, labels are
* generated from the data row and column labels.
*
* \note CategoryLabels actually reads/writes the Q3DAbstractAxis::labels property,
@@ -134,7 +134,7 @@ Q3DCategoryAxisPrivate::~Q3DCategoryAxisPrivate()
/*!
* \internal
* Controller uses this function to set labels from data proxy as category labels.
- * If the labels have been explicitly set by user, data proxy labels are not used.
+ * If the labels have been set explicitly by the user, data proxy labels are not used.
*/
void Q3DCategoryAxisPrivate::setDataLabels(const QStringList &labels)
{
diff --git a/src/datavisualization/axis/q3dvalueaxis.cpp b/src/datavisualization/axis/q3dvalueaxis.cpp
index 5e38e4ca..1b18dadb 100644
--- a/src/datavisualization/axis/q3dvalueaxis.cpp
+++ b/src/datavisualization/axis/q3dvalueaxis.cpp
@@ -26,7 +26,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DValueAxis
* \inmodule QtDataVisualization
* \brief The Q3DValueAxis class is used for manipulating an axis of a graph.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* Q3DValueAxis provides an axis that can be given a range of values and segment and subsegment
* counts to divide the range into.
@@ -38,7 +38,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ValueAxis3D
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates Q3DValueAxis
diff --git a/src/datavisualization/data/qabstractdatamapping.cpp b/src/datavisualization/data/qabstractdatamapping.cpp
index 892d2f94..a0698810 100644
--- a/src/datavisualization/data/qabstractdatamapping.cpp
+++ b/src/datavisualization/data/qabstractdatamapping.cpp
@@ -24,7 +24,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QAbstractDataMapping
* \inmodule QtDataVisualization
* \brief Abstract base class for QtDataVisualization data mapping classes.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* Data mapping classes provide a way to map data from an external data source to one of
* QtDataVisualization data proxies.
diff --git a/src/datavisualization/data/qabstractdataproxy.cpp b/src/datavisualization/data/qabstractdataproxy.cpp
index 8ccb0d7a..2e4556fd 100644
--- a/src/datavisualization/data/qabstractdataproxy.cpp
+++ b/src/datavisualization/data/qabstractdataproxy.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QAbstractDataProxy
* \inmodule QtDataVisualization
* \brief Base class for all QtDataVisualization data proxies.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* You use the visualization type specific inherited classes instead of the base class.
* \sa QBarDataProxy, QScatterDataProxy, QSurfaceDataProxy, {Qt Data Visualization Data Handling}
@@ -33,7 +33,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype AbstractDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QAbstractDataProxy
@@ -52,7 +52,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \qmlproperty string AbstractDataProxy::itemLabelFormat
*
* Label format for data items in this proxy. This format is used for single item labels,
- * e.g. when an item is selected. How the format is interpreted depends on proxy type. See
+ * for example, when an item is selected. How the format is interpreted depends on proxy type. See
* each proxy class documentation for more information.
*/
@@ -101,7 +101,7 @@ QAbstractDataProxy::DataType QAbstractDataProxy::type() const
* \property QAbstractDataProxy::itemLabelFormat
*
* Sets label \a format for data items in this proxy. This format is used for single item labels,
- * e.g. when an item is selected. How the format is interpreted depends on proxy type. See
+ * for example, when an item is selected. How the format is interpreted depends on proxy type. See
* each proxy class documentation for more information.
*
* \sa QBarDataProxy, QScatterDataProxy, QSurfaceDataProxy
diff --git a/src/datavisualization/data/qbardataitem.cpp b/src/datavisualization/data/qbardataitem.cpp
index 2803c01a..a474d785 100644
--- a/src/datavisualization/data/qbardataitem.cpp
+++ b/src/datavisualization/data/qbardataitem.cpp
@@ -24,7 +24,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QBarDataItem
* \inmodule QtDataVisualization
* \brief The QBarDataItem class provides a container for resolved data to be added to bar graphs.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* A QBarDataItem holds data for a single rendered bar in a graph.
* Bar data proxies parse data into QBarDataItem instances for visualizing.
diff --git a/src/datavisualization/data/qbardataproxy.cpp b/src/datavisualization/data/qbardataproxy.cpp
index 2ec38980..08d8151b 100644
--- a/src/datavisualization/data/qbardataproxy.cpp
+++ b/src/datavisualization/data/qbardataproxy.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QBarDataProxy
* \inmodule QtDataVisualization
* \brief Base proxy class for Q3DBars.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QBarDataProxy handles adding, inserting, changing and removing rows of data.
*
@@ -74,14 +74,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype BarDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QBarDataProxy
* \inherits AbstractDataProxy
* \brief Base proxy type for Bars3D.
*
- * This type handles adding, inserting, changing and removing rows of data with Qt Quick 2.
+ * This type handles adding, inserting, changing, and removing rows of data with Qt Quick 2.
*
* This type is uncreatable, but contains properties that are exposed via subtypes.
*
@@ -141,8 +141,8 @@ void QBarDataProxy::resetArray()
}
/*!
- * Takes ownership of the \a newArray. Clears the existing array and if the \a newArray is
- * different than the existing array. If it's the same array, this just triggers arrayReset()
+ * Takes ownership of the \a newArray. Clears the existing array if the \a newArray is
+ * different from the existing array. If it's the same array, this just triggers arrayReset()
* signal.
* Passing null array deletes the old array and creates a new empty array.
* Row and column labels are not affected.
@@ -154,10 +154,10 @@ void QBarDataProxy::resetArray(QBarDataArray *newArray)
}
/*!
- * Takes ownership of the \a newArray. Clears the existing array and if the \a newArray is
- * different than the existing array. If it's the same array, this just triggers arrayReset()
+ * Takes ownership of the \a newArray. Clears the existing array if the \a newArray is
+ * different from the existing array. If it's the same array, this just triggers arrayReset()
* signal.
- * Passing null array deletes the old array and creates a new empty array.
+ * Passing a null array deletes the old array and creates a new empty array.
* The \a rowLabels and \a columnLabels lists specify the new labels for rows and columns.
*/
void QBarDataProxy::resetArray(QBarDataArray *newArray, const QStringList &rowLabels,
@@ -388,7 +388,7 @@ const QBarDataArray *QBarDataProxy::array() const
}
/*!
- * \return pointer to the row at \a rowIndex. It is guaranteed to be valid only until next call
+ * \return pointer to the row at \a rowIndex. It is guaranteed to be valid only until the next call
* that modifies data.
*/
const QBarDataRow *QBarDataProxy::rowAt(int rowIndex) const
@@ -400,7 +400,7 @@ const QBarDataRow *QBarDataProxy::rowAt(int rowIndex) const
/*!
* \return pointer to the item at \a rowIndex, \a columnIndex. It is guaranteed to be valid only
- * until next call that modifies data.
+ * until the next call that modifies data.
*/
const QBarDataItem *QBarDataProxy::itemAt(int rowIndex, int columnIndex) const
{
diff --git a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
index 518e69eb..cd63e603 100644
--- a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
@@ -28,7 +28,7 @@ const float defaultMaxValue = 10.0f;
* \class QHeightMapSurfaceDataProxy
* \inmodule QtDataVisualization
* \brief Base proxy class for Q3DSurface.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QHeightMapSurfaceDataProxy takes care of surface related height map data handling. It provides a
* way for giving the surface plot a height map to be visualized.
@@ -43,7 +43,7 @@ const float defaultMaxValue = 10.0f;
/*!
* \qmltype HeightMapSurfaceDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QHeightMapSurfaceDataProxy
@@ -168,7 +168,7 @@ QHeightMapSurfaceDataProxy::~QHeightMapSurfaceDataProxy()
* QImage::Format_RGB32 in grayscale.
*
* The height of the image is read from the red component of the pixels if the image is in grayscale,
- * otherwise it is an average calculated from red, green and blue components of the pixels. Using
+ * otherwise it is an average calculated from red, green, and blue components of the pixels. Using
* grayscale images may improve data conversion speed for large images.
*
* Not recommended formats: all mono formats (for example QImage::Format_Mono).
diff --git a/src/datavisualization/data/qitemmodelbardatamapping.cpp b/src/datavisualization/data/qitemmodelbardatamapping.cpp
index fc6f8f54..37bd7bf1 100644
--- a/src/datavisualization/data/qitemmodelbardatamapping.cpp
+++ b/src/datavisualization/data/qitemmodelbardatamapping.cpp
@@ -24,7 +24,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelBarDataMapping
* \inmodule QtDataVisualization
* \brief Item model mapping for Q3DBars.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelBarDataMapping is used to map roles of QAbstractItemModel to rows, columns, and values
* of Q3DBars. There are three ways to use QItemModelBarDataMapping:
@@ -45,7 +45,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
*
* For example, assume that you have a custom QAbstractItemModel for storing various monthly values
* related to a business.
- * Each item in the model has roles "year", "month", "income", and "expenses".
+ * Each item in the model has the roles "year", "month", "income", and "expenses".
* You could do the following to display the data in a bar graph:
*
* \snippet doc_src_qtdatavisualization.cpp 3
@@ -55,14 +55,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype BarDataMapping
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelBarDataMapping
* \brief Item model mapping for Bars3D.
*
* This type is used to map roles of AbstractItemModel to rows, columns, and values of Bars3D. For
- * more complete description, see QItemModelBarDataMapping.
+ * a more complete description, see QItemModelBarDataMapping.
*
* Usage example:
*
@@ -89,13 +89,13 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmlproperty list BarDataMapping::rowCategories
* The row categories of the mapping. Only items with row roles that are found in this list are
- * included when data is resolved. The rows are ordered in the same order as they are in this list.
+ * included when the data is resolved. The rows are ordered in the same order as they are in this list.
*/
/*!
* \qmlproperty list BarDataMapping::columnCategories
* The column categories of the mapping. Only items with column roles that are found in this list are
- * included when data is resolved. The columns are ordered in the same order as they are in this list.
+ * included when the data is resolved. The columns are ordered in the same order as they are in this list.
*/
/*!
@@ -108,7 +108,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \qmlproperty list BarDataMapping::autoRowCategories
* When set to true, the mapping ignores any explicitly set row categories
* and overwrites them with automatically generated ones whenever the
- * data from model is resolved. Defaults to true.
+ * data from the model is resolved. Defaults to true.
*/
/*!
@@ -354,7 +354,7 @@ void QItemModelBarDataMapping::remap(const QString &rowRole,
* /return index of the specified \a category in row categories list.
* If the row categories list is empty, -1 is returned.
* \note If the automatic row categories generation is in use, this method will
- * not return valid index before the data in the model is resolved for the first time.
+ * not return a valid index before the data in the model is resolved for the first time.
*/
int QItemModelBarDataMapping::rowCategoryIndex(const QString &category)
{
@@ -365,7 +365,7 @@ int QItemModelBarDataMapping::rowCategoryIndex(const QString &category)
* /return index of the specified \a category in column categories list.
* If the category is not found, -1 is returned.
* \note If the automatic column categories generation is in use, this method will
- * not return valid index before the data in the model is resolved for the first time.
+ * not return a valid index before the data in the model is resolved for the first time.
*/
int QItemModelBarDataMapping::columnCategoryIndex(const QString &category)
{
diff --git a/src/datavisualization/data/qitemmodelbardataproxy.cpp b/src/datavisualization/data/qitemmodelbardataproxy.cpp
index b0fa74b6..bee87606 100644
--- a/src/datavisualization/data/qitemmodelbardataproxy.cpp
+++ b/src/datavisualization/data/qitemmodelbardataproxy.cpp
@@ -26,13 +26,13 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelBarDataProxy
* \inmodule QtDataVisualization
* \brief Proxy class for presenting data in item models with Q3DBars.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelBarDataProxy allows you to use QAbstractItemModel derived models as a data source
* for Q3DBars. It uses QItemModelBarDataMapping instance to map data from the model to Q3DBars
* graph.
*
- * Data is resolved asynchronously whenever the mapping or the model changes.
+ * The data is resolved asynchronously whenever the mapping or the model changes.
* QBarDataProxy::arrayReset() is emitted when the data has been resolved.
*
* \sa QItemModelBarDataMapping, {Qt Data Visualization Data Handling}
@@ -40,7 +40,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ItemModelBarDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelBarDataProxy
diff --git a/src/datavisualization/data/qitemmodelscatterdatamapping.cpp b/src/datavisualization/data/qitemmodelscatterdatamapping.cpp
index f9ef6d04..6705588d 100644
--- a/src/datavisualization/data/qitemmodelscatterdatamapping.cpp
+++ b/src/datavisualization/data/qitemmodelscatterdatamapping.cpp
@@ -24,7 +24,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelScatterDataMapping
* \inmodule QtDataVisualization
* \brief Item model mapping for Q3DScatter.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelScatterDataMapping is used to map roles of QAbstractItemModel to the XYZ-values
* of Q3DScatter points.
@@ -34,7 +34,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* that can be mapped to X, Y, and Z-values for the scatter points.
*
* For example, assume that you have a custom QAbstractItemModel for storing various measurements
- * done on material samples, providing data for roles such as "density", "hardness" and
+ * done on material samples, providing data for roles such as "density", "hardness", and
* "conductivity". You could visualize these properties on a scatter graph:
*
* \snippet doc_src_qtdatavisualization.cpp 4
@@ -44,14 +44,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ScatterDataMapping
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelScatterDataMapping
* \brief Item model mapping for Scatter3D.
*
* This type is used to map roles of AbstractItemModel to the XYZ-values of Scatter3D points. For
- * more complete description, see QItemModelScatterDataMapping.
+ * a more complete description, see QItemModelScatterDataMapping.
*
* Usage example:
*
diff --git a/src/datavisualization/data/qitemmodelscatterdataproxy.cpp b/src/datavisualization/data/qitemmodelscatterdataproxy.cpp
index b037d4d1..147b16da 100644
--- a/src/datavisualization/data/qitemmodelscatterdataproxy.cpp
+++ b/src/datavisualization/data/qitemmodelscatterdataproxy.cpp
@@ -26,12 +26,12 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelScatterDataProxy
* \inmodule QtDataVisualization
* \brief Proxy class for presenting data in item models with Q3DScatter.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelScatterDataProxy allows you to use QAbstractItemModel derived models as a data source
* for Q3DScatter. It maps roles defined in QItemModelScatterDataMapping to roles in the model.
*
- * Data is resolved asynchronously whenever the mapping or the model changes.
+ * The data is resolved asynchronously whenever the mapping or the model changes.
* QScatterDataProxy::arrayReset() is emitted when the data has been resolved.
*
* /sa {Qt Data Visualization Data Handling}
@@ -39,7 +39,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ItemModelScatterDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelScatterDataProxy
@@ -48,7 +48,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
*
* This type allows you to use AbstractItemModel derived models as a data source for Scatter3D.
*
- * Data is resolved asynchronously whenever the mapping or the model changes.
+ * The data is resolved asynchronously whenever the mapping or the model changes.
* QScatterDataProxy::arrayReset() is emitted when the data has been resolved.
*
* Usage example:
@@ -99,7 +99,7 @@ QItemModelScatterDataProxy::~QItemModelScatterDataProxy()
/*!
* \property QItemModelScatterDataProxy::itemModel
*
- * Defines item model. Does not take ownership of the model, but does connect to it to listen for
+ * Defines the item model. Does not take ownership of the model, but does connect to it to listen for
* changes.
*/
void QItemModelScatterDataProxy::setItemModel(const QAbstractItemModel *itemModel)
@@ -115,7 +115,7 @@ const QAbstractItemModel *QItemModelScatterDataProxy::itemModel() const
/*!
* \property QItemModelScatterDataProxy::activeMapping
*
- * Defines data mapping. Proxy takes ownership of the \a mapping.
+ * Defines the data mapping. The proxy takes ownership of the \a mapping.
* Modifying a mapping that is set to the proxy will trigger data set re-resolving.
*/
void QItemModelScatterDataProxy::setActiveMapping(QItemModelScatterDataMapping *mapping)
diff --git a/src/datavisualization/data/qitemmodelsurfacedatamapping.cpp b/src/datavisualization/data/qitemmodelsurfacedatamapping.cpp
index 5388ec18..eead9a8e 100644
--- a/src/datavisualization/data/qitemmodelsurfacedatamapping.cpp
+++ b/src/datavisualization/data/qitemmodelsurfacedatamapping.cpp
@@ -24,7 +24,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelSurfaceDataMapping
* \inmodule QtDataVisualization
* \brief Item model mapping for Q3DSurface.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelSurfaceDataMapping is used to map roles of QAbstractItemModel to rows, columns, and values
* of Q3DSurface. There are three ways to use QItemModelSurfaceDataMapping:
@@ -44,7 +44,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* columns.
*
* For example, assume that you have a custom QAbstractItemModel storing surface topography data.
- * Each item in the model has roles "longitude", "latitude" and "height". The item model already
+ * Each item in the model has the roles "longitude", "latitude", and "height". The item model already
* contains the data properly sorted so that longitudes and latitudes are first encountered in
* correct order, which enables us to utilize the row and column category autogeneration.
* You could do the following to display the data in a surface graph:
@@ -56,14 +56,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype SurfaceDataMapping
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelSurfaceDataMapping
* \brief Item model mapping for Surface3D.
*
* This type is used to map roles of AbstractItemModel to rows, columns, and values of Surface3D.
- * For more complete description, see QItemModelSurfaceDataMapping.
+ * For a more complete description, see QItemModelSurfaceDataMapping.
*
* Usage example:
*
@@ -142,7 +142,7 @@ QItemModelSurfaceDataMapping::QItemModelSurfaceDataMapping(const QString &valueR
}
/*!
- * Constructs QItemModelSurfaceDataMapping with \a rowRole, \a columnRole, \a valueRole
+ * Constructs QItemModelSurfaceDataMapping with \a rowRole, \a columnRole, \a valueRole,
* and the given \a parent.
*/
QItemModelSurfaceDataMapping::QItemModelSurfaceDataMapping(const QString &rowRole,
@@ -158,7 +158,7 @@ QItemModelSurfaceDataMapping::QItemModelSurfaceDataMapping(const QString &rowRol
/*!
* Constructs QItemModelSurfaceDataMapping with \a rowRole, \a columnRole, \a valueRole,
- * \a rowCategories, \a columnCategories and the given \a parent. This constructor
+ * \a rowCategories, \a columnCategories, and the given \a parent. This constructor
* also sets autoRowCategories and autoColumnCategories to false.
*/
QItemModelSurfaceDataMapping::QItemModelSurfaceDataMapping(const QString &rowRole,
@@ -359,7 +359,7 @@ void QItemModelSurfaceDataMapping::remap(const QString &rowRole,
* /return index of the specified \a category in row categories list.
* If the row categories list is empty, -1 is returned.
* \note If the automatic row categories generation is in use, this method will
- * not return valid index before the data in the model is resolved for the first time.
+ * not return a valid index before the data in the model is resolved for the first time.
*/
int QItemModelSurfaceDataMapping::rowCategoryIndex(const QString &category)
{
@@ -369,7 +369,7 @@ int QItemModelSurfaceDataMapping::rowCategoryIndex(const QString &category)
/*!
* /return index of the specified \a category in column categories list.
* \note If the automatic column categories generation is in use, this method will
- * not return valid index before the data in the model is resolved for the first time.
+ * not return a valid index before the data in the model is resolved for the first time.
*/
int QItemModelSurfaceDataMapping::columnCategoryIndex(const QString &category)
{
diff --git a/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp b/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp
index f6403e9b..750de4e2 100644
--- a/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp
@@ -28,7 +28,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QItemModelSurfaceDataProxy
* \inmodule QtDataVisualization
* \brief Proxy class for presenting data in item models with Q3DSurface.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QItemModelSurfaceDataProxy allows you to use QAbstractItemModel derived models as a data source
* for Q3DSurface. It maps roles defined in QItemModelSurfaceDataMapping to roles in the model.
@@ -41,7 +41,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ItemModelSurfaceDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QItemModelSurfaceDataProxy
diff --git a/src/datavisualization/data/qscatterdataitem.cpp b/src/datavisualization/data/qscatterdataitem.cpp
index 055a9dad..5c6f1f66 100644
--- a/src/datavisualization/data/qscatterdataitem.cpp
+++ b/src/datavisualization/data/qscatterdataitem.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \inmodule QtDataVisualization
* \brief The QScatterDataItem class provides a container for resolved data to be added to scatter
* graphs.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* A QScatterDataItem holds data for a single rendered item in a scatter graph.
* Scatter data proxies parse data into QScatterDataItem instances for visualizing.
diff --git a/src/datavisualization/data/qscatterdataproxy.cpp b/src/datavisualization/data/qscatterdataproxy.cpp
index 4d83da8d..479fdd75 100644
--- a/src/datavisualization/data/qscatterdataproxy.cpp
+++ b/src/datavisualization/data/qscatterdataproxy.cpp
@@ -25,9 +25,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QScatterDataProxy
* \inmodule QtDataVisualization
* \brief Base proxy class for Q3DScatter.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
- * QScatterDataProxy handles adding, inserting, changing and removing data items.
+ * QScatterDataProxy handles adding, inserting, changing, and removing data items.
*
* QScatterDataProxy takes ownership of all QScatterDataArrays and QScatterDataItems passed to it.
*
@@ -58,14 +58,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype ScatterDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QScatterDataProxy
* \inherits AbstractDataProxy
* \brief Base proxy class for Scatter3D.
*
- * This type handles adding, inserting, changing and removing data items.
+ * This type handles adding, inserting, changing, and removing data items.
*
* This type is uncreatable, but contains properties that are exposed via subtypes.
*
@@ -103,10 +103,10 @@ QScatterDataProxy::~QScatterDataProxy()
}
/*!
- * Takes ownership of the \a newArray. Clears the existing array and if the \a newArray is
- * different than the existing array. If it's the same array, this just triggers arrayReset()
+ * Takes ownership of the \a newArray. Clears the existing array if the \a newArray is
+ * different from the existing array. If it's the same array, this just triggers arrayReset()
* signal.
- * Passing null array deletes the old array and creates a new empty array.
+ * Passing a null array deletes the old array and creates a new empty array.
*/
void QScatterDataProxy::resetArray(QScatterDataArray *newArray)
{
diff --git a/src/datavisualization/data/qsurfacedataitem.cpp b/src/datavisualization/data/qsurfacedataitem.cpp
index 19f8f347..f5f91464 100644
--- a/src/datavisualization/data/qsurfacedataitem.cpp
+++ b/src/datavisualization/data/qsurfacedataitem.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \inmodule QtDataVisualization
* \brief The QSurfaceDataItem class provides a container for resolved data to be added to surface
* graphs.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* A QSurfaceDataItem holds data for a single vertex in surface graph.
* Surface data proxies parse data into QSurfaceDataItem instances for visualizing.
diff --git a/src/datavisualization/data/qsurfacedataproxy.cpp b/src/datavisualization/data/qsurfacedataproxy.cpp
index 72f33de7..1f152978 100644
--- a/src/datavisualization/data/qsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qsurfacedataproxy.cpp
@@ -25,7 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class QSurfaceDataProxy
* \inmodule QtDataVisualization
* \brief Base proxy class for Q3DSurface.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QSurfaceDataProxy takes care of surface related data handling. The QSurfaceDataProxy handles the data
* in rows and for this it provides two auxiliary typedefs. QSurfaceDataArray is a QList for
@@ -33,7 +33,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* objects. See Q3DSurface documentation and basic sample code there how to feed the data for the
* QSurfaceDataProxy.
*
- * All rows must have same number of items.
+ * All rows must have the same number of items.
*
* When determining what rows and columns are visible, the first item in each row and the first item in
* each column determine if the whole row or column is visible, even if other items in the row or column
@@ -66,7 +66,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
* \qmltype SurfaceDataProxy
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \instantiates QSurfaceDataProxy
@@ -78,7 +78,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
*
* This type is uncreatable, but contains properties that are exposed via subtypes.
*
- * For more complete description, see QSurfaceDataProxy.
+ * For a more complete description, see QSurfaceDataProxy.
*
* \sa ItemModelSurfaceDataProxy, {Qt Data Visualization Data Handling}
*/
@@ -117,10 +117,10 @@ QSurfaceDataProxy::~QSurfaceDataProxy()
}
/*!
- * Takes ownership of the \a newArray. Clears the existing array and if the \a newArray is
- * different than the existing array. If it's the same array, this just triggers arrayReset()
+ * Takes ownership of the \a newArray. Clears the existing array if the \a newArray is
+ * different from the existing array. If it's the same array, this just triggers arrayReset()
* signal.
- * Passing null array deletes the old array and creates a new empty array.
+ * Passing a null array deletes the old array and creates a new empty array.
* All rows in \a newArray must be of same length.
*/
void QSurfaceDataProxy::resetArray(QSurfaceDataArray *newArray)
@@ -163,7 +163,7 @@ int QSurfaceDataProxy::columnCount() const
}
/*!
- * \return pointer to the item at \a index. It is guaranteed to be valid only until next call that
+ * \return pointer to the item at \a index. It is guaranteed to be valid only until the next call that
* modifies data.
*/
const QSurfaceDataItem *QSurfaceDataProxy::itemAt(int index) const
@@ -190,7 +190,7 @@ const QSurfaceDataProxyPrivate *QSurfaceDataProxy::dptrc() const
/*!
* \fn void QSurfaceDataProxy::arrayReset()
*
- * Emitted when data array is reset.
+ * Emitted when the data array is reset.
* If you change the whole array contents without calling resetArray(), you need to
* emit this signal yourself or the graph won't get updated.
*/
diff --git a/src/datavisualization/doc/qtdatavisualization.qdocconf b/src/datavisualization/doc/qtdatavisualization.qdocconf
index 14dcb3cd..fffcd3c4 100644
--- a/src/datavisualization/doc/qtdatavisualization.qdocconf
+++ b/src/datavisualization/doc/qtdatavisualization.qdocconf
@@ -41,7 +41,7 @@ qhp.qtdatavisualization.subprojects.classes.selectors = class
qhp.qtdatavisualization.subprojects.classes.sortPages = true
qhp.qtdatavisualization.subprojects.types.title = QML Types
qhp.qtdatavisualization.subprojects.types.indexTitle = Qt Data Visualization QML Types
-qhp.qtdatavisualization.subprojects.types.selectors = class
+qhp.qtdatavisualization.subprojects.types.selectors = fake:qmlclass
qhp.qtdatavisualization.subprojects.types.sortPages = true
HTML.footer = \
diff --git a/src/datavisualization/doc/snippets/doc_src_q3dbars_construction.cpp b/src/datavisualization/doc/snippets/doc_src_q3dbars_construction.cpp
index a5615601..7c47183c 100644
--- a/src/datavisualization/doc/snippets/doc_src_q3dbars_construction.cpp
+++ b/src/datavisualization/doc/snippets/doc_src_q3dbars_construction.cpp
@@ -26,19 +26,19 @@ int main(int argc, char **argv)
QGuiApplication app(argc, argv);
//! [4]
- Q3DBars *bars = new Q3DBars();
+ Q3DBars bars;
//! [4]
//! [0]
- bars->rowAxis()->setRange(0, 4);
- bars->columnAxis()->setRange(0, 4);
+ bars.rowAxis()->setRange(0, 4);
+ bars.columnAxis()->setRange(0, 4);
//! [0]
//! [1]
- QBarDataRow data;
- data << 1.0 << 3.0 << 7.5 << 5.0 << 2.2;
- bars->activeDataProxy()->addRow(&data);
+ QBarDataRow *data = new QBarDataRow;
+ *data << 1.0 << 3.0 << 7.5 << 5.0 << 2.2;
+ bars.activeDataProxy()->addRow(data);
//! [1]
//! [2]
- bars->show();
+ bars.show();
//! [2]
return app.exec();
diff --git a/src/datavisualization/doc/snippets/doc_src_q3dscatter_construction.cpp b/src/datavisualization/doc/snippets/doc_src_q3dscatter_construction.cpp
index 74691525..cce43fec 100644
--- a/src/datavisualization/doc/snippets/doc_src_q3dscatter_construction.cpp
+++ b/src/datavisualization/doc/snippets/doc_src_q3dscatter_construction.cpp
@@ -26,15 +26,15 @@ int main(int argc, char **argv)
QGuiApplication app(argc, argv);
//! [0]
- Q3DScatter *scatter = new Q3DScatter();
+ Q3DScatter scatter;
//! [0]
//! [1]
QScatterDataArray data;
data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f) << QVector3D(0.0f, -0.3f, 0.2f);
- scatter->activeDataProxy()->addItems(data);
+ scatter.activeDataProxy()->addItems(data);
//! [1]
//! [2]
- scatter->show();
+ scatter.show();
//! [2]
return app.exec();
diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
index f2245c12..456f8ac5 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
@@ -19,7 +19,7 @@
/*!
\title Qt Data Visualization
\page qtdatavisualization-index.html
- \brief QtDataVisualization module provides functionality for 3D visualization.
+ \brief Provides functionality for 3D visualization.
Qt Data Visualization module provides a way to visualize data in 3D.
@@ -28,7 +28,7 @@
\list
\li Multiple data visualization options: 3D Bars, 3D Scatter, and 3D Surface
\li 2D slice views of the 3D data
- \li Interactive data: Rotate, zoom, and highlight data using mouse or touch
+ \li Interactive data: rotate, zoom, and highlight data using mouse or touch
\li Uses OpenGL for rendering the data
\li QML2 support
\li Customizable axes for data - control viewable data window with axis ranges
@@ -50,14 +50,14 @@
\snippet doc_src_qtdatavisualization.cpp 0
- \note If you are using a few classes from this module, we recommend including those specific
- classes only instead of the whole module.
+ \note If you are only using a few classes from this module, we recommend including only those
+ specific classes instead of the whole module.
- To link against Qt Data Visualization module, add this line to your \c qmake project file:
+ To link against the Qt Data Visualization module, add this line to your \c qmake project file:
\snippet doc_src_qtdatavisualization.pro 0
- See \l{Qt Data Visualization Getting Started}{Getting started} page for further information
+ See the \l{Qt Data Visualization Getting Started}{Getting started} page for further information on
how to use Qt Data Visualization in your application.
\section1 Articles
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
index 7a0d2c4a..6d85a1bd 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
@@ -18,17 +18,13 @@
/*!
\qmltype AbstractGraph3D
- \inqmlmodule com.digia.QtDataVisualization 1.0
+ \inqmlmodule com.digia.QtDataVisualization
\since com.digia.QtDataVisualization 1.0
\ingroup datavisualization_qml
\brief Base type for 3D visualizations.
This type is the base type for all 3D visualizations in QtDataVisualization.
- It resides in the data visualization module that can be imported like this:
-
- \snippet doc_src_qmldatavisualization.cpp 0
-
Note that this type is uncreatable, but contains properties that are shared between
the 3D visualizations.
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
index 213542b9..5e6ef522 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
@@ -19,7 +19,7 @@
/*!
* \qmltype Bars3D
* \inherits AbstractGraph3D
- * \inqmlmodule com.digia.QtDataVisualization 1.0
+ * \inqmlmodule com.digia.QtDataVisualization
* \since com.digia.QtDataVisualization 1.0
* \ingroup datavisualization_qml
* \brief 3D bar graph.
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-colorgradient.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-colorgradient.qdoc
index f8edf492..5c823d25 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-colorgradient.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-colorgradient.qdoc
@@ -18,7 +18,7 @@
/*!
\qmltype ColorGradientStop
- \inqmlmodule com.digia.QtDataVisualization 1.0
+ \inqmlmodule com.digia.QtDataVisualization
\since com.digia.QtDataVisualization 1.0
\ingroup datavisualization_qml
\brief Defines the color at a position in ColorGradient.
@@ -50,7 +50,7 @@
/*!
\qmltype ColorGradient
- \inqmlmodule com.digia.QtDataVisualization 1.0
+ \inqmlmodule com.digia.QtDataVisualization
\since com.digia.QtDataVisualization 1.0
\ingroup datavisualization_qml
\brief Defines a color gradient.
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc
index 2839468e..e583a807 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc
@@ -19,7 +19,7 @@
/*!
\qmltype Scatter3D
\inherits AbstractGraph3D
- \inqmlmodule com.digia.QtDataVisualization 1.0
+ \inqmlmodule com.digia.QtDataVisualization
\since com.digia.QtDataVisualization 1.0
\ingroup datavisualization_qml
\brief 3D scatter graph.
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
index 3669c1cd..c55b7ec1 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
@@ -19,14 +19,14 @@
/*!
\qmltype Surface3D
\inherits AbstractGraph3D
- \inqmlmodule com.digia.QtDataVisualization 1.0
+ \inqmlmodule com.digia.QtDataVisualization
\since com.digia.QtDataVisualization 1.0
\ingroup datavisualization_qml
- \brief 3D surface graph.
+ \brief Describes the usage of the 3D surface graph.
This type enables developers to render surface plots in 3D with Qt Quick 2.
- You will need to import data visualization module to use this type:
+ You will need to import the data visualization module to use this type:
\snippet doc_src_qmldatavisualization.cpp 0
@@ -53,7 +53,7 @@
If an axis is not given, a temporary default axis with no labels and automatically adjusting
range is created.
- This temporary axis is destroyed if another axis is explicitly set to same orientation.
+ This temporary axis is destroyed if another axis is explicitly set to the same orientation.
*/
/*!
@@ -62,7 +62,7 @@
If an axis is not given, a temporary default axis with no labels and automatically adjusting
range is created.
- This temporary axis is destroyed if another axis is explicitly set to same orientation.
+ This temporary axis is destroyed if another axis is explicitly set to the same orientation.
*/
/*!
@@ -71,17 +71,17 @@
If an axis is not given, a temporary default axis with no labels and automatically adjusting
range is created.
- This temporary axis is destroyed if another axis is explicitly set to same orientation.
+ This temporary axis is destroyed if another axis is explicitly set to the same orientation.
*/
/*!
\qmlproperty bool Surface3D::smoothSurfaceEnabled
- Smoothing of surface. If false, shading of the surface is flat.
+ The smoothing of surface. If false, the shading of the surface is flat.
*/
/*!
\qmlproperty bool Surface3D::surfaceGridEnabled
- Surface grid visibility. If false, no surface grid is drawn.
+ The surface grid visibility. If false, no surface grid is drawn.
*/
/*!
diff --git a/src/datavisualization/doc/src/qtdatavisualization.qdoc b/src/datavisualization/doc/src/qtdatavisualization.qdoc
index 191c7ba8..393bd6f9 100644
--- a/src/datavisualization/doc/src/qtdatavisualization.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization.qdoc
@@ -23,16 +23,17 @@
\brief C++ classes for the Qt Data Visualization API.
- Qt Data Visualization functionality can be accessed via these C++ classes.
+ The Qt Data Visualization functionality can be accessed via these C++ classes.
*/
/*!
- \group datavisualization_qml
+ \qmlmodule com.digia.QtDataVisualization 1.0
\title Qt Data Visualization QML Types
+ \ingroup qmlmodules
\brief QML types for the Qt Data Visualization API.
- Qt Data Visualization functionality can be accessed via these QML types.
+ The Qt Data Visualization functionality can be accessed via these QML types.
\section1 QML Types
*/
@@ -51,12 +52,12 @@
*/
/*!
- \page qtdatavisualization_getting_started.html
+ \group qtdatavisualization_getting_started
\title Qt Data Visualization Getting Started
\section1 Building Qt Data Visualization
- To build Qt Data Visualization module, set up a command prompt with an environment for
+ To build the Qt Data Visualization module, set up a command prompt with an environment for
building Qt applications, navigate to the directory containing \c qtdatavisualization.pro, and
configure the project with qmake:
\code
@@ -121,8 +122,8 @@
\section1 Running examples
- Qt Data Visualization examples are found under \c examples subdirectory. To build and run a
- single example, e.g. the qmlsurface example, navigate to the example directory and give the
+ Qt Data Visualization examples are found under the \c examples subdirectory. To build and run a
+ single example, for example, the qmlsurface example, navigate to the example directory and enter the
following commands:
\snippet doc_src_qtdatavisualization.cpp 8
@@ -142,12 +143,13 @@
\snippet doc_src_qtdatavisualization.cpp 0
Then, add the sample code found in one of the following pages, depending on what kind of
- visualization you are interested in: \l{How to construct a minimal Q3DBars graph},
+ visualization you are interested in:
+ \l{How to construct a minimal Q3DBars graph},
\l{How to construct a minimal Q3DScatter graph}, or
\l{How to construct a minimal Q3DSurface graph}.
To use Qt Data Visualization graphs in widget based applications, you can use
- QWidget::createWindowContainer() function to wrap the graph into a widget:
+ the QWidget::createWindowContainer() function to wrap the graph into a widget:
\snippet doc_src_qtdatavisualization.cpp 9
@@ -162,8 +164,8 @@
\section1 Data proxies
- The data users wish to visualize comes in many formats, all of which cannot obviously be
- directly supported. Therefore Qt Data Visualization implements data proxies into which
+ The data that users wish to visualize comes in many formats, all of which cannot obviously be
+ directly supported. Therefore, Qt Data Visualization implements data proxies into which
user can feed their data in a known format. Each visualization type has a basic proxy type,
which takes data in a format suitable for that visualization.
For example, the basic proxy for Q3DBars is QBarDataProxy, which stores rows of QBarDataItem
@@ -177,7 +179,7 @@
\note The graph objects can own more than one data proxy, but only one proxy can be
active at a time. If you need to switch back and forth between two different sets of data,
- it may be more efficient to store each set in different proxy and just change the active
+ it may be more efficient to store each set in a different proxy and just change the active
proxy, rather than reset the data in one proxy every time you need to switch.
\section1 Item models and data mapping
@@ -185,8 +187,8 @@
For common use cases, Qt Data Visualization offers specialized proxies. One such case is having
data in an item model (QAbstractItemModel subclass), which is a common way to store data in
Qt applications. Each of the visualization types offers a special proxy and a corresponding mapping
- class for this purpose, e.g. QItemModelBarDataProxy and QItemModelBarDataMapping for Q3DBars.
- These proxies are simple to use - just give them a pointer to the item model containing the
+ class for this purpose, for example, QItemModelBarDataProxy and QItemModelBarDataMapping for Q3DBars.
+ These proxies are simple to use: just give them a pointer to the item model containing the
data and the mapping object containing rules how to map the data into format the basic proxy can
digest.
@@ -196,16 +198,16 @@
and which role specifies the value of the item. When the proxy resolves the data from the model,
it uses these mappings to generate the rows and columns of the bar graph.
- Depending on the visualization type, mapping classes may support other functionality as well,
+ Depending on the visualization type, mapping classes may support other functionalities as well,
such as QItemModelBarDataMapping optionally mapping QAbstractItemModel rows and columns directly
into bar graph rows and columns. See individual mapping classes for more information and examples
- how to use them: QItemModelBarDataMapping, QItemModelScatterDataMapping, and
+ about how to use them: QItemModelBarDataMapping, QItemModelScatterDataMapping, and
QItemModelSurfaceDataMapping.
\section1 Other custom proxies
QHeightMapSurfaceDataProxy is a specialized proxy for generating a surface graph from a
- heightmap image. See QHeightMapSurfaceDataProxy documentation for more information.
+ heightmap image. See the QHeightMapSurfaceDataProxy documentation for more information.
The \l{Custom Proxy Example}{Custom Proxy} example shows how a custom proxy can be created. It
defines a custom data set based on variant lists and an extension of the basic proxy to resolve
@@ -217,13 +219,13 @@
ensure good performance. Since memory allocation is a costly operation, always use
QList::reserve() and QVector::resize() where possible to avoid reallocations when constructing
the array to give to the proxy. If you need to change the entire data set for each frame,
- it is in most cases best to re-use the existing array - especially if the array dimensions do not
+ it is in most cases best to reuse the existing array - especially if the array dimensions do not
change. If you need to add, insert, remove, or change several rows or items for each frame, it
is always more efficient to do it with one method call instead of multiple calls affecting
a single row or item each. For example, adding ten rows with a single QBarDataProxy::addRows() call
is much more efficient than ten separate QBarDataProxy::addRow() calls.
- Bars renderer is optimized to access only data that is within data window and thus should not
+ Bars renderer is optimized to access only data that is within the data window and thus should not
suffer noticeable slowdown even if more data is continually added to the proxy.
Due to the unsorted nature of the scatter data, any change in the data window ranges requires
@@ -231,9 +233,9 @@
continually added to the proxy.
Surface data, while on item level similar to scatter data, is already assigned into rows and
- columns, so the surface renderer can do some optimization by making assumption that the data in
+ columns, so the surface renderer can do some optimization by making the assumption that the data in
rows and columns is sorted along their respective axes, but it is nowhere near as efficient
- as in bars case. Surface rendering can suffer significant slowdown if the data size grows unchecked.
+ as in the bars case. Surface rendering can suffer significant slowdown if the data size grows unchecked.
For the best performance with the scatter and surface graphs, only keep the data you need in the
proxy.
@@ -252,21 +254,21 @@
see QTouch3DInputHandler documentation.
\note In the technology preview version, default input handlers cannot be replaced or even accessed
- via public API. This feature is planned for the final release.
+ via the public API. This feature is planned for the final release.
\section1 Data selection modes
- All visualization types support selecting single data item - a bar, a scatter item, or a surface
+ All visualization types support selecting a single data item - a bar, a scatter item, or a surface
vertex - using mouse, touch, and programmatically via the graph APIs. The selected item is highlighted
in the rendered graph, and selecting causes emission of a graph specific signal for this purpose,
- e.g. Q3DBars::selectedBarPosChanged(), which the application can handle.
+ for example, Q3DBars::selectedBarPosChanged(), which the application can handle.
- \note Surface graph doesn't have fully implemented selection API yet, it only supports
+ \note The surface graph doesn't have a fully implemented selection API yet. It only supports
selection with mouse and touch in the technology preview version.
Bar and surface graphs support slice selection modes, where the selected row or column is drawn
in a separate viewport as a pseudo-2D graph. This makes it easier to see the actual values of
- single row or column.
+ a single row or column.
Bar graph additionally supports simply highlighting the whole row and/or column of the selected bar
without opening the slice view.
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index 50d8d030..2eea6c74 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.cpp
@@ -43,7 +43,7 @@ Bars3DController::Bars3DController(QRect boundRect)
setActiveDataProxy(0);
// Setting a null axis creates a new default axis according to orientation and graph type.
- // Note: These cannot be set in Abstract3DController constructor, as they will call virtual
+ // Note: these cannot be set in the Abstract3DController constructor, as they will call virtual
// functions implemented by subclasses.
setAxisX(0);
setAxisY(0);
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 7863cda3..c7c2f64c 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -84,7 +84,7 @@ Bars3DRenderer::Bars3DRenderer(Bars3DController *controller)
m_scaleX(0),
m_scaleZ(0),
m_scaleFactor(0),
- m_maxSceneSize(40.0),
+ m_maxSceneSize(40.0f),
m_selection(selectionSkipColor),
m_previousSelection(selectionSkipColor),
m_hasHeightAdjustmentChanged(true)
@@ -169,10 +169,11 @@ void Bars3DRenderer::updateDataModel(QBarDataProxy *dataProxy)
m_sliceSelection->clear();
m_cachedColumnCount = newColumns;
- m_cachedRowCount = newRows;
- // TODO: Invent foolproof max scene size formula
- // This seems to work ok if spacing is not negative (and row/column or column/row ratio is not too high)
- m_maxSceneSize = 2 * qSqrt(newColumns * newRows);
+ m_cachedRowCount = newRows;
+ // Calculate max scene size
+ GLfloat sceneRatio = qMin(GLfloat(newColumns) / GLfloat(newRows),
+ GLfloat(newRows) / GLfloat(newColumns));
+ m_maxSceneSize = 2.0f * qSqrt(sceneRatio * newColumns * newRows);
// Calculate here and at setting bar specs
calculateSceneScalingFactors();
}
@@ -180,11 +181,12 @@ void Bars3DRenderer::updateDataModel(QBarDataProxy *dataProxy)
// Update cached data window
int dataRowCount = dataProxy->rowCount();
int dataRowIndex = minRow;
+ int updateSize = 0;
for (int i = 0; i < newRows; i++) {
int j = 0;
if (dataRowIndex < dataRowCount) {
const QBarDataRow *dataRow = dataProxy->rowAt(dataRowIndex);
- int updateSize = qMin((dataRow->size() - minCol), m_renderItemArray[i].size());
+ updateSize = qMin((dataRow->size() - minCol), m_renderItemArray[i].size());
if (dataRow) {
int dataColIndex = minCol;
for (; j < updateSize ; j++) {
@@ -202,6 +204,9 @@ void Bars3DRenderer::updateDataModel(QBarDataProxy *dataProxy)
dataRowIndex++;
}
+ m_renderColumns = updateSize;
+ m_renderRows = qMin((dataRowCount - minRow), m_renderItemArray.size());
+
Abstract3DRenderer::updateDataModel(dataProxy);
}
@@ -219,9 +224,9 @@ void Bars3DRenderer::updateScene(Q3DScene *scene)
if (m_hasHeightAdjustmentChanged) {
// Set initial camera position. Also update if height adjustment has changed.
- scene->activeCamera()->setBaseOrientation(QVector3D(0.0f, 0.0f, cameraDistance + zComp),
- QVector3D(0.0f, -m_yAdjustment, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ scene->activeCamera()->setBaseOrientation(cameraDistanceVector,
+ QVector3D(0.0f, -m_yAdjustment, 0.0f),
+ upVector);
m_hasHeightAdjustmentChanged = false;
}
@@ -241,13 +246,13 @@ void Bars3DRenderer::render(GLuint defaultFboHandle)
// Handle GL state setup for FBO buffers and clearing of the render surface
Abstract3DRenderer::render(defaultFboHandle);
+ // Draw bars scene
+ drawScene(defaultFboHandle);
+
// If slice selection is on, draw the sliced scene
if (m_cachedIsSlicingActivated)
drawSlicedScene(m_axisCacheX.titleItem(), m_axisCacheY.titleItem(), m_axisCacheZ.titleItem());
- // Draw bars scene
- drawScene(defaultFboHandle);
-
// If slicing has been activated by this render pass, we need another render
// Also trigger another render always when slicing changes in general to ensure
// final draw is correct.
@@ -276,21 +281,19 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
// Set up projection matrix
QMatrix4x4 projectionMatrix;
- projectionMatrix.perspective(45.0f, (GLfloat)m_sliceViewPort.width()
- / (GLfloat)m_sliceViewPort.height(), 0.1f, 100.0f);
+ projectionMatrix.perspective(40.0f, (GLfloat)m_sliceViewPort.width()
+ / (GLfloat)m_sliceViewPort.height(), 0.1f, 10.0f);
// Set view matrix
QMatrix4x4 viewMatrix;
// Adjust scaling (zoom rate based on aspect ratio)
- GLfloat camZPosSliced = 5.0f / m_autoScaleAdjustment + zComp;
+ GLfloat camZPosSliced = cameraDistance / m_autoScaleAdjustment;
- viewMatrix.lookAt(QVector3D(0.0f, 0.0f, camZPosSliced),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ viewMatrix.lookAt(QVector3D(0.0f, 0.0f, camZPosSliced), zeroVector, upVector);
// Set light position
- lightPos = QVector3D(0.0f, -m_yAdjustment, zComp);
+ lightPos = QVector3D(0.0f, -m_yAdjustment, camZPosSliced * 2.0f);
// Bind bar shader
m_barShader->bind();
@@ -301,8 +304,15 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
m_barShader->setUniformValue(m_barShader->lightS(), 0.5f);
m_barShader->setUniformValue(m_barShader->ambientS(),
m_cachedTheme.m_ambientStrength * 2.0f);
- // Draw bars
+
// Draw the selected row / column
+ // We need some room for labels underneath; add +0.2f
+ GLfloat barPosYAdjustment = m_yAdjustment / 2.0f - 0.2f;
+ QVector3D modelMatrixScaler(m_scaleX, 0.0f, m_scaleZ);
+ QMatrix4x4 projectionViewMatrix = projectionMatrix * viewMatrix;
+ QVector3D barHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor));
+ QVector3D rowHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightRowColor));
+ QVector3D columnHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightColumnColor));
for (int bar = startBar; bar != stopBar; bar += stepBar) {
BarRenderItem *item = m_sliceSelection->at(bar);
if (!item)
@@ -317,36 +327,37 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- GLfloat barPosY = negativesComp * item->translation().y() - m_yAdjustment / 2.0f + 0.2f; // we need some room for labels underneath; add +0.2f
+ GLfloat barPosY = negativesComp * item->translation().y() - barPosYAdjustment;
if (QDataVis::SelectionModeSliceRow == m_cachedSelectionMode)
barPosX = item->translation().x();
else
- barPosX = -(item->translation().z() - zComp); // flip z; frontmost bar to the left
- modelMatrix.translate(barPosX, barPosY, zComp);
- modelMatrix.scale(QVector3D(m_scaleX, negativesComp * item->height(), m_scaleZ));
- itModelMatrix.scale(QVector3D(m_scaleX, negativesComp * item->height(), m_scaleZ));
+ barPosX = -(item->translation().z()); // flip z; frontmost bar to the left
+ modelMatrix.translate(barPosX, barPosY, 0.0f);
+ modelMatrixScaler.setY(negativesComp * item->height());
+ modelMatrix.scale(modelMatrixScaler);
+ itModelMatrix.scale(modelMatrixScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
#if 0
QVector3D baseColor;
if (m_selection.x() == item->position().x() && m_selection.y() == item->position().y())
- baseColor = Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor);
+ baseColor = barHighlightColor;
else if (QDataVis::SelectionModeSliceRow == m_cachedSelectionMode)
- baseColor = Utils::vectorFromColor(m_cachedTheme.m_highlightRowColor);
+ baseColor = rowHighlightColor;
else
- baseColor = Utils::vectorFromColor(m_cachedTheme.m_highlightColumnColor);
+ baseColor = columnHighlightColor;
QVector3D heightColor = Utils::vectorFromColor(m_cachedTheme.m_heightColor) * item->height();
QVector3D barColor = baseColor + heightColor;
#else
QVector3D barColor;
if (m_selection.x() == item->position().x() && m_selection.y() == item->position().y())
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor);
+ barColor = barHighlightColor;
else if (QDataVis::SelectionModeSliceRow == m_cachedSelectionMode)
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightRowColor);
+ barColor = rowHighlightColor;
else
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightColumnColor);
+ barColor = columnHighlightColor;
#endif
if (item->height() != 0) {
@@ -376,70 +387,57 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
// Draw labels for axes
BarRenderItem *dummyItem(0);
const LabelItem &sliceSelectionLabel = *m_sliceTitleItem;
+ QVector3D positionComp(0.0f, m_autoScaleAdjustment, 0.0f);
+ const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
if (QDataVis::SelectionModeSliceRow == m_cachedSelectionMode) {
if (m_sliceTitleItem) {
m_drawer->drawLabel(*dummyItem, sliceSelectionLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false, Drawer::LabelTop);
+ positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, false, false, Drawer::LabelTop);
}
m_drawer->drawLabel(*dummyItem, zLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false, Drawer::LabelBottom);
+ positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, false, false, Drawer::LabelBottom);
} else {
m_drawer->drawLabel(*dummyItem, xLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false, Drawer::LabelBottom);
+ positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, false, false, Drawer::LabelBottom);
if (m_sliceTitleItem) {
m_drawer->drawLabel(*dummyItem, sliceSelectionLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false, Drawer::LabelTop);
+ positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, false, false, Drawer::LabelTop);
}
}
m_drawer->drawLabel(*dummyItem, yLabel, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 90.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false, Drawer::LabelLeft);
+ positionComp, QVector3D(0.0f, 0.0f, 90.0f), 0,
+ m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera,
+ false, false, Drawer::LabelLeft);
// Draw labels for bars
+ QVector3D valuePositionComp(0.0f, m_yAdjustment, 0.0f);
+ QVector3D negativesRotation(0.0f, 0.0f, 90.0f);
+ QVector3D sliceLabelRotation(0.0f, 0.0f, -45.0f);
+ GLfloat negativesCompPow2 = negativesComp * negativesComp;
for (int col = 0; col < stopBar; col++) {
BarRenderItem *item = m_sliceSelection->at(col);
// Draw values
- if (negativesComp == 1.0f) {
+ if (!m_hasNegativeValues) {
m_drawer->drawLabel(*item, item->sliceLabelItem(), viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 90.0f),
- item->height(),
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false,
- Drawer::LabelOver, Qt::AlignTop);
+ valuePositionComp, negativesRotation, item->height(),
+ m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera,
+ false, false, Drawer::LabelOver, Qt::AlignTop);
} else {
m_drawer->drawLabel(*item, item->sliceLabelItem(), viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f),
- negativesComp * negativesComp * item->height(),
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera());
+ valuePositionComp, zeroVector, negativesCompPow2 * item->height(),
+ m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera);
}
// Draw labels
if (m_sliceCache->labelItems().size() > col) {
- const LabelItem *labelItem(0);
- labelItem = m_sliceCache->labelItems().at(col);
- m_drawer->drawLabel(*item, *labelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_autoScaleAdjustment, zComp),
- QVector3D(0.0f, 0.0f, -45.0f), item->height(),
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), false, false,
- Drawer::LabelBelow);
+ m_drawer->drawLabel(*item, *m_sliceCache->labelItems().at(col), viewMatrix,
+ projectionMatrix, positionComp, sliceLabelRotation,
+ item->height(), m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, false, false, Drawer::LabelBelow);
}
}
@@ -466,17 +464,19 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
GLfloat colPos = 0;
GLfloat rowPos = 0;
+ const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
+
// Specify viewport
glViewport(m_mainViewPort.x(), m_mainViewPort.y(),
m_mainViewPort.width(), m_mainViewPort.height());
// Set up projection matrix
QMatrix4x4 projectionMatrix;
- projectionMatrix.perspective(45.0f, (GLfloat)m_mainViewPort.width()
- / (GLfloat)m_mainViewPort.height(), 0.1f, 100.0f);
+ GLfloat viewPortRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height();
+ projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f);
// Get the view matrix
- QMatrix4x4 viewMatrix = m_cachedScene->activeCamera()->viewMatrix();
+ QMatrix4x4 viewMatrix = activeCamera->viewMatrix();
// Calculate drawing order
// Draw order is reversed to optimize amount of drawing (ie. draw front objects first,
@@ -527,6 +527,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Introduce regardless of shadow quality to simplify logic
QMatrix4x4 depthViewMatrix;
QMatrix4x4 depthProjectionMatrix;
+ QMatrix4x4 depthProjectionViewMatrix;
+
+ QMatrix4x4 projectionViewMatrix = projectionMatrix * viewMatrix;
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -546,20 +549,21 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Get the depth view matrix
// It may be possible to hack lightPos here if we want to make some tweaks to shadow
- QVector3D depthLightPos = m_cachedScene->activeCamera()->calculatePositionRelativeToCamera(
- QVector3D(0.0f, 0.0f, zComp), 0.0f, 1.5f / m_autoScaleAdjustment);
- depthViewMatrix.lookAt(depthLightPos, QVector3D(0.0f, -m_yAdjustment, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ QVector3D depthLightPos = activeCamera->calculatePositionRelativeToCamera(
+ zeroVector, 0.0f, 3.5f / m_autoScaleAdjustment);
+ depthViewMatrix.lookAt(depthLightPos, QVector3D(0.0f, -m_yAdjustment, 0.0f),
+ upVector);
// TODO: Why does depthViewMatrix.column(3).y() goes to zero when we're directly above?
// That causes the scene to be not drawn from above -> must be fixed
// qDebug() << lightPos << depthViewMatrix << depthViewMatrix.column(3);
// Set the depth projection matrix
- depthProjectionMatrix.perspective(10.0f, (GLfloat)m_mainViewPort.width()
- / (GLfloat)m_mainViewPort.height(), 3.0f, 100.0f);
+ depthProjectionMatrix.perspective(10.0f, viewPortRatio, 3.0f, 100.0f);
+ depthProjectionViewMatrix = depthProjectionMatrix * depthViewMatrix;
// Draw bars to depth buffer
+ QVector3D shadowScaler(m_scaleX * 0.9f, 0.0f, m_scaleZ * 0.9f);
for (int row = startRow; row != stopRow; row += stepRow) {
for (int bar = startBar; bar != stopBar; bar += stepBar) {
const BarRenderItem &item = m_renderItemArray.at(row).at(bar);
@@ -590,11 +594,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// shadows through the ground
modelMatrix.translate((colPos - m_rowWidth) / m_scaleFactor,
item.height() - m_yAdjustment + shadowOffset,
- (m_columnDepth - rowPos) / m_scaleFactor + zComp);
+ (m_columnDepth - rowPos) / m_scaleFactor);
// Scale the bars down in X and Z to reduce self-shadowing issues
- modelMatrix.scale(QVector3D(m_scaleX * 0.9f, item.height(), m_scaleZ * 0.9f));
+ shadowScaler.setY(item.height());
+ modelMatrix.scale(shadowScaler);
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_depthShader->setUniformValue(m_depthShader->MVP(), MVPMatrix);
@@ -632,14 +637,10 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
glEnable(GL_TEXTURE_2D);
QMatrix4x4 modelMatrix;
QMatrix4x4 viewmatrix;
- viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
- modelMatrix.translate(0.0, 0.0, zComp);
- QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
+ viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f), zeroVector, upVector);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
- m_drawer->drawObject(m_labelShader, m_labelObj,
- m_depthTexture);
+ m_drawer->drawObject(m_labelShader, m_labelObj, m_depthTexture);
glDisable(GL_TEXTURE_2D);
m_labelShader->release();
#endif
@@ -660,8 +661,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw bars to selection buffer
glBindFramebuffer(GL_FRAMEBUFFER, m_selectionFrameBuffer);
glEnable(GL_DEPTH_TEST); // Needed, otherwise the depth render buffer is not used
- glClearColor(selectionSkipColor.x() / 255, selectionSkipColor.y() / 255,
- selectionSkipColor.z() / 255, 1.0f); // Set clear color to white (= selectionSkipColor)
+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Set clear color to white (= selectionSkipColor)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Needed for clearing the frame buffer
glDisable(GL_DITHER); // disable dithering, it may affect colors if enabled
for (int row = startRow; row != stopRow; row += stepRow) {
@@ -683,10 +683,10 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
modelMatrix.translate((colPos - m_rowWidth) / m_scaleFactor,
item.height() - m_yAdjustment,
- (m_columnDepth - rowPos) / m_scaleFactor + zComp);
+ (m_columnDepth - rowPos) / m_scaleFactor);
modelMatrix.scale(QVector3D(m_scaleX, item.height(), m_scaleZ));
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
//#if !defined(QT_OPENGL_ES_2)
// QVector3D barColor = QVector3D((GLdouble)row / 32767.0,
@@ -740,11 +740,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
glEnable(GL_TEXTURE_2D);
QMatrix4x4 modelMatrix;
QMatrix4x4 viewmatrix;
- viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.0f + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
- modelMatrix.translate(0.0, 0.0, zComp);
- QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
+ viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.0f), zeroVector, upVector);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
m_drawer->drawObject(m_labelShader, m_labelObj, m_selectionTexture);
glDisable(GL_TEXTURE_2D);
@@ -783,8 +780,17 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
// Draw bars
+ QVector3D barHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor));
+ QVector3D rowHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightRowColor));
+ QVector3D columnHighlightColor(Utils::vectorFromColor(m_cachedTheme.m_highlightColumnColor));
+ QVector3D baseColor(Utils::vectorFromColor(m_cachedTheme.m_baseColor));
+
+ GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f;
+ GLfloat adjustedHighlightStrength = m_cachedTheme.m_highlightLightStrength / 10.0f;
+
bool barSelectionFound = false;
BarRenderItem *selectedBar(0);
+ QVector3D modelScaler(m_scaleX, 0.0f, m_scaleZ);
for (int row = startRow; row != stopRow; row += stepRow) {
for (int bar = startBar; bar != stopBar; bar += stepBar) {
BarRenderItem &item = m_renderItemArray[row][bar];
@@ -797,25 +803,23 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QMatrix4x4 modelMatrix;
QMatrix4x4 itModelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
colPos = (bar + 0.5f) * (m_cachedBarSpacing.width());
rowPos = (row + 0.5f) * (m_cachedBarSpacing.height());
modelMatrix.translate((colPos - m_rowWidth) / m_scaleFactor,
item.height() - m_yAdjustment,
- (m_columnDepth - rowPos) / m_scaleFactor + zComp);
- modelMatrix.scale(QVector3D(m_scaleX, item.height(), m_scaleZ));
- itModelMatrix.scale(QVector3D(m_scaleX, item.height(), m_scaleZ));
+ (m_columnDepth - rowPos) / m_scaleFactor);
+ modelScaler.setY(item.height());
+ modelMatrix.scale(modelScaler);
+ itModelMatrix.scale(modelScaler);
#ifdef SHOW_DEPTH_TEXTURE_SCENE
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
#if 0
- QVector3D baseColor = Utils::vectorFromColor(m_cachedTheme.m_baseColor);
QVector3D heightColor = Utils::vectorFromColor(m_cachedTheme.m_heightColor)
* item.height();
QVector3D depthColor = Utils::vectorFromColor(m_cachedTheme.m_depthColor)
@@ -823,18 +827,20 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QVector3D barColor = baseColor + heightColor + depthColor;
#else
- QVector3D barColor = Utils::vectorFromColor(m_cachedTheme.m_baseColor);
+ QVector3D barColor = baseColor;
#endif
GLfloat lightStrength = m_cachedTheme.m_lightStrength;
+ GLfloat shadowLightStrength = adjustedLightStrength;
if (m_cachedSelectionMode > QDataVis::SelectionModeNone) {
Bars3DController::SelectionType selectionType = isSelected(row, bar);
switch (selectionType) {
case Bars3DController::SelectionItem: {
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightBarColor);
+ barColor = barHighlightColor;
lightStrength = m_cachedTheme.m_highlightLightStrength;
+ shadowLightStrength = adjustedHighlightStrength;
// Insert position data into render item. We have no ownership, don't delete the previous one
if (!m_cachedIsSlicingActivated) {
selectedBar = &item;
@@ -867,24 +873,26 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
case Bars3DController::SelectionRow: {
// Current bar is on the same row as the selected bar
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightRowColor);
+ barColor = rowHighlightColor;
lightStrength = m_cachedTheme.m_highlightLightStrength;
+ shadowLightStrength = adjustedHighlightStrength;
if (QDataVis::SelectionModeSliceRow == m_cachedSelectionMode) {
item.setTranslation(modelMatrix.column(3).toVector3D());
item.setPosition(QPoint(row, bar));
- if (selectionDirty)
+ if (selectionDirty && bar < m_renderColumns)
m_sliceSelection->append(&item);
}
break;
}
case Bars3DController::SelectionColumn: {
// Current bar is on the same column as the selected bar
- barColor = Utils::vectorFromColor(m_cachedTheme.m_highlightColumnColor);
+ barColor = columnHighlightColor;
lightStrength = m_cachedTheme.m_highlightLightStrength;
+ shadowLightStrength = adjustedHighlightStrength;
if (QDataVis::SelectionModeSliceColumn == m_cachedSelectionMode) {
item.setTranslation(modelMatrix.column(3).toVector3D());
item.setPosition(QPoint(row, bar));
- if (selectionDirty)
+ if (selectionDirty && row < m_renderRows)
m_sliceSelection->append(&item);
}
break;
@@ -909,9 +917,10 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_barShader->setUniformValue(m_barShader->shadowQ(), m_shadowQualityToShader);
m_barShader->setUniformValue(m_barShader->depth(), depthMVPMatrix);
- m_barShader->setUniformValue(m_barShader->lightS(), lightStrength / 10.0f);
+ m_barShader->setUniformValue(m_barShader->lightS(), shadowLightStrength);
// Draw the object
m_drawer->drawObject(m_barShader, m_barObj, 0, m_depthTexture);
@@ -943,28 +952,26 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
glCullFace(GL_BACK);
// Draw background
+ GLfloat rowScaleFactor = m_rowWidth / m_scaleFactor;
+ GLfloat columnScaleFactor = m_columnDepth / m_scaleFactor;
+
if (m_cachedIsBackgroundEnabled && m_backgroundObj) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(0.0f, 1.0f - m_yAdjustment, zComp);
- modelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor,
- 1.0f,
- m_columnDepth / m_scaleFactor));
+ QVector3D backgroundScaler(rowScaleFactor, 1.0f, columnScaleFactor);
+ modelMatrix.translate(0.0f, 1.0f - m_yAdjustment, 0.0f);
+ modelMatrix.scale(backgroundScaler);
modelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
- itModelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor,
- 1.0f,
- m_columnDepth / m_scaleFactor));
+ itModelMatrix.scale(backgroundScaler);
+ itModelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
#ifdef SHOW_DEPTH_TEXTURE_SCENE
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
-
QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
// Set shader bindings
@@ -981,11 +988,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_backgroundShader->setUniformValue(m_backgroundShader->shadowQ(),
m_shadowQualityToShader);
m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
+ adjustedLightStrength);
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj, 0, m_depthTexture);
@@ -1016,6 +1024,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw grid lines
if (m_cachedIsGridEnabled && m_heightNormalizer) {
ShaderHelper *lineShader = m_backgroundShader;
+
// Bind bar shader
lineShader->bind();
@@ -1025,27 +1034,39 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), barColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+#if !defined(QT_OPENGL_ES_2)
+ if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
+ // Set shadowed shader bindings
+ lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ lineShader->setUniformValue(lineShader->lightS(),
+ m_cachedTheme.m_lightStrength / 20.0f);
+ } else
+#endif
+ {
+ // Set shadowless shader bindings
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ }
+
+ QVector3D gridLineScaler(rowScaleFactor, gridLineWidth, gridLineWidth);
// Floor lines: rows
for (GLfloat row = 0.0f; row <= m_cachedRowCount; row++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
rowPos = row * m_cachedBarSpacing.height();
modelMatrix.translate(0.0f, -m_yAdjustment,
- (m_columnDepth - rowPos) / m_scaleFactor + zComp);
- modelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor, gridLineWidth,
- gridLineWidth));
- itModelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor, gridLineWidth,
- gridLineWidth));
+ (m_columnDepth - rowPos) / m_scaleFactor);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1056,45 +1077,38 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
}
// Floor lines: columns
+ gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, columnScaleFactor);
for (GLfloat bar = 0.0f; bar <= m_cachedColumnCount; bar++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
colPos = bar * m_cachedBarSpacing.width();
modelMatrix.translate((m_rowWidth - colPos) / m_scaleFactor,
- -m_yAdjustment, zComp);
- modelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- m_columnDepth / m_scaleFactor));
- itModelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- m_columnDepth / m_scaleFactor));
+ -m_yAdjustment, 0.0f);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1105,19 +1119,13 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1131,29 +1139,26 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_hasNegativeValues)
startLine = -m_heightNormalizer;
+ gridLineScaler = QVector3D(rowScaleFactor, gridLineWidth, gridLineWidth);
for (GLfloat lineHeight = startLine; lineHeight <= m_heightNormalizer;
lineHeight += heightStep) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_zFlipped) {
modelMatrix.translate(0.0f,
2.0f * lineHeight / m_heightNormalizer - m_yAdjustment,
- m_columnDepth / m_scaleFactor + zComp);
+ columnScaleFactor);
} else {
modelMatrix.translate(0.0f,
2.0f * lineHeight / m_heightNormalizer - m_yAdjustment,
- -m_columnDepth / m_scaleFactor + zComp);
+ -columnScaleFactor);
}
- modelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor, gridLineWidth,
- gridLineWidth));
- itModelMatrix.scale(QVector3D(m_rowWidth / m_scaleFactor, gridLineWidth,
- gridLineWidth));
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1164,48 +1169,39 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
}
// Wall lines: side wall
+ gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, columnScaleFactor);
for (GLfloat lineHeight = startLine; lineHeight <= m_heightNormalizer;
lineHeight += heightStep) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_xFlipped) {
- modelMatrix.translate(m_rowWidth / m_scaleFactor,
+ modelMatrix.translate(rowScaleFactor,
2.0f * lineHeight / m_heightNormalizer - m_yAdjustment,
- zComp);
+ 0.0f);
} else {
- modelMatrix.translate(-m_rowWidth / m_scaleFactor,
+ modelMatrix.translate(-rowScaleFactor,
2.0f * lineHeight / m_heightNormalizer - m_yAdjustment,
- zComp);
+ 0.0f);
}
- modelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- m_columnDepth / m_scaleFactor));
- itModelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- m_columnDepth / m_scaleFactor));
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1216,19 +1212,13 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1247,80 +1237,79 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Calculate the positions for row and column labels and store them
+ GLfloat labelYAdjustment = -m_yAdjustment + 0.005f;
+ GLfloat scaledRowWidth = rowScaleFactor;
+ GLfloat scaledColumnDepth = columnScaleFactor;
+ GLfloat colPosValue = scaledRowWidth + labelMargin;
+ GLfloat rowPosValue = scaledColumnDepth + labelMargin;
+ QVector3D positionComp(0.0f, m_yAdjustment, 0.0f);
+ QVector3D labelRotation(-90.0f, 0.0f, 0.0f);
+ if (m_zFlipped)
+ labelRotation.setY(180.0f);
+ if (m_yFlipped) {
+ if (m_zFlipped)
+ labelRotation.setY(0.0f);
+ else
+ labelRotation.setY(180.0f);
+ labelRotation.setZ(180.0f);
+ }
+ Qt::AlignmentFlag alignment = m_xFlipped ? Qt::AlignLeft : Qt::AlignRight;
for (int row = 0; row != m_cachedRowCount; row++) {
if (m_axisCacheX.labelItems().size() > row) {
// Go through all rows and get position of max+1 or min-1 column, depending on x flip
// We need only positions for them, labels have already been generated at QDataSetPrivate. Just add LabelItems
rowPos = (row + 0.5f) * m_cachedBarSpacing.height();
- colPos = (m_rowWidth / m_scaleFactor) + labelMargin;
- GLfloat rotLabelX = -90.0f;
- GLfloat rotLabelY = 0.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignRight;
- if (m_zFlipped)
- rotLabelY = 180.0f;
- if (m_xFlipped) {
- colPos = -(m_rowWidth / m_scaleFactor) - labelMargin;
- alignment = Qt::AlignLeft;
- }
- if (m_yFlipped) {
- if (m_zFlipped)
- rotLabelY = 0.0f;
- else
- rotLabelY = 180.0f;
- rotLabelZ = 180.0f;
- }
+ if (m_xFlipped)
+ colPos = -colPosValue;
+ else
+ colPos = colPosValue;
+
QVector3D labelPos = QVector3D(colPos,
- -m_yAdjustment + 0.005f, // raise a bit over background to avoid depth "glimmering"
- (m_columnDepth - rowPos) / m_scaleFactor + zComp);
+ labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
+ (m_columnDepth - rowPos) / m_scaleFactor);
m_dummyBarRenderItem.setTranslation(labelPos);
const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(row);
//qDebug() << "labelPos, row" << row + 1 << ":" << labelPos << m_axisCacheX.labels().at(row);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
+ positionComp, labelRotation, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment);
}
}
+ labelRotation = QVector3D(-90.0f, 90.0f, 0.0f);
+ if (m_xFlipped)
+ labelRotation.setY(-90.0f);
+ if (m_yFlipped) {
+ if (m_xFlipped)
+ labelRotation.setY(90.0f);
+ else
+ labelRotation.setY(-90.0f);
+ labelRotation.setZ(180.0f);
+ }
+
+ alignment = m_zFlipped ? Qt::AlignRight : Qt::AlignLeft;
for (int column = 0; column != m_cachedColumnCount; column += 1) {
if (m_axisCacheZ.labelItems().size() > column) {
// Go through all columns and get position of max+1 or min-1 row, depending on z flip
// We need only positions for them, labels have already been generated at QDataSetPrivate. Just add LabelItems
colPos = (column + 0.5f) * m_cachedBarSpacing.width();
- rowPos = (m_columnDepth / m_scaleFactor) + labelMargin;
- GLfloat rotLabelX = -90.0f;
- GLfloat rotLabelY = 90.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignLeft;
- if (m_xFlipped)
- rotLabelY = -90.0f;
- if (m_zFlipped) {
- rowPos = -(m_columnDepth / m_scaleFactor) - labelMargin;
- alignment = Qt::AlignRight;
- }
- if (m_yFlipped) {
- if (m_xFlipped)
- rotLabelY = -90.0f;
- else
- rotLabelY = 90.0f;
- rotLabelZ = 180.0f;
- }
+ if (m_zFlipped)
+ rowPos = -rowPosValue;
+ else
+ rowPos = rowPosValue;
+
QVector3D labelPos = QVector3D((colPos - m_rowWidth) / m_scaleFactor,
- -m_yAdjustment + 0.005f, // raise a bit over background to avoid depth "glimmering"
- rowPos + zComp);
+ labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
+ rowPos);
m_dummyBarRenderItem.setTranslation(labelPos);
const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(column);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
+ positionComp, labelRotation, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment);
}
}
@@ -1333,65 +1322,51 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_hasNegativeValues)
startLine = -m_heightNormalizer;
GLfloat labelPos = startLine;
+ GLfloat labelMarginXTrans = labelMargin;
+ GLfloat labelMarginZTrans = labelMargin;
+ GLfloat labelXTrans = rowScaleFactor;
+ GLfloat labelZTrans = columnScaleFactor;
+ QVector3D backLabelRotation(0.0f, -90.0f, 0.0f);
+ QVector3D sideLabelRotation(0.0f, 0.0f, 0.0f);
+ Qt::AlignmentFlag backAlignment = Qt::AlignLeft;
+ Qt::AlignmentFlag sideAlignment = Qt::AlignLeft;
+ if (!m_xFlipped) {
+ labelXTrans = -labelXTrans;
+ labelMarginXTrans = -labelMargin;
+ backLabelRotation.setY(90.0f);
+ sideAlignment = Qt::AlignRight;
+ }
+ if (m_zFlipped) {
+ labelZTrans = -labelZTrans;
+ labelMarginZTrans = -labelMargin;
+ backAlignment = Qt::AlignRight;
+ sideLabelRotation.setY(180.f);
+ }
+ QVector3D backLabelTrans = QVector3D(labelXTrans, 0.0f,
+ labelZTrans + labelMarginZTrans);
+ QVector3D sideLabelTrans = QVector3D(-labelXTrans - labelMarginXTrans,
+ 0.0f, -labelZTrans);
for (int i = 0; i < labelCount; i++) {
if (m_axisCacheY.labelItems().size() > labelNbr) {
- GLfloat labelMarginXTrans = labelMargin;
- GLfloat labelMarginZTrans = labelMargin;
- GLfloat labelXTrans = m_rowWidth / m_scaleFactor;
- GLfloat labelZTrans = m_columnDepth / m_scaleFactor;
- GLfloat labelYTrans = 2.0f * labelPos / m_heightNormalizer - m_yAdjustment;
- GLfloat rotLabelX = 0.0f;
- GLfloat rotLabelY = -90.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignLeft;
- if (!m_xFlipped) {
- labelXTrans = -labelXTrans;
- labelMarginXTrans = -labelMargin;
- rotLabelY = 90.0f;
- }
- if (m_zFlipped) {
- labelZTrans = -labelZTrans;
- labelMarginZTrans = -labelMargin;
- alignment = Qt::AlignRight;
- }
+ backLabelTrans.setY(2.0f * labelPos / m_heightNormalizer - m_yAdjustment);
+ sideLabelTrans.setY(backLabelTrans.y());
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(labelNbr);
// Back wall
- QVector3D labelTrans = QVector3D(labelXTrans, labelYTrans,
- labelZTrans + labelMarginZTrans + zComp);
-
- //qDebug() << "labelPos, value:" << labelTrans;
-
- m_dummyBarRenderItem.setTranslation(labelTrans);
+ m_dummyBarRenderItem.setTranslation(backLabelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
- true, true, Drawer::LabelMid, alignment);
+ positionComp, backLabelRotation, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera,
+ true, true, Drawer::LabelMid, backAlignment);
// Side wall
- if (m_xFlipped)
- alignment = Qt::AlignLeft;
- else
- alignment = Qt::AlignRight;
- if (m_zFlipped)
- rotLabelY = 180.0f;
- else
- rotLabelY = 0.0f;
-
- labelTrans = QVector3D(-labelXTrans - labelMarginXTrans, labelYTrans,
- -labelZTrans + zComp);
-
- m_dummyBarRenderItem.setTranslation(labelTrans);
+ m_dummyBarRenderItem.setTranslation(sideLabelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
- true, true, Drawer::LabelMid, alignment);
+ positionComp, sideLabelRotation, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera,
+ true, true, Drawer::LabelMid, sideAlignment);
}
labelNbr++;
labelPos += heightStep;
@@ -1468,10 +1443,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
m_drawer->drawLabel(*selectedBar, labelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, m_yAdjustment, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), selectedBar->height(),
+ positionComp, zeroVector, selectedBar->height(),
m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), true, false);
+ m_labelObj, activeCamera, true, false);
// Reset label update flag; they should have been updated when we get here
m_updateLabels = false;
@@ -1780,11 +1754,13 @@ void Bars3DRenderer::initSelectionShader()
void Bars3DRenderer::initSelectionBuffer()
{
- if (m_cachedIsSlicingActivated)
- return;
-
- if (m_selectionTexture)
+ if (m_selectionTexture) {
m_textureHelper->deleteTexture(&m_selectionTexture);
+ m_selectionTexture = 0;
+ }
+
+ if (m_cachedIsSlicingActivated || m_mainViewPort.size().isEmpty())
+ return;
m_selectionTexture = m_textureHelper->createSelectionTexture(m_mainViewPort.size(),
m_selectionFrameBuffer,
@@ -1808,6 +1784,9 @@ void Bars3DRenderer::updateDepthBuffer()
m_depthTexture = 0;
}
+ if (m_mainViewPort.size().isEmpty())
+ return;
+
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
m_depthTexture = m_textureHelper->createDepthTexture(m_mainViewPort.size(),
m_depthFrameBuffer,
diff --git a/src/datavisualization/engine/bars3drenderer_p.h b/src/datavisualization/engine/bars3drenderer_p.h
index 764942cc..dd80902a 100644
--- a/src/datavisualization/engine/bars3drenderer_p.h
+++ b/src/datavisualization/engine/bars3drenderer_p.h
@@ -100,6 +100,8 @@ private:
GLfloat m_maxSceneSize;
QVector3D m_selection;
QVector3D m_previousSelection;
+ int m_renderRows;
+ int m_renderColumns;
bool m_hasHeightAdjustmentChanged;
BarRenderItem m_dummyBarRenderItem;
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index e2ed6748..418dba77 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -143,12 +143,6 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui
void Drawer::drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object)
{
- // Store the GL state before changing
- GLint oldActiveTex[1];
- glGetIntegerv(GL_ACTIVE_TEXTURE, oldActiveTex);
- GLint oldTexId[1];
- glGetIntegerv(GL_TEXTURE_BINDING_2D, oldTexId);
-
// 1st attribute buffer : vertices
glEnableVertexAttribArray(shader->posAtt());
glBindBuffer(GL_ARRAY_BUFFER, object->vertexBuf());
@@ -165,10 +159,6 @@ void Drawer::drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(shader->posAtt());
-
- // Restore the GL state
- glActiveTexture(*oldActiveTex);
- glBindTexture(GL_TEXTURE_2D, *oldTexId);
}
void Drawer::drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
diff --git a/src/datavisualization/engine/meshes/backgroudFlat.obj b/src/datavisualization/engine/meshes/backgroudFlat.obj
index cf4d10a5..5eeb1f26 100644
--- a/src/datavisualization/engine/meshes/backgroudFlat.obj
+++ b/src/datavisualization/engine/meshes/backgroudFlat.obj
@@ -5,23 +5,23 @@ v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
-v 0.999999 1.000000 1.000001
+v 1.000000 1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
-vt 0.000000 0.501529
-vt 0.001529 1.000000
-vt 0.500000 0.998471
-vt 0.501529 0.500000
-vt 1.000000 0.498471
-vt 0.998471 0.000000
-vt 0.500000 0.498471
-vt 0.498471 0.000000
-vt 0.000000 0.001529
-vt 0.498471 0.500000
-vt 0.500000 0.001529
-vt 0.001529 0.500000
-vn -0.000000 1.000000 0.000000
-vn 0.000000 -0.000000 -1.000000
+vt 0.000000 0.500000
+vt 0.000000 1.000000
+vt 0.500000 1.000000
+vt 0.500000 0.500000
+vt 1.000000 0.500000
+vt 1.000000 0.000000
+vt 0.500000 0.500000
+vt 0.500000 0.000000
+vt 0.000000 0.000000
+vt 0.500000 0.500000
+vt 0.500000 0.000000
+vt 0.000000 0.500000
+vn 0.000000 1.000000 0.000000
+vn 0.000000 0.000000 -1.000000
vn 1.000000 0.000000 0.000000
s off
f 1/1/1 4/2/1 3/3/1
diff --git a/src/datavisualization/engine/meshes/backgroudNegatives.obj b/src/datavisualization/engine/meshes/backgroudNegatives.obj
index dd4d3f05..4153bfd4 100644
--- a/src/datavisualization/engine/meshes/backgroudNegatives.obj
+++ b/src/datavisualization/engine/meshes/backgroudNegatives.obj
@@ -5,7 +5,7 @@ v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
-v 0.999999 1.000000 1.000001
+v 1.000000 1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 -3.000000 1.000000
@@ -21,17 +21,13 @@ vt 0.666500 0.000100
vt 0.666500 0.666500
vt 0.000100 0.999900
vt 0.000100 0.666500
-vn 0.000000 0.999969 0.000000
-vn 0.000000 1.000000 0.000000
-vn 0.000000 0.000000 -1.000000
-vn 0.707083 0.000000 -0.707083
+vn -0.000000 1.000000 0.000000
+vn 0.000000 -0.000000 -1.000000
vn 1.000000 0.000000 0.000000
-vn 0.999969 0.000000 0.000000
-vn 0.000000 0.000000 -0.999969
-s 1
-f 1/1/1 4/2/2 3/3/2
-f 8/4/3 9/5/4 6/6/4
-f 9/5/4 10/7/5 7/8/6
-f 2/9/2 1/1/1 3/3/2
-f 5/10/7 8/4/3 6/6/4
-f 6/6/4 9/5/4 7/8/6
+s off
+f 1/1/1 4/2/1 3/3/1
+f 8/4/2 9/5/2 6/6/2
+f 9/5/3 10/7/3 7/8/3
+f 2/9/1 1/1/1 3/3/1
+f 5/10/2 8/4/2 6/6/2
+f 6/6/3 9/5/3 7/8/3
diff --git a/src/datavisualization/engine/meshes/backgroudSmooth.obj b/src/datavisualization/engine/meshes/backgroudSmooth.obj
index ad16d904..27d06aea 100644
--- a/src/datavisualization/engine/meshes/backgroudSmooth.obj
+++ b/src/datavisualization/engine/meshes/backgroudSmooth.obj
@@ -5,7 +5,7 @@ v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
-v 0.999999 1.000000 1.000001
+v 1.000000 1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.000000 0.501529
@@ -20,12 +20,12 @@ vt 0.000000 0.001529
vt 0.498471 0.500000
vt 0.500000 0.001529
vt 0.001529 0.500000
-vn 0.000000 0.999969 0.000000
+vn 0.000000 1.000000 0.000000
vn 0.707083 0.707083 0.000000
vn 0.577349 0.577349 -0.577349
vn 0.000000 0.707083 -0.707083
vn 0.707083 0.000000 -0.707083
-vn 0.999969 0.000000 0.000000
+vn 1.000000 0.000000 0.000000
vn 0.000000 0.000000 -1.000000
s 1
f 1/1/1 4/2/2 3/3/3
diff --git a/src/datavisualization/engine/q3dbars.cpp b/src/datavisualization/engine/q3dbars.cpp
index b40aeddd..d6b48e03 100644
--- a/src/datavisualization/engine/q3dbars.cpp
+++ b/src/datavisualization/engine/q3dbars.cpp
@@ -34,7 +34,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DBars
* \inmodule QtDataVisualization
* \brief The Q3DBars class provides methods for rendering 3D bar graphs.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.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
@@ -42,11 +42,11 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* 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.
*
- * If no axes are explicitly set to Q3DBars, temporary default axes with no labels are created.
- * These default axes can be modified via axis accessors, but as soon any axis is explicitly
- * set for the orientation, the default axis for that orientation is destroyed.
+ * If no axes are set explicitly to Q3DBars, temporary default axes with no labels are created.
+ * These default axes can be modified via axis accessors, but as soon any axis is set explicitly
+ * for the orientation, the default axis for that orientation is destroyed.
*
- * Data proxies work similarly: If no data proxy is explicitly set, Q3DBars creates a default
+ * Data proxies work similarly: If no data proxy is set explicitly, Q3DBars creates a default
* proxy. If any other proxy is set as active data proxy later, the default proxy and all data
* added to it is destroyed.
*
@@ -71,7 +71,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
*
* \snippet doc_src_q3dbars_construction.cpp 1
*
- * \note We set the data window to 5 x 5, but we are inserting only one row of data. This is ok,
+ * \note We set the data window to 5 x 5, but we are adding 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:
@@ -209,7 +209,7 @@ qreal Q3DBars::barThickness()
/*!
* \property Q3DBars::barSpacing
*
- * Bar spacing, ie. the empty space between bars, in X and Z dimensions. It is preset to
+ * Bar spacing, which is the empty space between bars, in X and Z dimensions. It is preset to
* \c {(1.0, 1.0)} by default. Spacing is affected by barSpacingRelative -property.
*
* \sa barSpacingRelative
@@ -439,7 +439,7 @@ QDataVis::ShadowQuality Q3DBars::shadowQuality() const
* the \a axis to this graph.
*
* If the \a axis is null, a temporary default axis with no labels is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -461,7 +461,7 @@ Q3DCategoryAxis *Q3DBars::rowAxis() const
* the \a axis to this graph.
*
* If the \a axis is null, a temporary default axis with no labels is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -484,7 +484,7 @@ Q3DCategoryAxis *Q3DBars::columnAxis() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -541,7 +541,7 @@ QList<Q3DAbstractAxis *> Q3DBars::axes() const
* the \a proxy to this graph.
*
* If the \a proxy is null, a temporary default proxy is created and activated.
- * This temporary proxy is destroyed if another \a proxy is explicitly set active via this method.
+ * This temporary proxy is destroyed if another \a proxy is set explicitly active via this method.
*
* \sa addDataProxy(), releaseDataProxy()
*/
@@ -608,7 +608,6 @@ Q3DBarsPrivate::Q3DBarsPrivate(Q3DBars *q, QRect rect)
Q3DBarsPrivate::~Q3DBarsPrivate()
{
- qDebug() << "Destroying Q3DBarsPrivate";
delete m_shared;
}
diff --git a/src/datavisualization/engine/q3dbox.cpp b/src/datavisualization/engine/q3dbox.cpp
index 43f3e90e..cc1e0265 100644
--- a/src/datavisualization/engine/q3dbox.cpp
+++ b/src/datavisualization/engine/q3dbox.cpp
@@ -26,7 +26,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
\class Q3DBox
\inmodule QtDataVisualization
\brief The Q3DBox class represents an axis-aligned box in 3D space.
- \since 1.0.0
+ \since Qt Data Visualization 1.0
Q3DBox can be used to represent the bounding box of objects in a 3D
scene so that they can be easily culled if they are out of view.
diff --git a/src/datavisualization/engine/q3dcamera.cpp b/src/datavisualization/engine/q3dcamera.cpp
index 571af1d7..fe452739 100644
--- a/src/datavisualization/engine/q3dcamera.cpp
+++ b/src/datavisualization/engine/q3dcamera.cpp
@@ -32,7 +32,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
\class Q3DCamera
\inmodule QtDataVisualization
\brief Representation of a camera in 3D space.
- \since 1.0.0
+ \since Qt Data Visualization 1.0
Q3DCamera represents a basic orbit around centerpoint 3D camera that is used when rendering the data visualization.
The class offers simple methods for setting the orbit point in rotations, but allows also setting the 4x4 viewmatrix
@@ -153,7 +153,7 @@ void Q3DCamera::setYRotation(qreal rotation)
*
* This property contains the current minimum X-rotation for the camera.
* The full circle range is [-180,180] and the minimum value is limited to -180.
- * Also the value can't be higher than maximum, and is adjusted if necessary.
+ * Also the value can't be higher than the maximum, and is adjusted if necessary.
*
* \sa wrapXRotation, maxXRotation
*/
@@ -167,7 +167,7 @@ qreal Q3DCamera::minXRotation() const
*/
void Q3DCamera::setMinXRotation(qreal minRotation)
{
- minRotation = qBound(-180.0, minRotation, 180.0);
+ minRotation = qBound(qreal(-180.0), minRotation, qreal(180.0));
if (minRotation > d_ptr->m_maxXRotation)
minRotation = d_ptr->m_maxXRotation;
@@ -185,7 +185,7 @@ void Q3DCamera::setMinXRotation(qreal minRotation)
*
* This property contains the current minimum Y-rotation for the camera.
* The full Y angle range is [-90,90] and the minimum value is limited to -90.
- * Also the value can't be higher than maximum, and is adjusted if necessary.
+ * Also the value can't be higher than the maximum, and is adjusted if necessary.
*
* \sa wrapYRotation, maxYRotation
*/
@@ -199,7 +199,7 @@ qreal Q3DCamera::minYRotation() const
*/
void Q3DCamera::setMinYRotation(qreal minRotation)
{
- minRotation = qBound(-90.0, minRotation, 90.0);
+ minRotation = qBound(qreal(-90.0), minRotation, qreal(90.0));
if (minRotation > d_ptr->m_maxYRotation)
minRotation = d_ptr->m_maxYRotation;
@@ -217,7 +217,7 @@ void Q3DCamera::setMinYRotation(qreal minRotation)
*
* This property contains the current maximum X-rotation for the camera.
* The full circle range is [-180,180] and the maximum value is limited to 180.
- * Also the value can't be lower than minimum, and is adjusted if necessary.
+ * Also the value can't be lower than the minimum, and is adjusted if necessary.
*
* \sa wrapXRotation, minXRotation
*/
@@ -231,7 +231,7 @@ qreal Q3DCamera::maxXRotation() const
*/
void Q3DCamera::setMaxXRotation(qreal maxRotation)
{
- maxRotation = qBound(-180.0, maxRotation, 180.0);
+ maxRotation = qBound(qreal(-180.0), maxRotation, qreal(180.0));
if (maxRotation < d_ptr->m_minXRotation)
maxRotation = d_ptr->m_minXRotation;
@@ -250,7 +250,7 @@ void Q3DCamera::setMaxXRotation(qreal maxRotation)
*
* This property contains the current maximum Y-rotation for the camera.
* The full Y angle range is [-90,90] and the maximum value is limited to 90.
- * Also the value can't be lower than minimum, and is adjusted if necessary.
+ * Also the value can't be lower than the minimum, and is adjusted if necessary.
*
* \sa wrapYRotation, minYRotation
*/
@@ -264,7 +264,7 @@ qreal Q3DCamera::maxYRotation() const
*/
void Q3DCamera::setMaxYRotation(qreal maxRotation)
{
- maxRotation = qBound(-90.0, maxRotation, 90.0);
+ maxRotation = qBound(qreal(-90.0), maxRotation, qreal(90.0));
if (maxRotation < d_ptr->m_minYRotation)
maxRotation = d_ptr->m_minYRotation;
@@ -301,8 +301,8 @@ void Q3DCamera::setBaseOrientation(const QVector3D &basePosition,
/*!
* \property Q3DCamera::viewMatrix
*
- * This property contains the view matrix used in the 3D calculations. When the default orbiting camera behavior is sufficient
- * there is no need to touch this property. But if the default behavior is insufficient the view matrix can be set directly.
+ * This property contains the view matrix used in the 3D calculations. When the default orbiting camera behavior is sufficient,
+ * there is no need to touch this property. But if the default behavior is insufficient, the view matrix can be set directly.
* When setting the view matrix directly remember to set Q3DCamera::viewMatrixAutoUpdateEnabled to false.
*/
QMatrix4x4 Q3DCamera::viewMatrix() const
@@ -518,7 +518,7 @@ QVector3D Q3DCamera::calculatePositionRelativeToCamera(const QVector3D &relative
qreal distanceModifier) const
{
// Move the position with camera
- GLfloat radiusFactor = relativePosition.z() * (1.5f + distanceModifier);
+ GLfloat radiusFactor = cameraDistance * (1.5f + distanceModifier);
GLfloat xAngle;
GLfloat yAngle;
if (!fixedRotation) {
@@ -532,6 +532,7 @@ QVector3D Q3DCamera::calculatePositionRelativeToCamera(const QVector3D &relative
GLfloat zPos = radius * qCos(xAngle) * qCos(yAngle);
GLfloat xPos = radius * qSin(xAngle) * qCos(yAngle);
GLfloat yPos = (radiusFactor + relativePosition.y()) * qSin(yAngle);
+
// Keep in the set position in relation to camera
return QVector3D(-xPos + relativePosition.x(),
yPos + relativePosition.y(),
@@ -582,7 +583,7 @@ void Q3DCamera::setWrapYRotation(bool isEnabled)
*/
void Q3DCamera::setCameraPosition(qreal horizontal, qreal vertical, qreal zoom)
{
- setZoomLevel(qBound(10.0, zoom, 500.0));
+ setZoomLevel(qBound(qreal(10.0), zoom, qreal(500.0)));
setXRotation(horizontal);
setYRotation(vertical);
}
diff --git a/src/datavisualization/engine/q3dlight.cpp b/src/datavisualization/engine/q3dlight.cpp
index c482e62a..f1b1b4e7 100644
--- a/src/datavisualization/engine/q3dlight.cpp
+++ b/src/datavisualization/engine/q3dlight.cpp
@@ -26,7 +26,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
\class Q3DLight
\inmodule QtDataVisualization
\brief Representation of a light source in 3D space.
- \since 1.0.0
+ \since Qt Data Visualization 1.0
Q3DLight represents a monochrome non variable light source in 3D space.
*/
diff --git a/src/datavisualization/engine/q3dobject.cpp b/src/datavisualization/engine/q3dobject.cpp
index ae13af7d..c4098fd0 100644
--- a/src/datavisualization/engine/q3dobject.cpp
+++ b/src/datavisualization/engine/q3dobject.cpp
@@ -26,7 +26,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
\class Q3DObject
\inmodule QtDataVisualization
\brief Simple baseclass for all the objects in the 3D scene.
- \since 1.0.0
+ \since Qt Data Visualization 1.0
Q3DObject is a baseclass that contains only position information for an object in 3D scene.
The object is considered to be a single point in the coordinate space without dimensions.
diff --git a/src/datavisualization/engine/q3dscatter.cpp b/src/datavisualization/engine/q3dscatter.cpp
index 3ad2cf2a..fc95842a 100644
--- a/src/datavisualization/engine/q3dscatter.cpp
+++ b/src/datavisualization/engine/q3dscatter.cpp
@@ -32,7 +32,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DScatter
* \inmodule QtDataVisualization
* \brief The Q3DScatter class provides methods for rendering 3D scatter graphs.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* This class enables developers to render scatter 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
@@ -40,11 +40,11 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* 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.
*
- * If no axes are explicitly set to Q3DScatter, temporary default axes with no labels are created.
- * These default axes can be modified via axis accessors, but as soon any axis is explicitly
- * set for the orientation, the default axis for that orientation is destroyed.
+ * If no axes are set explicitly to Q3DScatter, temporary default axes with no labels are created.
+ * These default axes can be modified via axis accessors, but as soon any axis is set explicitly
+ * for the orientation, the default axis for that orientation is destroyed.
*
- * Data proxies work similarly: If no data proxy is explicitly set, Q3DScatter creates a default
+ * Data proxies work similarly: if no data proxy is set explicitly, Q3DScatter creates a default
* proxy. If any other proxy is set as active data proxy later, the default proxy and all data
* added to it is destroyed.
*
@@ -374,7 +374,7 @@ QDataVis::ShadowQuality Q3DScatter::shadowQuality() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -397,7 +397,7 @@ Q3DValueAxis *Q3DScatter::axisX() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -420,7 +420,7 @@ Q3DValueAxis *Q3DScatter::axisY() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -482,7 +482,7 @@ QList<Q3DValueAxis *> Q3DScatter::axes() const
* the \a proxy to this graph.
*
* If the \a proxy is null, a temporary default proxy is created and activated.
- * This temporary proxy is destroyed if another \a proxy is explicitly set active via this method.
+ * This temporary proxy is destroyed if another \a proxy is set explicitly active via this method.
*
* \sa addDataProxy(), releaseDataProxy()
*/
diff --git a/src/datavisualization/engine/q3dscene.cpp b/src/datavisualization/engine/q3dscene.cpp
index 4908bde4..3789ea9f 100644
--- a/src/datavisualization/engine/q3dscene.cpp
+++ b/src/datavisualization/engine/q3dscene.cpp
@@ -30,7 +30,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DScene
* \inmodule QtDataVisualization
* \brief Q3DScene class provides description of the 3D scene being visualized.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* The 3D scene contains a single active camera and a single active light source.
* Visualized data is assumed to be at a fixed location.
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp
index 2a6506e1..42260e8b 100644
--- a/src/datavisualization/engine/q3dsurface.cpp
+++ b/src/datavisualization/engine/q3dsurface.cpp
@@ -30,7 +30,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DSurface
* \inmodule QtDataVisualization
* \brief The Q3DSurface class provides methods for rendering 3D surface plots.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* This class enables developers to render 3D surface plots and to view them by rotating the scene
* freely. The class provides configurable gradient texture to illustrate the height on the data. The
@@ -48,11 +48,11 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* To rotate the graph, hold down the right mouse button and move the mouse. Zooming is done using mouse
* wheel. Both assume the default input handler is in use.
*
- * If no axes are explicitly set to Q3DSurface, temporary default axes with no labels are created.
- * These default axes can be modified via axis accessors, but as soon any axis is explicitly
- * set for the orientation, the default axis for that orientation is destroyed.
+ * If no axes are set explicitly to Q3DSurface, temporary default axes with no labels are created.
+ * These default axes can be modified via axis accessors, but as soon any axis is set explicitly
+ * for the orientation, the default axis for that orientation is destroyed.
*
- * Data proxies work similarly: If no data proxy is explicitly set, Q3DSurface creates a default
+ * Data proxies work similarly: if no data proxy is set explicitly, Q3DSurface creates a default
* proxy. If any other proxy is set as active data proxy later, the default proxy and all data
* added to it is destroyed.
*
@@ -323,7 +323,7 @@ QFont Q3DSurface::font() const
/*!
* \property Q3DSurface::scene
*
- * This property contains the read only Q3DScene that can be used to access e.g. camera object.
+ * This property contains the read only Q3DScene that can be used to access, for example, a camera object.
*/
Q3DScene *Q3DSurface::scene() const
{
@@ -352,7 +352,7 @@ QDataVis::LabelStyle Q3DSurface::labelStyle() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -375,7 +375,7 @@ Q3DValueAxis *Q3DSurface::axisX() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -398,7 +398,7 @@ Q3DValueAxis *Q3DSurface::axisY() const
*
* If the \a axis is null, a temporary default axis with no labels and automatically adjusting
* range is created.
- * This temporary axis is destroyed if another \a axis is explicitly set to same orientation.
+ * This temporary axis is destroyed if another \a axis is set explicitly to the same orientation.
*
* \sa addAxis(), releaseAxis()
*/
@@ -460,7 +460,7 @@ QList<Q3DValueAxis *> Q3DSurface::axes() const
* the \a proxy to this graph.
*
* If the \a proxy is null, a temporary default proxy is created and activated.
- * This temporary proxy is destroyed if another \a proxy is explicitly set active via this method.
+ * This temporary proxy is destroyed if another \a proxy is set explicitly active via this method.
*
* \sa addDataProxy(), releaseDataProxy()
*/
diff --git a/src/datavisualization/engine/q3dwindow.cpp b/src/datavisualization/engine/q3dwindow.cpp
index 9b607e1d..2c0729ba 100644
--- a/src/datavisualization/engine/q3dwindow.cpp
+++ b/src/datavisualization/engine/q3dwindow.cpp
@@ -33,7 +33,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
* \class Q3DWindow
* \inmodule QtDataVisualization
* \brief The Q3DWindow class provides a window and render loop.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.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.
@@ -51,7 +51,7 @@ Q3DWindow::Q3DWindow(QWindow *parent)
{
setSurfaceType(QWindow::OpenGLSurface);
QSurfaceFormat surfaceFormat;
- surfaceFormat.setDepthBufferSize(16);
+ surfaceFormat.setDepthBufferSize(24);
#if !defined(QT_OPENGL_ES_2)
surfaceFormat.setSamples(8);
surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL);
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index d2f983f1..a187e3a4 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -182,9 +182,7 @@ void Scatter3DRenderer::updateScene(Q3DScene *scene)
if (m_hasHeightAdjustmentChanged) {
// Set initial m_cachedScene->activeCamera() position. Also update if height adjustment has changed.
- scene->activeCamera()->setBaseOrientation(QVector3D(0.0f, 0.0f, cameraDistance + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ scene->activeCamera()->setBaseOrientation(cameraDistanceVector, zeroVector, upVector);
m_hasHeightAdjustmentChanged = false;
}
@@ -208,17 +206,21 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
{
GLfloat backgroundRotation = 0;
+ const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
+
// Specify viewport
glViewport(m_mainViewPort.x(), m_mainViewPort.y(),
m_mainViewPort.width(), m_mainViewPort.height());
// Set up projection matrix
QMatrix4x4 projectionMatrix;
- projectionMatrix.perspective(45.0f, (GLfloat)m_mainViewPort.width()
- / (GLfloat)m_mainViewPort.height(), 0.1f, 100.0f);
+ GLfloat viewPortRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height();
+ projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f);
// Calculate view matrix
- QMatrix4x4 viewMatrix = m_cachedScene->activeCamera()->viewMatrix();
+ QMatrix4x4 viewMatrix = activeCamera->viewMatrix();
+
+ QMatrix4x4 projectionViewMatrix = projectionMatrix * viewMatrix;
// Calculate label flipping
if (viewMatrix.row(0).x() > 0)
@@ -257,10 +259,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
GLfloat heightScaler = 0.0f;
GLfloat widthScaler = 0.0f;
GLfloat depthScaler = 0.0f;
-
+ QVector3D modelScaler(widthMultiplier + widthScaler,
+ heightMultiplier + heightScaler,
+ depthMultiplier + depthScaler);
// Introduce regardless of shadow quality to simplify logic
QMatrix4x4 depthViewMatrix;
QMatrix4x4 depthProjectionMatrix;
+ QMatrix4x4 depthProjectionViewMatrix;
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -269,7 +274,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_depthShader->bind();
// Set viewport for depth map rendering. Must match texture size. Larger values give smoother shadows.
- glViewport(m_mainViewPort.x(), m_mainViewPort.y(),
+ glViewport(0, 0,
m_mainViewPort.width() * m_shadowQualityMultiplier,
m_mainViewPort.height() * m_shadowQualityMultiplier);
@@ -282,28 +287,28 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
// Get the depth view matrix
// It may be possible to hack lightPos here if we want to make some tweaks to shadow
- QVector3D depthLightPos = m_cachedScene->activeCamera()->calculatePositionRelativeToCamera(
- defaultLightPos, 0.0f, 1.0f / m_autoScaleAdjustment);
- depthViewMatrix.lookAt(depthLightPos, QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ QVector3D depthLightPos = activeCamera->calculatePositionRelativeToCamera(
+ zeroVector, 0.0f, 2.5f / m_autoScaleAdjustment);
+ depthViewMatrix.lookAt(depthLightPos, zeroVector, upVector);
// TODO: Why does depthViewMatrix.column(3).y() goes to zero when we're directly above?
// That causes the scene to be not drawn from above -> must be fixed
// qDebug() << lightPos << depthViewMatrix << depthViewMatrix.column(3);
// Set the depth projection matrix
#ifndef USE_WIDER_SHADOWS
// Use this for perspective shadows
- depthProjectionMatrix.perspective(15.0f, (GLfloat)m_mainViewPort.width()
- / (GLfloat)m_mainViewPort.height(), 3.0f, 100.0f);
+ depthProjectionMatrix.perspective(15.0f, viewPortRatio, 3.0f, 100.0f);
#else
// Use these for orthographic shadows
//depthProjectionMatrix.ortho(-aspectRatio * 2.0f, aspectRatio * 2.0f,
// -m_heightNormalizer * 2.0f, m_heightNormalizer * 2.0f,
// 0.0f, 100.0f);
- GLfloat testAspectRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height();
+ GLfloat testAspectRatio = viewPortRatio;
depthProjectionMatrix.ortho(-testAspectRatio * 2.0f, testAspectRatio * 2.0f,
-m_heightNormalizer * 2.0f, m_heightNormalizer * 2.0f,
0.0f, 100.0f);
#endif
+ depthProjectionViewMatrix = depthProjectionMatrix * depthViewMatrix;
+
// Draw dots to depth buffer
for (int dot = 0; dot < m_renderItemArray.size(); dot++) {
const ScatterRenderItem &item = m_renderItemArray.at(dot);
@@ -313,17 +318,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- modelMatrix.translate(item.translation().x(),
- item.translation().y(),
- item.translation().z());
- modelMatrix.scale(QVector3D(widthMultiplier + widthScaler,
- heightMultiplier + heightScaler,
- depthMultiplier + depthScaler));
+ modelMatrix.translate(item.translation());
+ modelMatrix.scale(modelScaler);
//modelMatrix.scale(QVector3D(widthMultiplier * item.size() + widthScaler,
// heightMultiplier * item.size() + heightScaler,
// depthMultiplier * item.size() + depthScaler));
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_depthShader->setUniformValue(m_depthShader->MVP(), MVPMatrix);
@@ -364,14 +365,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
glEnable(GL_TEXTURE_2D);
QMatrix4x4 modelMatrix;
QMatrix4x4 viewmatrix;
- viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
- modelMatrix.translate(0.0, 0.0, zComp);
- QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
+ viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f), zeroVector, upVector);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
- m_drawer->drawObject(m_labelShader, m_labelObj,
- m_depthTexture);
+ m_drawer->drawObject(m_labelShader, m_labelObj, m_depthTexture);
glDisable(GL_TEXTURE_2D);
m_labelShader->release();
#endif
@@ -402,17 +399,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- modelMatrix.translate(item.translation().x(),
- item.translation().y(),
- item.translation().z());
- modelMatrix.scale(QVector3D(widthMultiplier + widthScaler,
- heightMultiplier + heightScaler,
- depthMultiplier + depthScaler));
+ modelMatrix.translate(item.translation());
+ modelMatrix.scale(modelScaler);
//modelMatrix.scale(QVector3D(widthMultiplier * item.size() + widthScaler,
// heightMultiplier * item.size() + heightScaler,
// depthMultiplier * item.size() + depthScaler));
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
QVector3D dotColor = indexToSelectionColor(dot);
dotColor /= 255.0f;
@@ -456,14 +449,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
glEnable(GL_TEXTURE_2D);
QMatrix4x4 modelMatrix;
QMatrix4x4 viewmatrix;
- viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.0f + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
- modelMatrix.translate(0.0, 0.0, zComp);
- QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
+ viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.0f), zeroVector, upVector);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
- m_drawer->drawObject(m_labelShader, m_labelObj,
- m_selectionTexture);
+ m_drawer->drawObject(m_labelShader, m_labelObj, m_selectionTexture);
glDisable(GL_TEXTURE_2D);
m_labelShader->release();
#endif
@@ -498,6 +487,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
ScatterRenderItem *selectedItem(0);
+ QVector3D baseColor = Utils::vectorFromColor(m_cachedTheme.m_baseColor);
+
for (int dot = 0; dot < m_renderItemArray.size(); dot++) {
ScatterRenderItem &item = m_renderItemArray[dot];
if (!item.isVisible())
@@ -505,40 +496,31 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(item.translation().x(),
- item.translation().y(),
- item.translation().z());
- modelMatrix.scale(QVector3D(widthMultiplier + widthScaler,
- heightMultiplier + heightScaler,
- depthMultiplier + depthScaler));
+ modelMatrix.translate(item.translation());
+ modelMatrix.scale(modelScaler);
//modelMatrix.scale(QVector3D(widthMultiplier * item.size() + widthScaler,
// heightMultiplier * item.size() + heightScaler,
// depthMultiplier * item.size() + depthScaler));
- itModelMatrix.scale(QVector3D(widthMultiplier + widthScaler,
- heightMultiplier + heightScaler,
- depthMultiplier + depthScaler));
+ itModelMatrix.scale(modelScaler);
//itModelMatrix.scale(QVector3D(widthMultiplier * item.size() + widthScaler,
// heightMultiplier * item.size() + heightScaler,
// depthMultiplier * item.size() + depthScaler));
#ifdef SHOW_DEPTH_TEXTURE_SCENE
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
#if 0
- QVector3D baseColor = Utils::vectorFromColor(m_cachedTheme.m_baseColor);
QVector3D heightColor =
Utils::vectorFromColor(m_cachedTheme.m_heightColor) * item.translation().y();
QVector3D dotColor = baseColor + heightColor;
#else
- QVector3D dotColor = Utils::vectorFromColor(m_cachedTheme.m_baseColor);
+ QVector3D dotColor = baseColor;
#endif
GLfloat lightStrength = m_cachedTheme.m_lightStrength;
@@ -560,6 +542,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_dotShader->setUniformValue(m_dotShader->shadowQ(), m_shadowQualityToShader);
m_dotShader->setUniformValue(m_dotShader->depth(), depthMVPMatrix);
m_dotShader->setUniformValue(m_dotShader->lightS(), lightStrength / 10.0f);
@@ -585,11 +568,12 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
glCullFace(GL_BACK);
+ GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f;
+
// Draw background
if (m_cachedIsBackgroundEnabled && m_backgroundObj) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
@@ -601,9 +585,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
backgroundMargin,
(aspectRatio * backgroundMargin));
#endif
- modelMatrix.translate(0.0f, 0.0f, zComp);
modelMatrix.scale(bgScale);
- itModelMatrix.scale(bgScale);
// If we're viewing from below, background object must be flipped
if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
@@ -611,14 +593,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
} else {
modelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
}
+ itModelMatrix = modelMatrix; // Only scaling and rotations, can be used directly
#ifdef SHOW_DEPTH_TEXTURE_SCENE
- MVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
-
QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
// Set shader bindings
@@ -635,11 +616,12 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_backgroundShader->setUniformValue(m_backgroundShader->shadowQ(),
m_shadowQualityToShader);
m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
+ adjustedLightStrength);
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj, 0, m_depthTexture);
@@ -672,6 +654,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
if (m_cachedIsGridEnabled && m_heightNormalizer) {
ShaderHelper *lineShader = m_backgroundShader;
+
// Bind line shader
lineShader->bind();
@@ -681,6 +664,18 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+#if !defined(QT_OPENGL_ES_2)
+ if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
+ // Set shadowed shader bindings
+ lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ lineShader->setUniformValue(lineShader->lightS(),
+ m_cachedTheme.m_lightStrength / 20.0f);
+ } else
+#endif
+ {
+ // Set shadowless shader bindings
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ }
// Rows (= Z)
if (m_axisCacheZ.segmentCount() > 0) {
@@ -695,38 +690,35 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
int lastSegment = axisCacheMax->subSegmentCount() * axisCacheMax->segmentCount();
#endif
+#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
+ QVector3D gridLineScaler(
+ (aspectRatio * backgroundMargin * m_areaSize.width()) / m_scaleFactor,
+ gridLineWidth, gridLineWidth);
+#else // ..and this if we want uniform scaling based on largest dimension
+ QVector3D gridLineScaler((aspectRatio * backgroundMargin),
+ gridLineWidth, gridLineWidth);
+#endif
+
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_yFlipped)
- modelMatrix.translate(0.0f, backgroundMargin, linePos / m_scaleFactor + zComp);
+ modelMatrix.translate(0.0f, backgroundMargin, linePos / m_scaleFactor);
else
- modelMatrix.translate(0.0f, -backgroundMargin, linePos / m_scaleFactor + zComp);
-#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
- modelMatrix.scale(
- QVector3D(
- (aspectRatio * backgroundMargin * m_areaSize.width()) / m_scaleFactor,
- gridLineWidth, gridLineWidth));
- itModelMatrix.scale(
- QVector3D(
- (aspectRatio * backgroundMargin * m_areaSize.width()) / m_scaleFactor,
- gridLineWidth, gridLineWidth));
-#else // ..and this if we want uniform scaling based on largest dimension
- modelMatrix.scale(QVector3D((aspectRatio * backgroundMargin),
- gridLineWidth, gridLineWidth));
- itModelMatrix.scale(QVector3D(aspectRatio * backgroundMargin,
- gridLineWidth, gridLineWidth));
-#endif
+ modelMatrix.translate(0.0f, -backgroundMargin, linePos / m_scaleFactor);
+
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -736,21 +728,14 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -758,6 +743,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
}
// Side wall lines
+ gridLineScaler = QVector3D(gridLineWidth, backgroundMargin, gridLineWidth);
#ifndef USE_UNIFORM_SCALING
GLfloat lineXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
/ m_scaleFactor;
@@ -772,15 +758,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(lineXTrans, 0.0f, linePos / m_scaleFactor + zComp);
- modelMatrix.scale(QVector3D(gridLineWidth, backgroundMargin, gridLineWidth));
- itModelMatrix.scale(QVector3D(gridLineWidth, backgroundMargin, gridLineWidth));
+ modelMatrix.translate(lineXTrans, 0.0f, linePos / m_scaleFactor);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -791,20 +775,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -819,44 +796,36 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
GLfloat lineStep = aspectRatio * m_axisCacheX.subSegmentStep();
GLfloat linePos = aspectRatio * m_axisCacheX.min();
int lastSegment = m_axisCacheX.subSegmentCount() * m_axisCacheX.segmentCount();
+ QVector3D gridLineScaler(
+ gridLineWidth, gridLineWidth,
+ (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor);
#else
GLfloat lineStep = aspectRatio * axisCacheMax->subSegmentStep();
GLfloat linePos = -aspectRatio * m_scaleFactor;
int lastSegment = axisCacheMax->subSegmentCount() * axisCacheMax->segmentCount();
+ QVector3D gridLineScaler(gridLineWidth, gridLineWidth,
+ aspectRatio * backgroundMargin);
#endif
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_yFlipped)
- modelMatrix.translate(linePos / m_scaleFactor, backgroundMargin, zComp);
+ modelMatrix.translate(linePos / m_scaleFactor, backgroundMargin, 0.0f);
else
- modelMatrix.translate(linePos / m_scaleFactor, -backgroundMargin, zComp);
-#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
- modelMatrix.scale(
- QVector3D(
- gridLineWidth, gridLineWidth,
- (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor));
- itModelMatrix.scale(
- QVector3D(
- gridLineWidth, gridLineWidth,
- (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor));
-#else // ..and this if we want uniform scaling based on largest dimension
- modelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- aspectRatio * backgroundMargin));
- itModelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- aspectRatio * backgroundMargin));
-#endif
+ modelMatrix.translate(linePos / m_scaleFactor, -backgroundMargin, 0.0f);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -867,19 +836,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -898,18 +861,18 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
if (!m_zFlipped)
lineZTrans = -lineZTrans;
+ gridLineScaler = QVector3D(gridLineWidth, backgroundMargin, gridLineWidth);
+
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(linePos / m_scaleFactor, 0.0f, lineZTrans + zComp);
- modelMatrix.scale(QVector3D(gridLineWidth, backgroundMargin, gridLineWidth));
- itModelMatrix.scale(QVector3D(gridLineWidth, backgroundMargin, gridLineWidth));
+ modelMatrix.translate(linePos / m_scaleFactor, 0.0f, lineZTrans);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -920,20 +883,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -951,8 +907,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
GLfloat lineZTrans = (aspectRatio * backgroundMargin * m_areaSize.height())
/ m_scaleFactor;
+ QVector3D gridLineScaler(
+ (aspectRatio * backgroundMargin * m_areaSize.width() / m_scaleFactor),
+ gridLineWidth, gridLineWidth);
#else // ..and this if we want uniform scaling based on largest dimension
GLfloat lineZTrans = aspectRatio * backgroundMargin;
+ QVector3D gridLineScaler((aspectRatio * backgroundMargin),
+ gridLineWidth, gridLineWidth);
#endif
if (!m_zFlipped)
lineZTrans = -lineZTrans;
@@ -960,28 +921,14 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(0.0f, linePos / m_heightNormalizer, lineZTrans + zComp);
-#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
- modelMatrix.scale(
- QVector3D(
- (aspectRatio * backgroundMargin * m_areaSize.width() / m_scaleFactor),
- gridLineWidth, gridLineWidth));
- itModelMatrix.scale(
- QVector3D(
- (aspectRatio * backgroundMargin * m_areaSize.width() / m_scaleFactor),
- gridLineWidth, gridLineWidth));
-#else // ..and this if we want uniform scaling based on largest dimension
- modelMatrix.scale(QVector3D((aspectRatio * backgroundMargin),
- gridLineWidth, gridLineWidth));
- itModelMatrix.scale(QVector3D(aspectRatio * backgroundMargin,
- gridLineWidth, gridLineWidth));
-#endif
+ modelMatrix.translate(0.0f, linePos / m_heightNormalizer, lineZTrans);
+
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -992,19 +939,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1017,8 +958,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
GLfloat lineXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
/ m_scaleFactor;
+ gridLineScaler = QVector3D(
+ gridLineWidth, gridLineWidth,
+ (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor);
#else // ..and this if we want uniform scaling based on largest dimension
GLfloat lineXTrans = aspectRatio * backgroundMargin;
+ gridLineScaler = QVector3D(gridLineWidth, gridLineWidth,
+ aspectRatio * backgroundMargin);
#endif
if (!m_xFlipped)
lineXTrans = -lineXTrans;
@@ -1026,29 +972,14 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(lineXTrans, linePos / m_heightNormalizer, zComp);
-#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
- modelMatrix.scale(
- QVector3D(
- gridLineWidth, gridLineWidth,
- (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor));
- itModelMatrix.scale(
- QVector3D(
- gridLineWidth, gridLineWidth,
- (aspectRatio * backgroundMargin * m_areaSize.height()) / m_scaleFactor));
+ modelMatrix.translate(lineXTrans, linePos / m_heightNormalizer, 0.0f);
-#else // ..and this if we want uniform scaling based on largest dimension
- modelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- (aspectRatio * backgroundMargin)));
- itModelMatrix.scale(QVector3D(gridLineWidth, gridLineWidth,
- aspectRatio * backgroundMargin));
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
-#endif
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
+ MVPMatrix = projectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1059,20 +990,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1100,41 +1024,40 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
GLfloat posStep = aspectRatio * m_axisCacheZ.segmentStep();
GLfloat labelPos = -aspectRatio * m_axisCacheZ.min();
int lastSegment = m_axisCacheZ.segmentCount();
+ GLfloat labelXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
+ / m_scaleFactor + labelMargin;
#else
GLfloat posStep = aspectRatio * axisCacheMax->segmentStep();
GLfloat labelPos = aspectRatio * m_scaleFactor;
int lastSegment = axisCacheMax->segmentCount();
+ GLfloat labelXTrans = aspectRatio * backgroundMargin + labelMargin;
#endif
int labelNbr = 0;
+ GLfloat labelYTrans = -backgroundMargin;
+ GLfloat rotLabelX = -90.0f;
+ GLfloat rotLabelY = 0.0f;
+ GLfloat rotLabelZ = 0.0f;
+ Qt::AlignmentFlag alignment = Qt::AlignRight;
+ if (m_zFlipped)
+ rotLabelY = 180.0f;
+ if (m_xFlipped) {
+ labelXTrans = -labelXTrans;
+ alignment = Qt::AlignLeft;
+ }
+ if (m_yFlipped) {
+ rotLabelZ += 180.0f;
+ rotLabelY += 180.0f;
+ labelYTrans = -labelYTrans;
+ }
+ QVector3D labelRotateVector(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTrans = QVector3D(labelXTrans, labelYTrans, 0.0f);
for (int segment = 0; segment <= lastSegment; segment++) {
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
if (m_axisCacheZ.labelItems().size() > labelNbr) {
- GLfloat labelXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
- / m_scaleFactor + labelMargin;
#else // ..and this if we want uniform scaling based on largest dimension
if (axisCacheMax->labelItems().size() > labelNbr) {
- GLfloat labelXTrans = aspectRatio * backgroundMargin + labelMargin;
#endif
- GLfloat labelYTrans = -backgroundMargin;
- GLfloat rotLabelX = -90.0f;
- GLfloat rotLabelY = 0.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignRight;
- if (m_zFlipped)
- rotLabelY = 180.0f;
- if (m_xFlipped) {
- labelXTrans = -labelXTrans;
- alignment = Qt::AlignLeft;
- }
- if (m_yFlipped) {
- rotLabelZ += 180.0f;
- rotLabelY += 180.0f;
- labelYTrans = -labelYTrans;
- }
- QVector3D labelTrans = QVector3D(labelXTrans,
- labelYTrans,
- labelPos / m_scaleFactor + zComp);
-
+ labelTrans.setZ(labelPos / m_scaleFactor);
// Draw the label here
m_dummyRenderItem.setTranslation(labelTrans);
@@ -1145,11 +1068,9 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#endif
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(), true, true, Drawer::LabelMid,
- alignment);
+ zeroVector, labelRotateVector, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera, true, true,
+ Drawer::LabelMid, alignment);
}
labelNbr++;
labelPos -= posStep;
@@ -1161,40 +1082,40 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
GLfloat posStep = aspectRatio * m_axisCacheX.segmentStep();
GLfloat labelPos = aspectRatio * m_axisCacheX.min();
int lastSegment = m_axisCacheX.segmentCount();
+ GLfloat labelZTrans = (aspectRatio * backgroundMargin * m_areaSize.height())
+ / m_scaleFactor + labelMargin;
#else
GLfloat posStep = aspectRatio * axisCacheMax->segmentStep();
GLfloat labelPos = -aspectRatio * m_scaleFactor;
int lastSegment = axisCacheMax->segmentCount();
+ GLfloat labelZTrans = aspectRatio * backgroundMargin + labelMargin;
#endif
int labelNbr = 0;
+ GLfloat labelYTrans = -backgroundMargin;
+ GLfloat rotLabelX = -90.0f;
+ GLfloat rotLabelY = 90.0f;
+ GLfloat rotLabelZ = 0.0f;
+ Qt::AlignmentFlag alignment = Qt::AlignLeft;
+ if (m_xFlipped)
+ rotLabelY = -90.0f;
+ if (m_zFlipped) {
+ labelZTrans = -labelZTrans;
+ alignment = Qt::AlignRight;
+ }
+ if (m_yFlipped) {
+ rotLabelZ += 180.0f;
+ rotLabelY += 180.0f;
+ labelYTrans = -labelYTrans;
+ }
+ QVector3D labelRotateVector(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTrans = QVector3D(0.0f, labelYTrans, labelZTrans);
for (int segment = 0; segment <= lastSegment; segment++) {
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
if (m_axisCacheX.labelItems().size() > labelNbr) {
- GLfloat labelZTrans = (aspectRatio * backgroundMargin * m_areaSize.height())
- / m_scaleFactor + labelMargin;
#else // ..and this if we want uniform scaling based on largest dimension
if (axisCacheMax->labelItems().size() > labelNbr) {
- GLfloat labelZTrans = aspectRatio * backgroundMargin + labelMargin;
#endif
- GLfloat labelYTrans = -backgroundMargin;
- GLfloat rotLabelX = -90.0f;
- GLfloat rotLabelY = 90.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignLeft;
- if (m_xFlipped)
- rotLabelY = -90.0f;
- if (m_zFlipped) {
- labelZTrans = -labelZTrans;
- alignment = Qt::AlignRight;
- }
- if (m_yFlipped) {
- rotLabelZ += 180.0f;
- rotLabelY += 180.0f;
- labelYTrans = -labelYTrans;
- }
- QVector3D labelTrans = QVector3D(labelPos / m_scaleFactor,
- labelYTrans,
- labelZTrans + zComp);
+ labelTrans.setX(labelPos / m_scaleFactor);
// Draw the label here
m_dummyRenderItem.setTranslation(labelTrans);
@@ -1205,11 +1126,9 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#endif
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(), true, true, Drawer::LabelMid,
- alignment);
+ zeroVector, labelRotateVector, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera, true, true,
+ Drawer::LabelMid, alignment);
}
labelNbr++;
labelPos += posStep;
@@ -1220,71 +1139,69 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
GLfloat posStep = m_axisCacheY.segmentStep();
GLfloat labelPos = m_axisCacheY.min();
int labelNbr = 0;
- for (int segment = 0; segment <= m_axisCacheY.segmentCount(); segment++) {
- if (m_axisCacheY.labelItems().size() > labelNbr) {
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
- GLfloat labelXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
- / m_scaleFactor;
- GLfloat labelZTrans = (aspectRatio * backgroundMargin * m_areaSize.height())
- / m_scaleFactor;
+ GLfloat labelXTrans = (aspectRatio * backgroundMargin * m_areaSize.width())
+ / m_scaleFactor;
+ GLfloat labelZTrans = (aspectRatio * backgroundMargin * m_areaSize.height())
+ / m_scaleFactor;
#else // ..and this if we want uniform scaling based on largest dimension
- GLfloat labelXTrans = aspectRatio * backgroundMargin;
- GLfloat labelZTrans = labelXTrans;
+ GLfloat labelXTrans = aspectRatio * backgroundMargin;
+ GLfloat labelZTrans = labelXTrans;
#endif
- GLfloat labelMarginXTrans = labelMargin;
- GLfloat labelMarginZTrans = labelMargin;
- GLfloat labelYTrans = labelPos / m_heightNormalizer;
- GLfloat rotLabelX = 0.0f;
- GLfloat rotLabelY = -90.0f;
- GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignLeft;
- if (!m_xFlipped) {
- labelXTrans = -labelXTrans;
- labelMarginXTrans = -labelMargin;
- rotLabelY = 90.0f;
- }
- if (m_zFlipped) {
- labelZTrans = -labelZTrans;
- labelMarginZTrans = -labelMargin;
- alignment = Qt::AlignRight;
- }
+ // Back wall init
+ GLfloat labelMarginXTrans = labelMargin;
+ GLfloat labelMarginZTrans = labelMargin;
+ GLfloat rotLabelX = 0.0f;
+ GLfloat rotLabelY = -90.0f;
+ GLfloat rotLabelZ = 0.0f;
+ Qt::AlignmentFlag alignmentBack = Qt::AlignLeft;
+ if (!m_xFlipped) {
+ labelXTrans = -labelXTrans;
+ labelMarginXTrans = -labelMargin;
+ rotLabelY = 90.0f;
+ }
+ if (m_zFlipped) {
+ labelZTrans = -labelZTrans;
+ labelMarginZTrans = -labelMargin;
+ alignmentBack = Qt::AlignRight;
+ }
+ QVector3D labelRotateVectorBack(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTransBack = QVector3D(labelXTrans, 0.0f, labelZTrans + labelMarginZTrans);
+
+ // Side wall init
+ Qt::AlignmentFlag alignmentSide = Qt::AlignLeft;
+ if (m_xFlipped)
+ alignmentSide = Qt::AlignLeft;
+ else
+ alignmentSide = Qt::AlignRight;
+ if (m_zFlipped)
+ rotLabelY = 180.0f;
+ else
+ rotLabelY = 0.0f;
+
+ QVector3D labelRotateVectorSide(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTransSide(-labelXTrans - labelMarginXTrans, 0.0f, -labelZTrans);
+ for (int segment = 0; segment <= m_axisCacheY.segmentCount(); segment++) {
+ if (m_axisCacheY.labelItems().size() > labelNbr) {
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(labelNbr);
+ const GLfloat labelYTrans = labelPos / m_heightNormalizer;
// Back wall
- QVector3D labelTrans = QVector3D(labelXTrans, labelYTrans,
- labelZTrans + labelMarginZTrans + zComp);
-
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
+ labelTransBack.setY(labelYTrans);
+ m_dummyRenderItem.setTranslation(labelTransBack);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(), true, true, Drawer::LabelMid,
- alignment);
+ zeroVector, labelRotateVectorBack, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera, true, true,
+ Drawer::LabelMid, alignmentBack);
// Side wall
- if (m_xFlipped)
- alignment = Qt::AlignLeft;
- else
- alignment = Qt::AlignRight;
- if (m_zFlipped)
- rotLabelY = 180.0f;
- else
- rotLabelY = 0.0f;
-
- labelTrans = QVector3D(-labelXTrans - labelMarginXTrans, labelYTrans,
- -labelZTrans + zComp);
-
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
+ labelTransSide.setY(labelYTrans);
+ m_dummyRenderItem.setTranslation(labelTransSide);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(rotLabelX, rotLabelY, rotLabelZ),
- 0, m_cachedSelectionMode,
- m_labelShader, m_labelObj, m_cachedScene->activeCamera(), true, true, Drawer::LabelMid,
- alignment);
+ zeroVector, labelRotateVectorSide, 0, m_cachedSelectionMode,
+ m_labelShader, m_labelObj, activeCamera, true, true,
+ Drawer::LabelMid, alignmentSide);
}
labelNbr++;
labelPos += posStep;
@@ -1348,11 +1265,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
}
m_drawer->drawLabel(*selectedItem, labelItem, viewMatrix, projectionMatrix,
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 0.0f, 0.0f), 0,
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, m_cachedScene->activeCamera(), true, false,
- Drawer::LabelMid);
+ zeroVector, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, true, false, Drawer::LabelMid);
// Reset label update flag; they should have been updated when we get here
m_updateLabels = false;
@@ -1489,7 +1403,7 @@ void Scatter3DRenderer::calculateTranslation(ScatterRenderItem &item)
GLfloat xTrans = (aspectRatio * item.position().x()) / m_scaleFactor;
GLfloat zTrans = -(aspectRatio * item.position().z()) / m_scaleFactor;
GLfloat yTrans = item.position().y() / m_heightNormalizer;
- item.setTranslation(QVector3D(xTrans, yTrans, zTrans + zComp));
+ item.setTranslation(QVector3D(xTrans, yTrans, zTrans));
//qDebug() << item.translation();
}
@@ -1526,8 +1440,13 @@ void Scatter3DRenderer::initSelectionShader()
void Scatter3DRenderer::initSelectionBuffer()
{
- if (m_selectionTexture)
+ if (m_selectionTexture) {
m_textureHelper->deleteTexture(&m_selectionTexture);
+ m_selectionTexture = 0;
+ }
+
+ if (m_mainViewPort.size().isEmpty())
+ return;
m_selectionTexture = m_textureHelper->createSelectionTexture(m_mainViewPort.size(),
m_selectionFrameBuffer,
@@ -1551,6 +1470,9 @@ void Scatter3DRenderer::updateDepthBuffer()
m_depthTexture = 0;
}
+ if (m_mainViewPort.size().isEmpty())
+ return;
+
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
m_depthTexture = m_textureHelper->createDepthTexture(m_mainViewPort.size(),
m_depthFrameBuffer,
diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp
index 4fa9f688..19294ac8 100644
--- a/src/datavisualization/engine/selectionpointer.cpp
+++ b/src/datavisualization/engine/selectionpointer.cpp
@@ -105,11 +105,9 @@ void SelectionPointer::render(GLuint defaultFboHandle)
QMatrix4x4 projectionMatrix;
if (m_cachedIsSlicingActivated) {
GLfloat aspect = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height();
- viewMatrix.lookAt(QVector3D(0.0f, 0.0f, zComp + 1.0),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ viewMatrix.lookAt(QVector3D(0.0f, 0.0f, 1.0f), zeroVector, upVector);
projectionMatrix.ortho(-sliceUnits * aspect, sliceUnits * aspect,
- -sliceUnits, sliceUnits, -1.0f, 14.0f);
+ -sliceUnits, sliceUnits, -1.0f, 4.0f);
} else {
viewMatrix = camera->viewMatrix();
projectionMatrix.perspective(45.0f, (GLfloat)m_mainViewPort.width()
@@ -124,7 +122,7 @@ void SelectionPointer::render(GLuint defaultFboHandle)
QMatrix4x4 MVPMatrix;
// Position the pointer ball
- modelMatrix.translate(m_position + QVector3D(0.0f, 0.0f, zComp));
+ modelMatrix.translate(m_position);
// Scale the point with fixed values (at this point)
modelMatrix.scale(QVector3D(0.05f, 0.05f, 0.05f));
@@ -161,7 +159,7 @@ void SelectionPointer::render(GLuint defaultFboHandle)
// Position label
QVector3D labelAlign(0.0f, 1.0f * scaledFontSize + 0.05f, 0.0f);
- modelMatrixLabel.translate(m_position + labelAlign + QVector3D(0.0f, 0.0f, zComp));
+ modelMatrixLabel.translate(m_position + labelAlign);
// Position the label towards the camera
qreal camRotationsX = camera->xRotation();
diff --git a/src/datavisualization/engine/shaders/surfaceFlat.frag b/src/datavisualization/engine/shaders/surfaceFlat.frag
index a8a3dbb1..1f2a3822 100644
--- a/src/datavisualization/engine/shaders/surfaceFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceFlat.frag
@@ -1,8 +1,10 @@
-#version 150
+#version 120
+
+#extension GL_EXT_gpu_shader4 : require
varying highp vec3 coords_mdl;
varying highp vec3 position_wrld;
-flat in highp vec3 normal_cmr;
+flat varying highp vec3 normal_cmr;
varying highp vec3 eyeDirection_cmr;
varying highp vec3 lightDirection_cmr;
diff --git a/src/datavisualization/engine/shaders/surfaceFlat.vert b/src/datavisualization/engine/shaders/surfaceFlat.vert
index 7e248d02..0d39f6bc 100644
--- a/src/datavisualization/engine/shaders/surfaceFlat.vert
+++ b/src/datavisualization/engine/shaders/surfaceFlat.vert
@@ -1,4 +1,6 @@
-#version 150
+#version 120
+
+#extension GL_EXT_gpu_shader4 : require
attribute highp vec3 vertexPosition_mdl;
attribute highp vec3 vertexNormal_mdl;
@@ -10,7 +12,7 @@ uniform highp mat4 itM;
uniform highp vec3 lightPosition_wrld;
varying highp vec3 position_wrld;
-flat out highp vec3 normal_cmr;
+flat varying highp vec3 normal_cmr;
varying highp vec3 eyeDirection_cmr;
varying highp vec3 lightDirection_cmr;
varying highp vec3 coords_mdl;
diff --git a/src/datavisualization/engine/shaders/surface_ES2.frag b/src/datavisualization/engine/shaders/surface_ES2.frag
index a9aec528..7f40ba4d 100644
--- a/src/datavisualization/engine/shaders/surface_ES2.frag
+++ b/src/datavisualization/engine/shaders/surface_ES2.frag
@@ -11,7 +11,7 @@ uniform highp float lightStrength;
uniform highp float ambientStrength;
void main() {
- highp vec2 gradientUV = vec2(0.5, (coords_mdl.y + 1.0) / 2.0);
+ highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.001) / 2.0); // ~1000 pixel texture, we need a margin for 1/1000 rounding error
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index c8823eb7..8d1bcf85 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -39,7 +39,7 @@ Surface3DController::Surface3DController(QRect rect)
setActiveDataProxy(0);
// Setting a null axis creates a new default axis according to orientation and graph type.
- // Note: These cannot be set in Abstract3DController constructor, as they will call virtual
+ // Note: these cannot be set in the Abstract3DController constructor, as they will call virtual
// functions implemented by subclasses.
setAxisX(0);
setAxisY(0);
@@ -142,7 +142,7 @@ bool Surface3DController::surfaceGrid()
void Surface3DController::setGradient(const QLinearGradient &gradient)
{
m_userDefinedGradient = gradient;
- m_userDefinedGradient.setStart(1, 1000);
+ m_userDefinedGradient.setStart(2, 1024);
m_userDefinedGradient.setFinalStop(0, 0);
m_changeTracker.gradientColorChanged = true;
emitNeedRender();
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index b73332f3..a989ed3f 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -54,11 +54,8 @@ const GLfloat labelMargin = 0.05f;
const GLfloat backgroundBottom = 1.0f;
const GLfloat gridLineWidth = 0.005f;
const GLfloat sliceZScale = 0.1f;
-const GLfloat surfaceGridYOffsetValue = 0.001f;
const GLfloat sliceUnits = 2.5f;
const int subViewDivider = 5;
-// The second offset to opposite direction is double because same matrix is translated twice
-const GLfloat surfaceGridYOffset[2] = {-surfaceGridYOffsetValue, 2.0f * surfaceGridYOffsetValue};
Surface3DRenderer::Surface3DRenderer(Surface3DController *controller)
: Abstract3DRenderer(controller),
@@ -238,7 +235,7 @@ void Surface3DRenderer::updateDataModel(QSurfaceDataProxy *dataProxy)
if (!m_surfaceObj)
loadSurfaceObj();
- // Note: Data setup can change samplespace (as min width/height is 1)
+ // Note: Data setup can change sample space (as min width/height is 1)
if (m_cachedSmoothSurface) {
m_surfaceObj->setUpSmoothData(m_dataArray, m_sampleSpace, m_heightNormalizer,
m_axisCacheY.min(), dimensionChanged);
@@ -422,9 +419,7 @@ void Surface3DRenderer::updateScene(Q3DScene *scene)
// Set initial camera position
// X must be 0 for rotation to work - we can use "setCameraRotation" for setting it later
if (m_hasHeightAdjustmentChanged) {
- scene->activeCamera()->setBaseOrientation(QVector3D(0.0f, 0.0f, cameraDistance + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ scene->activeCamera()->setBaseOrientation(cameraDistanceVector, zeroVector, upVector);
// For now this is used just to make things once. Proper use will come
m_hasHeightAdjustmentChanged = false;
}
@@ -432,10 +427,10 @@ void Surface3DRenderer::updateScene(Q3DScene *scene)
scene->activeCamera()->d_ptr->updateViewMatrix(m_autoScaleAdjustment);
scene->setLightPositionRelativeToCamera(defaultLightPos);
- if (m_selectionPointer)
- m_selectionPointer->updateScene(scene);
-
Abstract3DRenderer::updateScene(scene);
+
+ if (m_selectionPointer)
+ m_selectionPointer->updateScene(m_cachedScene);
}
void Surface3DRenderer::render(GLuint defaultFboHandle)
@@ -448,17 +443,15 @@ void Surface3DRenderer::render(GLuint defaultFboHandle)
// Handle GL state setup for FBO buffers and clearing of the render surface
Abstract3DRenderer::render(defaultFboHandle);
- // In slice mode; draw slice and render selection ball
- if (m_cachedIsSlicingActivated && m_selectionPointer && m_selectionActive) {
- drawSlicedScene();
- m_selectionPointer->render(defaultFboHandle);
- }
-
// Draw the surface scene
drawScene(defaultFboHandle);
+ // In slice mode; draw slice and render selection ball
+ if (m_cachedIsSlicingActivated)
+ drawSlicedScene();
+
// Render selection ball if not in slice mode
- if (!m_cachedIsSlicingActivated && m_selectionPointer && m_selectionActive)
+ if (m_selectionPointer && m_selectionActive)
m_selectionPointer->render(defaultFboHandle);
// If slicing has been activated by this render pass, we need another render
@@ -481,16 +474,14 @@ void Surface3DRenderer::drawSlicedScene()
GLfloat aspect = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height();
projectionMatrix.ortho(-sliceUnits * aspect, sliceUnits * aspect,
- -sliceUnits, sliceUnits, -1.0f, 14.0f); // 14.0 because of zComp
+ -sliceUnits, sliceUnits, -1.0f, 4.0f);
// Set view matrix
QMatrix4x4 viewMatrix;
- viewMatrix.lookAt(QVector3D(0.0f, 0.0f, zComp + 1.0f),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ viewMatrix.lookAt(QVector3D(0.0f, 0.0f, 1.0f), zeroVector, upVector);
// Set light position
- lightPos = m_cachedScene->activeLight()->position();
+ lightPos = QVector3D(0.0f, 0.0f, 2.0f);
QMatrix4x4 projectionViewMatrix = projectionMatrix * viewMatrix;
@@ -511,11 +502,16 @@ void Surface3DRenderer::drawSlicedScene()
ShaderHelper *surfaceShader = m_shader;
surfaceShader->bind();
+ if (m_cachedSurfaceGridOn) {
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(0.5f, 1.0f);
+ }
+
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(offset, 0.0f, zComp);
+ modelMatrix.translate(offset, 0.0f, 0.0f);
QVector3D scaling(scaleX, 1.0f, sliceZScale);
modelMatrix.scale(scaling);
itModelMatrix.scale(scaling);
@@ -547,24 +543,20 @@ void Surface3DRenderer::drawSlicedScene()
// Draw surface grid
if (m_cachedSurfaceGridOn) {
m_surfaceGridShader->bind();
-
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->color(),
Utils::vectorFromColor(m_cachedTheme.m_gridLine));
- // Draw the grid twice, with slight offset on Y axis to each direction
- for (int i = 0; i < 2; i++) {
- MVPMatrix.translate(0.0f, surfaceGridYOffset[i], 0.0f);
-
- m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
- m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_sliceSurfaceObj);
- }
+ m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
+ m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_sliceSurfaceObj);
m_surfaceGridShader->release();
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
}
}
// Disable textures
glDisable(GL_TEXTURE_2D);
- // lines to the back
+ // Grid lines
if (m_cachedIsGridEnabled && m_heightNormalizer) {
ShaderHelper *lineShader = m_backgroundShader;
// Bind line shader
@@ -578,10 +570,10 @@ void Surface3DRenderer::drawSlicedScene()
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength * 2.0f);
lineShader->setUniformValue(lineShader->lightS(), 0.25f);
+ // Horizontal lines
if (m_axisCacheY.segmentCount() > 0) {
QVector3D gridLineScaleX(scaleXBackground, gridLineWidth, gridLineWidth);
- // Back wall
GLfloat lineStep = 2.0f * m_axisCacheY.subSegmentStep() / m_heightNormalizer;
GLfloat linePos = -1.0f;
int lastSegment = m_axisCacheY.subSegmentCount() * m_axisCacheY.segmentCount();
@@ -591,7 +583,7 @@ void Surface3DRenderer::drawSlicedScene()
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(0.0f, linePos, zComp - sliceZScale);
+ modelMatrix.translate(0.0f, linePos, -sliceZScale);
modelMatrix.scale(gridLineScaleX);
itModelMatrix.scale(gridLineScaleX);
@@ -611,8 +603,7 @@ void Surface3DRenderer::drawSlicedScene()
}
}
- // Floor lines
- QVector3D gridLineScaleZ(gridLineWidth, gridLineWidth, sliceZScale);
+ // Vertical lines
QVector3D gridLineScaleY(gridLineWidth, backgroundMargin, gridLineWidth);
int lastSegment;
@@ -633,36 +624,7 @@ void Surface3DRenderer::drawSlicedScene()
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(linePos, -backgroundMargin, zComp);
-
- modelMatrix.scale(gridLineScaleZ);
- itModelMatrix.scale(gridLineScaleZ);
-
- MVPMatrix = projectionViewMatrix * modelMatrix;
-
- // Set the rest of the shader bindings
- lineShader->setUniformValue(lineShader->model(), modelMatrix);
- lineShader->setUniformValue(lineShader->nModel(),
- itModelMatrix.inverted().transposed());
- lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
-
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj);
-
- linePos += lineStep;
- }
-
- if (m_cachedSelectionMode == QDataVis::SelectionModeSliceRow)
- linePos = m_scaleX;
- else
- linePos = m_scaleZ;
-
- for (int segment = 0; segment <= lastSegment; segment++) {
- QMatrix4x4 modelMatrix;
- QMatrix4x4 MVPMatrix;
- QMatrix4x4 itModelMatrix;
-
- modelMatrix.translate(linePos, 0.0f, zComp - sliceZScale);
+ modelMatrix.translate(linePos, 0.0f, -sliceZScale);
modelMatrix.scale(gridLineScaleY);
itModelMatrix.scale(gridLineScaleY);
@@ -699,9 +661,9 @@ void Surface3DRenderer::drawSlicedScene()
GLfloat labelPos = -1.0f;
int labelNbr = 0;
- QVector3D positionComp(0.0f, 0.0f, zComp);
+ QVector3D positionComp(0.0f, 0.0f, 0.0f);
QVector3D rotation(0.0f, 0.0f, 0.0f);
- QVector3D labelTrans = QVector3D(scaleXBackground + labelMargin, labelPos, zComp);
+ QVector3D labelTrans = QVector3D(scaleXBackground + labelMargin, labelPos, 0.0f);
for (int segment = 0; segment <= m_axisCacheY.segmentCount(); segment++) {
if (m_axisCacheY.labelItems().size() > labelNbr) {
labelTrans.setY(labelPos);
@@ -813,9 +775,8 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
QMatrix4x4 depthProjectionMatrix;
QMatrix4x4 depthProjectionViewMatrix;
-
QVector3D surfaceScaler(m_surfaceScaleX, 1.0f, m_surfaceScaleZ);
- QVector3D surfaceOffset(m_surfaceOffsetX, 0.0f, m_surfaceOffsetZ + zComp);
+ QVector3D surfaceOffset(m_surfaceOffsetX, 0.0f, m_surfaceOffsetZ);
// Draw depth buffer
#if !defined(QT_OPENGL_ES_2)
@@ -837,9 +798,8 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Get the depth view matrix
// It may be possible to hack lightPos here if we want to make some tweaks to shadow
QVector3D depthLightPos = m_cachedScene->activeCamera()->calculatePositionRelativeToCamera(
- QVector3D(0.0f, 0.0f, zComp), 0.0f, 1.5f / m_autoScaleAdjustment);
- depthViewMatrix.lookAt(depthLightPos, QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
+ zeroVector, 0.0f, 3.5f / m_autoScaleAdjustment);
+ depthViewMatrix.lookAt(depthLightPos, zeroVector, upVector);
// TODO: Why does depthViewMatrix.column(3).y() goes to zero when we're directly above?
// That causes the scene to be not drawn from above -> must be fixed
@@ -908,10 +868,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
glEnable(GL_TEXTURE_2D);
QMatrix4x4 modelMatrix;
QMatrix4x4 viewmatrix;
- viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f + zComp),
- QVector3D(0.0f, 0.0f, zComp),
- QVector3D(0.0f, 1.0f, 0.0f));
- modelMatrix.translate(0.0, 0.0, zComp);
+ viewmatrix.lookAt(QVector3D(0.0f, 0.0f, 2.5f), zeroVector, upVector);
QMatrix4x4 MVPMatrix = projectionMatrix * viewmatrix * modelMatrix;
m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
m_drawer->drawObject(m_labelShader, m_labelObj, m_depthTexture);
@@ -979,10 +936,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// For surface we can see climpses from underneath
glDisable(GL_CULL_FACE);
+ if (m_cachedSurfaceGridOn) {
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(0.5f, 1.0f);
+ }
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
modelMatrix.translate(surfaceOffset);
@@ -994,8 +954,6 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
-
// Set shader bindings
m_surfaceShader->setUniformValue(m_surfaceShader->lightP(), lightPos);
m_surfaceShader->setUniformValue(m_surfaceShader->view(), viewMatrix);
@@ -1009,6 +967,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_surfaceShader->setUniformValue(m_surfaceShader->shadowQ(), m_shadowQualityToShader);
m_surfaceShader->setUniformValue(m_surfaceShader->depth(), depthMVPMatrix);
m_surfaceShader->setUniformValue(m_surfaceShader->lightS(), adjustedLightStrength);
@@ -1033,17 +992,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw surface grid
if (m_cachedSurfaceGridOn) {
m_surfaceGridShader->bind();
-
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->color(),
Utils::vectorFromColor(m_cachedTheme.m_gridLine));
- // Draw the grid twice, with slight offset on Y axis to each direction
- for (int i = 0; i < 2; i++) {
- MVPMatrix.translate(0.0f, surfaceGridYOffset[i], 0.0f);
-
- m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
- m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_surfaceObj);
- }
+ m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
+ m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_surfaceObj);
m_surfaceGridShader->release();
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
}
}
@@ -1055,13 +1010,10 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_cachedIsBackgroundEnabled && m_backgroundObj) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(0.0f, 0.0f, zComp);
QVector3D bgScale(m_scaleXWithBackground, backgroundMargin, m_scaleZWithBackground);
modelMatrix.scale(bgScale);
- itModelMatrix.scale(bgScale);
// If we're viewing from below, background object must be flipped
if (m_yFlipped) {
@@ -1071,12 +1023,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
modelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
}
+ itModelMatrix = modelMatrix; // Only scaling and rotations, can be used directly
+
#ifdef SHOW_DEPTH_TEXTURE_SCENE
MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
@@ -1094,6 +1047,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
m_backgroundShader->setUniformValue(m_backgroundShader->shadowQ(),
m_shadowQualityToShader);
m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix);
@@ -1124,6 +1078,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_cachedIsGridEnabled && m_heightNormalizer) {
ShaderHelper *lineShader = m_backgroundShader;
+
// Bind line shader
lineShader->bind();
@@ -1133,18 +1088,29 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+#if !defined(QT_OPENGL_ES_2)
+ if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
+ // Set shadowed shader bindings
+ lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ lineShader->setUniformValue(lineShader->lightS(),
+ m_cachedTheme.m_lightStrength / 20.0f);
+ } else
+#endif
+ {
+ // Set shadowless shader bindings
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ }
// Rows (= Z)
if (m_axisCacheZ.segmentCount() > 0) {
// Floor lines
GLfloat lineStep = 2.0f * aspectRatio * m_axisCacheZ.subSegmentStep() / m_scaleFactor;
- GLfloat linePos = m_scaleZ + zComp; // Start line
+ GLfloat linePos = m_scaleZ; // Start line
int lastSegment = m_axisCacheZ.subSegmentCount() * m_axisCacheZ.segmentCount();
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_yFlipped)
@@ -1156,11 +1122,12 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.scale(gridLineScaleX);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1171,19 +1138,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(), adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1192,7 +1153,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Side wall lines
GLfloat lineXTrans = m_scaleXWithBackground;
- linePos = m_scaleZ + zComp; // Start line
+ linePos = m_scaleZ; // Start line
if (!m_xFlipped)
lineXTrans = -lineXTrans;
@@ -1200,7 +1161,6 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
modelMatrix.translate(lineXTrans, 0.0f, linePos);
@@ -1208,7 +1168,6 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.scale(gridLineScaleY);
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1219,20 +1178,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(),
- adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1250,23 +1202,23 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
if (m_yFlipped)
- modelMatrix.translate(linePos, backgroundMargin, zComp);
+ modelMatrix.translate(linePos, backgroundMargin, 0.0f);
else
- modelMatrix.translate(linePos, -backgroundMargin, zComp);
+ modelMatrix.translate(linePos, -backgroundMargin, 0.0f);
modelMatrix.scale(gridLineScaleZ);
itModelMatrix.scale(gridLineScaleZ);
// If we're viewing from below, grid line object must be flipped
- if (m_yFlipped)
+ if (m_yFlipped) {
modelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ itModelMatrix.rotate(180.0f, 1.0, 0.0, 0.0);
+ }
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1277,19 +1229,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(), adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1297,16 +1243,15 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
}
// Back wall lines
- GLfloat lineZTrans = m_scaleZWithBackground + zComp;
+ GLfloat lineZTrans = m_scaleZWithBackground;
linePos = m_scaleX;
if (!m_zFlipped)
- lineZTrans = -lineZTrans + zComp + zComp;
+ lineZTrans = -lineZTrans;
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
modelMatrix.translate(linePos, 0.0f, lineZTrans);
@@ -1314,7 +1259,6 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.scale(gridLineScaleY);
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1325,19 +1269,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(), adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1352,15 +1290,14 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
GLfloat linePos = -1.0f;
int lastSegment = m_axisCacheY.subSegmentCount() * m_axisCacheY.segmentCount();
- GLfloat lineZTrans = m_scaleZWithBackground + zComp;
+ GLfloat lineZTrans = m_scaleZWithBackground;
if (!m_zFlipped)
- lineZTrans = -lineZTrans + zComp + zComp;
+ lineZTrans = -lineZTrans;
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
modelMatrix.translate(0.0f, linePos, lineZTrans);
@@ -1369,7 +1306,6 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.scale(gridLineScaleX);
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1380,19 +1316,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(), adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1410,16 +1340,14 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
for (int segment = 0; segment <= lastSegment; segment++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
- QMatrix4x4 depthMVPMatrix;
QMatrix4x4 itModelMatrix;
- modelMatrix.translate(lineXTrans, linePos, zComp);
+ modelMatrix.translate(lineXTrans, linePos, 0.0f);
modelMatrix.scale(gridLineScaleZ);
itModelMatrix.scale(gridLineScaleZ);
MVPMatrix = projectionViewMatrix * modelMatrix;
- depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
// Set the rest of the shader bindings
lineShader->setUniformValue(lineShader->model(), modelMatrix);
@@ -1430,19 +1358,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadow shader bindings
- lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- lineShader->setUniformValue(lineShader->lightS(), adjustedLightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
} else
#endif
{
- // Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength);
-
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
}
@@ -1461,10 +1383,10 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Z Labels
- QVector3D positionZComp(0.0f, 0.0f, zComp);
+ QVector3D positionZComp(0.0f, 0.0f, 0.0f);
if (m_axisCacheZ.segmentCount() > 0) {
GLfloat posStep = 2.0f * aspectRatio * m_axisCacheZ.segmentStep() / m_scaleFactor;
- GLfloat labelPos = m_scaleZ + zComp;
+ GLfloat labelPos = m_scaleZ;
int lastSegment = m_axisCacheZ.segmentCount();
int labelNbr = 0;
GLfloat labelXTrans = m_scaleXWithBackground + labelMargin;
@@ -1532,7 +1454,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
}
QVector3D labelTrans = QVector3D(labelPos,
labelYTrans,
- labelZTrans + zComp);
+ labelZTrans);
QVector3D rotation(rotLabelX, rotLabelY, rotLabelZ);
for (int segment = 0; segment <= lastSegment; segment++) {
@@ -1559,12 +1481,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
GLfloat labelXTrans = m_scaleXWithBackground;
GLfloat labelZTrans = m_scaleZWithBackground;
+ // Back wall init
GLfloat labelMarginXTrans = labelMargin;
GLfloat labelMarginZTrans = labelMargin;
GLfloat rotLabelX = 0.0f;
GLfloat rotLabelY = -90.0f;
GLfloat rotLabelZ = 0.0f;
- Qt::AlignmentFlag alignment = Qt::AlignLeft;
+ Qt::AlignmentFlag alignmentBack = Qt::AlignLeft;
if (!m_xFlipped) {
labelXTrans = -labelXTrans;
labelMarginXTrans = -labelMargin;
@@ -1573,54 +1496,44 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_zFlipped) {
labelZTrans = -labelZTrans;
labelMarginZTrans = -labelMargin;
- alignment = Qt::AlignRight;
+ alignmentBack = Qt::AlignRight;
}
+ QVector3D labelRotateVectorBack(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTransBack = QVector3D(labelXTrans, 0.0f, labelZTrans + labelMarginZTrans);
- // Back wall
- QVector3D rotation(rotLabelX, rotLabelY, rotLabelZ);
+ // Side wall init
+ Qt::AlignmentFlag alignmentSide = Qt::AlignLeft;
+ if (m_xFlipped)
+ alignmentSide = Qt::AlignLeft;
+ else
+ alignmentSide = Qt::AlignRight;
+ if (m_zFlipped)
+ rotLabelY = 180.0f;
+ else
+ rotLabelY = 0.0f;
+
+ QVector3D labelRotateVectorSide(rotLabelX, rotLabelY, rotLabelZ);
+ QVector3D labelTransSide(-labelXTrans - labelMarginXTrans, 0.0f, -labelZTrans);
for (int segment = 0; segment <= m_axisCacheY.segmentCount(); segment++) {
if (m_axisCacheY.labelItems().size() > labelNbr) {
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(labelNbr);
- // Side wall
- QVector3D labelTrans = QVector3D(labelXTrans, labelPos,
- labelZTrans + labelMarginZTrans + zComp);
- if (m_xFlipped)
- rotation.setY(-90.0f);
- else
- rotation.setY(90.0f);
- if (m_zFlipped)
- alignment = Qt::AlignRight;
- else
- alignment = Qt::AlignLeft;
-
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
+ // Back wall
+ labelTransBack.setY(labelPos);
+ m_dummyRenderItem.setTranslation(labelTransBack);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, rotation, 0, m_cachedSelectionMode,
+ positionZComp, labelRotateVectorBack, 0, m_cachedSelectionMode,
m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
- true, true, Drawer::LabelMid, alignment);
-
- // Back wall
- if (m_xFlipped)
- alignment = Qt::AlignLeft;
- else
- alignment = Qt::AlignRight;
- if (m_zFlipped)
- rotation.setY(180.0f);
- else
- rotation.setY(0.0f);
-
- labelTrans = QVector3D(-labelXTrans - labelMarginXTrans, labelPos,
- -labelZTrans + zComp);
+ true, true, Drawer::LabelMid, alignmentBack);
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
+ // Side wall
+ labelTransSide.setY(labelPos);
+ m_dummyRenderItem.setTranslation(labelTransSide);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, rotation, 0, m_cachedSelectionMode,
+ positionZComp, labelRotateVectorSide, 0, m_cachedSelectionMode,
m_labelShader, m_labelObj, m_cachedScene->activeCamera(),
- true, true, Drawer::LabelMid, alignment);
+ true, true, Drawer::LabelMid, alignmentSide);
}
labelNbr++;
labelPos += posStep;
@@ -1673,11 +1586,11 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
void Surface3DRenderer::updateSurfaceGradient(const QLinearGradient &gradient)
{
- QImage image(QSize(1, 1000), QImage::Format_RGB32);
+ QImage image(QSize(2, 1024), QImage::Format_RGB32);
QPainter pmp(&image);
pmp.setBrush(QBrush(gradient));
pmp.setPen(Qt::NoPen);
- pmp.drawRect(0, 0, 1, 1000);
+ pmp.drawRect(0, 0, 2, 1024);
if (m_gradientTexture) {
m_textureHelper->deleteTexture(&m_gradientTexture);
@@ -1803,7 +1716,7 @@ bool Surface3DRenderer::updateSmoothStatus(bool enable)
{
if (!enable && !m_flatSupported) {
qWarning() << "Warning: Flat qualifier not supported on your platform's GLSL language."
- " Requires at least GLSL version 1.5.";
+ " Requires at least GLSL version 1.2 with GL_EXT_gpu_shader4 extension.";
enable = true;
}
@@ -2135,6 +2048,9 @@ void Surface3DRenderer::updateDepthBuffer()
m_depthTexture = 0;
}
+ if (m_mainViewPort.size().isEmpty())
+ return;
+
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
m_depthTexture = m_textureHelper->createDepthTexture(m_mainViewPort.size(),
m_depthFrameBuffer,
diff --git a/src/datavisualization/engine/theme.cpp b/src/datavisualization/engine/theme.cpp
index d9f2974a..387540b1 100644
--- a/src/datavisualization/engine/theme.cpp
+++ b/src/datavisualization/engine/theme.cpp
@@ -37,7 +37,7 @@ Theme::Theme()
m_highlightBarColor(QColor(Qt::red)),
m_highlightRowColor(QColor(Qt::darkRed)),
m_highlightColumnColor(QColor(Qt::darkMagenta)),
- m_surfaceGradient(QLinearGradient(1, 1000, 0, 0)),
+ m_surfaceGradient(QLinearGradient(2, 1024, 0, 0)),
m_lightStrength(4.0f),
m_ambientStrength(0.3f),
m_highlightLightStrength(8.0f),
diff --git a/src/datavisualization/global/datavisualizationglobal_p.h b/src/datavisualization/global/datavisualizationglobal_p.h
index 4da1023c..b37dbf91 100644
--- a/src/datavisualization/global/datavisualizationglobal_p.h
+++ b/src/datavisualization/global/datavisualizationglobal_p.h
@@ -38,16 +38,17 @@
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
// Constants used in several files
-// Compensation for z position; move all objects to positive z, as shader can't handle negative values correctly
-const GLfloat zComp = 10.0f;
// Distance from camera to origin
const GLfloat cameraDistance = 6.0f;
// Size of font to be used in label texture rendering. Doesn't affect the actual font size.
const int textureFontSize = 50;
+const GLfloat defaultRatio = 1.0f / 1.6f; // default aspect ratio 16:10
// Default light position. To have shadows working correctly, light should be as far as camera, or a bit further
// y position is added to the minimum height (or can be thought to be that much above or below the camera)
-const QVector3D defaultLightPos = QVector3D(0.0f, 0.5f, zComp);
-const GLfloat defaultRatio = 1.0f / 1.6f; // default aspect ratio 16:10
+const QVector3D defaultLightPos(0.0f, 0.5f, 0.0f);
+const QVector3D zeroVector(0.0f, 0.0f, 0.0f);
+const QVector3D upVector(0.0f, 1.0f, 0.0f);
+const QVector3D cameraDistanceVector(0.0f, 0.0f, cameraDistance);
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/global/qtdatavisualizationenums.qdoc b/src/datavisualization/global/qtdatavisualizationenums.qdoc
index 57e7d13d..d448953d 100644
--- a/src/datavisualization/global/qtdatavisualizationenums.qdoc
+++ b/src/datavisualization/global/qtdatavisualizationenums.qdoc
@@ -28,6 +28,15 @@
*/
/*!
+ * \class QtDataVisualization::QDataVis
+ * \inmodule QtDataVisualization
+ * \brief Container class for Qt Data Visualization enums.
+ * \since Qt Data Visualization 1.0
+ *
+ * QDataVis acts as a container for Qt Data Visualization enums. It has no other functionality.
+ */
+
+/*!
\enum QtDataVisualization::QDataVis::InputState
Predefined input states for mouse and touch based input handlers. All states are not valid with all input handlers.
diff --git a/src/datavisualization/input/q3dinputhandler.cpp b/src/datavisualization/input/q3dinputhandler.cpp
index 5267568c..357c97d3 100644
--- a/src/datavisualization/input/q3dinputhandler.cpp
+++ b/src/datavisualization/input/q3dinputhandler.cpp
@@ -38,23 +38,26 @@ const float rotationSpeed = 100.0f;
* \class Q3DInputHandler
* \inmodule QtDataVisualization
* \brief Basic wheel mouse based input handler.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* Q3DInputHandler is the basic input handler for wheel mouse type of input devices.
*
* Default input handler has the following functionalty:
* \table
* \header
- * \li Mouse action \li Action
+ * \li Mouse action \li Action
* \row
- * \li Right button pressed \li Rotate graph within limits set for Q3DCamera
+ * \li Drag with right button pressed \li Rotate graph within limits set for Q3DCamera.
* \row
- * \li Left click \li Select item under cursor or remove selection if none
+ * \li Left click \li Select item under cursor or remove selection if none.
+ * May open the secondary view depending on the
+ * selection mode.
* \row
- * \li Mouse wheel \li Zoom in/out within default range (10...500%)
+ * \li Mouse wheel \li Zoom in/out within default range (10...500%).
* \row
- * \li Left click on secodanry view \li Return to primary view when in slice mode
- * \note Slice mode is available in Q3DBars and Q3DSurface only
+ * \li Left click on the primary view when the secondary view is visible
+ * \li Closes the secondary view.
+ * \note Secondary view is available only for Q3DBars and Q3DSurface graphs.
* \endtable
*/
diff --git a/src/datavisualization/input/qabstract3dinputhandler.cpp b/src/datavisualization/input/qabstract3dinputhandler.cpp
index e111ff42..b84711a4 100644
--- a/src/datavisualization/input/qabstract3dinputhandler.cpp
+++ b/src/datavisualization/input/qabstract3dinputhandler.cpp
@@ -22,16 +22,16 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
/*!
\class QAbstract3DInputHandler
\inmodule QtDataVisualization
- \brief Baseclass for implementations of input handlers.
- \since 1.0.0
+ \brief The base class for implementations of input handlers.
+ \since Qt Data Visualization 1.0
- QAbstract3DInputHandler is a baseclass that is subclassed by different input handling implementations
+ QAbstract3DInputHandler is the base class that is subclassed by different input handling implementations
that take input events and translate those to camera and light movements. Input handlers also translate
raw input events to slicing and selection events in the scene.
*/
/*!
- * Constructs the baseclass. An optional \a parent parameter can be given
+ * Constructs the base class. An optional \a parent parameter can be given
* and is then passed to QObject constructor.
*/
QAbstract3DInputHandler::QAbstract3DInputHandler(QObject *parent) :
@@ -41,7 +41,7 @@ QAbstract3DInputHandler::QAbstract3DInputHandler(QObject *parent) :
}
/*!
- * Destroys the baseclass.
+ * Destroys the base class.
*/
QAbstract3DInputHandler::~QAbstract3DInputHandler()
{
@@ -162,7 +162,9 @@ void QAbstract3DInputHandler::setPrevDistance(int distance)
/*!
* \property QAbstract3DInputHandler::scene
*
- * The 3D scene this abstract inputhandler is controlling. Only one scene can be controlled by one input handler.
+ * The 3D scene this abstract input handler is controlling. Only one scene can
+ * be controlled by one input handler. Setting a \a scene to an input handler doesn't
+ * transfer the ownership of the \a scene.
*/
Q3DScene *QAbstract3DInputHandler::scene() const
{
diff --git a/src/datavisualization/input/qtouch3dinputhandler.cpp b/src/datavisualization/input/qtouch3dinputhandler.cpp
index fd079e88..1d8bd929 100644
--- a/src/datavisualization/input/qtouch3dinputhandler.cpp
+++ b/src/datavisualization/input/qtouch3dinputhandler.cpp
@@ -39,7 +39,7 @@ const int maxZoomLevel = 500;
* \class QTouch3DInputHandler
* \inmodule QtDataVisualization
* \brief Basic touch display based input handler.
- * \since 1.0.0
+ * \since Qt Data Visualization 1.0
*
* QTouch3DInputHandler is the basic input handler for touch screen devices.
*
@@ -50,14 +50,17 @@ const int maxZoomLevel = 500;
* \row
* \li Touch-And-Move \li Rotate graph within limits set for Q3DCamera
* \row
- * \li Tap \li Select item under pointer or remove selection if none
+ * \li Tap \li Select the item tapped or remove selection if none.
+ * May open the secondary view depending on the
+ * selection mode.
* \row
- * \li Tap-And-Hold \li Select item under pointer or remove selection if none
+ * \li Tap-And-Hold \li Same as tap.
* \row
- * \li Pinch \li Zoom in/out within default range (10...500%)
+ * \li Pinch \li Zoom in/out within default range (10...500%).
* \row
- * \li Tap on secondary view \li Return to primary view when in slice mode
- * \note Slice mode is available in Q3DBars and Q3DSurface only
+ * \li Tap on the primary view when the secondary view is visible
+ * \li Closes the secondary view.
+ * \note Secondary view is available only for Q3DBars and Q3DSurface graphs.
* \endtable
*/
diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp
index f78fcec3..d9a32ec6 100644
--- a/src/datavisualization/utils/surfaceobject.cpp
+++ b/src/datavisualization/utils/surfaceobject.cpp
@@ -58,7 +58,7 @@ void SurfaceObject::setUpSmoothData(const QSurfaceDataArray &dataArray, const QR
m_surfaceType = SurfaceSmooth;
- // Create/populate vertice table
+ // Create/populate vertix table
if (changeGeometry)
m_vertices.resize(totalSize);
@@ -174,7 +174,7 @@ void SurfaceObject::setUpData(const QSurfaceDataArray &dataArray, const QRect &s
m_surfaceType = SurfaceFlat;
- // Create vertice table
+ // Create vertix table
if (changeGeometry)
m_vertices.resize(totalSize);
diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp
index 25fe17ac..9e2b9811 100644
--- a/src/datavisualization/utils/texturehelper.cpp
+++ b/src/datavisualization/utils/texturehelper.cpp
@@ -99,53 +99,6 @@ GLuint TextureHelper::createCubeMapTexture(const QImage &image, bool useTrilinea
return textureId;
}
-GLuint TextureHelper::createSelectionBuffer(const QSize &size, GLuint &texture,
- GLuint &depthTexture)
-{
- GLuint framebuffer;
-
- // Create frame buffer
- glGenFramebuffers(1, &framebuffer);
- glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
-
- // Create texture for the selection buffer
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-//#if !defined(QT_OPENGL_ES_2)
-// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, GL_RGB,
-// GL_UNSIGNED_BYTE, NULL);
-//#else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size.width(), size.height(), 0, GL_RGB,
- GL_UNSIGNED_BYTE, NULL);
-//#endif
-
- // Create texture object for the depth buffer
- glGenTextures(1, &depthTexture);
- glBindTexture(GL_TEXTURE_2D, depthTexture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width(), size.height(),
- 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- // Attach texture to color attachment
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
- // Attach texture to depth attachment
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);
-
- // Verify that the frame buffer is complete
- GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- qCritical() << "Frame buffer creation failed" << status;
- return 0;
- }
-
- // Restore the default framebuffer
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- return framebuffer;
-}
-
GLuint TextureHelper::createSelectionTexture(const QSize &size, GLuint &frameBuffer,
GLuint &depthBuffer)
{
@@ -213,7 +166,7 @@ GLuint TextureHelper::createDepthTexture(const QSize &size, GLuint &frameBuffer,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, size.width() * textureSize,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width() * textureSize,
size.height() * textureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
diff --git a/src/datavisualization/utils/texturehelper_p.h b/src/datavisualization/utils/texturehelper_p.h
index f7779b59..8371825e 100644
--- a/src/datavisualization/utils/texturehelper_p.h
+++ b/src/datavisualization/utils/texturehelper_p.h
@@ -45,8 +45,6 @@ class TextureHelper : protected QOpenGLFunctions
GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false,
bool convert = true, bool smoothScale = true);
GLuint createCubeMapTexture(const QImage &image, bool useTrilinearFiltering = false);
- // Returns selection framebuffer and inserts generated texture id to texture parameters
- GLuint createSelectionBuffer(const QSize &size, GLuint &texture, GLuint &depthTexture);
// Returns selection texture and inserts generated framebuffers to framebuffer parameters
GLuint createSelectionTexture(const QSize &size, GLuint &frameBuffer, GLuint &depthBuffer);
#if !defined(QT_OPENGL_ES_2)
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp
index 947dbfba..eb74d1a3 100644
--- a/src/datavisualization/utils/utils.cpp
+++ b/src/datavisualization/utils/utils.cpp
@@ -29,7 +29,7 @@
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
#define NUM_IN_POWER(y, x) for (;y<x;y<<=1)
-#define MIN_POWER 32
+#define MIN_POWER 2
GLuint Utils::getNearestPowerOfTwo(GLuint value, GLuint &padding)
{
diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp
index 63b9faaf..dafe5dbc 100644
--- a/src/datavisualization/utils/vertexindexer.cpp
+++ b/src/datavisualization/utils/vertexindexer.cpp
@@ -33,7 +33,7 @@ bool VertexIndexer::is_near(float v1, float v2)
return qAbs(v1 - v2) < 0.01f;
}
-// Searches through all already-exported vertices
+// Searches through all already exported vertices
// for a similar one.
// Similar = same position + same UVs + same normal
bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex,
diff --git a/src/datavisualizationqml2/declarativesurface.cpp b/src/datavisualizationqml2/declarativesurface.cpp
index af3e059b..9ace6c55 100644
--- a/src/datavisualizationqml2/declarativesurface.cpp
+++ b/src/datavisualizationqml2/declarativesurface.cpp
@@ -75,7 +75,7 @@ QSGNode *DeclarativeSurface::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
if (oldNode)
delete oldNode;
- // Create a new one and set it's bounding rectangle
+ // Create a new one and set its bounding rectangle
DeclarativeSurfaceRenderer *node = new DeclarativeSurfaceRenderer(window(), m_shared);
node->setRect(boundingRect());
m_shared->setBoundingRect(boundingRect().toRect());
diff --git a/tests/kinectsurface/QtKinectWrapper/QKinectWrapper.cpp b/tests/kinectsurface/QtKinectWrapper/QKinectWrapper.cpp
index 3ebe930d..5de4a8a6 100644
--- a/tests/kinectsurface/QtKinectWrapper/QKinectWrapper.cpp
+++ b/tests/kinectsurface/QtKinectWrapper/QKinectWrapper.cpp
@@ -86,7 +86,7 @@ QImage QKinectWrapper::getDepth()
/**
\brief Returns if running
- Runing comprises initializing and reading data (i.e. not running is idle or error)
+ Runing comprises initializing and reading data (not running is idle or error)
We query the thread state to get this.
**/
bool QKinectWrapper::isRunning()
@@ -99,7 +99,7 @@ bool QKinectWrapper::isRunning()
/**
\brief Returns if stopped
- Runing comprises initializing and reading data (i.e. not running is idle or error)
+ Runing comprises initializing and reading data (not running is idle or error)
We query the thread state to get this.
**/
bool QKinectWrapper::isStopped()