summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-10-29 09:45:41 +0200
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-10-29 09:45:41 +0200
commite3a4f132ca2a42af3d4bb889d6a17948b88d26a2 (patch)
tree554d2b8b3020dc71438301aa696dea1e9a36943a
parentcc50608385cf77a0803431ece1385f341a400b75 (diff)
parentbf716cfdf0afecccdb1f2eabb2e6a172c620fbff (diff)
Merge branch 'develop'
Conflicts: .qmake.conf README src/datavisualization/global/qdatavisualizationglobal.h Change-Id: Ia6941dcf3e6aa17e2e9ebc6f60fac16ef5049f11
-rw-r--r--.qmake.conf2
-rw-r--r--README25
-rw-r--r--dist/changes-1.1.02
-rw-r--r--dist/changes-1.2.079
-rw-r--r--examples/datavisualization/audiolevels/audiolevels.cpp2
-rw-r--r--examples/datavisualization/bars/doc/images/bars-example.pngbin188289 -> 238712 bytes
-rw-r--r--examples/datavisualization/bars/doc/src/bars.qdoc24
-rw-r--r--examples/datavisualization/bars/graphmodifier.cpp115
-rw-r--r--examples/datavisualization/bars/graphmodifier.h11
-rw-r--r--examples/datavisualization/bars/main.cpp14
-rw-r--r--examples/datavisualization/customproxy/doc/images/customproxy-example.pngbin125698 -> 173744 bytes
-rw-r--r--examples/datavisualization/customproxy/rainfallgraph.cpp5
-rw-r--r--examples/datavisualization/datavisualization.pro30
-rw-r--r--examples/datavisualization/qmlspectrogram/doc/images/qmlspectrogram-example.pngbin0 -> 80103 bytes
-rw-r--r--examples/datavisualization/qmlspectrogram/doc/src/qmlspectrogram.qdoc89
-rw-r--r--examples/datavisualization/qmlspectrogram/main.cpp42
-rw-r--r--examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/Data.qml1560
-rw-r--r--examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/NewButton.qml52
-rw-r--r--examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml293
-rw-r--r--examples/datavisualization/qmlspectrogram/qmlspectrogram.pro12
-rw-r--r--examples/datavisualization/qmlspectrogram/qmlspectrogram.qrc7
-rw-r--r--examples/datavisualization/qmlsurfacelayers/layer_2.pngbin10553 -> 10563 bytes
-rw-r--r--examples/datavisualization/texturesurface/custominputhandler.cpp182
-rw-r--r--examples/datavisualization/texturesurface/custominputhandler.h91
-rw-r--r--examples/datavisualization/texturesurface/doc/images/texturesurface-example.pngbin0 -> 157373 bytes
-rw-r--r--examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc126
-rw-r--r--examples/datavisualization/texturesurface/highlightseries.cpp119
-rw-r--r--examples/datavisualization/texturesurface/highlightseries.h52
-rw-r--r--examples/datavisualization/texturesurface/license.txt77
-rw-r--r--examples/datavisualization/texturesurface/main.cpp101
-rw-r--r--examples/datavisualization/texturesurface/maptexture.jpgbin0 -> 352922 bytes
-rw-r--r--examples/datavisualization/texturesurface/surfacegraph.cpp90
-rw-r--r--examples/datavisualization/texturesurface/surfacegraph.h52
-rw-r--r--examples/datavisualization/texturesurface/texturedsurface.qrc6
-rw-r--r--examples/datavisualization/texturesurface/texturesurface.pro25
-rw-r--r--examples/datavisualization/texturesurface/topographicseries.cpp72
-rw-r--r--examples/datavisualization/texturesurface/topographicseries.h45
-rw-r--r--examples/datavisualization/texturesurface/topography.pngbin0 -> 395504 bytes
-rw-r--r--examples/datavisualization/volumetric/doc/images/volumetric-example.pngbin0 -> 177203 bytes
-rw-r--r--examples/datavisualization/volumetric/doc/src/volumetric.qdoc129
-rw-r--r--examples/datavisualization/volumetric/layer_ground.pngbin0 -> 63473 bytes
-rw-r--r--examples/datavisualization/volumetric/layer_magma.pngbin0 -> 17332 bytes
-rw-r--r--examples/datavisualization/volumetric/layer_water.pngbin0 -> 27124 bytes
-rw-r--r--examples/datavisualization/volumetric/main.cpp247
-rw-r--r--examples/datavisualization/volumetric/volumetric.cpp764
-rw-r--r--examples/datavisualization/volumetric/volumetric.h116
-rw-r--r--examples/datavisualization/volumetric/volumetric.pro17
-rw-r--r--examples/datavisualization/volumetric/volumetric.qrc7
-rw-r--r--qtdatavisualization.pro2
-rw-r--r--src/datavisualization/axis/axis.pri2
-rw-r--r--src/datavisualization/axis/qlogvalue3daxisformatter.cpp1
-rw-r--r--src/datavisualization/axis/qvalue3daxis.cpp24
-rw-r--r--src/datavisualization/axis/qvalue3daxisformatter.cpp40
-rw-r--r--src/datavisualization/axis/qvalue3daxisformatter.h4
-rw-r--r--src/datavisualization/axis/qvalue3daxisformatter_p.h8
-rw-r--r--src/datavisualization/common.pri7
-rw-r--r--src/datavisualization/data/abstractrenderitem_p.h6
-rw-r--r--src/datavisualization/data/customrenderitem.cpp68
-rw-r--r--src/datavisualization/data/customrenderitem_p.h109
-rw-r--r--src/datavisualization/data/data.pri9
-rw-r--r--src/datavisualization/data/labelitem.cpp6
-rw-r--r--src/datavisualization/data/qabstract3dseries.cpp3
-rw-r--r--src/datavisualization/data/qabstract3dseries.h1
-rw-r--r--src/datavisualization/data/qbar3dseries.cpp21
-rw-r--r--src/datavisualization/data/qcustom3ditem.cpp101
-rw-r--r--src/datavisualization/data/qcustom3ditem.h5
-rw-r--r--src/datavisualization/data/qcustom3ditem_p.h5
-rw-r--r--src/datavisualization/data/qcustom3dlabel.cpp1
-rw-r--r--src/datavisualization/data/qcustom3dvolume.cpp1278
-rw-r--r--src/datavisualization/data/qcustom3dvolume.h147
-rw-r--r--src/datavisualization/data/qcustom3dvolume_p.h108
-rw-r--r--src/datavisualization/data/qheightmapsurfacedataproxy.cpp16
-rw-r--r--src/datavisualization/data/qsurface3dseries.cpp66
-rw-r--r--src/datavisualization/data/qsurface3dseries.h9
-rw-r--r--src/datavisualization/data/qsurface3dseries_p.h3
-rw-r--r--src/datavisualization/data/qsurfacedataproxy.cpp4
-rw-r--r--src/datavisualization/datavisualization.pro8
-rw-r--r--src/datavisualization/doc/qtdatavisualization.qdocconf12
-rw-r--r--src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp8
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc151
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc8
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc21
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization.qdoc23
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp270
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h85
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp1242
-rw-r--r--src/datavisualization/engine/abstract3drenderer_p.h119
-rw-r--r--src/datavisualization/engine/axisrendercache.cpp18
-rw-r--r--src/datavisualization/engine/axisrendercache_p.h2
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp30
-rw-r--r--src/datavisualization/engine/bars3dcontroller_p.h7
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp869
-rw-r--r--src/datavisualization/engine/bars3drenderer_p.h28
-rw-r--r--src/datavisualization/engine/drawer.cpp68
-rw-r--r--src/datavisualization/engine/drawer_p.h4
-rw-r--r--src/datavisualization/engine/engine.pri2
-rw-r--r--src/datavisualization/engine/engine.qrc13
-rw-r--r--src/datavisualization/engine/q3dbars.cpp20
-rw-r--r--src/datavisualization/engine/q3dbars.h4
-rw-r--r--src/datavisualization/engine/q3dcamera.cpp233
-rw-r--r--src/datavisualization/engine/q3dcamera.h13
-rw-r--r--src/datavisualization/engine/q3dcamera_p.h19
-rw-r--r--src/datavisualization/engine/q3dlight.cpp9
-rw-r--r--src/datavisualization/engine/q3dobject.cpp9
-rw-r--r--src/datavisualization/engine/q3dscene.cpp123
-rw-r--r--src/datavisualization/engine/q3dscene.h5
-rw-r--r--src/datavisualization/engine/q3dscene_p.h7
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp27
-rw-r--r--src/datavisualization/engine/q3dsurface.h4
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.cpp300
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.h41
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp1661
-rw-r--r--src/datavisualization/engine/scatter3drenderer_p.h32
-rw-r--r--src/datavisualization/engine/scatterseriesrendercache.cpp4
-rw-r--r--src/datavisualization/engine/scatterseriesrendercache_p.h10
-rw-r--r--src/datavisualization/engine/selectionpointer.cpp33
-rw-r--r--src/datavisualization/engine/selectionpointer_p.h2
-rw-r--r--src/datavisualization/engine/seriesrendercache.cpp8
-rw-r--r--src/datavisualization/engine/seriesrendercache_p.h3
-rw-r--r--src/datavisualization/engine/shaders/3dsliceframes.frag15
-rw-r--r--src/datavisualization/engine/shaders/default.frag3
-rw-r--r--src/datavisualization/engine/shaders/defaultNoMatrices.vert26
-rw-r--r--src/datavisualization/engine/shaders/default_ES2.frag2
-rw-r--r--src/datavisualization/engine/shaders/point_ES2_UV.vert12
-rw-r--r--src/datavisualization/engine/shaders/position.vert10
-rw-r--r--src/datavisualization/engine/shaders/positionmap.frag11
-rw-r--r--src/datavisualization/engine/shaders/shadowNoMatrices.vert36
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTex.frag2
-rw-r--r--src/datavisualization/engine/shaders/surface.frag4
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.frag4
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.vert3
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowFlat.frag10
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowFlat.vert16
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowNoTex.frag8
-rw-r--r--src/datavisualization/engine/shaders/surfaceTexturedFlat.frag39
-rw-r--r--src/datavisualization/engine/shaders/surfaceTexturedShadow.frag67
-rw-r--r--src/datavisualization/engine/shaders/surfaceTexturedShadowFlat.frag72
-rw-r--r--src/datavisualization/engine/shaders/surface_ES2.frag4
-rw-r--r--src/datavisualization/engine/shaders/texture3d.frag155
-rw-r--r--src/datavisualization/engine/shaders/texture3d.vert36
-rw-r--r--src/datavisualization/engine/shaders/texture3dlowdef.frag109
-rw-r--r--src/datavisualization/engine/shaders/texture3dslice.frag155
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp42
-rw-r--r--src/datavisualization/engine/surface3dcontroller_p.h20
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp1326
-rw-r--r--src/datavisualization/engine/surface3drenderer_p.h32
-rw-r--r--src/datavisualization/engine/surfaceseriesrendercache.cpp7
-rw-r--r--src/datavisualization/engine/surfaceseriesrendercache_p.h3
-rw-r--r--src/datavisualization/global/datavisualizationglobal_p.h2
-rw-r--r--src/datavisualization/global/global.pri2
-rw-r--r--src/datavisualization/global/qdatavisualizationglobal.h4
-rw-r--r--src/datavisualization/input/input.pri2
-rw-r--r--src/datavisualization/input/q3dinputhandler.cpp306
-rw-r--r--src/datavisualization/input/q3dinputhandler.h19
-rw-r--r--src/datavisualization/input/q3dinputhandler_p.h25
-rw-r--r--src/datavisualization/input/qtouch3dinputhandler.cpp158
-rw-r--r--src/datavisualization/input/qtouch3dinputhandler_p.h9
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp6
-rw-r--r--src/datavisualization/theme/theme.pri2
-rw-r--r--src/datavisualization/utils/abstractobjecthelper.cpp1
-rw-r--r--src/datavisualization/utils/abstractobjecthelper_p.h4
-rw-r--r--src/datavisualization/utils/objecthelper.cpp5
-rw-r--r--src/datavisualization/utils/objecthelper_p.h2
-rw-r--r--src/datavisualization/utils/qutils.h12
-rw-r--r--src/datavisualization/utils/scatterobjectbufferhelper.cpp237
-rw-r--r--src/datavisualization/utils/scatterobjectbufferhelper_p.h13
-rw-r--r--src/datavisualization/utils/scatterpointbufferhelper.cpp109
-rw-r--r--src/datavisualization/utils/scatterpointbufferhelper_p.h13
-rw-r--r--src/datavisualization/utils/shaderhelper.cpp177
-rw-r--r--src/datavisualization/utils/shaderhelper_p.h112
-rw-r--r--src/datavisualization/utils/surfaceobject.cpp745
-rw-r--r--src/datavisualization/utils/surfaceobject_p.h52
-rw-r--r--src/datavisualization/utils/texturehelper.cpp244
-rw-r--r--src/datavisualization/utils/texturehelper_p.h14
-rw-r--r--src/datavisualization/utils/utils.cpp252
-rw-r--r--src/datavisualization/utils/utils.pri2
-rw-r--r--src/datavisualization/utils/utils_p.h15
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp202
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h40
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2.pro1
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2_plugin.cpp18
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2_plugin.h7
-rw-r--r--src/datavisualizationqml2/declarativebars.cpp13
-rw-r--r--src/datavisualizationqml2/declarativebars_p.h5
-rw-r--r--src/datavisualizationqml2/declarativesurface.cpp12
-rw-r--r--src/datavisualizationqml2/declarativesurface_p.h4
-rw-r--r--src/datavisualizationqml2/designer/Bars3DSpecifics.qml86
-rw-r--r--src/datavisualizationqml2/designer/Scatter3DSpecifics.qml72
-rw-r--r--src/datavisualizationqml2/designer/Surface3DSpecifics.qml70
-rw-r--r--src/datavisualizationqml2/designer/default/Bars3D.qml2
-rw-r--r--src/datavisualizationqml2/designer/default/Scatter3D.qml2
-rw-r--r--src/datavisualizationqml2/designer/default/Surface3D.qml2
-rw-r--r--src/datavisualizationqml2/plugins.qmltypes334
-rw-r--r--src/src.pro5
-rw-r--r--tests/auto/auto.pro7
-rw-r--r--tests/auto/cpptest/cpptest.pro26
-rw-r--r--tests/auto/cpptest/q3daxis-category/q3daxis-category.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-category/tst_axis.cpp133
-rw-r--r--tests/auto/cpptest/q3daxis-logvalue/q3daxis-logvalue.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-logvalue/tst_axis.cpp102
-rw-r--r--tests/auto/cpptest/q3daxis-value/q3daxis-value.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-value/tst_axis.cpp158
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp267
-rw-r--r--tests/auto/cpptest/q3dbars-proxy/q3dbars-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-proxy/tst_proxy.cpp97
-rw-r--r--tests/auto/cpptest/q3dbars-series/q3dbars-series.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-series/tst_series.cpp169
-rw-r--r--tests/auto/cpptest/q3dbars/q3dbars.pro8
-rw-r--r--tests/auto/cpptest/q3dbars/tst_bars.cpp401
-rw-r--r--tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom-label/tst_custom.cpp158
-rw-r--r--tests/auto/cpptest/q3dcustom-volume/q3dcustom-volume.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom-volume/tst_custom.cpp204
-rw-r--r--tests/auto/cpptest/q3dcustom/q3dcustom.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom/tst_custom.cpp128
-rw-r--r--tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro8
-rw-r--r--tests/auto/cpptest/q3dinput-touch/tst_input.cpp106
-rw-r--r--tests/auto/cpptest/q3dinput/q3dinput.pro8
-rw-r--r--tests/auto/cpptest/q3dinput/tst_input.cpp109
-rw-r--r--tests/auto/cpptest/q3dscatter-modelproxy/q3dscatter-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-modelproxy/tst_proxy.cpp193
-rw-r--r--tests/auto/cpptest/q3dscatter-proxy/q3dscatter-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-proxy/tst_proxy.cpp91
-rw-r--r--tests/auto/cpptest/q3dscatter-series/q3dscatter-series.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-series/tst_series.cpp110
-rw-r--r--tests/auto/cpptest/q3dscatter/q3dscatter.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter/tst_scatter.cpp237
-rw-r--r--tests/auto/cpptest/q3dscene-camera/q3dscene-camera.pro8
-rw-r--r--tests/auto/cpptest/q3dscene-camera/tst_camera.cpp179
-rw-r--r--tests/auto/cpptest/q3dscene-light/q3dscene-light.pro8
-rw-r--r--tests/auto/cpptest/q3dscene-light/tst_light.cpp92
-rw-r--r--tests/auto/cpptest/q3dscene/q3dscene.pro8
-rw-r--r--tests/auto/cpptest/q3dscene/tst_scene.cpp170
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpgbin0 -> 516 bytes
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.pro11
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.qrc5
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/tst_proxy.cpp156
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp283
-rw-r--r--tests/auto/cpptest/q3dsurface-proxy/q3dsurface-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-proxy/tst_proxy.cpp98
-rw-r--r--tests/auto/cpptest/q3dsurface-series/q3dsurface-series.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-series/tst_series.cpp120
-rw-r--r--tests/auto/cpptest/q3dsurface/q3dsurface.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface/tst_surface.cpp247
-rw-r--r--tests/auto/cpptest/q3dtheme/q3dtheme.pro8
-rw-r--r--tests/auto/cpptest/q3dtheme/tst_theme.cpp216
-rw-r--r--tests/auto/qmltest/axis3d/tst_category.qml135
-rw-r--r--tests/auto/qmltest/axis3d/tst_logvalue.qml91
-rw-r--r--tests/auto/qmltest/axis3d/tst_value.qml154
-rw-r--r--tests/auto/qmltest/bars3d/tst_bars.qml147
-rw-r--r--tests/auto/qmltest/bars3d/tst_barseries.qml215
-rw-r--r--tests/auto/qmltest/bars3d/tst_basic.qml240
-rw-r--r--tests/auto/qmltest/bars3d/tst_proxy.qml253
-rw-r--r--tests/auto/qmltest/custom3d/tst_customitem.qml106
-rw-r--r--tests/auto/qmltest/custom3d/tst_customlabel.qml134
-rw-r--r--tests/auto/qmltest/custom3d/tst_customvolume.qml182
-rw-r--r--tests/auto/qmltest/customitem.obj54
-rw-r--r--tests/auto/qmltest/customtexture.jpgbin0 -> 516 bytes
-rw-r--r--tests/auto/qmltest/input3d/tst_input.qml83
-rw-r--r--tests/auto/qmltest/input3d/tst_touch.qml83
-rw-r--r--tests/auto/qmltest/qmltest.pro35
-rw-r--r--tests/auto/qmltest/qmltest.qrc6
-rw-r--r--tests/auto/qmltest/scatter3d/tst_basic.qml203
-rw-r--r--tests/auto/qmltest/scatter3d/tst_proxy.qml134
-rw-r--r--tests/auto/qmltest/scatter3d/tst_scatter.qml60
-rw-r--r--tests/auto/qmltest/scatter3d/tst_scatterseries.qml233
-rw-r--r--tests/auto/qmltest/scene3d/tst_camera.qml135
-rw-r--r--tests/auto/qmltest/scene3d/tst_light.qml65
-rw-r--r--tests/auto/qmltest/scene3d/tst_scene.qml125
-rw-r--r--tests/auto/qmltest/surface3d/tst_basic.qml211
-rw-r--r--tests/auto/qmltest/surface3d/tst_heightproxy.qml116
-rw-r--r--tests/auto/qmltest/surface3d/tst_proxy.qml263
-rw-r--r--tests/auto/qmltest/surface3d/tst_surface.qml60
-rw-r--r--tests/auto/qmltest/surface3d/tst_surfaceseries.qml229
-rw-r--r--tests/auto/qmltest/theme3d/tst_colorgradient.qml89
-rw-r--r--tests/auto/qmltest/theme3d/tst_theme.qml266
-rw-r--r--tests/auto/qmltest/theme3d/tst_themecolor.qml66
-rw-r--r--tests/auto/qmltest/tst_qmltest.cpp20
-rw-r--r--tests/barstest/barstest.pro2
-rw-r--r--tests/barstest/barstest.qrc6
-rw-r--r--tests/barstest/chart.cpp160
-rw-r--r--tests/barstest/chart.h17
-rw-r--r--tests/barstest/main.cpp168
-rw-r--r--tests/barstest/shuttle.obj6349
-rw-r--r--tests/barstest/shuttle.pngbin0 -> 1361 bytes
-rw-r--r--tests/directional/main.cpp7
-rw-r--r--tests/directional/scatterdatamodifier.cpp9
-rw-r--r--tests/directional/scatterdatamodifier.h1
-rw-r--r--tests/qmlcamera/qml/qmlcamera/main.qml45
-rw-r--r--tests/qmldynamicdata/qml/qmldynamicdata/main.qml28
-rw-r--r--tests/qmlmultiwindow/qml/qmlmultiwindow/main.qml122
-rw-r--r--tests/qmlperf/main.cpp47
-rw-r--r--tests/qmlperf/qml/qmlperf/main.qml189
-rw-r--r--tests/qmlperf/qml/qmlperf/script.js33
-rw-r--r--tests/qmlperf/qmlperf.pro12
-rw-r--r--tests/qmlperf/qmlperf.qrc6
-rw-r--r--tests/qmlvolume/datasource.cpp90
-rw-r--r--tests/qmlvolume/datasource.h38
-rw-r--r--tests/qmlvolume/main.cpp56
-rw-r--r--tests/qmlvolume/qml/qmlvolume/NewButton.qml52
-rw-r--r--tests/qmlvolume/qml/qmlvolume/main.qml164
-rw-r--r--tests/qmlvolume/qmlvolume.pro16
-rw-r--r--tests/qmlvolume/qmlvolume.qrc6
-rw-r--r--tests/scattertest/main.cpp96
-rw-r--r--tests/scattertest/scatterchart.cpp90
-rw-r--r--tests/scattertest/scatterchart.h11
-rw-r--r--tests/surfacetest/graphmodifier.cpp151
-rw-r--r--tests/surfacetest/graphmodifier.h16
-rw-r--r--tests/surfacetest/main.cpp151
-rw-r--r--tests/surfacetest/mapimage.pngbin0 -> 159540 bytes
-rw-r--r--tests/surfacetest/surfacetest.qrc1
-rw-r--r--tests/tests.pro43
-rw-r--r--tests/volumetrictest/cubeFilledFlat.obj54
-rw-r--r--tests/volumetrictest/logo.pngbin0 -> 2205 bytes
-rw-r--r--tests/volumetrictest/logo_no_padding.pngbin0 -> 2278 bytes
-rw-r--r--tests/volumetrictest/main.cpp168
-rw-r--r--tests/volumetrictest/volumetrictest.cpp716
-rw-r--r--tests/volumetrictest/volumetrictest.h80
-rw-r--r--tests/volumetrictest/volumetrictest.pro14
-rw-r--r--tests/volumetrictest/volumetrictest.qrc7
-rw-r--r--tools/blender/arrow.blendbin0 -> 497968 bytes
-rw-r--r--tools/blender/narrowArrow.blendbin0 -> 489112 bytes
324 files changed, 32714 insertions, 3104 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 6ab2606e..48e733ed 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,6 +1,6 @@
load(qt_build_config)
CONFIG += qt_example_installs
-MODULE_VERSION=1.1.1
+MODULE_VERSION=1.2.0
CMAKE_MODULE_TESTS=-
diff --git a/README b/README
index 78714891..667dcdaa 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
---------------------------
-Qt Data Visualization 1.1.1
+Qt Data Visualization 1.2.0
---------------------------
Qt Data Visualization module provides multiple graph types to visualize data in 3D space
@@ -8,7 +8,7 @@ both with C++ and Qt Quick 2.
System Requirements
===================
-- Qt 5.2 or newer
+- Qt 5.2.1 or newer
- OpenGL 2.1 or newer (recommended) or OpenGL ES2 (reduced feature set)
- Manipulating Qt Data Visualization graphs with QML Designer requires
Qt Creator 3.1 or newer
@@ -22,7 +22,7 @@ After running qmake, build the project with make:
(Linux) make
(Windows with MinGw) mingw32-make
(Windows with Visual Studio) nmake
- (OSX) make
+ (OS X) make
The above generates the default makefiles for your configuration, which is typically
the release build if you are using precompiled binary Qt distribution. To build both
@@ -42,7 +42,7 @@ For release builds:
qmake CONFIG+=debug_and_release
make release
-For both builds (Windows/Mac only):
+For both builds (Windows/OS X only):
qmake CONFIG+="debug_and_release build_all"
make
@@ -74,17 +74,18 @@ Please refer to the generated documentation for more information:
Known Issues
============
-- Android doesn't support both widgets and OpenGL simultaneously, so only
- the Qt Quick 2 API is usable in practice in Android.
+- Some platforms like Android and WinRT cannot handle multiple native windows properly,
+ so only the Qt Quick 2 versions of graphs are available in practice for those platforms.
- Shadows are not supported with OpenGL ES2 (including Angle builds in Windows).
- Anti-aliasing doesn't work with OpenGL ES2 (including Angle builds in Windows).
+- QCustom3DVolume items are not supported with OpenGL ES2 (including Angle builds in Windows).
- Surfaces with non-straight rows and columns do not always render properly.
- Q3DLight class (and Light3D QML item) are currently not usable for anything.
-- Changing any of Q3DScene properties affecting subviewports currently has no effect.
-- The color style Q3DTheme::ColorStyleObjectGradient doesn't work for surface graphs.
+- Changing most of Q3DScene properties affecting subviewports currently has no effect.
- Widget based examples layout incorrectly in iOS.
- Reparenting a graph to an item in another QQuickWindow is not supported.
-- There is a low-impact binary break between 1.0 and 1.1. The break is due to a QML type
- registration conflict with QAbstractItemModel between QtDataVisualization and
- QtCommercial.Charts. Introducing the binary break makes it possible to use both
- Charts and Data Visualization in the same QML application.
+- Android builds of QML applications importing QtDataVisualization also require
+ "QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has
+ a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add
+ to the deployment package.
+
diff --git a/dist/changes-1.1.0 b/dist/changes-1.1.0
index 7d27438b..d404cf09 100644
--- a/dist/changes-1.1.0
+++ b/dist/changes-1.1.0
@@ -73,4 +73,4 @@ Platform specific changes
- Fixed issue with graph not always updating before rotating the graph in iOS.
- Fixed shader linking error on some Android versions.
-- Fixed memory leaks in Mac and Android builds.
+- Fixed memory leaks in OS X and Android builds.
diff --git a/dist/changes-1.2.0 b/dist/changes-1.2.0
new file mode 100644
index 00000000..b23d83b1
--- /dev/null
+++ b/dist/changes-1.2.0
@@ -0,0 +1,79 @@
+Qt Data Visualization 1.2
+
+New features
+------------
+
+- Added support for volumetric custom objects (QCustom3DVolume) for rendering 3D voxel data.
+- Reflection support for bar graphs (floor only).
+- Polar horizontal axes supported for scatter and surface graphs.
+- Added flipHorizontalGrid property for surface to enable displaying grid in 2D orthographic
+ projections of the surface (e.g. 2D spectrogram graphs).
+- Added horizontalAspectRatio property for graphs to enable better control over graph dimensions.
+- Added an API for setting a custom texture for a surface series.
+- Added several properties to control the default input handler behavior.
+- Exposed default input handlers to QML API.
+- Camera can now be targeted at any point within axis ranges on the scatter and surface graphs.
+ On bar graphs, camera target is limited to any point on the graph floor.
+- Added possibility to scale custom items based on data ranges.
+- Added a property for specifying the locale for the graph, which affects how various labels
+ are formatted (e.g. which character is used for the decimal point).
+- Added a property for specifying the Y-value of the floor level on bar graphs.
+- Added a property to Q3DScene for querying the graph position at a screen position.
+- The default input handlers now zoom to cursor/pinch instead of zooming toward the center of the
+ graph. Added a property to restore the old zoom behavior.
+- Added properties to control the minimum and maximum allowable zoom level of the camera.
+- Added a method for getting the list of custom items added to the graph.
+- Added a property for specifying the graph background margin.
+
+Fixed issues
+------------
+
+General:
+- Label widths now update consistently when axis range changes.
+- Made selection texture creation more robust.
+- Grid lines and labels no longer change size if aspect ratio changes.
+- Q3DTheme::ColorStyleObjectGradient now works for surface graphs.
+- Removed the superfluous common.pri.
+- Fixed non-visible selected object drawing in static optimization mode.
+- Gradient color styles are now supported equally in both default and static optimization modes.
+- Specular highlight now works with rotated objects in static optimization mode.
+- Fixed a crash in static optimization mode when data is updated without resizing.
+- Fixed changing items in static optimization mode.
+- Fixed issues with static optimization mode when some items were outside axis ranges.
+- Slice mode grid lines should no longer vanish into the background when using high ambient light
+ value.
+- Reduced the size of the surface selection texture, allowing selection to work with larger
+ surfaces.
+- Fixed QAbstract3DGraph::renderToImage in OpenGL ES2 environments.
+- Fixed crash when attempting to enable slicing without row/column selection modes.
+- QCustom3DLabels now use the same shader as other labels, which means the specular highlight
+ no longer makes camera facing custom labels unreadable with some themes.
+- Made various selection queries thread safe.
+- Fixed selection query synchronization issue when using threaded renderer.
+- Font size is automatically reduced if the label gets too wide to fit the label texture.
+- Fixed the ordering of the subviews.
+- Fixed surface normals in cases where the surface values were not in the same order
+ (ascending or descending) along both axes.
+- Fixed a crash when removing and changing items on the same render frame.
+- Fixed an issue with grid line color on surface graphs.
+- Prevented selecting bars through the floor in bar graphs.
+- Fixed recurring GL_INVALID_VALUE OpenGL errors.
+- Improved the surface shadows.
+- Fixed the OpenGL context cleanup upon renderer destruction.
+- Fixed scatter item autosizing when adding a new series.
+- Fixed a crash related to selection render buffer reuse.
+- Fixed the flipped Z-coordinate for absolutely positioned custom items.
+- Fixed shadows when viewing the graph directly from above or below.
+
+New examples
+------------
+
+- Qmlspectrogram example added. It shows how to display 2D spectrogram using surface graph with
+ gradients and orthographic projection. Also demonstrates the use of polar axes.
+- Bars example now demonstrates zooming to selection, which leverages the new ability to
+ control the camera target.
+- Textured surface example added.
+- Volumetric example added. It shows how to use the new QCustom3DVolume object to visualize
+ volumetric data.
+- Reflection added to Bars and Customproxy examples.
+- Custom camera targeting added to Bars example.
diff --git a/examples/datavisualization/audiolevels/audiolevels.cpp b/examples/datavisualization/audiolevels/audiolevels.cpp
index 672e4984..c4a6b78c 100644
--- a/examples/datavisualization/audiolevels/audiolevels.cpp
+++ b/examples/datavisualization/audiolevels/audiolevels.cpp
@@ -74,7 +74,7 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent)
m_audioInput = new QAudioInput(inputDevice, formatAudio, this);
#ifdef Q_OS_MAC
- // Mac seems to wait for entire buffer to fill before calling writeData, so use smaller buffer
+ // OS X seems to wait for entire buffer to fill before calling writeData, so use smaller buffer
m_audioInput->setBufferSize(256);
#else
m_audioInput->setBufferSize(1024);
diff --git a/examples/datavisualization/bars/doc/images/bars-example.png b/examples/datavisualization/bars/doc/images/bars-example.png
index fb79668d..c06fe2c1 100644
--- a/examples/datavisualization/bars/doc/images/bars-example.png
+++ b/examples/datavisualization/bars/doc/images/bars-example.png
Binary files differ
diff --git a/examples/datavisualization/bars/doc/src/bars.qdoc b/examples/datavisualization/bars/doc/src/bars.qdoc
index 9717fe8a..1117376f 100644
--- a/examples/datavisualization/bars/doc/src/bars.qdoc
+++ b/examples/datavisualization/bars/doc/src/bars.qdoc
@@ -188,6 +188,30 @@
You can use the same method with \c SelectionSlice and \c SelectionItem flags, as long as
you have either \c SelectionRow or \c SelectionColumn set as well.
+ \section1 Zooming to selection
+
+ As an example of adjusting camera target we have implemented an animation of zooming to
+ selection via a button press. Animation initializations are done in the constructor:
+
+ \snippet bars/graphmodifier.cpp 12
+
+ The function \c{GraphModifier::zoomToSelectedBar()} contains the rest of the functionality:
+
+ \snippet bars/graphmodifier.cpp 11
+
+ The QPropertyAnimation \c m_animationCameraTarget targets Q3DCamera::target property,
+ which takes a value normalized to the range (-1, 1). We figure out where the selected bar
+ is relative to axes, and use that as the end value for \c{m_animationCameraTarget}:
+
+ \snippet bars/graphmodifier.cpp 13
+ \dots
+ \snippet bars/graphmodifier.cpp 14
+
+ Likewise, we want to angle the camera so that it always points approximately to the center of
+ the graph at the end of the animation:
+
+ \snippet bars/graphmodifier.cpp 15
+
\section1 Example contents
*/
diff --git a/examples/datavisualization/bars/graphmodifier.cpp b/examples/datavisualization/bars/graphmodifier.cpp
index 9c280bfb..587bc1d6 100644
--- a/examples/datavisualization/bars/graphmodifier.cpp
+++ b/examples/datavisualization/bars/graphmodifier.cpp
@@ -26,6 +26,7 @@
#include <QtDataVisualization/q3dtheme.h>
#include <QtCore/QTime>
#include <QtWidgets/QComboBox>
+#include <QtCore/qmath.h>
using namespace QtDataVisualization;
@@ -106,6 +107,39 @@ GraphModifier::GraphModifier(Q3DBars *bargraph)
//! [9]
resetTemperatureData();
//! [9]
+
+ // Set up property animations for zooming to the selected bar
+ //! [12]
+ Q3DCamera *camera = m_graph->scene()->activeCamera();
+ m_defaultAngleX = camera->xRotation();
+ m_defaultAngleY = camera->yRotation();
+ m_defaultZoom = camera->zoomLevel();
+ m_defaultTarget = camera->target();
+
+ m_animationCameraX.setTargetObject(camera);
+ m_animationCameraY.setTargetObject(camera);
+ m_animationCameraZoom.setTargetObject(camera);
+ m_animationCameraTarget.setTargetObject(camera);
+
+ m_animationCameraX.setPropertyName("xRotation");
+ m_animationCameraY.setPropertyName("yRotation");
+ m_animationCameraZoom.setPropertyName("zoomLevel");
+ m_animationCameraTarget.setPropertyName("target");
+
+ int duration = 1700;
+ m_animationCameraX.setDuration(duration);
+ m_animationCameraY.setDuration(duration);
+ m_animationCameraZoom.setDuration(duration);
+ m_animationCameraTarget.setDuration(duration);
+
+ // The zoom always first zooms out above the graph and then zooms in
+ qreal zoomOutFraction = 0.3;
+ m_animationCameraX.setKeyValueAt(zoomOutFraction, QVariant::fromValue(0.0f));
+ m_animationCameraY.setKeyValueAt(zoomOutFraction, QVariant::fromValue(90.0f));
+ m_animationCameraZoom.setKeyValueAt(zoomOutFraction, QVariant::fromValue(50.0f));
+ m_animationCameraTarget.setKeyValueAt(zoomOutFraction,
+ QVariant::fromValue(QVector3D(0.0f, 0.0f, 0.0f)));
+ //! [12]
}
//! [0]
@@ -187,6 +221,14 @@ void GraphModifier::changeStyle(int style)
void GraphModifier::changePresetCamera()
{
+ m_animationCameraX.stop();
+ m_animationCameraY.stop();
+ m_animationCameraZoom.stop();
+ m_animationCameraTarget.stop();
+
+ // Restore camera target in case animation has changed it
+ m_graph->scene()->activeCamera()->setTarget(QVector3D(0.0f, 0.0f, 0.0f));
+
//! [10]
static int preset = Q3DCamera::CameraPresetFront;
@@ -263,6 +305,74 @@ void GraphModifier::setAxisTitleFixed(bool enabled)
m_yearAxis->setTitleFixed(enabled);
}
+//! [11]
+void GraphModifier::zoomToSelectedBar()
+{
+ m_animationCameraX.stop();
+ m_animationCameraY.stop();
+ m_animationCameraZoom.stop();
+ m_animationCameraTarget.stop();
+
+ Q3DCamera *camera = m_graph->scene()->activeCamera();
+ float currentX = camera->xRotation();
+ float currentY = camera->yRotation();
+ float currentZoom = camera->zoomLevel();
+ QVector3D currentTarget = camera->target();
+
+ m_animationCameraX.setStartValue(QVariant::fromValue(currentX));
+ m_animationCameraY.setStartValue(QVariant::fromValue(currentY));
+ m_animationCameraZoom.setStartValue(QVariant::fromValue(currentZoom));
+ m_animationCameraTarget.setStartValue(QVariant::fromValue(currentTarget));
+
+ QPoint selectedBar = m_graph->selectedSeries()
+ ? m_graph->selectedSeries()->selectedBar()
+ : QBar3DSeries::invalidSelectionPosition();
+
+ if (selectedBar != QBar3DSeries::invalidSelectionPosition()) {
+ // Normalize selected bar position within axis range to determine target coordinates
+ //! [13]
+ QVector3D endTarget;
+ float xMin = m_graph->columnAxis()->min();
+ float xRange = m_graph->columnAxis()->max() - xMin;
+ float zMin = m_graph->rowAxis()->min();
+ float zRange = m_graph->rowAxis()->max() - zMin;
+ endTarget.setX((selectedBar.y() - xMin) / xRange * 2.0f - 1.0f);
+ endTarget.setZ((selectedBar.x() - zMin) / zRange * 2.0f - 1.0f);
+ //! [13]
+
+ // Rotate the camera so that it always points approximately to the graph center
+ //! [15]
+ qreal endAngleX = qAtan(qreal(endTarget.z() / endTarget.x())) / M_PI * -180.0 + 90.0;
+ if (endTarget.x() > 0.0f)
+ endAngleX -= 180.0f;
+ float barValue = m_graph->selectedSeries()->dataProxy()->itemAt(selectedBar.x(),
+ selectedBar.y())->value();
+ float endAngleY = barValue >= 0.0f ? 30.0f : -30.0f;
+ if (m_graph->valueAxis()->reversed())
+ endAngleY *= -1.0f;
+ //! [15]
+
+ m_animationCameraX.setEndValue(QVariant::fromValue(float(endAngleX)));
+ m_animationCameraY.setEndValue(QVariant::fromValue(endAngleY));
+ m_animationCameraZoom.setEndValue(QVariant::fromValue(250));
+ //! [14]
+ m_animationCameraTarget.setEndValue(QVariant::fromValue(endTarget));
+ //! [14]
+ } else {
+ // No selected bar, so return to the default view
+ m_animationCameraX.setEndValue(QVariant::fromValue(m_defaultAngleX));
+ m_animationCameraY.setEndValue(QVariant::fromValue(m_defaultAngleY));
+ m_animationCameraZoom.setEndValue(QVariant::fromValue(m_defaultZoom));
+ m_animationCameraTarget.setEndValue(QVariant::fromValue(m_defaultTarget));
+ }
+
+ m_animationCameraX.start();
+ m_animationCameraY.start();
+ m_animationCameraZoom.start();
+ m_animationCameraTarget.start();
+}
+//! [11]
+
void GraphModifier::changeShadowQuality(int quality)
{
QAbstract3DGraph::ShadowQuality sq = QAbstract3DGraph::ShadowQuality(quality);
@@ -310,3 +420,8 @@ void GraphModifier::setReverseValueAxis(int enabled)
{
m_graph->valueAxis()->setReversed(enabled);
}
+
+void GraphModifier::setReflection(bool enabled)
+{
+ m_graph->setReflection(enabled);
+}
diff --git a/examples/datavisualization/bars/graphmodifier.h b/examples/datavisualization/bars/graphmodifier.h
index 107ffbab..22b00923 100644
--- a/examples/datavisualization/bars/graphmodifier.h
+++ b/examples/datavisualization/bars/graphmodifier.h
@@ -27,6 +27,7 @@
#include <QtCore/QDebug>
#include <QtCore/QStringList>
#include <QtCore/QPointer>
+#include <QtCore/QPropertyAnimation>
using namespace QtDataVisualization;
@@ -49,6 +50,7 @@ public:
void setSmoothBars(int smooth);
void setSeriesVisibility(int enabled);
void setReverseValueAxis(int enabled);
+ void setReflection(bool enabled);
public slots:
void changeRange(int range);
@@ -60,6 +62,7 @@ public slots:
void changeLabelRotation(int rotation);
void setAxisTitleVisibility(bool enabled);
void setAxisTitleFixed(bool enabled);
+ void zoomToSelectedBar();
signals:
void shadowQualityChanged(int quality);
@@ -86,6 +89,14 @@ private:
QBar3DSeries *m_secondarySeries;
QAbstract3DSeries::Mesh m_barMesh;
bool m_smooth;
+ QPropertyAnimation m_animationCameraX;
+ QPropertyAnimation m_animationCameraY;
+ QPropertyAnimation m_animationCameraZoom;
+ QPropertyAnimation m_animationCameraTarget;
+ float m_defaultAngleX;
+ float m_defaultAngleY;
+ float m_defaultZoom;
+ QVector3D m_defaultTarget;
};
#endif
diff --git a/examples/datavisualization/bars/main.cpp b/examples/datavisualization/bars/main.cpp
index 96abdc51..a7df14e0 100644
--- a/examples/datavisualization/bars/main.cpp
+++ b/examples/datavisualization/bars/main.cpp
@@ -72,6 +72,7 @@ int main(int argc, char **argv)
smoothCheckBox->setText(QStringLiteral("Smooth bars"));
smoothCheckBox->setChecked(false);
+
QComboBox *barStyleList = new QComboBox(widget);
barStyleList->addItem(QStringLiteral("Bar"), int(QAbstract3DSeries::MeshBar));
barStyleList->addItem(QStringLiteral("Pyramid"), int(QAbstract3DSeries::MeshPyramid));
@@ -84,6 +85,9 @@ int main(int argc, char **argv)
QPushButton *cameraButton = new QPushButton(widget);
cameraButton->setText(QStringLiteral("Change camera preset"));
+ QPushButton *zoomToSelectedButton = new QPushButton(widget);
+ zoomToSelectedButton->setText(QStringLiteral("Zoom to selected bar"));
+
QComboBox *selectionModeList = new QComboBox(widget);
selectionModeList->addItem(QStringLiteral("None"),
int(QAbstract3DGraph::SelectionNone));
@@ -136,6 +140,10 @@ int main(int argc, char **argv)
reverseValueAxisCheckBox->setText(QStringLiteral("Reverse value axis"));
reverseValueAxisCheckBox->setChecked(false);
+ QCheckBox *reflectionCheckBox = new QCheckBox(widget);
+ reflectionCheckBox->setText(QStringLiteral("Show reflections"));
+ reflectionCheckBox->setChecked(false);
+
//! [4]
QSlider *rotationSliderX = new QSlider(Qt::Horizontal, widget);
rotationSliderX->setTickInterval(30);
@@ -206,9 +214,11 @@ int main(int argc, char **argv)
//! [5]
vLayout->addWidget(labelButton, 0, Qt::AlignTop);
vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
+ vLayout->addWidget(zoomToSelectedButton, 0, Qt::AlignTop);
vLayout->addWidget(backgroundCheckBox);
vLayout->addWidget(gridCheckBox);
vLayout->addWidget(smoothCheckBox);
+ vLayout->addWidget(reflectionCheckBox);
vLayout->addWidget(seriesCheckBox);
vLayout->addWidget(reverseValueAxisCheckBox);
vLayout->addWidget(axisTitlesVisibleCB);
@@ -243,6 +253,8 @@ int main(int argc, char **argv)
&GraphModifier::changeLabelBackground);
QObject::connect(cameraButton, &QPushButton::clicked, modifier,
&GraphModifier::changePresetCamera);
+ QObject::connect(zoomToSelectedButton, &QPushButton::clicked, modifier,
+ &GraphModifier::zoomToSelectedBar);
QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
&GraphModifier::setBackgroundEnabled);
@@ -254,6 +266,8 @@ int main(int argc, char **argv)
&GraphModifier::setSeriesVisibility);
QObject::connect(reverseValueAxisCheckBox, &QCheckBox::stateChanged, modifier,
&GraphModifier::setReverseValueAxis);
+ QObject::connect(reflectionCheckBox, &QCheckBox::stateChanged, modifier,
+ &GraphModifier::setReflection);
QObject::connect(modifier, &GraphModifier::backgroundEnabledChanged,
backgroundCheckBox, &QCheckBox::setChecked);
diff --git a/examples/datavisualization/customproxy/doc/images/customproxy-example.png b/examples/datavisualization/customproxy/doc/images/customproxy-example.png
index 753b8951..4f82943a 100644
--- a/examples/datavisualization/customproxy/doc/images/customproxy-example.png
+++ b/examples/datavisualization/customproxy/doc/images/customproxy-example.png
Binary files differ
diff --git a/examples/datavisualization/customproxy/rainfallgraph.cpp b/examples/datavisualization/customproxy/rainfallgraph.cpp
index 024fc2a1..bcd67acc 100644
--- a/examples/datavisualization/customproxy/rainfallgraph.cpp
+++ b/examples/datavisualization/customproxy/rainfallgraph.cpp
@@ -49,7 +49,7 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall)
// Set up bar specifications; make the bars as wide as they are deep,
// and add a small space between the bars
m_graph->setBarThickness(1.0f);
- m_graph->setBarSpacing(QSizeF(0.2, 0.2));
+ m_graph->setBarSpacing(QSizeF(1.1, 1.1));
// Set axis labels and titles
QStringList months;
@@ -85,6 +85,9 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall)
// Set window title
m_graph->setTitle(QStringLiteral("Monthly rainfall in Northern Finland"));
+
+ // Set reflections on
+ m_graph->setReflection(true);
}
RainfallGraph::~RainfallGraph()
diff --git a/examples/datavisualization/datavisualization.pro b/examples/datavisualization/datavisualization.pro
index 1f72820c..b6ece48d 100644
--- a/examples/datavisualization/datavisualization.pro
+++ b/examples/datavisualization/datavisualization.pro
@@ -1,14 +1,17 @@
TEMPLATE = subdirs
-SUBDIRS += qmlbars \
- qmlscatter \
- qmlsurface \
- qmlcustominput \
- qmllegend \
- qmlmultigraph \
- qmloscilloscope \
- qmlsurfacelayers \
- qmlaxisformatter \
- qmlaxisdrag
+qtHaveModule(quick) {
+ SUBDIRS += qmlbars \
+ qmlscatter \
+ qmlsurface \
+ qmlcustominput \
+ qmllegend \
+ qmlmultigraph \
+ qmloscilloscope \
+ qmlsurfacelayers \
+ qmlaxisformatter \
+ qmlaxisdrag \
+ qmlspectrogram
+}
!android:!ios {
SUBDIRS += bars \
@@ -19,7 +22,10 @@ SUBDIRS += qmlbars \
surface \
rotations \
draggableaxes \
- customitems
+ customitems \
+ texturesurface \
+ volumetric
+
+ qtHaveModule(multimedia): SUBDIRS += audiolevels
}
-qtHaveModule(multimedia):!android:!ios: SUBDIRS += audiolevels
diff --git a/examples/datavisualization/qmlspectrogram/doc/images/qmlspectrogram-example.png b/examples/datavisualization/qmlspectrogram/doc/images/qmlspectrogram-example.png
new file mode 100644
index 00000000..de376cd9
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/doc/images/qmlspectrogram-example.png
Binary files differ
diff --git a/examples/datavisualization/qmlspectrogram/doc/src/qmlspectrogram.qdoc b/examples/datavisualization/qmlspectrogram/doc/src/qmlspectrogram.qdoc
new file mode 100644
index 00000000..0aebdde0
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/doc/src/qmlspectrogram.qdoc
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+/*!
+ \example qmlspectrogram
+ \title Qt Quick 2 Spectrogram Example
+ \ingroup qtdatavisualization_examples
+ \brief Showing spectrogram graph in a QML application.
+
+ The Qt Quick 2 Spectrogram example demonstrates how to show a polar and cartesian spectrograms
+ and how to utilize orthographic projection to show them in 2D.
+
+ \image qmlspectrogram-example.png
+
+ Spectrogram is simply a surface graph with a range gradient used to emphasize the different
+ values. Typically spectrograms are shown with two dimensional surfaces, which we simulate
+ with a top down orthographic view of the graph. To enforce the 2D effect, we disable the
+ graph rotation via mouse or touch when in the orthographic mode.
+
+ The focus in this example is on showing how to display spectrograms, so the basic
+ functionality is not explained. For more detailed QML example documentation,
+ see \l{Qt Quick 2 Scatter Example}.
+
+ \section1 Creating a spectrogram
+
+ To create a 2D spectrogram, we define a Surface3D item:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 0
+
+ The key properties for enabling the 2D effect are
+ \l{AbstractGraph3D::orthoProjection}{orthoProjection} and
+ \l{Camera3D::cameraPreset}{scene.activeCamera.cameraPreset}. We remove the perspective by
+ enabling orthographic projection for the graph, and then we eliminate the Y-dimension by
+ viewing the graph directly from above:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 1
+
+ Since this viewpoint causes the horizontal axis grid to be mostly obscured by the surface,
+ we also specify that the horizontal grid should be drawn on top of the graph:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 2
+
+ \section1 Polar spectrogram
+
+ Depending on the data, it is sometimes more natural to use a polar graph instead of a cartesian
+ one. Qt Data Visualization supports this via \l{AbstractGraph3D::polar}{polar} property.
+ In this example we provide a button to switch between polar and cartesian modes:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 3
+
+ In the polar mode, the X-axis is converted into the angular polar axis, and the Z-axis is
+ converted into the radial polar axis. The surface points are recalculated according to new axes.
+
+ The radial axis labels are drawn outside the graph by default, but in this example we want to
+ draw them right next to the 0 degree angular axis inside the graph, so we define only a tiny
+ offset for them:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 4
+
+ To enforce the 2D effect, graph rotation via user input is disabled when in orthographic mode.
+ We do this by specifying a new input handler:
+
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 5
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 7
+ \dots 0
+ \snippet qmlspectrogram/qml/qmlspectrogram/main.qml 6
+ \dots 0
+
+ When the projection mode changes, we adjust the value of the
+ \l{InputHandler3D::rotationEnabled}{rotationEnabled} property of the \c{customInputHandler}
+ to control the rotation.
+
+ \section1 Example contents
+*/
diff --git a/examples/datavisualization/qmlspectrogram/main.cpp b/examples/datavisualization/qmlspectrogram/main.cpp
new file mode 100644
index 00000000..87665564
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/main.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtCore/QDir>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ engine.addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ engine.load(QUrl(QStringLiteral("qrc:/qml/qml/qmlspectrogram/main.qml")));
+
+ return app.exec();
+}
diff --git a/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/Data.qml b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/Data.qml
new file mode 100644
index 00000000..fc54edf4
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/Data.qml
@@ -0,0 +1,1560 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ property alias model: dataModel
+
+ ListModel {
+ id: dataModel
+ ListElement{ radius: "0"; angle: "0"; value: "50"; }
+ ListElement{ radius: "0"; angle: "5"; value: "54.3578"; }
+ ListElement{ radius: "0"; angle: "10"; value: "58.6824"; }
+ ListElement{ radius: "0"; angle: "15"; value: "62.941"; }
+ ListElement{ radius: "0"; angle: "20"; value: "67.101"; }
+ ListElement{ radius: "0"; angle: "25"; value: "71.1309"; }
+ ListElement{ radius: "0"; angle: "30"; value: "75"; }
+ ListElement{ radius: "0"; angle: "35"; value: "78.6788"; }
+ ListElement{ radius: "0"; angle: "40"; value: "82.1394"; }
+ ListElement{ radius: "0"; angle: "45"; value: "85.3553"; }
+ ListElement{ radius: "0"; angle: "50"; value: "88.3022"; }
+ ListElement{ radius: "0"; angle: "55"; value: "90.9576"; }
+ ListElement{ radius: "0"; angle: "60"; value: "93.3013"; }
+ ListElement{ radius: "0"; angle: "65"; value: "95.3154"; }
+ ListElement{ radius: "0"; angle: "70"; value: "96.9846"; }
+ ListElement{ radius: "0"; angle: "75"; value: "98.2963"; }
+ ListElement{ radius: "0"; angle: "80"; value: "99.2404"; }
+ ListElement{ radius: "0"; angle: "85"; value: "99.8097"; }
+ ListElement{ radius: "0"; angle: "90"; value: "100"; }
+ ListElement{ radius: "0"; angle: "95"; value: "99.8097"; }
+ ListElement{ radius: "0"; angle: "100"; value: "99.2404"; }
+ ListElement{ radius: "0"; angle: "105"; value: "98.2963"; }
+ ListElement{ radius: "0"; angle: "110"; value: "96.9846"; }
+ ListElement{ radius: "0"; angle: "115"; value: "95.3154"; }
+ ListElement{ radius: "0"; angle: "120"; value: "93.3013"; }
+ ListElement{ radius: "0"; angle: "125"; value: "90.9576"; }
+ ListElement{ radius: "0"; angle: "130"; value: "88.3022"; }
+ ListElement{ radius: "0"; angle: "135"; value: "85.3553"; }
+ ListElement{ radius: "0"; angle: "140"; value: "82.1394"; }
+ ListElement{ radius: "0"; angle: "145"; value: "78.6788"; }
+ ListElement{ radius: "0"; angle: "150"; value: "75"; }
+ ListElement{ radius: "0"; angle: "155"; value: "71.1309"; }
+ ListElement{ radius: "0"; angle: "160"; value: "67.101"; }
+ ListElement{ radius: "0"; angle: "165"; value: "62.941"; }
+ ListElement{ radius: "0"; angle: "170"; value: "58.6824"; }
+ ListElement{ radius: "0"; angle: "175"; value: "54.3578"; }
+ ListElement{ radius: "0"; angle: "180"; value: "50"; }
+ ListElement{ radius: "0"; angle: "185"; value: "45.6422"; }
+ ListElement{ radius: "0"; angle: "190"; value: "41.3176"; }
+ ListElement{ radius: "0"; angle: "195"; value: "37.059"; }
+ ListElement{ radius: "0"; angle: "200"; value: "32.899"; }
+ ListElement{ radius: "0"; angle: "205"; value: "28.8691"; }
+ ListElement{ radius: "0"; angle: "210"; value: "25"; }
+ ListElement{ radius: "0"; angle: "215"; value: "21.3212"; }
+ ListElement{ radius: "0"; angle: "220"; value: "17.8606"; }
+ ListElement{ radius: "0"; angle: "225"; value: "14.6447"; }
+ ListElement{ radius: "0"; angle: "230"; value: "11.6978"; }
+ ListElement{ radius: "0"; angle: "235"; value: "9.0424"; }
+ ListElement{ radius: "0"; angle: "240"; value: "6.69873"; }
+ ListElement{ radius: "0"; angle: "245"; value: "4.68461"; }
+ ListElement{ radius: "0"; angle: "250"; value: "3.01537"; }
+ ListElement{ radius: "0"; angle: "255"; value: "1.70371"; }
+ ListElement{ radius: "0"; angle: "260"; value: "0.759612"; }
+ ListElement{ radius: "0"; angle: "265"; value: "0.190265"; }
+ ListElement{ radius: "0"; angle: "270"; value: "0"; }
+ ListElement{ radius: "0"; angle: "275"; value: "0.190265"; }
+ ListElement{ radius: "0"; angle: "280"; value: "0.759612"; }
+ ListElement{ radius: "0"; angle: "285"; value: "1.70371"; }
+ ListElement{ radius: "0"; angle: "290"; value: "3.01537"; }
+ ListElement{ radius: "0"; angle: "295"; value: "4.68461"; }
+ ListElement{ radius: "0"; angle: "300"; value: "6.69873"; }
+ ListElement{ radius: "0"; angle: "305"; value: "9.0424"; }
+ ListElement{ radius: "0"; angle: "310"; value: "11.6978"; }
+ ListElement{ radius: "0"; angle: "315"; value: "14.6447"; }
+ ListElement{ radius: "0"; angle: "320"; value: "17.8606"; }
+ ListElement{ radius: "0"; angle: "325"; value: "21.3212"; }
+ ListElement{ radius: "0"; angle: "330"; value: "25"; }
+ ListElement{ radius: "0"; angle: "335"; value: "28.8691"; }
+ ListElement{ radius: "0"; angle: "340"; value: "32.899"; }
+ ListElement{ radius: "0"; angle: "345"; value: "37.059"; }
+ ListElement{ radius: "0"; angle: "350"; value: "41.3176"; }
+ ListElement{ radius: "0"; angle: "355"; value: "45.6422"; }
+ ListElement{ radius: "0"; angle: "360"; value: "50"; }
+ ListElement{ radius: "5"; angle: "0"; value: "49.3844"; }
+ ListElement{ radius: "5"; angle: "5"; value: "53.7422"; }
+ ListElement{ radius: "5"; angle: "10"; value: "58.0668"; }
+ ListElement{ radius: "5"; angle: "15"; value: "62.3254"; }
+ ListElement{ radius: "5"; angle: "20"; value: "66.4854"; }
+ ListElement{ radius: "5"; angle: "25"; value: "70.5153"; }
+ ListElement{ radius: "5"; angle: "30"; value: "74.3844"; }
+ ListElement{ radius: "5"; angle: "35"; value: "78.0632"; }
+ ListElement{ radius: "5"; angle: "40"; value: "81.5238"; }
+ ListElement{ radius: "5"; angle: "45"; value: "84.7398"; }
+ ListElement{ radius: "5"; angle: "50"; value: "87.6866"; }
+ ListElement{ radius: "5"; angle: "55"; value: "90.342"; }
+ ListElement{ radius: "5"; angle: "60"; value: "92.6857"; }
+ ListElement{ radius: "5"; angle: "65"; value: "94.6998"; }
+ ListElement{ radius: "5"; angle: "70"; value: "96.369"; }
+ ListElement{ radius: "5"; angle: "75"; value: "97.6807"; }
+ ListElement{ radius: "5"; angle: "80"; value: "98.6248"; }
+ ListElement{ radius: "5"; angle: "85"; value: "99.1942"; }
+ ListElement{ radius: "5"; angle: "90"; value: "99.3844"; }
+ ListElement{ radius: "5"; angle: "95"; value: "99.1942"; }
+ ListElement{ radius: "5"; angle: "100"; value: "98.6248"; }
+ ListElement{ radius: "5"; angle: "105"; value: "97.6807"; }
+ ListElement{ radius: "5"; angle: "110"; value: "96.369"; }
+ ListElement{ radius: "5"; angle: "115"; value: "94.6998"; }
+ ListElement{ radius: "5"; angle: "120"; value: "92.6857"; }
+ ListElement{ radius: "5"; angle: "125"; value: "90.342"; }
+ ListElement{ radius: "5"; angle: "130"; value: "87.6866"; }
+ ListElement{ radius: "5"; angle: "135"; value: "84.7398"; }
+ ListElement{ radius: "5"; angle: "140"; value: "81.5238"; }
+ ListElement{ radius: "5"; angle: "145"; value: "78.0632"; }
+ ListElement{ radius: "5"; angle: "150"; value: "74.3844"; }
+ ListElement{ radius: "5"; angle: "155"; value: "70.5153"; }
+ ListElement{ radius: "5"; angle: "160"; value: "66.4854"; }
+ ListElement{ radius: "5"; angle: "165"; value: "62.3254"; }
+ ListElement{ radius: "5"; angle: "170"; value: "58.0668"; }
+ ListElement{ radius: "5"; angle: "175"; value: "53.7422"; }
+ ListElement{ radius: "5"; angle: "180"; value: "49.3844"; }
+ ListElement{ radius: "5"; angle: "185"; value: "45.0266"; }
+ ListElement{ radius: "5"; angle: "190"; value: "40.702"; }
+ ListElement{ radius: "5"; angle: "195"; value: "36.4435"; }
+ ListElement{ radius: "5"; angle: "200"; value: "32.2834"; }
+ ListElement{ radius: "5"; angle: "205"; value: "28.2535"; }
+ ListElement{ radius: "5"; angle: "210"; value: "24.3844"; }
+ ListElement{ radius: "5"; angle: "215"; value: "20.7056"; }
+ ListElement{ radius: "5"; angle: "220"; value: "17.245"; }
+ ListElement{ radius: "5"; angle: "225"; value: "14.0291"; }
+ ListElement{ radius: "5"; angle: "230"; value: "11.0822"; }
+ ListElement{ radius: "5"; angle: "235"; value: "8.42681"; }
+ ListElement{ radius: "5"; angle: "240"; value: "6.08315"; }
+ ListElement{ radius: "5"; angle: "245"; value: "4.06903"; }
+ ListElement{ radius: "5"; angle: "250"; value: "2.39979"; }
+ ListElement{ radius: "5"; angle: "255"; value: "1.08813"; }
+ ListElement{ radius: "5"; angle: "260"; value: "0.144029"; }
+ ListElement{ radius: "5"; angle: "265"; value: "-0.425318"; }
+ ListElement{ radius: "5"; angle: "270"; value: "-0.615583"; }
+ ListElement{ radius: "5"; angle: "275"; value: "-0.425318"; }
+ ListElement{ radius: "5"; angle: "280"; value: "0.144029"; }
+ ListElement{ radius: "5"; angle: "285"; value: "1.08813"; }
+ ListElement{ radius: "5"; angle: "290"; value: "2.39979"; }
+ ListElement{ radius: "5"; angle: "295"; value: "4.06903"; }
+ ListElement{ radius: "5"; angle: "300"; value: "6.08315"; }
+ ListElement{ radius: "5"; angle: "305"; value: "8.42681"; }
+ ListElement{ radius: "5"; angle: "310"; value: "11.0822"; }
+ ListElement{ radius: "5"; angle: "315"; value: "14.0291"; }
+ ListElement{ radius: "5"; angle: "320"; value: "17.245"; }
+ ListElement{ radius: "5"; angle: "325"; value: "20.7056"; }
+ ListElement{ radius: "5"; angle: "330"; value: "24.3844"; }
+ ListElement{ radius: "5"; angle: "335"; value: "28.2535"; }
+ ListElement{ radius: "5"; angle: "340"; value: "32.2834"; }
+ ListElement{ radius: "5"; angle: "345"; value: "36.4435"; }
+ ListElement{ radius: "5"; angle: "350"; value: "40.702"; }
+ ListElement{ radius: "5"; angle: "355"; value: "45.0266"; }
+ ListElement{ radius: "5"; angle: "360"; value: "49.3844"; }
+ ListElement{ radius: "10"; angle: "0"; value: "47.5528"; }
+ ListElement{ radius: "10"; angle: "5"; value: "51.9106"; }
+ ListElement{ radius: "10"; angle: "10"; value: "56.2352"; }
+ ListElement{ radius: "10"; angle: "15"; value: "60.4938"; }
+ ListElement{ radius: "10"; angle: "20"; value: "64.6538"; }
+ ListElement{ radius: "10"; angle: "25"; value: "68.6837"; }
+ ListElement{ radius: "10"; angle: "30"; value: "72.5528"; }
+ ListElement{ radius: "10"; angle: "35"; value: "76.2316"; }
+ ListElement{ radius: "10"; angle: "40"; value: "79.6922"; }
+ ListElement{ radius: "10"; angle: "45"; value: "82.9082"; }
+ ListElement{ radius: "10"; angle: "50"; value: "85.855"; }
+ ListElement{ radius: "10"; angle: "55"; value: "88.5104"; }
+ ListElement{ radius: "10"; angle: "60"; value: "90.8541"; }
+ ListElement{ radius: "10"; angle: "65"; value: "92.8682"; }
+ ListElement{ radius: "10"; angle: "70"; value: "94.5375"; }
+ ListElement{ radius: "10"; angle: "75"; value: "95.8491"; }
+ ListElement{ radius: "10"; angle: "80"; value: "96.7932"; }
+ ListElement{ radius: "10"; angle: "85"; value: "97.3626"; }
+ ListElement{ radius: "10"; angle: "90"; value: "97.5528"; }
+ ListElement{ radius: "10"; angle: "95"; value: "97.3626"; }
+ ListElement{ radius: "10"; angle: "100"; value: "96.7932"; }
+ ListElement{ radius: "10"; angle: "105"; value: "95.8491"; }
+ ListElement{ radius: "10"; angle: "110"; value: "94.5375"; }
+ ListElement{ radius: "10"; angle: "115"; value: "92.8682"; }
+ ListElement{ radius: "10"; angle: "120"; value: "90.8541"; }
+ ListElement{ radius: "10"; angle: "125"; value: "88.5104"; }
+ ListElement{ radius: "10"; angle: "130"; value: "85.855"; }
+ ListElement{ radius: "10"; angle: "135"; value: "82.9082"; }
+ ListElement{ radius: "10"; angle: "140"; value: "79.6922"; }
+ ListElement{ radius: "10"; angle: "145"; value: "76.2316"; }
+ ListElement{ radius: "10"; angle: "150"; value: "72.5528"; }
+ ListElement{ radius: "10"; angle: "155"; value: "68.6837"; }
+ ListElement{ radius: "10"; angle: "160"; value: "64.6538"; }
+ ListElement{ radius: "10"; angle: "165"; value: "60.4938"; }
+ ListElement{ radius: "10"; angle: "170"; value: "56.2352"; }
+ ListElement{ radius: "10"; angle: "175"; value: "51.9106"; }
+ ListElement{ radius: "10"; angle: "180"; value: "47.5528"; }
+ ListElement{ radius: "10"; angle: "185"; value: "43.195"; }
+ ListElement{ radius: "10"; angle: "190"; value: "38.8704"; }
+ ListElement{ radius: "10"; angle: "195"; value: "34.6119"; }
+ ListElement{ radius: "10"; angle: "200"; value: "30.4518"; }
+ ListElement{ radius: "10"; angle: "205"; value: "26.4219"; }
+ ListElement{ radius: "10"; angle: "210"; value: "22.5528"; }
+ ListElement{ radius: "10"; angle: "215"; value: "18.874"; }
+ ListElement{ radius: "10"; angle: "220"; value: "15.4134"; }
+ ListElement{ radius: "10"; angle: "225"; value: "12.1975"; }
+ ListElement{ radius: "10"; angle: "230"; value: "9.2506"; }
+ ListElement{ radius: "10"; angle: "235"; value: "6.59522"; }
+ ListElement{ radius: "10"; angle: "240"; value: "4.25156"; }
+ ListElement{ radius: "10"; angle: "245"; value: "2.23744"; }
+ ListElement{ radius: "10"; angle: "250"; value: "0.568195"; }
+ ListElement{ radius: "10"; angle: "255"; value: "-0.743465"; }
+ ListElement{ radius: "10"; angle: "260"; value: "-1.68756"; }
+ ListElement{ radius: "10"; angle: "265"; value: "-2.25691"; }
+ ListElement{ radius: "10"; angle: "270"; value: "-2.44717"; }
+ ListElement{ radius: "10"; angle: "275"; value: "-2.25691"; }
+ ListElement{ radius: "10"; angle: "280"; value: "-1.68756"; }
+ ListElement{ radius: "10"; angle: "285"; value: "-0.743465"; }
+ ListElement{ radius: "10"; angle: "290"; value: "0.568195"; }
+ ListElement{ radius: "10"; angle: "295"; value: "2.23744"; }
+ ListElement{ radius: "10"; angle: "300"; value: "4.25156"; }
+ ListElement{ radius: "10"; angle: "305"; value: "6.59522"; }
+ ListElement{ radius: "10"; angle: "310"; value: "9.2506"; }
+ ListElement{ radius: "10"; angle: "315"; value: "12.1975"; }
+ ListElement{ radius: "10"; angle: "320"; value: "15.4134"; }
+ ListElement{ radius: "10"; angle: "325"; value: "18.874"; }
+ ListElement{ radius: "10"; angle: "330"; value: "22.5528"; }
+ ListElement{ radius: "10"; angle: "335"; value: "26.4219"; }
+ ListElement{ radius: "10"; angle: "340"; value: "30.4518"; }
+ ListElement{ radius: "10"; angle: "345"; value: "34.6119"; }
+ ListElement{ radius: "10"; angle: "350"; value: "38.8704"; }
+ ListElement{ radius: "10"; angle: "355"; value: "43.195"; }
+ ListElement{ radius: "10"; angle: "360"; value: "47.5528"; }
+ ListElement{ radius: "15"; angle: "0"; value: "44.5503"; }
+ ListElement{ radius: "15"; angle: "5"; value: "48.9081"; }
+ ListElement{ radius: "15"; angle: "10"; value: "53.2327"; }
+ ListElement{ radius: "15"; angle: "15"; value: "57.4913"; }
+ ListElement{ radius: "15"; angle: "20"; value: "61.6513"; }
+ ListElement{ radius: "15"; angle: "25"; value: "65.6812"; }
+ ListElement{ radius: "15"; angle: "30"; value: "69.5503"; }
+ ListElement{ radius: "15"; angle: "35"; value: "73.2291"; }
+ ListElement{ radius: "15"; angle: "40"; value: "76.6897"; }
+ ListElement{ radius: "15"; angle: "45"; value: "79.9057"; }
+ ListElement{ radius: "15"; angle: "50"; value: "82.8525"; }
+ ListElement{ radius: "15"; angle: "55"; value: "85.5079"; }
+ ListElement{ radius: "15"; angle: "60"; value: "87.8516"; }
+ ListElement{ radius: "15"; angle: "65"; value: "89.8657"; }
+ ListElement{ radius: "15"; angle: "70"; value: "91.535"; }
+ ListElement{ radius: "15"; angle: "75"; value: "92.8466"; }
+ ListElement{ radius: "15"; angle: "80"; value: "93.7907"; }
+ ListElement{ radius: "15"; angle: "85"; value: "94.3601"; }
+ ListElement{ radius: "15"; angle: "90"; value: "94.5503"; }
+ ListElement{ radius: "15"; angle: "95"; value: "94.3601"; }
+ ListElement{ radius: "15"; angle: "100"; value: "93.7907"; }
+ ListElement{ radius: "15"; angle: "105"; value: "92.8466"; }
+ ListElement{ radius: "15"; angle: "110"; value: "91.535"; }
+ ListElement{ radius: "15"; angle: "115"; value: "89.8657"; }
+ ListElement{ radius: "15"; angle: "120"; value: "87.8516"; }
+ ListElement{ radius: "15"; angle: "125"; value: "85.5079"; }
+ ListElement{ radius: "15"; angle: "130"; value: "82.8525"; }
+ ListElement{ radius: "15"; angle: "135"; value: "79.9057"; }
+ ListElement{ radius: "15"; angle: "140"; value: "76.6897"; }
+ ListElement{ radius: "15"; angle: "145"; value: "73.2291"; }
+ ListElement{ radius: "15"; angle: "150"; value: "69.5503"; }
+ ListElement{ radius: "15"; angle: "155"; value: "65.6812"; }
+ ListElement{ radius: "15"; angle: "160"; value: "61.6513"; }
+ ListElement{ radius: "15"; angle: "165"; value: "57.4913"; }
+ ListElement{ radius: "15"; angle: "170"; value: "53.2327"; }
+ ListElement{ radius: "15"; angle: "175"; value: "48.9081"; }
+ ListElement{ radius: "15"; angle: "180"; value: "44.5503"; }
+ ListElement{ radius: "15"; angle: "185"; value: "40.1925"; }
+ ListElement{ radius: "15"; angle: "190"; value: "35.8679"; }
+ ListElement{ radius: "15"; angle: "195"; value: "31.6094"; }
+ ListElement{ radius: "15"; angle: "200"; value: "27.4493"; }
+ ListElement{ radius: "15"; angle: "205"; value: "23.4194"; }
+ ListElement{ radius: "15"; angle: "210"; value: "19.5503"; }
+ ListElement{ radius: "15"; angle: "215"; value: "15.8715"; }
+ ListElement{ radius: "15"; angle: "220"; value: "12.4109"; }
+ ListElement{ radius: "15"; angle: "225"; value: "9.19499"; }
+ ListElement{ radius: "15"; angle: "230"; value: "6.2481"; }
+ ListElement{ radius: "15"; angle: "235"; value: "3.59272"; }
+ ListElement{ radius: "15"; angle: "240"; value: "1.24906"; }
+ ListElement{ radius: "15"; angle: "245"; value: "-0.765063"; }
+ ListElement{ radius: "15"; angle: "250"; value: "-2.4343"; }
+ ListElement{ radius: "15"; angle: "255"; value: "-3.74597"; }
+ ListElement{ radius: "15"; angle: "260"; value: "-4.69006"; }
+ ListElement{ radius: "15"; angle: "265"; value: "-5.25941"; }
+ ListElement{ radius: "15"; angle: "270"; value: "-5.44967"; }
+ ListElement{ radius: "15"; angle: "275"; value: "-5.25941"; }
+ ListElement{ radius: "15"; angle: "280"; value: "-4.69006"; }
+ ListElement{ radius: "15"; angle: "285"; value: "-3.74597"; }
+ ListElement{ radius: "15"; angle: "290"; value: "-2.4343"; }
+ ListElement{ radius: "15"; angle: "295"; value: "-0.765063"; }
+ ListElement{ radius: "15"; angle: "300"; value: "1.24906"; }
+ ListElement{ radius: "15"; angle: "305"; value: "3.59272"; }
+ ListElement{ radius: "15"; angle: "310"; value: "6.2481"; }
+ ListElement{ radius: "15"; angle: "315"; value: "9.19499"; }
+ ListElement{ radius: "15"; angle: "320"; value: "12.4109"; }
+ ListElement{ radius: "15"; angle: "325"; value: "15.8715"; }
+ ListElement{ radius: "15"; angle: "330"; value: "19.5503"; }
+ ListElement{ radius: "15"; angle: "335"; value: "23.4194"; }
+ ListElement{ radius: "15"; angle: "340"; value: "27.4493"; }
+ ListElement{ radius: "15"; angle: "345"; value: "31.6094"; }
+ ListElement{ radius: "15"; angle: "350"; value: "35.8679"; }
+ ListElement{ radius: "15"; angle: "355"; value: "40.1925"; }
+ ListElement{ radius: "15"; angle: "360"; value: "44.5503"; }
+ ListElement{ radius: "20"; angle: "0"; value: "40.4508"; }
+ ListElement{ radius: "20"; angle: "5"; value: "44.8086"; }
+ ListElement{ radius: "20"; angle: "10"; value: "49.1333"; }
+ ListElement{ radius: "20"; angle: "15"; value: "53.3918"; }
+ ListElement{ radius: "20"; angle: "20"; value: "57.5519"; }
+ ListElement{ radius: "20"; angle: "25"; value: "61.5818"; }
+ ListElement{ radius: "20"; angle: "30"; value: "65.4508"; }
+ ListElement{ radius: "20"; angle: "35"; value: "69.1297"; }
+ ListElement{ radius: "20"; angle: "40"; value: "72.5902"; }
+ ListElement{ radius: "20"; angle: "45"; value: "75.8062"; }
+ ListElement{ radius: "20"; angle: "50"; value: "78.7531"; }
+ ListElement{ radius: "20"; angle: "55"; value: "81.4085"; }
+ ListElement{ radius: "20"; angle: "60"; value: "83.7521"; }
+ ListElement{ radius: "20"; angle: "65"; value: "85.7662"; }
+ ListElement{ radius: "20"; angle: "70"; value: "87.4355"; }
+ ListElement{ radius: "20"; angle: "75"; value: "88.7471"; }
+ ListElement{ radius: "20"; angle: "80"; value: "89.6912"; }
+ ListElement{ radius: "20"; angle: "85"; value: "90.2606"; }
+ ListElement{ radius: "20"; angle: "90"; value: "90.4508"; }
+ ListElement{ radius: "20"; angle: "95"; value: "90.2606"; }
+ ListElement{ radius: "20"; angle: "100"; value: "89.6912"; }
+ ListElement{ radius: "20"; angle: "105"; value: "88.7471"; }
+ ListElement{ radius: "20"; angle: "110"; value: "87.4355"; }
+ ListElement{ radius: "20"; angle: "115"; value: "85.7662"; }
+ ListElement{ radius: "20"; angle: "120"; value: "83.7521"; }
+ ListElement{ radius: "20"; angle: "125"; value: "81.4085"; }
+ ListElement{ radius: "20"; angle: "130"; value: "78.7531"; }
+ ListElement{ radius: "20"; angle: "135"; value: "75.8062"; }
+ ListElement{ radius: "20"; angle: "140"; value: "72.5902"; }
+ ListElement{ radius: "20"; angle: "145"; value: "69.1297"; }
+ ListElement{ radius: "20"; angle: "150"; value: "65.4508"; }
+ ListElement{ radius: "20"; angle: "155"; value: "61.5818"; }
+ ListElement{ radius: "20"; angle: "160"; value: "57.5519"; }
+ ListElement{ radius: "20"; angle: "165"; value: "53.3918"; }
+ ListElement{ radius: "20"; angle: "170"; value: "49.1333"; }
+ ListElement{ radius: "20"; angle: "175"; value: "44.8086"; }
+ ListElement{ radius: "20"; angle: "180"; value: "40.4508"; }
+ ListElement{ radius: "20"; angle: "185"; value: "36.0931"; }
+ ListElement{ radius: "20"; angle: "190"; value: "31.7684"; }
+ ListElement{ radius: "20"; angle: "195"; value: "27.5099"; }
+ ListElement{ radius: "20"; angle: "200"; value: "23.3498"; }
+ ListElement{ radius: "20"; angle: "205"; value: "19.3199"; }
+ ListElement{ radius: "20"; angle: "210"; value: "15.4508"; }
+ ListElement{ radius: "20"; angle: "215"; value: "11.772"; }
+ ListElement{ radius: "20"; angle: "220"; value: "8.31147"; }
+ ListElement{ radius: "20"; angle: "225"; value: "5.09551"; }
+ ListElement{ radius: "20"; angle: "230"; value: "2.14863"; }
+ ListElement{ radius: "20"; angle: "235"; value: "-0.506752"; }
+ ListElement{ radius: "20"; angle: "240"; value: "-2.85042"; }
+ ListElement{ radius: "20"; angle: "245"; value: "-4.86454"; }
+ ListElement{ radius: "20"; angle: "250"; value: "-6.53378"; }
+ ListElement{ radius: "20"; angle: "255"; value: "-7.84544"; }
+ ListElement{ radius: "20"; angle: "260"; value: "-8.78954"; }
+ ListElement{ radius: "20"; angle: "265"; value: "-9.35889"; }
+ ListElement{ radius: "20"; angle: "270"; value: "-9.54915"; }
+ ListElement{ radius: "20"; angle: "275"; value: "-9.35889"; }
+ ListElement{ radius: "20"; angle: "280"; value: "-8.78954"; }
+ ListElement{ radius: "20"; angle: "285"; value: "-7.84544"; }
+ ListElement{ radius: "20"; angle: "290"; value: "-6.53378"; }
+ ListElement{ radius: "20"; angle: "295"; value: "-4.86454"; }
+ ListElement{ radius: "20"; angle: "300"; value: "-2.85042"; }
+ ListElement{ radius: "20"; angle: "305"; value: "-0.506752"; }
+ ListElement{ radius: "20"; angle: "310"; value: "2.14863"; }
+ ListElement{ radius: "20"; angle: "315"; value: "5.09551"; }
+ ListElement{ radius: "20"; angle: "320"; value: "8.31147"; }
+ ListElement{ radius: "20"; angle: "325"; value: "11.772"; }
+ ListElement{ radius: "20"; angle: "330"; value: "15.4508"; }
+ ListElement{ radius: "20"; angle: "335"; value: "19.3199"; }
+ ListElement{ radius: "20"; angle: "340"; value: "23.3498"; }
+ ListElement{ radius: "20"; angle: "345"; value: "27.5099"; }
+ ListElement{ radius: "20"; angle: "350"; value: "31.7684"; }
+ ListElement{ radius: "20"; angle: "355"; value: "36.0931"; }
+ ListElement{ radius: "20"; angle: "360"; value: "40.4508"; }
+ ListElement{ radius: "25"; angle: "0"; value: "35.3553"; }
+ ListElement{ radius: "25"; angle: "5"; value: "39.7131"; }
+ ListElement{ radius: "25"; angle: "10"; value: "44.0377"; }
+ ListElement{ radius: "25"; angle: "15"; value: "48.2963"; }
+ ListElement{ radius: "25"; angle: "20"; value: "52.4563"; }
+ ListElement{ radius: "25"; angle: "25"; value: "56.4863"; }
+ ListElement{ radius: "25"; angle: "30"; value: "60.3553"; }
+ ListElement{ radius: "25"; angle: "35"; value: "64.0342"; }
+ ListElement{ radius: "25"; angle: "40"; value: "67.4947"; }
+ ListElement{ radius: "25"; angle: "45"; value: "70.7107"; }
+ ListElement{ radius: "25"; angle: "50"; value: "73.6576"; }
+ ListElement{ radius: "25"; angle: "55"; value: "76.3129"; }
+ ListElement{ radius: "25"; angle: "60"; value: "78.6566"; }
+ ListElement{ radius: "25"; angle: "65"; value: "80.6707"; }
+ ListElement{ radius: "25"; angle: "70"; value: "82.34"; }
+ ListElement{ radius: "25"; angle: "75"; value: "83.6516"; }
+ ListElement{ radius: "25"; angle: "80"; value: "84.5957"; }
+ ListElement{ radius: "25"; angle: "85"; value: "85.1651"; }
+ ListElement{ radius: "25"; angle: "90"; value: "85.3553"; }
+ ListElement{ radius: "25"; angle: "95"; value: "85.1651"; }
+ ListElement{ radius: "25"; angle: "100"; value: "84.5957"; }
+ ListElement{ radius: "25"; angle: "105"; value: "83.6516"; }
+ ListElement{ radius: "25"; angle: "110"; value: "82.34"; }
+ ListElement{ radius: "25"; angle: "115"; value: "80.6707"; }
+ ListElement{ radius: "25"; angle: "120"; value: "78.6566"; }
+ ListElement{ radius: "25"; angle: "125"; value: "76.3129"; }
+ ListElement{ radius: "25"; angle: "130"; value: "73.6576"; }
+ ListElement{ radius: "25"; angle: "135"; value: "70.7107"; }
+ ListElement{ radius: "25"; angle: "140"; value: "67.4947"; }
+ ListElement{ radius: "25"; angle: "145"; value: "64.0342"; }
+ ListElement{ radius: "25"; angle: "150"; value: "60.3553"; }
+ ListElement{ radius: "25"; angle: "155"; value: "56.4863"; }
+ ListElement{ radius: "25"; angle: "160"; value: "52.4563"; }
+ ListElement{ radius: "25"; angle: "165"; value: "48.2963"; }
+ ListElement{ radius: "25"; angle: "170"; value: "44.0377"; }
+ ListElement{ radius: "25"; angle: "175"; value: "39.7131"; }
+ ListElement{ radius: "25"; angle: "180"; value: "35.3553"; }
+ ListElement{ radius: "25"; angle: "185"; value: "30.9976"; }
+ ListElement{ radius: "25"; angle: "190"; value: "26.6729"; }
+ ListElement{ radius: "25"; angle: "195"; value: "22.4144"; }
+ ListElement{ radius: "25"; angle: "200"; value: "18.2543"; }
+ ListElement{ radius: "25"; angle: "205"; value: "14.2244"; }
+ ListElement{ radius: "25"; angle: "210"; value: "10.3553"; }
+ ListElement{ radius: "25"; angle: "215"; value: "6.67652"; }
+ ListElement{ radius: "25"; angle: "220"; value: "3.21596"; }
+ ListElement{ radius: "25"; angle: "225"; value: "5.55112e-15"; }
+ ListElement{ radius: "25"; angle: "230"; value: "-2.94688"; }
+ ListElement{ radius: "25"; angle: "235"; value: "-5.60226"; }
+ ListElement{ radius: "25"; angle: "240"; value: "-7.94593"; }
+ ListElement{ radius: "25"; angle: "245"; value: "-9.96005"; }
+ ListElement{ radius: "25"; angle: "250"; value: "-11.6293"; }
+ ListElement{ radius: "25"; angle: "255"; value: "-12.941"; }
+ ListElement{ radius: "25"; angle: "260"; value: "-13.885"; }
+ ListElement{ radius: "25"; angle: "265"; value: "-14.4544"; }
+ ListElement{ radius: "25"; angle: "270"; value: "-14.6447"; }
+ ListElement{ radius: "25"; angle: "275"; value: "-14.4544"; }
+ ListElement{ radius: "25"; angle: "280"; value: "-13.885"; }
+ ListElement{ radius: "25"; angle: "285"; value: "-12.941"; }
+ ListElement{ radius: "25"; angle: "290"; value: "-11.6293"; }
+ ListElement{ radius: "25"; angle: "295"; value: "-9.96005"; }
+ ListElement{ radius: "25"; angle: "300"; value: "-7.94593"; }
+ ListElement{ radius: "25"; angle: "305"; value: "-5.60226"; }
+ ListElement{ radius: "25"; angle: "310"; value: "-2.94688"; }
+ ListElement{ radius: "25"; angle: "315"; value: "-5.55112e-15"; }
+ ListElement{ radius: "25"; angle: "320"; value: "3.21596"; }
+ ListElement{ radius: "25"; angle: "325"; value: "6.67652"; }
+ ListElement{ radius: "25"; angle: "330"; value: "10.3553"; }
+ ListElement{ radius: "25"; angle: "335"; value: "14.2244"; }
+ ListElement{ radius: "25"; angle: "340"; value: "18.2543"; }
+ ListElement{ radius: "25"; angle: "345"; value: "22.4144"; }
+ ListElement{ radius: "25"; angle: "350"; value: "26.6729"; }
+ ListElement{ radius: "25"; angle: "355"; value: "30.9976"; }
+ ListElement{ radius: "25"; angle: "360"; value: "35.3553"; }
+ ListElement{ radius: "30"; angle: "0"; value: "29.3893"; }
+ ListElement{ radius: "30"; angle: "5"; value: "33.747"; }
+ ListElement{ radius: "30"; angle: "10"; value: "38.0717"; }
+ ListElement{ radius: "30"; angle: "15"; value: "42.3302"; }
+ ListElement{ radius: "30"; angle: "20"; value: "46.4903"; }
+ ListElement{ radius: "30"; angle: "25"; value: "50.5202"; }
+ ListElement{ radius: "30"; angle: "30"; value: "54.3893"; }
+ ListElement{ radius: "30"; angle: "35"; value: "58.0681"; }
+ ListElement{ radius: "30"; angle: "40"; value: "61.5286"; }
+ ListElement{ radius: "30"; angle: "45"; value: "64.7446"; }
+ ListElement{ radius: "30"; angle: "50"; value: "67.6915"; }
+ ListElement{ radius: "30"; angle: "55"; value: "70.3469"; }
+ ListElement{ radius: "30"; angle: "60"; value: "72.6905"; }
+ ListElement{ radius: "30"; angle: "65"; value: "74.7047"; }
+ ListElement{ radius: "30"; angle: "70"; value: "76.3739"; }
+ ListElement{ radius: "30"; angle: "75"; value: "77.6856"; }
+ ListElement{ radius: "30"; angle: "80"; value: "78.6297"; }
+ ListElement{ radius: "30"; angle: "85"; value: "79.199"; }
+ ListElement{ radius: "30"; angle: "90"; value: "79.3893"; }
+ ListElement{ radius: "30"; angle: "95"; value: "79.199"; }
+ ListElement{ radius: "30"; angle: "100"; value: "78.6297"; }
+ ListElement{ radius: "30"; angle: "105"; value: "77.6856"; }
+ ListElement{ radius: "30"; angle: "110"; value: "76.3739"; }
+ ListElement{ radius: "30"; angle: "115"; value: "74.7047"; }
+ ListElement{ radius: "30"; angle: "120"; value: "72.6905"; }
+ ListElement{ radius: "30"; angle: "125"; value: "70.3469"; }
+ ListElement{ radius: "30"; angle: "130"; value: "67.6915"; }
+ ListElement{ radius: "30"; angle: "135"; value: "64.7446"; }
+ ListElement{ radius: "30"; angle: "140"; value: "61.5286"; }
+ ListElement{ radius: "30"; angle: "145"; value: "58.0681"; }
+ ListElement{ radius: "30"; angle: "150"; value: "54.3893"; }
+ ListElement{ radius: "30"; angle: "155"; value: "50.5202"; }
+ ListElement{ radius: "30"; angle: "160"; value: "46.4903"; }
+ ListElement{ radius: "30"; angle: "165"; value: "42.3302"; }
+ ListElement{ radius: "30"; angle: "170"; value: "38.0717"; }
+ ListElement{ radius: "30"; angle: "175"; value: "33.747"; }
+ ListElement{ radius: "30"; angle: "180"; value: "29.3893"; }
+ ListElement{ radius: "30"; angle: "185"; value: "25.0315"; }
+ ListElement{ radius: "30"; angle: "190"; value: "20.7069"; }
+ ListElement{ radius: "30"; angle: "195"; value: "16.4483"; }
+ ListElement{ radius: "30"; angle: "200"; value: "12.2883"; }
+ ListElement{ radius: "30"; angle: "205"; value: "8.25835"; }
+ ListElement{ radius: "30"; angle: "210"; value: "4.38926"; }
+ ListElement{ radius: "30"; angle: "215"; value: "0.710441"; }
+ ListElement{ radius: "30"; angle: "220"; value: "-2.75012"; }
+ ListElement{ radius: "30"; angle: "225"; value: "-5.96608"; }
+ ListElement{ radius: "30"; angle: "230"; value: "-8.91296"; }
+ ListElement{ radius: "30"; angle: "235"; value: "-11.5683"; }
+ ListElement{ radius: "30"; angle: "240"; value: "-13.912"; }
+ ListElement{ radius: "30"; angle: "245"; value: "-15.9261"; }
+ ListElement{ radius: "30"; angle: "250"; value: "-17.5954"; }
+ ListElement{ radius: "30"; angle: "255"; value: "-18.907"; }
+ ListElement{ radius: "30"; angle: "260"; value: "-19.8511"; }
+ ListElement{ radius: "30"; angle: "265"; value: "-20.4205"; }
+ ListElement{ radius: "30"; angle: "270"; value: "-20.6107"; }
+ ListElement{ radius: "30"; angle: "275"; value: "-20.4205"; }
+ ListElement{ radius: "30"; angle: "280"; value: "-19.8511"; }
+ ListElement{ radius: "30"; angle: "285"; value: "-18.907"; }
+ ListElement{ radius: "30"; angle: "290"; value: "-17.5954"; }
+ ListElement{ radius: "30"; angle: "295"; value: "-15.9261"; }
+ ListElement{ radius: "30"; angle: "300"; value: "-13.912"; }
+ ListElement{ radius: "30"; angle: "305"; value: "-11.5683"; }
+ ListElement{ radius: "30"; angle: "310"; value: "-8.91296"; }
+ ListElement{ radius: "30"; angle: "315"; value: "-5.96608"; }
+ ListElement{ radius: "30"; angle: "320"; value: "-2.75012"; }
+ ListElement{ radius: "30"; angle: "325"; value: "0.710441"; }
+ ListElement{ radius: "30"; angle: "330"; value: "4.38926"; }
+ ListElement{ radius: "30"; angle: "335"; value: "8.25835"; }
+ ListElement{ radius: "30"; angle: "340"; value: "12.2883"; }
+ ListElement{ radius: "30"; angle: "345"; value: "16.4483"; }
+ ListElement{ radius: "30"; angle: "350"; value: "20.7069"; }
+ ListElement{ radius: "30"; angle: "355"; value: "25.0315"; }
+ ListElement{ radius: "30"; angle: "360"; value: "29.3893"; }
+ ListElement{ radius: "35"; angle: "0"; value: "22.6995"; }
+ ListElement{ radius: "35"; angle: "5"; value: "27.0573"; }
+ ListElement{ radius: "35"; angle: "10"; value: "31.3819"; }
+ ListElement{ radius: "35"; angle: "15"; value: "35.6405"; }
+ ListElement{ radius: "35"; angle: "20"; value: "39.8005"; }
+ ListElement{ radius: "35"; angle: "25"; value: "43.8304"; }
+ ListElement{ radius: "35"; angle: "30"; value: "47.6995"; }
+ ListElement{ radius: "35"; angle: "35"; value: "51.3783"; }
+ ListElement{ radius: "35"; angle: "40"; value: "54.8389"; }
+ ListElement{ radius: "35"; angle: "45"; value: "58.0549"; }
+ ListElement{ radius: "35"; angle: "50"; value: "61.0017"; }
+ ListElement{ radius: "35"; angle: "55"; value: "63.6571"; }
+ ListElement{ radius: "35"; angle: "60"; value: "66.0008"; }
+ ListElement{ radius: "35"; angle: "65"; value: "68.0149"; }
+ ListElement{ radius: "35"; angle: "70"; value: "69.6842"; }
+ ListElement{ radius: "35"; angle: "75"; value: "70.9958"; }
+ ListElement{ radius: "35"; angle: "80"; value: "71.9399"; }
+ ListElement{ radius: "35"; angle: "85"; value: "72.5093"; }
+ ListElement{ radius: "35"; angle: "90"; value: "72.6995"; }
+ ListElement{ radius: "35"; angle: "95"; value: "72.5093"; }
+ ListElement{ radius: "35"; angle: "100"; value: "71.9399"; }
+ ListElement{ radius: "35"; angle: "105"; value: "70.9958"; }
+ ListElement{ radius: "35"; angle: "110"; value: "69.6842"; }
+ ListElement{ radius: "35"; angle: "115"; value: "68.0149"; }
+ ListElement{ radius: "35"; angle: "120"; value: "66.0008"; }
+ ListElement{ radius: "35"; angle: "125"; value: "63.6571"; }
+ ListElement{ radius: "35"; angle: "130"; value: "61.0017"; }
+ ListElement{ radius: "35"; angle: "135"; value: "58.0549"; }
+ ListElement{ radius: "35"; angle: "140"; value: "54.8389"; }
+ ListElement{ radius: "35"; angle: "145"; value: "51.3783"; }
+ ListElement{ radius: "35"; angle: "150"; value: "47.6995"; }
+ ListElement{ radius: "35"; angle: "155"; value: "43.8304"; }
+ ListElement{ radius: "35"; angle: "160"; value: "39.8005"; }
+ ListElement{ radius: "35"; angle: "165"; value: "35.6405"; }
+ ListElement{ radius: "35"; angle: "170"; value: "31.3819"; }
+ ListElement{ radius: "35"; angle: "175"; value: "27.0573"; }
+ ListElement{ radius: "35"; angle: "180"; value: "22.6995"; }
+ ListElement{ radius: "35"; angle: "185"; value: "18.3417"; }
+ ListElement{ radius: "35"; angle: "190"; value: "14.0171"; }
+ ListElement{ radius: "35"; angle: "195"; value: "9.75857"; }
+ ListElement{ radius: "35"; angle: "200"; value: "5.59852"; }
+ ListElement{ radius: "35"; angle: "205"; value: "1.56861"; }
+ ListElement{ radius: "35"; angle: "210"; value: "-2.30048"; }
+ ListElement{ radius: "35"; angle: "215"; value: "-5.9793"; }
+ ListElement{ radius: "35"; angle: "220"; value: "-9.43986"; }
+ ListElement{ radius: "35"; angle: "225"; value: "-12.6558"; }
+ ListElement{ radius: "35"; angle: "230"; value: "-15.6027"; }
+ ListElement{ radius: "35"; angle: "235"; value: "-18.2581"; }
+ ListElement{ radius: "35"; angle: "240"; value: "-20.6017"; }
+ ListElement{ radius: "35"; angle: "245"; value: "-22.6159"; }
+ ListElement{ radius: "35"; angle: "250"; value: "-24.2851"; }
+ ListElement{ radius: "35"; angle: "255"; value: "-25.5968"; }
+ ListElement{ radius: "35"; angle: "260"; value: "-26.5409"; }
+ ListElement{ radius: "35"; angle: "265"; value: "-27.1102"; }
+ ListElement{ radius: "35"; angle: "270"; value: "-27.3005"; }
+ ListElement{ radius: "35"; angle: "275"; value: "-27.1102"; }
+ ListElement{ radius: "35"; angle: "280"; value: "-26.5409"; }
+ ListElement{ radius: "35"; angle: "285"; value: "-25.5968"; }
+ ListElement{ radius: "35"; angle: "290"; value: "-24.2851"; }
+ ListElement{ radius: "35"; angle: "295"; value: "-22.6159"; }
+ ListElement{ radius: "35"; angle: "300"; value: "-20.6017"; }
+ ListElement{ radius: "35"; angle: "305"; value: "-18.2581"; }
+ ListElement{ radius: "35"; angle: "310"; value: "-15.6027"; }
+ ListElement{ radius: "35"; angle: "315"; value: "-12.6558"; }
+ ListElement{ radius: "35"; angle: "320"; value: "-9.43986"; }
+ ListElement{ radius: "35"; angle: "325"; value: "-5.9793"; }
+ ListElement{ radius: "35"; angle: "330"; value: "-2.30048"; }
+ ListElement{ radius: "35"; angle: "335"; value: "1.56861"; }
+ ListElement{ radius: "35"; angle: "340"; value: "5.59852"; }
+ ListElement{ radius: "35"; angle: "345"; value: "9.75857"; }
+ ListElement{ radius: "35"; angle: "350"; value: "14.0171"; }
+ ListElement{ radius: "35"; angle: "355"; value: "18.3417"; }
+ ListElement{ radius: "35"; angle: "360"; value: "22.6995"; }
+ ListElement{ radius: "40"; angle: "0"; value: "15.4508"; }
+ ListElement{ radius: "40"; angle: "5"; value: "19.8086"; }
+ ListElement{ radius: "40"; angle: "10"; value: "24.1333"; }
+ ListElement{ radius: "40"; angle: "15"; value: "28.3918"; }
+ ListElement{ radius: "40"; angle: "20"; value: "32.5519"; }
+ ListElement{ radius: "40"; angle: "25"; value: "36.5818"; }
+ ListElement{ radius: "40"; angle: "30"; value: "40.4508"; }
+ ListElement{ radius: "40"; angle: "35"; value: "44.1297"; }
+ ListElement{ radius: "40"; angle: "40"; value: "47.5902"; }
+ ListElement{ radius: "40"; angle: "45"; value: "50.8062"; }
+ ListElement{ radius: "40"; angle: "50"; value: "53.7531"; }
+ ListElement{ radius: "40"; angle: "55"; value: "56.4085"; }
+ ListElement{ radius: "40"; angle: "60"; value: "58.7521"; }
+ ListElement{ radius: "40"; angle: "65"; value: "60.7662"; }
+ ListElement{ radius: "40"; angle: "70"; value: "62.4355"; }
+ ListElement{ radius: "40"; angle: "75"; value: "63.7471"; }
+ ListElement{ radius: "40"; angle: "80"; value: "64.6912"; }
+ ListElement{ radius: "40"; angle: "85"; value: "65.2606"; }
+ ListElement{ radius: "40"; angle: "90"; value: "65.4508"; }
+ ListElement{ radius: "40"; angle: "95"; value: "65.2606"; }
+ ListElement{ radius: "40"; angle: "100"; value: "64.6912"; }
+ ListElement{ radius: "40"; angle: "105"; value: "63.7471"; }
+ ListElement{ radius: "40"; angle: "110"; value: "62.4355"; }
+ ListElement{ radius: "40"; angle: "115"; value: "60.7662"; }
+ ListElement{ radius: "40"; angle: "120"; value: "58.7521"; }
+ ListElement{ radius: "40"; angle: "125"; value: "56.4085"; }
+ ListElement{ radius: "40"; angle: "130"; value: "53.7531"; }
+ ListElement{ radius: "40"; angle: "135"; value: "50.8062"; }
+ ListElement{ radius: "40"; angle: "140"; value: "47.5902"; }
+ ListElement{ radius: "40"; angle: "145"; value: "44.1297"; }
+ ListElement{ radius: "40"; angle: "150"; value: "40.4508"; }
+ ListElement{ radius: "40"; angle: "155"; value: "36.5818"; }
+ ListElement{ radius: "40"; angle: "160"; value: "32.5519"; }
+ ListElement{ radius: "40"; angle: "165"; value: "28.3918"; }
+ ListElement{ radius: "40"; angle: "170"; value: "24.1333"; }
+ ListElement{ radius: "40"; angle: "175"; value: "19.8086"; }
+ ListElement{ radius: "40"; angle: "180"; value: "15.4508"; }
+ ListElement{ radius: "40"; angle: "185"; value: "11.0931"; }
+ ListElement{ radius: "40"; angle: "190"; value: "6.76844"; }
+ ListElement{ radius: "40"; angle: "195"; value: "2.5099"; }
+ ListElement{ radius: "40"; angle: "200"; value: "-1.65016"; }
+ ListElement{ radius: "40"; angle: "205"; value: "-5.68006"; }
+ ListElement{ radius: "40"; angle: "210"; value: "-9.54915"; }
+ ListElement{ radius: "40"; angle: "215"; value: "-13.228"; }
+ ListElement{ radius: "40"; angle: "220"; value: "-16.6885"; }
+ ListElement{ radius: "40"; angle: "225"; value: "-19.9045"; }
+ ListElement{ radius: "40"; angle: "230"; value: "-22.8514"; }
+ ListElement{ radius: "40"; angle: "235"; value: "-25.5068"; }
+ ListElement{ radius: "40"; angle: "240"; value: "-27.8504"; }
+ ListElement{ radius: "40"; angle: "245"; value: "-29.8645"; }
+ ListElement{ radius: "40"; angle: "250"; value: "-31.5338"; }
+ ListElement{ radius: "40"; angle: "255"; value: "-32.8454"; }
+ ListElement{ radius: "40"; angle: "260"; value: "-33.7895"; }
+ ListElement{ radius: "40"; angle: "265"; value: "-34.3589"; }
+ ListElement{ radius: "40"; angle: "270"; value: "-34.5492"; }
+ ListElement{ radius: "40"; angle: "275"; value: "-34.3589"; }
+ ListElement{ radius: "40"; angle: "280"; value: "-33.7895"; }
+ ListElement{ radius: "40"; angle: "285"; value: "-32.8454"; }
+ ListElement{ radius: "40"; angle: "290"; value: "-31.5338"; }
+ ListElement{ radius: "40"; angle: "295"; value: "-29.8645"; }
+ ListElement{ radius: "40"; angle: "300"; value: "-27.8504"; }
+ ListElement{ radius: "40"; angle: "305"; value: "-25.5068"; }
+ ListElement{ radius: "40"; angle: "310"; value: "-22.8514"; }
+ ListElement{ radius: "40"; angle: "315"; value: "-19.9045"; }
+ ListElement{ radius: "40"; angle: "320"; value: "-16.6885"; }
+ ListElement{ radius: "40"; angle: "325"; value: "-13.228"; }
+ ListElement{ radius: "40"; angle: "330"; value: "-9.54915"; }
+ ListElement{ radius: "40"; angle: "335"; value: "-5.68006"; }
+ ListElement{ radius: "40"; angle: "340"; value: "-1.65016"; }
+ ListElement{ radius: "40"; angle: "345"; value: "2.5099"; }
+ ListElement{ radius: "40"; angle: "350"; value: "6.76844"; }
+ ListElement{ radius: "40"; angle: "355"; value: "11.0931"; }
+ ListElement{ radius: "40"; angle: "360"; value: "15.4508"; }
+ ListElement{ radius: "45"; angle: "0"; value: "7.82172"; }
+ ListElement{ radius: "45"; angle: "5"; value: "12.1795"; }
+ ListElement{ radius: "45"; angle: "10"; value: "16.5041"; }
+ ListElement{ radius: "45"; angle: "15"; value: "20.7627"; }
+ ListElement{ radius: "45"; angle: "20"; value: "24.9227"; }
+ ListElement{ radius: "45"; angle: "25"; value: "28.9526"; }
+ ListElement{ radius: "45"; angle: "30"; value: "32.8217"; }
+ ListElement{ radius: "45"; angle: "35"; value: "36.5005"; }
+ ListElement{ radius: "45"; angle: "40"; value: "39.9611"; }
+ ListElement{ radius: "45"; angle: "45"; value: "43.1771"; }
+ ListElement{ radius: "45"; angle: "50"; value: "46.1239"; }
+ ListElement{ radius: "45"; angle: "55"; value: "48.7793"; }
+ ListElement{ radius: "45"; angle: "60"; value: "51.123"; }
+ ListElement{ radius: "45"; angle: "65"; value: "53.1371"; }
+ ListElement{ radius: "45"; angle: "70"; value: "54.8064"; }
+ ListElement{ radius: "45"; angle: "75"; value: "56.118"; }
+ ListElement{ radius: "45"; angle: "80"; value: "57.0621"; }
+ ListElement{ radius: "45"; angle: "85"; value: "57.6315"; }
+ ListElement{ radius: "45"; angle: "90"; value: "57.8217"; }
+ ListElement{ radius: "45"; angle: "95"; value: "57.6315"; }
+ ListElement{ radius: "45"; angle: "100"; value: "57.0621"; }
+ ListElement{ radius: "45"; angle: "105"; value: "56.118"; }
+ ListElement{ radius: "45"; angle: "110"; value: "54.8064"; }
+ ListElement{ radius: "45"; angle: "115"; value: "53.1371"; }
+ ListElement{ radius: "45"; angle: "120"; value: "51.123"; }
+ ListElement{ radius: "45"; angle: "125"; value: "48.7793"; }
+ ListElement{ radius: "45"; angle: "130"; value: "46.1239"; }
+ ListElement{ radius: "45"; angle: "135"; value: "43.1771"; }
+ ListElement{ radius: "45"; angle: "140"; value: "39.9611"; }
+ ListElement{ radius: "45"; angle: "145"; value: "36.5005"; }
+ ListElement{ radius: "45"; angle: "150"; value: "32.8217"; }
+ ListElement{ radius: "45"; angle: "155"; value: "28.9526"; }
+ ListElement{ radius: "45"; angle: "160"; value: "24.9227"; }
+ ListElement{ radius: "45"; angle: "165"; value: "20.7627"; }
+ ListElement{ radius: "45"; angle: "170"; value: "16.5041"; }
+ ListElement{ radius: "45"; angle: "175"; value: "12.1795"; }
+ ListElement{ radius: "45"; angle: "180"; value: "7.82172"; }
+ ListElement{ radius: "45"; angle: "185"; value: "3.46394"; }
+ ListElement{ radius: "45"; angle: "190"; value: "-0.860686"; }
+ ListElement{ radius: "45"; angle: "195"; value: "-5.11923"; }
+ ListElement{ radius: "45"; angle: "200"; value: "-9.27928"; }
+ ListElement{ radius: "45"; angle: "205"; value: "-13.3092"; }
+ ListElement{ radius: "45"; angle: "210"; value: "-17.1783"; }
+ ListElement{ radius: "45"; angle: "215"; value: "-20.8571"; }
+ ListElement{ radius: "45"; angle: "220"; value: "-24.3177"; }
+ ListElement{ radius: "45"; angle: "225"; value: "-27.5336"; }
+ ListElement{ radius: "45"; angle: "230"; value: "-30.4805"; }
+ ListElement{ radius: "45"; angle: "235"; value: "-33.1359"; }
+ ListElement{ radius: "45"; angle: "240"; value: "-35.4795"; }
+ ListElement{ radius: "45"; angle: "245"; value: "-37.4937"; }
+ ListElement{ radius: "45"; angle: "250"; value: "-39.1629"; }
+ ListElement{ radius: "45"; angle: "255"; value: "-40.4746"; }
+ ListElement{ radius: "45"; angle: "260"; value: "-41.4187"; }
+ ListElement{ radius: "45"; angle: "265"; value: "-41.988"; }
+ ListElement{ radius: "45"; angle: "270"; value: "-42.1783"; }
+ ListElement{ radius: "45"; angle: "275"; value: "-41.988"; }
+ ListElement{ radius: "45"; angle: "280"; value: "-41.4187"; }
+ ListElement{ radius: "45"; angle: "285"; value: "-40.4746"; }
+ ListElement{ radius: "45"; angle: "290"; value: "-39.1629"; }
+ ListElement{ radius: "45"; angle: "295"; value: "-37.4937"; }
+ ListElement{ radius: "45"; angle: "300"; value: "-35.4795"; }
+ ListElement{ radius: "45"; angle: "305"; value: "-33.1359"; }
+ ListElement{ radius: "45"; angle: "310"; value: "-30.4805"; }
+ ListElement{ radius: "45"; angle: "315"; value: "-27.5336"; }
+ ListElement{ radius: "45"; angle: "320"; value: "-24.3177"; }
+ ListElement{ radius: "45"; angle: "325"; value: "-20.8571"; }
+ ListElement{ radius: "45"; angle: "330"; value: "-17.1783"; }
+ ListElement{ radius: "45"; angle: "335"; value: "-13.3092"; }
+ ListElement{ radius: "45"; angle: "340"; value: "-9.27928"; }
+ ListElement{ radius: "45"; angle: "345"; value: "-5.11923"; }
+ ListElement{ radius: "45"; angle: "350"; value: "-0.860686"; }
+ ListElement{ radius: "45"; angle: "355"; value: "3.46394"; }
+ ListElement{ radius: "45"; angle: "360"; value: "7.82172"; }
+ ListElement{ radius: "50"; angle: "0"; value: "3.06162e-15"; }
+ ListElement{ radius: "50"; angle: "5"; value: "4.35779"; }
+ ListElement{ radius: "50"; angle: "10"; value: "8.68241"; }
+ ListElement{ radius: "50"; angle: "15"; value: "12.941"; }
+ ListElement{ radius: "50"; angle: "20"; value: "17.101"; }
+ ListElement{ radius: "50"; angle: "25"; value: "21.1309"; }
+ ListElement{ radius: "50"; angle: "30"; value: "25"; }
+ ListElement{ radius: "50"; angle: "35"; value: "28.6788"; }
+ ListElement{ radius: "50"; angle: "40"; value: "32.1394"; }
+ ListElement{ radius: "50"; angle: "45"; value: "35.3553"; }
+ ListElement{ radius: "50"; angle: "50"; value: "38.3022"; }
+ ListElement{ radius: "50"; angle: "55"; value: "40.9576"; }
+ ListElement{ radius: "50"; angle: "60"; value: "43.3013"; }
+ ListElement{ radius: "50"; angle: "65"; value: "45.3154"; }
+ ListElement{ radius: "50"; angle: "70"; value: "46.9846"; }
+ ListElement{ radius: "50"; angle: "75"; value: "48.2963"; }
+ ListElement{ radius: "50"; angle: "80"; value: "49.2404"; }
+ ListElement{ radius: "50"; angle: "85"; value: "49.8097"; }
+ ListElement{ radius: "50"; angle: "90"; value: "50"; }
+ ListElement{ radius: "50"; angle: "95"; value: "49.8097"; }
+ ListElement{ radius: "50"; angle: "100"; value: "49.2404"; }
+ ListElement{ radius: "50"; angle: "105"; value: "48.2963"; }
+ ListElement{ radius: "50"; angle: "110"; value: "46.9846"; }
+ ListElement{ radius: "50"; angle: "115"; value: "45.3154"; }
+ ListElement{ radius: "50"; angle: "120"; value: "43.3013"; }
+ ListElement{ radius: "50"; angle: "125"; value: "40.9576"; }
+ ListElement{ radius: "50"; angle: "130"; value: "38.3022"; }
+ ListElement{ radius: "50"; angle: "135"; value: "35.3553"; }
+ ListElement{ radius: "50"; angle: "140"; value: "32.1394"; }
+ ListElement{ radius: "50"; angle: "145"; value: "28.6788"; }
+ ListElement{ radius: "50"; angle: "150"; value: "25"; }
+ ListElement{ radius: "50"; angle: "155"; value: "21.1309"; }
+ ListElement{ radius: "50"; angle: "160"; value: "17.101"; }
+ ListElement{ radius: "50"; angle: "165"; value: "12.941"; }
+ ListElement{ radius: "50"; angle: "170"; value: "8.68241"; }
+ ListElement{ radius: "50"; angle: "175"; value: "4.35779"; }
+ ListElement{ radius: "50"; angle: "180"; value: "9.18485e-15"; }
+ ListElement{ radius: "50"; angle: "185"; value: "-4.35779"; }
+ ListElement{ radius: "50"; angle: "190"; value: "-8.68241"; }
+ ListElement{ radius: "50"; angle: "195"; value: "-12.941"; }
+ ListElement{ radius: "50"; angle: "200"; value: "-17.101"; }
+ ListElement{ radius: "50"; angle: "205"; value: "-21.1309"; }
+ ListElement{ radius: "50"; angle: "210"; value: "-25"; }
+ ListElement{ radius: "50"; angle: "215"; value: "-28.6788"; }
+ ListElement{ radius: "50"; angle: "220"; value: "-32.1394"; }
+ ListElement{ radius: "50"; angle: "225"; value: "-35.3553"; }
+ ListElement{ radius: "50"; angle: "230"; value: "-38.3022"; }
+ ListElement{ radius: "50"; angle: "235"; value: "-40.9576"; }
+ ListElement{ radius: "50"; angle: "240"; value: "-43.3013"; }
+ ListElement{ radius: "50"; angle: "245"; value: "-45.3154"; }
+ ListElement{ radius: "50"; angle: "250"; value: "-46.9846"; }
+ ListElement{ radius: "50"; angle: "255"; value: "-48.2963"; }
+ ListElement{ radius: "50"; angle: "260"; value: "-49.2404"; }
+ ListElement{ radius: "50"; angle: "265"; value: "-49.8097"; }
+ ListElement{ radius: "50"; angle: "270"; value: "-50"; }
+ ListElement{ radius: "50"; angle: "275"; value: "-49.8097"; }
+ ListElement{ radius: "50"; angle: "280"; value: "-49.2404"; }
+ ListElement{ radius: "50"; angle: "285"; value: "-48.2963"; }
+ ListElement{ radius: "50"; angle: "290"; value: "-46.9846"; }
+ ListElement{ radius: "50"; angle: "295"; value: "-45.3154"; }
+ ListElement{ radius: "50"; angle: "300"; value: "-43.3013"; }
+ ListElement{ radius: "50"; angle: "305"; value: "-40.9576"; }
+ ListElement{ radius: "50"; angle: "310"; value: "-38.3022"; }
+ ListElement{ radius: "50"; angle: "315"; value: "-35.3553"; }
+ ListElement{ radius: "50"; angle: "320"; value: "-32.1394"; }
+ ListElement{ radius: "50"; angle: "325"; value: "-28.6788"; }
+ ListElement{ radius: "50"; angle: "330"; value: "-25"; }
+ ListElement{ radius: "50"; angle: "335"; value: "-21.1309"; }
+ ListElement{ radius: "50"; angle: "340"; value: "-17.101"; }
+ ListElement{ radius: "50"; angle: "345"; value: "-12.941"; }
+ ListElement{ radius: "50"; angle: "350"; value: "-8.68241"; }
+ ListElement{ radius: "50"; angle: "355"; value: "-4.35779"; }
+ ListElement{ radius: "50"; angle: "360"; value: "-9.18485e-15"; }
+ ListElement{ radius: "55"; angle: "0"; value: "-7.82172"; }
+ ListElement{ radius: "55"; angle: "5"; value: "-3.46394"; }
+ ListElement{ radius: "55"; angle: "10"; value: "0.860686"; }
+ ListElement{ radius: "55"; angle: "15"; value: "5.11923"; }
+ ListElement{ radius: "55"; angle: "20"; value: "9.27928"; }
+ ListElement{ radius: "55"; angle: "25"; value: "13.3092"; }
+ ListElement{ radius: "55"; angle: "30"; value: "17.1783"; }
+ ListElement{ radius: "55"; angle: "35"; value: "20.8571"; }
+ ListElement{ radius: "55"; angle: "40"; value: "24.3177"; }
+ ListElement{ radius: "55"; angle: "45"; value: "27.5336"; }
+ ListElement{ radius: "55"; angle: "50"; value: "30.4805"; }
+ ListElement{ radius: "55"; angle: "55"; value: "33.1359"; }
+ ListElement{ radius: "55"; angle: "60"; value: "35.4795"; }
+ ListElement{ radius: "55"; angle: "65"; value: "37.4937"; }
+ ListElement{ radius: "55"; angle: "70"; value: "39.1629"; }
+ ListElement{ radius: "55"; angle: "75"; value: "40.4746"; }
+ ListElement{ radius: "55"; angle: "80"; value: "41.4187"; }
+ ListElement{ radius: "55"; angle: "85"; value: "41.988"; }
+ ListElement{ radius: "55"; angle: "90"; value: "42.1783"; }
+ ListElement{ radius: "55"; angle: "95"; value: "41.988"; }
+ ListElement{ radius: "55"; angle: "100"; value: "41.4187"; }
+ ListElement{ radius: "55"; angle: "105"; value: "40.4746"; }
+ ListElement{ radius: "55"; angle: "110"; value: "39.1629"; }
+ ListElement{ radius: "55"; angle: "115"; value: "37.4937"; }
+ ListElement{ radius: "55"; angle: "120"; value: "35.4795"; }
+ ListElement{ radius: "55"; angle: "125"; value: "33.1359"; }
+ ListElement{ radius: "55"; angle: "130"; value: "30.4805"; }
+ ListElement{ radius: "55"; angle: "135"; value: "27.5336"; }
+ ListElement{ radius: "55"; angle: "140"; value: "24.3177"; }
+ ListElement{ radius: "55"; angle: "145"; value: "20.8571"; }
+ ListElement{ radius: "55"; angle: "150"; value: "17.1783"; }
+ ListElement{ radius: "55"; angle: "155"; value: "13.3092"; }
+ ListElement{ radius: "55"; angle: "160"; value: "9.27928"; }
+ ListElement{ radius: "55"; angle: "165"; value: "5.11923"; }
+ ListElement{ radius: "55"; angle: "170"; value: "0.860686"; }
+ ListElement{ radius: "55"; angle: "175"; value: "-3.46394"; }
+ ListElement{ radius: "55"; angle: "180"; value: "-7.82172"; }
+ ListElement{ radius: "55"; angle: "185"; value: "-12.1795"; }
+ ListElement{ radius: "55"; angle: "190"; value: "-16.5041"; }
+ ListElement{ radius: "55"; angle: "195"; value: "-20.7627"; }
+ ListElement{ radius: "55"; angle: "200"; value: "-24.9227"; }
+ ListElement{ radius: "55"; angle: "205"; value: "-28.9526"; }
+ ListElement{ radius: "55"; angle: "210"; value: "-32.8217"; }
+ ListElement{ radius: "55"; angle: "215"; value: "-36.5005"; }
+ ListElement{ radius: "55"; angle: "220"; value: "-39.9611"; }
+ ListElement{ radius: "55"; angle: "225"; value: "-43.1771"; }
+ ListElement{ radius: "55"; angle: "230"; value: "-46.1239"; }
+ ListElement{ radius: "55"; angle: "235"; value: "-48.7793"; }
+ ListElement{ radius: "55"; angle: "240"; value: "-51.123"; }
+ ListElement{ radius: "55"; angle: "245"; value: "-53.1371"; }
+ ListElement{ radius: "55"; angle: "250"; value: "-54.8064"; }
+ ListElement{ radius: "55"; angle: "255"; value: "-56.118"; }
+ ListElement{ radius: "55"; angle: "260"; value: "-57.0621"; }
+ ListElement{ radius: "55"; angle: "265"; value: "-57.6315"; }
+ ListElement{ radius: "55"; angle: "270"; value: "-57.8217"; }
+ ListElement{ radius: "55"; angle: "275"; value: "-57.6315"; }
+ ListElement{ radius: "55"; angle: "280"; value: "-57.0621"; }
+ ListElement{ radius: "55"; angle: "285"; value: "-56.118"; }
+ ListElement{ radius: "55"; angle: "290"; value: "-54.8064"; }
+ ListElement{ radius: "55"; angle: "295"; value: "-53.1371"; }
+ ListElement{ radius: "55"; angle: "300"; value: "-51.123"; }
+ ListElement{ radius: "55"; angle: "305"; value: "-48.7793"; }
+ ListElement{ radius: "55"; angle: "310"; value: "-46.1239"; }
+ ListElement{ radius: "55"; angle: "315"; value: "-43.1771"; }
+ ListElement{ radius: "55"; angle: "320"; value: "-39.9611"; }
+ ListElement{ radius: "55"; angle: "325"; value: "-36.5005"; }
+ ListElement{ radius: "55"; angle: "330"; value: "-32.8217"; }
+ ListElement{ radius: "55"; angle: "335"; value: "-28.9526"; }
+ ListElement{ radius: "55"; angle: "340"; value: "-24.9227"; }
+ ListElement{ radius: "55"; angle: "345"; value: "-20.7627"; }
+ ListElement{ radius: "55"; angle: "350"; value: "-16.5041"; }
+ ListElement{ radius: "55"; angle: "355"; value: "-12.1795"; }
+ ListElement{ radius: "55"; angle: "360"; value: "-7.82172"; }
+ ListElement{ radius: "60"; angle: "0"; value: "-15.4508"; }
+ ListElement{ radius: "60"; angle: "5"; value: "-11.0931"; }
+ ListElement{ radius: "60"; angle: "10"; value: "-6.76844"; }
+ ListElement{ radius: "60"; angle: "15"; value: "-2.5099"; }
+ ListElement{ radius: "60"; angle: "20"; value: "1.65016"; }
+ ListElement{ radius: "60"; angle: "25"; value: "5.68006"; }
+ ListElement{ radius: "60"; angle: "30"; value: "9.54915"; }
+ ListElement{ radius: "60"; angle: "35"; value: "13.228"; }
+ ListElement{ radius: "60"; angle: "40"; value: "16.6885"; }
+ ListElement{ radius: "60"; angle: "45"; value: "19.9045"; }
+ ListElement{ radius: "60"; angle: "50"; value: "22.8514"; }
+ ListElement{ radius: "60"; angle: "55"; value: "25.5068"; }
+ ListElement{ radius: "60"; angle: "60"; value: "27.8504"; }
+ ListElement{ radius: "60"; angle: "65"; value: "29.8645"; }
+ ListElement{ radius: "60"; angle: "70"; value: "31.5338"; }
+ ListElement{ radius: "60"; angle: "75"; value: "32.8454"; }
+ ListElement{ radius: "60"; angle: "80"; value: "33.7895"; }
+ ListElement{ radius: "60"; angle: "85"; value: "34.3589"; }
+ ListElement{ radius: "60"; angle: "90"; value: "34.5492"; }
+ ListElement{ radius: "60"; angle: "95"; value: "34.3589"; }
+ ListElement{ radius: "60"; angle: "100"; value: "33.7895"; }
+ ListElement{ radius: "60"; angle: "105"; value: "32.8454"; }
+ ListElement{ radius: "60"; angle: "110"; value: "31.5338"; }
+ ListElement{ radius: "60"; angle: "115"; value: "29.8645"; }
+ ListElement{ radius: "60"; angle: "120"; value: "27.8504"; }
+ ListElement{ radius: "60"; angle: "125"; value: "25.5068"; }
+ ListElement{ radius: "60"; angle: "130"; value: "22.8514"; }
+ ListElement{ radius: "60"; angle: "135"; value: "19.9045"; }
+ ListElement{ radius: "60"; angle: "140"; value: "16.6885"; }
+ ListElement{ radius: "60"; angle: "145"; value: "13.228"; }
+ ListElement{ radius: "60"; angle: "150"; value: "9.54915"; }
+ ListElement{ radius: "60"; angle: "155"; value: "5.68006"; }
+ ListElement{ radius: "60"; angle: "160"; value: "1.65016"; }
+ ListElement{ radius: "60"; angle: "165"; value: "-2.5099"; }
+ ListElement{ radius: "60"; angle: "170"; value: "-6.76844"; }
+ ListElement{ radius: "60"; angle: "175"; value: "-11.0931"; }
+ ListElement{ radius: "60"; angle: "180"; value: "-15.4508"; }
+ ListElement{ radius: "60"; angle: "185"; value: "-19.8086"; }
+ ListElement{ radius: "60"; angle: "190"; value: "-24.1333"; }
+ ListElement{ radius: "60"; angle: "195"; value: "-28.3918"; }
+ ListElement{ radius: "60"; angle: "200"; value: "-32.5519"; }
+ ListElement{ radius: "60"; angle: "205"; value: "-36.5818"; }
+ ListElement{ radius: "60"; angle: "210"; value: "-40.4508"; }
+ ListElement{ radius: "60"; angle: "215"; value: "-44.1297"; }
+ ListElement{ radius: "60"; angle: "220"; value: "-47.5902"; }
+ ListElement{ radius: "60"; angle: "225"; value: "-50.8062"; }
+ ListElement{ radius: "60"; angle: "230"; value: "-53.7531"; }
+ ListElement{ radius: "60"; angle: "235"; value: "-56.4085"; }
+ ListElement{ radius: "60"; angle: "240"; value: "-58.7521"; }
+ ListElement{ radius: "60"; angle: "245"; value: "-60.7662"; }
+ ListElement{ radius: "60"; angle: "250"; value: "-62.4355"; }
+ ListElement{ radius: "60"; angle: "255"; value: "-63.7471"; }
+ ListElement{ radius: "60"; angle: "260"; value: "-64.6912"; }
+ ListElement{ radius: "60"; angle: "265"; value: "-65.2606"; }
+ ListElement{ radius: "60"; angle: "270"; value: "-65.4508"; }
+ ListElement{ radius: "60"; angle: "275"; value: "-65.2606"; }
+ ListElement{ radius: "60"; angle: "280"; value: "-64.6912"; }
+ ListElement{ radius: "60"; angle: "285"; value: "-63.7471"; }
+ ListElement{ radius: "60"; angle: "290"; value: "-62.4355"; }
+ ListElement{ radius: "60"; angle: "295"; value: "-60.7662"; }
+ ListElement{ radius: "60"; angle: "300"; value: "-58.7521"; }
+ ListElement{ radius: "60"; angle: "305"; value: "-56.4085"; }
+ ListElement{ radius: "60"; angle: "310"; value: "-53.7531"; }
+ ListElement{ radius: "60"; angle: "315"; value: "-50.8062"; }
+ ListElement{ radius: "60"; angle: "320"; value: "-47.5902"; }
+ ListElement{ radius: "60"; angle: "325"; value: "-44.1297"; }
+ ListElement{ radius: "60"; angle: "330"; value: "-40.4508"; }
+ ListElement{ radius: "60"; angle: "335"; value: "-36.5818"; }
+ ListElement{ radius: "60"; angle: "340"; value: "-32.5519"; }
+ ListElement{ radius: "60"; angle: "345"; value: "-28.3918"; }
+ ListElement{ radius: "60"; angle: "350"; value: "-24.1333"; }
+ ListElement{ radius: "60"; angle: "355"; value: "-19.8086"; }
+ ListElement{ radius: "60"; angle: "360"; value: "-15.4508"; }
+ ListElement{ radius: "65"; angle: "0"; value: "-22.6995"; }
+ ListElement{ radius: "65"; angle: "5"; value: "-18.3417"; }
+ ListElement{ radius: "65"; angle: "10"; value: "-14.0171"; }
+ ListElement{ radius: "65"; angle: "15"; value: "-9.75857"; }
+ ListElement{ radius: "65"; angle: "20"; value: "-5.59852"; }
+ ListElement{ radius: "65"; angle: "25"; value: "-1.56861"; }
+ ListElement{ radius: "65"; angle: "30"; value: "2.30048"; }
+ ListElement{ radius: "65"; angle: "35"; value: "5.9793"; }
+ ListElement{ radius: "65"; angle: "40"; value: "9.43986"; }
+ ListElement{ radius: "65"; angle: "45"; value: "12.6558"; }
+ ListElement{ radius: "65"; angle: "50"; value: "15.6027"; }
+ ListElement{ radius: "65"; angle: "55"; value: "18.2581"; }
+ ListElement{ radius: "65"; angle: "60"; value: "20.6017"; }
+ ListElement{ radius: "65"; angle: "65"; value: "22.6159"; }
+ ListElement{ radius: "65"; angle: "70"; value: "24.2851"; }
+ ListElement{ radius: "65"; angle: "75"; value: "25.5968"; }
+ ListElement{ radius: "65"; angle: "80"; value: "26.5409"; }
+ ListElement{ radius: "65"; angle: "85"; value: "27.1102"; }
+ ListElement{ radius: "65"; angle: "90"; value: "27.3005"; }
+ ListElement{ radius: "65"; angle: "95"; value: "27.1102"; }
+ ListElement{ radius: "65"; angle: "100"; value: "26.5409"; }
+ ListElement{ radius: "65"; angle: "105"; value: "25.5968"; }
+ ListElement{ radius: "65"; angle: "110"; value: "24.2851"; }
+ ListElement{ radius: "65"; angle: "115"; value: "22.6159"; }
+ ListElement{ radius: "65"; angle: "120"; value: "20.6017"; }
+ ListElement{ radius: "65"; angle: "125"; value: "18.2581"; }
+ ListElement{ radius: "65"; angle: "130"; value: "15.6027"; }
+ ListElement{ radius: "65"; angle: "135"; value: "12.6558"; }
+ ListElement{ radius: "65"; angle: "140"; value: "9.43986"; }
+ ListElement{ radius: "65"; angle: "145"; value: "5.9793"; }
+ ListElement{ radius: "65"; angle: "150"; value: "2.30048"; }
+ ListElement{ radius: "65"; angle: "155"; value: "-1.56861"; }
+ ListElement{ radius: "65"; angle: "160"; value: "-5.59852"; }
+ ListElement{ radius: "65"; angle: "165"; value: "-9.75857"; }
+ ListElement{ radius: "65"; angle: "170"; value: "-14.0171"; }
+ ListElement{ radius: "65"; angle: "175"; value: "-18.3417"; }
+ ListElement{ radius: "65"; angle: "180"; value: "-22.6995"; }
+ ListElement{ radius: "65"; angle: "185"; value: "-27.0573"; }
+ ListElement{ radius: "65"; angle: "190"; value: "-31.3819"; }
+ ListElement{ radius: "65"; angle: "195"; value: "-35.6405"; }
+ ListElement{ radius: "65"; angle: "200"; value: "-39.8005"; }
+ ListElement{ radius: "65"; angle: "205"; value: "-43.8304"; }
+ ListElement{ radius: "65"; angle: "210"; value: "-47.6995"; }
+ ListElement{ radius: "65"; angle: "215"; value: "-51.3783"; }
+ ListElement{ radius: "65"; angle: "220"; value: "-54.8389"; }
+ ListElement{ radius: "65"; angle: "225"; value: "-58.0549"; }
+ ListElement{ radius: "65"; angle: "230"; value: "-61.0017"; }
+ ListElement{ radius: "65"; angle: "235"; value: "-63.6571"; }
+ ListElement{ radius: "65"; angle: "240"; value: "-66.0008"; }
+ ListElement{ radius: "65"; angle: "245"; value: "-68.0149"; }
+ ListElement{ radius: "65"; angle: "250"; value: "-69.6842"; }
+ ListElement{ radius: "65"; angle: "255"; value: "-70.9958"; }
+ ListElement{ radius: "65"; angle: "260"; value: "-71.9399"; }
+ ListElement{ radius: "65"; angle: "265"; value: "-72.5093"; }
+ ListElement{ radius: "65"; angle: "270"; value: "-72.6995"; }
+ ListElement{ radius: "65"; angle: "275"; value: "-72.5093"; }
+ ListElement{ radius: "65"; angle: "280"; value: "-71.9399"; }
+ ListElement{ radius: "65"; angle: "285"; value: "-70.9958"; }
+ ListElement{ radius: "65"; angle: "290"; value: "-69.6842"; }
+ ListElement{ radius: "65"; angle: "295"; value: "-68.0149"; }
+ ListElement{ radius: "65"; angle: "300"; value: "-66.0008"; }
+ ListElement{ radius: "65"; angle: "305"; value: "-63.6571"; }
+ ListElement{ radius: "65"; angle: "310"; value: "-61.0017"; }
+ ListElement{ radius: "65"; angle: "315"; value: "-58.0549"; }
+ ListElement{ radius: "65"; angle: "320"; value: "-54.8389"; }
+ ListElement{ radius: "65"; angle: "325"; value: "-51.3783"; }
+ ListElement{ radius: "65"; angle: "330"; value: "-47.6995"; }
+ ListElement{ radius: "65"; angle: "335"; value: "-43.8304"; }
+ ListElement{ radius: "65"; angle: "340"; value: "-39.8005"; }
+ ListElement{ radius: "65"; angle: "345"; value: "-35.6405"; }
+ ListElement{ radius: "65"; angle: "350"; value: "-31.3819"; }
+ ListElement{ radius: "65"; angle: "355"; value: "-27.0573"; }
+ ListElement{ radius: "65"; angle: "360"; value: "-22.6995"; }
+ ListElement{ radius: "70"; angle: "0"; value: "-29.3893"; }
+ ListElement{ radius: "70"; angle: "5"; value: "-25.0315"; }
+ ListElement{ radius: "70"; angle: "10"; value: "-20.7069"; }
+ ListElement{ radius: "70"; angle: "15"; value: "-16.4483"; }
+ ListElement{ radius: "70"; angle: "20"; value: "-12.2883"; }
+ ListElement{ radius: "70"; angle: "25"; value: "-8.25835"; }
+ ListElement{ radius: "70"; angle: "30"; value: "-4.38926"; }
+ ListElement{ radius: "70"; angle: "35"; value: "-0.710441"; }
+ ListElement{ radius: "70"; angle: "40"; value: "2.75012"; }
+ ListElement{ radius: "70"; angle: "45"; value: "5.96608"; }
+ ListElement{ radius: "70"; angle: "50"; value: "8.91296"; }
+ ListElement{ radius: "70"; angle: "55"; value: "11.5683"; }
+ ListElement{ radius: "70"; angle: "60"; value: "13.912"; }
+ ListElement{ radius: "70"; angle: "65"; value: "15.9261"; }
+ ListElement{ radius: "70"; angle: "70"; value: "17.5954"; }
+ ListElement{ radius: "70"; angle: "75"; value: "18.907"; }
+ ListElement{ radius: "70"; angle: "80"; value: "19.8511"; }
+ ListElement{ radius: "70"; angle: "85"; value: "20.4205"; }
+ ListElement{ radius: "70"; angle: "90"; value: "20.6107"; }
+ ListElement{ radius: "70"; angle: "95"; value: "20.4205"; }
+ ListElement{ radius: "70"; angle: "100"; value: "19.8511"; }
+ ListElement{ radius: "70"; angle: "105"; value: "18.907"; }
+ ListElement{ radius: "70"; angle: "110"; value: "17.5954"; }
+ ListElement{ radius: "70"; angle: "115"; value: "15.9261"; }
+ ListElement{ radius: "70"; angle: "120"; value: "13.912"; }
+ ListElement{ radius: "70"; angle: "125"; value: "11.5683"; }
+ ListElement{ radius: "70"; angle: "130"; value: "8.91296"; }
+ ListElement{ radius: "70"; angle: "135"; value: "5.96608"; }
+ ListElement{ radius: "70"; angle: "140"; value: "2.75012"; }
+ ListElement{ radius: "70"; angle: "145"; value: "-0.710441"; }
+ ListElement{ radius: "70"; angle: "150"; value: "-4.38926"; }
+ ListElement{ radius: "70"; angle: "155"; value: "-8.25835"; }
+ ListElement{ radius: "70"; angle: "160"; value: "-12.2883"; }
+ ListElement{ radius: "70"; angle: "165"; value: "-16.4483"; }
+ ListElement{ radius: "70"; angle: "170"; value: "-20.7069"; }
+ ListElement{ radius: "70"; angle: "175"; value: "-25.0315"; }
+ ListElement{ radius: "70"; angle: "180"; value: "-29.3893"; }
+ ListElement{ radius: "70"; angle: "185"; value: "-33.747"; }
+ ListElement{ radius: "70"; angle: "190"; value: "-38.0717"; }
+ ListElement{ radius: "70"; angle: "195"; value: "-42.3302"; }
+ ListElement{ radius: "70"; angle: "200"; value: "-46.4903"; }
+ ListElement{ radius: "70"; angle: "205"; value: "-50.5202"; }
+ ListElement{ radius: "70"; angle: "210"; value: "-54.3893"; }
+ ListElement{ radius: "70"; angle: "215"; value: "-58.0681"; }
+ ListElement{ radius: "70"; angle: "220"; value: "-61.5286"; }
+ ListElement{ radius: "70"; angle: "225"; value: "-64.7446"; }
+ ListElement{ radius: "70"; angle: "230"; value: "-67.6915"; }
+ ListElement{ radius: "70"; angle: "235"; value: "-70.3469"; }
+ ListElement{ radius: "70"; angle: "240"; value: "-72.6905"; }
+ ListElement{ radius: "70"; angle: "245"; value: "-74.7047"; }
+ ListElement{ radius: "70"; angle: "250"; value: "-76.3739"; }
+ ListElement{ radius: "70"; angle: "255"; value: "-77.6856"; }
+ ListElement{ radius: "70"; angle: "260"; value: "-78.6297"; }
+ ListElement{ radius: "70"; angle: "265"; value: "-79.199"; }
+ ListElement{ radius: "70"; angle: "270"; value: "-79.3893"; }
+ ListElement{ radius: "70"; angle: "275"; value: "-79.199"; }
+ ListElement{ radius: "70"; angle: "280"; value: "-78.6297"; }
+ ListElement{ radius: "70"; angle: "285"; value: "-77.6856"; }
+ ListElement{ radius: "70"; angle: "290"; value: "-76.3739"; }
+ ListElement{ radius: "70"; angle: "295"; value: "-74.7047"; }
+ ListElement{ radius: "70"; angle: "300"; value: "-72.6905"; }
+ ListElement{ radius: "70"; angle: "305"; value: "-70.3469"; }
+ ListElement{ radius: "70"; angle: "310"; value: "-67.6915"; }
+ ListElement{ radius: "70"; angle: "315"; value: "-64.7446"; }
+ ListElement{ radius: "70"; angle: "320"; value: "-61.5286"; }
+ ListElement{ radius: "70"; angle: "325"; value: "-58.0681"; }
+ ListElement{ radius: "70"; angle: "330"; value: "-54.3893"; }
+ ListElement{ radius: "70"; angle: "335"; value: "-50.5202"; }
+ ListElement{ radius: "70"; angle: "340"; value: "-46.4903"; }
+ ListElement{ radius: "70"; angle: "345"; value: "-42.3302"; }
+ ListElement{ radius: "70"; angle: "350"; value: "-38.0717"; }
+ ListElement{ radius: "70"; angle: "355"; value: "-33.747"; }
+ ListElement{ radius: "70"; angle: "360"; value: "-29.3893"; }
+ ListElement{ radius: "75"; angle: "0"; value: "-35.3553"; }
+ ListElement{ radius: "75"; angle: "5"; value: "-30.9976"; }
+ ListElement{ radius: "75"; angle: "10"; value: "-26.6729"; }
+ ListElement{ radius: "75"; angle: "15"; value: "-22.4144"; }
+ ListElement{ radius: "75"; angle: "20"; value: "-18.2543"; }
+ ListElement{ radius: "75"; angle: "25"; value: "-14.2244"; }
+ ListElement{ radius: "75"; angle: "30"; value: "-10.3553"; }
+ ListElement{ radius: "75"; angle: "35"; value: "-6.67652"; }
+ ListElement{ radius: "75"; angle: "40"; value: "-3.21596"; }
+ ListElement{ radius: "75"; angle: "45"; value: "5.55112e-15"; }
+ ListElement{ radius: "75"; angle: "50"; value: "2.94688"; }
+ ListElement{ radius: "75"; angle: "55"; value: "5.60226"; }
+ ListElement{ radius: "75"; angle: "60"; value: "7.94593"; }
+ ListElement{ radius: "75"; angle: "65"; value: "9.96005"; }
+ ListElement{ radius: "75"; angle: "70"; value: "11.6293"; }
+ ListElement{ radius: "75"; angle: "75"; value: "12.941"; }
+ ListElement{ radius: "75"; angle: "80"; value: "13.885"; }
+ ListElement{ radius: "75"; angle: "85"; value: "14.4544"; }
+ ListElement{ radius: "75"; angle: "90"; value: "14.6447"; }
+ ListElement{ radius: "75"; angle: "95"; value: "14.4544"; }
+ ListElement{ radius: "75"; angle: "100"; value: "13.885"; }
+ ListElement{ radius: "75"; angle: "105"; value: "12.941"; }
+ ListElement{ radius: "75"; angle: "110"; value: "11.6293"; }
+ ListElement{ radius: "75"; angle: "115"; value: "9.96005"; }
+ ListElement{ radius: "75"; angle: "120"; value: "7.94593"; }
+ ListElement{ radius: "75"; angle: "125"; value: "5.60226"; }
+ ListElement{ radius: "75"; angle: "130"; value: "2.94688"; }
+ ListElement{ radius: "75"; angle: "135"; value: "5.55112e-15"; }
+ ListElement{ radius: "75"; angle: "140"; value: "-3.21596"; }
+ ListElement{ radius: "75"; angle: "145"; value: "-6.67652"; }
+ ListElement{ radius: "75"; angle: "150"; value: "-10.3553"; }
+ ListElement{ radius: "75"; angle: "155"; value: "-14.2244"; }
+ ListElement{ radius: "75"; angle: "160"; value: "-18.2543"; }
+ ListElement{ radius: "75"; angle: "165"; value: "-22.4144"; }
+ ListElement{ radius: "75"; angle: "170"; value: "-26.6729"; }
+ ListElement{ radius: "75"; angle: "175"; value: "-30.9976"; }
+ ListElement{ radius: "75"; angle: "180"; value: "-35.3553"; }
+ ListElement{ radius: "75"; angle: "185"; value: "-39.7131"; }
+ ListElement{ radius: "75"; angle: "190"; value: "-44.0377"; }
+ ListElement{ radius: "75"; angle: "195"; value: "-48.2963"; }
+ ListElement{ radius: "75"; angle: "200"; value: "-52.4563"; }
+ ListElement{ radius: "75"; angle: "205"; value: "-56.4863"; }
+ ListElement{ radius: "75"; angle: "210"; value: "-60.3553"; }
+ ListElement{ radius: "75"; angle: "215"; value: "-64.0342"; }
+ ListElement{ radius: "75"; angle: "220"; value: "-67.4947"; }
+ ListElement{ radius: "75"; angle: "225"; value: "-70.7107"; }
+ ListElement{ radius: "75"; angle: "230"; value: "-73.6576"; }
+ ListElement{ radius: "75"; angle: "235"; value: "-76.3129"; }
+ ListElement{ radius: "75"; angle: "240"; value: "-78.6566"; }
+ ListElement{ radius: "75"; angle: "245"; value: "-80.6707"; }
+ ListElement{ radius: "75"; angle: "250"; value: "-82.34"; }
+ ListElement{ radius: "75"; angle: "255"; value: "-83.6516"; }
+ ListElement{ radius: "75"; angle: "260"; value: "-84.5957"; }
+ ListElement{ radius: "75"; angle: "265"; value: "-85.1651"; }
+ ListElement{ radius: "75"; angle: "270"; value: "-85.3553"; }
+ ListElement{ radius: "75"; angle: "275"; value: "-85.1651"; }
+ ListElement{ radius: "75"; angle: "280"; value: "-84.5957"; }
+ ListElement{ radius: "75"; angle: "285"; value: "-83.6516"; }
+ ListElement{ radius: "75"; angle: "290"; value: "-82.34"; }
+ ListElement{ radius: "75"; angle: "295"; value: "-80.6707"; }
+ ListElement{ radius: "75"; angle: "300"; value: "-78.6566"; }
+ ListElement{ radius: "75"; angle: "305"; value: "-76.3129"; }
+ ListElement{ radius: "75"; angle: "310"; value: "-73.6576"; }
+ ListElement{ radius: "75"; angle: "315"; value: "-70.7107"; }
+ ListElement{ radius: "75"; angle: "320"; value: "-67.4947"; }
+ ListElement{ radius: "75"; angle: "325"; value: "-64.0342"; }
+ ListElement{ radius: "75"; angle: "330"; value: "-60.3553"; }
+ ListElement{ radius: "75"; angle: "335"; value: "-56.4863"; }
+ ListElement{ radius: "75"; angle: "340"; value: "-52.4563"; }
+ ListElement{ radius: "75"; angle: "345"; value: "-48.2963"; }
+ ListElement{ radius: "75"; angle: "350"; value: "-44.0377"; }
+ ListElement{ radius: "75"; angle: "355"; value: "-39.7131"; }
+ ListElement{ radius: "75"; angle: "360"; value: "-35.3553"; }
+ ListElement{ radius: "80"; angle: "0"; value: "-40.4508"; }
+ ListElement{ radius: "80"; angle: "5"; value: "-36.0931"; }
+ ListElement{ radius: "80"; angle: "10"; value: "-31.7684"; }
+ ListElement{ radius: "80"; angle: "15"; value: "-27.5099"; }
+ ListElement{ radius: "80"; angle: "20"; value: "-23.3498"; }
+ ListElement{ radius: "80"; angle: "25"; value: "-19.3199"; }
+ ListElement{ radius: "80"; angle: "30"; value: "-15.4508"; }
+ ListElement{ radius: "80"; angle: "35"; value: "-11.772"; }
+ ListElement{ radius: "80"; angle: "40"; value: "-8.31147"; }
+ ListElement{ radius: "80"; angle: "45"; value: "-5.09551"; }
+ ListElement{ radius: "80"; angle: "50"; value: "-2.14863"; }
+ ListElement{ radius: "80"; angle: "55"; value: "0.506752"; }
+ ListElement{ radius: "80"; angle: "60"; value: "2.85042"; }
+ ListElement{ radius: "80"; angle: "65"; value: "4.86454"; }
+ ListElement{ radius: "80"; angle: "70"; value: "6.53378"; }
+ ListElement{ radius: "80"; angle: "75"; value: "7.84544"; }
+ ListElement{ radius: "80"; angle: "80"; value: "8.78954"; }
+ ListElement{ radius: "80"; angle: "85"; value: "9.35889"; }
+ ListElement{ radius: "80"; angle: "90"; value: "9.54915"; }
+ ListElement{ radius: "80"; angle: "95"; value: "9.35889"; }
+ ListElement{ radius: "80"; angle: "100"; value: "8.78954"; }
+ ListElement{ radius: "80"; angle: "105"; value: "7.84544"; }
+ ListElement{ radius: "80"; angle: "110"; value: "6.53378"; }
+ ListElement{ radius: "80"; angle: "115"; value: "4.86454"; }
+ ListElement{ radius: "80"; angle: "120"; value: "2.85042"; }
+ ListElement{ radius: "80"; angle: "125"; value: "0.506752"; }
+ ListElement{ radius: "80"; angle: "130"; value: "-2.14863"; }
+ ListElement{ radius: "80"; angle: "135"; value: "-5.09551"; }
+ ListElement{ radius: "80"; angle: "140"; value: "-8.31147"; }
+ ListElement{ radius: "80"; angle: "145"; value: "-11.772"; }
+ ListElement{ radius: "80"; angle: "150"; value: "-15.4508"; }
+ ListElement{ radius: "80"; angle: "155"; value: "-19.3199"; }
+ ListElement{ radius: "80"; angle: "160"; value: "-23.3498"; }
+ ListElement{ radius: "80"; angle: "165"; value: "-27.5099"; }
+ ListElement{ radius: "80"; angle: "170"; value: "-31.7684"; }
+ ListElement{ radius: "80"; angle: "175"; value: "-36.0931"; }
+ ListElement{ radius: "80"; angle: "180"; value: "-40.4508"; }
+ ListElement{ radius: "80"; angle: "185"; value: "-44.8086"; }
+ ListElement{ radius: "80"; angle: "190"; value: "-49.1333"; }
+ ListElement{ radius: "80"; angle: "195"; value: "-53.3918"; }
+ ListElement{ radius: "80"; angle: "200"; value: "-57.5519"; }
+ ListElement{ radius: "80"; angle: "205"; value: "-61.5818"; }
+ ListElement{ radius: "80"; angle: "210"; value: "-65.4508"; }
+ ListElement{ radius: "80"; angle: "215"; value: "-69.1297"; }
+ ListElement{ radius: "80"; angle: "220"; value: "-72.5902"; }
+ ListElement{ radius: "80"; angle: "225"; value: "-75.8062"; }
+ ListElement{ radius: "80"; angle: "230"; value: "-78.7531"; }
+ ListElement{ radius: "80"; angle: "235"; value: "-81.4085"; }
+ ListElement{ radius: "80"; angle: "240"; value: "-83.7521"; }
+ ListElement{ radius: "80"; angle: "245"; value: "-85.7662"; }
+ ListElement{ radius: "80"; angle: "250"; value: "-87.4355"; }
+ ListElement{ radius: "80"; angle: "255"; value: "-88.7471"; }
+ ListElement{ radius: "80"; angle: "260"; value: "-89.6912"; }
+ ListElement{ radius: "80"; angle: "265"; value: "-90.2606"; }
+ ListElement{ radius: "80"; angle: "270"; value: "-90.4508"; }
+ ListElement{ radius: "80"; angle: "275"; value: "-90.2606"; }
+ ListElement{ radius: "80"; angle: "280"; value: "-89.6912"; }
+ ListElement{ radius: "80"; angle: "285"; value: "-88.7471"; }
+ ListElement{ radius: "80"; angle: "290"; value: "-87.4355"; }
+ ListElement{ radius: "80"; angle: "295"; value: "-85.7662"; }
+ ListElement{ radius: "80"; angle: "300"; value: "-83.7521"; }
+ ListElement{ radius: "80"; angle: "305"; value: "-81.4085"; }
+ ListElement{ radius: "80"; angle: "310"; value: "-78.7531"; }
+ ListElement{ radius: "80"; angle: "315"; value: "-75.8062"; }
+ ListElement{ radius: "80"; angle: "320"; value: "-72.5902"; }
+ ListElement{ radius: "80"; angle: "325"; value: "-69.1297"; }
+ ListElement{ radius: "80"; angle: "330"; value: "-65.4508"; }
+ ListElement{ radius: "80"; angle: "335"; value: "-61.5818"; }
+ ListElement{ radius: "80"; angle: "340"; value: "-57.5519"; }
+ ListElement{ radius: "80"; angle: "345"; value: "-53.3918"; }
+ ListElement{ radius: "80"; angle: "350"; value: "-49.1333"; }
+ ListElement{ radius: "80"; angle: "355"; value: "-44.8086"; }
+ ListElement{ radius: "80"; angle: "360"; value: "-40.4508"; }
+ ListElement{ radius: "85"; angle: "0"; value: "-44.5503"; }
+ ListElement{ radius: "85"; angle: "5"; value: "-40.1925"; }
+ ListElement{ radius: "85"; angle: "10"; value: "-35.8679"; }
+ ListElement{ radius: "85"; angle: "15"; value: "-31.6094"; }
+ ListElement{ radius: "85"; angle: "20"; value: "-27.4493"; }
+ ListElement{ radius: "85"; angle: "25"; value: "-23.4194"; }
+ ListElement{ radius: "85"; angle: "30"; value: "-19.5503"; }
+ ListElement{ radius: "85"; angle: "35"; value: "-15.8715"; }
+ ListElement{ radius: "85"; angle: "40"; value: "-12.4109"; }
+ ListElement{ radius: "85"; angle: "45"; value: "-9.19499"; }
+ ListElement{ radius: "85"; angle: "50"; value: "-6.2481"; }
+ ListElement{ radius: "85"; angle: "55"; value: "-3.59272"; }
+ ListElement{ radius: "85"; angle: "60"; value: "-1.24906"; }
+ ListElement{ radius: "85"; angle: "65"; value: "0.765063"; }
+ ListElement{ radius: "85"; angle: "70"; value: "2.4343"; }
+ ListElement{ radius: "85"; angle: "75"; value: "3.74597"; }
+ ListElement{ radius: "85"; angle: "80"; value: "4.69006"; }
+ ListElement{ radius: "85"; angle: "85"; value: "5.25941"; }
+ ListElement{ radius: "85"; angle: "90"; value: "5.44967"; }
+ ListElement{ radius: "85"; angle: "95"; value: "5.25941"; }
+ ListElement{ radius: "85"; angle: "100"; value: "4.69006"; }
+ ListElement{ radius: "85"; angle: "105"; value: "3.74597"; }
+ ListElement{ radius: "85"; angle: "110"; value: "2.4343"; }
+ ListElement{ radius: "85"; angle: "115"; value: "0.765063"; }
+ ListElement{ radius: "85"; angle: "120"; value: "-1.24906"; }
+ ListElement{ radius: "85"; angle: "125"; value: "-3.59272"; }
+ ListElement{ radius: "85"; angle: "130"; value: "-6.2481"; }
+ ListElement{ radius: "85"; angle: "135"; value: "-9.19499"; }
+ ListElement{ radius: "85"; angle: "140"; value: "-12.4109"; }
+ ListElement{ radius: "85"; angle: "145"; value: "-15.8715"; }
+ ListElement{ radius: "85"; angle: "150"; value: "-19.5503"; }
+ ListElement{ radius: "85"; angle: "155"; value: "-23.4194"; }
+ ListElement{ radius: "85"; angle: "160"; value: "-27.4493"; }
+ ListElement{ radius: "85"; angle: "165"; value: "-31.6094"; }
+ ListElement{ radius: "85"; angle: "170"; value: "-35.8679"; }
+ ListElement{ radius: "85"; angle: "175"; value: "-40.1925"; }
+ ListElement{ radius: "85"; angle: "180"; value: "-44.5503"; }
+ ListElement{ radius: "85"; angle: "185"; value: "-48.9081"; }
+ ListElement{ radius: "85"; angle: "190"; value: "-53.2327"; }
+ ListElement{ radius: "85"; angle: "195"; value: "-57.4913"; }
+ ListElement{ radius: "85"; angle: "200"; value: "-61.6513"; }
+ ListElement{ radius: "85"; angle: "205"; value: "-65.6812"; }
+ ListElement{ radius: "85"; angle: "210"; value: "-69.5503"; }
+ ListElement{ radius: "85"; angle: "215"; value: "-73.2291"; }
+ ListElement{ radius: "85"; angle: "220"; value: "-76.6897"; }
+ ListElement{ radius: "85"; angle: "225"; value: "-79.9057"; }
+ ListElement{ radius: "85"; angle: "230"; value: "-82.8525"; }
+ ListElement{ radius: "85"; angle: "235"; value: "-85.5079"; }
+ ListElement{ radius: "85"; angle: "240"; value: "-87.8516"; }
+ ListElement{ radius: "85"; angle: "245"; value: "-89.8657"; }
+ ListElement{ radius: "85"; angle: "250"; value: "-91.535"; }
+ ListElement{ radius: "85"; angle: "255"; value: "-92.8466"; }
+ ListElement{ radius: "85"; angle: "260"; value: "-93.7907"; }
+ ListElement{ radius: "85"; angle: "265"; value: "-94.3601"; }
+ ListElement{ radius: "85"; angle: "270"; value: "-94.5503"; }
+ ListElement{ radius: "85"; angle: "275"; value: "-94.3601"; }
+ ListElement{ radius: "85"; angle: "280"; value: "-93.7907"; }
+ ListElement{ radius: "85"; angle: "285"; value: "-92.8466"; }
+ ListElement{ radius: "85"; angle: "290"; value: "-91.535"; }
+ ListElement{ radius: "85"; angle: "295"; value: "-89.8657"; }
+ ListElement{ radius: "85"; angle: "300"; value: "-87.8516"; }
+ ListElement{ radius: "85"; angle: "305"; value: "-85.5079"; }
+ ListElement{ radius: "85"; angle: "310"; value: "-82.8525"; }
+ ListElement{ radius: "85"; angle: "315"; value: "-79.9057"; }
+ ListElement{ radius: "85"; angle: "320"; value: "-76.6897"; }
+ ListElement{ radius: "85"; angle: "325"; value: "-73.2291"; }
+ ListElement{ radius: "85"; angle: "330"; value: "-69.5503"; }
+ ListElement{ radius: "85"; angle: "335"; value: "-65.6812"; }
+ ListElement{ radius: "85"; angle: "340"; value: "-61.6513"; }
+ ListElement{ radius: "85"; angle: "345"; value: "-57.4913"; }
+ ListElement{ radius: "85"; angle: "350"; value: "-53.2327"; }
+ ListElement{ radius: "85"; angle: "355"; value: "-48.9081"; }
+ ListElement{ radius: "85"; angle: "360"; value: "-44.5503"; }
+ ListElement{ radius: "90"; angle: "0"; value: "-47.5528"; }
+ ListElement{ radius: "90"; angle: "5"; value: "-43.195"; }
+ ListElement{ radius: "90"; angle: "10"; value: "-38.8704"; }
+ ListElement{ radius: "90"; angle: "15"; value: "-34.6119"; }
+ ListElement{ radius: "90"; angle: "20"; value: "-30.4518"; }
+ ListElement{ radius: "90"; angle: "25"; value: "-26.4219"; }
+ ListElement{ radius: "90"; angle: "30"; value: "-22.5528"; }
+ ListElement{ radius: "90"; angle: "35"; value: "-18.874"; }
+ ListElement{ radius: "90"; angle: "40"; value: "-15.4134"; }
+ ListElement{ radius: "90"; angle: "45"; value: "-12.1975"; }
+ ListElement{ radius: "90"; angle: "50"; value: "-9.2506"; }
+ ListElement{ radius: "90"; angle: "55"; value: "-6.59522"; }
+ ListElement{ radius: "90"; angle: "60"; value: "-4.25156"; }
+ ListElement{ radius: "90"; angle: "65"; value: "-2.23744"; }
+ ListElement{ radius: "90"; angle: "70"; value: "-0.568195"; }
+ ListElement{ radius: "90"; angle: "75"; value: "0.743465"; }
+ ListElement{ radius: "90"; angle: "80"; value: "1.68756"; }
+ ListElement{ radius: "90"; angle: "85"; value: "2.25691"; }
+ ListElement{ radius: "90"; angle: "90"; value: "2.44717"; }
+ ListElement{ radius: "90"; angle: "95"; value: "2.25691"; }
+ ListElement{ radius: "90"; angle: "100"; value: "1.68756"; }
+ ListElement{ radius: "90"; angle: "105"; value: "0.743465"; }
+ ListElement{ radius: "90"; angle: "110"; value: "-0.568195"; }
+ ListElement{ radius: "90"; angle: "115"; value: "-2.23744"; }
+ ListElement{ radius: "90"; angle: "120"; value: "-4.25156"; }
+ ListElement{ radius: "90"; angle: "125"; value: "-6.59522"; }
+ ListElement{ radius: "90"; angle: "130"; value: "-9.2506"; }
+ ListElement{ radius: "90"; angle: "135"; value: "-12.1975"; }
+ ListElement{ radius: "90"; angle: "140"; value: "-15.4134"; }
+ ListElement{ radius: "90"; angle: "145"; value: "-18.874"; }
+ ListElement{ radius: "90"; angle: "150"; value: "-22.5528"; }
+ ListElement{ radius: "90"; angle: "155"; value: "-26.4219"; }
+ ListElement{ radius: "90"; angle: "160"; value: "-30.4518"; }
+ ListElement{ radius: "90"; angle: "165"; value: "-34.6119"; }
+ ListElement{ radius: "90"; angle: "170"; value: "-38.8704"; }
+ ListElement{ radius: "90"; angle: "175"; value: "-43.195"; }
+ ListElement{ radius: "90"; angle: "180"; value: "-47.5528"; }
+ ListElement{ radius: "90"; angle: "185"; value: "-51.9106"; }
+ ListElement{ radius: "90"; angle: "190"; value: "-56.2352"; }
+ ListElement{ radius: "90"; angle: "195"; value: "-60.4938"; }
+ ListElement{ radius: "90"; angle: "200"; value: "-64.6538"; }
+ ListElement{ radius: "90"; angle: "205"; value: "-68.6837"; }
+ ListElement{ radius: "90"; angle: "210"; value: "-72.5528"; }
+ ListElement{ radius: "90"; angle: "215"; value: "-76.2316"; }
+ ListElement{ radius: "90"; angle: "220"; value: "-79.6922"; }
+ ListElement{ radius: "90"; angle: "225"; value: "-82.9082"; }
+ ListElement{ radius: "90"; angle: "230"; value: "-85.855"; }
+ ListElement{ radius: "90"; angle: "235"; value: "-88.5104"; }
+ ListElement{ radius: "90"; angle: "240"; value: "-90.8541"; }
+ ListElement{ radius: "90"; angle: "245"; value: "-92.8682"; }
+ ListElement{ radius: "90"; angle: "250"; value: "-94.5375"; }
+ ListElement{ radius: "90"; angle: "255"; value: "-95.8491"; }
+ ListElement{ radius: "90"; angle: "260"; value: "-96.7932"; }
+ ListElement{ radius: "90"; angle: "265"; value: "-97.3626"; }
+ ListElement{ radius: "90"; angle: "270"; value: "-97.5528"; }
+ ListElement{ radius: "90"; angle: "275"; value: "-97.3626"; }
+ ListElement{ radius: "90"; angle: "280"; value: "-96.7932"; }
+ ListElement{ radius: "90"; angle: "285"; value: "-95.8491"; }
+ ListElement{ radius: "90"; angle: "290"; value: "-94.5375"; }
+ ListElement{ radius: "90"; angle: "295"; value: "-92.8682"; }
+ ListElement{ radius: "90"; angle: "300"; value: "-90.8541"; }
+ ListElement{ radius: "90"; angle: "305"; value: "-88.5104"; }
+ ListElement{ radius: "90"; angle: "310"; value: "-85.855"; }
+ ListElement{ radius: "90"; angle: "315"; value: "-82.9082"; }
+ ListElement{ radius: "90"; angle: "320"; value: "-79.6922"; }
+ ListElement{ radius: "90"; angle: "325"; value: "-76.2316"; }
+ ListElement{ radius: "90"; angle: "330"; value: "-72.5528"; }
+ ListElement{ radius: "90"; angle: "335"; value: "-68.6837"; }
+ ListElement{ radius: "90"; angle: "340"; value: "-64.6538"; }
+ ListElement{ radius: "90"; angle: "345"; value: "-60.4938"; }
+ ListElement{ radius: "90"; angle: "350"; value: "-56.2352"; }
+ ListElement{ radius: "90"; angle: "355"; value: "-51.9106"; }
+ ListElement{ radius: "90"; angle: "360"; value: "-47.5528"; }
+ ListElement{ radius: "95"; angle: "0"; value: "-49.3844"; }
+ ListElement{ radius: "95"; angle: "5"; value: "-45.0266"; }
+ ListElement{ radius: "95"; angle: "10"; value: "-40.702"; }
+ ListElement{ radius: "95"; angle: "15"; value: "-36.4435"; }
+ ListElement{ radius: "95"; angle: "20"; value: "-32.2834"; }
+ ListElement{ radius: "95"; angle: "25"; value: "-28.2535"; }
+ ListElement{ radius: "95"; angle: "30"; value: "-24.3844"; }
+ ListElement{ radius: "95"; angle: "35"; value: "-20.7056"; }
+ ListElement{ radius: "95"; angle: "40"; value: "-17.245"; }
+ ListElement{ radius: "95"; angle: "45"; value: "-14.0291"; }
+ ListElement{ radius: "95"; angle: "50"; value: "-11.0822"; }
+ ListElement{ radius: "95"; angle: "55"; value: "-8.42681"; }
+ ListElement{ radius: "95"; angle: "60"; value: "-6.08315"; }
+ ListElement{ radius: "95"; angle: "65"; value: "-4.06903"; }
+ ListElement{ radius: "95"; angle: "70"; value: "-2.39979"; }
+ ListElement{ radius: "95"; angle: "75"; value: "-1.08813"; }
+ ListElement{ radius: "95"; angle: "80"; value: "-0.144029"; }
+ ListElement{ radius: "95"; angle: "85"; value: "0.425318"; }
+ ListElement{ radius: "95"; angle: "90"; value: "0.615583"; }
+ ListElement{ radius: "95"; angle: "95"; value: "0.425318"; }
+ ListElement{ radius: "95"; angle: "100"; value: "-0.144029"; }
+ ListElement{ radius: "95"; angle: "105"; value: "-1.08813"; }
+ ListElement{ radius: "95"; angle: "110"; value: "-2.39979"; }
+ ListElement{ radius: "95"; angle: "115"; value: "-4.06903"; }
+ ListElement{ radius: "95"; angle: "120"; value: "-6.08315"; }
+ ListElement{ radius: "95"; angle: "125"; value: "-8.42681"; }
+ ListElement{ radius: "95"; angle: "130"; value: "-11.0822"; }
+ ListElement{ radius: "95"; angle: "135"; value: "-14.0291"; }
+ ListElement{ radius: "95"; angle: "140"; value: "-17.245"; }
+ ListElement{ radius: "95"; angle: "145"; value: "-20.7056"; }
+ ListElement{ radius: "95"; angle: "150"; value: "-24.3844"; }
+ ListElement{ radius: "95"; angle: "155"; value: "-28.2535"; }
+ ListElement{ radius: "95"; angle: "160"; value: "-32.2834"; }
+ ListElement{ radius: "95"; angle: "165"; value: "-36.4435"; }
+ ListElement{ radius: "95"; angle: "170"; value: "-40.702"; }
+ ListElement{ radius: "95"; angle: "175"; value: "-45.0266"; }
+ ListElement{ radius: "95"; angle: "180"; value: "-49.3844"; }
+ ListElement{ radius: "95"; angle: "185"; value: "-53.7422"; }
+ ListElement{ radius: "95"; angle: "190"; value: "-58.0668"; }
+ ListElement{ radius: "95"; angle: "195"; value: "-62.3254"; }
+ ListElement{ radius: "95"; angle: "200"; value: "-66.4854"; }
+ ListElement{ radius: "95"; angle: "205"; value: "-70.5153"; }
+ ListElement{ radius: "95"; angle: "210"; value: "-74.3844"; }
+ ListElement{ radius: "95"; angle: "215"; value: "-78.0632"; }
+ ListElement{ radius: "95"; angle: "220"; value: "-81.5238"; }
+ ListElement{ radius: "95"; angle: "225"; value: "-84.7398"; }
+ ListElement{ radius: "95"; angle: "230"; value: "-87.6866"; }
+ ListElement{ radius: "95"; angle: "235"; value: "-90.342"; }
+ ListElement{ radius: "95"; angle: "240"; value: "-92.6857"; }
+ ListElement{ radius: "95"; angle: "245"; value: "-94.6998"; }
+ ListElement{ radius: "95"; angle: "250"; value: "-96.369"; }
+ ListElement{ radius: "95"; angle: "255"; value: "-97.6807"; }
+ ListElement{ radius: "95"; angle: "260"; value: "-98.6248"; }
+ ListElement{ radius: "95"; angle: "265"; value: "-99.1942"; }
+ ListElement{ radius: "95"; angle: "270"; value: "-99.3844"; }
+ ListElement{ radius: "95"; angle: "275"; value: "-99.1942"; }
+ ListElement{ radius: "95"; angle: "280"; value: "-98.6248"; }
+ ListElement{ radius: "95"; angle: "285"; value: "-97.6807"; }
+ ListElement{ radius: "95"; angle: "290"; value: "-96.369"; }
+ ListElement{ radius: "95"; angle: "295"; value: "-94.6998"; }
+ ListElement{ radius: "95"; angle: "300"; value: "-92.6857"; }
+ ListElement{ radius: "95"; angle: "305"; value: "-90.342"; }
+ ListElement{ radius: "95"; angle: "310"; value: "-87.6866"; }
+ ListElement{ radius: "95"; angle: "315"; value: "-84.7398"; }
+ ListElement{ radius: "95"; angle: "320"; value: "-81.5238"; }
+ ListElement{ radius: "95"; angle: "325"; value: "-78.0632"; }
+ ListElement{ radius: "95"; angle: "330"; value: "-74.3844"; }
+ ListElement{ radius: "95"; angle: "335"; value: "-70.5153"; }
+ ListElement{ radius: "95"; angle: "340"; value: "-66.4854"; }
+ ListElement{ radius: "95"; angle: "345"; value: "-62.3254"; }
+ ListElement{ radius: "95"; angle: "350"; value: "-58.0668"; }
+ ListElement{ radius: "95"; angle: "355"; value: "-53.7422"; }
+ ListElement{ radius: "95"; angle: "360"; value: "-49.3844"; }
+ ListElement{ radius: "100"; angle: "0"; value: "-50"; }
+ ListElement{ radius: "100"; angle: "5"; value: "-45.6422"; }
+ ListElement{ radius: "100"; angle: "10"; value: "-41.3176"; }
+ ListElement{ radius: "100"; angle: "15"; value: "-37.059"; }
+ ListElement{ radius: "100"; angle: "20"; value: "-32.899"; }
+ ListElement{ radius: "100"; angle: "25"; value: "-28.8691"; }
+ ListElement{ radius: "100"; angle: "30"; value: "-25"; }
+ ListElement{ radius: "100"; angle: "35"; value: "-21.3212"; }
+ ListElement{ radius: "100"; angle: "40"; value: "-17.8606"; }
+ ListElement{ radius: "100"; angle: "45"; value: "-14.6447"; }
+ ListElement{ radius: "100"; angle: "50"; value: "-11.6978"; }
+ ListElement{ radius: "100"; angle: "55"; value: "-9.0424"; }
+ ListElement{ radius: "100"; angle: "60"; value: "-6.69873"; }
+ ListElement{ radius: "100"; angle: "65"; value: "-4.68461"; }
+ ListElement{ radius: "100"; angle: "70"; value: "-3.01537"; }
+ ListElement{ radius: "100"; angle: "75"; value: "-1.70371"; }
+ ListElement{ radius: "100"; angle: "80"; value: "-0.759612"; }
+ ListElement{ radius: "100"; angle: "85"; value: "-0.190265"; }
+ ListElement{ radius: "100"; angle: "90"; value: "0"; }
+ ListElement{ radius: "100"; angle: "95"; value: "-0.190265"; }
+ ListElement{ radius: "100"; angle: "100"; value: "-0.759612"; }
+ ListElement{ radius: "100"; angle: "105"; value: "-1.70371"; }
+ ListElement{ radius: "100"; angle: "110"; value: "-3.01537"; }
+ ListElement{ radius: "100"; angle: "115"; value: "-4.68461"; }
+ ListElement{ radius: "100"; angle: "120"; value: "-6.69873"; }
+ ListElement{ radius: "100"; angle: "125"; value: "-9.0424"; }
+ ListElement{ radius: "100"; angle: "130"; value: "-11.6978"; }
+ ListElement{ radius: "100"; angle: "135"; value: "-14.6447"; }
+ ListElement{ radius: "100"; angle: "140"; value: "-17.8606"; }
+ ListElement{ radius: "100"; angle: "145"; value: "-21.3212"; }
+ ListElement{ radius: "100"; angle: "150"; value: "-25"; }
+ ListElement{ radius: "100"; angle: "155"; value: "-28.8691"; }
+ ListElement{ radius: "100"; angle: "160"; value: "-32.899"; }
+ ListElement{ radius: "100"; angle: "165"; value: "-37.059"; }
+ ListElement{ radius: "100"; angle: "170"; value: "-41.3176"; }
+ ListElement{ radius: "100"; angle: "175"; value: "-45.6422"; }
+ ListElement{ radius: "100"; angle: "180"; value: "-50"; }
+ ListElement{ radius: "100"; angle: "185"; value: "-54.3578"; }
+ ListElement{ radius: "100"; angle: "190"; value: "-58.6824"; }
+ ListElement{ radius: "100"; angle: "195"; value: "-62.941"; }
+ ListElement{ radius: "100"; angle: "200"; value: "-67.101"; }
+ ListElement{ radius: "100"; angle: "205"; value: "-71.1309"; }
+ ListElement{ radius: "100"; angle: "210"; value: "-75"; }
+ ListElement{ radius: "100"; angle: "215"; value: "-78.6788"; }
+ ListElement{ radius: "100"; angle: "220"; value: "-82.1394"; }
+ ListElement{ radius: "100"; angle: "225"; value: "-85.3553"; }
+ ListElement{ radius: "100"; angle: "230"; value: "-88.3022"; }
+ ListElement{ radius: "100"; angle: "235"; value: "-90.9576"; }
+ ListElement{ radius: "100"; angle: "240"; value: "-93.3013"; }
+ ListElement{ radius: "100"; angle: "245"; value: "-95.3154"; }
+ ListElement{ radius: "100"; angle: "250"; value: "-96.9846"; }
+ ListElement{ radius: "100"; angle: "255"; value: "-98.2963"; }
+ ListElement{ radius: "100"; angle: "260"; value: "-99.2404"; }
+ ListElement{ radius: "100"; angle: "265"; value: "-99.8097"; }
+ ListElement{ radius: "100"; angle: "270"; value: "-100"; }
+ ListElement{ radius: "100"; angle: "275"; value: "-99.8097"; }
+ ListElement{ radius: "100"; angle: "280"; value: "-99.2404"; }
+ ListElement{ radius: "100"; angle: "285"; value: "-98.2963"; }
+ ListElement{ radius: "100"; angle: "290"; value: "-96.9846"; }
+ ListElement{ radius: "100"; angle: "295"; value: "-95.3154"; }
+ ListElement{ radius: "100"; angle: "300"; value: "-93.3013"; }
+ ListElement{ radius: "100"; angle: "305"; value: "-90.9576"; }
+ ListElement{ radius: "100"; angle: "310"; value: "-88.3022"; }
+ ListElement{ radius: "100"; angle: "315"; value: "-85.3553"; }
+ ListElement{ radius: "100"; angle: "320"; value: "-82.1394"; }
+ ListElement{ radius: "100"; angle: "325"; value: "-78.6788"; }
+ ListElement{ radius: "100"; angle: "330"; value: "-75"; }
+ ListElement{ radius: "100"; angle: "335"; value: "-71.1309"; }
+ ListElement{ radius: "100"; angle: "340"; value: "-67.101"; }
+ ListElement{ radius: "100"; angle: "345"; value: "-62.941"; }
+ ListElement{ radius: "100"; angle: "350"; value: "-58.6824"; }
+ ListElement{ radius: "100"; angle: "355"; value: "-54.3578"; }
+ ListElement{ radius: "100"; angle: "360"; value: "-50"; }
+ }
+}
diff --git a/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/NewButton.qml b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/NewButton.qml
new file mode 100644
index 00000000..e4fb99d2
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/NewButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ id: newbutton
+
+ property alias text: buttonText.text
+
+ signal clicked
+
+ implicitWidth: buttonText.implicitWidth + 5
+ implicitHeight: buttonText.implicitHeight + 10
+
+ Button {
+ id: buttonText
+ width: parent.width
+ height: parent.height
+
+ style: ButtonStyle {
+ label: Component {
+ Text {
+ text: buttonText.text
+ clip: true
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ }
+ }
+ }
+ onClicked: newbutton.clicked()
+ }
+}
diff --git a/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml
new file mode 100644
index 00000000..4c77fd45
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml
@@ -0,0 +1,293 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import QtQuick.Window 2.1
+import QtDataVisualization 1.2
+import "."
+
+Window {
+ id: mainview
+ title: "Qt Quick 2 Spectrogram Example"
+ visible: true
+ width: 1024
+ height: 768
+ color: surfaceGraph.theme.windowColor
+
+ Data {
+ id: surfaceData
+ }
+
+ Item {
+ id: surfaceView
+ width: mainview.width
+ height: mainview.height
+ anchors.top: mainview.top
+ anchors.left: mainview.left
+
+ ColorGradient {
+ id: surfaceGradient
+ ColorGradientStop { position: 0.0; color: "black" }
+ ColorGradientStop { position: 0.2; color: "red" }
+ ColorGradientStop { position: 0.5; color: "blue" }
+ ColorGradientStop { position: 0.8; color: "yellow" }
+ ColorGradientStop { position: 1.0; color: "white" }
+ }
+
+ ValueAxis3D {
+ id: xAxis
+ segmentCount: 8
+ labelFormat: "%i\u00B0"
+ title: "Angle"
+ titleVisible: true
+ titleFixed: false
+ }
+
+ ValueAxis3D {
+ id: yAxis
+ segmentCount: 8
+ labelFormat: "%i \%"
+ title: "Value"
+ titleVisible: true
+ labelAutoRotation: 0
+ titleFixed: false
+ }
+
+ ValueAxis3D {
+ id: zAxis
+ segmentCount: 5
+ labelFormat: "%i nm"
+ title: "Radius"
+ titleVisible: true
+ titleFixed: false
+ }
+
+ Theme3D {
+ id: customTheme
+ type: Theme3D.ThemeQt
+ // Don't show specular spotlight as we don't want it to distort the colors
+ lightStrength: 0.0
+ ambientLightStrength: 1.0
+ backgroundEnabled: false
+ gridLineColor: "#AAAAAA"
+ windowColor: "#EEEEEE"
+ }
+
+
+ //! [5]
+ TouchInputHandler3D {
+ id: customInputHandler
+ rotationEnabled: false
+ }
+ //! [5]
+
+ //! [0]
+ //! [7]
+ Surface3D {
+ //! [7]
+ id: surfaceGraph
+ width: surfaceView.width
+ height: surfaceView.height
+
+ shadowQuality: AbstractGraph3D.ShadowQualityNone
+ selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndColumn
+ axisX: xAxis
+ axisY: yAxis
+ axisZ: zAxis
+
+ theme: customTheme
+ //! [6]
+ inputHandler: customInputHandler
+ //! [6]
+
+ // Remove the perspective and view the graph from top down to achieve 2D effect
+ //! [1]
+ orthoProjection: true
+ scene.activeCamera.cameraPreset: Camera3D.CameraPresetDirectlyAbove
+ //! [1]
+
+ //! [2]
+ flipHorizontalGrid: true
+ //! [2]
+
+ //! [4]
+ radialLabelOffset: 0.01
+ //! [4]
+
+ horizontalAspectRatio: 1
+ scene.activeCamera.zoomLevel: 85
+
+ Surface3DSeries {
+ id: surfaceSeries
+ flatShadingEnabled: false
+ drawMode: Surface3DSeries.DrawSurface
+ baseGradient: surfaceGradient
+ colorStyle: Theme3D.ColorStyleRangeGradient
+ itemLabelFormat: "(@xLabel, @zLabel): @yLabel"
+
+ ItemModelSurfaceDataProxy {
+ itemModel: surfaceData.model
+ rowRole: "radius"
+ columnRole: "angle"
+ yPosRole: "value"
+ }
+ }
+ }
+ //! [0]
+ }
+
+ RowLayout {
+ id: buttonLayout
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ opacity: 0.5
+
+ //! [3]
+ NewButton {
+ id: polarToggle
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ text: "Switch to polar"
+ onClicked: {
+ if (surfaceGraph.polar === false) {
+ surfaceGraph.polar = true
+ text = "Switch to cartesian"
+ } else {
+ surfaceGraph.polar = false
+ text = "Switch to polar"
+ }
+ }
+ }
+ //! [3]
+
+ NewButton {
+ id: orthoToggle
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ text: "Switch to perspective"
+ onClicked: {
+ if (surfaceGraph.orthoProjection === true) {
+ surfaceGraph.orthoProjection = false;
+ xAxis.labelAutoRotation = 30
+ yAxis.labelAutoRotation = 30
+ zAxis.labelAutoRotation = 30
+ customInputHandler.rotationEnabled = true
+ text = "Switch to orthographic"
+ } else {
+ surfaceGraph.orthoProjection = true;
+ surfaceGraph.scene.activeCamera.cameraPreset = Camera3D.CameraPresetDirectlyAbove
+ surfaceSeries.drawMode &= ~Surface3DSeries.DrawWireframe;
+ xAxis.labelAutoRotation = 0
+ yAxis.labelAutoRotation = 0
+ zAxis.labelAutoRotation = 0
+ customInputHandler.rotationEnabled = false
+ text = "Switch to perspective"
+ }
+ }
+ }
+
+ NewButton {
+ id: flipGridToggle
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ text: "Toggle axis grid on top"
+ onClicked: {
+ onClicked: {
+ if (surfaceGraph.flipHorizontalGrid === true) {
+ surfaceGraph.flipHorizontalGrid = false;
+ } else {
+ surfaceGraph.flipHorizontalGrid = true;
+ }
+ }
+ }
+ }
+
+ NewButton {
+ id: labelOffsetToggle
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ text: "Toggle radial label position"
+ visible: surfaceGraph.polar
+ onClicked: {
+ if (surfaceGraph.radialLabelOffset >= 1.0) {
+ surfaceGraph.radialLabelOffset = 0.01
+ } else {
+ surfaceGraph.radialLabelOffset = 1.0
+ }
+ }
+ }
+
+ NewButton {
+ id: surfaceGridToggle
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ text: "Toggle surface grid"
+ visible: !surfaceGraph.orthoProjection
+ onClicked: {
+ if (surfaceSeries.drawMode & Surface3DSeries.DrawWireframe) {
+ surfaceSeries.drawMode &= ~Surface3DSeries.DrawWireframe;
+ } else {
+ surfaceSeries.drawMode |= Surface3DSeries.DrawWireframe;
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: legend
+ anchors.margins: 20
+ anchors.bottom: parent.bottom
+ anchors.top: buttonLayout.bottom
+ anchors.right: parent.right
+ border.color: "black"
+ border.width: 1
+ width: 50
+ rotation: 180
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "black" }
+ GradientStop { position: 0.2; color: "red" }
+ GradientStop { position: 0.5; color: "blue" }
+ GradientStop { position: 0.8; color: "yellow" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+ }
+
+ Text {
+ anchors.verticalCenter: legend.bottom
+ anchors.right: legend.left
+ anchors.margins: 2
+ text: surfaceGraph.axisY.min + "%"
+ }
+
+ Text {
+ anchors.verticalCenter: legend.verticalCenter
+ anchors.right: legend.left
+ anchors.margins: 2
+ text: (surfaceGraph.axisY.max + surfaceGraph.axisY.min) / 2 + "%"
+ }
+
+ Text {
+ anchors.verticalCenter: legend.top
+ anchors.right: legend.left
+ anchors.margins: 2
+ text: surfaceGraph.axisY.max + "%"
+ }
+}
diff --git a/examples/datavisualization/qmlspectrogram/qmlspectrogram.pro b/examples/datavisualization/qmlspectrogram/qmlspectrogram.pro
new file mode 100644
index 00000000..655fb0b8
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/qmlspectrogram.pro
@@ -0,0 +1,12 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+RESOURCES += qmlspectrogram.qrc
+
+OTHER_FILES += doc/src/* \
+ doc/images/* \
+ qml/qmlspectrogram/*
diff --git a/examples/datavisualization/qmlspectrogram/qmlspectrogram.qrc b/examples/datavisualization/qmlspectrogram/qmlspectrogram.qrc
new file mode 100644
index 00000000..9f024404
--- /dev/null
+++ b/examples/datavisualization/qmlspectrogram/qmlspectrogram.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/qml">
+ <file>qml/qmlspectrogram/Data.qml</file>
+ <file>qml/qmlspectrogram/main.qml</file>
+ <file>qml/qmlspectrogram/NewButton.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/datavisualization/qmlsurfacelayers/layer_2.png b/examples/datavisualization/qmlsurfacelayers/layer_2.png
index 61631ae8..3af154e2 100644
--- a/examples/datavisualization/qmlsurfacelayers/layer_2.png
+++ b/examples/datavisualization/qmlsurfacelayers/layer_2.png
Binary files differ
diff --git a/examples/datavisualization/texturesurface/custominputhandler.cpp b/examples/datavisualization/texturesurface/custominputhandler.cpp
new file mode 100644
index 00000000..2510df54
--- /dev/null
+++ b/examples/datavisualization/texturesurface/custominputhandler.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "custominputhandler.h"
+
+#include <QtDataVisualization/Q3DCamera>
+#include <QtCore/qmath.h>
+
+CustomInputHandler::CustomInputHandler(QAbstract3DGraph *graph, QObject *parent) :
+ Q3DInputHandler(parent),
+ m_highlight(0),
+ m_mousePressed(false),
+ m_state(StateNormal),
+ m_axisX(0),
+ m_axisZ(0),
+ m_speedModifier(20.0f)
+{
+ // Connect to the item selection signal from graph
+ connect(graph, &QAbstract3DGraph::selectedElementChanged, this,
+ &CustomInputHandler::handleElementSelected);
+}
+
+void CustomInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ if (Qt::LeftButton == event->button()) {
+ m_highlight->setVisible(false);
+ m_mousePressed = true;
+ }
+ Q3DInputHandler::mousePressEvent(event, mousePos);
+}
+
+//! [1]
+void CustomInputHandler::wheelEvent(QWheelEvent *event)
+{
+ float delta = float(event->delta());
+
+ m_axisXMinValue += delta;
+ m_axisXMaxValue -= delta;
+ m_axisZMinValue += delta;
+ m_axisZMaxValue -= delta;
+ checkConstraints();
+
+ float y = (m_axisXMaxValue - m_axisXMinValue) * m_aspectRatio;
+
+ m_axisX->setRange(m_axisXMinValue, m_axisXMaxValue);
+ m_axisY->setRange(100.0f, y);
+ m_axisZ->setRange(m_axisZMinValue, m_axisZMaxValue);
+}
+//! [1]
+
+void CustomInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ // Check if we're trying to drag axis label
+ if (m_mousePressed && m_state != StateNormal) {
+ setPreviousInputPos(inputPosition());
+ setInputPosition(mousePos);
+ handleAxisDragging();
+ } else {
+ Q3DInputHandler::mouseMoveEvent(event, mousePos);
+ }
+}
+
+void CustomInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q3DInputHandler::mouseReleaseEvent(event, mousePos);
+ m_mousePressed = false;
+ m_state = StateNormal;
+}
+
+void CustomInputHandler::handleElementSelected(QAbstract3DGraph::ElementType type)
+{
+ switch (type) {
+ case QAbstract3DGraph::ElementAxisXLabel:
+ m_state = StateDraggingX;
+ break;
+ case QAbstract3DGraph::ElementAxisZLabel:
+ m_state = StateDraggingZ;
+ break;
+ default:
+ m_state = StateNormal;
+ break;
+ }
+}
+
+void CustomInputHandler::handleAxisDragging()
+{
+ float distance = 0.0f;
+
+ // Get scene orientation from active camera
+ float xRotation = scene()->activeCamera()->xRotation();
+
+ // Calculate directional drag multipliers based on rotation
+ float xMulX = qCos(qDegreesToRadians(xRotation));
+ float xMulY = qSin(qDegreesToRadians(xRotation));
+ float zMulX = qSin(qDegreesToRadians(xRotation));
+ float zMulY = qCos(qDegreesToRadians(xRotation));
+
+ // Get the drag amount
+ QPoint move = inputPosition() - previousInputPos();
+
+ // Adjust axes
+ switch (m_state) {
+//! [0]
+ case StateDraggingX:
+ distance = (move.x() * xMulX - move.y() * xMulY) * m_speedModifier;
+ m_axisXMinValue -= distance;
+ m_axisXMaxValue -= distance;
+ if (m_axisXMinValue < m_areaMinValue) {
+ float dist = m_axisXMaxValue - m_axisXMinValue;
+ m_axisXMinValue = m_areaMinValue;
+ m_axisXMaxValue = m_axisXMinValue + dist;
+ }
+ if (m_axisXMaxValue > m_areaMaxValue) {
+ float dist = m_axisXMaxValue - m_axisXMinValue;
+ m_axisXMaxValue = m_areaMaxValue;
+ m_axisXMinValue = m_axisXMaxValue - dist;
+ }
+ m_axisX->setRange(m_axisXMinValue, m_axisXMaxValue);
+ break;
+//! [0]
+ case StateDraggingZ:
+ distance = (move.x() * zMulX + move.y() * zMulY) * m_speedModifier;
+ m_axisZMinValue += distance;
+ m_axisZMaxValue += distance;
+ if (m_axisZMinValue < m_areaMinValue) {
+ float dist = m_axisZMaxValue - m_axisZMinValue;
+ m_axisZMinValue = m_areaMinValue;
+ m_axisZMaxValue = m_axisZMinValue + dist;
+ }
+ if (m_axisZMaxValue > m_areaMaxValue) {
+ float dist = m_axisZMaxValue - m_axisZMinValue;
+ m_axisZMaxValue = m_areaMaxValue;
+ m_axisZMinValue = m_axisZMaxValue - dist;
+ }
+ m_axisZ->setRange(m_axisZMinValue, m_axisZMaxValue);
+ break;
+ default:
+ break;
+ }
+}
+
+void CustomInputHandler::checkConstraints()
+{
+//! [2]
+ if (m_axisXMinValue < m_areaMinValue)
+ m_axisXMinValue = m_areaMinValue;
+ if (m_axisXMaxValue > m_areaMaxValue)
+ m_axisXMaxValue = m_areaMaxValue;
+ // Don't allow too much zoom in
+ if ((m_axisXMaxValue - m_axisXMinValue) < m_axisXMinRange) {
+ float adjust = (m_axisXMinRange - (m_axisXMaxValue - m_axisXMinValue)) / 2.0f;
+ m_axisXMinValue -= adjust;
+ m_axisXMaxValue += adjust;
+ }
+//! [2]
+
+ if (m_axisZMinValue < m_areaMinValue)
+ m_axisZMinValue = m_areaMinValue;
+ if (m_axisZMaxValue > m_areaMaxValue)
+ m_axisZMaxValue = m_areaMaxValue;
+ // Don't allow too much zoom in
+ if ((m_axisZMaxValue - m_axisZMinValue) < m_axisZMinRange) {
+ float adjust = (m_axisZMinRange - (m_axisZMaxValue - m_axisZMinValue)) / 2.0f;
+ m_axisZMinValue -= adjust;
+ m_axisZMaxValue += adjust;
+ }
+}
diff --git a/examples/datavisualization/texturesurface/custominputhandler.h b/examples/datavisualization/texturesurface/custominputhandler.h
new file mode 100644
index 00000000..8bef990e
--- /dev/null
+++ b/examples/datavisualization/texturesurface/custominputhandler.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef CUSTOMINPUTHANDLER_H
+#define CUSTOMINPUTHANDLER_H
+
+#include <QtDataVisualization/Q3DInputHandler>
+#include <QtDataVisualization/QAbstract3DGraph>
+#include <QtDataVisualization/QValue3DAxis>
+#include "highlightseries.h"
+
+using namespace QtDataVisualization;
+
+class CustomInputHandler : public Q3DInputHandler
+{
+ Q_OBJECT
+
+ enum InputState {
+ StateNormal = 0,
+ StateDraggingX,
+ StateDraggingZ,
+ StateDraggingY
+ };
+
+public:
+ explicit CustomInputHandler(QAbstract3DGraph *graph, QObject *parent = 0);
+
+ inline void setLimits(float min, float max, float minRange) {
+ m_areaMinValue = min;
+ m_areaMaxValue = max;
+ m_axisXMinValue = m_areaMinValue;
+ m_axisXMaxValue = m_areaMaxValue;
+ m_axisZMinValue = m_areaMinValue;
+ m_axisZMaxValue = m_areaMaxValue;
+ m_axisXMinRange = minRange;
+ m_axisZMinRange = minRange;
+ }
+ inline void setAxes(QValue3DAxis *axisX, QValue3DAxis *axisY, QValue3DAxis *axisZ) {
+ m_axisX = axisX;
+ m_axisY = axisY;
+ m_axisZ = axisZ;
+ }
+ inline void setAspectRatio(float ratio) { m_aspectRatio = ratio; }
+ inline void setHighlightSeries(HighlightSeries *series) { m_highlight = series; }
+ inline void setDragSpeedModifier(float modifier) { m_speedModifier = modifier; }
+
+ virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void wheelEvent(QWheelEvent *event);
+
+private:
+ void handleElementSelected(QAbstract3DGraph::ElementType type);
+ void handleAxisDragging();
+ void checkConstraints();
+
+private:
+ HighlightSeries *m_highlight;
+ bool m_mousePressed;
+ InputState m_state;
+ QValue3DAxis *m_axisX;
+ QValue3DAxis *m_axisY;
+ QValue3DAxis *m_axisZ;
+ float m_speedModifier;
+ float m_aspectRatio;
+ float m_axisXMinValue;
+ float m_axisXMaxValue;
+ float m_axisXMinRange;
+ float m_axisZMinValue;
+ float m_axisZMaxValue;
+ float m_axisZMinRange;
+ float m_areaMinValue;
+ float m_areaMaxValue;
+};
+
+#endif
diff --git a/examples/datavisualization/texturesurface/doc/images/texturesurface-example.png b/examples/datavisualization/texturesurface/doc/images/texturesurface-example.png
new file mode 100644
index 00000000..76819607
--- /dev/null
+++ b/examples/datavisualization/texturesurface/doc/images/texturesurface-example.png
Binary files differ
diff --git a/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc b/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc
new file mode 100644
index 00000000..483b8110
--- /dev/null
+++ b/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+/*!
+ \example texturesurface
+ \title Textured Surface Example
+ \ingroup qtdatavisualization_examples
+ \brief Using texture with Q3DSurface.
+ \since QtDataVisualization 1.2
+
+ The textured surface example shows how to add an image as a texture for a surface. The example
+ shows also how to:
+
+ \list
+ \li Create a surface series from an image
+ \li Use custom input handler to enable zooming and panning
+ \li Highlight an area of the surface
+ \endlist
+
+ \image texturesurface-example.png
+
+ \section1 Texture to a surface series
+
+ The image to be set as a texture to a surface can be set using QSurface3DSeries::setTextureFile().
+ In this example we have added a check box to control if the texture is set or not. The
+ following code extract is for reacting to the check box selections. The image in this
+ example is read from the resource file where it is as a JPG file. Setting an empty file
+ with the method clears the texture, and the surface uses the gradients or colors from the theme.
+
+ \snippet texturesurface/surfacegraph.cpp 0
+
+ \section1 Topographic surface series
+
+ The topographic data for this example is obtained from National Land Survey of Finland. It
+ provides a product called \c{Elevation Model 2 m}, which was suitable for our needs. We selected
+ Levi fell to be shown. The accuracy of the data was well beyond our needs and therefore it
+ is compressed and encoded into a PNG file. The height value from the original ASCII data is
+ encoded into RGB format using a multiplier, which you will see later on a code extract.
+ The multiplier is calculated simply by dividing the largest 24 bit value with the highest point
+ in Finland.
+
+ Qt Data Visualization has a special proxy for height map image files, but it converts
+ only one byte values. So to utilize the bigger accuracy on the data from National Land
+ Survey of Finland, we read the data from the PNG file and decode it into QSurface3DSeries.
+ The following code samples show how this is done.
+
+ First the encoding multiplier.
+ \snippet texturesurface/topographicseries.cpp 0
+
+ And then the actual decoding.
+ \snippet texturesurface/topographicseries.cpp 1
+
+ \section1 Use custom input handler to enable zooming and panning
+
+ For the panning the implementation is similar to the \l{Axis Range Dragging With Labels Example}.
+ The difference is that in this example we follow only dragging of X and Z axis and we don't
+ allow dragging the surface outside the graph. The control for this is very simple and done as
+ on the following example for the X axis.
+
+ \snippet texturesurface/custominputhandler.cpp 0
+
+ For the zooming we catch the \c wheelEvent and adjust the X and Y axis ranges according to delta
+ value on QWheelEvent. The Y axis is also adjusted so that the aspect ratio between Y axis and
+ XZ plane stays the same, and we don't get silly looking graph with height exaggerated too much.
+
+ \snippet texturesurface/custominputhandler.cpp 1
+
+ In this case we want to control the zoom level so that it won't get too near to or far from the
+ surface. For instance, if the value for the X axis gets below the allowed, i.e. zooming gets too
+ far, the value is set to the minimum allowed value. If the range is going to below the range
+ minimum, both ends of the axis are adjusted so that the range stays at the limit.
+
+ \snippet texturesurface/custominputhandler.cpp 2
+
+ \section1 Highlight an area of the surface
+
+ The main idea on creating a highlight on the surface is to create a copy of the series and add
+ a bit of offset to the y value. On this example the class \c HighlightSeries implements the
+ creation of the copy on its \c handlePositionChange method. Firstly the \c HighlightSeries
+ needs to get the pointer to the original series and then it starts to listen the
+ QSurface3DSeries::selectedPointChanged signal.
+
+ \snippet texturesurface/highlightseries.cpp 0
+
+ When the signal arrives, first thing is to check that the position is valid. Then the ranges
+ for the copied area are calculated and checked that they stay within the bounds. Finally
+ we simply fill the data array of the highlight series with the range from the data array of
+ topography series.
+
+ \snippet texturesurface/highlightseries.cpp 1
+
+ \section1 A gradient to the highlight series
+
+ Since the \c HighlightSeries is QSurface3DSeries, we can use all the decoration methods series can
+ have. In this example we added a gradient to emphasize the elevation. Because the suitable gradient
+ style depends on the range of the Y axis and we change the range when zooming, we need to adjust
+ the gradient color positions as the range change.
+
+ For the gradient color positions we define proportional values.
+
+ \snippet texturesurface/highlightseries.cpp 2
+
+ The gradient modification is done on \c handleGradientChange method and we connect it to react to
+ changes on Y axis.
+
+ \snippet texturesurface/surfacegraph.cpp 1
+
+ When a change on Y axis max value happens, we calculate the gradient color positions.
+
+ \snippet texturesurface/highlightseries.cpp 3
+*/
diff --git a/examples/datavisualization/texturesurface/highlightseries.cpp b/examples/datavisualization/texturesurface/highlightseries.cpp
new file mode 100644
index 00000000..13d1fba3
--- /dev/null
+++ b/examples/datavisualization/texturesurface/highlightseries.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "highlightseries.h"
+
+using namespace QtDataVisualization;
+
+//! [2]
+const float darkRedPos = 1.0f;
+const float redPos = 0.8f;
+const float yellowPos = 0.6f;
+const float greenPos = 0.4f;
+const float darkGreenPos = 0.2f;
+//! [2]
+
+HighlightSeries::HighlightSeries()
+ : m_width(100),
+ m_height(100)
+{
+ setDrawMode(QSurface3DSeries::DrawSurface);
+ setFlatShadingEnabled(true);
+ setVisible(false);
+}
+
+HighlightSeries::~HighlightSeries()
+{
+}
+
+//! [0]
+void HighlightSeries::setTopographicSeries(TopographicSeries *series)
+{
+ m_topographicSeries = series;
+ m_srcWidth = m_topographicSeries->dataProxy()->array()->at(0)->size();
+ m_srcHeight = m_topographicSeries->dataProxy()->array()->size();
+
+ QObject::connect(m_topographicSeries, &QSurface3DSeries::selectedPointChanged,
+ this, &HighlightSeries::handlePositionChange);
+}
+//! [0]
+
+//! [1]
+void HighlightSeries::handlePositionChange(const QPoint &position)
+{
+ m_position = position;
+
+ if (position == invalidSelectionPosition()) {
+ setVisible(false);
+
+ return;
+ }
+
+ int halfWidth = m_width / 2;
+ int halfHeight = m_height / 2;
+
+ int startX = position.y() - halfWidth;
+ if (startX < 0 )
+ startX = 0;
+ int endX = position.y() + halfWidth;
+ if (endX > (m_srcWidth - 1))
+ endX = m_srcWidth - 1;
+ int startZ = position.x() - halfHeight;
+ if (startZ < 0 )
+ startZ = 0;
+ int endZ = position.x() + halfHeight;
+ if (endZ > (m_srcHeight - 1))
+ endZ = m_srcHeight - 1;
+
+ QSurfaceDataProxy *srcProxy = m_topographicSeries->dataProxy();
+ const QSurfaceDataArray &srcArray = *srcProxy->array();
+
+ QSurfaceDataArray *dataArray = new QSurfaceDataArray;
+ dataArray->reserve(endZ - startZ);
+ for (int i = startZ; i < endZ; i++) {
+ QSurfaceDataRow *newRow = new QSurfaceDataRow(endX - startX);
+ QSurfaceDataRow *srcRow = srcArray.at(i);
+ for (int j = startX, p = 0; j < endX; j++, p++) {
+ QVector3D pos = srcRow->at(j).position();
+ (*newRow)[p].setPosition(QVector3D(pos.x(), pos.y() + 0.1f, pos.z()));
+ }
+ *dataArray << newRow;
+ }
+
+ dataProxy()->resetArray(dataArray);
+ setVisible(true);
+}
+//! [1]
+
+//! [3]
+void HighlightSeries::handleGradientChange(float value)
+{
+ float ratio = m_minHeight / value;
+
+ QLinearGradient gr;
+ gr.setColorAt(0.0f, Qt::black);
+ gr.setColorAt(darkGreenPos * ratio, Qt::darkGreen);
+ gr.setColorAt(greenPos * ratio, Qt::green);
+ gr.setColorAt(yellowPos * ratio, Qt::yellow);
+ gr.setColorAt(redPos * ratio, Qt::red);
+ gr.setColorAt(darkRedPos * ratio, Qt::darkRed);
+
+ setBaseGradient(gr);
+ setColorStyle(Q3DTheme::ColorStyleRangeGradient);
+}
+//! [3]
diff --git a/examples/datavisualization/texturesurface/highlightseries.h b/examples/datavisualization/texturesurface/highlightseries.h
new file mode 100644
index 00000000..aa1590e5
--- /dev/null
+++ b/examples/datavisualization/texturesurface/highlightseries.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef HIGHLIGHTSERIES_H
+#define HIGHLIGHTSERIES_H
+
+#include <QtDataVisualization/QSurface3DSeries>
+
+#include "topographicseries.h"
+
+using namespace QtDataVisualization;
+
+class HighlightSeries : public QSurface3DSeries
+{
+ Q_OBJECT
+public:
+ explicit HighlightSeries();
+ ~HighlightSeries();
+
+ void setTopographicSeries(TopographicSeries *series);
+ inline void setMinHeight(float height) { m_minHeight = height; }
+
+public slots:
+ void handlePositionChange(const QPoint &position);
+ void handleGradientChange(float value);
+
+private:
+ int m_width;
+ int m_height;
+ int m_srcWidth;
+ int m_srcHeight;
+ QPoint m_position;
+ TopographicSeries *m_topographicSeries;
+ float m_minHeight;
+};
+
+#endif // HIGHLIGHTSERIES_H
diff --git a/examples/datavisualization/texturesurface/license.txt b/examples/datavisualization/texturesurface/license.txt
new file mode 100644
index 00000000..749daf31
--- /dev/null
+++ b/examples/datavisualization/texturesurface/license.txt
@@ -0,0 +1,77 @@
+License information regarding the data obtained from National Land Survey of
+Finland http://www.maanmittauslaitos.fi/en
+- topographic model from Elevation model 2 m (U4421B, U4421D, U4422A and
+ U4422C) 08/2014
+- map image extracted from Topographic map raster 1:50 000 (U442) 08/2014
+
+National Land Survey open data licence - version 1.0 - 1 May 2012
+
+1. General information
+
+The National Land Survey of Finland (hereinafter the Licensor), as the holder
+of the immaterial rights to the data, has granted on the terms mentioned below
+the right to use a copy (hereinafter data or dataset(s)) of the data (or a part
+of it).
+
+The Licensee is a natural or legal person who makes use of the data covered by
+this licence. The Licensee accepts the terms of this licence by receiving the
+dataset(s) covered by the licence.
+
+This Licence agreement does not create a co-operation or business relationship
+between the Licensee and the Licensor.
+
+2. Terms of the licence
+
+2.1. Right of use
+
+This licence grants a worldwide, free of charge and irrevocable parallel right
+of use to open data. According to the terms of the licence, data received by
+the Licensee can be freely:
+ - copied, distributed and published,
+ - modified and utilised commercially and non-commercially,
+ - inserted into other products and
+ - used as a part of a software application or service.
+
+2.2. Duties and responsibilities of the Licensee
+
+Through reasonable means suitable to the distribution medium or method which is
+used in conjunction with a product containing data or a service utilising data
+covered by this licence or while distributing data, the Licensee shall:
+ - mention the name of the Licensor, the name of the dataset(s) and the time
+ when the National Land Survey has delivered the dataset(s) (e.g.: contains
+ data from the National Land Survey of Finland Topographic Database 06/2012)
+ - provide a copy of this licence or a link to it, as well as
+ - require third parties to provide the same information when granting rights
+ to copies of dataset(s) or products and services containing such data and
+ - remove the name of the Licensor from the product or service, if required to
+ do so by the Licensor.
+
+The terms of this licence do not allow the Licensee to state in conjunction
+with the use of dataset(s) that the Licensor supports or recommends such use.
+
+2.3. Duties and responsibilities of the Licensor
+
+The Licensor shall ensure that
+ - the Licensor has the right to grant rights to the dataset(s) in accordance
+ with this licence.
+
+The data has been licensed "as is" and the Licensor
+ - shall not be held responsible for any errors or omissions in the data,
+ disclaims any warranty for the validity or up to date status of the data and
+ shall be free from liability for direct or consequential damages arising
+ from the use of data provided by the Licensor,
+ - and is not obligated to ensure the continuous availability of the data, nor
+ to announce in advance the interruption or cessation of availability, and
+ the Licensor shall be free from liability for direct or consequential
+ damages arising from any such interruption or cessation.
+
+3. Jurisdiction
+
+Finnish law shall apply to this licence.
+
+4. Changes to this licence
+
+The Licensor may at any time change the terms of the licence or apply a
+different licence to the data. The terms of this licence shall, however, still
+apply to such data that has been received prior to the change of the terms of
+the licence or the licence itself.
diff --git a/examples/datavisualization/texturesurface/main.cpp b/examples/datavisualization/texturesurface/main.cpp
new file mode 100644
index 00000000..ed1a9be4
--- /dev/null
+++ b/examples/datavisualization/texturesurface/main.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "surfacegraph.h"
+
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QGroupBox>
+#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QLabel>
+#include <QtGui/QScreen>
+#include <QtGui/QPainter>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ Q3DSurface *graph = new Q3DSurface();
+ QWidget *container = QWidget::createWindowContainer(graph);
+
+ QSize screenSize = graph->screen()->size();
+ container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6));
+ container->setMaximumSize(screenSize);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ container->setFocusPolicy(Qt::StrongFocus);
+
+ QWidget *widget = new QWidget;
+ QHBoxLayout *hLayout = new QHBoxLayout(widget);
+ QVBoxLayout *vLayout = new QVBoxLayout();
+ hLayout->addWidget(container, 1);
+ hLayout->addLayout(vLayout);
+ vLayout->setAlignment(Qt::AlignTop);
+
+ widget->setWindowTitle(QStringLiteral("Textured surface example"));
+
+ QCheckBox *enableTexture = new QCheckBox(widget);
+ enableTexture->setText(QStringLiteral("Surface texture"));
+
+ int height = 400;
+ int width = 100;
+ int border = 10;
+ QLinearGradient gr(0, 0, 1, height - 2 * border);
+ gr.setColorAt(1.0f, Qt::black);
+ gr.setColorAt(0.8f, Qt::darkGreen);
+ gr.setColorAt(0.6f, Qt::green);
+ gr.setColorAt(0.4f, Qt::yellow);
+ gr.setColorAt(0.2f, Qt::red);
+ gr.setColorAt(0.0f, Qt::darkRed);
+
+ QPixmap pm(width, height);
+ pm.fill(Qt::transparent);
+ QPainter pmp(&pm);
+ pmp.setBrush(QBrush(gr));
+ pmp.setPen(Qt::NoPen);
+ pmp.drawRect(border, border, 35, height - 2 * border);
+ pmp.setPen(Qt::black);
+ int step = (height - 2 * border) / 5;
+ for (int i = 0; i < 6; i++) {
+ int yPos = i * step + border;
+ pmp.drawLine(border, yPos, 55, yPos);
+ pmp.drawText(60, yPos + 2, QString("%1 m").arg(550 - (i * 110)));
+ }
+
+ QLabel *label = new QLabel(widget);
+ label->setPixmap(pm);
+
+ QGroupBox *heightMapGroupBox = new QGroupBox(QStringLiteral("Height color map"));
+ QVBoxLayout *colorMapVBox = new QVBoxLayout;
+ colorMapVBox->addWidget(label);
+ heightMapGroupBox->setLayout(colorMapVBox);
+
+ vLayout->addWidget(enableTexture);
+ vLayout->addWidget(heightMapGroupBox);
+
+ widget->show();
+
+ SurfaceGraph *modifier = new SurfaceGraph(graph);
+
+ QObject::connect(enableTexture, &QCheckBox::stateChanged,
+ modifier, &SurfaceGraph::toggleSurfaceTexture);
+
+ enableTexture->setChecked(true);
+
+ return app.exec();
+}
diff --git a/examples/datavisualization/texturesurface/maptexture.jpg b/examples/datavisualization/texturesurface/maptexture.jpg
new file mode 100644
index 00000000..ae5d66eb
--- /dev/null
+++ b/examples/datavisualization/texturesurface/maptexture.jpg
Binary files differ
diff --git a/examples/datavisualization/texturesurface/surfacegraph.cpp b/examples/datavisualization/texturesurface/surfacegraph.cpp
new file mode 100644
index 00000000..e01a329d
--- /dev/null
+++ b/examples/datavisualization/texturesurface/surfacegraph.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "surfacegraph.h"
+#include "topographicseries.h"
+
+#include <QtDataVisualization/QValue3DAxis>
+#include <QtDataVisualization/Q3DTheme>
+
+using namespace QtDataVisualization;
+
+const float areaWidth = 8000.0f;
+const float areaHeight = 8000.0f;
+const float aspectRatio = 0.1389f;
+const float minRange = areaWidth * 0.49f;
+
+SurfaceGraph::SurfaceGraph(Q3DSurface *surface)
+ : m_graph(surface)
+{
+ m_graph->setAxisX(new QValue3DAxis);
+ m_graph->setAxisY(new QValue3DAxis);
+ m_graph->setAxisZ(new QValue3DAxis);
+ m_graph->axisX()->setLabelFormat("%i");
+ m_graph->axisZ()->setLabelFormat("%i");
+ m_graph->axisX()->setRange(0.0f, areaWidth);
+ m_graph->axisY()->setRange(100.0f, areaWidth * aspectRatio);
+ m_graph->axisZ()->setRange(0.0f, areaHeight);
+ m_graph->axisX()->setLabelAutoRotation(30);
+ m_graph->axisY()->setLabelAutoRotation(90);
+ m_graph->axisZ()->setLabelAutoRotation(30);
+ m_graph->activeTheme()->setType(Q3DTheme::ThemePrimaryColors);
+
+ QFont font = m_graph->activeTheme()->font();
+ font.setPointSize(20);
+ m_graph->activeTheme()->setFont(font);
+
+ m_topography = new TopographicSeries();
+ m_topography->setTopographyFile(":/maps/topography", areaWidth, areaHeight);
+ m_topography->setItemLabelFormat(QStringLiteral("@yLabel m"));
+
+ m_highlight = new HighlightSeries();
+ m_highlight->setTopographicSeries(m_topography);
+ m_highlight->setMinHeight(minRange * aspectRatio);
+ m_highlight->handleGradientChange(areaWidth * aspectRatio);
+//! [1]
+ QObject::connect(m_graph->axisY(), &QValue3DAxis::maxChanged,
+ m_highlight, &HighlightSeries::handleGradientChange);
+//! [1]
+
+ m_graph->addSeries(m_topography);
+ m_graph->addSeries(m_highlight);
+
+ m_inputHandler = new CustomInputHandler(m_graph);
+ m_inputHandler->setHighlightSeries(m_highlight);
+ m_inputHandler->setAxes(m_graph->axisX(), m_graph->axisY(), m_graph->axisZ());
+ m_inputHandler->setLimits(0.0f, areaWidth, minRange);
+ m_inputHandler->setAspectRatio(aspectRatio);
+
+ m_graph->setActiveInputHandler(m_inputHandler);
+}
+
+SurfaceGraph::~SurfaceGraph()
+{
+ delete m_graph;
+}
+
+//! [0]
+void SurfaceGraph::toggleSurfaceTexture(bool enable)
+{
+ if (enable)
+ m_topography->setTextureFile(":/maps/maptexture");
+ else
+ m_topography->setTextureFile("");
+}
+//! [0]
diff --git a/examples/datavisualization/texturesurface/surfacegraph.h b/examples/datavisualization/texturesurface/surfacegraph.h
new file mode 100644
index 00000000..c1d81595
--- /dev/null
+++ b/examples/datavisualization/texturesurface/surfacegraph.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef SURFACEGRAPH_H
+#define SURFACEGRAPH_H
+
+#include <QtDataVisualization/Q3DSurface>
+#include <QtDataVisualization/QSurface3DSeries>
+#include <QtWidgets/QSlider>
+#include "topographicseries.h"
+#include "highlightseries.h"
+
+#include "custominputhandler.h"
+
+using namespace QtDataVisualization;
+
+class SurfaceGraph : public QObject
+{
+ Q_OBJECT
+public:
+ explicit SurfaceGraph(Q3DSurface *surface);
+ ~SurfaceGraph();
+
+ void toggleSurfaceTexture(bool enable);
+
+private:
+ Q3DSurface *m_graph;
+
+ TopographicSeries *m_topography;
+ HighlightSeries *m_highlight;
+ int m_highlightWidth;
+ int m_highlightHeight;
+
+ CustomInputHandler *m_inputHandler;
+};
+
+#endif // SURFACEGRAPH_H
diff --git a/examples/datavisualization/texturesurface/texturedsurface.qrc b/examples/datavisualization/texturesurface/texturedsurface.qrc
new file mode 100644
index 00000000..94b96d24
--- /dev/null
+++ b/examples/datavisualization/texturesurface/texturedsurface.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/maps">
+ <file alias="topography">topography.png</file>
+ <file alias="maptexture">maptexture.jpg</file>
+ </qresource>
+</RCC>
diff --git a/examples/datavisualization/texturesurface/texturesurface.pro b/examples/datavisualization/texturesurface/texturesurface.pro
new file mode 100644
index 00000000..f24c3d17
--- /dev/null
+++ b/examples/datavisualization/texturesurface/texturesurface.pro
@@ -0,0 +1,25 @@
+android|ios {
+ error( "This example is not supported for android or ios." )
+}
+
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+SOURCES += main.cpp \
+ surfacegraph.cpp \
+ topographicseries.cpp \
+ highlightseries.cpp \
+ custominputhandler.cpp
+
+HEADERS += surfacegraph.h \
+ topographicseries.h \
+ highlightseries.h \
+ custominputhandler.h
+
+QT += widgets
+
+RESOURCES += texturedsurface.qrc
+
+OTHER_FILES += doc/src/* \
+ doc/images/*
diff --git a/examples/datavisualization/texturesurface/topographicseries.cpp b/examples/datavisualization/texturesurface/topographicseries.cpp
new file mode 100644
index 00000000..530e56b4
--- /dev/null
+++ b/examples/datavisualization/texturesurface/topographicseries.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "topographicseries.h"
+
+using namespace QtDataVisualization;
+
+//! [0]
+// Value used to encode height data as RGB value on PNG file
+const float packingFactor = 11983.0f;
+//! [0]
+
+TopographicSeries::TopographicSeries()
+{
+ setDrawMode(QSurface3DSeries::DrawSurface);
+ setFlatShadingEnabled(true);
+}
+
+TopographicSeries::~TopographicSeries()
+{
+}
+
+void TopographicSeries::setTopographyFile(const QString file, float width, float height)
+{
+//! [1]
+ QImage heightMapImage(file);
+ uchar *bits = heightMapImage.bits();
+ int imageHeight = heightMapImage.height();
+ int imageWidth = heightMapImage.width();
+ int widthBits = imageWidth * 4;
+ float stepX = width / float(imageWidth);
+ float stepZ = height / float(imageHeight);
+
+ QSurfaceDataArray *dataArray = new QSurfaceDataArray;
+ dataArray->reserve(imageHeight);
+ for (int i = 0; i < imageHeight; i++) {
+ int p = i * widthBits;
+ float z = height - float(i) * stepZ;
+ QSurfaceDataRow *newRow = new QSurfaceDataRow(imageWidth);
+ for (int j = 0; j < imageWidth; j++) {
+ uchar aa = bits[p + 0];
+ uchar rr = bits[p + 1];
+ uchar gg = bits[p + 2];
+ uint color = uint((gg << 16) + (rr << 8) + aa);
+ float y = float(color) / packingFactor;
+ (*newRow)[j].setPosition(QVector3D(float(j) * stepX, y, z));
+ p = p + 4;
+ }
+ *dataArray << newRow;
+ }
+
+ dataProxy()->resetArray(dataArray);
+//! [1]
+
+ m_sampleCountX = float(imageWidth);
+ m_sampleCountZ = float(imageHeight);
+}
diff --git a/examples/datavisualization/texturesurface/topographicseries.h b/examples/datavisualization/texturesurface/topographicseries.h
new file mode 100644
index 00000000..06530c63
--- /dev/null
+++ b/examples/datavisualization/texturesurface/topographicseries.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef TOPOGRAPHICSERIES_H
+#define TOPOGRAPHICSERIES_H
+
+#include <QtDataVisualization/QSurface3DSeries>
+
+using namespace QtDataVisualization;
+
+class TopographicSeries : public QSurface3DSeries
+{
+ Q_OBJECT
+public:
+ explicit TopographicSeries();
+ ~TopographicSeries();
+
+ void setTopographyFile(const QString file, float width, float height);
+
+ float sampleCountX() { return m_sampleCountX; }
+ float sampleCountZ() { return m_sampleCountZ; }
+
+public slots:
+
+private:
+ float m_sampleCountX;
+ float m_sampleCountZ;
+};
+
+#endif // TOPOGRAPHICSERIES_H
diff --git a/examples/datavisualization/texturesurface/topography.png b/examples/datavisualization/texturesurface/topography.png
new file mode 100644
index 00000000..9349cdb3
--- /dev/null
+++ b/examples/datavisualization/texturesurface/topography.png
Binary files differ
diff --git a/examples/datavisualization/volumetric/doc/images/volumetric-example.png b/examples/datavisualization/volumetric/doc/images/volumetric-example.png
new file mode 100644
index 00000000..277d4fe4
--- /dev/null
+++ b/examples/datavisualization/volumetric/doc/images/volumetric-example.png
Binary files differ
diff --git a/examples/datavisualization/volumetric/doc/src/volumetric.qdoc b/examples/datavisualization/volumetric/doc/src/volumetric.qdoc
new file mode 100644
index 00000000..39616670
--- /dev/null
+++ b/examples/datavisualization/volumetric/doc/src/volumetric.qdoc
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+/*!
+ \example volumetric
+ \title Volumetric rendering Example
+ \ingroup qtdatavisualization_examples
+ \brief Rendering volumetric objects.
+ \since QtDataVisualization 1.2
+
+ This example shows how to use QCustom3DVolume items to display volumetric data.
+
+ \image volumetric-example.png
+
+ \section1 Initializing volume item
+
+ The QCustom3DVolume items are special custom items (see QCustom3DItem), which can be used
+ to display volumetric data. The volume items are only supported with orthographic projection,
+ so first we make sure the graph is using it:
+
+ \snippet volumetric/volumetric.cpp 6
+
+ The following code shows how to create a volumetric item tied to the data ranges of the axes:
+
+ \snippet volumetric/volumetric.cpp 0
+
+ By setting the QCustom3DItem::scalingAbsolute property to \c{false}, we indicate that the
+ scaling of the volume should follow the changes in the data ranges. Next we define the
+ internal contents of the volume:
+
+ \snippet volumetric/volumetric.cpp 1
+
+ We use eight bit indexed color for our texture, as it is compact and makes it easy to adjust the
+ colors without needing to reset the whole texture. For the texture data we use the data we
+ created earlier based on some height maps.
+ Typically the data for volume items comes pregenerated in a form of a stack of images, so we are
+ not going to explain the data generation in detail. Please refer to the example code if you
+ are interested in the actual data generation process.
+
+ Since we are using eight bit indexed colors, we need a color table to map the eight bit color
+ indexes to actual colors. We use one we populated on our own, but in a typical use case you
+ would get the color table from the source images:
+
+ \snippet volumetric/volumetric.cpp 2
+
+ We want to optionally show slice frames around the volume, so we initialize their properties.
+ Initially, the frames will be hidden:
+
+ \snippet volumetric/volumetric.cpp 5
+
+ Finally we add the volume as a custom item to the graph to display it:
+
+ \snippet volumetric/volumetric.cpp 3
+
+ \section1 Slicing into the volume
+
+ Unless the volume is largely transparent, you can only see the surface of it, which is often
+ not very helpful. One way to inspect the internal structure of the volume is to view the slices
+ of the volume. QCustom3DVolume provides two ways to display the slices. The first is to show
+ the selected slices in place of the volume. For example, to specify a slice perpendicular to
+ the X-axis, you can use the following method:
+
+ \snippet volumetric/volumetric.cpp 7
+
+ To actually draw the slice specified above, the QCustom3DVolume::drawSlices property must be
+ also set:
+
+ \snippet volumetric/volumetric.cpp 8
+
+ The second way to view slices is to use QCustom3DVolume::renderSlice() method, which produces
+ a QImage from the specified slice. This image can then be displayed on another widget, such
+ as a QLabel here:
+
+ \snippet volumetric/volumetric.cpp 9
+
+ \section1 Adjusting volume transparency
+
+ Sometimes viewing just the slices doesn't give you a good understanding of the volume's internal
+ structure. QCustom3DVolume provides two properties that can be used to adjust the volume
+ transparency:
+
+ \snippet volumetric/volumetric.cpp 11
+ \dots
+ \snippet volumetric/volumetric.cpp 10
+
+ The QCustom3DVolume::alphaMultiplier is a general multiplier that is applied to the alpha value
+ of each voxel of the volume. It makes it possible to add uniform transparency to the already
+ somewhat transparent portions of the volume to reveal internal opaque details. This multiplier
+ doesn't affect colors that are fully opaque, unless the QCustom3DVolume::preserveOpacity
+ property is set to \c{false}.
+
+ An alternative way to adjust the transparency of the volume is adjust the alpha values of the
+ voxels directly. For eight bit indexed textures, this is done simply by modifying and
+ resetting the color table:
+
+ \snippet volumetric/volumetric.cpp 12
+
+ \section1 High definition vs. low definition shader
+
+ By default the volume rendering uses the high definition shader. It accounts for each
+ voxel of the volume with correct weight when ray-tracing the volume contents,
+ providing an accurate representation of even the finer details of the volume.
+ However, this is computationally very expensive, so the frame rate suffers.
+ If rendering speed is more important than pixel-perfect
+ accuracy of the volume contents, you can take the much faster low definition shader into use
+ by setting \c{false} for QCustom3DVolume::useHighDefShader property. The low definition shader
+ achieves the speed by making compromises on the accuracy, so it doesn't guarantee each voxel
+ of the volume will be sampled. This can lead to flickering and/or other rendering artifacts
+ on the finer details of the volume.
+
+ \snippet volumetric/volumetric.cpp 13
+
+ \section1 Example contents
+*/
diff --git a/examples/datavisualization/volumetric/layer_ground.png b/examples/datavisualization/volumetric/layer_ground.png
new file mode 100644
index 00000000..3f96a122
--- /dev/null
+++ b/examples/datavisualization/volumetric/layer_ground.png
Binary files differ
diff --git a/examples/datavisualization/volumetric/layer_magma.png b/examples/datavisualization/volumetric/layer_magma.png
new file mode 100644
index 00000000..01434d35
--- /dev/null
+++ b/examples/datavisualization/volumetric/layer_magma.png
Binary files differ
diff --git a/examples/datavisualization/volumetric/layer_water.png b/examples/datavisualization/volumetric/layer_water.png
new file mode 100644
index 00000000..4d57563e
--- /dev/null
+++ b/examples/datavisualization/volumetric/layer_water.png
Binary files differ
diff --git a/examples/datavisualization/volumetric/main.cpp b/examples/datavisualization/volumetric/main.cpp
new file mode 100644
index 00000000..faf379ec
--- /dev/null
+++ b/examples/datavisualization/volumetric/main.cpp
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "volumetric.h"
+
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QRadioButton>
+#include <QtWidgets/QSlider>
+#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QGroupBox>
+#include <QtGui/QScreen>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ Q3DScatter *graph = new Q3DScatter();
+ QWidget *container = QWidget::createWindowContainer(graph);
+
+ QSize screenSize = graph->screen()->size();
+ container->setMinimumSize(QSize(screenSize.width() / 3, screenSize.height() / 3));
+ container->setMaximumSize(screenSize);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ container->setFocusPolicy(Qt::StrongFocus);
+
+ QWidget *widget = new QWidget();
+ QHBoxLayout *hLayout = new QHBoxLayout(widget);
+ QVBoxLayout *vLayout = new QVBoxLayout();
+ QVBoxLayout *vLayout2 = new QVBoxLayout();
+ hLayout->addWidget(container, 1);
+ hLayout->addLayout(vLayout);
+ hLayout->addLayout(vLayout2);
+
+ widget->setWindowTitle(QStringLiteral("Volumetric object example - 3D terrain"));
+
+ QCheckBox *sliceXCheckBox = new QCheckBox(widget);
+ sliceXCheckBox->setText(QStringLiteral("Slice volume on X axis"));
+ sliceXCheckBox->setChecked(false);
+ QCheckBox *sliceYCheckBox = new QCheckBox(widget);
+ sliceYCheckBox->setText(QStringLiteral("Slice volume on Y axis"));
+ sliceYCheckBox->setChecked(false);
+ QCheckBox *sliceZCheckBox = new QCheckBox(widget);
+ sliceZCheckBox->setText(QStringLiteral("Slice volume on Z axis"));
+ sliceZCheckBox->setChecked(false);
+
+ QSlider *sliceXSlider = new QSlider(Qt::Horizontal, widget);
+ sliceXSlider->setMinimum(0);
+ sliceXSlider->setMaximum(1024);
+ sliceXSlider->setValue(512);
+ sliceXSlider->setEnabled(true);
+ QSlider *sliceYSlider = new QSlider(Qt::Horizontal, widget);
+ sliceYSlider->setMinimum(0);
+ sliceYSlider->setMaximum(1024);
+ sliceYSlider->setValue(512);
+ sliceYSlider->setEnabled(true);
+ QSlider *sliceZSlider = new QSlider(Qt::Horizontal, widget);
+ sliceZSlider->setMinimum(0);
+ sliceZSlider->setMaximum(1024);
+ sliceZSlider->setValue(512);
+ sliceZSlider->setEnabled(true);
+
+ QCheckBox *fpsCheckBox = new QCheckBox(widget);
+ fpsCheckBox->setText(QStringLiteral("Show FPS"));
+ fpsCheckBox->setChecked(false);
+ QLabel *fpsLabel = new QLabel(QStringLiteral(""), widget);
+
+ QGroupBox *textureDetailGroupBox = new QGroupBox(QStringLiteral("Texture detail"));
+
+ QRadioButton *lowDetailRB = new QRadioButton(widget);
+ lowDetailRB->setText(QStringLiteral("Low (128x64x128)"));
+ lowDetailRB->setChecked(true);
+
+ QRadioButton *mediumDetailRB = new QRadioButton(widget);
+ mediumDetailRB->setText(QStringLiteral("Generating..."));
+ mediumDetailRB->setChecked(false);
+ mediumDetailRB->setEnabled(false);
+
+ QRadioButton *highDetailRB = new QRadioButton(widget);
+ highDetailRB->setText(QStringLiteral("Generating..."));
+ highDetailRB->setChecked(false);
+ highDetailRB->setEnabled(false);
+
+ QVBoxLayout *textureDetailVBox = new QVBoxLayout;
+ textureDetailVBox->addWidget(lowDetailRB);
+ textureDetailVBox->addWidget(mediumDetailRB);
+ textureDetailVBox->addWidget(highDetailRB);
+ textureDetailGroupBox->setLayout(textureDetailVBox);
+
+ QGroupBox *areaGroupBox = new QGroupBox(QStringLiteral("Show area"));
+
+ QRadioButton *areaAllRB = new QRadioButton(widget);
+ areaAllRB->setText(QStringLiteral("Whole region"));
+ areaAllRB->setChecked(true);
+
+ QRadioButton *areaMineRB = new QRadioButton(widget);
+ areaMineRB->setText(QStringLiteral("The mine"));
+ areaMineRB->setChecked(false);
+
+ QRadioButton *areaMountainRB = new QRadioButton(widget);
+ areaMountainRB->setText(QStringLiteral("The mountain"));
+ areaMountainRB->setChecked(false);
+
+ QVBoxLayout *areaVBox = new QVBoxLayout;
+ areaVBox->addWidget(areaAllRB);
+ areaVBox->addWidget(areaMineRB);
+ areaVBox->addWidget(areaMountainRB);
+ areaGroupBox->setLayout(areaVBox);
+
+ QCheckBox *colorTableCheckBox = new QCheckBox(widget);
+ colorTableCheckBox->setText(QStringLiteral("Alternate color table"));
+ colorTableCheckBox->setChecked(false);
+
+ QLabel *sliceImageXLabel = new QLabel(widget);
+ QLabel *sliceImageYLabel = new QLabel(widget);
+ QLabel *sliceImageZLabel = new QLabel(widget);
+ sliceImageXLabel->setMinimumSize(QSize(200, 100));
+ sliceImageYLabel->setMinimumSize(QSize(200, 200));
+ sliceImageZLabel->setMinimumSize(QSize(200, 100));
+ sliceImageXLabel->setMaximumSize(QSize(200, 100));
+ sliceImageYLabel->setMaximumSize(QSize(200, 200));
+ sliceImageZLabel->setMaximumSize(QSize(200, 100));
+ sliceImageXLabel->setFrameShape(QFrame::Box);
+ sliceImageYLabel->setFrameShape(QFrame::Box);
+ sliceImageZLabel->setFrameShape(QFrame::Box);
+ sliceImageXLabel->setScaledContents(true);
+ sliceImageYLabel->setScaledContents(true);
+ sliceImageZLabel->setScaledContents(true);
+
+ QSlider *alphaMultiplierSlider = new QSlider(Qt::Horizontal, widget);
+ alphaMultiplierSlider->setMinimum(0);
+ alphaMultiplierSlider->setMaximum(139);
+ alphaMultiplierSlider->setValue(100);
+ alphaMultiplierSlider->setEnabled(true);
+ QLabel *alphaMultiplierLabel = new QLabel(QStringLiteral("Alpha multiplier: 1.0"));
+
+ QCheckBox *preserveOpacityCheckBox = new QCheckBox(widget);
+ preserveOpacityCheckBox->setText(QStringLiteral("Preserve opacity"));
+ preserveOpacityCheckBox->setChecked(true);
+
+ QCheckBox *transparentGroundCheckBox = new QCheckBox(widget);
+ transparentGroundCheckBox->setText(QStringLiteral("Transparent ground"));
+ transparentGroundCheckBox->setChecked(false);
+
+ QCheckBox *useHighDefShaderCheckBox = new QCheckBox(widget);
+ useHighDefShaderCheckBox->setText(QStringLiteral("Use HD shader"));
+ useHighDefShaderCheckBox->setChecked(true);
+
+ QLabel *performanceNoteLabel =
+ new QLabel(QStringLiteral(
+ "Note: A high end graphics card is\nrecommended with the HD shader\nwhen the volume contains a lot of\ntransparent areas."));
+ performanceNoteLabel->setFrameShape(QFrame::Box);
+
+ QCheckBox *drawSliceFramesCheckBox = new QCheckBox(widget);
+ drawSliceFramesCheckBox->setText(QStringLiteral("Draw slice frames"));
+ drawSliceFramesCheckBox->setChecked(false);
+
+ vLayout->addWidget(sliceXCheckBox);
+ vLayout->addWidget(sliceXSlider);
+ vLayout->addWidget(sliceImageXLabel);
+ vLayout->addWidget(sliceYCheckBox);
+ vLayout->addWidget(sliceYSlider);
+ vLayout->addWidget(sliceImageYLabel);
+ vLayout->addWidget(sliceZCheckBox);
+ vLayout->addWidget(sliceZSlider);
+ vLayout->addWidget(sliceImageZLabel);
+ vLayout->addWidget(drawSliceFramesCheckBox, 1, Qt::AlignTop);
+ vLayout2->addWidget(fpsCheckBox);
+ vLayout2->addWidget(fpsLabel);
+ vLayout2->addWidget(textureDetailGroupBox);
+ vLayout2->addWidget(areaGroupBox);
+ vLayout2->addWidget(colorTableCheckBox);
+ vLayout2->addWidget(alphaMultiplierLabel);
+ vLayout2->addWidget(alphaMultiplierSlider);
+ vLayout2->addWidget(preserveOpacityCheckBox);
+ vLayout2->addWidget(transparentGroundCheckBox);
+ vLayout2->addWidget(useHighDefShaderCheckBox);
+ vLayout2->addWidget(performanceNoteLabel, 1, Qt::AlignTop);
+
+ VolumetricModifier *modifier = new VolumetricModifier(graph);
+ modifier->setFpsLabel(fpsLabel);
+ modifier->setMediumDetailRB(mediumDetailRB);
+ modifier->setHighDetailRB(highDetailRB);
+ modifier->setSliceSliders(sliceXSlider, sliceYSlider, sliceZSlider);
+ modifier->setSliceLabels(sliceImageXLabel, sliceImageYLabel, sliceImageZLabel);
+ modifier->setAlphaMultiplierLabel(alphaMultiplierLabel);
+ modifier->setTransparentGround(transparentGroundCheckBox->isChecked());
+
+ QObject::connect(fpsCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::setFpsMeasurement);
+ QObject::connect(sliceXCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::sliceX);
+ QObject::connect(sliceYCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::sliceY);
+ QObject::connect(sliceZCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::sliceZ);
+ QObject::connect(sliceXSlider, &QSlider::valueChanged, modifier,
+ &VolumetricModifier::adjustSliceX);
+ QObject::connect(sliceYSlider, &QSlider::valueChanged, modifier,
+ &VolumetricModifier::adjustSliceY);
+ QObject::connect(sliceZSlider, &QSlider::valueChanged, modifier,
+ &VolumetricModifier::adjustSliceZ);
+ QObject::connect(lowDetailRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleLowDetail);
+ QObject::connect(mediumDetailRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleMediumDetail);
+ QObject::connect(highDetailRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleHighDetail);
+ QObject::connect(colorTableCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::changeColorTable);
+ QObject::connect(preserveOpacityCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::setPreserveOpacity);
+ QObject::connect(transparentGroundCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::setTransparentGround);
+ QObject::connect(useHighDefShaderCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::setUseHighDefShader);
+ QObject::connect(alphaMultiplierSlider, &QSlider::valueChanged, modifier,
+ &VolumetricModifier::adjustAlphaMultiplier);
+ QObject::connect(areaAllRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleAreaAll);
+ QObject::connect(areaMineRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleAreaMine);
+ QObject::connect(areaMountainRB, &QRadioButton::toggled, modifier,
+ &VolumetricModifier::toggleAreaMountain);
+ QObject::connect(drawSliceFramesCheckBox, &QCheckBox::stateChanged, modifier,
+ &VolumetricModifier::setDrawSliceFrames);
+
+ widget->show();
+ return app.exec();
+}
diff --git a/examples/datavisualization/volumetric/volumetric.cpp b/examples/datavisualization/volumetric/volumetric.cpp
new file mode 100644
index 00000000..20338598
--- /dev/null
+++ b/examples/datavisualization/volumetric/volumetric.cpp
@@ -0,0 +1,764 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "volumetric.h"
+#include <QtDataVisualization/qvalue3daxis.h>
+#include <QtDataVisualization/q3dscene.h>
+#include <QtDataVisualization/q3dcamera.h>
+#include <QtDataVisualization/q3dtheme.h>
+#include <QtDataVisualization/qcustom3dlabel.h>
+#include <QtDataVisualization/q3dscatter.h>
+#include <QtDataVisualization/q3dinputhandler.h>
+#include <QtCore/qmath.h>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QRadioButton>
+#include <QtWidgets/QSlider>
+#include <QtCore/QDebug>
+#include <QtGui/QOpenGLContext>
+
+using namespace QtDataVisualization;
+
+const int lowDetailSize(128);
+const int mediumDetailSize(256);
+const int highDetailSize(512);
+const int colorTableSize(256);
+const int layerDataSize(512);
+const int mineShaftDiameter(1);
+
+const int airColorIndex(254);
+const int mineShaftColorIndex(255);
+const int layerColorThickness(60);
+const int heightToColorDiv(140);
+const int magmaColorsMin(0);
+const int magmaColorsMax(layerColorThickness);
+const int aboveWaterGroundColorsMin(magmaColorsMax + 1);
+const int aboveWaterGroundColorsMax(aboveWaterGroundColorsMin + layerColorThickness);
+const int underWaterGroundColorsMin(aboveWaterGroundColorsMax + 1);
+const int underWaterGroundColorsMax(underWaterGroundColorsMin + layerColorThickness);
+const int waterColorsMin(underWaterGroundColorsMax + 1);
+const int waterColorsMax(waterColorsMin + layerColorThickness);
+const int terrainTransparency(12);
+
+static bool isOpenGLES()
+{
+#if defined(QT_OPENGL_ES_2)
+ return true;
+#elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
+ return false;
+#else
+ return QOpenGLContext::currentContext()->isOpenGLES();
+#endif
+}
+
+VolumetricModifier::VolumetricModifier(Q3DScatter *scatter)
+ : m_graph(scatter),
+ m_volumeItem(0),
+ m_sliceIndexX(lowDetailSize / 2),
+ m_sliceIndexY(lowDetailSize / 4),
+ m_sliceIndexZ(lowDetailSize / 2),
+ m_slicingX(false),
+ m_slicingY(false),
+ m_slicingZ(false),
+ m_mediumDetailRB(0),
+ m_highDetailRB(0),
+ m_lowDetailData(0),
+ m_mediumDetailData(0),
+ m_highDetailData(0),
+ m_mediumDetailIndex(0),
+ m_highDetailIndex(0),
+ m_mediumDetailShaftIndex(0),
+ m_highDetailShaftIndex(0),
+ m_sliceSliderX(0),
+ m_sliceSliderY(0),
+ m_sliceSliderZ(0),
+ m_usingPrimaryTable(true),
+ m_sliceLabelX(0),
+ m_sliceLabelY(0),
+ m_sliceLabelZ(0)
+{
+ m_graph->activeTheme()->setType(Q3DTheme::ThemeQt);
+ m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityNone);
+ m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront);
+ //! [6]
+ m_graph->setOrthoProjection(true);
+ //! [6]
+ m_graph->activeTheme()->setBackgroundEnabled(false);
+
+ // Only allow zooming at the center and limit the zoom to 200% to avoid clipping issues
+ static_cast<Q3DInputHandler *>(m_graph->activeInputHandler())->setZoomAtTargetEnabled(false);
+ m_graph->scene()->activeCamera()->setMaxZoomLevel(200.0f);
+
+ toggleAreaAll(true);
+
+ if (!isOpenGLES()) {
+ m_lowDetailData = new QVector<uchar>(lowDetailSize * lowDetailSize * lowDetailSize / 2);
+ m_mediumDetailData = new QVector<uchar>(mediumDetailSize * mediumDetailSize * mediumDetailSize / 2);
+ m_highDetailData = new QVector<uchar>(highDetailSize * highDetailSize * highDetailSize / 2);
+
+ initHeightMap(QStringLiteral(":/heightmaps/layer_ground.png"), m_groundLayer);
+ initHeightMap(QStringLiteral(":/heightmaps/layer_water.png"), m_waterLayer);
+ initHeightMap(QStringLiteral(":/heightmaps/layer_magma.png"), m_magmaLayer);
+
+ initMineShaftArray();
+
+ createVolume(lowDetailSize, 0, lowDetailSize, m_lowDetailData);
+ excavateMineShaft(lowDetailSize, 0, m_mineShaftArray.size(), m_lowDetailData);
+
+ //! [0]
+ m_volumeItem = new QCustom3DVolume;
+ // Adjust water level to zero with a minor tweak to y-coordinate position and scaling
+ m_volumeItem->setScaling(
+ QVector3D(m_graph->axisX()->max() - m_graph->axisX()->min(),
+ (m_graph->axisY()->max() - m_graph->axisY()->min()) * 0.91f,
+ m_graph->axisZ()->max() - m_graph->axisZ()->min()));
+ m_volumeItem->setPosition(
+ QVector3D((m_graph->axisX()->max() + m_graph->axisX()->min()) / 2.0f,
+ -0.045f * (m_graph->axisY()->max() - m_graph->axisY()->min()) +
+ (m_graph->axisY()->max() + m_graph->axisY()->min()) / 2.0f,
+ (m_graph->axisZ()->max() + m_graph->axisZ()->min()) / 2.0f));
+ m_volumeItem->setScalingAbsolute(false);
+ //! [0]
+ //! [1]
+ m_volumeItem->setTextureWidth(lowDetailSize);
+ m_volumeItem->setTextureHeight(lowDetailSize / 2);
+ m_volumeItem->setTextureDepth(lowDetailSize);
+ m_volumeItem->setTextureFormat(QImage::Format_Indexed8);
+ m_volumeItem->setTextureData(new QVector<uchar>(*m_lowDetailData));
+ //! [1]
+
+ // Generate color tables.
+ m_colorTable1.resize(colorTableSize);
+ m_colorTable2.resize(colorTableSize);
+
+ for (int i = 0; i < colorTableSize - 2; i++) {
+ if (i < magmaColorsMax) {
+ m_colorTable1[i] = qRgba(130 - (i * 2), 0, 0, 255);
+ } else if (i < aboveWaterGroundColorsMax) {
+ m_colorTable1[i] = qRgba((i - magmaColorsMax) * 4,
+ ((i - magmaColorsMax) * 2) + 120,
+ (i - magmaColorsMax) * 5, terrainTransparency);
+ } else if (i < underWaterGroundColorsMax) {
+ m_colorTable1[i] = qRgba(((layerColorThickness - i - aboveWaterGroundColorsMax)) + 70,
+ ((layerColorThickness - i - aboveWaterGroundColorsMax) * 2) + 20,
+ ((layerColorThickness - i - aboveWaterGroundColorsMax)) + 50,
+ terrainTransparency);
+ } else if (i < waterColorsMax) {
+ m_colorTable1[i] = qRgba(0, 0, ((i - underWaterGroundColorsMax) * 2) + 120,
+ terrainTransparency);
+ } else {
+ m_colorTable1[i] = qRgba(0, 0, 0, 0); // Not used
+ }
+ }
+ m_colorTable1[airColorIndex] = qRgba(0, 0, 0, 0);
+ m_colorTable1[mineShaftColorIndex] = qRgba(50, 50, 50, 255);
+
+ // The alternate color table just has gray gradients for all terrain except water
+ for (int i = 0; i < colorTableSize - 2; i++) {
+ if (i < magmaColorsMax) {
+ m_colorTable2[i] = qRgba(((i - aboveWaterGroundColorsMax) * 2),
+ ((i - aboveWaterGroundColorsMax) * 2),
+ ((i - aboveWaterGroundColorsMax) * 2), 255);
+ } else if (i < underWaterGroundColorsMax) {
+ m_colorTable2[i] = qRgba(((i - aboveWaterGroundColorsMax) * 2),
+ ((i - aboveWaterGroundColorsMax) * 2),
+ ((i - aboveWaterGroundColorsMax) * 2), terrainTransparency);
+ } else if (i < waterColorsMax) {
+ m_colorTable2[i] = qRgba(0, 0, ((i - underWaterGroundColorsMax) * 2) + 120,
+ terrainTransparency);
+ } else {
+ m_colorTable2[i] = qRgba(0, 0, 0, 0); // Not used
+ }
+ }
+ m_colorTable2[airColorIndex] = qRgba(0, 0, 0, 0);
+ m_colorTable2[mineShaftColorIndex] = qRgba(255, 255, 0, 255);
+
+ //! [2]
+ m_volumeItem->setColorTable(m_colorTable1);
+ //! [2]
+
+ //! [5]
+ m_volumeItem->setSliceFrameGaps(QVector3D(0.01f, 0.02f, 0.01f));
+ m_volumeItem->setSliceFrameThicknesses(QVector3D(0.0025f, 0.005f, 0.0025f));
+ m_volumeItem->setSliceFrameWidths(QVector3D(0.0025f, 0.005f, 0.0025f));
+ m_volumeItem->setDrawSliceFrames(false);
+ //! [5]
+ handleSlicingChanges();
+
+ //! [3]
+ m_graph->addCustomItem(m_volumeItem);
+ //! [3]
+
+ m_timer.start(0);
+ } else {
+ // OpenGL ES2 doesn't support 3D textures, so show a warning label instead
+ QCustom3DLabel *warningLabel = new QCustom3DLabel(
+ "QCustom3DVolume is not supported with OpenGL ES2",
+ QFont(),
+ QVector3D(0.0f, 0.5f, 0.0f),
+ QVector3D(1.5f, 1.5f, 0.0f),
+ QQuaternion());
+ warningLabel->setPositionAbsolute(true);
+ warningLabel->setFacingCamera(true);
+ m_graph->addCustomItem(warningLabel);
+ }
+
+ QObject::connect(m_graph, &QAbstract3DGraph::currentFpsChanged, this,
+ &VolumetricModifier::handleFpsChange);
+ QObject::connect(&m_timer, &QTimer::timeout, this,
+ &VolumetricModifier::handleTimeout);
+
+}
+
+VolumetricModifier::~VolumetricModifier()
+{
+ delete m_graph;
+}
+
+void VolumetricModifier::setFpsLabel(QLabel *fpsLabel)
+{
+ m_fpsLabel = fpsLabel;
+}
+
+void VolumetricModifier::setMediumDetailRB(QRadioButton *button)
+{
+ m_mediumDetailRB = button;
+}
+
+void VolumetricModifier::setHighDetailRB(QRadioButton *button)
+{
+ m_highDetailRB = button;
+}
+
+void VolumetricModifier::setSliceLabels(QLabel *xLabel, QLabel *yLabel, QLabel *zLabel)
+{
+ m_sliceLabelX = xLabel;
+ m_sliceLabelY = yLabel;
+ m_sliceLabelZ = zLabel;
+
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+}
+
+void VolumetricModifier::setAlphaMultiplierLabel(QLabel *label)
+{
+ m_alphaMultiplierLabel = label;
+}
+
+void VolumetricModifier::sliceX(int enabled)
+{
+ m_slicingX = enabled;
+ handleSlicingChanges();
+}
+
+void VolumetricModifier::sliceY(int enabled)
+{
+ m_slicingY = enabled;
+ handleSlicingChanges();
+}
+
+void VolumetricModifier::sliceZ(int enabled)
+{
+ m_slicingZ = enabled;
+ handleSlicingChanges();
+}
+
+void VolumetricModifier::adjustSliceX(int value)
+{
+ if (m_volumeItem) {
+ m_sliceIndexX = value / (1024 / m_volumeItem->textureWidth());
+ if (m_sliceIndexX == m_volumeItem->textureWidth())
+ m_sliceIndexX--;
+ if (m_volumeItem->sliceIndexX() != -1)
+ //! [7]
+ m_volumeItem->setSliceIndexX(m_sliceIndexX);
+ //! [7]
+ //! [9]
+ m_sliceLabelX->setPixmap(
+ QPixmap::fromImage(m_volumeItem->renderSlice(Qt::XAxis, m_sliceIndexX)));
+ //! [9]
+ }
+}
+
+void VolumetricModifier::adjustSliceY(int value)
+{
+ if (m_volumeItem) {
+ m_sliceIndexY = value / (1024 / m_volumeItem->textureHeight());
+ if (m_sliceIndexY == m_volumeItem->textureHeight())
+ m_sliceIndexY--;
+ if (m_volumeItem->sliceIndexY() != -1)
+ m_volumeItem->setSliceIndexY(m_sliceIndexY);
+ m_sliceLabelY->setPixmap(
+ QPixmap::fromImage(m_volumeItem->renderSlice(Qt::YAxis, m_sliceIndexY)));
+ }
+}
+
+void VolumetricModifier::adjustSliceZ(int value)
+{
+ if (m_volumeItem) {
+ m_sliceIndexZ = value / (1024 / m_volumeItem->textureDepth());
+ if (m_sliceIndexZ == m_volumeItem->textureDepth())
+ m_sliceIndexZ--;
+ if (m_volumeItem->sliceIndexZ() != -1)
+ m_volumeItem->setSliceIndexZ(m_sliceIndexZ);
+ m_sliceLabelZ->setPixmap(
+ QPixmap::fromImage(m_volumeItem->renderSlice(Qt::ZAxis, m_sliceIndexZ)));
+ }
+}
+
+void VolumetricModifier::handleFpsChange(qreal fps)
+{
+ const QString fpsFormat = QStringLiteral("FPS: %1");
+ int fps10 = int(fps * 10.0);
+ m_fpsLabel->setText(fpsFormat.arg(qreal(fps10) / 10.0));
+}
+
+void VolumetricModifier::handleTimeout()
+{
+ if (!m_mediumDetailRB->isEnabled()) {
+ if (m_mediumDetailIndex != mediumDetailSize) {
+ m_mediumDetailIndex = createVolume(mediumDetailSize, m_mediumDetailIndex, 4,
+ m_mediumDetailData);
+ } else if (m_mediumDetailShaftIndex != m_mineShaftArray.size()) {
+ m_mediumDetailShaftIndex = excavateMineShaft(mediumDetailSize, m_mediumDetailShaftIndex,
+ 1, m_mediumDetailData );
+ } else {
+ m_mediumDetailRB->setEnabled(true);
+ QString label = QStringLiteral("Medium (%1x%2x%1)");
+ m_mediumDetailRB->setText(label.arg(mediumDetailSize).arg(mediumDetailSize / 2));
+ }
+ } else if (!m_highDetailRB->isEnabled()) {
+ if (m_highDetailIndex != highDetailSize) {
+ m_highDetailIndex = createVolume(highDetailSize, m_highDetailIndex, 1,
+ m_highDetailData);
+ } else if (m_highDetailShaftIndex != m_mineShaftArray.size()) {
+ m_highDetailShaftIndex = excavateMineShaft(highDetailSize, m_highDetailShaftIndex, 1,
+ m_highDetailData);
+ } else {
+ m_highDetailRB->setEnabled(true);
+ QString label = QStringLiteral("High (%1x%2x%1)");
+ m_highDetailRB->setText(label.arg(highDetailSize).arg(highDetailSize / 2));
+ m_timer.stop();
+ }
+ }
+}
+
+void VolumetricModifier::toggleLowDetail(bool enabled)
+{
+ if (enabled && m_volumeItem) {
+ m_volumeItem->setTextureData(new QVector<uchar>(*m_lowDetailData));
+ m_volumeItem->setTextureDimensions(lowDetailSize, lowDetailSize / 2, lowDetailSize);
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::toggleMediumDetail(bool enabled)
+{
+ if (enabled && m_volumeItem) {
+ m_volumeItem->setTextureData(new QVector<uchar>(*m_mediumDetailData));
+ m_volumeItem->setTextureDimensions(mediumDetailSize, mediumDetailSize / 2, mediumDetailSize);
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::toggleHighDetail(bool enabled)
+{
+ if (enabled && m_volumeItem) {
+ m_volumeItem->setTextureData(new QVector<uchar>(*m_highDetailData));
+ m_volumeItem->setTextureDimensions(highDetailSize, highDetailSize / 2, highDetailSize);
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::setFpsMeasurement(bool enabled)
+{
+ m_graph->setMeasureFps(enabled);
+ if (enabled)
+ m_fpsLabel->setText(QStringLiteral("Measuring..."));
+ else
+ m_fpsLabel->setText(QString());
+}
+
+void VolumetricModifier::setSliceSliders(QSlider *sliderX, QSlider *sliderY, QSlider *sliderZ)
+{
+ m_sliceSliderX = sliderX;
+ m_sliceSliderY = sliderY;
+ m_sliceSliderZ = sliderZ;
+
+ // Set sliders to interesting values
+ m_sliceSliderX->setValue(715);
+ m_sliceSliderY->setValue(612);
+ m_sliceSliderZ->setValue(715);
+}
+
+void VolumetricModifier::changeColorTable(int enabled)
+{
+ if (m_volumeItem) {
+ if (enabled)
+ m_volumeItem->setColorTable(m_colorTable2);
+ else
+ m_volumeItem->setColorTable(m_colorTable1);
+
+ m_usingPrimaryTable = !enabled;
+
+ // Rerender image labels
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::setPreserveOpacity(bool enabled)
+{
+
+ if (m_volumeItem) {
+ //! [10]
+ m_volumeItem->setPreserveOpacity(enabled);
+ //! [10]
+
+ // Rerender image labels
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::setTransparentGround(bool enabled)
+{
+ if (m_volumeItem) {
+ //! [12]
+ int newAlpha = enabled ? terrainTransparency : 255;
+ for (int i = aboveWaterGroundColorsMin; i < underWaterGroundColorsMax; i++) {
+ QRgb oldColor1 = m_colorTable1.at(i);
+ QRgb oldColor2 = m_colorTable2.at(i);
+ m_colorTable1[i] = qRgba(qRed(oldColor1), qGreen(oldColor1), qBlue(oldColor1), newAlpha);
+ m_colorTable2[i] = qRgba(qRed(oldColor2), qGreen(oldColor2), qBlue(oldColor2), newAlpha);
+ }
+ if (m_usingPrimaryTable)
+ m_volumeItem->setColorTable(m_colorTable1);
+ else
+ m_volumeItem->setColorTable(m_colorTable2);
+ //! [12]
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::setUseHighDefShader(bool enabled)
+{
+ if (m_volumeItem) {
+ //! [13]
+ m_volumeItem->setUseHighDefShader(enabled);
+ //! [13]
+ }
+}
+
+void VolumetricModifier::adjustAlphaMultiplier(int value)
+{
+ if (m_volumeItem) {
+ float mult;
+ if (value > 100)
+ mult = float(value - 99) / 2.0f;
+ else
+ mult = float(value) / float(500 - value * 4);
+ //! [11]
+ m_volumeItem->setAlphaMultiplier(mult);
+ //! [11]
+ QString labelFormat = QStringLiteral("Alpha multiplier: %1");
+ m_alphaMultiplierLabel->setText(labelFormat.arg(
+ QString::number(m_volumeItem->alphaMultiplier(), 'f', 3)));
+
+ // Rerender image labels
+ adjustSliceX(m_sliceSliderX->value());
+ adjustSliceY(m_sliceSliderY->value());
+ adjustSliceZ(m_sliceSliderZ->value());
+ }
+}
+
+void VolumetricModifier::toggleAreaAll(bool enabled)
+{
+ if (enabled) {
+ m_graph->axisX()->setRange(0.0f, 1000.0f);
+ m_graph->axisY()->setRange(-600.0f, 600.0f);
+ m_graph->axisZ()->setRange(0.0f, 1000.0f);
+ m_graph->axisX()->setSegmentCount(5);
+ m_graph->axisY()->setSegmentCount(6);
+ m_graph->axisZ()->setSegmentCount(5);
+ }
+}
+
+void VolumetricModifier::toggleAreaMine(bool enabled)
+{
+ if (enabled) {
+ m_graph->axisX()->setRange(350.0f, 850.0f);
+ m_graph->axisY()->setRange(-500.0f, 100.0f);
+ m_graph->axisZ()->setRange(350.0f, 900.0f);
+ m_graph->axisX()->setSegmentCount(10);
+ m_graph->axisY()->setSegmentCount(6);
+ m_graph->axisZ()->setSegmentCount(11);
+ }
+}
+
+void VolumetricModifier::toggleAreaMountain(bool enabled)
+{
+ if (enabled) {
+ m_graph->axisX()->setRange(300.0f, 600.0f);
+ m_graph->axisY()->setRange(-100.0f, 400.0f);
+ m_graph->axisZ()->setRange(300.0f, 600.0f);
+ m_graph->axisX()->setSegmentCount(9);
+ m_graph->axisY()->setSegmentCount(5);
+ m_graph->axisZ()->setSegmentCount(9);
+ }
+}
+
+void VolumetricModifier::setDrawSliceFrames(int enabled)
+{
+ if (m_volumeItem)
+ m_volumeItem->setDrawSliceFrames(enabled);
+}
+
+void VolumetricModifier::initHeightMap(QString fileName, QVector<uchar> &layerData)
+{
+ QImage heightImage(fileName);
+
+ layerData.resize(layerDataSize * layerDataSize);
+ const uchar *bits = heightImage.bits();
+ int index = 0;
+ QVector<QRgb> colorTable = heightImage.colorTable();
+ for (int i = 0; i < layerDataSize; i++) {
+ for (int j = 0; j < layerDataSize; j++) {
+ layerData[index] = qRed(colorTable.at(bits[index]));
+ index++;
+ }
+ }
+}
+
+int VolumetricModifier::createVolume(int textureSize, int startIndex, int count,
+ QVector<uchar> *textureData)
+{
+ // Generate volume from layer data.
+ int index = startIndex * textureSize * textureSize / 2.0f;
+ int endIndex = startIndex + count;
+ if (endIndex > textureSize)
+ endIndex = textureSize;
+ QVector<uchar> magmaHeights(textureSize);
+ QVector<uchar> waterHeights(textureSize);
+ QVector<uchar> groundHeights(textureSize);
+ float multiplier = float(layerDataSize) / float(textureSize);
+ for (int i = startIndex; i < endIndex; i++) {
+ // Generate layer height arrays
+ for (int l = 0; l < textureSize; l++) {
+ int layerIndex = (int(i * multiplier) * layerDataSize + int(l * multiplier));
+ magmaHeights[l] = int(m_magmaLayer.at(layerIndex));
+ waterHeights[l] = int(m_waterLayer.at(layerIndex));
+ groundHeights[l] = int(m_groundLayer.at(layerIndex));
+ }
+ for (int j = 0; j < textureSize / 2; j++) {
+ for (int k = 0; k < textureSize; k++) {
+ int colorIndex;
+ int height((layerDataSize - (j * 2 * multiplier)) / 2);
+ if (height < magmaHeights.at(k)) {
+ // Magma layer
+ colorIndex = int((float(height) / heightToColorDiv)
+ * float(layerColorThickness)) + magmaColorsMin;
+ } else if (height < groundHeights.at(k) && height < waterHeights.at(k)) {
+ // Ground layer below water
+ colorIndex = int((float(waterHeights.at(k) - height) / heightToColorDiv)
+ * float(layerColorThickness)) + underWaterGroundColorsMin;
+ } else if (height < waterHeights.at(k)) {
+ // Water layer where water goes over ground
+ colorIndex = int((float(height - magmaHeights.at(k)) / heightToColorDiv)
+ * float(layerColorThickness)) + waterColorsMin;
+ } else if (height <= groundHeights.at(k)) {
+ // Ground above water
+ colorIndex = int((float(height - waterHeights.at(k)) / heightToColorDiv)
+ * float(layerColorThickness)) + aboveWaterGroundColorsMin;
+ } else {
+ // Rest is air
+ colorIndex = airColorIndex;
+ }
+
+ (*textureData)[index] = colorIndex;
+ index++;
+ }
+ }
+ }
+ return endIndex;
+}
+
+int VolumetricModifier::excavateMineShaft(int textureSize, int startIndex, int count,
+ QVector<uchar> *textureData)
+{
+ int endIndex = startIndex + count;
+ if (endIndex > m_mineShaftArray.size())
+ endIndex = m_mineShaftArray.size();
+ int shaftSize = mineShaftDiameter * textureSize / lowDetailSize;
+ for (int i = startIndex; i < endIndex; i++) {
+ QVector3D shaftStart(m_mineShaftArray.at(i).first);
+ QVector3D shaftEnd(m_mineShaftArray.at(i).second);
+ int shaftLen = (shaftEnd - shaftStart).length() * lowDetailSize;
+ int dataX = shaftStart.x() * textureSize - (shaftSize / 2);
+ int dataY = (shaftStart.y() * textureSize - (shaftSize / 2)) / 2;
+ int dataZ = shaftStart.z() * textureSize - (shaftSize / 2);
+ int dataIndex = dataX + (dataY * textureSize) + dataZ * (textureSize * textureSize / 2);
+ if (shaftStart.x() != shaftEnd.x()) {
+ for (int j = 0; j <= shaftLen; j++) {
+ excavateMineBlock(textureSize, dataIndex, shaftSize, textureData);
+ dataIndex += shaftSize;
+ }
+ } else if (shaftStart.y() != shaftEnd.y()) {
+ shaftLen /= 2; // Vertical shafts are half as long
+ for (int j = 0; j <= shaftLen; j++) {
+ excavateMineBlock(textureSize, dataIndex, shaftSize, textureData);
+ dataIndex += textureSize * shaftSize;
+ }
+ } else {
+ for (int j = 0; j <= shaftLen; j++) {
+ excavateMineBlock(textureSize, dataIndex, shaftSize, textureData);
+ dataIndex += (textureSize * textureSize / 2) * shaftSize;
+ }
+ }
+
+
+ }
+ return endIndex;
+}
+
+void VolumetricModifier::excavateMineBlock(int textureSize, int dataIndex, int size,
+ QVector<uchar> *textureData)
+{
+ for (int k = 0; k < size; k++) {
+ int curIndex = dataIndex + (k * textureSize * textureSize / 2);
+ for (int l = 0; l < size; l++) {
+ curIndex = dataIndex + (k * textureSize * textureSize / 2)
+ + (l * textureSize);
+ for (int m = 0; m < size; m++) {
+ if (textureData->at(curIndex) != airColorIndex)
+ (*textureData)[curIndex] = mineShaftColorIndex;
+ curIndex++;
+ }
+
+ }
+ }
+}
+
+void VolumetricModifier::handleSlicingChanges()
+{
+ if (m_volumeItem) {
+ if (m_slicingX || m_slicingY || m_slicingZ) {
+ // Only show slices of selected dimensions
+ //! [8]
+ m_volumeItem->setDrawSlices(true);
+ //! [8]
+ m_volumeItem->setSliceIndexX(m_slicingX ? m_sliceIndexX : -1);
+ m_volumeItem->setSliceIndexY(m_slicingY ? m_sliceIndexY : -1);
+ m_volumeItem->setSliceIndexZ(m_slicingZ ? m_sliceIndexZ : -1);
+ } else {
+ // Show slice frames for all dimenstions when not actually slicing
+ m_volumeItem->setDrawSlices(false);
+ m_volumeItem->setSliceIndexX(m_sliceIndexX);
+ m_volumeItem->setSliceIndexY(m_sliceIndexY);
+ m_volumeItem->setSliceIndexZ(m_sliceIndexZ);
+ }
+ }
+}
+
+void VolumetricModifier::initMineShaftArray()
+{
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.1f, 0.7f),
+ QVector3D(0.7f, 0.8f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.7f, 0.5f),
+ QVector3D(0.7f, 0.7f, 0.7f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.4f, 0.7f, 0.7f),
+ QVector3D(0.7f, 0.7f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.4f, 0.7f, 0.7f),
+ QVector3D(0.4f, 0.7f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.45f, 0.7f, 0.7f),
+ QVector3D(0.45f, 0.7f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.5f, 0.7f, 0.7f),
+ QVector3D(0.5f, 0.7f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.55f, 0.7f, 0.7f),
+ QVector3D(0.55f, 0.7f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.7f),
+ QVector3D(0.6f, 0.7f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.65f, 0.7f, 0.7f),
+ QVector3D(0.65f, 0.7f, 0.8f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.5f, 0.6f, 0.7f),
+ QVector3D(0.7f, 0.6f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.5f, 0.6f, 0.7f),
+ QVector3D(0.5f, 0.6f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.55f, 0.6f, 0.7f),
+ QVector3D(0.55f, 0.6f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.7f),
+ QVector3D(0.6f, 0.6f, 0.8f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.65f, 0.6f, 0.7f),
+ QVector3D(0.65f, 0.6f, 0.8f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.6f, 0.4f),
+ QVector3D(0.7f, 0.6f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.45f),
+ QVector3D(0.8f, 0.6f, 0.45f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.5f),
+ QVector3D(0.8f, 0.6f, 0.5f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.55f),
+ QVector3D(0.8f, 0.6f, 0.55f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.6f),
+ QVector3D(0.8f, 0.6f, 0.6f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.65f),
+ QVector3D(0.8f, 0.6f, 0.65f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.6f, 0.7f),
+ QVector3D(0.8f, 0.6f, 0.7f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.7f, 0.4f),
+ QVector3D(0.7f, 0.7f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.45f),
+ QVector3D(0.8f, 0.7f, 0.45f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.5f),
+ QVector3D(0.8f, 0.7f, 0.5f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.55f),
+ QVector3D(0.8f, 0.7f, 0.55f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.6f),
+ QVector3D(0.8f, 0.7f, 0.6f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.65f),
+ QVector3D(0.8f, 0.7f, 0.65f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.7f, 0.7f),
+ QVector3D(0.8f, 0.7f, 0.7f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.8f, 0.5f),
+ QVector3D(0.7f, 0.8f, 0.7f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.8f, 0.55f),
+ QVector3D(0.8f, 0.8f, 0.55f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.8f, 0.6f),
+ QVector3D(0.8f, 0.8f, 0.6f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.8f, 0.65f),
+ QVector3D(0.8f, 0.8f, 0.65f));
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.6f, 0.8f, 0.7f),
+ QVector3D(0.8f, 0.8f, 0.7f));
+
+ m_mineShaftArray << QPair<QVector3D, QVector3D>(QVector3D(0.7f, 0.1f, 0.4f),
+ QVector3D(0.7f, 0.7f, 0.4f));
+}
diff --git a/examples/datavisualization/volumetric/volumetric.h b/examples/datavisualization/volumetric/volumetric.h
new file mode 100644
index 00000000..8d28b524
--- /dev/null
+++ b/examples/datavisualization/volumetric/volumetric.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef VOLUMETRICMODIFIER_H
+#define VOLUMETRICMODIFIER_H
+
+#include <QtDataVisualization/q3dscatter.h>
+#include <QtDataVisualization/qcustom3dvolume.h>
+#include <QtCore/QTimer>
+#include <QtGui/QRgb>
+
+class QLabel;
+class QRadioButton;
+class QSlider;
+
+using namespace QtDataVisualization;
+
+class VolumetricModifier : public QObject
+{
+ Q_OBJECT
+public:
+ explicit VolumetricModifier(Q3DScatter *scatter);
+ ~VolumetricModifier();
+
+ void setFpsLabel(QLabel *fpsLabel);
+ void setMediumDetailRB(QRadioButton *button);
+ void setHighDetailRB(QRadioButton *button);
+ void setSliceLabels(QLabel *xLabel, QLabel *yLabel, QLabel *zLabel);
+ void setAlphaMultiplierLabel(QLabel *label);
+
+public slots:
+ void sliceX(int enabled);
+ void sliceY(int enabled);
+ void sliceZ(int enabled);
+ void adjustSliceX(int value);
+ void adjustSliceY(int value);
+ void adjustSliceZ(int value);
+ void handleFpsChange(qreal fps);
+ void handleTimeout();
+ void toggleLowDetail(bool enabled);
+ void toggleMediumDetail(bool enabled);
+ void toggleHighDetail(bool enabled);
+ void setFpsMeasurement(bool enabled);
+ void setSliceSliders(QSlider *sliderX, QSlider *sliderY, QSlider *sliderZ);
+ void changeColorTable(int enabled);
+ void setPreserveOpacity(bool enabled);
+ void setTransparentGround(bool enabled);
+ void setUseHighDefShader(bool enabled);
+ void adjustAlphaMultiplier(int value);
+ void toggleAreaAll(bool enabled);
+ void toggleAreaMine(bool enabled);
+ void toggleAreaMountain(bool enabled);
+ void setDrawSliceFrames(int enabled);
+
+private:
+
+ void initHeightMap(QString fileName, QVector<uchar> &layerData);
+ void initMineShaftArray();
+ int createVolume(int textureSize, int startIndex, int count,
+ QVector<uchar> *textureData);
+ int excavateMineShaft(int textureSize, int startIndex, int count,
+ QVector<uchar> *textureData);
+ void excavateMineBlock(int textureSize, int dataIndex, int size, QVector<uchar> *textureData);
+ void handleSlicingChanges();
+
+ Q3DScatter *m_graph;
+ QCustom3DVolume *m_volumeItem;
+ int m_sliceIndexX;
+ int m_sliceIndexY;
+ int m_sliceIndexZ;
+ bool m_slicingX;
+ bool m_slicingY;
+ bool m_slicingZ;
+ QLabel *m_fpsLabel;
+ QRadioButton *m_mediumDetailRB;
+ QRadioButton *m_highDetailRB;
+ QVector<uchar> *m_lowDetailData;
+ QVector<uchar> *m_mediumDetailData;
+ QVector<uchar> *m_highDetailData;
+ QTimer m_timer;
+ int m_mediumDetailIndex;
+ int m_highDetailIndex;
+ int m_mediumDetailShaftIndex;
+ int m_highDetailShaftIndex;
+ QSlider *m_sliceSliderX;
+ QSlider *m_sliceSliderY;
+ QSlider *m_sliceSliderZ;
+ QVector<QRgb> m_colorTable1;
+ QVector<QRgb> m_colorTable2;
+ bool m_usingPrimaryTable;
+ QLabel *m_sliceLabelX;
+ QLabel *m_sliceLabelY;
+ QLabel *m_sliceLabelZ;
+ QLabel *m_alphaMultiplierLabel;
+ QVector<uchar> m_magmaLayer;
+ QVector<uchar> m_waterLayer;
+ QVector<uchar> m_groundLayer;
+ QVector<QPair<QVector3D, QVector3D> > m_mineShaftArray;
+};
+
+#endif
diff --git a/examples/datavisualization/volumetric/volumetric.pro b/examples/datavisualization/volumetric/volumetric.pro
new file mode 100644
index 00000000..fa355692
--- /dev/null
+++ b/examples/datavisualization/volumetric/volumetric.pro
@@ -0,0 +1,17 @@
+android|ios {
+ error( "This example is not supported for android or ios." )
+}
+
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+SOURCES += main.cpp volumetric.cpp
+HEADERS += volumetric.h
+
+QT += widgets
+
+OTHER_FILES += doc/src/* \
+ doc/images/*
+
+RESOURCES += volumetric.qrc
diff --git a/examples/datavisualization/volumetric/volumetric.qrc b/examples/datavisualization/volumetric/volumetric.qrc
new file mode 100644
index 00000000..920fd1d2
--- /dev/null
+++ b/examples/datavisualization/volumetric/volumetric.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/heightmaps">
+ <file>layer_ground.png</file>
+ <file>layer_magma.png</file>
+ <file>layer_water.png</file>
+ </qresource>
+</RCC>
diff --git a/qtdatavisualization.pro b/qtdatavisualization.pro
index bb98435e..faadadbc 100644
--- a/qtdatavisualization.pro
+++ b/qtdatavisualization.pro
@@ -8,4 +8,4 @@ contains(QT_CONFIG, opengles1) {
error(QtDataVisualization does not support OpenGL ES 1!)
}
-OTHER_FILES += README dist/*
+OTHER_FILES += README dist/* .qmake.conf
diff --git a/src/datavisualization/axis/axis.pri b/src/datavisualization/axis/axis.pri
index 0173b597..4c142c91 100644
--- a/src/datavisualization/axis/axis.pri
+++ b/src/datavisualization/axis/axis.pri
@@ -16,3 +16,5 @@ SOURCES += \
$$PWD/qcategory3daxis.cpp \
$$PWD/qvalue3daxisformatter.cpp \
$$PWD/qlogvalue3daxisformatter.cpp
+
+INCLUDEPATH += $$PWD
diff --git a/src/datavisualization/axis/qlogvalue3daxisformatter.cpp b/src/datavisualization/axis/qlogvalue3daxisformatter.cpp
index 7367e7c5..85fd5c4f 100644
--- a/src/datavisualization/axis/qlogvalue3daxisformatter.cpp
+++ b/src/datavisualization/axis/qlogvalue3daxisformatter.cpp
@@ -42,6 +42,7 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \since QtDataVisualization 1.1
* \ingroup datavisualization_qml
* \instantiates QLogValue3DAxisFormatter
+ * \inherits ValueAxis3DFormatter
* \brief LogValueAxis3DFormatter implements logarithmic value axis formatter.
*
* This type provides formatting rules for a logarithmic ValueAxis3D.
diff --git a/src/datavisualization/axis/qvalue3daxis.cpp b/src/datavisualization/axis/qvalue3daxis.cpp
index 8207174f..3b9c9e3d 100644
--- a/src/datavisualization/axis/qvalue3daxis.cpp
+++ b/src/datavisualization/axis/qvalue3daxis.cpp
@@ -18,6 +18,7 @@
#include "qvalue3daxis_p.h"
#include "qvalue3daxisformatter_p.h"
+#include "abstract3dcontroller_p.h"
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -68,8 +69,16 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
/*!
* \qmlproperty string ValueAxis3D::labelFormat
*
- * Defines the label format to be used for the labels on this axis. Supported specifiers are:
+ * Defines the label format to be used for the labels on this axis. How the format is interpreted
+ * depends on the axis formatter and the locale in use. Using the default formatter and default
+ * locale (\c{"C"}), the formatting uses QString::sprintf(). Supported specifiers are:
* \c {d, i, o, x, X, f, F, e, E, g, G, c}. See QString::sprintf() for additional details.
+ * For other locales, the default formatter uses reduced set of printf format specifiers:
+ * \c {d, i, f, F, e, E, g, G}. In these cases, the only supported modifier is the precision
+ * modifier for the floating point and exponential formats. The decimal point and other locale
+ * dependent formatting is done according to the graph locale.
+ *
+ * \sa AbstractGraph3D::locale
*/
/*!
@@ -164,12 +173,20 @@ int QValue3DAxis::subSegmentCount() const
/*!
* \property QValue3DAxis::labelFormat
*
- * Defines the label \a format to be used for the labels on this axis. Supported specifiers are:
+ * Defines the label format to be used for the labels on this axis. How the format is interpreted
+ * depends on the axis formatter and the locale in use. Using the default formatter and default
+ * locale (\c{"C"}), the formatting uses QString::sprintf(). Supported specifiers are:
* \c {d, i, o, x, X, f, F, e, E, g, G, c}. See QString::sprintf() for additional details.
+ * For other locales, the default formatter uses reduced set of printf format specifiers:
+ * \c {d, i, f, F, e, E, g, G}. In these cases, the only supported modifier is the precision
+ * modifier for the floating point and exponential formats. The decimal point and other locale
+ * dependent formatting is done according to the graph locale.
*
* Usage example:
*
* \c {axis->setLabelFormat("%.2f mm");}
+ *
+ * \sa formatter, QAbstract3DGraph::locale
*/
void QValue3DAxis::setLabelFormat(const QString &format)
{
@@ -201,6 +218,9 @@ void QValue3DAxis::setFormatter(QValue3DAxisFormatter *formatter)
dptr()->m_formatter = formatter;
formatter->setParent(this);
formatter->d_ptr->setAxis(this);
+ Abstract3DController *controller = qobject_cast<Abstract3DController *>(parent());
+ if (controller)
+ formatter->setLocale(controller->locale());
emit formatterChanged(formatter);
emit dptr()->formatterDirty();
}
diff --git a/src/datavisualization/axis/qvalue3daxisformatter.cpp b/src/datavisualization/axis/qvalue3daxisformatter.cpp
index 56ca3b0f..f6b705a9 100644
--- a/src/datavisualization/axis/qvalue3daxisformatter.cpp
+++ b/src/datavisualization/axis/qvalue3daxisformatter.cpp
@@ -270,6 +270,28 @@ QStringList &QValue3DAxisFormatter::labelStrings() const
return d_ptr->m_labelStrings;
}
+/*!
+ * Sets the \a locale that this formatter uses.
+ * The graph automatically sets the formatter's locale to a graph's locale whenever the parent axis
+ * is set as an active axis of the graph, the axis formatter is set to an axis attached to
+ * the graph, or the graph's locale changes.
+ *
+ * \sa locale(), QAbstract3DGraph::locale
+ */
+void QValue3DAxisFormatter::setLocale(const QLocale &locale)
+{
+ d_ptr->m_cLocaleInUse = (locale == QLocale::c());
+ d_ptr->m_locale = locale;
+ markDirty(true);
+}
+/*!
+ * \return the current locale this formatter is using.
+ */
+QLocale QValue3DAxisFormatter::locale() const
+{
+ return d_ptr->m_locale;
+}
+
// QValue3DAxisFormatterPrivate
QValue3DAxisFormatterPrivate::QValue3DAxisFormatterPrivate(QValue3DAxisFormatter *q)
: QObject(0),
@@ -281,7 +303,10 @@ QValue3DAxisFormatterPrivate::QValue3DAxisFormatterPrivate(QValue3DAxisFormatter
m_axis(0),
m_preparsedParamType(Utils::ParamTypeUnknown),
m_allowNegatives(true),
- m_allowZero(true)
+ m_allowZero(true),
+ m_formatPrecision(6), // 6 and 'g' are defaults in Qt API for format precision and spec
+ m_formatSpec('g'),
+ m_cLocaleInUse(true)
{
}
@@ -363,12 +388,19 @@ QString QValue3DAxisFormatterPrivate::stringForValue(qreal value, const QString
{
if (m_previousLabelFormat.compare(format)) {
// Format string different than the previous one used, reparse it
- m_previousLabelFormat = format;
- m_preparsedParamType = Utils::findFormatParamType(format);
m_labelFormatArray = format.toUtf8();
+ m_previousLabelFormat = format;
+ m_preparsedParamType = Utils::preParseFormat(format, m_formatPreStr, m_formatPostStr,
+ m_formatPrecision, m_formatSpec);
}
- return Utils::formatLabel(m_labelFormatArray, m_preparsedParamType, value);
+ if (m_cLocaleInUse) {
+ return Utils::formatLabelSprintf(m_labelFormatArray, m_preparsedParamType, value);
+ } else {
+ return Utils::formatLabelLocalized(m_preparsedParamType, value, m_locale, m_formatPreStr,
+ m_formatPostStr, m_formatPrecision, m_formatSpec,
+ m_labelFormatArray);
+ }
}
float QValue3DAxisFormatterPrivate::positionAt(float value) const
diff --git a/src/datavisualization/axis/qvalue3daxisformatter.h b/src/datavisualization/axis/qvalue3daxisformatter.h
index c7b0bac5..82e49f21 100644
--- a/src/datavisualization/axis/qvalue3daxisformatter.h
+++ b/src/datavisualization/axis/qvalue3daxisformatter.h
@@ -24,6 +24,7 @@
#include <QtCore/QScopedPointer>
#include <QtCore/QVector>
#include <QtCore/QStringList>
+#include <QtCore/QLocale>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -60,6 +61,9 @@ protected:
QVector<float> &labelPositions() const;
QStringList &labelStrings() const;
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
QScopedPointer<QValue3DAxisFormatterPrivate> d_ptr;
private:
diff --git a/src/datavisualization/axis/qvalue3daxisformatter_p.h b/src/datavisualization/axis/qvalue3daxisformatter_p.h
index 2d1dc920..9571d001 100644
--- a/src/datavisualization/axis/qvalue3daxisformatter_p.h
+++ b/src/datavisualization/axis/qvalue3daxisformatter_p.h
@@ -32,6 +32,7 @@
#include "datavisualizationglobal_p.h"
#include "qvalue3daxisformatter.h"
#include "utils_p.h"
+#include <QtCore/QLocale>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -83,6 +84,13 @@ protected:
bool m_allowNegatives;
bool m_allowZero;
+ QLocale m_locale;
+ QString m_formatPreStr;
+ QString m_formatPostStr;
+ int m_formatPrecision;
+ char m_formatSpec;
+ bool m_cLocaleInUse;
+
friend class QValue3DAxisFormatter;
};
diff --git a/src/datavisualization/common.pri b/src/datavisualization/common.pri
deleted file mode 100644
index 9a497c2c..00000000
--- a/src/datavisualization/common.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-INCLUDEPATH += $$PWD/engine \
- $$PWD/global \
- $$PWD/utils \
- $$PWD/axis \
- $$PWD/data \
- $$PWD/input \
- $$PWD/theme
diff --git a/src/datavisualization/data/abstractrenderitem_p.h b/src/datavisualization/data/abstractrenderitem_p.h
index 57977a3c..ccee2b00 100644
--- a/src/datavisualization/data/abstractrenderitem_p.h
+++ b/src/datavisualization/data/abstractrenderitem_p.h
@@ -48,10 +48,12 @@ public:
inline void setTranslation(const QVector3D &translation) { m_translation = translation; }
inline const QVector3D &translation() const {return m_translation; }
- inline QQuaternion rotation() const { return m_rotation; }
+ inline const QQuaternion &rotation() const { return m_rotation; }
inline void setRotation(const QQuaternion &rotation)
{
- if (m_rotation != rotation)
+ if (rotation.isNull())
+ m_rotation = identityQuaternion;
+ else
m_rotation = rotation;
}
diff --git a/src/datavisualization/data/customrenderitem.cpp b/src/datavisualization/data/customrenderitem.cpp
index a1c70057..f56ca86e 100644
--- a/src/datavisualization/data/customrenderitem.cpp
+++ b/src/datavisualization/data/customrenderitem.cpp
@@ -23,9 +23,32 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
CustomRenderItem::CustomRenderItem()
: AbstractRenderItem(),
m_texture(0),
+ m_positionAbsolute(false),
+ m_scalingAbsolute(true),
m_object(0),
+ m_needBlend(true),
m_visible(true),
- m_renderer(0)
+ m_valid(true),
+ m_index(0),
+ m_shadowCasting(false),
+ m_isFacingCamera(false),
+ m_item(0),
+ m_renderer(0),
+ m_labelItem(false),
+ m_textureWidth(0),
+ m_textureHeight(0),
+ m_textureDepth(0),
+ m_isVolume(false),
+ m_textureFormat(QImage::Format_ARGB32),
+ m_sliceIndexX(-1),
+ m_sliceIndexY(-1),
+ m_sliceIndexZ(-1),
+ m_alphaMultiplier(1.0f),
+ m_preserveOpacity(true),
+ m_useHighDefShader(true),
+ m_drawSlices(false),
+ m_drawSliceFrames(false)
+
{
}
@@ -39,4 +62,47 @@ void CustomRenderItem::setMesh(const QString &meshFile)
ObjectHelper::resetObjectHelper(m_renderer, m_object, meshFile);
}
+void CustomRenderItem::setColorTable(const QVector<QRgb> &colors)
+{
+ m_colorTable.resize(256);
+ for (int i = 0; i < 256; i++) {
+ if (i < colors.size()) {
+ const QRgb &rgb = colors.at(i);
+ m_colorTable[i] = QVector4D(float(qRed(rgb)) / 255.0f,
+ float(qGreen(rgb)) / 255.0f,
+ float(qBlue(rgb)) / 255.0f,
+ float(qAlpha(rgb)) / 255.0f);
+ } else {
+ m_colorTable[i] = QVector4D(0.0f, 0.0f, 0.0f, 0.0f);
+ }
+ }
+}
+
+void CustomRenderItem::setMinBounds(const QVector3D &bounds)
+{
+ m_minBounds = bounds;
+ m_minBoundsNormal = m_minBounds;
+ m_minBoundsNormal.setY(-m_minBoundsNormal.y());
+ m_minBoundsNormal.setZ(-m_minBoundsNormal.z());
+ m_minBoundsNormal = 0.5f * (m_minBoundsNormal + oneVector);
+}
+
+void CustomRenderItem::setMaxBounds(const QVector3D &bounds)
+{
+ m_maxBounds = bounds;
+ m_maxBoundsNormal = m_maxBounds;
+ m_maxBoundsNormal.setY(-m_maxBoundsNormal.y());
+ m_maxBoundsNormal.setZ(-m_maxBoundsNormal.z());
+ m_maxBoundsNormal = 0.5f * (m_maxBoundsNormal + oneVector);
+}
+
+void CustomRenderItem::setSliceFrameColor(const QColor &color)
+{
+ const QRgb &rgb = color.rgba();
+ m_sliceFrameColor = QVector4D(float(qRed(rgb)) / 255.0f,
+ float(qGreen(rgb)) / 255.0f,
+ float(qBlue(rgb)) / 255.0f,
+ float(1.0f)); // Alpha not supported for frames
+}
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/data/customrenderitem_p.h b/src/datavisualization/data/customrenderitem_p.h
index 4fb94276..ad868fac 100644
--- a/src/datavisualization/data/customrenderitem_p.h
+++ b/src/datavisualization/data/customrenderitem_p.h
@@ -31,6 +31,9 @@
#include "abstractrenderitem_p.h"
#include "objecthelper_p.h"
+#include <QtGui/QRgb>
+#include <QtGui/QImage>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -48,11 +51,17 @@ public:
void setMesh(const QString &meshFile);
inline ObjectHelper *mesh() const { return m_object; }
inline void setScaling(const QVector3D &scaling) { m_scaling = scaling; }
- inline QVector3D scaling() const { return m_scaling; }
+ inline const QVector3D &scaling() const { return m_scaling; }
+ inline void setOrigScaling(const QVector3D &scaling) { m_origScaling = scaling; }
+ inline const QVector3D &origScaling() const { return m_origScaling; }
inline void setPosition(const QVector3D &position) { m_position = position; }
- inline QVector3D position() const { return m_position; }
- inline void setPositionAbsolute(bool absolute) { m_absolute = absolute; }
- inline bool isPositionAbsolute() const { return m_absolute; }
+ inline const QVector3D &position() const { return m_position; }
+ inline void setOrigPosition(const QVector3D &position) { m_origPosition = position; }
+ inline const QVector3D &origPosition() const { return m_origPosition; }
+ inline void setPositionAbsolute(bool absolute) { m_positionAbsolute = absolute; }
+ inline bool isPositionAbsolute() const { return m_positionAbsolute; }
+ inline void setScalingAbsolute(bool absolute) { m_scalingAbsolute = absolute; }
+ inline bool isScalingAbsolute() const { return m_scalingAbsolute; }
inline void setBlendNeeded(bool blend) { m_needBlend = blend; }
inline bool isBlendNeeded() const { return m_needBlend; }
inline void setVisible(bool visible) { m_visible = visible; }
@@ -68,14 +77,78 @@ public:
inline void setFacingCamera(bool facing) { m_isFacingCamera = facing; }
inline bool isFacingCamera() const { return m_isFacingCamera; }
inline void setRenderer(Abstract3DRenderer *renderer) { m_renderer = renderer; }
+ inline void setLabelItem(bool isLabel) { m_labelItem = isLabel; }
+ inline bool isLabel() const { return m_labelItem; }
+
+ // Volume specific
+ inline void setTextureWidth(int width) { m_textureWidth = width; setSliceIndexX(m_sliceIndexX); }
+ inline int textureWidth() const { return m_textureWidth; }
+ inline void setTextureHeight(int height) { m_textureHeight = height; setSliceIndexY(m_sliceIndexY); }
+ inline int textureHeight() const { return m_textureHeight; }
+ inline void setTextureDepth(int depth) { m_textureDepth = depth; setSliceIndexZ(m_sliceIndexZ); }
+ inline int textureDepth() const { return m_textureDepth; }
+ inline int textureSize() const { return m_textureWidth * m_textureHeight * m_textureDepth; }
+ inline void setColorTable(const QVector<QVector4D> &colors) { m_colorTable = colors; }
+ void setColorTable(const QVector<QRgb> &colors);
+ inline const QVector<QVector4D> &colorTable() const { return m_colorTable; }
+ inline void setVolume(bool volume) { m_isVolume = volume; }
+ inline bool isVolume() const { return m_isVolume; }
+ inline void setTextureFormat(QImage::Format format) { m_textureFormat = format; }
+ inline QImage::Format textureFormat() const { return m_textureFormat; }
+ inline void setSliceIndexX(int index)
+ {
+ m_sliceIndexX = index;
+ m_sliceFractions.setX((float(index) + 0.5f) / float(m_textureWidth) * 2.0 - 1.0);
+ }
+ inline void setSliceIndexY(int index)
+ {
+ m_sliceIndexY = index;
+ m_sliceFractions.setY((float(index) + 0.5f) / float(m_textureHeight) * 2.0 - 1.0);
+ }
+ inline void setSliceIndexZ(int index)
+ {
+ m_sliceIndexZ = index;
+ m_sliceFractions.setZ((float(index) + 0.5f) / float(m_textureDepth) * 2.0 - 1.0);
+ }
+ inline const QVector3D &sliceFractions() const { return m_sliceFractions; }
+ inline int sliceIndexX() const { return m_sliceIndexX; }
+ inline int sliceIndexY() const { return m_sliceIndexY; }
+ inline int sliceIndexZ() const { return m_sliceIndexZ; }
+ inline void setAlphaMultiplier(float mult) { m_alphaMultiplier = mult; }
+ inline float alphaMultiplier() const { return m_alphaMultiplier; }
+ inline void setPreserveOpacity(bool enable) { m_preserveOpacity = enable; }
+ inline bool preserveOpacity() const { return m_preserveOpacity; }
+ inline void setUseHighDefShader(bool enable) { m_useHighDefShader = enable; }
+ inline bool useHighDefShader() const {return m_useHighDefShader; }
+ void setMinBounds(const QVector3D &bounds);
+ inline const QVector3D &minBounds() const { return m_minBounds; }
+ void setMaxBounds(const QVector3D &bounds);
+ inline const QVector3D &maxBounds() const { return m_maxBounds; }
+ inline const QVector3D &minBoundsNormal() const { return m_minBoundsNormal; }
+ inline const QVector3D &maxBoundsNormal() const { return m_maxBoundsNormal; }
+ inline void setDrawSlices(bool enable) { m_drawSlices = enable; }
+ inline bool drawSlices() const {return m_drawSlices; }
+ inline void setDrawSliceFrames(bool enable) { m_drawSliceFrames = enable; }
+ inline bool drawSliceFrames() const {return m_drawSliceFrames; }
+ void setSliceFrameColor(const QColor &color);
+ inline const QVector4D &sliceFrameColor() const { return m_sliceFrameColor; }
+ inline void setSliceFrameWidths(const QVector3D &widths) { m_sliceFrameWidths = widths * 2.0f; }
+ inline const QVector3D &sliceFrameWidths() const { return m_sliceFrameWidths; }
+ inline void setSliceFrameGaps(const QVector3D &gaps) { m_sliceFrameGaps = gaps * 2.0f; }
+ inline const QVector3D &sliceFrameGaps() const { return m_sliceFrameGaps; }
+ inline void setSliceFrameThicknesses(const QVector3D &thicknesses) { m_sliceFrameThicknesses = thicknesses; }
+ inline const QVector3D &sliceFrameThicknesses() const { return m_sliceFrameThicknesses; }
private:
Q_DISABLE_COPY(CustomRenderItem)
GLuint m_texture;
QVector3D m_scaling;
+ QVector3D m_origScaling;
QVector3D m_position;
- bool m_absolute;
+ QVector3D m_origPosition;
+ bool m_positionAbsolute;
+ bool m_scalingAbsolute;
ObjectHelper *m_object; // shared reference
bool m_needBlend;
bool m_visible;
@@ -85,6 +158,32 @@ private:
bool m_isFacingCamera;
QCustom3DItem *m_item;
Abstract3DRenderer *m_renderer;
+ bool m_labelItem;
+
+ // Volume specific
+ int m_textureWidth;
+ int m_textureHeight;
+ int m_textureDepth;
+ QVector<QVector4D> m_colorTable;
+ bool m_isVolume;
+ QImage::Format m_textureFormat;
+ int m_sliceIndexX;
+ int m_sliceIndexY;
+ int m_sliceIndexZ;
+ QVector3D m_sliceFractions;
+ float m_alphaMultiplier;
+ bool m_preserveOpacity;
+ bool m_useHighDefShader;
+ QVector3D m_minBounds;
+ QVector3D m_maxBounds;
+ QVector3D m_minBoundsNormal;
+ QVector3D m_maxBoundsNormal;
+ bool m_drawSlices;
+ bool m_drawSliceFrames;
+ QVector4D m_sliceFrameColor;
+ QVector3D m_sliceFrameWidths;
+ QVector3D m_sliceFrameGaps;
+ QVector3D m_sliceFrameThicknesses;
};
typedef QHash<QCustom3DItem *, CustomRenderItem *> CustomRenderItemArray;
diff --git a/src/datavisualization/data/data.pri b/src/datavisualization/data/data.pri
index 73f398bf..e2bbd6eb 100644
--- a/src/datavisualization/data/data.pri
+++ b/src/datavisualization/data/data.pri
@@ -41,7 +41,9 @@ HEADERS += \
$$PWD/qcustom3ditem.h \
$$PWD/qcustom3ditem_p.h \
$$PWD/qcustom3dlabel.h \
- $$PWD/qcustom3dlabel_p.h
+ $$PWD/qcustom3dlabel_p.h \
+ $$PWD/qcustom3dvolume.h \
+ $$PWD/qcustom3dvolume_p.h
SOURCES += \
$$PWD/labelitem.cpp \
@@ -69,4 +71,7 @@ SOURCES += \
$$PWD/qsurface3dseries.cpp \
$$PWD/customrenderitem.cpp \
$$PWD/qcustom3ditem.cpp \
- $$PWD/qcustom3dlabel.cpp
+ $$PWD/qcustom3dlabel.cpp \
+ $$PWD/qcustom3dvolume.cpp
+
+INCLUDEPATH += $$PWD
diff --git a/src/datavisualization/data/labelitem.cpp b/src/datavisualization/data/labelitem.cpp
index 859b0550..ec8ba3fd 100644
--- a/src/datavisualization/data/labelitem.cpp
+++ b/src/datavisualization/data/labelitem.cpp
@@ -28,7 +28,7 @@ LabelItem::LabelItem()
LabelItem::~LabelItem()
{
- glDeleteTextures(1, &m_textureId);
+ QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId);
}
void LabelItem::setSize(const QSize &size)
@@ -43,7 +43,7 @@ QSize LabelItem::size() const
void LabelItem::setTextureId(GLuint textureId)
{
- glDeleteTextures(1, &m_textureId);
+ QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId);
m_textureId = textureId;
}
@@ -55,7 +55,7 @@ GLuint LabelItem::textureId() const
void LabelItem::clear()
{
if (m_textureId) {
- glDeleteTextures(1, &m_textureId);
+ QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId);
m_textureId = 0;
}
m_size = QSize(0, 0);
diff --git a/src/datavisualization/data/qabstract3dseries.cpp b/src/datavisualization/data/qabstract3dseries.cpp
index f8fe6b4f..caa95062 100644
--- a/src/datavisualization/data/qabstract3dseries.cpp
+++ b/src/datavisualization/data/qabstract3dseries.cpp
@@ -657,6 +657,9 @@ QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q,
m_mesh(QAbstract3DSeries::MeshCube),
m_meshSmooth(false),
m_colorStyle(Q3DTheme::ColorStyleUniform),
+ m_baseColor(Qt::black),
+ m_singleHighlightColor(Qt::black),
+ m_multiHighlightColor(Qt::black),
m_itemLabelDirty(true),
m_itemLabelVisible(true)
{
diff --git a/src/datavisualization/data/qabstract3dseries.h b/src/datavisualization/data/qabstract3dseries.h
index 87c4f3c1..c26c40d1 100644
--- a/src/datavisualization/data/qabstract3dseries.h
+++ b/src/datavisualization/data/qabstract3dseries.h
@@ -153,6 +153,7 @@ private:
friend class Bars3DController;
friend class Surface3DController;
friend class Surface3DRenderer;
+ friend class Scatter3DRenderer;
friend class Scatter3DController;
friend class QBar3DSeries;
friend class SeriesRenderCache;
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp
index 19c3bf79..0aa60b66 100644
--- a/src/datavisualization/data/qbar3dseries.cpp
+++ b/src/datavisualization/data/qbar3dseries.cpp
@@ -43,26 +43,27 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \row
* \li @valueTitle \li Title from value axis
* \row
- * \li @rowIdx \li Visible row index
+ * \li @rowIdx \li Visible row index. Localized using graph locale.
* \row
- * \li @colIdx \li Visible Column index
+ * \li @colIdx \li Visible Column index. Localized using graph locale.
* \row
* \li @rowLabel \li Label from row axis
* \row
* \li @colLabel \li Label from column axis
* \row
- * \li @valueLabel \li Item value formatted using the same format the value axis attached to the graph uses,
- * see \l{QValue3DAxis::setLabelFormat()} for more information.
+ * \li @valueLabel \li Item value formatted using the same format the value axis attached to
+ * the graph uses. See \l{QValue3DAxis::labelFormat} for more information.
* \row
* \li @seriesName \li Name of the series
* \row
- * \li %<format spec> \li Item value in specified format.
+ * \li %<format spec> \li Item value in specified format. Formatted using the same rules as
+ * \l{QValue3DAxis::labelFormat}.
* \endtable
*
* For example:
* \snippet doc_src_qtdatavisualization.cpp 1
*
- * \sa {Qt Data Visualization Data Handling}
+ * \sa {Qt Data Visualization Data Handling}, QAbstract3DGraph::locale
*/
/*!
@@ -334,6 +335,10 @@ void QBar3DSeriesPrivate::createItemLabel()
return;
}
+ QLocale locale(QLocale::c());
+ if (m_controller)
+ locale = m_controller->locale();
+
QCategory3DAxis *categoryAxisZ = static_cast<QCategory3DAxis *>(m_controller->axisZ());
QCategory3DAxis *categoryAxisX = static_cast<QCategory3DAxis *>(m_controller->axisX());
QValue3DAxis *valueAxis = static_cast<QValue3DAxis *>(m_controller->axisY());
@@ -344,13 +349,13 @@ void QBar3DSeriesPrivate::createItemLabel()
int selBarPosRow = m_selectedBar.x();
int selBarPosCol = m_selectedBar.y();
- m_itemLabel.replace(rowIndexTag, QString::number(selBarPosRow));
+ m_itemLabel.replace(rowIndexTag, locale.toString(selBarPosRow));
if (categoryAxisZ->labels().size() > selBarPosRow)
m_itemLabel.replace(rowLabelTag, categoryAxisZ->labels().at(selBarPosRow));
else
m_itemLabel.replace(rowLabelTag, QString());
m_itemLabel.replace(rowTitleTag, categoryAxisZ->title());
- m_itemLabel.replace(colIndexTag, QString::number(selBarPosCol));
+ m_itemLabel.replace(colIndexTag, locale.toString(selBarPosCol));
if (categoryAxisX->labels().size() > selBarPosCol)
m_itemLabel.replace(colLabelTag, categoryAxisX->labels().at(selBarPosCol));
else
diff --git a/src/datavisualization/data/qcustom3ditem.cpp b/src/datavisualization/data/qcustom3ditem.cpp
index efee3b15..b9825732 100644
--- a/src/datavisualization/data/qcustom3ditem.cpp
+++ b/src/datavisualization/data/qcustom3ditem.cpp
@@ -62,13 +62,15 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
*
* Holds the item \a position as a vector3d. Defaults to \c {vector3d(0.0, 0.0, 0.0)}.
*
- * Item position is either in data coordinates or in absolute coordinates, depending on
+ * Item position is either in data coordinates or in absolute coordinates, depending on the
* positionAbsolute property. When using absolute coordinates, values between \c{-1.0...1.0} are
* within axis ranges.
*
- * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false}.
+ * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false},
+ * unless the item is a Custom3DVolume that would be partially visible and scalingAbsolute is also
+ * \c{false}. In that case, the visible portion of the volume will be rendered.
*
- * \sa positionAbsolute
+ * \sa positionAbsolute, scalingAbsolute
*/
/*! \qmlproperty bool Custom3DItem::positionAbsolute
@@ -83,8 +85,33 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
/*! \qmlproperty vector3d Custom3DItem::scaling
*
* Holds the item \a scaling as a vector3d. Defaults to \c {vector3d(0.1, 0.1, 0.1)}.
- * The default value sets the item to 10% of the height of the graph, provided the item size is
- * normalized.
+ *
+ * Item scaling is either in data values or in absolute values, depending on the
+ * scalingAbsolute property. The default vector interpreted as absolute values sets the item to
+ * 10% of the height of the graph, provided the item mesh is normalized and the graph aspect ratios
+ * haven't been changed from the defaults.
+ *
+ * \sa scalingAbsolute
+ */
+
+/*! \qmlproperty bool Custom3DItem::scalingAbsolute
+ * \since QtDataVisualization 1.2
+ *
+ * This property dictates if item scaling is to be handled in data values or in absolute
+ * values. Defaults to \c{true}. Items with absolute scaling will be rendered at the same
+ * size, regardless of axis ranges. Items with data scaling will change their apparent size
+ * according to the axis ranges. If positionAbsolute value is \c{true}, this property is ignored
+ * and scaling is interpreted as an absolute value. If the item has rotation, the data scaling
+ * is calculated on the unrotated item. Similarly, for Custom3DVolume items, the range clipping
+ * is calculated on the unrotated item.
+ *
+ * \note: Only absolute scaling is supported for Custom3DLabel items or for custom items used in
+ * \l{AbstractGraph3D::polar}{polar} graphs.
+ *
+ * \note: The custom item's mesh must be normalized to range \c{[-1 ,1]}, or the data
+ * scaling will not be accurate.
+ *
+ * \sa scaling, positionAbsolute
*/
/*! \qmlproperty quaternion Custom3DItem::rotation
@@ -180,7 +207,9 @@ QString QCustom3DItem::meshFile() const
* positionAbsolute property. When using absolute coordinates, values between \c{-1.0...1.0} are
* within axis ranges.
*
- * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false}.
+ * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false},
+ * unless the item is a QCustom3DVolume that would be partially visible and scalingAbsolute is also
+ * \c{false}. In that case, the visible portion of the volume will be rendered.
*
* \sa positionAbsolute
*/
@@ -211,7 +240,7 @@ void QCustom3DItem::setPositionAbsolute(bool positionAbsolute)
{
if (d_ptr->m_positionAbsolute != positionAbsolute) {
d_ptr->m_positionAbsolute = positionAbsolute;
- d_ptr->m_dirtyBits.positionAbsoluteDirty = true;
+ d_ptr->m_dirtyBits.positionDirty = true;
emit positionAbsoluteChanged(positionAbsolute);
emit d_ptr->needUpdate();
}
@@ -225,8 +254,13 @@ bool QCustom3DItem::isPositionAbsolute() const
/*! \property QCustom3DItem::scaling
*
* Holds the item \a scaling as a QVector3D. Defaults to \c {QVector3D(0.1, 0.1, 0.1)}.
- * The default value sets the item to 10% of the height of the graph, provided the item size is
- * normalized.
+ *
+ * Item scaling is either in data values or in absolute values, depending on the
+ * scalingAbsolute property. The default vector interpreted as absolute values sets the item to
+ * 10% of the height of the graph, provided the item mesh is normalized and the graph aspect ratios
+ * haven't been changed from the defaults.
+ *
+ * \sa scalingAbsolute
*/
void QCustom3DItem::setScaling(const QVector3D &scaling)
{
@@ -243,6 +277,42 @@ QVector3D QCustom3DItem::scaling() const
return d_ptr->m_scaling;
}
+/*! \property QCustom3DItem::scalingAbsolute
+ * \since QtDataVisualization 1.2
+ *
+ * This property dictates if item scaling is to be handled in data values or in absolute
+ * values. Defaults to \c{true}. Items with absolute scaling will be rendered at the same
+ * size, regardless of axis ranges. Items with data scaling will change their apparent size
+ * according to the axis ranges. If positionAbsolute value is \c{true}, this property is ignored
+ * and scaling is interpreted as an absolute value. If the item has rotation, the data scaling
+ * is calculated on the unrotated item. Similarly, for QCustom3DVolume items, the range clipping
+ * is calculated on the unrotated item.
+ *
+ * \note: Only absolute scaling is supported for QCustom3DLabel items or for custom items used in
+ * \l{QAbstract3DGraph::polar}{polar} graphs.
+ *
+ * \note: The custom item's mesh must be normalized to range \c{[-1 ,1]}, or the data
+ * scaling will not be accurate.
+ *
+ * \sa scaling, positionAbsolute
+ */
+void QCustom3DItem::setScalingAbsolute(bool scalingAbsolute)
+{
+ if (d_ptr->m_isLabelItem && !scalingAbsolute) {
+ qWarning() << __FUNCTION__ << "Data bounds are not supported for label items.";
+ } else if (d_ptr->m_scalingAbsolute != scalingAbsolute) {
+ d_ptr->m_scalingAbsolute = scalingAbsolute;
+ d_ptr->m_dirtyBits.scalingDirty = true;
+ emit scalingAbsoluteChanged(scalingAbsolute);
+ emit d_ptr->needUpdate();
+ }
+}
+
+bool QCustom3DItem::isScalingAbsolute() const
+{
+ return d_ptr->m_scalingAbsolute;
+}
+
/*! \property QCustom3DItem::rotation
*
* Holds the item \a rotation as a QQuaternion. Defaults to \c {QQuaternion(0.0, 0.0, 0.0, 0.0)}.
@@ -367,13 +437,16 @@ QString QCustom3DItem::textureFile() const
QCustom3DItemPrivate::QCustom3DItemPrivate(QCustom3DItem *q) :
q_ptr(q),
+ m_textureImage(QImage(1, 1, QImage::Format_ARGB32)),
m_position(QVector3D(0.0f, 0.0f, 0.0f)),
m_positionAbsolute(false),
m_scaling(QVector3D(0.1f, 0.1f, 0.1f)),
- m_rotation(QQuaternion(0.0f, 0.0f, 0.0f, 0.0f)),
+ m_scalingAbsolute(true),
+ m_rotation(identityQuaternion),
m_visible(true),
m_shadowCasting(true),
- m_isLabelItem(false)
+ m_isLabelItem(false),
+ m_isVolumeItem(false)
{
}
@@ -381,14 +454,17 @@ QCustom3DItemPrivate::QCustom3DItemPrivate(QCustom3DItem *q, const QString &mesh
const QVector3D &position, const QVector3D &scaling,
const QQuaternion &rotation) :
q_ptr(q),
+ m_textureImage(QImage(1, 1, QImage::Format_ARGB32)),
m_meshFile(meshFile),
m_position(position),
m_positionAbsolute(false),
m_scaling(scaling),
+ m_scalingAbsolute(true),
m_rotation(rotation),
m_visible(true),
m_shadowCasting(true),
- m_isLabelItem(false)
+ m_isLabelItem(false),
+ m_isVolumeItem(false)
{
}
@@ -412,7 +488,6 @@ void QCustom3DItemPrivate::resetDirtyBits()
m_dirtyBits.textureDirty = false;
m_dirtyBits.meshDirty = false;
m_dirtyBits.positionDirty = false;
- m_dirtyBits.positionAbsoluteDirty = false;
m_dirtyBits.scalingDirty = false;
m_dirtyBits.rotationDirty = false;
m_dirtyBits.visibleDirty = false;
diff --git a/src/datavisualization/data/qcustom3ditem.h b/src/datavisualization/data/qcustom3ditem.h
index 2f7f37cf..5c880213 100644
--- a/src/datavisualization/data/qcustom3ditem.h
+++ b/src/datavisualization/data/qcustom3ditem.h
@@ -39,6 +39,7 @@ class QT_DATAVISUALIZATION_EXPORT QCustom3DItem : public QObject
Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(bool shadowCasting READ isShadowCasting WRITE setShadowCasting NOTIFY shadowCastingChanged)
+ Q_PROPERTY(bool scalingAbsolute READ isScalingAbsolute WRITE setScalingAbsolute NOTIFY scalingAbsoluteChanged REVISION 1)
public:
explicit QCustom3DItem(QObject *parent = 0);
@@ -62,6 +63,9 @@ public:
void setScaling(const QVector3D &scaling);
QVector3D scaling() const;
+ void setScalingAbsolute(bool scalingAbsolute);
+ bool isScalingAbsolute() const;
+
void setRotation(const QQuaternion &rotation);
QQuaternion rotation();
@@ -84,6 +88,7 @@ signals:
void rotationChanged(const QQuaternion &rotation);
void visibleChanged(bool visible);
void shadowCastingChanged(bool shadowCasting);
+ Q_REVISION(1) void scalingAbsoluteChanged(bool scalingAbsolute);
protected:
QCustom3DItem(QCustom3DItemPrivate *d, QObject *parent = 0);
diff --git a/src/datavisualization/data/qcustom3ditem_p.h b/src/datavisualization/data/qcustom3ditem_p.h
index c1ce5996..627bf53f 100644
--- a/src/datavisualization/data/qcustom3ditem_p.h
+++ b/src/datavisualization/data/qcustom3ditem_p.h
@@ -29,6 +29,7 @@
#ifndef QCUSTOM3DITEM_P_H
#define QCUSTOM3DITEM_P_H
+#include "datavisualizationglobal_p.h"
#include "qcustom3ditem.h"
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -37,7 +38,6 @@ struct QCustomItemDirtyBitField {
bool textureDirty : 1;
bool meshDirty : 1;
bool positionDirty : 1;
- bool positionAbsoluteDirty : 1;
bool scalingDirty : 1;
bool rotationDirty : 1;
bool visibleDirty : 1;
@@ -47,7 +47,6 @@ struct QCustomItemDirtyBitField {
: textureDirty(false),
meshDirty(false),
positionDirty(false),
- positionAbsoluteDirty(false),
scalingDirty(false),
rotationDirty(false),
visibleDirty(false),
@@ -77,11 +76,13 @@ public:
QVector3D m_position;
bool m_positionAbsolute;
QVector3D m_scaling;
+ bool m_scalingAbsolute;
QQuaternion m_rotation;
bool m_visible;
bool m_shadowCasting;
bool m_isLabelItem;
+ bool m_isVolumeItem;
QCustomItemDirtyBitField m_dirtyBits;
diff --git a/src/datavisualization/data/qcustom3dlabel.cpp b/src/datavisualization/data/qcustom3dlabel.cpp
index 85a37e2d..bb5d71d0 100644
--- a/src/datavisualization/data/qcustom3dlabel.cpp
+++ b/src/datavisualization/data/qcustom3dlabel.cpp
@@ -44,6 +44,7 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \since QtDataVisualization 1.1
* \ingroup datavisualization_qml
* \instantiates QCustom3DLabel
+ * \inherits Custom3DItem
* \brief The Custom3DLabel type is for creating custom labels to be added to a graph.
*
* This type is for creating custom labels to be added to a graph. You can set text, font,
diff --git a/src/datavisualization/data/qcustom3dvolume.cpp b/src/datavisualization/data/qcustom3dvolume.cpp
new file mode 100644
index 00000000..f8287a81
--- /dev/null
+++ b/src/datavisualization/data/qcustom3dvolume.cpp
@@ -0,0 +1,1278 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "qcustom3dvolume_p.h"
+#include "utils_p.h"
+
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
+
+/*!
+ * \class QCustom3DVolume
+ * \inmodule QtDataVisualization
+ * \brief The QCustom3DVolume class is for creating volume rendered objects to be added to a graph.
+ * \since QtDataVisualization 1.2
+ *
+ * This class is for creating volume rendered objects to be added to a graph. A volume rendered
+ * object is a box with a 3D texture. Three slice planes are supported for the volume, one along
+ * each main axis of the volume.
+ *
+ * Rendering volume objects is very performance intensive, especially when the volume is largely
+ * transparent, as the contents of the volume are ray-traced. The performance scales nearly linearly
+ * with the amount of pixels that the volume occupies on the screen, so showing the volume in a
+ * smaller view or limiting the zoom level of the graph are easy ways to improve performance.
+ * Similarly, the volume texture dimensions have a large impact on performance.
+ * If the frame rate is more important than pixel-perfect rendering of the volume contents, consider
+ * turning the high definition shader off by setting useHighDefShader property to \c{false}.
+ *
+ * \note Volumetric objects are only supported with orthographic projection.
+ *
+ * \note Volumetric objects utilize 3D textures, which are not supported in OpenGL ES2 environments.
+ *
+ * \sa QAbstract3DGraph::addCustomItem(), QAbstract3DGraph::orthoProjection, useHighDefShader
+ */
+
+/*!
+ * \qmltype Custom3DVolume
+ * \inqmlmodule QtDataVisualization
+ * \since QtDataVisualization 1.2
+ * \ingroup datavisualization_qml
+ * \instantiates QCustom3DVolume
+ * \inherits Custom3DItem
+ * \brief The Custom3DVolume type is for creating volume rendered objects to be added to a graph.
+ *
+ * This class is for creating volume rendered objects to be added to a graph. A volume rendered
+ * object is a box with a 3D texture. Three slice planes are supported for the volume, one along
+ * each main axis of the volume.
+ *
+ * Rendering volume objects is very performance intensive, especially when the volume is largely
+ * transparent, as the contents of the volume are ray-traced. The performance scales nearly linearly
+ * with the amount of pixels that the volume occupies on the screen, so showing the volume in a
+ * smaller view or limiting the zoom level of the graph are easy ways to improve performance.
+ * Similarly, the volume texture dimensions have a large impact on performance.
+ * If the frame rate is more important than pixel-perfect rendering of the volume contents, consider
+ * turning the high definition shader off by setting useHighDefShader property to \c{false}.
+ *
+ * \note: Filling in the volume data would not typically be efficient or practical from pure QML,
+ * so properties directly related to that are not fully supported from QML.
+ * Make a hybrid QML/C++ application if you want to use volume objects with a QML UI.
+ *
+ * \note Volumetric objects are only supported with orthographic projection.
+ *
+ * \note Volumetric objects utilize 3D textures, which are not supported in OpenGL ES2 environments.
+ *
+ * \sa AbstractGraph3D::orthoProjection, useHighDefShader
+ */
+
+/*! \qmlproperty int Custom3DVolume::textureWidth
+ *
+ * The width of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note: Changing this property from QML is not supported, as the texture data cannot be resized
+ * to match.
+ */
+
+/*! \qmlproperty int Custom3DVolume::textureHeight
+ *
+ * The height of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note: Changing this property from QML is not supported, as the texture data cannot be resized
+ * to match.
+ */
+
+/*! \qmlproperty int Custom3DVolume::textureDepth
+ *
+ * The depth of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note: Changing this property from QML is not supported, as the texture data cannot be resized
+ * to match.
+ */
+
+/*! \qmlproperty int Custom3DVolume::sliceIndexX
+ *
+ * The X dimension index into the texture data indicating which vertical slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa QCustom3DVolume::textureData, drawSlices, drawSliceFrames
+ */
+
+/*! \qmlproperty int Custom3DVolume::sliceIndexY
+ *
+ * The Y dimension index into the texture data indicating which horizontal slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa QCustom3DVolume::textureData, drawSlices, drawSliceFrames
+ */
+
+/*! \qmlproperty int Custom3DVolume::sliceIndexZ
+ *
+ * The Z dimension index into the texture data indicating which vertical slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa QCustom3DVolume::textureData, drawSlices, drawSliceFrames
+ */
+
+/*!
+ * \qmlproperty real Custom3DVolume::alphaMultiplier
+ *
+ * The alpha value of every texel of the volume texture is multiplied with this value at
+ * the render time. This can be used to introduce uniform transparency to the volume.
+ * If preserveOpacity is \c{true}, only texels with at least some transparency to begin with are
+ * affected, and fully opaque texels are not affected.
+ * The value must not be negative.
+ * Defaults to \c{1.0}.
+ *
+ * \sa preserveOpacity
+ */
+
+/*!
+ * \qmlproperty bool Custom3DVolume::preserveOpacity
+ *
+ * If this property value is \c{true}, alphaMultiplier is only applied to texels that already have
+ * some transparency. If it is \c{false}, the multiplier is applied to the alpha value of all
+ * texels.
+ * Defaults to \c{true}.
+ *
+ * \sa alphaMultiplier
+ */
+
+/*!
+ * \qmlproperty bool Custom3DVolume::useHighDefShader
+ *
+ * If this property value is \c{true}, a high definition shader is used to render the volume.
+ * If it is \c{false}, a low definition shader is used.
+ *
+ * The high definition shader guarantees that every visible texel of the volume texture is sampled
+ * when the volume is rendered.
+ * The low definition shader renders only a rough approximation of the volume contents,
+ * but at much higher frame rate. The low definition shader doesn't guarantee every texel of the
+ * volume texture is sampled, so there may be flickering if the volume contains distinct thin
+ * features.
+ *
+ * \note This value doesn't affect the level of detail when rendering the slices of the volume.
+ *
+ * Defaults to \c{true}.
+ */
+
+/*!
+ * \qmlproperty bool Custom3DVolume::drawSlices
+ *
+ * If this property value is \c{true}, the slices indicated by slice index properties
+ * will be drawn instead of the full volume.
+ * If it is \c{false}, the full volume will always be drawn.
+ * Defaults to \c{false}.
+ *
+ * \note The slices are always drawn along the item axes, so if the item is rotated, the slices are
+ * rotated as well.
+ *
+ * \sa sliceIndexX, sliceIndexY, sliceIndexZ
+ */
+
+/*!
+ * \qmlproperty bool Custom3DVolume::drawSliceFrames
+ *
+ * If this property value is \c{true}, the frames of slices indicated by slice index properties
+ * will be drawn around the volume.
+ * If it is \c{false}, no slice frames will be drawn.
+ * Drawing slice frames is independent of drawing slices, so you can show the full volume and
+ * still draw the slice frames around it.
+ * Defaults to \c{false}.
+ *
+ * \sa sliceIndexX, sliceIndexY, sliceIndexZ, drawSlices
+ */
+
+/*!
+ * \qmlproperty color Custom3DVolume::sliceFrameColor
+ *
+ * Indicates the color of the slice frame. Transparent slice frame color is not supported.
+ *
+ * Defaults to black.
+ *
+ * \sa drawSliceFrames
+ */
+
+/*!
+ * \qmlproperty vector3d Custom3DVolume::sliceFrameWidths
+ *
+ * Indicates the widths of the slice frame. The width can be different on different dimensions,
+ * so you can for example omit drawing the frames on certain sides of the volume by setting the
+ * value for that dimension to zero. The values are fractions of the volume thickness in the same
+ * dimension. The values cannot be negative.
+ *
+ * Defaults to \c{vector3d(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+
+/*!
+ * \qmlproperty vector3d Custom3DVolume::sliceFrameGaps
+ *
+ * Indicates the amount of air gap left between the volume itself and the frame in each dimension.
+ * The gap can be different on different dimensions. The values are fractions of the volume
+ * thickness in the same dimension. The values cannot be negative.
+ *
+ * Defaults to \c{vector3d(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+
+/*!
+ * \qmlproperty vector3d Custom3DVolume::sliceFrameThicknesses
+ *
+ * Indicates the thickness of the slice frames for each dimension. The values are fractions of
+ * the volume thickness in the same dimension. The values cannot be negative.
+ *
+ * Defaults to \c{vector3d(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+
+/*!
+ * Constructs QCustom3DVolume with given \a parent.
+ */
+QCustom3DVolume::QCustom3DVolume(QObject *parent) :
+ QCustom3DItem(new QCustom3DVolumePrivate(this), parent)
+{
+}
+
+/*!
+ * Constructs QCustom3DVolume with given \a position, \a scaling, \a rotation,
+ * \a textureWidth, \a textureHeight, \a textureDepth, \a textureData, \a textureFormat,
+ * \a colorTable, and optional \a parent.
+ *
+ * \sa textureData, setTextureFormat(), colorTable
+ */
+QCustom3DVolume::QCustom3DVolume(const QVector3D &position, const QVector3D &scaling,
+ const QQuaternion &rotation, int textureWidth,
+ int textureHeight, int textureDepth,
+ QVector<uchar> *textureData, QImage::Format textureFormat,
+ const QVector<QRgb> &colorTable, QObject *parent) :
+ QCustom3DItem(new QCustom3DVolumePrivate(this, position, scaling, rotation, textureWidth,
+ textureHeight, textureDepth,
+ textureData, textureFormat, colorTable), parent)
+{
+}
+
+
+/*!
+ * Destroys QCustom3DVolume.
+ */
+QCustom3DVolume::~QCustom3DVolume()
+{
+}
+
+/*! \property QCustom3DVolume::textureWidth
+ *
+ * The width of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note The textureData may need to be resized or recreated if this value is changed.
+ * Defaults to \c{0}.
+ *
+ * \sa textureData, textureHeight, textureDepth, setTextureFormat(), textureDataWidth()
+ */
+void QCustom3DVolume::setTextureWidth(int value)
+{
+ if (value >= 0) {
+ if (dptr()->m_textureWidth != value) {
+ dptr()->m_textureWidth = value;
+ dptr()->m_dirtyBitsVolume.textureDimensionsDirty = true;
+ emit textureWidthChanged(value);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Cannot set negative value.";
+ }
+}
+
+int QCustom3DVolume::textureWidth() const
+{
+ return dptrc()->m_textureWidth;
+}
+
+/*! \property QCustom3DVolume::textureHeight
+ *
+ * The height of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note The textureData may need to be resized or recreated if this value is changed.
+ * Defaults to \c{0}.
+ *
+ * \sa textureData, textureWidth, textureDepth, setTextureFormat()
+ */
+void QCustom3DVolume::setTextureHeight(int value)
+{
+ if (value >= 0) {
+ if (dptr()->m_textureHeight != value) {
+ dptr()->m_textureHeight = value;
+ dptr()->m_dirtyBitsVolume.textureDimensionsDirty = true;
+ emit textureHeightChanged(value);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Cannot set negative value.";
+ }
+
+}
+
+int QCustom3DVolume::textureHeight() const
+{
+ return dptrc()->m_textureHeight;
+}
+
+/*! \property QCustom3DVolume::textureDepth
+ *
+ * The depth of the 3D texture defining the volume content in pixels. Defaults to \c{0}.
+ *
+ * \note The textureData may need to be resized or recreated if this value is changed.
+ * Defaults to \c{0}.
+ *
+ * \sa textureData, textureWidth, textureHeight, setTextureFormat()
+ */
+void QCustom3DVolume::setTextureDepth(int value)
+{
+ if (value >= 0) {
+ if (dptr()->m_textureDepth != value) {
+ dptr()->m_textureDepth = value;
+ dptr()->m_dirtyBitsVolume.textureDimensionsDirty = true;
+ emit textureDepthChanged(value);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Cannot set negative value.";
+ }
+}
+
+int QCustom3DVolume::textureDepth() const
+{
+ return dptrc()->m_textureDepth;
+}
+
+/*!
+ * A convenience function for setting all three texture dimensions
+ * (\a width, \a height, and \a depth) at once.
+ *
+ * \sa textureData
+ */
+void QCustom3DVolume::setTextureDimensions(int width, int height, int depth)
+{
+ setTextureWidth(width);
+ setTextureHeight(height);
+ setTextureDepth(depth);
+}
+
+/*!
+ * \return the actual texture data width. When the texture format is QImage::Format_Indexed8,
+ * this is textureWidth aligned to 32bit boundary. Otherwise this is four times textureWidth.
+ */
+int QCustom3DVolume::textureDataWidth() const
+{
+ int dataWidth = dptrc()->m_textureWidth;
+
+ if (dptrc()->m_textureFormat == QImage::Format_Indexed8)
+ dataWidth += dataWidth % 4;
+ else
+ dataWidth *= 4;
+
+ return dataWidth;
+}
+
+/*! \property QCustom3DVolume::sliceIndexX
+ *
+ * The X dimension index into the texture data indicating which vertical slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa textureData, drawSlices, drawSliceFrames
+ */
+void QCustom3DVolume::setSliceIndexX(int value)
+{
+ if (dptr()->m_sliceIndexX != value) {
+ dptr()->m_sliceIndexX = value;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceIndexXChanged(value);
+ emit dptr()->needUpdate();
+ }
+}
+
+int QCustom3DVolume::sliceIndexX() const
+{
+ return dptrc()->m_sliceIndexX;
+}
+
+/*! \property QCustom3DVolume::sliceIndexY
+ *
+ * The Y dimension index into the texture data indicating which horizontal slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa textureData, drawSlices, drawSliceFrames
+ */
+void QCustom3DVolume::setSliceIndexY(int value)
+{
+ if (dptr()->m_sliceIndexY != value) {
+ dptr()->m_sliceIndexY = value;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceIndexYChanged(value);
+ emit dptr()->needUpdate();
+ }
+}
+
+int QCustom3DVolume::sliceIndexY() const
+{
+ return dptrc()->m_sliceIndexY;
+}
+
+/*! \property QCustom3DVolume::sliceIndexZ
+ *
+ * The Z dimension index into the texture data indicating which vertical slice to show.
+ * Setting any dimension to negative indicates no slice or slice frame for that dimension is drawn.
+ * If all dimensions are negative, no slices or slice frames are drawn and the volume is drawn
+ * normally.
+ * Defaults to \c{-1}.
+ *
+ * \sa textureData, drawSlices, drawSliceFrames
+ */
+void QCustom3DVolume::setSliceIndexZ(int value)
+{
+ if (dptr()->m_sliceIndexZ != value) {
+ dptr()->m_sliceIndexZ = value;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceIndexZChanged(value);
+ emit dptr()->needUpdate();
+ }
+}
+
+int QCustom3DVolume::sliceIndexZ() const
+{
+ return dptrc()->m_sliceIndexZ;
+}
+
+/*!
+ * A convenience function for setting all three slice indices (\a x, \a y, and \a z) at once.
+ *
+ * \sa textureData
+ */
+void QCustom3DVolume::setSliceIndices(int x, int y, int z)
+{
+ setSliceIndexX(x);
+ setSliceIndexY(y);
+ setSliceIndexZ(z);
+}
+
+/*! \property QCustom3DVolume::colorTable
+ *
+ * The array containing the colors for indexed texture formats. If the texture format is not
+ * indexed, this array is not used and can be empty.
+ *
+ * Defaults to \c{0}.
+ *
+ * \sa textureData, setTextureFormat(), QImage::colorTable()
+ */
+void QCustom3DVolume::setColorTable(const QVector<QRgb> &colors)
+{
+ if (dptr()->m_colorTable != colors) {
+ dptr()->m_colorTable = colors;
+ dptr()->m_dirtyBitsVolume.colorTableDirty = true;
+ emit colorTableChanged();
+ emit dptr()->needUpdate();
+ }
+}
+
+QVector<QRgb> QCustom3DVolume::colorTable() const
+{
+ return dptrc()->m_colorTable;
+}
+
+/*! \property QCustom3DVolume::textureData
+ *
+ * The array containing the texture data in the format specified by textureFormat.
+ * The size of this array must be at least
+ * (\c{textureDataWidth * textureHeight * textureDepth * texture format color depth in bytes}).
+ *
+ * A 3D texture is defined by a stack of 2D subtextures. Each subtexture must be of identical size
+ * (\c{textureDataWidth * textureHeight}), and the depth of the stack is defined by textureDepth
+ * property. Each 2D texture data is identical to a QImage data with the same format, so
+ * QImage::bits() can be used to supply the data for each subtexture.
+ *
+ * Ownership of the new array transfers to QCustom3DVolume instance.
+ * If another array is set, the previous array is deleted.
+ * If the same array is set again, it is assumed that the array contents have been changed and the
+ * graph rendering is triggered.
+ *
+ * \note Each X-line of the data needs to be 32bit aligned. If the textureFormat is
+ * QImage::Format_Indexed8 and textureWidth is not divisible by four, padding bytes need
+ * to be added to each X-line of the \a data. You can get the padded byte count with
+ * textureDataWidth() function. The padding bytes should indicate an fully transparent color
+ * to avoid rendering artifacts.
+ *
+ * Defaults to \c{0}.
+ *
+ * \sa colorTable, setTextureFormat(), setSubTextureData(), textureDataWidth()
+ */
+void QCustom3DVolume::setTextureData(QVector<uchar> *data)
+{
+ if (dptr()->m_textureData != data)
+ delete dptr()->m_textureData;
+
+ // Even if the pointer is same as previously, consider this property changed, as the values
+ // can be changed unbeknownst to us via the array pointer.
+ dptr()->m_textureData = data;
+ dptr()->m_dirtyBitsVolume.textureDataDirty = true;
+ emit textureDataChanged(data);
+ emit dptr()->needUpdate();
+}
+
+/*!
+ * This function creates a new texture data array from an array of \a images and sets it as
+ * textureData for this volume object. The texture dimensions are also set according to image
+ * and array dimensions. All of the images in the array must be the same size. If the images are not
+ * all in QImage::Format_Indexed8 format, all texture data will be converted into
+ * QImage::Format_ARGB32 format. If the images are in QImage::Format_Indexed8 format, the colorTable
+ * for the entire volume will be taken from the first image.
+ *
+ * \return pointer to the newly created array.
+ *
+ * \sa textureData, textureWidth, textureHeight, textureDepth, setTextureFormat()
+ */
+QVector<uchar> *QCustom3DVolume::createTextureData(const QVector<QImage *> &images)
+{
+ int imageCount = images.size();
+ if (imageCount) {
+ QImage *currentImage = images.at(0);
+ int imageWidth = currentImage->width();
+ int imageHeight = currentImage->height();
+ QImage::Format imageFormat = currentImage->format();
+ bool convert = false;
+ if (imageFormat != QImage::Format_Indexed8 && imageFormat != QImage::Format_ARGB32) {
+ convert = true;
+ imageFormat = QImage::Format_ARGB32;
+ } else {
+ for (int i = 0; i < imageCount; i++) {
+ currentImage = images.at(i);
+ if (imageWidth != currentImage->width() || imageHeight != currentImage->height()) {
+ qWarning() << __FUNCTION__ << "Not all images were of the same size.";
+ setTextureData(0);
+ setTextureWidth(0);
+ setTextureHeight(0);
+ setTextureDepth(0);
+ return 0;
+
+ }
+ if (currentImage->format() != imageFormat) {
+ convert = true;
+ imageFormat = QImage::Format_ARGB32;
+ break;
+ }
+ }
+ }
+ int colorBytes = (imageFormat == QImage::Format_Indexed8) ? 1 : 4;
+ int imageByteWidth = (imageFormat == QImage::Format_Indexed8)
+ ? currentImage->bytesPerLine() : imageWidth;
+ int frameSize = imageByteWidth * imageHeight * colorBytes;
+ QVector<uchar> *newTextureData = new QVector<uchar>;
+ newTextureData->resize(frameSize * imageCount);
+ uchar *texturePtr = newTextureData->data();
+ QImage convertedImage;
+
+ for (int i = 0; i < imageCount; i++) {
+ currentImage = images.at(i);
+ if (convert) {
+ convertedImage = currentImage->convertToFormat(imageFormat);
+ currentImage = &convertedImage;
+ }
+ memcpy(texturePtr, static_cast<void *>(currentImage->bits()), frameSize);
+ texturePtr += frameSize;
+ }
+
+ if (imageFormat == QImage::Format_Indexed8)
+ setColorTable(images.at(0)->colorTable());
+ setTextureData(newTextureData);
+ setTextureFormat(imageFormat);
+ setTextureWidth(imageWidth);
+ setTextureHeight(imageHeight);
+ setTextureDepth(imageCount);
+ } else {
+ setTextureData(0);
+ setTextureWidth(0);
+ setTextureHeight(0);
+ setTextureDepth(0);
+ }
+ return dptr()->m_textureData;
+}
+
+QVector<uchar> *QCustom3DVolume::textureData() const
+{
+ return dptrc()->m_textureData;
+}
+
+/*!
+ * This function allows setting a single 2D subtexture of the 3D texture along the specified
+ * \a axis of the volume.
+ * The \a index parameter specifies the subtexture to set.
+ * The texture \a data must be in the format specified by textureFormat property and have size of
+ * the cross-section of the volume texture along the specified axis multiplied by
+ * the texture format color depth in bytes.
+ * The \a data is expected to be ordered similarly to the data in images produced by renderSlice()
+ * method along the same axis.
+ *
+ * \note Each X-line of the data needs to be 32bit aligned when targeting Y-axis or Z-axis.
+ * If the textureFormat is QImage::Format_Indexed8 and textureWidth is not divisible by four,
+ * padding bytes need to be added to each X-line of the \a data in cases it is not already
+ * properly aligned. The padding bytes should indicate an fully transparent color to avoid
+ * rendering artifacts.
+ *
+ * \sa textureData, renderSlice()
+ */
+void QCustom3DVolume::setSubTextureData(Qt::Axis axis, int index, const uchar *data)
+{
+ if (data) {
+ int lineSize = textureDataWidth();
+ int frameSize = lineSize * dptr()->m_textureHeight;
+ int dataSize = dptr()->m_textureData->size();
+ int pixelWidth = (dptr()->m_textureFormat == QImage::Format_Indexed8) ? 1 : 4;
+ int targetIndex;
+ uchar *dataPtr = dptr()->m_textureData->data();
+ bool invalid = (index < 0);
+ if (axis == Qt::XAxis) {
+ targetIndex = index * pixelWidth;
+ if (index >= dptr()->m_textureWidth
+ || (frameSize * (dptr()->m_textureDepth - 1) + targetIndex) > dataSize) {
+ invalid = true;
+ }
+ } else if (axis == Qt::YAxis) {
+ targetIndex = (index * lineSize) + (frameSize * (dptr()->m_textureDepth - 1));
+ if (index >= dptr()->m_textureHeight || (targetIndex + lineSize > dataSize))
+ invalid = true;
+ } else {
+ targetIndex = index * frameSize;
+ if (index >= dptr()->m_textureDepth || ((targetIndex + frameSize) > dataSize))
+ invalid = true;
+ }
+
+ if (invalid) {
+ qWarning() << __FUNCTION__ << "Attempted to set invalid subtexture.";
+ } else {
+ const uchar *sourcePtr = data;
+ uchar *targetPtr = dataPtr + targetIndex;
+ if (axis == Qt::XAxis) {
+ int targetWidth = dptr()->m_textureDepth;
+ int targetHeight = dptr()->m_textureHeight;
+ for (int i = 0; i < targetHeight; i++) {
+ targetPtr = dataPtr + targetIndex + (lineSize * i);
+ for (int j = 0; j < targetWidth; j++) {
+ for (int k = 0; k < pixelWidth; k++)
+ *targetPtr++ = *sourcePtr++;
+ targetPtr += (frameSize - pixelWidth);
+ }
+ }
+ } else if (axis == Qt::YAxis) {
+ int targetHeight = dptr()->m_textureDepth;
+ for (int i = 0; i < targetHeight; i++){
+ for (int j = 0; j < lineSize; j++)
+ *targetPtr++ = *sourcePtr++;
+ targetPtr -= (frameSize + lineSize);
+ }
+ } else {
+ void *subTexPtr = dataPtr + targetIndex;
+ memcpy(subTexPtr, static_cast<const void *>(data), frameSize);
+ }
+ dptr()->m_dirtyBitsVolume.textureDataDirty = true;
+ emit textureDataChanged(dptr()->m_textureData);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Tried to set null data.";
+ }
+}
+
+/*!
+ * This function allows setting a single 2D subtexture of the 3D texture along the specified
+ * \a axis of the volume.
+ * The \a index parameter specifies the subtexture to set.
+ * The source \a image must be in the format specified by the textureFormat property if the
+ * textureFormat is indexed. If the textureFormat is QImage::Format_ARGB32, the image is converted
+ * to that format. The image must have the size of the cross-section of the volume texture along
+ * the specified axis. The orientation of the image should correspond to the orientation of
+ * the slice image produced by renderSlice() method along the same axis.
+ *
+ * \note Each X-line of the data needs to be 32bit aligned when targeting Y-axis or Z-axis.
+ * If the textureFormat is QImage::Format_Indexed8 and textureWidth is not divisible by four,
+ * padding bytes need to be added to each X-line of the \a image in cases it is not already
+ * properly aligned. The padding bytes should indicate an fully transparent color to avoid
+ * rendering artifacts. It is not guaranteed QImage will do this automatically.
+ *
+ * \sa textureData, renderSlice()
+ */
+void QCustom3DVolume::setSubTextureData(Qt::Axis axis, int index, const QImage &image)
+{
+ int sourceWidth = image.width();
+ int sourceHeight = image.height();
+ int targetWidth;
+ int targetHeight;
+ if (axis == Qt::XAxis) {
+ targetWidth = dptr()->m_textureDepth;
+ targetHeight = dptr()->m_textureHeight;
+ } else if (axis == Qt::YAxis) {
+ targetWidth = dptr()->m_textureWidth;
+ targetHeight = dptr()->m_textureDepth;
+ } else {
+ targetWidth = dptr()->m_textureWidth;
+ targetHeight = dptr()->m_textureHeight;
+ }
+
+ if (sourceWidth == targetWidth
+ && sourceHeight == targetHeight
+ && (image.format() == dptr()->m_textureFormat
+ || dptr()->m_textureFormat == QImage::Format_ARGB32)) {
+ QImage convertedImage;
+ if (dptr()->m_textureFormat == QImage::Format_ARGB32
+ && image.format() != QImage::Format_ARGB32) {
+ convertedImage = image.convertToFormat(QImage::Format_ARGB32);
+ } else {
+ convertedImage = image;
+ }
+ setSubTextureData(axis, index, convertedImage.bits());
+ } else {
+ qWarning() << __FUNCTION__ << "Invalid image size or format.";
+ }
+}
+
+// Note: textureFormat is not a Q_PROPERTY to work around an issue in meta object system that
+// doesn't allow QImage::format to be a property type. Qt 5.2.1 at least has this problem.
+
+/*!
+ * Sets the format of the textureData to \a format. Only two formats are supported currently:
+ * QImage::Format_Indexed8 and QImage::Format_ARGB32. If an indexed format is specified, colorTable
+ * must also be set.
+ * Defaults to QImage::Format_ARGB32.
+ *
+ * \sa colorTable, textureData
+ */
+void QCustom3DVolume::setTextureFormat(QImage::Format format)
+{
+ if (format == QImage::Format_ARGB32 || format == QImage::Format_Indexed8) {
+ if (dptr()->m_textureFormat != format) {
+ dptr()->m_textureFormat = format;
+ dptr()->m_dirtyBitsVolume.textureFormatDirty = true;
+ emit textureFormatChanged(format);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Attempted to set invalid texture format.";
+ }
+}
+
+/*!
+ * \return the format of the textureData.
+ *
+ * \sa setTextureFormat()
+ */
+QImage::Format QCustom3DVolume::textureFormat() const
+{
+ return dptrc()->m_textureFormat;
+}
+
+/*!
+ * \fn void QCustom3DVolume::textureFormatChanged(QImage::Format format)
+ *
+ * This signal is emitted when the textureData \a format changes.
+ *
+ * \sa setTextureFormat()
+ */
+
+/*!
+ * \property QCustom3DVolume::alphaMultiplier
+ *
+ * The alpha value of every texel of the volume texture is multiplied with this value at
+ * the render time. This can be used to introduce uniform transparency to the volume.
+ * If preserveOpacity is \c{true}, only texels with at least some transparency to begin with are
+ * affected, and fully opaque texels are not affected.
+ * The value must not be negative.
+ * Defaults to \c{1.0f}.
+ *
+ * \sa preserveOpacity, textureData
+ */
+void QCustom3DVolume::setAlphaMultiplier(float mult)
+{
+ if (mult >= 0.0f) {
+ if (dptr()->m_alphaMultiplier != mult) {
+ dptr()->m_alphaMultiplier = mult;
+ dptr()->m_dirtyBitsVolume.alphaDirty = true;
+ emit alphaMultiplierChanged(mult);
+ emit dptr()->needUpdate();
+ }
+ } else {
+ qWarning() << __FUNCTION__ << "Attempted to set negative multiplier.";
+ }
+}
+
+float QCustom3DVolume::alphaMultiplier() const
+{
+ return dptrc()->m_alphaMultiplier;
+}
+
+/*!
+ * \property QCustom3DVolume::preserveOpacity
+ *
+ * If this property value is \c{true}, alphaMultiplier is only applied to texels that already have
+ * some transparency. If it is \c{false}, the multiplier is applied to the alpha value of all
+ * texels.
+ * Defaults to \c{true}.
+ *
+ * \sa alphaMultiplier
+ */
+void QCustom3DVolume::setPreserveOpacity(bool enable)
+{
+ if (dptr()->m_preserveOpacity != enable) {
+ dptr()->m_preserveOpacity = enable;
+ dptr()->m_dirtyBitsVolume.alphaDirty = true;
+ emit preserveOpacityChanged(enable);
+ emit dptr()->needUpdate();
+ }
+}
+
+bool QCustom3DVolume::preserveOpacity() const
+{
+ return dptrc()->m_preserveOpacity;
+}
+
+/*!
+ * \property QCustom3DVolume::useHighDefShader
+ *
+ * If this property value is \c{true}, a high definition shader is used to render the volume.
+ * If it is \c{false}, a low definition shader is used.
+ *
+ * The high definition shader guarantees that every visible texel of the volume texture is sampled
+ * when the volume is rendered.
+ * The low definition shader renders only a rough approximation of the volume contents,
+ * but at much higher frame rate. The low definition shader doesn't guarantee every texel of the
+ * volume texture is sampled, so there may be flickering if the volume contains distinct thin
+ * features.
+ *
+ * \note This value doesn't affect the level of detail when rendering the slices of the volume.
+ *
+ * Defaults to \c{true}.
+ *
+ * \sa renderSlice()
+ */
+void QCustom3DVolume::setUseHighDefShader(bool enable)
+{
+ if (dptr()->m_useHighDefShader != enable) {
+ dptr()->m_useHighDefShader = enable;
+ dptr()->m_dirtyBitsVolume.shaderDirty = true;
+ emit useHighDefShaderChanged(enable);
+ emit dptr()->needUpdate();
+ }
+}
+
+bool QCustom3DVolume::useHighDefShader() const
+{
+ return dptrc()->m_useHighDefShader;
+}
+
+/*!
+ * \property QCustom3DVolume::drawSlices
+ *
+ * If this property value is \c{true}, the slices indicated by slice index properties
+ * will be drawn instead of the full volume.
+ * If it is \c{false}, the full volume will always be drawn.
+ * Defaults to \c{false}.
+ *
+ * \note The slices are always drawn along the item axes, so if the item is rotated, the slices are
+ * rotated as well.
+ *
+ * \sa sliceIndexX, sliceIndexY, sliceIndexZ
+ */
+void QCustom3DVolume::setDrawSlices(bool enable)
+{
+ if (dptr()->m_drawSlices != enable) {
+ dptr()->m_drawSlices = enable;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit drawSlicesChanged(enable);
+ emit dptr()->needUpdate();
+ }
+}
+
+bool QCustom3DVolume::drawSlices() const
+{
+ return dptrc()->m_drawSlices;
+}
+
+/*!
+ * \property QCustom3DVolume::drawSliceFrames
+ *
+ * If this property value is \c{true}, the frames of slices indicated by slice index properties
+ * will be drawn around the volume.
+ * If it is \c{false}, no slice frames will be drawn.
+ * Drawing slice frames is independent of drawing slices, so you can show the full volume and
+ * still draw the slice frames around it. This is useful when using renderSlice() to display the
+ * slices outside the graph itself.
+ * Defaults to \c{false}.
+ *
+ * \sa sliceIndexX, sliceIndexY, sliceIndexZ, drawSlices, renderSlice()
+ */
+void QCustom3DVolume::setDrawSliceFrames(bool enable)
+{
+ if (dptr()->m_drawSliceFrames != enable) {
+ dptr()->m_drawSliceFrames = enable;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit drawSliceFramesChanged(enable);
+ emit dptr()->needUpdate();
+ }
+}
+
+bool QCustom3DVolume::drawSliceFrames() const
+{
+ return dptrc()->m_drawSliceFrames;
+}
+
+/*!
+ * \property QCustom3DVolume::sliceFrameColor
+ *
+ * Indicates the color of the slice frame. Transparent slice frame color is not supported.
+ *
+ * Defaults to black.
+ *
+ * \sa drawSliceFrames
+ */
+void QCustom3DVolume::setSliceFrameColor(const QColor &color)
+{
+ if (dptr()->m_sliceFrameColor != color) {
+ dptr()->m_sliceFrameColor = color;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceFrameColorChanged(color);
+ emit dptr()->needUpdate();
+ }
+}
+
+QColor QCustom3DVolume::sliceFrameColor() const
+{
+ return dptrc()->m_sliceFrameColor;
+}
+
+/*!
+ * \property QCustom3DVolume::sliceFrameWidths
+ *
+ * Indicates the widths of the slice frame. The width can be different on different dimensions,
+ * so you can for example omit drawing the frames on certain sides of the volume by setting the
+ * value for that dimension to zero. The values are fractions of the volume thickness in the same
+ * dimension. The values cannot be negative.
+ *
+ * Defaults to \c{QVector3D(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+void QCustom3DVolume::setSliceFrameWidths(const QVector3D &values)
+{
+ if (values.x() < 0.0f || values.y() < 0.0f || values.z() < 0.0f) {
+ qWarning() << __FUNCTION__ << "Attempted to set negative values.";
+ } else if (dptr()->m_sliceFrameWidths != values) {
+ dptr()->m_sliceFrameWidths = values;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceFrameWidthsChanged(values);
+ emit dptr()->needUpdate();
+ }
+}
+
+QVector3D QCustom3DVolume::sliceFrameWidths() const
+{
+ return dptrc()->m_sliceFrameWidths;
+}
+
+/*!
+ * \property QCustom3DVolume::sliceFrameGaps
+ *
+ * Indicates the amount of air gap left between the volume itself and the frame in each dimension.
+ * The gap can be different on different dimensions. The values are fractions of the volume
+ * thickness in the same dimension. The values cannot be negative.
+ *
+ * Defaults to \c{QVector3D(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+void QCustom3DVolume::setSliceFrameGaps(const QVector3D &values)
+{
+ if (values.x() < 0.0f || values.y() < 0.0f || values.z() < 0.0f) {
+ qWarning() << __FUNCTION__ << "Attempted to set negative values.";
+ } else if (dptr()->m_sliceFrameGaps != values) {
+ dptr()->m_sliceFrameGaps = values;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceFrameGapsChanged(values);
+ emit dptr()->needUpdate();
+ }
+}
+
+QVector3D QCustom3DVolume::sliceFrameGaps() const
+{
+ return dptrc()->m_sliceFrameGaps;
+}
+
+/*!
+ * \property QCustom3DVolume::sliceFrameThicknesses
+ *
+ * Indicates the thickness of the slice frames for each dimension. The values are fractions of
+ * the volume thickness in the same dimension. The values cannot be negative.
+ *
+ * Defaults to \c{QVector3D(0.01, 0.01, 0.01)}.
+ *
+ * \sa drawSliceFrames
+ */
+void QCustom3DVolume::setSliceFrameThicknesses(const QVector3D &values)
+{
+ if (values.x() < 0.0f || values.y() < 0.0f || values.z() < 0.0f) {
+ qWarning() << __FUNCTION__ << "Attempted to set negative values.";
+ } else if (dptr()->m_sliceFrameThicknesses != values) {
+ dptr()->m_sliceFrameThicknesses = values;
+ dptr()->m_dirtyBitsVolume.slicesDirty = true;
+ emit sliceFrameThicknessesChanged(values);
+ emit dptr()->needUpdate();
+ }
+}
+
+QVector3D QCustom3DVolume::sliceFrameThicknesses() const
+{
+ return dptrc()->m_sliceFrameThicknesses;
+}
+
+/*!
+ * Renders the slice specified by \a index along \a axis into an image.
+ * The texture format of this object is used.
+ *
+ * \return the rendered image of the slice, or a null image if invalid index is specified.
+ *
+ * \sa setTextureFormat()
+ */
+QImage QCustom3DVolume::renderSlice(Qt::Axis axis, int index)
+{
+ return dptr()->renderSlice(axis, index);
+}
+
+/*!
+ * \internal
+ */
+QCustom3DVolumePrivate *QCustom3DVolume::dptr()
+{
+ return static_cast<QCustom3DVolumePrivate *>(d_ptr.data());
+}
+
+/*!
+ * \internal
+ */
+const QCustom3DVolumePrivate *QCustom3DVolume::dptrc() const
+{
+ return static_cast<const QCustom3DVolumePrivate *>(d_ptr.data());
+}
+
+QCustom3DVolumePrivate::QCustom3DVolumePrivate(QCustom3DVolume *q) :
+ QCustom3DItemPrivate(q),
+ m_textureWidth(0),
+ m_textureHeight(0),
+ m_textureDepth(0),
+ m_sliceIndexX(-1),
+ m_sliceIndexY(-1),
+ m_sliceIndexZ(-1),
+ m_textureFormat(QImage::Format_ARGB32),
+ m_textureData(0),
+ m_alphaMultiplier(1.0f),
+ m_preserveOpacity(true),
+ m_useHighDefShader(true),
+ m_drawSlices(false),
+ m_drawSliceFrames(false),
+ m_sliceFrameColor(Qt::black),
+ m_sliceFrameWidths(QVector3D(0.01f, 0.01f, 0.01f)),
+ m_sliceFrameGaps(QVector3D(0.01f, 0.01f, 0.01f)),
+ m_sliceFrameThicknesses(QVector3D(0.01f, 0.01f, 0.01f))
+{
+ m_isVolumeItem = true;
+ m_meshFile = QStringLiteral(":/defaultMeshes/barFull");
+}
+
+QCustom3DVolumePrivate::QCustom3DVolumePrivate(QCustom3DVolume *q, const QVector3D &position,
+ const QVector3D &scaling,
+ const QQuaternion &rotation,
+ int textureWidth, int textureHeight,
+ int textureDepth, QVector<uchar> *textureData,
+ QImage::Format textureFormat,
+ const QVector<QRgb> &colorTable) :
+ QCustom3DItemPrivate(q, QStringLiteral(":/defaultMeshes/barFull"), position, scaling, rotation),
+ m_textureWidth(textureWidth),
+ m_textureHeight(textureHeight),
+ m_textureDepth(textureDepth),
+ m_sliceIndexX(-1),
+ m_sliceIndexY(-1),
+ m_sliceIndexZ(-1),
+ m_textureFormat(textureFormat),
+ m_colorTable(colorTable),
+ m_textureData(textureData),
+ m_alphaMultiplier(1.0f),
+ m_preserveOpacity(true),
+ m_useHighDefShader(true),
+ m_drawSlices(false),
+ m_drawSliceFrames(false),
+ m_sliceFrameColor(Qt::black),
+ m_sliceFrameWidths(QVector3D(0.01f, 0.01f, 0.01f)),
+ m_sliceFrameGaps(QVector3D(0.01f, 0.01f, 0.01f)),
+ m_sliceFrameThicknesses(QVector3D(0.01f, 0.01f, 0.01f))
+{
+ m_isVolumeItem = true;
+ m_shadowCasting = false;
+
+ if (m_textureWidth < 0)
+ m_textureWidth = 0;
+ if (m_textureHeight < 0)
+ m_textureHeight = 0;
+ if (m_textureDepth < 0)
+ m_textureDepth = 0;
+
+ if (m_textureFormat != QImage::Format_Indexed8)
+ m_textureFormat = QImage::Format_ARGB32;
+
+}
+
+QCustom3DVolumePrivate::~QCustom3DVolumePrivate()
+{
+ delete m_textureData;
+}
+
+void QCustom3DVolumePrivate::resetDirtyBits()
+{
+ QCustom3DItemPrivate::resetDirtyBits();
+
+ m_dirtyBitsVolume.textureDimensionsDirty = false;
+ m_dirtyBitsVolume.slicesDirty = false;
+ m_dirtyBitsVolume.colorTableDirty = false;
+ m_dirtyBitsVolume.textureDataDirty = false;
+ m_dirtyBitsVolume.textureFormatDirty = false;
+ m_dirtyBitsVolume.alphaDirty = false;
+ m_dirtyBitsVolume.shaderDirty = false;
+}
+
+QImage QCustom3DVolumePrivate::renderSlice(Qt::Axis axis, int index)
+{
+ if (index < 0)
+ return QImage();
+
+ int x;
+ int y;
+ if (axis == Qt::XAxis) {
+ if (index >= m_textureWidth)
+ return QImage();
+ x = m_textureDepth;
+ y = m_textureHeight;
+ } else if (axis == Qt::YAxis) {
+ if (index >= m_textureHeight)
+ return QImage();
+ x = m_textureWidth;
+ y = m_textureDepth;
+ } else {
+ if (index >= m_textureDepth)
+ return QImage();
+ x = m_textureWidth;
+ y = m_textureHeight;
+ }
+
+ int padding = 0;
+ int pixelWidth = 4;
+ int dataWidth = qptr()->textureDataWidth();
+ if (m_textureFormat == QImage::Format_Indexed8) {
+ padding = x % 4;
+ pixelWidth = 1;
+ }
+ QVector<uchar> data((x + padding) * y * pixelWidth);
+ int frameSize = qptr()->textureDataWidth() * m_textureHeight;
+
+ int dataIndex = 0;
+ if (axis == Qt::XAxis) {
+ for (int i = 0; i < y; i++) {
+ const uchar *p = m_textureData->constData()
+ + (index * pixelWidth) + (dataWidth * i);
+ for (int j = 0; j < x; j++) {
+ for (int k = 0; k < pixelWidth; k++)
+ data[dataIndex++] = *(p + k);
+ p += frameSize;
+ }
+ }
+ } else if (axis == Qt::YAxis) {
+ for (int i = y - 1; i >= 0; i--) {
+ const uchar *p = m_textureData->constData() + (index * dataWidth)
+ + (frameSize * i);
+ for (int j = 0; j < (x * pixelWidth); j++) {
+ data[dataIndex++] = *p;
+ p++;
+ }
+ }
+ } else {
+ for (int i = 0; i < y; i++) {
+ const uchar *p = m_textureData->constData() + (index * frameSize) + (dataWidth * i);
+ for (int j = 0; j < (x * pixelWidth); j++) {
+ data[dataIndex++] = *p;
+ p++;
+ }
+ }
+ }
+
+ if (m_textureFormat != QImage::Format_Indexed8 && m_alphaMultiplier != 1.0f) {
+ for (int i = pixelWidth - 1; i < data.size(); i += pixelWidth)
+ data[i] = static_cast<uchar>(multipliedAlphaValue(data.at(i)));
+ }
+
+ QImage image(data.constData(), x, y, x * pixelWidth, m_textureFormat);
+ image.bits(); // Call bits() to detach the new image from local data
+ if (m_textureFormat == QImage::Format_Indexed8) {
+ QVector<QRgb> colorTable = m_colorTable;
+ if (m_alphaMultiplier != 1.0f) {
+ for (int i = 0; i < colorTable.size(); i++) {
+ QRgb curCol = colorTable.at(i);
+ int alpha = multipliedAlphaValue(qAlpha(curCol));
+ if (alpha != qAlpha(curCol))
+ colorTable[i] = qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), alpha);
+ }
+ }
+ image.setColorTable(colorTable);
+ }
+
+ return image;
+}
+
+int QCustom3DVolumePrivate::multipliedAlphaValue(int alpha)
+{
+ int modifiedAlpha = alpha;
+ if (!m_preserveOpacity || alpha != 255) {
+ modifiedAlpha = int(m_alphaMultiplier * float(alpha));
+ modifiedAlpha = qMin(modifiedAlpha, 255);
+ }
+ return modifiedAlpha;
+}
+
+QCustom3DVolume *QCustom3DVolumePrivate::qptr()
+{
+ return static_cast<QCustom3DVolume *>(q_ptr);
+}
+
+QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/data/qcustom3dvolume.h b/src/datavisualization/data/qcustom3dvolume.h
new file mode 100644
index 00000000..a9dfda86
--- /dev/null
+++ b/src/datavisualization/data/qcustom3dvolume.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef QCUSTOM3DVOLUME_H
+#define QCUSTOM3DVOLUME_H
+
+#include <QtDataVisualization/qdatavisualizationglobal.h>
+#include <QtDataVisualization/QCustom3DItem>
+#include <QtGui/QColor>
+#include <QtGui/QImage>
+
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
+
+class QCustom3DVolumePrivate;
+
+class QT_DATAVISUALIZATION_EXPORT QCustom3DVolume : public QCustom3DItem
+{
+ Q_OBJECT
+ Q_PROPERTY(int textureWidth READ textureWidth WRITE setTextureWidth NOTIFY textureWidthChanged)
+ Q_PROPERTY(int textureHeight READ textureHeight WRITE setTextureHeight NOTIFY textureHeightChanged)
+ Q_PROPERTY(int textureDepth READ textureDepth WRITE setTextureDepth NOTIFY textureDepthChanged)
+ Q_PROPERTY(int sliceIndexX READ sliceIndexX WRITE setSliceIndexX NOTIFY sliceIndexXChanged)
+ Q_PROPERTY(int sliceIndexY READ sliceIndexY WRITE setSliceIndexY NOTIFY sliceIndexYChanged)
+ Q_PROPERTY(int sliceIndexZ READ sliceIndexZ WRITE setSliceIndexZ NOTIFY sliceIndexZChanged)
+ Q_PROPERTY(QVector<QRgb> colorTable READ colorTable WRITE setColorTable NOTIFY colorTableChanged)
+ Q_PROPERTY(QVector<uchar> *textureData READ textureData WRITE setTextureData NOTIFY textureDataChanged)
+ Q_PROPERTY(float alphaMultiplier READ alphaMultiplier WRITE setAlphaMultiplier NOTIFY alphaMultiplierChanged)
+ Q_PROPERTY(bool preserveOpacity READ preserveOpacity WRITE setPreserveOpacity NOTIFY preserveOpacityChanged)
+ Q_PROPERTY(bool useHighDefShader READ useHighDefShader WRITE setUseHighDefShader NOTIFY useHighDefShaderChanged)
+ Q_PROPERTY(bool drawSlices READ drawSlices WRITE setDrawSlices NOTIFY drawSlicesChanged)
+ Q_PROPERTY(bool drawSliceFrames READ drawSliceFrames WRITE setDrawSliceFrames NOTIFY drawSliceFramesChanged)
+ Q_PROPERTY(QColor sliceFrameColor READ sliceFrameColor WRITE setSliceFrameColor NOTIFY sliceFrameColorChanged)
+ Q_PROPERTY(QVector3D sliceFrameWidths READ sliceFrameWidths WRITE setSliceFrameWidths NOTIFY sliceFrameWidthsChanged)
+ Q_PROPERTY(QVector3D sliceFrameGaps READ sliceFrameGaps WRITE setSliceFrameGaps NOTIFY sliceFrameGapsChanged)
+ Q_PROPERTY(QVector3D sliceFrameThicknesses READ sliceFrameThicknesses WRITE setSliceFrameThicknesses NOTIFY sliceFrameThicknessesChanged)
+
+public:
+
+ explicit QCustom3DVolume(QObject *parent = 0);
+ explicit QCustom3DVolume(const QVector3D &position, const QVector3D &scaling,
+ const QQuaternion &rotation, int textureWidth,
+ int textureHeight, int textureDepth,
+ QVector<uchar> *textureData, QImage::Format textureFormat,
+ const QVector<QRgb> &colorTable, QObject *parent = 0);
+ virtual ~QCustom3DVolume();
+
+ void setTextureWidth(int value);
+ int textureWidth() const;
+ void setTextureHeight(int value);
+ int textureHeight() const;
+ void setTextureDepth(int value);
+ int textureDepth() const;
+ void setTextureDimensions(int width, int height, int depth);
+ int textureDataWidth() const;
+
+ void setSliceIndexX(int value);
+ int sliceIndexX() const;
+ void setSliceIndexY(int value);
+ int sliceIndexY() const;
+ void setSliceIndexZ(int value);
+ int sliceIndexZ() const;
+ void setSliceIndices(int x, int y, int z);
+
+ void setColorTable(const QVector<QRgb> &colors);
+ QVector<QRgb> colorTable() const;
+
+ void setTextureData(QVector<uchar> *data);
+ QVector<uchar> *createTextureData(const QVector<QImage *> &images);
+ QVector<uchar> *textureData() const;
+ void setSubTextureData(Qt::Axis axis, int index, const uchar *data);
+ void setSubTextureData(Qt::Axis axis, int index, const QImage &image);
+
+ void setTextureFormat(QImage::Format format);
+ QImage::Format textureFormat() const;
+
+ void setAlphaMultiplier(float mult);
+ float alphaMultiplier() const;
+ void setPreserveOpacity(bool enable);
+ bool preserveOpacity() const;
+
+ void setUseHighDefShader(bool enable);
+ bool useHighDefShader() const;
+
+ void setDrawSlices(bool enable);
+ bool drawSlices() const;
+ void setDrawSliceFrames(bool enable);
+ bool drawSliceFrames() const;
+
+ void setSliceFrameColor(const QColor &color);
+ QColor sliceFrameColor() const;
+ void setSliceFrameWidths(const QVector3D &values);
+ QVector3D sliceFrameWidths() const;
+ void setSliceFrameGaps(const QVector3D &values);
+ QVector3D sliceFrameGaps() const;
+ void setSliceFrameThicknesses(const QVector3D &values);
+ QVector3D sliceFrameThicknesses() const;
+
+ QImage renderSlice(Qt::Axis axis, int index);
+
+signals:
+ void textureWidthChanged(int value);
+ void textureHeightChanged(int value);
+ void textureDepthChanged(int value);
+ void sliceIndexXChanged(int value);
+ void sliceIndexYChanged(int value);
+ void sliceIndexZChanged(int value);
+ void colorTableChanged();
+ void textureDataChanged(QVector<uchar> *data);
+ void textureFormatChanged(QImage::Format format);
+ void alphaMultiplierChanged(float mult);
+ void preserveOpacityChanged(bool enabled);
+ void useHighDefShaderChanged(bool enabled);
+ void drawSlicesChanged(bool enabled);
+ void drawSliceFramesChanged(bool enabled);
+ void sliceFrameColorChanged(const QColor &color);
+ void sliceFrameWidthsChanged(const QVector3D &values);
+ void sliceFrameGapsChanged(const QVector3D &values);
+ void sliceFrameThicknessesChanged(const QVector3D &values);
+
+protected:
+ QCustom3DVolumePrivate *dptr();
+ const QCustom3DVolumePrivate *dptrc() const;
+
+private:
+ Q_DISABLE_COPY(QCustom3DVolume)
+
+ friend class Abstract3DRenderer;
+};
+
+QT_END_NAMESPACE_DATAVISUALIZATION
+
+#endif
diff --git a/src/datavisualization/data/qcustom3dvolume_p.h b/src/datavisualization/data/qcustom3dvolume_p.h
new file mode 100644
index 00000000..642d2af5
--- /dev/null
+++ b/src/datavisualization/data/qcustom3dvolume_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the QtDataVisualization API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef QCUSTOM3DVOLUME_P_H
+#define QCUSTOM3DVOLUME_P_H
+
+#include "qcustom3dvolume.h"
+#include "qcustom3ditem_p.h"
+
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
+
+struct QCustomVolumeDirtyBitField {
+ bool textureDimensionsDirty : 1;
+ bool slicesDirty : 1;
+ bool colorTableDirty : 1;
+ bool textureDataDirty : 1;
+ bool textureFormatDirty : 1;
+ bool alphaDirty : 1;
+ bool shaderDirty : 1;
+
+ QCustomVolumeDirtyBitField()
+ : textureDimensionsDirty(false),
+ slicesDirty(false),
+ colorTableDirty(false),
+ textureDataDirty(false),
+ textureFormatDirty(false),
+ alphaDirty(false),
+ shaderDirty(false)
+ {
+ }
+};
+
+class QCustom3DVolumePrivate : public QCustom3DItemPrivate
+{
+ Q_OBJECT
+
+public:
+ QCustom3DVolumePrivate(QCustom3DVolume *q);
+ QCustom3DVolumePrivate(QCustom3DVolume *q, const QVector3D &position, const QVector3D &scaling,
+ const QQuaternion &rotation, int textureWidth,
+ int textureHeight, int textureDepth, QVector<uchar> *textureData,
+ QImage::Format textureFormat, const QVector<QRgb> &colorTable);
+ virtual ~QCustom3DVolumePrivate();
+
+ void resetDirtyBits();
+ QImage renderSlice(Qt::Axis axis, int index);
+
+ QCustom3DVolume *qptr();
+
+public:
+ int m_textureWidth;
+ int m_textureHeight;
+ int m_textureDepth;
+ int m_sliceIndexX;
+ int m_sliceIndexY;
+ int m_sliceIndexZ;
+
+ QImage::Format m_textureFormat;
+ QVector<QRgb> m_colorTable;
+ QVector<uchar> *m_textureData;
+
+ float m_alphaMultiplier;
+ bool m_preserveOpacity;
+ bool m_useHighDefShader;
+
+ bool m_drawSlices;
+ bool m_drawSliceFrames;
+ QColor m_sliceFrameColor;
+ QVector3D m_sliceFrameWidths;
+ QVector3D m_sliceFrameGaps;
+ QVector3D m_sliceFrameThicknesses;
+
+ QCustomVolumeDirtyBitField m_dirtyBitsVolume;
+
+private:
+ int multipliedAlphaValue(int alpha);
+
+ friend class QCustom3DVolume;
+};
+
+QT_END_NAMESPACE_DATAVISUALIZATION
+
+#endif
diff --git a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
index d64046be..85aed432 100644
--- a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
@@ -84,7 +84,7 @@ const float defaultMaxValue = 10.0f;
/*!
* \qmlproperty real HeightMapSurfaceDataProxy::minXValue
*
- * The minimum X value for the generated surface points.
+ * The minimum X value for the generated surface points. Defaults to \c{0.0}.
* When setting this property the corresponding maximum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -92,7 +92,7 @@ const float defaultMaxValue = 10.0f;
/*!
* \qmlproperty real HeightMapSurfaceDataProxy::maxXValue
*
- * The maximum X value for the generated surface points.
+ * The maximum X value for the generated surface points. Defaults to \c{10.0}.
* When setting this property the corresponding minimum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -100,7 +100,7 @@ const float defaultMaxValue = 10.0f;
/*!
* \qmlproperty real HeightMapSurfaceDataProxy::minZValue
*
- * The minimum Z value for the generated surface points.
+ * The minimum Z value for the generated surface points. Defaults to \c{0.0}.
* When setting this property the corresponding maximum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -108,7 +108,7 @@ const float defaultMaxValue = 10.0f;
/*!
* \qmlproperty real HeightMapSurfaceDataProxy::maxZValue
*
- * The maximum Z value for the generated surface points.
+ * The maximum Z value for the generated surface points. Defaults to \c{10.0}.
* When setting this property the corresponding minimum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -228,7 +228,7 @@ void QHeightMapSurfaceDataProxy::setValueRanges(float minX, float maxX, float mi
/*!
* \property QHeightMapSurfaceDataProxy::minXValue
*
- * The minimum X value for the generated surface points.
+ * The minimum X value for the generated surface points. Defaults to \c{0.0}.
* When setting this property the corresponding maximum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -245,7 +245,7 @@ float QHeightMapSurfaceDataProxy::minXValue() const
/*!
* \property QHeightMapSurfaceDataProxy::maxXValue
*
- * The maximum X value for the generated surface points.
+ * The maximum X value for the generated surface points. Defaults to \c{10.0}.
* When setting this property the corresponding minimum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -262,7 +262,7 @@ float QHeightMapSurfaceDataProxy::maxXValue() const
/*!
* \property QHeightMapSurfaceDataProxy::minZValue
*
- * The minimum Z value for the generated surface points.
+ * The minimum Z value for the generated surface points. Defaults to \c{0.0}.
* When setting this property the corresponding maximum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
@@ -279,7 +279,7 @@ float QHeightMapSurfaceDataProxy::minZValue() const
/*!
* \property QHeightMapSurfaceDataProxy::maxZValue
*
- * The maximum Z value for the generated surface points.
+ * The maximum Z value for the generated surface points. Defaults to \c{10.0}.
* When setting this property the corresponding minimum value is adjusted if necessary,
* to ensure that the range remains valid.
*/
diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp
index 1107d721..7d4dacfe 100644
--- a/src/datavisualization/data/qsurface3dseries.cpp
+++ b/src/datavisualization/data/qsurface3dseries.cpp
@@ -141,6 +141,14 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
*/
/*!
+ * \qmlproperty string Surface3DSeries::textureFile
+ *
+ * Holds the texture file name for the surface texture. To clear the texture, set empty
+ * file name.
+ */
+
+
+/*!
* \enum QSurface3DSeries::DrawFlag
*
* Drawing mode of the surface. Values of this enumeration can be combined with OR operator.
@@ -300,6 +308,57 @@ QSurface3DSeries::DrawFlags QSurface3DSeries::drawMode() const
}
/*!
+ * \property QSurface3DSeries::texture
+ *
+ * Set the \a texture as a QImage for the surface. To clear the texture, set empty
+ * QImage as texture.
+ */
+void QSurface3DSeries::setTexture(const QImage &texture)
+{
+ if (dptr()->m_texture != texture) {
+ dptr()->setTexture(texture);
+
+ emit textureChanged(texture);
+ dptr()->m_textureFile.clear();
+ }
+}
+
+QImage QSurface3DSeries::texture() const
+{
+ return dptrc()->m_texture;
+}
+
+/*!
+ * \property QSurface3DSeries::textureFile
+ *
+ * Holds the texture file name for the surface texture. To clear the texture, set empty
+ * file name.
+ */
+void QSurface3DSeries::setTextureFile(const QString &filename)
+{
+ if (dptr()->m_textureFile != filename) {
+ if (filename.isEmpty()) {
+ setTexture(QImage());
+ } else {
+ QImage image(filename);
+ if (image.isNull()) {
+ qWarning() << "Warning: Tried to set invalid image file as surface texture.";
+ return;
+ }
+ setTexture(image);
+ }
+
+ dptr()->m_textureFile = filename;
+ emit textureFileChanged(filename);
+ }
+}
+
+QString QSurface3DSeries::textureFile() const
+{
+ return dptrc()->m_textureFile;
+}
+
+/*!
* \internal
*/
QSurface3DSeriesPrivate *QSurface3DSeries::dptr()
@@ -445,4 +504,11 @@ void QSurface3DSeriesPrivate::setDrawMode(QSurface3DSeries::DrawFlags mode)
}
}
+void QSurface3DSeriesPrivate::setTexture(const QImage &texture)
+{
+ m_texture = texture;
+ if (static_cast<Surface3DController *>(m_controller))
+ static_cast<Surface3DController *>(m_controller)->updateSurfaceTexture(qptr());
+}
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/data/qsurface3dseries.h b/src/datavisualization/data/qsurface3dseries.h
index 64df7202..7051e583 100644
--- a/src/datavisualization/data/qsurface3dseries.h
+++ b/src/datavisualization/data/qsurface3dseries.h
@@ -35,6 +35,8 @@ class QT_DATAVISUALIZATION_EXPORT QSurface3DSeries : public QAbstract3DSeries
Q_PROPERTY(bool flatShadingEnabled READ isFlatShadingEnabled WRITE setFlatShadingEnabled NOTIFY flatShadingEnabledChanged)
Q_PROPERTY(bool flatShadingSupported READ isFlatShadingSupported NOTIFY flatShadingSupportedChanged)
Q_PROPERTY(DrawFlags drawMode READ drawMode WRITE setDrawMode NOTIFY drawModeChanged)
+ Q_PROPERTY(QImage texture READ texture WRITE setTexture NOTIFY textureChanged)
+ Q_PROPERTY(QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged)
public:
enum DrawFlag {
@@ -63,12 +65,19 @@ public:
bool isFlatShadingSupported() const;
+ void setTexture(const QImage &texture);
+ QImage texture() const;
+ void setTextureFile(const QString &filename);
+ QString textureFile() const;
+
signals:
void dataProxyChanged(QSurfaceDataProxy *proxy);
void selectedPointChanged(const QPoint &position);
void flatShadingEnabledChanged(bool enable);
void flatShadingSupportedChanged(bool enable);
void drawModeChanged(QSurface3DSeries::DrawFlags mode);
+ void textureChanged(const QImage &image);
+ void textureFileChanged(const QString &filename);
protected:
explicit QSurface3DSeries(QSurface3DSeriesPrivate *d, QObject *parent = 0);
diff --git a/src/datavisualization/data/qsurface3dseries_p.h b/src/datavisualization/data/qsurface3dseries_p.h
index d4cc2820..270a3ad1 100644
--- a/src/datavisualization/data/qsurface3dseries_p.h
+++ b/src/datavisualization/data/qsurface3dseries_p.h
@@ -48,6 +48,7 @@ public:
void setSelectedPoint(const QPoint &position);
void setFlatShadingEnabled(bool enabled);
void setDrawMode(QSurface3DSeries::DrawFlags mode);
+ void setTexture(const QImage &texture);
private:
QSurface3DSeries *qptr();
@@ -55,6 +56,8 @@ private:
QPoint m_selectedPoint;
bool m_flatShadingEnabled;
QSurface3DSeries::DrawFlags m_drawMode;
+ QImage m_texture;
+ QString m_textureFile;
private:
friend class QSurface3DSeries;
diff --git a/src/datavisualization/data/qsurfacedataproxy.cpp b/src/datavisualization/data/qsurfacedataproxy.cpp
index dbe7cc49..12b24465 100644
--- a/src/datavisualization/data/qsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qsurfacedataproxy.cpp
@@ -53,6 +53,10 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \note Surfaces with less than two rows or columns are not considered valid surfaces and will
* not be rendered.
*
+ * \note On some environments, surfaces with a lot of visible vertices may not render, because
+ * they exceed the per-draw vertex count supported by the graphics driver.
+ * This is mostly an issue on 32bit and/or OpenGL ES2 platforms.
+ *
* \sa {Qt Data Visualization Data Handling}
*/
diff --git a/src/datavisualization/datavisualization.pro b/src/datavisualization/datavisualization.pro
index 44f0f60c..645a1733 100644
--- a/src/datavisualization/datavisualization.pro
+++ b/src/datavisualization/datavisualization.pro
@@ -1,5 +1,5 @@
# Target can't start with 'Qt' as it gets major version number inserted into it in that case,
-# which we don't want. Exception is mac bundles, where the target name must match the module name
+# which we don't want. Exception is OS X bundles, where the target name must match the module name
mac:CONFIG(shared, static|shared):contains(QT_CONFIG, qt_framework) {
TARGET = QtDataVisualization
} else {
@@ -7,7 +7,8 @@ mac:CONFIG(shared, static|shared):contains(QT_CONFIG, qt_framework) {
}
message($$QT_CONFIG)
-QT = core gui
+QT += core gui
+osx: QT += gui-private
DEFINES += QT_DATAVISUALIZATION_LIBRARY
# Fix exports in static builds for applications linking datavisualization module
@@ -19,9 +20,8 @@ QMAKE_DOCS = $$PWD/doc/qtdatavisualization.qdocconf
load(qt_module)
-include($$PWD/common.pri)
-include($$PWD/engine/engine.pri)
include($$PWD/global/global.pri)
+include($$PWD/engine/engine.pri)
include($$PWD/utils/utils.pri)
include($$PWD/theme/theme.pri)
include($$PWD/axis/axis.pri)
diff --git a/src/datavisualization/doc/qtdatavisualization.qdocconf b/src/datavisualization/doc/qtdatavisualization.qdocconf
index 6e9f09b4..4d63b526 100644
--- a/src/datavisualization/doc/qtdatavisualization.qdocconf
+++ b/src/datavisualization/doc/qtdatavisualization.qdocconf
@@ -6,7 +6,7 @@ include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf)
project = QtDataVisualization
description = Qt Data Visualization Reference Documentation
-version = 1.1.0
+version = 1.2.0
exampledirs += ../../../examples/datavisualization \
snippets
@@ -27,14 +27,14 @@ indexes += $QT_INSTALL_DOCS/qtcore/qtcore.index \
qhp.projects = QtDataVisualization
qhp.QtDataVisualization.file = qtdatavisualization.qhp
-qhp.QtDataVisualization.namespace = com.digia.qtdatavisualization.110
+qhp.QtDataVisualization.namespace = com.digia.qtdatavisualization.120
qhp.QtDataVisualization.virtualFolder = qtdatavisualization
qhp.QtDataVisualization.indexTitle = Qt Data Visualization
qhp.QtDataVisualization.indexRoot =
-qhp.QtDataVisualization.filterAttributes = qtdatavisualization 1.1.0 qtrefdoc
-qhp.QtDataVisualization.customFilters.Qt.name = QtDataVisualization 1.1.0
-qhp.QtDataVisualization.customFilters.Qt.filterAttributes = qtdatavisualization 1.1.0
+qhp.QtDataVisualization.filterAttributes = qtdatavisualization 1.2.0 qtrefdoc
+qhp.QtDataVisualization.customFilters.Qt.name = QtDataVisualization 1.2.0
+qhp.QtDataVisualization.customFilters.Qt.filterAttributes = qtdatavisualization 1.2.0
qhp.QtDataVisualization.subprojects = gettingstarted examples classes types
qhp.QtDataVisualization.subprojects.gettingstarted.title = Getting Started
qhp.QtDataVisualization.subprojects.gettingstarted.indexTitle = Qt Data Visualization Getting Started
@@ -50,7 +50,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 = fake:qmlclass
+qhp.QtDataVisualization.subprojects.types.selectors = qmlclass
qhp.QtDataVisualization.subprojects.types.sortPages = true
navigation.landingpage = Qt Data Visualization
diff --git a/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp b/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp
index 56bfc5ee..1ca3f597 100644
--- a/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp
+++ b/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp
@@ -17,12 +17,12 @@
****************************************************************************/
//! [0]
-import QtDataVisualization 1.1
+import QtDataVisualization 1.2
//! [0]
//! [1]
import QtQuick 2.0
-import QtDataVisualization 1.1
+import QtDataVisualization 1.2
Item {
width: 640
@@ -61,7 +61,7 @@ Item {
//! [2]
import QtQuick 2.0
-import QtDataVisualization 1.1
+import QtDataVisualization 1.2
Item {
width: 640
@@ -94,7 +94,7 @@ Item {
//! [3]
import QtQuick 2.0
-import QtDataVisualization 1.1
+import QtDataVisualization 1.2
Item {
width: 640
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
index 2cc3eece..b5a678e5 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
@@ -153,6 +153,32 @@
*/
/*!
+ * \qmlproperty bool AbstractGraph3D::polar
+ * \since QtDataVisualization 1.2
+ *
+ * If \c {true}, the horizontal axes are changed into polar axes. The X axis becomes the
+ * angular axis and the Z axis becomes the radial axis.
+ * Polar mode is not available for bar graphs.
+ *
+ * Defaults to \c{false}.
+ *
+ * \sa orthoProjection, radialLabelOffset
+ */
+
+/*!
+ * \qmlproperty real AbstractGraph3D::radialLabelOffset
+ * \since QtDataVisualization 1.2
+ *
+ * This property specifies the normalized horizontal offset for the axis labels of the radial
+ * polar axis. The value 0.0 indicates the labels should be drawn next to the 0-angle angular
+ * axis grid line. The value 1.0 indicates the labels are drawn on their normal place at the edge
+ * of the graph background.
+ * This property is ignored if polar property value is \c{false}. Defaults to 1.0.
+ *
+ * \sa polar
+ */
+
+/*!
* \qmlmethod void AbstractGraph3D::clearSelection()
* Clears selection from all attached series.
*/
@@ -289,22 +315,123 @@
* \qmlproperty real AbstractGraph3D::aspectRatio
* \since QtDataVisualization 1.1
*
- * Aspect ratio of the graph data. This is the ratio of data scaling between horizontal and
- * vertical axes. Defaults to \c{2.0}.
+ * The aspect ratio is the ratio of the graph scaling between the longest axis on the horizontal
+ * plane and the Y-axis. Defaults to \c{2.0}.
*
* \note Has no effect on Bars3D.
+ *
+ * \sa horizontalAspectRatio
+ */
+
+/*!
+ * \qmlproperty real AbstractGraph3D::horizontalAspectRatio
+ * \since QtDataVisualization 1.2
+ *
+ * The horizontal aspect ratio is the ratio of the graph scaling between the X and Z axes.
+ * Value of 0.0 indicates automatic scaling according to axis ranges.
+ * Defaults to \c{0.0}.
+ *
+ * \note Has no effect on Bars3D, which handles scaling on the horizontal plane via
+ * \l{Bars3D::barThickness}{barThickness} and \l{Bars3D::barSpacing}{barSpacing} properties.
+ * Polar graphs also ignore this property.
+ *
+ * \sa aspectRatio, polar, Bars3D::barThickness, Bars3D::barSpacing
*/
/*!
* \qmlproperty AbstractGraph3D.OptimizationHints AbstractGraph3D::optimizationHints
- * \since Qt Data Visualization 1.1
- *
- * Defines if the rendering optimization is default or static. Default mode provides the full feature set at
- * reasonable performance. Static is a beta level feature and currently supports only a subset of the
- * features on the Scatter graph. Missing features are object gradient for mesh objects, both gradients
- * for points, and diffuse and specular color on rotations. At this point static is intended just for
- * introducing a new feature. It optimizes graph rendering and is ideal for large non-changing data
- * sets. It is slower with dynamic data changes and item rotations. Selection is not optimized, so using it
- * with massive data sets is not advisable.
- * Defaults to \c{OptimizationDefault}
+ * \since QtDataVisualization 1.1
+ *
+ * Defines if the rendering optimization is default or static. Default mode provides the full
+ * feature set at reasonable performance. Static mode optimizes graph rendering and is ideal for
+ * large non-changing data sets. It is slower with dynamic data changes and item rotations.
+ * Selection is not optimized, so using it with massive data sets is not advisable.
+ * Static works only on the Scatter graph.
+ * Defaults to \c{OptimizationDefault}.
+ *
+ * \note On some environments, large graphs using static optimization may not render, because
+ * all of the items are rendered using a single draw call, and different graphics drivers have
+ * different maximum vertice counts per call that they support.
+ * This is mostly an issue on 32bit and/or OpenGL ES2 platforms.
+ * To work around this issue, choose an item mesh with low vertex count or use the point mesh.
+ *
+ * \sa Abstract3DSeries::mesh
+ */
+
+/*!
+ * \qmlproperty bool AbstractGraph3D::reflection
+ * \since QtDataVisualization 1.2
+ *
+ * Sets floor reflections on or off. Defaults to \c{false}.
+ *
+ * \note Affects only Bars3D.
+ *
+ * \note In Bars3D graphs holding both positive and negative values, reflections are not supported
+ * for custom items that intersect the floor plane. In that case, reflections should be turned off
+ * to avoid incorrect rendering.
+ *
+ * \sa reflectivity
+ */
+
+/*!
+ * \qmlproperty real AbstractGraph3D::reflectivity
+ * \since QtDataVisualization 1.2
+ *
+ * Adjusts floor reflectivity, larger number being more reflective. Valid range is \c{[0...1]}.
+ * Defaults to \c{0.5}.
+ *
+ * \note Affects only Bars3D.
+ *
+ * \sa reflection
+ */
+
+/*!
+ * \qmlproperty locale AbstractGraph3D::locale
+ * \since QtDataVisualization 1.2
+ *
+ * Sets the locale used for formatting various numeric labels.
+ * Defaults to \c{"C"} locale.
+ *
+ * \sa ValueAxis3D::labelFormat
+ */
+
+/*!
+ * \qmlproperty vector3d AbstractGraph3D::queriedGraphPosition
+ * \since QtDataVisualization 1.2
+ *
+ * This read-only property contains the latest graph position values along each axis queried using
+ * Scene3D::graphPositionQuery. The values are normalized to range \c{[-1, 1]}.
+ * If the queried position was outside the graph bounds, the values
+ * will not reflect the real position, but will instead be some undefined position outside
+ * the range \c{[-1, 1]}. The value will be undefined before any queries are made.
+ *
+ * There isn't a single correct 3D coordinate to match to each specific screen position, so to be
+ * consistent, the queries are always done against the inner sides of an invisible box surrounding
+ * the graph.
+ *
+ * \note Bar graphs only allow querying graph position at the graph floor level,
+ * so the Y-value is always zero for bar graphs and the valid queries can be only made at
+ * screen positions that contain the floor of the graph.
+ *
+ * \sa Scene3D::graphPositionQuery
+ */
+
+/*!
+ * \qmlproperty real AbstractGraph3D::margin
+ * \since QtDataVisualization 1.2
+ *
+ * This property contains the absolute value used for graph margin. The graph margin is the space
+ * left between the edge of the plottable graph area and the edge of the graph background.
+ * If the margin value is negative, the margins are determined automatically and can vary according
+ * to size of the items in the series and the type of the graph.
+ * The value is interpreted as a fraction of Y-axis range, provided the graph aspect ratios have
+ * not beed changed from the defaults.
+ * Defaults to \c{-1.0}.
+ *
+ * \note Having smaller than the automatically determined margin on scatter graph can cause
+ * the scatter items at the edges of the graph to overlap with the graph background.
+ *
+ * \note On scatter and surface graphs, if the margin is comparatively small to the axis label
+ * size, the positions of the edge labels of the axes are adjusted to avoid overlap with
+ * the edge labels of the neighboring axes.
*/
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
index 6ee51742..0348652a 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc
@@ -115,6 +115,14 @@
*/
/*!
+ * \qmlproperty real Bars3D::floorLevel
+ *
+ * The desired floor level for the bar graph in Y-axis data coordinates.
+ * The actual floor level cannot go below Y-axis minimum or above Y-axis maximum.
+ * Defaults to zero.
+ */
+
+/*!
* \qmlmethod void Bars3D::addSeries(Bar3DSeries series)
* Adds the \a series to the graph. A graph can contain multiple series, but only one set of axes,
* so the rows and columns of all series must match for the visualized data to be meaningful.
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
index 23a9a004..2b83b807 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc
@@ -73,11 +73,6 @@
*/
/*!
- \qmlproperty ColorGradient Surface3D::gradient
- The current surface gradient. Setting this property replaces the previous gradient.
- */
-
-/*!
* \qmlproperty list<Surface3DSeries> Surface3D::seriesList
* \default
* This property holds the series of the graph.
@@ -86,6 +81,22 @@
*/
/*!
+ * \qmlproperty bool Surface3D::flipHorizontalGrid
+ * \since QtDataVisualization 1.2
+ *
+ * In some use cases the horizontal axis grid is mostly covered by the surface, so it can be more
+ * useful to display the horizontal axis grid on top of the graph rather than on the bottom.
+ * A typical use case for this is showing 2D spectrograms using orthoGraphic projection with
+ * a top-down viewpoint.
+ *
+ * If \c{false}, the horizontal axis grid and labels are drawn on the horizontal background
+ * of the graph.
+ * If \c{true}, the horizontal axis grid and labels are drawn on the opposite side of the graph
+ * from the horizontal background.
+ * Defaults to \c{false}.
+ */
+
+/*!
* \qmlmethod void Surface3D::addSeries(Surface3DSeries series)
* Adds the \a series to the graph.
*/
diff --git a/src/datavisualization/doc/src/qtdatavisualization.qdoc b/src/datavisualization/doc/src/qtdatavisualization.qdoc
index af419814..b07074b1 100644
--- a/src/datavisualization/doc/src/qtdatavisualization.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization.qdoc
@@ -37,7 +37,7 @@
*/
/*!
- \qmlmodule QtDataVisualization 1.1
+ \qmlmodule QtDataVisualization 1.2
\title Qt Data Visualization QML Types
\ingroup qmlmodules
@@ -98,7 +98,7 @@
\row
\li Windows (MSVC) \li nmake
\row
- \li OSX \li make
+ \li OS X \li make
\endtable
The above generates the default makefiles for your configuration, which is typically
@@ -127,7 +127,7 @@
make release
\endcode
- For both builds (Windows/Mac only):
+ For both builds (Windows/OS X only):
\code
qmake CONFIG+="debug_and_release build_all"
make
@@ -323,20 +323,21 @@
\title Qt Data Visualization Known Issues
\list
- \li Android doesn't support both widgets and OpenGL simultaneously, so only
- the Qt Quick 2 API is usable in practice in Android.
+ \li Some platforms like Android and WinRT cannot handle multiple native windows properly,
+ so only the Qt Quick 2 graphs are available in practice for those platforms.
\li Shadows are not supported with OpenGL ES2 (including Angle builds in Windows).
\li Anti-aliasing doesn't work with OpenGL ES2 (including Angle builds in Windows).
+ \li QCustom3DVolume items are not supported with OpenGL ES2 (including Angle builds in
+ Windows).
\li Surfaces with non-straight rows and columns do not always render properly.
\li Q3DLight class (and Light3D QML item) are currently not usable for anything.
- \li Changing any of Q3DScene properties affecting subviewports currently has no effect.
- \li The color style Q3DTheme::ColorStyleObjectGradient doesn't work for surface graphs.
+ \li Changing most of Q3DScene properties affecting subviewports currently has no effect.
\li Widget based examples layout incorrectly in iOS.
\li Reparenting a graph to an item in another QQuickWindow is not supported.
- \li There is a low-impact binary break between 1.0 and 1.1. The break is due to a QML type
- registration conflict with QAbstractItemModel between QtDataVisualization and
- QtCommercial.Charts. Introducing the binary break makes it possible to use both
- Charts and Data Visualization in the same QML application.
+ \li Android builds of QML applications importing QtDataVisualization also require
+ "QT += datavisualization" in the pro file. This is because Qt Data Visualization
+ QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator
+ doesn't automatically add to the deployment package.
\endlist
*/
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index 30434dca..275d0fe2 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -25,6 +25,7 @@
#include "thememanager_p.h"
#include "q3dtheme_p.h"
#include "qcustom3ditem_p.h"
+#include "utils_p.h"
#include <QtCore/QThread>
#include <QtGui/QOpenGLFramebufferObject>
@@ -37,8 +38,12 @@ Abstract3DController::Abstract3DController(QRect initialViewport, Q3DScene *scen
m_selectionMode(QAbstract3DGraph::SelectionItem),
m_shadowQuality(QAbstract3DGraph::ShadowQualityMedium),
m_useOrthoProjection(false),
- m_aspectRatio(2.0f),
+ m_aspectRatio(2.0),
+ m_horizontalAspectRatio(0.0),
m_optimizationHints(QAbstract3DGraph::OptimizationDefault),
+ m_reflectionEnabled(false),
+ m_reflectivity(0.5),
+ m_locale(QLocale::c()),
m_scene(scene),
m_activeInputHandler(0),
m_axisX(0),
@@ -50,12 +55,19 @@ Abstract3DController::Abstract3DController(QRect initialViewport, Q3DScene *scen
m_isCustomItemDirty(true),
m_isSeriesVisualsDirty(true),
m_renderPending(false),
+ m_isPolar(false),
+ m_radialLabelOffset(1.0f),
m_measureFps(false),
m_numFrames(0),
- m_currentFps(0.0)
+ m_currentFps(0.0),
+ m_clickedType(QAbstract3DGraph::ElementNone),
+ m_selectedLabelIndex(-1),
+ m_selectedCustomItemIndex(-1),
+ m_margin(-1.0)
{
if (!m_scene)
m_scene = new Q3DScene;
+ m_scene->setParent(this);
// Set initial theme
Q3DTheme *defaultTheme = new Q3DTheme(Q3DTheme::ThemeQt);
@@ -72,10 +84,6 @@ Abstract3DController::Abstract3DController(QRect initialViewport, Q3DScene *scen
inputHandler = new QTouch3DInputHandler();
inputHandler->d_ptr->m_isDefaultHandler = true;
setActiveInputHandler(inputHandler);
- connect(inputHandler, &QAbstract3DInputHandler::inputViewChanged, this,
- &Abstract3DController::handleInputViewChanged);
- connect(inputHandler, &QAbstract3DInputHandler::positionChanged, this,
- &Abstract3DController::handleInputPositionChanged);
connect(m_scene->d_ptr.data(), &Q3DScenePrivate::needRender, this,
&Abstract3DController::emitNeedRender);
}
@@ -93,7 +101,7 @@ Abstract3DController::~Abstract3DController()
void Abstract3DController::destroyRenderer()
{
// Renderer can be in another thread, don't delete it directly in that case
- if (m_renderer && m_renderer->thread() != QThread::currentThread())
+ if (m_renderer && m_renderer->thread() && m_renderer->thread() != this->thread())
m_renderer->deleteLater();
else
delete m_renderer;
@@ -107,6 +115,13 @@ void Abstract3DController::destroyRenderer()
void Abstract3DController::setRenderer(Abstract3DRenderer *renderer)
{
m_renderer = renderer;
+
+ // If renderer is created in different thread than controller, make sure renderer gets
+ // destroyed before the render thread finishes.
+ if (renderer->thread() != this->thread()) {
+ QObject::connect(renderer->thread(), &QThread::finished, this,
+ &Abstract3DController::destroyRenderer, Qt::DirectConnection);
+ }
}
void Abstract3DController::addSeries(QAbstract3DSeries *series)
@@ -163,11 +178,14 @@ void Abstract3DController::synchDataToRenderer()
{
// Subclass implementations check for renderer validity already, so no need to check here.
- // If there is a pending click from renderer, handle that first.
- if (m_renderer->isClickPending()) {
+ m_renderPending = false;
+
+ // If there are pending queries, handle those first
+ if (m_renderer->isGraphPositionQueryResolved())
+ handlePendingGraphPositionQuery();
+
+ if (m_renderer->isClickQueryResolved())
handlePendingClick();
- m_renderer->clearClickPending();
- }
startRecordingRemovesAndInserts();
@@ -176,6 +194,16 @@ void Abstract3DController::synchDataToRenderer()
m_renderer->updateTheme(m_themeManager->activeTheme());
+ if (m_changeTracker.polarChanged) {
+ m_renderer->updatePolar(m_isPolar);
+ m_changeTracker.polarChanged = false;
+ }
+
+ if (m_changeTracker.radialLabelOffsetChanged) {
+ m_renderer->updateRadialLabelOffset(m_radialLabelOffset);
+ m_changeTracker.radialLabelOffsetChanged = false;
+ }
+
if (m_changeTracker.shadowQualityChanged) {
m_renderer->updateShadowQuality(m_shadowQuality);
m_changeTracker.shadowQualityChanged = false;
@@ -192,15 +220,31 @@ void Abstract3DController::synchDataToRenderer()
}
if (m_changeTracker.aspectRatioChanged) {
- m_renderer->updateAspectRatio(m_aspectRatio);
+ m_renderer->updateAspectRatio(float(m_aspectRatio));
m_changeTracker.aspectRatioChanged = false;
}
+ if (m_changeTracker.horizontalAspectRatioChanged) {
+ m_renderer->updateHorizontalAspectRatio(float(m_horizontalAspectRatio));
+ m_changeTracker.horizontalAspectRatioChanged = false;
+ }
+
if (m_changeTracker.optimizationHintChanged) {
m_renderer->updateOptimizationHint(m_optimizationHints);
m_changeTracker.optimizationHintChanged = false;
}
+ if (m_changeTracker.reflectionChanged) {
+ m_renderer->m_reflectionEnabled = m_reflectionEnabled;
+ m_changeTracker.reflectionChanged = false;
+ }
+
+ if (m_changeTracker.reflectivityChanged) {
+ // Invert value to match functionality to the property description
+ m_renderer->m_reflectivity = -(m_reflectivity - 1.0);
+ m_changeTracker.reflectivityChanged = false;
+ }
+
if (m_changeTracker.axisXFormatterChanged) {
m_changeTracker.axisXFormatterChanged = false;
if (m_axisX->type() & QAbstract3DAxis::AxisTypeValue) {
@@ -445,6 +489,11 @@ void Abstract3DController::synchDataToRenderer()
m_changeTracker.axisZTitleFixedChanged = false;
}
+ if (m_changeTracker.marginChanged) {
+ m_renderer->updateMargin(float(m_margin));
+ m_changeTracker.marginChanged = false;
+ }
+
if (m_changedSeriesList.size()) {
m_renderer->modifiedSeriesList(m_changedSeriesList);
m_changedSeriesList.clear();
@@ -475,8 +524,6 @@ void Abstract3DController::synchDataToRenderer()
void Abstract3DController::render(const GLuint defaultFboHandle)
{
- m_renderPending = false;
-
// If not initialized, do nothing.
if (!m_renderer)
return;
@@ -765,8 +812,9 @@ void Abstract3DController::setActiveInputHandler(QAbstract3DInputHandler *inputH
m_inputHandlers.removeAll(m_activeInputHandler);
delete m_activeInputHandler;
} else {
- // Disconnect the old input handler from the scene
+ // Disconnect the old input handler
m_activeInputHandler->setScene(0);
+ QObject::disconnect(m_activeInputHandler, 0, this, 0);
}
}
@@ -775,9 +823,16 @@ void Abstract3DController::setActiveInputHandler(QAbstract3DInputHandler *inputH
addInputHandler(inputHandler);
m_activeInputHandler = inputHandler;
- if (m_activeInputHandler)
+ if (m_activeInputHandler) {
m_activeInputHandler->setScene(m_scene);
+ // Connect the input handler
+ QObject::connect(m_activeInputHandler, &QAbstract3DInputHandler::inputViewChanged, this,
+ &Abstract3DController::handleInputViewChanged);
+ QObject::connect(m_activeInputHandler, &QAbstract3DInputHandler::positionChanged, this,
+ &Abstract3DController::handleInputPositionChanged);
+ }
+
// Notify change of input handler
emit activeInputHandlerChanged(m_activeInputHandler);
}
@@ -886,11 +941,7 @@ QAbstract3DGraph::OptimizationHints Abstract3DController::optimizationHints() co
bool Abstract3DController::shadowsSupported() const
{
-#if defined(QT_OPENGL_ES_2)
- return false;
-#else
- return true;
-#endif
+ return !isOpenGLES();
}
bool Abstract3DController::isSlicingActive() const
@@ -989,6 +1040,11 @@ void Abstract3DController::releaseCustomItem(QCustom3DItem *item)
}
}
+QList<QCustom3DItem *> Abstract3DController::customItems() const
+{
+ return m_customItems;
+}
+
void Abstract3DController::updateCustomItem()
{
m_isCustomItemDirty = true;
@@ -1303,6 +1359,11 @@ void Abstract3DController::markSeriesItemLabelsDirty()
m_seriesList.at(i)->d_ptr->markItemLabelDirty();
}
+bool Abstract3DController::isOpenGLES() const
+{
+ return Utils::isOpenGLES();
+}
+
void Abstract3DController::setAxisHelper(QAbstract3DAxis::AxisOrientation orientation,
QAbstract3DAxis *axis, QAbstract3DAxis **axisPtr)
{
@@ -1381,6 +1442,8 @@ void Abstract3DController::setAxisHelper(QAbstract3DAxis::AxisOrientation orient
handleAxisLabelFormatChangedBySender(valueAxis);
handleAxisReversedChangedBySender(valueAxis);
handleAxisFormatterDirtyBySender(valueAxis->dptr());
+
+ valueAxis->formatter()->setLocale(m_locale);
}
}
@@ -1427,13 +1490,37 @@ void Abstract3DController::emitNeedRender()
void Abstract3DController::handlePendingClick()
{
- QAbstract3DGraph::ElementType type = m_renderer->clickedType();
- emit elementSelected(type);
+ m_clickedType = m_renderer->clickedType();
+ m_selectedLabelIndex = m_renderer->m_selectedLabelIndex;
+ m_selectedCustomItemIndex = m_renderer->m_selectedCustomItemIndex;
+
+ // Invalidate query position to indicate the query has been handled, unless another
+ // point has been queried.
+ if (m_renderer->cachedClickQuery() == m_scene->selectionQueryPosition())
+ m_scene->setSelectionQueryPosition(Q3DScene::invalidSelectionPoint());
+
+ m_renderer->clearClickQueryResolved();
+
+ emit elementSelected(m_clickedType);
+}
+
+void Abstract3DController::handlePendingGraphPositionQuery()
+{
+ m_queriedGraphPosition = m_renderer->queriedGraphPosition();
+
+ // Invalidate query position to indicate the query has been handled, unless another
+ // point has been queried.
+ if (m_renderer->cachedGraphPositionQuery() == m_scene->graphPositionQuery())
+ m_scene->setGraphPositionQuery(Q3DScene::invalidSelectionPoint());
+
+ m_renderer->clearGraphPositionQueryResolved();
+
+ emit queriedGraphPositionChanged(m_queriedGraphPosition);
}
int Abstract3DController::selectedLabelIndex() const
{
- int index = m_renderer->m_selectedLabelIndex;
+ int index = m_selectedLabelIndex;
QAbstract3DAxis *axis = selectedAxis();
if (axis && axis->labels().count() <= index)
index = -1;
@@ -1443,7 +1530,7 @@ int Abstract3DController::selectedLabelIndex() const
QAbstract3DAxis *Abstract3DController::selectedAxis() const
{
QAbstract3DAxis *axis = 0;
- QAbstract3DGraph::ElementType type = m_renderer->clickedType();
+ QAbstract3DGraph::ElementType type = m_clickedType;
switch (type) {
case QAbstract3DGraph::ElementAxisXLabel:
axis = axisX();
@@ -1464,7 +1551,7 @@ QAbstract3DAxis *Abstract3DController::selectedAxis() const
int Abstract3DController::selectedCustomItemIndex() const
{
- int index = m_renderer->m_selectedCustomItemIndex;
+ int index = m_selectedCustomItemIndex;
if (m_customItems.count() <= index)
index = -1;
return index;
@@ -1481,10 +1568,7 @@ QCustom3DItem *Abstract3DController::selectedCustomItem() const
QAbstract3DGraph::ElementType Abstract3DController::selectedElement() const
{
- if (m_renderer)
- return m_renderer->clickedType();
- else
- return QAbstract3DGraph::ElementNone;
+ return m_clickedType;
}
void Abstract3DController::setOrthoProjection(bool enable)
@@ -1505,7 +1589,7 @@ bool Abstract3DController::isOrthoProjection() const
return m_useOrthoProjection;
}
-void Abstract3DController::setAspectRatio(float ratio)
+void Abstract3DController::setAspectRatio(qreal ratio)
{
if (m_aspectRatio != ratio) {
m_aspectRatio = ratio;
@@ -1516,9 +1600,131 @@ void Abstract3DController::setAspectRatio(float ratio)
}
}
-float Abstract3DController::aspectRatio()
+qreal Abstract3DController::aspectRatio()
{
return m_aspectRatio;
}
+void Abstract3DController::setHorizontalAspectRatio(qreal ratio)
+{
+ if (m_horizontalAspectRatio != ratio) {
+ m_horizontalAspectRatio = ratio;
+ m_changeTracker.horizontalAspectRatioChanged = true;
+ emit horizontalAspectRatioChanged(m_horizontalAspectRatio);
+ m_isDataDirty = true;
+ emitNeedRender();
+ }
+}
+
+qreal Abstract3DController::horizontalAspectRatio() const
+{
+ return m_horizontalAspectRatio;
+}
+
+void Abstract3DController::setReflection(bool enable)
+{
+ if (m_reflectionEnabled != enable) {
+ m_reflectionEnabled = enable;
+ m_changeTracker.reflectionChanged = true;
+ emit reflectionChanged(m_reflectionEnabled);
+ emitNeedRender();
+ }
+}
+
+bool Abstract3DController::reflection() const
+{
+ return m_reflectionEnabled;
+}
+
+void Abstract3DController::setReflectivity(qreal reflectivity)
+{
+ if (m_reflectivity != reflectivity) {
+ m_reflectivity = reflectivity;
+ m_changeTracker.reflectivityChanged = true;
+ emit reflectivityChanged(m_reflectivity);
+ emitNeedRender();
+ }
+}
+
+qreal Abstract3DController::reflectivity() const
+{
+ return m_reflectivity;
+}
+
+void Abstract3DController::setPolar(bool enable)
+{
+ if (enable != m_isPolar) {
+ m_isPolar = enable;
+ m_changeTracker.polarChanged = true;
+ m_isDataDirty = true;
+ emit polarChanged(m_isPolar);
+ emitNeedRender();
+ }
+}
+
+bool Abstract3DController::isPolar() const
+{
+ return m_isPolar;
+}
+
+void Abstract3DController::setRadialLabelOffset(float offset)
+{
+ if (m_radialLabelOffset != offset) {
+ m_radialLabelOffset = offset;
+ m_changeTracker.radialLabelOffsetChanged = true;
+ emit radialLabelOffsetChanged(m_radialLabelOffset);
+ emitNeedRender();
+ }
+}
+
+float Abstract3DController::radialLabelOffset() const
+{
+ return m_radialLabelOffset;
+}
+
+void Abstract3DController::setLocale(const QLocale &locale)
+{
+ if (m_locale != locale) {
+ m_locale = locale;
+
+ // Value axis formatters need to be updated
+ QValue3DAxis *axis = qobject_cast<QValue3DAxis *>(m_axisX);
+ if (axis)
+ axis->formatter()->setLocale(m_locale);
+ axis = qobject_cast<QValue3DAxis *>(m_axisY);
+ if (axis)
+ axis->formatter()->setLocale(m_locale);
+ axis = qobject_cast<QValue3DAxis *>(m_axisZ);
+ if (axis)
+ axis->formatter()->setLocale(m_locale);
+ emit localeChanged(m_locale);
+ }
+}
+
+QLocale Abstract3DController::locale() const
+{
+ return m_locale;
+}
+
+QVector3D Abstract3DController::queriedGraphPosition() const
+{
+ return m_queriedGraphPosition;
+}
+
+void Abstract3DController::setMargin(qreal margin)
+{
+ if (m_margin != margin) {
+ m_margin = margin;
+ m_changeTracker.marginChanged = true;
+ emit marginChanged(margin);
+ emitNeedRender();
+ }
+}
+
+qreal Abstract3DController::margin() const
+{
+ return m_margin;
+}
+
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index 0e4d1add..d5a1ac8f 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -38,6 +38,7 @@
#include "qcustom3ditem.h"
#include <QtGui/QLinearGradient>
#include <QtCore/QTime>
+#include <QtCore/QLocale>
class QOpenGLFramebufferObject;
@@ -84,12 +85,18 @@ struct Abstract3DChangeBitField {
bool axisYLabelAutoRotationChanged : 1;
bool axisZLabelAutoRotationChanged : 1;
bool aspectRatioChanged : 1;
+ bool horizontalAspectRatioChanged : 1;
bool axisXTitleVisibilityChanged : 1;
bool axisYTitleVisibilityChanged : 1;
bool axisZTitleVisibilityChanged : 1;
bool axisXTitleFixedChanged : 1;
bool axisYTitleFixedChanged : 1;
bool axisZTitleFixedChanged : 1;
+ bool polarChanged : 1;
+ bool radialLabelOffsetChanged : 1;
+ bool reflectionChanged : 1;
+ bool reflectivityChanged : 1;
+ bool marginChanged : 1;
Abstract3DChangeBitField() :
themeChanged(true),
@@ -128,12 +135,18 @@ struct Abstract3DChangeBitField {
axisYLabelAutoRotationChanged(true),
axisZLabelAutoRotationChanged(true),
aspectRatioChanged(true),
+ horizontalAspectRatioChanged(true),
axisXTitleVisibilityChanged(true),
axisYTitleVisibilityChanged(true),
axisZTitleVisibilityChanged(true),
axisXTitleFixedChanged(true),
axisYTitleFixedChanged(true),
- axisZTitleFixedChanged(true)
+ axisZTitleFixedChanged(true),
+ polarChanged(true),
+ radialLabelOffsetChanged(true),
+ reflectionChanged(true),
+ reflectivityChanged(true),
+ marginChanged(true)
{
}
};
@@ -156,8 +169,13 @@ private:
QAbstract3DGraph::SelectionFlags m_selectionMode;
QAbstract3DGraph::ShadowQuality m_shadowQuality;
bool m_useOrthoProjection;
- float m_aspectRatio;
+ qreal m_aspectRatio;
+ qreal m_horizontalAspectRatio;
QAbstract3DGraph::OptimizationHints m_optimizationHints;
+ bool m_reflectionEnabled;
+ qreal m_reflectivity;
+ QLocale m_locale;
+ QVector3D m_queriedGraphPosition;
protected:
Q3DScene *m_scene;
@@ -175,6 +193,8 @@ protected:
bool m_isCustomItemDirty;
bool m_isSeriesVisualsDirty;
bool m_renderPending;
+ bool m_isPolar;
+ float m_radialLabelOffset;
QList<QAbstract3DSeries *> m_seriesList;
@@ -187,13 +207,17 @@ protected:
QList<QCustom3DItem *> m_customItems;
+ QAbstract3DGraph::ElementType m_clickedType;
+ int m_selectedLabelIndex;
+ int m_selectedCustomItemIndex;
+ qreal m_margin;
+
explicit Abstract3DController(QRect initialViewport, Q3DScene *scene, QObject *parent = 0);
public:
virtual ~Abstract3DController();
inline bool isInitialized() { return (m_renderer != 0); }
- virtual void destroyRenderer();
virtual void synchDataToRenderer();
virtual void render(const GLuint defaultFboHandle = 0);
virtual void initializeOpenGL() = 0;
@@ -252,6 +276,7 @@ public:
void deleteCustomItem(QCustom3DItem *item);
void deleteCustomItem(const QVector3D &position);
void releaseCustomItem(QCustom3DItem *item);
+ QList<QCustom3DItem *> customItems() const;
int selectedLabelIndex() const;
QAbstract3DAxis *selectedAxis() const;
@@ -261,6 +286,35 @@ public:
void setOrthoProjection(bool enable);
bool isOrthoProjection() const;
+ void setMeasureFps(bool enable);
+ inline bool measureFps() const { return m_measureFps; }
+ inline qreal currentFps() const { return m_currentFps; }
+
+ QAbstract3DGraph::ElementType selectedElement() const;
+
+ void setAspectRatio(qreal ratio);
+ qreal aspectRatio();
+ void setHorizontalAspectRatio(qreal ratio);
+ qreal horizontalAspectRatio() const;
+
+ void setReflection(bool enable);
+ bool reflection() const;
+ void setReflectivity(qreal reflectivity);
+ qreal reflectivity() const;
+
+ void setPolar(bool enable);
+ bool isPolar() const;
+ void setRadialLabelOffset(float offset);
+ float radialLabelOffset() const;
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+
+ QVector3D queriedGraphPosition() const;
+
+ void setMargin(qreal margin);
+ qreal margin() const;
+
void emitNeedRender();
virtual void clearSelection() = 0;
@@ -286,12 +340,16 @@ public:
virtual void handleAxisTitleVisibilityChangedBySender(QObject *sender);
virtual void handleAxisTitleFixedChangedBySender(QObject *sender);
virtual void handleSeriesVisibilityChangedBySender(QObject *sender);
- virtual void handlePendingClick() = 0;
+ virtual void handlePendingClick();
+ virtual void handlePendingGraphPositionQuery();
virtual void adjustAxisRanges() = 0;
void markSeriesItemLabelsDirty();
+ bool isOpenGLES() const;
public slots:
+ void destroyRenderer();
+
void handleAxisTitleChanged(const QString &title);
void handleAxisLabelsChanged();
void handleAxisRangeChanged(float min, float max);
@@ -320,17 +378,8 @@ public slots:
// Renderer callback handlers
void handleRequestShadowQuality(QAbstract3DGraph::ShadowQuality quality);
- void setMeasureFps(bool enable);
- inline bool measureFps() const { return m_measureFps; }
- inline qreal currentFps() const { return m_currentFps; }
-
- QAbstract3DGraph::ElementType selectedElement() const;
-
void updateCustomItem();
- void setAspectRatio(float ratio);
- float aspectRatio();
-
signals:
void shadowQualityChanged(QAbstract3DGraph::ShadowQuality quality);
void activeInputHandlerChanged(QAbstract3DInputHandler *inputHandler);
@@ -344,8 +393,16 @@ signals:
void measureFpsChanged(bool enabled);
void currentFpsChanged(qreal fps);
void orthoProjectionChanged(bool enabled);
- void aspectRatioChanged(float ratio);
+ void aspectRatioChanged(qreal ratio);
+ void horizontalAspectRatioChanged(qreal ratio);
void optimizationHintsChanged(QAbstract3DGraph::OptimizationHints hints);
+ void polarChanged(bool enabled);
+ void radialLabelOffsetChanged(float offset);
+ void reflectionChanged(bool enabled);
+ void reflectivityChanged(qreal reflectivity);
+ void localeChanged(const QLocale &locale);
+ void queriedGraphPositionChanged(const QVector3D &data);
+ void marginChanged(qreal margin);
protected:
virtual QAbstract3DAxis *createDefaultAxis(QAbstract3DAxis::AxisOrientation orientation);
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 04ede782..cfc691af 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -24,9 +24,24 @@
#include "shaderhelper_p.h"
#include "qcustom3ditem_p.h"
#include "qcustom3dlabel_p.h"
+#include "qcustom3dvolume_p.h"
+#include "scatter3drenderer_p.h"
+
+#include <QtCore/qmath.h>
+#include <QtGui/QWindow>
+#include <QtCore/QThread>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
+// Defined in shaderhelper.cpp
+extern void discardDebugMsgs(QtMsgType type, const QMessageLogContext &context, const QString &msg);
+
+const qreal doublePi(M_PI * 2.0);
+const int polarGridRoundness(64);
+const qreal polarGridAngle(doublePi / qreal(polarGridRoundness));
+const float polarGridAngleDegrees(float(360.0 / qreal(polarGridRoundness)));
+const qreal polarGridHalfAngle(polarGridAngle / 2.0);
+
Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
: QObject(0),
m_hasNegativeValues(false),
@@ -37,26 +52,83 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_cachedSelectionMode(QAbstract3DGraph::SelectionNone),
m_cachedOptimizationHint(QAbstract3DGraph::OptimizationDefault),
m_textureHelper(0),
+ m_depthTexture(0),
m_cachedScene(new Q3DScene()),
m_selectionDirty(true),
m_selectionState(SelectNone),
m_devicePixelRatio(1.0f),
m_selectionLabelDirty(true),
- m_clickPending(false),
+ m_clickResolved(false),
+ m_graphPositionQueryPending(false),
+ m_graphPositionQueryResolved(false),
m_clickedSeries(0),
m_clickedType(QAbstract3DGraph::ElementNone),
+ m_selectedLabelIndex(-1),
+ m_selectedCustomItemIndex(-1),
m_selectionLabelItem(0),
m_visibleSeriesCount(0),
m_customItemShader(0),
+ m_volumeTextureShader(0),
+ m_volumeTextureLowDefShader(0),
+ m_volumeTextureSliceShader(0),
+ m_volumeSliceFrameShader(0),
+ m_labelShader(0),
+ m_cursorPositionShader(0),
+ m_cursorPositionFrameBuffer(0),
+ m_cursorPositionTexture(0),
m_useOrthoProjection(false),
m_xFlipped(false),
m_yFlipped(false),
m_zFlipped(false),
+ m_yFlippedForGrid(false),
m_backgroundObj(0),
m_gridLineObj(0),
m_labelObj(0),
- m_graphAspectRatio(2.0f)
+ m_positionMapperObj(0),
+ m_graphAspectRatio(2.0f),
+ m_graphHorizontalAspectRatio(0.0f),
+ m_polarGraph(false),
+ m_radialLabelOffset(1.0f),
+ m_polarRadius(2.0f),
+ m_xRightAngleRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, 90.0f)),
+ m_yRightAngleRotation(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 90.0f)),
+ m_zRightAngleRotation(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, 90.0f)),
+ m_xRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f)),
+ m_yRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -90.0f)),
+ m_zRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -90.0f)),
+ m_xFlipRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -180.0f)),
+ m_zFlipRotation(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f)),
+ m_requestedMargin(-1.0f),
+ m_vBackgroundMargin(0.1f),
+ m_hBackgroundMargin(0.1f),
+ m_scaleXWithBackground(0.0f),
+ m_scaleYWithBackground(0.0f),
+ m_scaleZWithBackground(0.0f),
+ m_oldCameraTarget(QVector3D(2000.0f, 2000.0f, 2000.0f)), // Just random invalid target
+ m_reflectionEnabled(false),
+ m_reflectivity(0.5),
+#if !defined(QT_OPENGL_ES_2)
+ m_funcs_2_1(0),
+#endif
+ m_context(0),
+ m_dummySurfaceAtDelete(0),
+ m_isOpenGLES(true)
+
{
+ initializeOpenGLFunctions();
+ m_isOpenGLES = Utils::isOpenGLES();
+#if !defined(QT_OPENGL_ES_2)
+ if (!m_isOpenGLES) {
+ // Discard warnings about deprecated functions
+ QtMessageHandler handler = qInstallMessageHandler(discardDebugMsgs);
+
+ m_funcs_2_1 = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
+ m_funcs_2_1->initializeOpenGLFunctions();
+
+ // Restore original message handler
+ qInstallMessageHandler(handler);
+ }
+#endif
QObject::connect(m_drawer, &Drawer::drawerChanged, this, &Abstract3DRenderer::updateTextures);
QObject::connect(this, &Abstract3DRenderer::needRender, controller,
&Abstract3DController::needRender, Qt::QueuedConnection);
@@ -71,6 +143,12 @@ Abstract3DRenderer::~Abstract3DRenderer()
delete m_cachedTheme;
delete m_selectionLabelItem;
delete m_customItemShader;
+ delete m_volumeTextureShader;
+ delete m_volumeTextureLowDefShader;
+ delete m_volumeSliceFrameShader;
+ delete m_volumeTextureSliceShader;
+ delete m_labelShader;
+ delete m_cursorPositionShader;
foreach (SeriesRenderCache *cache, m_renderCacheList) {
cache->cleanup(m_textureHelper);
@@ -88,12 +166,29 @@ Abstract3DRenderer::~Abstract3DRenderer()
ObjectHelper::releaseObjectHelper(this, m_backgroundObj);
ObjectHelper::releaseObjectHelper(this, m_gridLineObj);
ObjectHelper::releaseObjectHelper(this, m_labelObj);
+ ObjectHelper::releaseObjectHelper(this, m_positionMapperObj);
+
+ if (m_textureHelper) {
+ m_textureHelper->deleteTexture(&m_depthTexture);
+ m_textureHelper->deleteTexture(&m_cursorPositionTexture);
+
+ if (QOpenGLContext::currentContext())
+ m_textureHelper->glDeleteFramebuffers(1, &m_cursorPositionFrameBuffer);
+
+ delete m_textureHelper;
+ }
+
+ m_axisCacheX.clearLabels();
+ m_axisCacheY.clearLabels();
+ m_axisCacheZ.clearLabels();
- delete m_textureHelper;
+ restoreContextAfterDelete();
}
void Abstract3DRenderer::initializeOpenGL()
{
+ m_context = QOpenGLContext::currentContext();
+
// Set OpenGL features
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
@@ -101,9 +196,11 @@ void Abstract3DRenderer::initializeOpenGL()
glCullFace(GL_BACK);
#if !defined(QT_OPENGL_ES_2)
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
- glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+ if (!m_isOpenGLES) {
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+ glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+ }
#endif
m_textureHelper = new TextureHelper();
@@ -112,6 +209,15 @@ void Abstract3DRenderer::initializeOpenGL()
axisCacheForOrientation(QAbstract3DAxis::AxisOrientationX).setDrawer(m_drawer);
axisCacheForOrientation(QAbstract3DAxis::AxisOrientationY).setDrawer(m_drawer);
axisCacheForOrientation(QAbstract3DAxis::AxisOrientationZ).setDrawer(m_drawer);
+
+ initLabelShaders(QStringLiteral(":/shaders/vertexLabel"),
+ QStringLiteral(":/shaders/fragmentLabel"));
+
+ initCursorPositionShaders(QStringLiteral(":/shaders/vertexPosition"),
+ QStringLiteral(":/shaders/fragmentPositionMap"));
+
+ loadLabelMesh();
+ loadPositionMapperMesh();
}
void Abstract3DRenderer::render(const GLuint defaultFboHandle)
@@ -137,7 +243,7 @@ void Abstract3DRenderer::render(const GLuint defaultFboHandle)
glEnable(GL_SCISSOR_TEST);
QVector4D clearColor = Utils::vectorFromColor(m_cachedTheme->windowColor());
glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
}
@@ -146,28 +252,87 @@ void Abstract3DRenderer::updateSelectionState(SelectionState state)
m_selectionState = state;
}
-void Abstract3DRenderer::updateInputPosition(const QPoint &position)
+void Abstract3DRenderer::initGradientShaders(const QString &vertexShader,
+ const QString &fragmentShader)
{
- m_inputPosition = position;
+ // Do nothing by default
+ Q_UNUSED(vertexShader)
+ Q_UNUSED(fragmentShader)
}
-void Abstract3DRenderer::initGradientShaders(const QString &vertexShader,
- const QString &fragmentShader)
+void Abstract3DRenderer::initStaticSelectedItemShaders(const QString &vertexShader,
+ const QString &fragmentShader,
+ const QString &gradientVertexShader,
+ const QString &gradientFragmentShader)
{
// Do nothing by default
Q_UNUSED(vertexShader)
Q_UNUSED(fragmentShader)
+ Q_UNUSED(gradientVertexShader)
+ Q_UNUSED(gradientFragmentShader)
}
void Abstract3DRenderer::initCustomItemShaders(const QString &vertexShader,
const QString &fragmentShader)
{
- if (m_customItemShader)
- delete m_customItemShader;
+ delete m_customItemShader;
m_customItemShader = new ShaderHelper(this, vertexShader, fragmentShader);
m_customItemShader->initialize();
}
+void Abstract3DRenderer::initVolumeTextureShaders(const QString &vertexShader,
+ const QString &fragmentShader,
+ const QString &fragmentLowDefShader,
+ const QString &sliceShader,
+ const QString &sliceFrameVertexShader,
+ const QString &sliceFrameShader)
+{
+
+ delete m_volumeTextureShader;
+ m_volumeTextureShader = new ShaderHelper(this, vertexShader, fragmentShader);
+ m_volumeTextureShader->initialize();
+
+ delete m_volumeTextureLowDefShader;
+ m_volumeTextureLowDefShader = new ShaderHelper(this, vertexShader, fragmentLowDefShader);
+ m_volumeTextureLowDefShader->initialize();
+
+ delete m_volumeTextureSliceShader;
+ m_volumeTextureSliceShader = new ShaderHelper(this, vertexShader, sliceShader);
+ m_volumeTextureSliceShader->initialize();
+
+ delete m_volumeSliceFrameShader;
+ m_volumeSliceFrameShader = new ShaderHelper(this, sliceFrameVertexShader, sliceFrameShader);
+ m_volumeSliceFrameShader->initialize();
+}
+
+void Abstract3DRenderer::initLabelShaders(const QString &vertexShader, const QString &fragmentShader)
+{
+ delete m_labelShader;
+ m_labelShader = new ShaderHelper(this, vertexShader, fragmentShader);
+ m_labelShader->initialize();
+}
+
+void Abstract3DRenderer::initCursorPositionShaders(const QString &vertexShader,
+ const QString &fragmentShader)
+{
+ // Init the shader
+ delete m_cursorPositionShader;
+ m_cursorPositionShader = new ShaderHelper(this, vertexShader, fragmentShader);
+ m_cursorPositionShader->initialize();
+}
+
+void Abstract3DRenderer::initCursorPositionBuffer()
+{
+ m_textureHelper->deleteTexture(&m_cursorPositionTexture);
+
+ if (m_primarySubViewport.size().isEmpty())
+ return;
+
+ m_cursorPositionTexture =
+ m_textureHelper->createCursorPositionTexture(m_primarySubViewport.size(),
+ m_cursorPositionFrameBuffer);
+}
+
void Abstract3DRenderer::updateTheme(Q3DTheme *theme)
{
// Synchronize the controller theme with renderer
@@ -193,24 +358,22 @@ void Abstract3DRenderer::updateScene(Q3DScene *scene)
handleResize();
}
- scene->activeCamera()->d_ptr->updateViewMatrix(m_autoScaleAdjustment);
- // Set light position (rotate light with activeCamera, a bit above it (as set in defaultLightPos))
- scene->d_ptr->setLightPositionRelativeToCamera(defaultLightPos);
-
QPoint logicalPixelPosition = scene->selectionQueryPosition();
- updateInputPosition(QPoint(logicalPixelPosition.x() * m_devicePixelRatio,
- logicalPixelPosition.y() * m_devicePixelRatio));
+ m_inputPosition = QPoint(logicalPixelPosition.x() * m_devicePixelRatio,
+ logicalPixelPosition.y() * m_devicePixelRatio);
+
+ QPoint logicalGraphPosition = scene->graphPositionQuery();
+ m_graphPositionQuery = QPoint(logicalGraphPosition.x() * m_devicePixelRatio,
+ logicalGraphPosition.y() * m_devicePixelRatio);
// Synchronize the renderer scene to controller scene
scene->d_ptr->sync(*m_cachedScene->d_ptr);
+ updateCameraViewport();
+
if (Q3DScene::invalidSelectionPoint() == logicalPixelPosition) {
updateSelectionState(SelectNone);
} else {
- // Selections are one-shot, reset selection active to false before processing
- scene->setSelectionQueryPosition(Q3DScene::invalidSelectionPoint());
- m_clickPending = true;
-
if (scene->isSlicingActive()) {
if (scene->isPointInPrimarySubView(logicalPixelPosition))
updateSelectionState(SelectOnOverview);
@@ -222,53 +385,109 @@ void Abstract3DRenderer::updateScene(Q3DScene *scene)
updateSelectionState(SelectOnScene);
}
}
+
+ if (Q3DScene::invalidSelectionPoint() != logicalGraphPosition)
+ m_graphPositionQueryPending = true;
+
+ // Queue up another render when we have a query that needs resolving.
+ // This is needed because QtQuick scene graph can sometimes do a sync without following it up
+ // with a render.
+ if (m_graphPositionQueryPending || m_selectionState != SelectNone)
+ emit needRender();
+}
+
+void Abstract3DRenderer::updateTextures()
+{
+ m_axisCacheX.updateTextures();
+ m_axisCacheY.updateTextures();
+ m_axisCacheZ.updateTextures();
}
void Abstract3DRenderer::reInitShaders()
{
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- initGradientShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
- initShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
- initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadowNoTex"));
- initCustomItemShaders(QStringLiteral(":/shaders/vertexShadow"),
- QStringLiteral(":/shaders/fragmentShadow"));
- } else {
- initGradientShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnY"));
- initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ if (!m_isOpenGLES) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ if (m_cachedOptimizationHint.testFlag(QAbstract3DGraph::OptimizationStatic)
+ && qobject_cast<Scatter3DRenderer *>(this)) {
+ initGradientShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadow"));
+ initStaticSelectedItemShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadowNoTex"),
+ QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ initShaders(QStringLiteral(":/shaders/vertexShadowNoMatrices"),
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ } else {
+ initGradientShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
+ initShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ }
+ initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadowNoTex"));
+ initCustomItemShaders(QStringLiteral(":/shaders/vertexShadow"),
+ QStringLiteral(":/shaders/fragmentShadow"));
+ } else {
+ if (m_cachedOptimizationHint.testFlag(QAbstract3DGraph::OptimizationStatic)
+ && qobject_cast<Scatter3DRenderer *>(this)) {
+ initGradientShaders(QStringLiteral(":/shaders/vertexTexture"),
+ QStringLiteral(":/shaders/fragmentTexture"));
+ initStaticSelectedItemShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragment"),
+ QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentColorOnY"));
+ initShaders(QStringLiteral(":/shaders/vertexNoMatrices"),
+ QStringLiteral(":/shaders/fragment"));
+ } else {
+ initGradientShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentColorOnY"));
+ initShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragment"));
+ }
+ initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragment"));
+ initCustomItemShaders(QStringLiteral(":/shaders/vertexTexture"),
+ QStringLiteral(":/shaders/fragmentTexture"));
+ }
+ initVolumeTextureShaders(QStringLiteral(":/shaders/vertexTexture3D"),
+ QStringLiteral(":/shaders/fragmentTexture3D"),
+ QStringLiteral(":/shaders/fragmentTexture3DLowDef"),
+ QStringLiteral(":/shaders/fragmentTexture3DSlice"),
+ QStringLiteral(":/shaders/vertexPosition"),
+ QStringLiteral(":/shaders/fragment3DSliceFrames"));
+ } else {
+ if (m_cachedOptimizationHint.testFlag(QAbstract3DGraph::OptimizationStatic)
+ && qobject_cast<Scatter3DRenderer *>(this)) {
+ initGradientShaders(QStringLiteral(":/shaders/vertexTexture"),
+ QStringLiteral(":/shaders/fragmentTextureES2"));
+ initStaticSelectedItemShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentES2"),
+ QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ initBackgroundShaders(QStringLiteral(":/shaders/vertexNoMatrices"),
+ QStringLiteral(":/shaders/fragmentES2"));
+ } else {
+ initGradientShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ initShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentES2"));
+ }
initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragment"));
+ QStringLiteral(":/shaders/fragmentES2"));
initCustomItemShaders(QStringLiteral(":/shaders/vertexTexture"),
- QStringLiteral(":/shaders/fragmentTexture"));
+ QStringLiteral(":/shaders/fragmentTextureES2"));
}
-#else
- initGradientShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
- initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentES2"));
- initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentES2"));
- initCustomItemShaders(QStringLiteral(":/shaders/vertexTexture"),
- QStringLiteral(":/shaders/fragmentTextureES2"));
-#endif
}
void Abstract3DRenderer::handleShadowQualityChange()
{
reInitShaders();
-#if defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality != QAbstract3DGraph::ShadowQualityNone) {
+ if (m_isOpenGLES && m_cachedShadowQuality != QAbstract3DGraph::ShadowQualityNone) {
emit requestShadowQuality(QAbstract3DGraph::ShadowQualityNone);
qWarning("Shadows are not yet supported for OpenGL ES2");
m_cachedShadowQuality = QAbstract3DGraph::ShadowQualityNone;
}
-#endif
}
void Abstract3DRenderer::updateSelectionMode(QAbstract3DGraph::SelectionFlags mode)
@@ -280,16 +499,39 @@ void Abstract3DRenderer::updateSelectionMode(QAbstract3DGraph::SelectionFlags mo
void Abstract3DRenderer::updateAspectRatio(float ratio)
{
m_graphAspectRatio = ratio;
- calculateZoomLevel();
- m_cachedScene->activeCamera()->d_ptr->updateViewMatrix(m_autoScaleAdjustment);
foreach (SeriesRenderCache *cache, m_renderCacheList)
cache->setDataDirty(true);
- updateCustomItemPositions();
+}
+
+void Abstract3DRenderer::updateHorizontalAspectRatio(float ratio)
+{
+ m_graphHorizontalAspectRatio = ratio;
+ foreach (SeriesRenderCache *cache, m_renderCacheList)
+ cache->setDataDirty(true);
+}
+
+void Abstract3DRenderer::updatePolar(bool enable)
+{
+ m_polarGraph = enable;
+ foreach (SeriesRenderCache *cache, m_renderCacheList)
+ cache->setDataDirty(true);
+}
+
+void Abstract3DRenderer::updateRadialLabelOffset(float offset)
+{
+ m_radialLabelOffset = offset;
+}
+
+void Abstract3DRenderer::updateMargin(float margin)
+{
+ m_requestedMargin = margin;
}
void Abstract3DRenderer::updateOptimizationHint(QAbstract3DGraph::OptimizationHints hint)
{
m_cachedOptimizationHint = hint;
+ foreach (SeriesRenderCache *cache, m_renderCacheList)
+ cache->setDataDirty(true);
}
void Abstract3DRenderer::handleResize()
@@ -303,10 +545,10 @@ void Abstract3DRenderer::handleResize()
// Re-init selection buffer
initSelectionBuffer();
-#if !defined(QT_OPENGL_ES_2)
// Re-init depth buffer
updateDepthBuffer();
-#endif
+
+ initCursorPositionBuffer();
}
void Abstract3DRenderer::calculateZoomLevel()
@@ -315,9 +557,9 @@ void Abstract3DRenderer::calculateZoomLevel()
GLfloat div;
GLfloat zoomAdjustment;
div = qMin(m_primarySubViewport.width(), m_primarySubViewport.height());
- zoomAdjustment = 2.0f * defaultRatio
+ zoomAdjustment = defaultRatio
* ((m_primarySubViewport.width() / div)
- / (m_primarySubViewport.height() / div)) / m_graphAspectRatio;
+ / (m_primarySubViewport.height() / div));
m_autoScaleAdjustment = qMin(zoomAdjustment, 1.0f); // clamp to 1.0f
}
@@ -348,8 +590,6 @@ void Abstract3DRenderer::updateAxisRange(QAbstract3DAxis::AxisOrientation orient
foreach (SeriesRenderCache *cache, m_renderCacheList)
cache->setDataDirty(true);
-
- updateCustomItemPositions();
}
void Abstract3DRenderer::updateAxisSegmentCount(QAbstract3DAxis::AxisOrientation orientation,
@@ -378,8 +618,6 @@ void Abstract3DRenderer::updateAxisReversed(QAbstract3DAxis::AxisOrientation ori
axisCacheForOrientation(orientation).setReversed(enable);
foreach (SeriesRenderCache *cache, m_renderCacheList)
cache->setDataDirty(true);
-
- updateCustomItemPositions();
}
void Abstract3DRenderer::updateAxisFormatter(QAbstract3DAxis::AxisOrientation orientation,
@@ -396,8 +634,6 @@ void Abstract3DRenderer::updateAxisFormatter(QAbstract3DAxis::AxisOrientation or
foreach (SeriesRenderCache *cache, m_renderCacheList)
cache->setDataDirty(true);
-
- updateCustomItemPositions();
}
void Abstract3DRenderer::updateAxisLabelAutoRotation(QAbstract3DAxis::AxisOrientation orientation,
@@ -607,10 +843,9 @@ void Abstract3DRenderer::drawAxisTitleY(const QVector3D &sideLabelRotation,
QQuaternion titleRotation;
if (m_axisCacheY.isTitleFixed()) {
titleRotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, yRotation)
- * QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, 90.0f);
+ * m_zRightAngleRotation;
} else {
- titleRotation = totalRotation
- * QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, 90.0f);
+ titleRotation = totalRotation * m_zRightAngleRotation;
}
dummyItem.setTranslation(titleTrans + titleOffsetVector);
@@ -628,17 +863,22 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
float labelsMaxWidth,
const QMatrix4x4 &viewMatrix,
const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader)
+ ShaderHelper *shader,
+ bool radial)
{
float scaleFactor = m_drawer->scaledFontSize() / m_axisCacheX.titleItem().size().height();
- float titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
+ float titleOffset;
+ if (radial)
+ titleOffset = -2.0f * (labelMargin + m_drawer->scaledFontSize());
+ else
+ titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
float zRotation = 0.0f;
float yRotation = 0.0f;
float xRotation = -90.0f + labelRotation.z();
float offsetRotation = labelRotation.z();
float extraRotation = -90.0f;
Qt::AlignmentFlag alignment = Qt::AlignTop;
- if (m_yFlipped) {
+ if (m_yFlippedForGrid) {
alignment = Qt::AlignBottom;
zRotation = 180.0f;
if (m_zFlipped) {
@@ -678,6 +918,17 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
}
}
+ if (radial) {
+ if (m_zFlipped) {
+ titleOffset = -titleOffset;
+ } else {
+ if (m_yFlippedForGrid)
+ alignment = Qt::AlignTop;
+ else
+ alignment = Qt::AlignBottom;
+ }
+ }
+
if (offsetRotation == 180.0f || offsetRotation == -180.0f)
offsetRotation = 0.0f;
QQuaternion offsetRotator = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, offsetRotation);
@@ -718,7 +969,7 @@ void Abstract3DRenderer::drawAxisTitleZ(const QVector3D &labelRotation,
float xRotation = -90.0f;
float extraRotation = 90.0f;
Qt::AlignmentFlag alignment = Qt::AlignTop;
- if (m_yFlipped) {
+ if (m_yFlippedForGrid) {
alignment = Qt::AlignBottom;
xRotation = -xRotation;
if (m_zFlipped) {
@@ -793,6 +1044,11 @@ void Abstract3DRenderer::loadLabelMesh()
QStringLiteral(":/defaultMeshes/plane"));
}
+void Abstract3DRenderer::loadPositionMapperMesh()
+{
+ ObjectHelper::resetObjectHelper(this, m_positionMapperObj,
+ QStringLiteral(":/defaultMeshes/barFull"));
+}
void Abstract3DRenderer::generateBaseColorTexture(const QColor &color, GLuint *texture)
{
@@ -846,11 +1102,16 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
newItem->setRenderer(this);
newItem->setItemPointer(item); // Store pointer for render item updates
newItem->setMesh(item->meshFile());
- QVector3D scaling = item->scaling();
+ newItem->setOrigPosition(item->position());
+ newItem->setOrigScaling(item->scaling());
+ newItem->setScalingAbsolute(item->isScalingAbsolute());
+ newItem->setPositionAbsolute(item->isPositionAbsolute());
QImage textureImage = item->d_ptr->textureImage();
bool facingCamera = false;
+ GLuint texture = 0;
if (item->d_ptr->m_isLabelItem) {
QCustom3DLabel *labelItem = static_cast<QCustom3DLabel *>(item);
+ newItem->setLabelItem(true);
float pointSize = labelItem->font().pointSizeF();
// Check do we have custom visuals or need to use theme
if (!labelItem->dptr()->m_customVisuals) {
@@ -864,22 +1125,52 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
}
// Calculate scaling based on text (texture size), font size and asked scaling
float scaledFontSize = (0.05f + pointSize / 500.0f) / float(textureImage.height());
+ QVector3D scaling = newItem->origScaling();
scaling.setX(scaling.x() * textureImage.width() * scaledFontSize);
scaling.setY(scaling.y() * textureImage.height() * scaledFontSize);
+ newItem->setOrigScaling(scaling);
// Check if facing camera
facingCamera = labelItem->isFacingCamera();
+ } else if (item->d_ptr->m_isVolumeItem && !m_isOpenGLES) {
+ QCustom3DVolume *volumeItem = static_cast<QCustom3DVolume *>(item);
+ newItem->setTextureWidth(volumeItem->textureWidth());
+ newItem->setTextureHeight(volumeItem->textureHeight());
+ newItem->setTextureDepth(volumeItem->textureDepth());
+ if (volumeItem->textureFormat() == QImage::Format_Indexed8)
+ newItem->setColorTable(volumeItem->colorTable());
+ newItem->setTextureFormat(volumeItem->textureFormat());
+ newItem->setVolume(true);
+ newItem->setBlendNeeded(true);
+ texture = m_textureHelper->create3DTexture(volumeItem->textureData(),
+ volumeItem->textureWidth(),
+ volumeItem->textureHeight(),
+ volumeItem->textureDepth(),
+ volumeItem->textureFormat());
+ newItem->setSliceIndexX(volumeItem->sliceIndexX());
+ newItem->setSliceIndexY(volumeItem->sliceIndexY());
+ newItem->setSliceIndexZ(volumeItem->sliceIndexZ());
+ newItem->setAlphaMultiplier(volumeItem->alphaMultiplier());
+ newItem->setPreserveOpacity(volumeItem->preserveOpacity());
+ newItem->setUseHighDefShader(volumeItem->useHighDefShader());
+
+ newItem->setDrawSlices(volumeItem->drawSlices());
+ newItem->setDrawSliceFrames(volumeItem->drawSliceFrames());
+ newItem->setSliceFrameColor(volumeItem->sliceFrameColor());
+ newItem->setSliceFrameWidths(volumeItem->sliceFrameWidths());
+ newItem->setSliceFrameGaps(volumeItem->sliceFrameGaps());
+ newItem->setSliceFrameThicknesses(volumeItem->sliceFrameThicknesses());
}
- newItem->setScaling(scaling);
+ recalculateCustomItemScalingAndPos(newItem);
newItem->setRotation(item->rotation());
- newItem->setPosition(item->position());
- newItem->setPositionAbsolute(item->isPositionAbsolute());
- newItem->setBlendNeeded(textureImage.hasAlphaChannel());
- GLuint texture = m_textureHelper->create2DTexture(textureImage, true, true, true);
+
+ // In OpenGL ES we simply draw volumes as regular custom item placeholders.
+ if (!item->d_ptr->m_isVolumeItem || m_isOpenGLES)
+ {
+ newItem->setBlendNeeded(textureImage.hasAlphaChannel());
+ texture = m_textureHelper->create2DTexture(textureImage, true, true, true);
+ }
newItem->setTexture(texture);
item->d_ptr->clearTextureImage();
- QVector3D translation = convertPositionToTranslation(item->position(),
- item->isPositionAbsolute());
- newItem->setTranslation(translation);
newItem->setVisible(item->isVisible());
newItem->setShadowCasting(item->isShadowCasting());
newItem->setFacingCamera(facingCamera);
@@ -887,6 +1178,74 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
return newItem;
}
+void Abstract3DRenderer::recalculateCustomItemScalingAndPos(CustomRenderItem *item)
+{
+ if (!m_polarGraph && !item->isLabel() && !item->isScalingAbsolute()
+ && !item->isPositionAbsolute()) {
+ QVector3D scale = item->origScaling() / 2.0f;
+ QVector3D pos = item->origPosition();
+ QVector3D minBounds(pos.x() - scale.x(),
+ pos.y() - scale.y(),
+ pos.z() + scale.z());
+ QVector3D maxBounds(pos.x() + scale.x(),
+ pos.y() + scale.y(),
+ pos.z() - scale.z());
+ QVector3D minCorner = convertPositionToTranslation(minBounds, false);
+ QVector3D maxCorner = convertPositionToTranslation(maxBounds, false);
+ scale = QVector3D(qAbs(maxCorner.x() - minCorner.x()),
+ qAbs(maxCorner.y() - minCorner.y()),
+ qAbs(maxCorner.z() - minCorner.z())) / 2.0f;
+ if (item->isVolume()) {
+ // Only volume items need to scale and reposition according to bounds
+ QVector3D minBoundsNormal = minCorner;
+ QVector3D maxBoundsNormal = maxCorner;
+ // getVisibleItemBounds returns bounds normalized for fragment shader [-1,1]
+ // Y and Z are also flipped.
+ getVisibleItemBounds(minBoundsNormal, maxBoundsNormal);
+ item->setMinBounds(minBoundsNormal);
+ item->setMaxBounds(maxBoundsNormal);
+ // For scaling calculations, we want [0,1] normalized values
+ minBoundsNormal = item->minBoundsNormal();
+ maxBoundsNormal = item->maxBoundsNormal();
+
+ // Rescale and reposition the item so that it doesn't go over the edges
+ QVector3D adjScaling =
+ QVector3D(scale.x() * (maxBoundsNormal.x() - minBoundsNormal.x()),
+ scale.y() * (maxBoundsNormal.y() - minBoundsNormal.y()),
+ scale.z() * (maxBoundsNormal.z() - minBoundsNormal.z()));
+
+ item->setScaling(adjScaling);
+
+ QVector3D adjPos = item->origPosition();
+ QVector3D dataExtents = QVector3D(maxBounds.x() - minBounds.x(),
+ maxBounds.y() - minBounds.y(),
+ maxBounds.z() - minBounds.z()) / 2.0f;
+ adjPos.setX(adjPos.x() + (dataExtents.x() * minBoundsNormal.x())
+ - (dataExtents.x() * (1.0f - maxBoundsNormal.x())));
+ adjPos.setY(adjPos.y() + (dataExtents.y() * minBoundsNormal.y())
+ - (dataExtents.y() * (1.0f - maxBoundsNormal.y())));
+ adjPos.setZ(adjPos.z() + (dataExtents.z() * minBoundsNormal.z())
+ - (dataExtents.z() * (1.0f - maxBoundsNormal.z())));
+ item->setPosition(adjPos);
+ } else {
+ // Only scale for non-volume items, and do not readjust position
+ item->setScaling(scale);
+ item->setPosition(item->origPosition());
+ }
+ } else {
+ item->setScaling(item->origScaling());
+ item->setPosition(item->origPosition());
+ if (item->isVolume()) {
+ // Y and Z need to be flipped as shader flips those axes
+ item->setMinBounds(QVector3D(-1.0f, 1.0f, 1.0f));
+ item->setMaxBounds(QVector3D(1.0f, -1.0f, -1.0f));
+ }
+ }
+ QVector3D translation = convertPositionToTranslation(item->position(),
+ item->isPositionAbsolute());
+ item->setTranslation(translation);
+}
+
void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
{
QCustom3DItem *item = renderItem->itemPointer();
@@ -894,8 +1253,17 @@ void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
renderItem->setMesh(item->meshFile());
item->d_ptr->m_dirtyBits.meshDirty = false;
}
+ if (item->d_ptr->m_dirtyBits.positionDirty) {
+ renderItem->setOrigPosition(item->position());
+ renderItem->setPositionAbsolute(item->isPositionAbsolute());
+ if (!item->d_ptr->m_dirtyBits.scalingDirty)
+ recalculateCustomItemScalingAndPos(renderItem);
+ item->d_ptr->m_dirtyBits.positionDirty = false;
+ }
if (item->d_ptr->m_dirtyBits.scalingDirty) {
QVector3D scaling = item->scaling();
+ renderItem->setOrigScaling(scaling);
+ renderItem->setScalingAbsolute(item->isScalingAbsolute());
// In case we have label item, we need to recreate texture for scaling adjustment
if (item->d_ptr->m_isLabelItem) {
QCustom3DLabel *labelItem = static_cast<QCustom3DLabel *>(item);
@@ -918,8 +1286,9 @@ void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
scaling.setX(scaling.x() * textureImage.width() * scaledFontSize);
scaling.setY(scaling.y() * textureImage.height() * scaledFontSize);
item->d_ptr->clearTextureImage();
+ renderItem->setOrigScaling(scaling);
}
- renderItem->setScaling(scaling);
+ recalculateCustomItemScalingAndPos(renderItem);
item->d_ptr->m_dirtyBits.scalingDirty = false;
}
if (item->d_ptr->m_dirtyBits.rotationDirty) {
@@ -939,24 +1308,16 @@ void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
m_cachedTheme->isLabelBorderEnabled());
textureImage = item->d_ptr->textureImage();
}
+ } else if (!item->d_ptr->m_isVolumeItem || m_isOpenGLES) {
+ renderItem->setBlendNeeded(textureImage.hasAlphaChannel());
+ GLuint oldTexture = renderItem->texture();
+ m_textureHelper->deleteTexture(&oldTexture);
+ GLuint texture = m_textureHelper->create2DTexture(textureImage, true, true, true);
+ renderItem->setTexture(texture);
}
- renderItem->setBlendNeeded(textureImage.hasAlphaChannel());
- GLuint oldTexture = renderItem->texture();
- m_textureHelper->deleteTexture(&oldTexture);
- GLuint texture = m_textureHelper->create2DTexture(textureImage, true, true, true);
- renderItem->setTexture(texture);
item->d_ptr->clearTextureImage();
item->d_ptr->m_dirtyBits.textureDirty = false;
}
- if (item->d_ptr->m_dirtyBits.positionDirty || item->d_ptr->m_dirtyBits.positionAbsoluteDirty) {
- renderItem->setPosition(item->position());
- renderItem->setPositionAbsolute(item->isPositionAbsolute());
- QVector3D translation = convertPositionToTranslation(item->position(),
- item->isPositionAbsolute());
- renderItem->setTranslation(translation);
- item->d_ptr->m_dirtyBits.positionDirty = false;
- item->d_ptr->m_dirtyBits.positionAbsoluteDirty = false;
- }
if (item->d_ptr->m_dirtyBits.visibleDirty) {
renderItem->setVisible(item->isVisible());
item->d_ptr->m_dirtyBits.visibleDirty = false;
@@ -971,130 +1332,649 @@ void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
renderItem->setFacingCamera(labelItem->isFacingCamera());
labelItem->dptr()->m_facingCameraDirty = false;
}
+ } else if (item->d_ptr->m_isVolumeItem && !m_isOpenGLES) {
+ QCustom3DVolume *volumeItem = static_cast<QCustom3DVolume *>(item);
+ if (volumeItem->dptr()->m_dirtyBitsVolume.colorTableDirty) {
+ renderItem->setColorTable(volumeItem->colorTable());
+ volumeItem->dptr()->m_dirtyBitsVolume.colorTableDirty = false;
+ }
+ if (volumeItem->dptr()->m_dirtyBitsVolume.textureDimensionsDirty
+ || volumeItem->dptr()->m_dirtyBitsVolume.textureDataDirty
+ || volumeItem->dptr()->m_dirtyBitsVolume.textureFormatDirty) {
+ GLuint oldTexture = renderItem->texture();
+ m_textureHelper->deleteTexture(&oldTexture);
+ GLuint texture = m_textureHelper->create3DTexture(volumeItem->textureData(),
+ volumeItem->textureWidth(),
+ volumeItem->textureHeight(),
+ volumeItem->textureDepth(),
+ volumeItem->textureFormat());
+ renderItem->setTexture(texture);
+ renderItem->setTextureWidth(volumeItem->textureWidth());
+ renderItem->setTextureHeight(volumeItem->textureHeight());
+ renderItem->setTextureDepth(volumeItem->textureDepth());
+ renderItem->setTextureFormat(volumeItem->textureFormat());
+ volumeItem->dptr()->m_dirtyBitsVolume.textureDimensionsDirty = false;
+ volumeItem->dptr()->m_dirtyBitsVolume.textureDataDirty = false;
+ volumeItem->dptr()->m_dirtyBitsVolume.textureFormatDirty = false;
+ }
+ if (volumeItem->dptr()->m_dirtyBitsVolume.slicesDirty) {
+ renderItem->setDrawSlices(volumeItem->drawSlices());
+ renderItem->setDrawSliceFrames(volumeItem->drawSliceFrames());
+ renderItem->setSliceFrameColor(volumeItem->sliceFrameColor());
+ renderItem->setSliceFrameWidths(volumeItem->sliceFrameWidths());
+ renderItem->setSliceFrameGaps(volumeItem->sliceFrameGaps());
+ renderItem->setSliceFrameThicknesses(volumeItem->sliceFrameThicknesses());
+ renderItem->setSliceIndexX(volumeItem->sliceIndexX());
+ renderItem->setSliceIndexY(volumeItem->sliceIndexY());
+ renderItem->setSliceIndexZ(volumeItem->sliceIndexZ());
+ volumeItem->dptr()->m_dirtyBitsVolume.slicesDirty = false;
+ }
+ if (volumeItem->dptr()->m_dirtyBitsVolume.alphaDirty) {
+ renderItem->setAlphaMultiplier(volumeItem->alphaMultiplier());
+ renderItem->setPreserveOpacity(volumeItem->preserveOpacity());
+ volumeItem->dptr()->m_dirtyBitsVolume.alphaDirty = false;
+ }
+ if (volumeItem->dptr()->m_dirtyBitsVolume.shaderDirty) {
+ renderItem->setUseHighDefShader(volumeItem->useHighDefShader());
+ volumeItem->dptr()->m_dirtyBitsVolume.shaderDirty = false;
+ }
}
}
void Abstract3DRenderer::updateCustomItemPositions()
{
- foreach (CustomRenderItem *renderItem, m_customRenderCache) {
- QVector3D translation = convertPositionToTranslation(renderItem->position(),
- renderItem->isPositionAbsolute());
- renderItem->setTranslation(translation);
- }
+ foreach (CustomRenderItem *renderItem, m_customRenderCache)
+ recalculateCustomItemScalingAndPos(renderItem);
}
void Abstract3DRenderer::drawCustomItems(RenderingState state,
- ShaderHelper *shader,
+ ShaderHelper *regularShader,
const QMatrix4x4 &viewMatrix,
const QMatrix4x4 &projectionViewMatrix,
const QMatrix4x4 &depthProjectionViewMatrix,
GLuint depthTexture,
- GLfloat shadowQuality)
+ GLfloat shadowQuality,
+ GLfloat reflection)
{
if (m_customRenderCache.isEmpty())
return;
+ ShaderHelper *shader = regularShader;
+ shader->bind();
+
if (RenderingNormal == state) {
- shader->bind();
shader->setUniformValue(shader->lightP(), m_cachedScene->activeLight()->position());
shader->setUniformValue(shader->ambientS(), m_cachedTheme->ambientLightStrength());
shader->setUniformValue(shader->lightColor(),
Utils::vectorFromColor(m_cachedTheme->lightColor()));
shader->setUniformValue(shader->view(), viewMatrix);
-
- glEnable(GL_TEXTURE_2D);
}
- // Draw custom items
- foreach (CustomRenderItem *item, m_customRenderCache) {
- // Check that the render item is visible, and skip drawing if not
- if (!item->isVisible())
- continue;
-
- // Check if the render item is in data coordinates and not within axis ranges, and skip drawing if it is
- if (!item->isPositionAbsolute()
- && (item->position().x() < m_axisCacheX.min()
- || item->position().x() > m_axisCacheX.max()
- || item->position().z() < m_axisCacheZ.min()
- || item->position().z() > m_axisCacheZ.max()
- || item->position().y() < m_axisCacheY.min()
- || item->position().y() > m_axisCacheY.max())) {
- continue;
- }
+ // Draw custom items - first regular and then volumes
+ bool volumeDetected = false;
+ int loopCount = 0;
+ while (loopCount < 2) {
+ foreach (CustomRenderItem *item, m_customRenderCache) {
+ // Check that the render item is visible, and skip drawing if not
+ // Also check if reflected item is on the "wrong" side, and skip drawing if it is
+ if (!item->isVisible() || ((m_reflectionEnabled && reflection < 0.0f)
+ && (m_yFlipped == (item->translation().y() >= 0.0)))) {
+ continue;
+ }
+ if (loopCount == 0) {
+ if (item->isVolume()) {
+ volumeDetected = true;
+ continue;
+ }
+ } else {
+ if (!item->isVolume())
+ continue;
+ }
- QMatrix4x4 modelMatrix;
- QMatrix4x4 itModelMatrix;
- QMatrix4x4 MVPMatrix;
-
- QQuaternion rotation = item->rotation();
- // Check if the (label) item should be facing camera, and adjust rotation accordingly
- if (item->isFacingCamera()) {
- float camRotationX = m_cachedScene->activeCamera()->xRotation();
- float camRotationY = m_cachedScene->activeCamera()->yRotation();
- rotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -camRotationX)
- * QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -camRotationY);
+ // If the render item is in data coordinates and not within axis ranges, skip it
+ if (!item->isPositionAbsolute()
+ && (item->position().x() < m_axisCacheX.min()
+ || item->position().x() > m_axisCacheX.max()
+ || item->position().z() < m_axisCacheZ.min()
+ || item->position().z() > m_axisCacheZ.max()
+ || item->position().y() < m_axisCacheY.min()
+ || item->position().y() > m_axisCacheY.max())) {
+ continue;
+ }
+
+ QMatrix4x4 modelMatrix;
+ QMatrix4x4 itModelMatrix;
+ QMatrix4x4 MVPMatrix;
+
+ QQuaternion rotation = item->rotation();
+ // Check if the (label) item should be facing camera, and adjust rotation accordingly
+ if (item->isFacingCamera()) {
+ float camRotationX = m_cachedScene->activeCamera()->xRotation();
+ float camRotationY = m_cachedScene->activeCamera()->yRotation();
+ rotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -camRotationX)
+ * QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -camRotationY);
+ }
+
+ if (m_reflectionEnabled) {
+ if (reflection < 0.0f) {
+ if (item->itemPointer()->d_ptr->m_isLabelItem)
+ continue;
+ else
+ glCullFace(GL_FRONT);
+ } else {
+ glCullFace(GL_BACK);
+ }
+ QVector3D trans = item->translation();
+ trans.setY(reflection * trans.y());
+ modelMatrix.translate(trans);
+ if (reflection < 0.0f) {
+ QQuaternion mirror = QQuaternion(rotation.scalar(),
+ -rotation.x(), rotation.y(), -rotation.z());
+ modelMatrix.rotate(mirror);
+ itModelMatrix.rotate(mirror);
+ } else {
+ modelMatrix.rotate(rotation);
+ itModelMatrix.rotate(rotation);
+ }
+ QVector3D scale = item->scaling();
+ scale.setY(reflection * scale.y());
+ modelMatrix.scale(scale);
+ } else {
+ modelMatrix.translate(item->translation());
+ modelMatrix.rotate(rotation);
+ modelMatrix.scale(item->scaling());
+ itModelMatrix.rotate(rotation);
+ }
+ if (!item->isFacingCamera())
+ itModelMatrix.scale(item->scaling());
+ MVPMatrix = projectionViewMatrix * modelMatrix;
+
+ if (RenderingNormal == state) {
+ // Normal render
+ ShaderHelper *prevShader = shader;
+ if (item->isVolume() && !m_isOpenGLES) {
+ if (item->drawSlices() &&
+ (item->sliceIndexX() >= 0
+ || item->sliceIndexY() >= 0
+ || item->sliceIndexZ() >= 0)) {
+ shader = m_volumeTextureSliceShader;
+ } else if (item->useHighDefShader()) {
+ shader = m_volumeTextureShader;
+ } else {
+ shader = m_volumeTextureLowDefShader;
+ }
+ } else if (item->isLabel()) {
+ shader = m_labelShader;
+ } else {
+ shader = regularShader;
+ }
+ if (shader != prevShader)
+ shader->bind();
+ shader->setUniformValue(shader->model(), modelMatrix);
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
+ shader->setUniformValue(shader->nModel(), itModelMatrix.inverted().transposed());
+
+ if (item->isBlendNeeded()) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ if (!item->isVolume() && !m_isOpenGLES)
+ glDisable(GL_CULL_FACE);
+ } else {
+ glDisable(GL_BLEND);
+ glEnable(GL_CULL_FACE);
+ }
+
+ if (!m_isOpenGLES && m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone
+ && !item->isVolume()) {
+ // Set shadow shader bindings
+ shader->setUniformValue(shader->shadowQ(), shadowQuality);
+ shader->setUniformValue(shader->depth(), depthProjectionViewMatrix * modelMatrix);
+ shader->setUniformValue(shader->lightS(), m_cachedTheme->lightStrength() / 10.0f);
+ m_drawer->drawObject(shader, item->mesh(), item->texture(), depthTexture);
+ } else {
+ // Set shadowless shader bindings
+ if (item->isVolume() && !m_isOpenGLES) {
+ QVector3D cameraPos = m_cachedScene->activeCamera()->position();
+ cameraPos = MVPMatrix.inverted().map(cameraPos);
+ // Adjust camera position according to min/max bounds
+ cameraPos = -(cameraPos
+ + ((oneVector - cameraPos) * item->minBoundsNormal())
+ - ((oneVector + cameraPos) * (oneVector - item->maxBoundsNormal())));
+ shader->setUniformValue(shader->cameraPositionRelativeToModel(), cameraPos);
+ GLint color8Bit = (item->textureFormat() == QImage::Format_Indexed8) ? 1 : 0;
+ if (color8Bit) {
+ shader->setUniformValueArray(shader->colorIndex(),
+ item->colorTable().constData(), 256);
+ }
+ shader->setUniformValue(shader->color8Bit(), color8Bit);
+ shader->setUniformValue(shader->alphaMultiplier(), item->alphaMultiplier());
+ shader->setUniformValue(shader->preserveOpacity(),
+ item->preserveOpacity() ? 1 : 0);
+
+ shader->setUniformValue(shader->minBounds(), item->minBounds());
+ shader->setUniformValue(shader->maxBounds(), item->maxBounds());
+
+ if (shader == m_volumeTextureSliceShader) {
+ shader->setUniformValue(shader->volumeSliceIndices(),
+ item->sliceFractions());
+ } else {
+ // Precalculate texture dimensions so we can optimize
+ // ray stepping to hit every texture layer.
+ QVector3D textureDimensions(1.0f / float(item->textureWidth()),
+ 1.0f / float(item->textureHeight()),
+ 1.0f / float(item->textureDepth()));
+
+ // Worst case scenario sample count
+ int sampleCount;
+ if (shader == m_volumeTextureLowDefShader) {
+ sampleCount = qMax(item->textureWidth(),
+ qMax(item->textureDepth(), item->textureHeight()));
+ // Further improve speed with big textures by simply dropping every
+ // other sample:
+ if (sampleCount > 256)
+ sampleCount /= 2;
+ } else {
+ sampleCount = item->textureWidth() + item->textureHeight()
+ + item->textureDepth();
+ }
+ shader->setUniformValue(shader->textureDimensions(), textureDimensions);
+ shader->setUniformValue(shader->sampleCount(), sampleCount);
+ }
+ if (item->drawSliceFrames()) {
+ // Set up the slice frame shader
+ glDisable(GL_CULL_FACE);
+ m_volumeSliceFrameShader->bind();
+ m_volumeSliceFrameShader->setUniformValue(
+ m_volumeSliceFrameShader->color(), item->sliceFrameColor());
+
+ // Draw individual slice frames.
+ if (item->sliceIndexX() >= 0)
+ drawVolumeSliceFrame(item, Qt::XAxis, projectionViewMatrix);
+ if (item->sliceIndexY() >= 0)
+ drawVolumeSliceFrame(item, Qt::YAxis, projectionViewMatrix);
+ if (item->sliceIndexZ() >= 0)
+ drawVolumeSliceFrame(item, Qt::ZAxis, projectionViewMatrix);
+
+ glEnable(GL_CULL_FACE);
+ shader->bind();
+ }
+ m_drawer->drawObject(shader, item->mesh(), 0, 0, item->texture());
+ } else {
+ shader->setUniformValue(shader->lightS(), m_cachedTheme->lightStrength());
+ m_drawer->drawObject(shader, item->mesh(), item->texture());
+ }
+ }
+ } else if (RenderingSelection == state) {
+ // Selection render
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
+ QVector4D itemColor = indexToSelectionColor(item->index());
+ itemColor.setW(customItemAlpha);
+ itemColor /= 255.0f;
+ shader->setUniformValue(shader->color(), itemColor);
+ m_drawer->drawObject(shader, item->mesh());
+ } else if (item->isShadowCasting()) {
+ // Depth render
+ shader->setUniformValue(shader->MVP(), depthProjectionViewMatrix * modelMatrix);
+ m_drawer->drawObject(shader, item->mesh());
+ }
}
+ loopCount++;
+ if (!volumeDetected)
+ loopCount++; // Skip second run if no volumes detected
+ }
+
+ if (RenderingNormal == state) {
+ glDisable(GL_BLEND);
+ glEnable(GL_CULL_FACE);
+ }
+}
+
+void Abstract3DRenderer::drawVolumeSliceFrame(const CustomRenderItem *item, Qt::Axis axis,
+ const QMatrix4x4 &projectionViewMatrix)
+{
+ QVector2D frameWidth;
+ QVector3D frameScaling;
+ QVector3D translation = item->translation();
+ QQuaternion rotation = item->rotation();
+ float fracTrans;
+ bool needRotate = !rotation.isIdentity();
+ QMatrix4x4 rotationMatrix;
+ if (needRotate)
+ rotationMatrix.rotate(rotation);
+
+ if (axis == Qt::XAxis) {
+ fracTrans = item->sliceFractions().x();
+ float range = item->maxBoundsNormal().x() - item->minBoundsNormal().x();
+ float minMult = item->minBoundsNormal().x() / range;
+ float maxMult = (1.0f - item->maxBoundsNormal().x()) / range;
+ fracTrans = fracTrans - ((1.0f - fracTrans) * minMult) + ((1.0f + fracTrans) * maxMult);
+ if (needRotate)
+ translation += rotationMatrix.map(QVector3D(fracTrans * item->scaling().x(), 0.0f, 0.0f));
+ else
+ translation.setX(translation.x() + fracTrans * item->scaling().x());
+ frameScaling = QVector3D(item->scaling().z()
+ + (item->scaling().z() * item->sliceFrameGaps().z())
+ + (item->scaling().z() * item->sliceFrameWidths().z()),
+ item->scaling().y()
+ + (item->scaling().y() * item->sliceFrameGaps().y())
+ + (item->scaling().y() * item->sliceFrameWidths().y()),
+ item->scaling().x() * item->sliceFrameThicknesses().x());
+ frameWidth = QVector2D(item->scaling().z() * item->sliceFrameWidths().z(),
+ item->scaling().y() * item->sliceFrameWidths().y());
+ rotation *= m_yRightAngleRotation;
+ } else if (axis == Qt::YAxis) {
+ fracTrans = item->sliceFractions().y();
+ float range = item->maxBoundsNormal().y() - item->minBoundsNormal().y();
+ // Y axis is logically flipped, so we need to swam min and max bounds
+ float minMult = (1.0f - item->maxBoundsNormal().y()) / range;
+ float maxMult = item->minBoundsNormal().y() / range;
+ fracTrans = fracTrans - ((1.0f - fracTrans) * minMult) + ((1.0f + fracTrans) * maxMult);
+ if (needRotate)
+ translation -= rotationMatrix.map(QVector3D(0.0f, fracTrans * item->scaling().y(), 0.0f));
+ else
+ translation.setY(translation.y() - fracTrans * item->scaling().y());
+ frameScaling = QVector3D(item->scaling().x()
+ + (item->scaling().x() * item->sliceFrameGaps().x())
+ + (item->scaling().x() * item->sliceFrameWidths().x()),
+ item->scaling().z()
+ + (item->scaling().z() * item->sliceFrameGaps().z())
+ + (item->scaling().z() * item->sliceFrameWidths().z()),
+ item->scaling().y() * item->sliceFrameThicknesses().y());
+ frameWidth = QVector2D(item->scaling().x() * item->sliceFrameWidths().x(),
+ item->scaling().z() * item->sliceFrameWidths().z());
+ rotation *= m_xRightAngleRotation;
+ } else { // Z axis
+ fracTrans = item->sliceFractions().z();
+ float range = item->maxBoundsNormal().z() - item->minBoundsNormal().z();
+ // Z axis is logically flipped, so we need to swam min and max bounds
+ float minMult = (1.0f - item->maxBoundsNormal().z()) / range;
+ float maxMult = item->minBoundsNormal().z() / range;
+ fracTrans = fracTrans - ((1.0f - fracTrans) * minMult) + ((1.0f + fracTrans) * maxMult);
+ if (needRotate)
+ translation -= rotationMatrix.map(QVector3D(0.0f, 0.0f, fracTrans * item->scaling().z()));
+ else
+ translation.setZ(translation.z() - fracTrans * item->scaling().z());
+ frameScaling = QVector3D(item->scaling().x()
+ + (item->scaling().x() * item->sliceFrameGaps().x())
+ + (item->scaling().x() * item->sliceFrameWidths().x()),
+ item->scaling().y()
+ + (item->scaling().y() * item->sliceFrameGaps().y())
+ + (item->scaling().y() * item->sliceFrameWidths().y()),
+ item->scaling().z() * item->sliceFrameThicknesses().z());
+ frameWidth = QVector2D(item->scaling().x() * item->sliceFrameWidths().x(),
+ item->scaling().y() * item->sliceFrameWidths().y());
+ }
+
+ // If the slice is outside the shown area, don't show the frame
+ if (fracTrans < -1.0 || fracTrans > 1.0)
+ return;
+
+ // Shader needs the width of clear space in the middle.
+ frameWidth.setX(1.0f - (frameWidth.x() / frameScaling.x()));
+ frameWidth.setY(1.0f - (frameWidth.y() / frameScaling.y()));
- modelMatrix.translate(item->translation());
- modelMatrix.rotate(rotation);
- modelMatrix.scale(item->scaling());
- itModelMatrix.rotate(rotation);
- if (!item->isFacingCamera())
- itModelMatrix.scale(item->scaling());
- MVPMatrix = projectionViewMatrix * modelMatrix;
+ QMatrix4x4 modelMatrix;
+ QMatrix4x4 mvpMatrix;
+
+ modelMatrix.translate(translation);
+ modelMatrix.rotate(rotation);
+ modelMatrix.scale(frameScaling);
+ mvpMatrix = projectionViewMatrix * modelMatrix;
+ m_volumeSliceFrameShader->setUniformValue(m_volumeSliceFrameShader->MVP(), mvpMatrix);
+ m_volumeSliceFrameShader->setUniformValue(m_volumeSliceFrameShader->sliceFrameWidth(),
+ frameWidth);
+
+ m_drawer->drawObject(m_volumeSliceFrameShader, item->mesh());
+
+}
+
+void Abstract3DRenderer::queriedGraphPosition(const QMatrix4x4 &projectionViewMatrix,
+ const QVector3D &scaling,
+ GLuint defaultFboHandle)
+{
+ m_cursorPositionShader->bind();
+
+ // Set up mapper framebuffer
+ glBindFramebuffer(GL_FRAMEBUFFER, m_cursorPositionFrameBuffer);
+ glViewport(0, 0,
+ m_primarySubViewport.width(),
+ m_primarySubViewport.height());
+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDisable(GL_DITHER); // Dither may affect colors if enabled
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_FRONT);
+
+ // Draw a cube scaled to the graph dimensions
+ QMatrix4x4 modelMatrix;
+ QMatrix4x4 MVPMatrix;
+
+ modelMatrix.scale(scaling);
+
+ MVPMatrix = projectionViewMatrix * modelMatrix;
+ m_cursorPositionShader->setUniformValue(m_cursorPositionShader->MVP(), MVPMatrix);
+ m_drawer->drawObject(m_cursorPositionShader, m_positionMapperObj);
+
+ QVector4D dataColor = Utils::getSelection(m_graphPositionQuery,
+ m_primarySubViewport.height());
+ if (dataColor.w() > 0.0f) {
+ // If position is outside the graph, set the position well outside the graph boundaries
+ dataColor = QVector4D(-10000.0f, -10000.0f, -10000.0f, 0.0f);
+ } else {
+ // Normalize to range [0.0, 1.0]
+ dataColor /= 255.0f;
+ }
+
+ // Restore state
+ glEnable(GL_DITHER);
+ glCullFace(GL_BACK);
+ glBindFramebuffer(GL_FRAMEBUFFER, defaultFboHandle);
+ glViewport(m_primarySubViewport.x(),
+ m_primarySubViewport.y(),
+ m_primarySubViewport.width(),
+ m_primarySubViewport.height());
+
+ QVector3D normalizedValues = dataColor.toVector3D() * 2.0f;
+ normalizedValues -= oneVector;
+ m_queriedGraphPosition = QVector3D(normalizedValues.x(),
+ normalizedValues.y(),
+ normalizedValues.z());
+ m_graphPositionQueryResolved = true;
+ m_graphPositionQueryPending = false;
+}
+
+void Abstract3DRenderer::fixContextBeforeDelete()
+{
+ // Only need to fix context if the current context is null.
+ // Otherwise we expect it to be our shared context, so we can use it for cleanup.
+ if (!QOpenGLContext::currentContext() && !m_context.isNull()
+ && QThread::currentThread() == this->thread()) {
+ m_dummySurfaceAtDelete = new QWindow();
+ m_dummySurfaceAtDelete->setSurfaceType(QWindow::OpenGLSurface);
+ m_dummySurfaceAtDelete->setFormat(m_context->format());
+ m_dummySurfaceAtDelete->create();
+
+ m_context->makeCurrent(m_dummySurfaceAtDelete);
+ }
+}
+
+void Abstract3DRenderer::restoreContextAfterDelete()
+{
+ if (m_dummySurfaceAtDelete)
+ m_context->doneCurrent();
+
+ delete m_dummySurfaceAtDelete;
+ m_dummySurfaceAtDelete = 0;
+}
+
+void Abstract3DRenderer::calculatePolarXZ(const QVector3D &dataPos, float &x, float &z) const
+{
+ // x is angular, z is radial
+ qreal angle = m_axisCacheX.formatter()->positionAt(dataPos.x()) * doublePi;
+ qreal radius = m_axisCacheZ.formatter()->positionAt(dataPos.z());
+
+ // Convert angle & radius to X and Z coords
+ x = float(radius * qSin(angle)) * m_polarRadius;
+ z = -float(radius * qCos(angle)) * m_polarRadius;
+}
+
+void Abstract3DRenderer::drawRadialGrid(ShaderHelper *shader, float yFloorLinePos,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &depthMatrix)
+{
+ static QVector<QQuaternion> lineRotations;
+ if (!lineRotations.size()) {
+ lineRotations.resize(polarGridRoundness);
+ for (int j = 0; j < polarGridRoundness; j++) {
+ lineRotations[j] = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f,
+ polarGridAngleDegrees * float(j));
+ }
+ }
+ int gridLineCount = m_axisCacheZ.gridLineCount();
+ const QVector<float> &gridPositions = m_axisCacheZ.formatter()->gridPositions();
+ const QVector<float> &subGridPositions = m_axisCacheZ.formatter()->subGridPositions();
+ int mainSize = gridPositions.size();
+ QVector3D translateVector(0.0f, yFloorLinePos, 0.0f);
+ QQuaternion finalRotation = m_xRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ finalRotation *= m_xFlipRotation;
+
+ for (int i = 0; i < gridLineCount; i++) {
+ float gridPosition = (i >= mainSize)
+ ? subGridPositions.at(i - mainSize) : gridPositions.at(i);
+ float radiusFraction = m_polarRadius * gridPosition;
+ QVector3D gridLineScaler(radiusFraction * float(qSin(polarGridHalfAngle)),
+ gridLineWidth, gridLineWidth);
+ translateVector.setZ(gridPosition * m_polarRadius);
+ for (int j = 0; j < polarGridRoundness; j++) {
+ QMatrix4x4 modelMatrix;
+ QMatrix4x4 itModelMatrix;
+ modelMatrix.rotate(lineRotations.at(j));
+ itModelMatrix.rotate(lineRotations.at(j));
+ modelMatrix.translate(translateVector);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
+ modelMatrix.rotate(finalRotation);
+ itModelMatrix.rotate(finalRotation);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
- if (RenderingNormal == state) {
- // Normal render
shader->setUniformValue(shader->model(), modelMatrix);
- shader->setUniformValue(shader->MVP(), MVPMatrix);
shader->setUniformValue(shader->nModel(), itModelMatrix.inverted().transposed());
-
- if (item->isBlendNeeded()) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_CULL_FACE);
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
+ if (!m_isOpenGLES) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthMatrix * modelMatrix;
+ shader->setUniformValue(shader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(shader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(shader, m_gridLineObj);
+ }
} else {
- glDisable(GL_BLEND);
- glEnable(GL_CULL_FACE);
+ m_drawer->drawLine(shader);
}
+ }
+ }
+}
-#if !defined(QT_OPENGL_ES_2)
+void Abstract3DRenderer::drawAngularGrid(ShaderHelper *shader, float yFloorLinePos,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &depthMatrix)
+{
+ float halfRatio((m_polarRadius + (labelMargin / 2.0f)) / 2.0f);
+ QVector3D gridLineScaler(gridLineWidth, gridLineWidth, halfRatio);
+ int gridLineCount = m_axisCacheX.gridLineCount();
+ const QVector<float> &gridPositions = m_axisCacheX.formatter()->gridPositions();
+ const QVector<float> &subGridPositions = m_axisCacheX.formatter()->subGridPositions();
+ int mainSize = gridPositions.size();
+ QVector3D translateVector(0.0f, yFloorLinePos, -halfRatio);
+ QQuaternion finalRotation;
+ if (m_isOpenGLES)
+ finalRotation = m_yRightAngleRotationNeg;
+ else
+ finalRotation = m_xRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ finalRotation *= m_xFlipRotation;
+ for (int i = 0; i < gridLineCount; i++) {
+ QMatrix4x4 modelMatrix;
+ QMatrix4x4 itModelMatrix;
+ float gridPosition = (i >= mainSize)
+ ? subGridPositions.at(i - mainSize) : gridPositions.at(i);
+ QQuaternion lineRotation = QQuaternion::fromAxisAndAngle(upVector, gridPosition * 360.0f);
+ modelMatrix.rotate(lineRotation);
+ itModelMatrix.rotate(lineRotation);
+ modelMatrix.translate(translateVector);
+ modelMatrix.scale(gridLineScaler);
+ itModelMatrix.scale(gridLineScaler);
+ modelMatrix.rotate(finalRotation);
+ itModelMatrix.rotate(finalRotation);
+ QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
+
+ shader->setUniformValue(shader->model(), modelMatrix);
+ shader->setUniformValue(shader->nModel(), itModelMatrix.inverted().transposed());
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
+ if (m_isOpenGLES) {
+ m_drawer->drawLine(shader);
+ } else {
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
// Set shadow shader bindings
- shader->setUniformValue(shader->shadowQ(), shadowQuality);
- shader->setUniformValue(shader->depth(), depthProjectionViewMatrix * modelMatrix);
- shader->setUniformValue(shader->lightS(), m_cachedTheme->lightStrength() / 10.0f);
- m_drawer->drawObject(shader, item->mesh(), item->texture(), depthTexture);
- } else
-#else
- Q_UNUSED(depthTexture)
- Q_UNUSED(shadowQuality)
-#endif
- {
- // Set shadowless shader bindings
- shader->setUniformValue(shader->lightS(), m_cachedTheme->lightStrength());
- m_drawer->drawObject(shader, item->mesh(), item->texture());
+ QMatrix4x4 depthMVPMatrix = depthMatrix * modelMatrix;
+ shader->setUniformValue(shader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(shader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(shader, m_gridLineObj);
}
- } else if (RenderingSelection == state) {
- // Selection render
- shader->setUniformValue(shader->MVP(), MVPMatrix);
- QVector4D itemColor = indexToSelectionColor(item->index());
- itemColor.setW(customItemAlpha);
- itemColor /= 255.0f;
- shader->setUniformValue(shader->color(), itemColor);
- m_drawer->drawObject(shader, item->mesh());
- } else if (item->isShadowCasting()) {
- // Depth render
- shader->setUniformValue(shader->MVP(), depthProjectionViewMatrix * modelMatrix);
- m_drawer->drawObject(shader, item->mesh());
}
}
+}
- if (RenderingNormal == state) {
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- glEnable(GL_CULL_FACE);
+float Abstract3DRenderer::calculatePolarBackgroundMargin()
+{
+ // Check each extents of each angular label
+ // Calculate angular position
+ QVector<float> &labelPositions = m_axisCacheX.formatter()->labelPositions();
+ float actualLabelHeight = m_drawer->scaledFontSize() * 2.0f; // All labels are same height
+ float maxNeededMargin = 0.0f;
+
+ // Axis title needs to be accounted for
+ if (m_axisCacheX.isTitleVisible())
+ maxNeededMargin = 2.0f * actualLabelHeight + 3.0f * labelMargin;
+
+ for (int label = 0; label < labelPositions.size(); label++) {
+ QSize labelSize = m_axisCacheX.labelItems().at(label)->size();
+ float actualLabelWidth = actualLabelHeight / labelSize.height() * labelSize.width();
+ float labelPosition = labelPositions.at(label);
+ qreal angle = labelPosition * M_PI * 2.0;
+ float x = qAbs((m_polarRadius + labelMargin) * float(qSin(angle)))
+ + actualLabelWidth - m_polarRadius + labelMargin;
+ float z = qAbs(-(m_polarRadius + labelMargin) * float(qCos(angle)))
+ + actualLabelHeight - m_polarRadius + labelMargin;
+ float neededMargin = qMax(x, z);
+ maxNeededMargin = qMax(maxNeededMargin, neededMargin);
}
+
+ return maxNeededMargin;
+}
+
+void Abstract3DRenderer::updateCameraViewport()
+{
+ QVector3D adjustedTarget = m_cachedScene->activeCamera()->target();
+ fixCameraTarget(adjustedTarget);
+ if (m_oldCameraTarget != adjustedTarget) {
+ QVector3D cameraBase = cameraDistanceVector + adjustedTarget;
+
+ m_cachedScene->activeCamera()->d_ptr->setBaseOrientation(cameraBase,
+ adjustedTarget,
+ upVector);
+ m_oldCameraTarget = adjustedTarget;
+ }
+ m_cachedScene->activeCamera()->d_ptr->updateViewMatrix(m_autoScaleAdjustment);
+ // Set light position (i.e rotate light with activeCamera, a bit above it)
+ m_cachedScene->d_ptr->setLightPositionRelativeToCamera(defaultLightPos);
}
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h
index 0dfc7367..1e38023d 100644
--- a/src/datavisualization/engine/abstract3drenderer_p.h
+++ b/src/datavisualization/engine/abstract3drenderer_p.h
@@ -30,13 +30,17 @@
#define ABSTRACT3DRENDERER_P_H
#include <QtGui/QOpenGLFunctions>
-
+#if !defined(QT_OPENGL_ES_2)
+# include <QtGui/QOpenGLFunctions_2_1>
+#endif
#include "datavisualizationglobal_p.h"
#include "abstract3dcontroller_p.h"
#include "axisrendercache_p.h"
#include "seriesrendercache_p.h"
#include "customrenderitem_p.h"
+class QSurface;
+
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
class TextureHelper;
@@ -77,21 +81,33 @@ public:
virtual void updateSelectionMode(QAbstract3DGraph::SelectionFlags newMode);
virtual void updateOptimizationHint(QAbstract3DGraph::OptimizationHints hint);
virtual void updateScene(Q3DScene *scene);
- virtual void updateTextures() = 0;
+ virtual void updateTextures();
virtual void initSelectionBuffer() = 0;
virtual void updateSelectionState(SelectionState state);
- virtual void updateInputPosition(const QPoint &position);
-#if !defined(QT_OPENGL_ES_2)
virtual void updateDepthBuffer() = 0;
-#endif
virtual void updateShadowQuality(QAbstract3DGraph::ShadowQuality quality) = 0;
virtual void initShaders(const QString &vertexShader, const QString &fragmentShader) = 0;
virtual void initGradientShaders(const QString &vertexShader, const QString &fragmentShader);
+ virtual void initStaticSelectedItemShaders(const QString &vertexShader,
+ const QString &fragmentShader,
+ const QString &gradientVertexShader,
+ const QString &gradientFragmentShader);
virtual void initBackgroundShaders(const QString &vertexShader,
const QString &fragmentShader) = 0;
virtual void initCustomItemShaders(const QString &vertexShader,
const QString &fragmentShader);
+ virtual void initVolumeTextureShaders(const QString &vertexShader,
+ const QString &fragmentShader,
+ const QString &fragmentLowDefShader,
+ const QString &sliceShader,
+ const QString &sliceFrameVertexShader,
+ const QString &sliceFrameShader);
+ virtual void initLabelShaders(const QString &vertexShader, const QString &fragmentShader);
+ virtual void initCursorPositionShaders(const QString &vertexShader,
+ const QString &fragmentShader);
+ virtual void initCursorPositionBuffer();
+
virtual void updateAxisType(QAbstract3DAxis::AxisOrientation orientation,
QAbstract3DAxis::AxisType type);
virtual void updateAxisTitle(QAbstract3DAxis::AxisOrientation orientation,
@@ -112,7 +128,7 @@ public:
virtual void updateAxisLabelAutoRotation(QAbstract3DAxis::AxisOrientation orientation,
float angle);
virtual void updateAxisTitleVisibility(QAbstract3DAxis::AxisOrientation orientation,
- bool visible);
+ bool visible);
virtual void updateAxisTitleFixed(QAbstract3DAxis::AxisOrientation orientation,
bool fixed);
virtual void modifiedSeriesList(const QVector<QAbstract3DSeries *> &seriesList);
@@ -123,6 +139,10 @@ public:
virtual void updateCustomItem(CustomRenderItem *renderItem);
virtual void updateAspectRatio(float ratio);
+ virtual void updateHorizontalAspectRatio(float ratio);
+ virtual void updatePolar(bool enable);
+ virtual void updateRadialLabelOffset(float offset);
+ virtual void updateMargin(float margin);
virtual QVector3D convertPositionToTranslation(const QVector3D &position,
bool isAbsolute) = 0;
@@ -130,21 +150,28 @@ public:
void generateBaseColorTexture(const QColor &color, GLuint *texture);
void fixGradientAndGenerateTexture(QLinearGradient *gradient, GLuint *gradientTexture);
- inline bool isClickPending() { return m_clickPending; }
- inline void clearClickPending() { m_clickPending = false; }
+ inline bool isClickQueryResolved() const { return m_clickResolved; }
+ inline void clearClickQueryResolved() { m_clickResolved = false; }
+ inline QPoint cachedClickQuery() const { return m_cachedScene->selectionQueryPosition(); }
inline QAbstract3DSeries *clickedSeries() const { return m_clickedSeries; }
inline QAbstract3DGraph::ElementType clickedType() { return m_clickedType; }
+ inline bool isGraphPositionQueryResolved() const { return m_graphPositionQueryResolved; }
+ inline void clearGraphPositionQueryResolved() { m_graphPositionQueryResolved = false; }
+ inline QVector3D queriedGraphPosition() const { return m_queriedGraphPosition; }
+ inline QPoint cachedGraphPositionQuery() const { return m_cachedScene->graphPositionQuery(); }
LabelItem &selectionLabelItem();
void setSelectionLabel(const QString &label);
QString &selectionLabel();
- void drawCustomItems(RenderingState state, ShaderHelper *shader,
+ void drawCustomItems(RenderingState state, ShaderHelper *regularShader,
const QMatrix4x4 &viewMatrix,
const QMatrix4x4 &projectionViewMatrix,
const QMatrix4x4 &depthProjectionViewMatrix,
- GLuint depthTexture, GLfloat shadowQuality);
+ GLuint depthTexture, GLfloat shadowQuality, GLfloat reflection = 1.0f);
+
QVector4D indexToSelectionColor(GLint index);
+ void calculatePolarXZ(const QVector3D &dataPos, float &x, float &z) const;
signals:
void needRender(); // Emit this if something in renderer causes need for another render pass.
@@ -177,7 +204,7 @@ protected:
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader);
+ ShaderHelper *shader, bool radial = false);
void drawAxisTitleZ(const QVector3D &labelRotation, const QVector3D &labelTrans,
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
@@ -186,6 +213,26 @@ protected:
void loadGridLineMesh();
void loadLabelMesh();
+ void loadPositionMapperMesh();
+
+ void drawRadialGrid(ShaderHelper *shader, float yFloorLinePos,
+ const QMatrix4x4 &projectionViewMatrix, const QMatrix4x4 &depthMatrix);
+ void drawAngularGrid(ShaderHelper *shader, float yFloorLinePos,
+ const QMatrix4x4 &projectionViewMatrix, const QMatrix4x4 &depthMatrix);
+
+ float calculatePolarBackgroundMargin();
+ virtual void fixCameraTarget(QVector3D &target) = 0;
+ void updateCameraViewport();
+
+ void recalculateCustomItemScalingAndPos(CustomRenderItem *item);
+ virtual void getVisibleItemBounds(QVector3D &minBounds, QVector3D &maxBounds) = 0;
+ void drawVolumeSliceFrame(const CustomRenderItem *item, Qt::Axis axis,
+ const QMatrix4x4 &projectionViewMatrix);
+ void queriedGraphPosition(const QMatrix4x4 &projectionViewMatrix, const QVector3D &scaling,
+ GLuint defaultFboHandle);
+
+ void fixContextBeforeDelete();
+ void restoreContextAfterDelete();
bool m_hasNegativeValues;
Q3DTheme *m_cachedTheme;
@@ -201,6 +248,7 @@ protected:
AxisRenderCache m_axisCacheY;
AxisRenderCache m_axisCacheZ;
TextureHelper *m_textureHelper;
+ GLuint m_depthTexture;
Q3DScene *m_cachedScene;
bool m_selectionDirty;
@@ -212,28 +260,75 @@ protected:
QRect m_secondarySubViewport;
float m_devicePixelRatio;
bool m_selectionLabelDirty;
- bool m_clickPending;
+ bool m_clickResolved;
+ bool m_graphPositionQueryPending;
+ bool m_graphPositionQueryResolved;
QAbstract3DSeries *m_clickedSeries;
QAbstract3DGraph::ElementType m_clickedType;
int m_selectedLabelIndex;
int m_selectedCustomItemIndex;
+ QVector3D m_queriedGraphPosition;
+ QPoint m_graphPositionQuery;
QString m_selectionLabel;
LabelItem *m_selectionLabelItem;
int m_visibleSeriesCount;
ShaderHelper *m_customItemShader;
+ ShaderHelper *m_volumeTextureShader;
+ ShaderHelper *m_volumeTextureLowDefShader;
+ ShaderHelper *m_volumeTextureSliceShader;
+ ShaderHelper *m_volumeSliceFrameShader;
+ ShaderHelper *m_labelShader;
+ ShaderHelper *m_cursorPositionShader;
+ GLuint m_cursorPositionFrameBuffer;
+ GLuint m_cursorPositionTexture;
bool m_useOrthoProjection;
bool m_xFlipped;
bool m_yFlipped;
bool m_zFlipped;
+ bool m_yFlippedForGrid;
ObjectHelper *m_backgroundObj; // Shared reference
ObjectHelper *m_gridLineObj; // Shared reference
ObjectHelper *m_labelObj; // Shared reference
+ ObjectHelper *m_positionMapperObj; // Shared reference
float m_graphAspectRatio;
+ float m_graphHorizontalAspectRatio;
+ bool m_polarGraph;
+ float m_radialLabelOffset;
+ float m_polarRadius;
+
+ QQuaternion m_xRightAngleRotation;
+ QQuaternion m_yRightAngleRotation;
+ QQuaternion m_zRightAngleRotation;
+ QQuaternion m_xRightAngleRotationNeg;
+ QQuaternion m_yRightAngleRotationNeg;
+ QQuaternion m_zRightAngleRotationNeg;
+ QQuaternion m_xFlipRotation;
+ QQuaternion m_zFlipRotation;
+
+ float m_requestedMargin;
+ float m_vBackgroundMargin;
+ float m_hBackgroundMargin;
+ float m_scaleXWithBackground;
+ float m_scaleYWithBackground;
+ float m_scaleZWithBackground;
+
+ QVector3D m_oldCameraTarget;
+
+ bool m_reflectionEnabled;
+ qreal m_reflectivity;
+
+ QLocale m_locale;
+#if !defined(QT_OPENGL_ES_2)
+ QOpenGLFunctions_2_1 *m_funcs_2_1; // Not owned
+#endif
+ QPointer<QOpenGLContext> m_context; // Not owned
+ QWindow *m_dummySurfaceAtDelete;
+ bool m_isOpenGLES;
private:
friend class Abstract3DController;
diff --git a/src/datavisualization/engine/axisrendercache.cpp b/src/datavisualization/engine/axisrendercache.cpp
index 0b7a5c7a..02e3b7f6 100644
--- a/src/datavisualization/engine/axisrendercache.cpp
+++ b/src/datavisualization/engine/axisrendercache.cpp
@@ -46,6 +46,7 @@ AxisRenderCache::~AxisRenderCache()
{
foreach (LabelItem *label, m_labelItems)
delete label;
+ m_titleItem.clear();
delete m_formatter;
}
@@ -54,10 +55,8 @@ void AxisRenderCache::setDrawer(Drawer *drawer)
{
m_drawer = drawer;
m_font = m_drawer->font();
- if (m_drawer) {
- QObject::connect(m_drawer, &Drawer::drawerChanged, this, &AxisRenderCache::updateTextures);
+ if (m_drawer)
updateTextures();
- }
}
void AxisRenderCache::setType(QAbstract3DAxis::AxisType type)
@@ -106,10 +105,12 @@ void AxisRenderCache::setLabels(const QStringList &labels)
if (i >= oldSize)
m_labelItems.append(new LabelItem);
if (m_drawer) {
- if (labels.at(i).isEmpty())
+ if (labels.at(i).isEmpty()) {
m_labelItems[i]->clear();
- else if (i >= oldSize || labels.at(i) != m_labels.at(i))
+ } else if (i >= oldSize || labels.at(i) != m_labels.at(i)
+ || m_labelItems[i]->size().width() != widest) {
m_drawer->generateLabelItem(*m_labelItems[i], labels.at(i), widest);
+ }
}
}
m_labels = labels;
@@ -175,6 +176,13 @@ void AxisRenderCache::updateTextures()
}
}
+void AxisRenderCache::clearLabels()
+{
+ m_titleItem.clear();
+ for (int i = 0; i < m_labels.size(); i++)
+ m_labelItems[i]->clear();
+}
+
int AxisRenderCache::maxLabelWidth(const QStringList &labels) const
{
int labelWidth = 0;
diff --git a/src/datavisualization/engine/axisrendercache_p.h b/src/datavisualization/engine/axisrendercache_p.h
index 90321740..e32c590e 100644
--- a/src/datavisualization/engine/axisrendercache_p.h
+++ b/src/datavisualization/engine/axisrendercache_p.h
@@ -107,8 +107,8 @@ public:
inline bool isTitleFixed() const { return m_titleFixed; }
inline void setTitleFixed(bool fixed) { m_titleFixed = fixed; }
-public slots:
void updateTextures();
+ void clearLabels();
private:
int maxLabelWidth(const QStringList &labels) const;
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index 3a240c24..2092dd60 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.cpp
@@ -36,6 +36,7 @@ Bars3DController::Bars3DController(QRect boundRect, Q3DScene *scene)
m_isBarSpecRelative(true),
m_barThicknessRatio(1.0f),
m_barSpacing(QSizeF(1.0, 1.0)),
+ m_floorLevel(0.0f),
m_renderer(0)
{
// Setting a null axis creates a new default axis according to orientation and graph type.
@@ -83,6 +84,12 @@ void Bars3DController::synchDataToRenderer()
needSceneUpdate = true;
}
+ // Floor level update requires data update, so do before abstract sync
+ if (m_changeTracker.floorLevelChanged) {
+ m_renderer->updateFloorLevel(m_floorLevel);
+ m_changeTracker.floorLevelChanged = false;
+ }
+
Abstract3DController::synchDataToRenderer();
// Notify changes to renderer
@@ -114,12 +121,10 @@ void Bars3DController::synchDataToRenderer()
m_changeTracker.selectedBarChanged = false;
}
- if (needSceneUpdate) {
- // Since scene is updated before axis updates are handled,
- // do another render pass for scene update
- m_scene->d_ptr->m_sceneDirty = true;
- emitNeedRender();
- }
+ // Since scene is updated before axis updates are handled, do another render pass to
+ // properly update controller side camera limits.
+ if (needSceneUpdate)
+ m_scene->d_ptr->markDirty();
}
void Bars3DController::handleArrayReset()
@@ -487,6 +492,19 @@ bool Bars3DController::isBarSpecRelative()
return m_isBarSpecRelative;
}
+void Bars3DController::setFloorLevel(float level)
+{
+ m_floorLevel = level;
+ m_isDataDirty = true;
+ m_changeTracker.floorLevelChanged = true;
+ emitNeedRender();
+}
+
+float Bars3DController::floorLevel() const
+{
+ return m_floorLevel;
+}
+
void Bars3DController::setSelectionMode(QAbstract3DGraph::SelectionFlags mode)
{
if (mode.testFlag(QAbstract3DGraph::SelectionSlice)
diff --git a/src/datavisualization/engine/bars3dcontroller_p.h b/src/datavisualization/engine/bars3dcontroller_p.h
index 4f0e1f20..ac62f37d 100644
--- a/src/datavisualization/engine/bars3dcontroller_p.h
+++ b/src/datavisualization/engine/bars3dcontroller_p.h
@@ -43,13 +43,15 @@ struct Bars3DChangeBitField {
bool selectedBarChanged : 1;
bool rowsChanged : 1;
bool itemChanged : 1;
+ bool floorLevelChanged : 1;
Bars3DChangeBitField() :
multiSeriesScalingChanged(true),
barSpecsChanged(true),
selectedBarChanged(true),
rowsChanged(false),
- itemChanged(false)
+ itemChanged(false),
+ floorLevelChanged(false)
{
}
};
@@ -84,6 +86,7 @@ private:
bool m_isBarSpecRelative;
GLfloat m_barThicknessRatio;
QSizeF m_barSpacing;
+ float m_floorLevel;
// Rendering
Bars3DRenderer *m_renderer;
@@ -107,6 +110,8 @@ public:
GLfloat barThickness();
QSizeF barSpacing();
bool isBarSpecRelative();
+ void setFloorLevel(float level);
+ float floorLevel() const;
inline QBar3DSeries *selectedSeries() const { return m_selectedBarSeries; }
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 689f3f5d..b6a191a9 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -31,7 +31,6 @@
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
-const GLfloat gridLineWidth = 0.005f;
const bool sliceGridLabels = true;
Bars3DRenderer::Bars3DRenderer(Bars3DController *controller)
@@ -48,9 +47,7 @@ Bars3DRenderer::Bars3DRenderer(Bars3DController *controller)
m_depthShader(0),
m_selectionShader(0),
m_backgroundShader(0),
- m_labelShader(0),
m_bgrTexture(0),
- m_depthTexture(0),
m_selectionTexture(0),
m_depthFrameBuffer(0),
m_selectionFrameBuffer(0),
@@ -67,7 +64,6 @@ Bars3DRenderer::Bars3DRenderer(Bars3DController *controller)
m_scaleFactor(0),
m_maxSceneSize(40.0f),
m_visualSelectedBarPos(Bars3DController::invalidSelectionPosition()),
- m_resetCameraBaseOrientation(true),
m_selectedBarPos(Bars3DController::invalidSelectionPosition()),
m_selectedSeriesCache(0),
m_noZeroInRange(false),
@@ -79,17 +75,22 @@ Bars3DRenderer::Bars3DRenderer(Bars3DController *controller)
m_keepSeriesUniform(false),
m_haveUniformColorSeries(false),
m_haveGradientSeries(false),
- m_zeroPosition(0.0f)
+ m_zeroPosition(0.0f),
+ m_xScaleFactor(1.0f),
+ m_zScaleFactor(1.0f),
+ m_floorLevel(0.0f),
+ m_actualFloorLevel(0.0f)
{
m_axisCacheY.setScale(2.0f);
m_axisCacheY.setTranslate(-1.0f);
- initializeOpenGLFunctions();
initializeOpenGL();
}
Bars3DRenderer::~Bars3DRenderer()
{
+ fixContextBeforeDelete();
+
if (QOpenGLContext::currentContext()) {
m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer);
m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer);
@@ -103,7 +104,6 @@ Bars3DRenderer::~Bars3DRenderer()
delete m_depthShader;
delete m_selectionShader;
delete m_backgroundShader;
- delete m_labelShader;
}
void Bars3DRenderer::initializeOpenGL()
@@ -111,13 +111,9 @@ void Bars3DRenderer::initializeOpenGL()
Abstract3DRenderer::initializeOpenGL();
// Initialize shaders
- initLabelShaders(QStringLiteral(":/shaders/vertexLabel"),
- QStringLiteral(":/shaders/fragmentLabel"));
-#if !defined(QT_OPENGL_ES_2)
// Init depth shader (for shadows). Init in any case, easier to handle shadow activation if done via api.
initDepthShader();
-#endif
// Init selection shader
initSelectionShader();
@@ -125,13 +121,57 @@ void Bars3DRenderer::initializeOpenGL()
// Load grid line mesh
loadGridLineMesh();
- // Load label mesh
- loadLabelMesh();
-
// Load background mesh (we need to be initialized first)
loadBackgroundMesh();
}
+void Bars3DRenderer::fixCameraTarget(QVector3D &target)
+{
+ target.setX(target.x() * m_xScaleFactor);
+ target.setY(0.0f);
+ target.setZ(target.z() * -m_zScaleFactor);
+}
+
+void Bars3DRenderer::getVisibleItemBounds(QVector3D &minBounds, QVector3D &maxBounds)
+{
+ // The inputs are the item bounds in OpenGL coordinates.
+ // The outputs limit these bounds to visible ranges, normalized to range [-1, 1]
+ // Volume shader flips the Y and Z axes, so we need to set negatives of actual values to those
+ float itemRangeX = (maxBounds.x() - minBounds.x());
+ float itemRangeY = (maxBounds.y() - minBounds.y());
+ float itemRangeZ = (maxBounds.z() - minBounds.z());
+
+ if (minBounds.x() < -m_xScaleFactor)
+ minBounds.setX(-1.0f + (2.0f * qAbs(minBounds.x() + m_xScaleFactor) / itemRangeX));
+ else
+ minBounds.setX(-1.0f);
+
+ if (minBounds.y() < -1.0f + m_backgroundAdjustment)
+ minBounds.setY(-(-1.0f + (2.0f * qAbs(minBounds.y() + 1.0f - m_backgroundAdjustment) / itemRangeY)));
+ else
+ minBounds.setY(1.0f);
+
+ if (minBounds.z() < -m_zScaleFactor)
+ minBounds.setZ(-(-1.0f + (2.0f * qAbs(minBounds.z() + m_zScaleFactor) / itemRangeZ)));
+ else
+ minBounds.setZ(1.0f);
+
+ if (maxBounds.x() > m_xScaleFactor)
+ maxBounds.setX(1.0f - (2.0f * qAbs(maxBounds.x() - m_xScaleFactor) / itemRangeX));
+ else
+ maxBounds.setX(1.0f);
+
+ if (maxBounds.y() > 1.0f + m_backgroundAdjustment)
+ maxBounds.setY(-(1.0f - (2.0f * qAbs(maxBounds.y() - 1.0f - m_backgroundAdjustment) / itemRangeY)));
+ else
+ maxBounds.setY(-1.0f);
+
+ if (maxBounds.z() > m_zScaleFactor)
+ maxBounds.setZ(-(1.0f - (2.0f * qAbs(maxBounds.z() - m_zScaleFactor) / itemRangeZ)));
+ else
+ maxBounds.setZ(-1.0f);
+}
+
void Bars3DRenderer::updateData()
{
int minRow = m_axisCacheZ.min();
@@ -163,11 +203,11 @@ void Bars3DRenderer::updateData()
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();
}
- m_zeroPosition = m_axisCacheY.formatter()->positionAt(0.0f);
+ calculateSceneScalingFactors();
+
+ m_zeroPosition = m_axisCacheY.formatter()->positionAt(m_actualFloorLevel);
foreach (SeriesRenderCache *baseCache, m_renderCacheList) {
BarSeriesRenderCache *cache = static_cast<BarSeriesRenderCache *>(baseCache);
@@ -390,14 +430,6 @@ void Bars3DRenderer::updateScene(Q3DScene *scene)
}
}
- if (m_resetCameraBaseOrientation) {
- // Set initial camera position. Also update if height adjustment has changed.
- scene->activeCamera()->d_ptr->setBaseOrientation(cameraDistanceVector,
- zeroVector,
- upVector);
- m_resetCameraBaseOrientation = false;
- }
-
Abstract3DRenderer::updateScene(scene);
updateSlicingActive(scene->isSlicingActive());
@@ -418,10 +450,17 @@ void Bars3DRenderer::render(GLuint defaultFboHandle)
void Bars3DRenderer::drawSlicedScene()
{
+ if (m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionRow)
+ == m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionColumn)) {
+ qWarning("Invalid selection mode. Either QAbstract3DGraph::SelectionRow or"
+ " QAbstract3DGraph::SelectionColumn must be set before calling"
+ " setSlicingActive(true).");
+ return;
+ }
+
GLfloat barPosX = 0;
QVector3D lightPos;
QVector4D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
- static QQuaternion ninetyDegreeRotation = QQuaternion::fromAxisAndAngle(upVector, 90.0f);
// Specify viewport
glViewport(m_secondarySubViewport.x(),
@@ -482,11 +521,12 @@ void Bars3DRenderer::drawSlicedScene()
// Draw grid lines
if (m_cachedTheme->isGridEnabled()) {
glDisable(GL_DEPTH_TEST);
-#if !(defined QT_OPENGL_ES_2)
- ShaderHelper *lineShader = m_backgroundShader;
-#else
- ShaderHelper *lineShader = m_selectionShader; // Plain color shader for GL_LINES
-#endif
+ ShaderHelper *lineShader;
+ if (m_isOpenGLES)
+ lineShader = m_selectionShader; // Plain color shader for GL_LINES
+ else
+ lineShader = m_backgroundShader;
+
// Bind line shader
lineShader->bind();
@@ -496,7 +536,8 @@ void Bars3DRenderer::drawSlicedScene()
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(),
- m_cachedTheme->ambientLightStrength() * 2.3f);
+ m_cachedTheme->ambientLightStrength()
+ + m_cachedTheme->lightStrength() / 7.0f);
lineShader->setUniformValue(lineShader->lightS(), 0.0f);
lineShader->setUniformValue(lineShader->lightColor(), lightColor);
@@ -524,11 +565,10 @@ void Bars3DRenderer::drawSlicedScene()
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
// Draw the object
-#if !(defined QT_OPENGL_ES_2)
- m_drawer->drawObject(lineShader, m_gridLineObj);
-#else
- m_drawer->drawLine(lineShader);
-#endif
+ if (m_isOpenGLES)
+ m_drawer->drawLine(lineShader);
+ else
+ m_drawer->drawObject(lineShader, m_gridLineObj);
// Check if we have a line at zero position already
if (gridPos == (barPosYAdjustment + zeroPosAdjustment))
@@ -553,18 +593,16 @@ void Bars3DRenderer::drawSlicedScene()
m_cachedTheme->labelTextColor()));
// Draw the object
-#if !(defined QT_OPENGL_ES_2)
- m_drawer->drawObject(lineShader, m_gridLineObj);
-#else
- m_drawer->drawLine(lineShader);
-#endif
+ if (m_isOpenGLES)
+ m_drawer->drawLine(lineShader);
+ else
+ m_drawer->drawObject(lineShader, m_gridLineObj);
}
}
if (sliceGridLabels) {
// Bind label shader
m_labelShader->bind();
- glEnable(GL_TEXTURE_2D);
glCullFace(GL_BACK);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -587,7 +625,6 @@ void Bars3DRenderer::drawSlicedScene()
}
labelNbr++;
}
- glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
}
@@ -606,14 +643,16 @@ void Bars3DRenderer::drawSlicedScene()
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->lightS(), 0.15f);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_cachedTheme->ambientLightStrength() * 2.3f);
+ m_cachedTheme->ambientLightStrength()
+ + m_cachedTheme->lightStrength() / 7.0f);
m_barShader->setUniformValue(m_barShader->lightColor(), lightColor);
m_barGradientShader->bind();
m_barGradientShader->setUniformValue(m_barGradientShader->lightP(), lightPos);
m_barGradientShader->setUniformValue(m_barGradientShader->view(), viewMatrix);
m_barGradientShader->setUniformValue(m_barGradientShader->lightS(), 0.15f);
m_barGradientShader->setUniformValue(m_barGradientShader->ambientS(),
- m_cachedTheme->ambientLightStrength() * 2.3f);
+ m_cachedTheme->ambientLightStrength()
+ + m_cachedTheme->lightStrength() / 7.0f);
m_barGradientShader->setUniformValue(m_barGradientShader->gradientMin(), 0.0f);
m_barGradientShader->setUniformValue(m_barGradientShader->lightColor(), lightColor);
@@ -700,7 +739,7 @@ void Bars3DRenderer::drawSlicedScene()
barPosX = item.translation().x();
} else {
barPosX = -(item.translation().z()); // flip z; frontmost bar to the left
- barRotation *= ninetyDegreeRotation;
+ barRotation *= m_yRightAngleRotation;
}
modelMatrix.translate(barPosX, barPosY, 0.0f);
@@ -760,7 +799,6 @@ void Bars3DRenderer::drawSlicedScene()
// Draw labels
m_labelShader->bind();
glDisable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D);
glCullFace(GL_BACK);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -778,6 +816,12 @@ void Bars3DRenderer::drawSlicedScene()
int labelCount = m_sliceCache->labelItems().size();
for (int labelNo = 0; labelNo < labelCount; labelNo++) {
+ // Check for invalid usage (no selection when setting slicing active)
+ if (!firstVisualSliceArray) {
+ qWarning("No slice data found. Make sure there is a valid selection.");
+ continue;
+ }
+
// Get labels from first series only
const BarRenderSliceItem &item = firstVisualSliceArray->at(labelNo);
m_dummyBarRenderItem.setTranslation(QVector3D(item.translation().x(),
@@ -889,7 +933,6 @@ void Bars3DRenderer::drawSlicedScene()
m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera,
false, false, Drawer::LabelMid, Qt::AlignBottom);
- glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
@@ -912,8 +955,6 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
GLfloat colPos = 0;
GLfloat rowPos = 0;
- QVector4D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
-
const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
glViewport(m_primarySubViewport.x(),
@@ -990,15 +1031,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QMatrix4x4 projectionViewMatrix = projectionMatrix * viewMatrix;
- bool rowMode = m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionRow);
-
- GLfloat rowScaleFactor = m_rowWidth / m_scaleFactor;
- GLfloat columnScaleFactor = m_columnDepth / m_scaleFactor;
-
BarRenderItem *selectedBar(0);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && !m_isOpenGLES) {
// Render scene into a depth texture for using with shadow mapping
// Enable drawing to depth framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, m_depthFrameBuffer);
@@ -1052,6 +1087,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
shadowOffset = -0.015f;
}
+ if (m_cachedTheme->isBackgroundEnabled() && m_reflectionEnabled
+ && ((m_yFlipped && item.height() > 0.0)
+ || (!m_yFlipped && item.height() < 0.0))) {
+ continue;
+ }
+
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
@@ -1097,8 +1138,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
Abstract3DRenderer::drawCustomItems(RenderingDepth, m_depthShader, viewMatrix,
- projectionViewMatrix, depthProjectionViewMatrix,
- m_depthTexture, m_shadowQualityToShader);
+ projectionViewMatrix,
+ depthProjectionViewMatrix, m_depthTexture,
+ m_shadowQualityToShader);
// Disable drawing to depth framebuffer (= enable drawing to screen)
glBindFramebuffer(GL_FRAMEBUFFER, defaultFboHandle);
@@ -1112,12 +1154,22 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_primarySubViewport.width(),
m_primarySubViewport.height());
}
-#endif
+
+ // Do position mapping when necessary
+ if (m_graphPositionQueryPending) {
+ QVector3D graphDimensions(m_xScaleFactor, 0.0f, m_zScaleFactor);
+ queriedGraphPosition(projectionViewMatrix, graphDimensions, defaultFboHandle);
+
+ // Y is always at floor level
+ m_queriedGraphPosition.setY(0.0f);
+ emit needRender();
+ }
// Skip selection mode drawing if we're slicing or have no selection mode
if (!m_cachedIsSlicingActivated && m_cachedSelectionMode > QAbstract3DGraph::SelectionNone
&& m_selectionState == SelectOnScene
- && (m_visibleSeriesCount > 0 || !m_customRenderCache.isEmpty())) {
+ && (m_visibleSeriesCount > 0 || !m_customRenderCache.isEmpty())
+ && m_selectionTexture) {
// Bind selection shader
m_selectionShader->bind();
@@ -1181,18 +1233,20 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
}
glCullFace(GL_BACK);
- Abstract3DRenderer::drawCustomItems(RenderingSelection, m_selectionShader, viewMatrix,
+ Abstract3DRenderer::drawCustomItems(RenderingSelection, m_selectionShader,
+ viewMatrix,
projectionViewMatrix, depthProjectionViewMatrix,
m_depthTexture, m_shadowQualityToShader);
- drawLabels(true, activeCamera, viewMatrix, projectionMatrix, rowScaleFactor,
- columnScaleFactor);
+ drawLabels(true, activeCamera, viewMatrix, projectionMatrix);
+ drawBackground(backgroundRotation, depthProjectionViewMatrix, projectionViewMatrix,
+ viewMatrix, false, true);
glEnable(GL_DITHER);
// Read color under cursor
- QVector4D clickedColor = Utils::getSelection(m_inputPosition,
- m_viewport.height());
+ QVector4D clickedColor = Utils::getSelection(m_inputPosition, m_viewport.height());
m_clickedPosition = selectionColorToArrayPosition(clickedColor);
m_clickedSeries = selectionColorToSeries(clickedColor);
+ m_clickResolved = true;
emit needRender();
@@ -1204,8 +1258,133 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_primarySubViewport.height());
}
- // Enable texturing
- glEnable(GL_TEXTURE_2D);
+ if (m_reflectionEnabled) {
+ //
+ // Draw reflections
+ //
+ glDisable(GL_DEPTH_TEST);
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ glEnable(GL_STENCIL_TEST);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
+
+ // Draw background stencil
+ drawBackground(backgroundRotation, depthProjectionViewMatrix, projectionViewMatrix,
+ viewMatrix);
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+
+ glStencilFunc(GL_EQUAL, 1, 0xffffffff);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+ // Set light
+ QVector3D reflectionLightPos = lightPos;
+ reflectionLightPos.setY(-(lightPos.y()));
+ m_cachedScene->activeLight()->setPosition(reflectionLightPos);
+
+ // Draw bar reflections
+ (void)drawBars(&selectedBar, depthProjectionViewMatrix,
+ projectionViewMatrix, viewMatrix,
+ startRow, stopRow, stepRow,
+ startBar, stopBar, stepBar, -1.0f);
+
+ Abstract3DRenderer::drawCustomItems(RenderingNormal, m_customItemShader,
+ viewMatrix, projectionViewMatrix,
+ depthProjectionViewMatrix, m_depthTexture,
+ m_shadowQualityToShader, -1.0f);
+
+ // Reset light
+ m_cachedScene->activeLight()->setPosition(lightPos);
+
+ glDisable(GL_STENCIL_TEST);
+
+ glCullFace(GL_BACK);
+ }
+
+ //
+ // Draw the real scene
+ //
+ // Draw background
+ if (m_reflectionEnabled) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ drawBackground(backgroundRotation, depthProjectionViewMatrix, projectionViewMatrix,
+ viewMatrix, true);
+ glDisable(GL_BLEND);
+ } else {
+ drawBackground(backgroundRotation, depthProjectionViewMatrix, projectionViewMatrix,
+ viewMatrix);
+ }
+
+ // Draw bars
+ bool barSelectionFound = drawBars(&selectedBar, depthProjectionViewMatrix,
+ projectionViewMatrix, viewMatrix,
+ startRow, stopRow, stepRow,
+ startBar, stopBar, stepBar);
+
+ // Draw grid lines
+ drawGridLines(depthProjectionViewMatrix, projectionViewMatrix, viewMatrix);
+
+ // Draw custom items
+ Abstract3DRenderer::drawCustomItems(RenderingNormal, m_customItemShader, viewMatrix,
+ projectionViewMatrix, depthProjectionViewMatrix,
+ m_depthTexture, m_shadowQualityToShader);
+
+ // Draw labels
+ drawLabels(false, activeCamera, viewMatrix, projectionMatrix);
+
+ // Handle selected bar label generation
+ if (barSelectionFound) {
+ // Print value of selected bar
+ glDisable(GL_DEPTH_TEST);
+ // Draw the selection label
+ LabelItem &labelItem = selectionLabelItem();
+ if (m_selectedBar != selectedBar || m_updateLabels || !labelItem.textureId()
+ || m_selectionLabelDirty) {
+ QString labelText = selectionLabel();
+ if (labelText.isNull() || m_selectionLabelDirty) {
+ labelText = m_selectedSeriesCache->itemLabel();
+ setSelectionLabel(labelText);
+ m_selectionLabelDirty = false;
+ }
+ m_drawer->generateLabelItem(labelItem, labelText);
+ m_selectedBar = selectedBar;
+ }
+
+ Drawer::LabelPosition position =
+ m_selectedBar->height() >= 0 ? Drawer::LabelOver : Drawer::LabelBelow;
+
+ m_drawer->drawLabel(*selectedBar, labelItem, viewMatrix, projectionMatrix,
+ zeroVector, identityQuaternion, selectedBar->height(),
+ m_cachedSelectionMode, m_labelShader,
+ m_labelObj, activeCamera, true, false, position);
+
+ // Reset label update flag; they should have been updated when we get here
+ m_updateLabels = false;
+
+ glEnable(GL_DEPTH_TEST);
+ } else {
+ m_selectedBar = 0;
+ }
+
+ glDisable(GL_BLEND);
+
+ // Release shader
+ glUseProgram(0);
+ m_selectionDirty = false;
+}
+
+bool Bars3DRenderer::drawBars(BarRenderItem **selectedBar,
+ const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix, const QMatrix4x4 &viewMatrix,
+ GLint startRow, GLint stopRow, GLint stepRow,
+ GLint startBar, GLint stopBar, GLint stepBar, GLfloat reflection)
+{
+ QVector3D lightPos = m_cachedScene->activeLight()->position();
+ QVector4D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
+ bool rowMode = m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionRow);
ShaderHelper *barShader = 0;
GLuint gradientTexture = 0;
@@ -1251,7 +1430,6 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_sliceTitleItem = 0;
}
- // Draw bars
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5f, 1.0f);
@@ -1302,12 +1480,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
previousColorStyle = colorStyle;
-
for (int row = startRow; row != stopRow; row += stepRow) {
BarRenderItemRow &renderRow = renderArray[row];
for (int bar = startBar; bar != stopBar; bar += stepBar) {
BarRenderItem &item = renderRow[bar];
- if (item.height() < 0)
+ float adjustedHeight = reflection * item.height();
+ if (adjustedHeight < 0)
glCullFace(GL_FRONT);
else
glCullFace(GL_BACK);
@@ -1316,13 +1494,13 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QMatrix4x4 itModelMatrix;
QMatrix4x4 MVPMatrix;
- colPos = (bar + seriesPos) * (m_cachedBarSpacing.width());
- rowPos = (row + 0.5f) * (m_cachedBarSpacing.height());
+ GLfloat colPos = (bar + seriesPos) * (m_cachedBarSpacing.width());
+ GLfloat rowPos = (row + 0.5f) * (m_cachedBarSpacing.height());
modelMatrix.translate((colPos - m_rowWidth) / m_scaleFactor,
- item.height(),
+ adjustedHeight,
(m_columnDepth - rowPos) / m_scaleFactor);
- modelScaler.setY(item.height());
+ modelScaler.setY(adjustedHeight);
if (!seriesRotation.isIdentity() || !item.rotation().isIdentity()) {
QQuaternion totalRotation = seriesRotation * item.rotation();
modelMatrix.rotate(totalRotation);
@@ -1357,8 +1535,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// We have no ownership, don't delete the previous one
if (!m_cachedIsSlicingActivated
&& m_selectedSeriesCache == cache) {
- selectedBar = &item;
- selectedBar->setPosition(QPoint(row, bar));
+ *selectedBar = &item;
+ (*selectedBar)->setPosition(QPoint(row, bar));
item.setTranslation(modelMatrix.column(3).toVector3D());
barSelectionFound = true;
}
@@ -1438,8 +1616,15 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
}
- // Skip drawing of 0-height bars
- if (item.height() != 0) {
+ if (item.height() == 0) {
+ continue;
+ } else if ((m_reflectionEnabled
+ && (reflection == 1.0f
+ || (reflection != 1.0f
+ && ((m_yFlipped && item.height() < 0.0)
+ || (!m_yFlipped && item.height() > 0.0)))))
+ || !m_reflectionEnabled) {
+ // Skip drawing of 0-height bars and reflections of bars on the "wrong side"
// Set shader bindings
barShader->setUniformValue(barShader->model(), modelMatrix);
barShader->setUniformValue(barShader->nModel(),
@@ -1452,8 +1637,10 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
qAbs(item.height()) / m_gradientFraction);
}
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ if (((m_reflectionEnabled && reflection == 1.0f
+ && m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone)
+ || m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone)
+ && !m_isOpenGLES) {
// Set shadow shader bindings
QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
barShader->setUniformValue(barShader->shadowQ(),
@@ -1465,13 +1652,15 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw the object
m_drawer->drawObject(barShader, barObj, gradientTexture,
m_depthTexture);
- } else
-#else
- Q_UNUSED(shadowLightStrength);
-#endif
- {
+ } else {
// Set shadowless shader bindings
- barShader->setUniformValue(barShader->lightS(), lightStrength);
+ if (m_reflectionEnabled && reflection != 1.0f
+ && m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ barShader->setUniformValue(barShader->lightS(),
+ adjustedLightStrength);
+ } else {
+ barShader->setUniformValue(barShader->lightS(), lightStrength);
+ }
// Draw the object
m_drawer->drawObject(barShader, barObj, gradientTexture);
@@ -1481,122 +1670,145 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
}
}
-
glDisable(GL_POLYGON_OFFSET_FILL);
// Reset culling
glCullFace(GL_BACK);
- // Bind background shader
- m_backgroundShader->bind();
+ return barSelectionFound;
+}
+void Bars3DRenderer::drawBackground(GLfloat backgroundRotation,
+ const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &viewMatrix, bool reflectingDraw,
+ bool drawingSelectionBuffer)
+{
// Draw background
if (m_cachedTheme->isBackgroundEnabled() && m_backgroundObj) {
+ QVector3D lightPos = m_cachedScene->activeLight()->position();
+ QVector4D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+ GLfloat adjustedLightStrength = m_cachedTheme->lightStrength() / 10.0f;
+ ShaderHelper *shader = 0;
+
+ // Bind background shader
+ if (drawingSelectionBuffer)
+ shader = m_selectionShader; // Use single color shader when drawing to selection buffer
+ else
+ shader = m_backgroundShader;
+ shader->bind();
+
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- QVector3D backgroundScaler(rowScaleFactor, 1.0f, columnScaleFactor);
- modelMatrix.translate(0.0f, m_backgroundAdjustment, 0.0f);
+ QVector3D backgroundScaler(m_scaleXWithBackground, m_scaleYWithBackground,
+ m_scaleZWithBackground);
+ QVector4D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor());
+ if (m_reflectionEnabled)
+ backgroundColor.setW(backgroundColor.w() * m_reflectivity);
+ // Set shader bindings
+ shader->setUniformValue(shader->lightP(), lightPos);
+ shader->setUniformValue(shader->view(), viewMatrix);
+ if (drawingSelectionBuffer) {
+ // Use selectionSkipColor for background when drawing to selection buffer
+ shader->setUniformValue(shader->color(), selectionSkipColor);
+ } else {
+ shader->setUniformValue(shader->color(), backgroundColor);
+ }
+ shader->setUniformValue(shader->ambientS(),
+ m_cachedTheme->ambientLightStrength() * 2.0f);
+ shader->setUniformValue(shader->lightColor(), lightColor);
+
+ // Draw floor
modelMatrix.scale(backgroundScaler);
- itModelMatrix.scale(backgroundScaler);
- modelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
- itModelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
+
+ if (m_yFlipped)
+ modelMatrix.rotate(m_xRightAngleRotation);
+ else
+ modelMatrix.rotate(m_xRightAngleRotationNeg);
+
+ itModelMatrix = modelMatrix;
#ifdef SHOW_DEPTH_TEXTURE_SCENE
MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- QVector4D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor());
-
- // Set shader bindings
- m_backgroundShader->setUniformValue(m_backgroundShader->lightP(), lightPos);
- m_backgroundShader->setUniformValue(m_backgroundShader->view(), viewMatrix);
- m_backgroundShader->setUniformValue(m_backgroundShader->model(), modelMatrix);
- m_backgroundShader->setUniformValue(m_backgroundShader->nModel(),
- itModelMatrix.inverted().transposed());
- m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix);
- m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
- m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
- m_cachedTheme->ambientLightStrength() * 2.0f);
- m_backgroundShader->setUniformValue(m_backgroundShader->lightColor(), lightColor);
+ // Set changed shader bindings
+ shader->setUniformValue(shader->model(), modelMatrix);
+ shader->setUniformValue(shader->nModel(), itModelMatrix.inverted().transposed());
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && !m_isOpenGLES) {
// 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(),
- adjustedLightStrength);
-
+ shader->setUniformValue(shader->depth(), depthMVPMatrix);
// Draw the object
- m_drawer->drawObject(m_backgroundShader, m_backgroundObj, 0, m_depthTexture);
- } else
-#endif
- {
- // Set shadowless shader bindings
- m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme->lightStrength());
-
+ m_drawer->drawObject(shader, m_gridLineObj, 0, m_depthTexture);
+ } else {
// Draw the object
- m_drawer->drawObject(m_backgroundShader, m_backgroundObj);
+ m_drawer->drawObject(shader, m_gridLineObj);
}
- // Draw floor
+ // Draw walls
modelMatrix = QMatrix4x4();
itModelMatrix = QMatrix4x4();
+ modelMatrix.translate(0.0f, m_backgroundAdjustment, 0.0f);
modelMatrix.scale(backgroundScaler);
-
- if (m_yFlipped)
- modelMatrix.rotate(90.0f, 1.0f, 0.0f, 0.0f);
- else
- modelMatrix.rotate(-90.0f, 1.0f, 0.0f, 0.0f);
-
- itModelMatrix = modelMatrix;
+ itModelMatrix.scale(backgroundScaler);
+ modelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
+ itModelMatrix.rotate(backgroundRotation, 0.0f, 1.0f, 0.0f);
#ifdef SHOW_DEPTH_TEXTURE_SCENE
MVPMatrix = depthProjectionViewMatrix * modelMatrix;
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
+
// Set changed shader bindings
- m_backgroundShader->setUniformValue(m_backgroundShader->model(), modelMatrix);
- m_backgroundShader->setUniformValue(m_backgroundShader->nModel(),
- itModelMatrix.inverted().transposed());
- m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix);
+ shader->setUniformValue(shader->model(), modelMatrix);
+ shader->setUniformValue(shader->nModel(), itModelMatrix.inverted().transposed());
+ shader->setUniformValue(shader->MVP(), MVPMatrix);
+ if (!m_reflectionEnabled || (m_reflectionEnabled && reflectingDraw)) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && !m_isOpenGLES) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
+ shader->setUniformValue(shader->shadowQ(), m_shadowQualityToShader);
+ shader->setUniformValue(shader->depth(), depthMVPMatrix);
+ shader->setUniformValue(shader->lightS(), adjustedLightStrength);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- // Set shadow shader bindings
- QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix);
- // Draw the object
- m_drawer->drawObject(m_backgroundShader, m_gridLineObj, 0, m_depthTexture);
- } else
-#endif
- {
- // Draw the object
- m_drawer->drawObject(m_backgroundShader, m_gridLineObj);
+ // Draw the object
+ m_drawer->drawObject(shader, m_backgroundObj, 0, m_depthTexture);
+ } else {
+ // Set shadowless shader bindings
+ shader->setUniformValue(shader->lightS(), m_cachedTheme->lightStrength());
+
+ // Draw the object
+ m_drawer->drawObject(shader, m_backgroundObj);
+ }
}
}
+}
- // Disable textures
- glDisable(GL_TEXTURE_2D);
-
- // Draw grid lines
+void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &viewMatrix)
+{
if (m_cachedTheme->isGridEnabled()) {
-#if !(defined QT_OPENGL_ES_2)
- ShaderHelper *lineShader = m_backgroundShader;
-#else
- ShaderHelper *lineShader = m_selectionShader; // Plain color shader for GL_LINES
-#endif
+ ShaderHelper *lineShader;
+ if (m_isOpenGLES)
+ lineShader = m_selectionShader; // Plain color shader for GL_LINES
+ else
+ lineShader = m_backgroundShader;
+
QQuaternion lineRotation;
+ QVector3D lightPos = m_cachedScene->activeLight()->position();
+ QVector4D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
// Bind bar shader
lineShader->bind();
@@ -1607,15 +1819,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->color(), barColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
lineShader->setUniformValue(lineShader->lightColor(), lightColor);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && !m_isOpenGLES) {
// Set shadowed shader bindings
lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
lineShader->setUniformValue(lineShader->lightS(),
m_cachedTheme->lightStrength() / 20.0f);
- } else
-#endif
- {
+ } else {
// Set shadowless shader bindings
lineShader->setUniformValue(lineShader->lightS(),
m_cachedTheme->lightStrength() / 2.5f);
@@ -1625,12 +1834,12 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_yFlipped)
yFloorLinePosition = -yFloorLinePosition;
- QVector3D gridLineScaler(rowScaleFactor, gridLineWidth, gridLineWidth);
+ QVector3D gridLineScaler(m_scaleXWithBackground, gridLineWidth, gridLineWidth);
if (m_yFlipped)
- lineRotation = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, 90.0f);
+ lineRotation = m_xRightAngleRotation;
else
- lineRotation = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f);
+ lineRotation = m_xRightAngleRotationNeg;
// Floor lines: rows
for (GLfloat row = 0.0f; row <= m_cachedRowCount; row++) {
@@ -1638,7 +1847,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- rowPos = row * m_cachedBarSpacing.height();
+ GLfloat rowPos = row * m_cachedBarSpacing.height();
modelMatrix.translate(0.0f, yFloorLinePosition,
(m_columnDepth - rowPos) / m_scaleFactor);
modelMatrix.scale(gridLineScaler);
@@ -1654,33 +1863,32 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- // Set shadow shader bindings
- QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ if (m_isOpenGLES) {
+ m_drawer->drawLine(lineShader);
} else {
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj);
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
+ lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj);
+ }
}
-#else
- m_drawer->drawLine(lineShader);
-#endif
}
// Floor lines: columns
-#if defined(QT_OPENGL_ES_2)
- lineRotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 90.0f);
-#endif
- gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, columnScaleFactor);
+ if (m_isOpenGLES)
+ lineRotation = m_yRightAngleRotation;
+ gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_scaleZWithBackground);
for (GLfloat bar = 0.0f; bar <= m_cachedColumnCount; bar++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
QMatrix4x4 itModelMatrix;
- colPos = bar * m_cachedBarSpacing.width();
+ GLfloat colPos = bar * m_cachedBarSpacing.width();
modelMatrix.translate((m_rowWidth - colPos) / m_scaleFactor,
yFloorLinePosition, 0.0f);
modelMatrix.scale(gridLineScaler);
@@ -1696,31 +1904,31 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- // Set shadow shader bindings
- QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ if (m_isOpenGLES) {
+ m_drawer->drawLine(lineShader);
} else {
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj);
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
+ lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj);
+ }
}
-#else
- m_drawer->drawLine(lineShader);
-#endif
}
if (m_axisCacheY.segmentCount() > 0) {
// Wall lines: back wall
int gridLineCount = m_axisCacheY.gridLineCount();
- GLfloat zWallLinePosition = -columnScaleFactor + gridLineOffset;
+ GLfloat zWallLinePosition = -m_scaleZWithBackground + gridLineOffset;
if (m_zFlipped)
zWallLinePosition = -zWallLinePosition;
- gridLineScaler = QVector3D(rowScaleFactor, gridLineWidth, gridLineWidth);
+ gridLineScaler = QVector3D(m_scaleXWithBackground, gridLineWidth, gridLineWidth);
for (int line = 0; line < gridLineCount; line++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
@@ -1732,8 +1940,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
modelMatrix.scale(gridLineScaler);
itModelMatrix.scale(gridLineScaler);
if (m_zFlipped) {
- modelMatrix.rotate(180.0f, 1.0f, 0.0f, 0.0f);
- itModelMatrix.rotate(180.0f, 1.0f, 0.0f, 0.0f);
+ modelMatrix.rotate(m_xFlipRotation);
+ itModelMatrix.rotate(m_xFlipRotation);
}
MVPMatrix = projectionViewMatrix * modelMatrix;
@@ -1744,33 +1952,33 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- // Set shadow shader bindings
- QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ if (m_isOpenGLES) {
+ m_drawer->drawLine(lineShader);
} else {
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj);
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
+ lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj);
+ }
}
-#else
- m_drawer->drawLine(lineShader);
-#endif
}
// Wall lines: side wall
- GLfloat xWallLinePosition = -rowScaleFactor + gridLineOffset;
+ GLfloat xWallLinePosition = -m_scaleXWithBackground + gridLineOffset;
if (m_xFlipped)
xWallLinePosition = -xWallLinePosition;
if (m_xFlipped)
- lineRotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -90.0f);
+ lineRotation = m_yRightAngleRotationNeg;
else
- lineRotation = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 90.0f);
+ lineRotation = m_yRightAngleRotation;
- gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, columnScaleFactor);
+ gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_scaleZWithBackground);
for (int line = 0; line < gridLineCount; line++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 MVPMatrix;
@@ -1792,76 +2000,27 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
-#if !defined(QT_OPENGL_ES_2)
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- // Set shadow shader bindings
- QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ if (m_isOpenGLES) {
+ m_drawer->drawLine(lineShader);
} else {
- // Draw the object
- m_drawer->drawObject(lineShader, m_gridLineObj);
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ // Set shadow shader bindings
+ QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
+ lineShader->setUniformValue(lineShader->depth(), depthMVPMatrix);
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj, 0, m_depthTexture);
+ } else {
+ // Draw the object
+ m_drawer->drawObject(lineShader, m_gridLineObj);
+ }
}
-#else
- m_drawer->drawLine(lineShader);
-#endif
}
}
}
-
- Abstract3DRenderer::drawCustomItems(RenderingNormal, m_customItemShader, viewMatrix,
- projectionViewMatrix, depthProjectionViewMatrix,
- m_depthTexture, m_shadowQualityToShader);
-
- drawLabels(false, activeCamera, viewMatrix, projectionMatrix, rowScaleFactor,
- columnScaleFactor);
-
- // Handle selected bar label generation
- if (barSelectionFound) {
- // Print value of selected bar
- glDisable(GL_DEPTH_TEST);
- // Draw the selection label
- LabelItem &labelItem = selectionLabelItem();
- if (m_selectedBar != selectedBar || m_updateLabels || !labelItem.textureId()
- || m_selectionLabelDirty) {
- QString labelText = selectionLabel();
- if (labelText.isNull() || m_selectionLabelDirty) {
- labelText = m_selectedSeriesCache->itemLabel();
- setSelectionLabel(labelText);
- m_selectionLabelDirty = false;
- }
- m_drawer->generateLabelItem(labelItem, labelText);
- m_selectedBar = selectedBar;
- }
-
- Drawer::LabelPosition position =
- m_selectedBar->height() >= 0 ? Drawer::LabelOver : Drawer::LabelBelow;
-
- m_drawer->drawLabel(*selectedBar, labelItem, viewMatrix, projectionMatrix,
- zeroVector, identityQuaternion, selectedBar->height(),
- m_cachedSelectionMode, m_labelShader,
- m_labelObj, activeCamera, true, false, position);
-
- // Reset label update flag; they should have been updated when we get here
- m_updateLabels = false;
-
- glEnable(GL_DEPTH_TEST);
- } else {
- m_selectedBar = 0;
- }
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
-
- // Release shader
- glUseProgram(0);
- m_selectionDirty = false;
}
void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamera,
- const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix,
- GLfloat rowScaleFactor, GLfloat columnScaleFactor) {
+ const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix) {
ShaderHelper *shader = 0;
GLfloat alphaForValueSelection = labelValueAlpha / 255.0f;
GLfloat alphaForRowSelection = labelRowAlpha / 255.0f;
@@ -1873,7 +2032,6 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
shader = m_labelShader;
shader->bind();
- glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -1894,8 +2052,8 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
int labelCount = m_axisCacheY.labelCount();
GLfloat labelMarginXTrans = labelMargin;
GLfloat labelMarginZTrans = labelMargin;
- GLfloat labelXTrans = rowScaleFactor;
- GLfloat labelZTrans = columnScaleFactor;
+ GLfloat labelXTrans = m_scaleXWithBackground;
+ GLfloat labelZTrans = m_scaleZWithBackground;
QVector3D backLabelRotation(0.0f, -90.0f, 0.0f);
QVector3D sideLabelRotation(0.0f, 0.0f, 0.0f);
Qt::AlignmentFlag backAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
@@ -1999,10 +2157,8 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
fractionCamY = activeCamera->yRotation() * labelAngleFraction;
fractionCamX = activeCamera->xRotation() * labelAngleFraction;
GLfloat labelYAdjustment = 0.005f;
- GLfloat scaledRowWidth = rowScaleFactor;
- GLfloat scaledColumnDepth = columnScaleFactor;
- GLfloat colPosValue = scaledRowWidth + labelMargin;
- GLfloat rowPosValue = scaledColumnDepth + labelMargin;
+ GLfloat colPosValue = m_scaleXWithBackground + labelMargin;
+ GLfloat rowPosValue = m_scaleZWithBackground + labelMargin;
GLfloat rowPos = 0.0f;
GLfloat colPos = 0.0f;
Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
@@ -2296,14 +2452,8 @@ void Bars3DRenderer::updateAxisRange(QAbstract3DAxis::AxisOrientation orientatio
{
Abstract3DRenderer::updateAxisRange(orientation, min, max);
- if (orientation == QAbstract3DAxis::AxisOrientationY) {
- // Check if we have negative values
- if (min < 0)
- m_hasNegativeValues = true;
- else if (min >= 0)
- m_hasNegativeValues = false;
+ if (orientation == QAbstract3DAxis::AxisOrientationY)
calculateHeightAdjustment();
- }
}
void Bars3DRenderer::updateAxisReversed(QAbstract3DAxis::AxisOrientation orientation, bool enable)
@@ -2384,10 +2534,12 @@ void Bars3DRenderer::updateShadowQuality(QAbstract3DGraph::ShadowQuality quality
handleShadowQualityChange();
-#if !defined(QT_OPENGL_ES_2)
// Re-init depth buffer
updateDepthBuffer();
-#endif
+
+ // Redraw to handle both reflections and shadows on background
+ if (m_reflectionEnabled)
+ needRender();
}
void Bars3DRenderer::loadBackgroundMesh()
@@ -2398,6 +2550,8 @@ void Bars3DRenderer::loadBackgroundMesh()
void Bars3DRenderer::updateTextures()
{
+ Abstract3DRenderer::updateTextures();
+
// Drawer has changed; this flag needs to be checked when checking if we need to update labels
m_updateLabels = true;
}
@@ -2420,30 +2574,60 @@ void Bars3DRenderer::calculateSceneScalingFactors()
m_maxDimension = qMax(m_rowWidth, m_columnDepth);
m_scaleFactor = qMin((m_cachedColumnCount * (m_maxDimension / m_maxSceneSize)),
(m_cachedRowCount * (m_maxDimension / m_maxSceneSize)));
+
+ // Single bar scaling
m_scaleX = m_cachedBarThickness.width() / m_scaleFactor;
m_scaleZ = m_cachedBarThickness.height() / m_scaleFactor;
+
+ // Whole graph scale factors
+ m_xScaleFactor = m_rowWidth / m_scaleFactor;
+ m_zScaleFactor = m_columnDepth / m_scaleFactor;
+
+ if (m_requestedMargin < 0.0f) {
+ m_hBackgroundMargin = 0.0f;
+ m_vBackgroundMargin = 0.0f;
+ } else {
+ m_hBackgroundMargin = m_requestedMargin;
+ m_vBackgroundMargin = m_requestedMargin;
+ }
+
+ m_scaleXWithBackground = m_xScaleFactor + m_hBackgroundMargin;
+ m_scaleYWithBackground = 1.0f + m_vBackgroundMargin;
+ m_scaleZWithBackground = m_zScaleFactor + m_hBackgroundMargin;
+
+ updateCameraViewport();
+ updateCustomItemPositions();
}
void Bars3DRenderer::calculateHeightAdjustment()
{
+ float min = m_axisCacheY.min();
+ float max = m_axisCacheY.max();
GLfloat newAdjustment = 1.0f;
- GLfloat maxAbs = qFabs(m_axisCacheY.max());
-
- if (m_axisCacheY.max() < 0.0f) {
- m_heightNormalizer = GLfloat(qFabs(m_axisCacheY.min()) - qFabs(m_axisCacheY.max()));
- maxAbs = qFabs(m_axisCacheY.max()) - qFabs(m_axisCacheY.min());
+ m_actualFloorLevel = qBound(min, m_floorLevel, max);
+ GLfloat maxAbs = qFabs(max - m_actualFloorLevel);
+
+ // Check if we have negative values
+ if (min < m_actualFloorLevel)
+ m_hasNegativeValues = true;
+ else if (min >= m_actualFloorLevel)
+ m_hasNegativeValues = false;
+
+ if (max < m_actualFloorLevel) {
+ m_heightNormalizer = GLfloat(qFabs(min) - qFabs(max));
+ maxAbs = qFabs(max) - qFabs(min);
} else {
- m_heightNormalizer = GLfloat(m_axisCacheY.max() - m_axisCacheY.min());
+ m_heightNormalizer = GLfloat(max - min);
}
// Height fractions are used in gradient calculations and are therefore doubled
// Note that if max or min is exactly zero, we still consider it outside the range
- if (m_axisCacheY.max() <= 0.0f || m_axisCacheY.min() >= 0.0f) {
+ if (max <= m_actualFloorLevel || min >= m_actualFloorLevel) {
m_noZeroInRange = true;
m_gradientFraction = 2.0f;
} else {
m_noZeroInRange = false;
- GLfloat minAbs = qFabs(m_axisCacheY.min());
+ GLfloat minAbs = qFabs(min - m_actualFloorLevel);
m_gradientFraction = qMax(minAbs, maxAbs) / m_heightNormalizer * 2.0f;
}
@@ -2551,13 +2735,13 @@ void Bars3DRenderer::updateSlicingActive(bool isSlicing)
m_cachedIsSlicingActivated = isSlicing;
- if (!m_cachedIsSlicingActivated)
- initSelectionBuffer(); // We need to re-init selection buffer in case there has been a resize
+ if (!m_cachedIsSlicingActivated) {
+ // We need to re-init selection buffer in case there has been a resize
+ initSelectionBuffer();
+ initCursorPositionBuffer();
+ }
-#if !defined(QT_OPENGL_ES_2)
updateDepthBuffer(); // Re-init depth buffer as well
-#endif
-
m_selectionDirty = true;
}
@@ -2598,32 +2782,35 @@ void Bars3DRenderer::initSelectionBuffer()
m_selectionDepthBuffer);
}
-#if !defined(QT_OPENGL_ES_2)
void Bars3DRenderer::initDepthShader()
{
- if (m_depthShader)
- delete m_depthShader;
- m_depthShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertexDepth"),
- QStringLiteral(":/shaders/fragmentDepth"));
- m_depthShader->initialize();
+ if (!m_isOpenGLES) {
+ if (m_depthShader)
+ delete m_depthShader;
+ m_depthShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertexDepth"),
+ QStringLiteral(":/shaders/fragmentDepth"));
+ m_depthShader->initialize();
+ }
}
void Bars3DRenderer::updateDepthBuffer()
{
- m_textureHelper->deleteTexture(&m_depthTexture);
+ if (!m_isOpenGLES) {
+ m_textureHelper->deleteTexture(&m_depthTexture);
- if (m_primarySubViewport.size().isEmpty())
- return;
+ if (m_primarySubViewport.size().isEmpty())
+ return;
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
- m_depthTexture = m_textureHelper->createDepthTextureFrameBuffer(m_primarySubViewport.size(),
- m_depthFrameBuffer,
- m_shadowQualityMultiplier);
- if (!m_depthTexture)
- lowerShadowQuality();
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
+ m_depthTexture =
+ m_textureHelper->createDepthTextureFrameBuffer(m_primarySubViewport.size(),
+ m_depthFrameBuffer,
+ m_shadowQualityMultiplier);
+ if (!m_depthTexture)
+ lowerShadowQuality();
+ }
}
}
-#endif
void Bars3DRenderer::initBackgroundShaders(const QString &vertexShader,
const QString &fragmentShader)
@@ -2634,14 +2821,6 @@ void Bars3DRenderer::initBackgroundShaders(const QString &vertexShader,
m_backgroundShader->initialize();
}
-void Bars3DRenderer::initLabelShaders(const QString &vertexShader, const QString &fragmentShader)
-{
- if (m_labelShader)
- delete m_labelShader;
- m_labelShader = new ShaderHelper(this, vertexShader, fragmentShader);
- m_labelShader->initialize();
-}
-
QVector3D Bars3DRenderer::convertPositionToTranslation(const QVector3D &position, bool isAbsolute)
{
float xTrans = 0.0f;
@@ -2649,15 +2828,15 @@ QVector3D Bars3DRenderer::convertPositionToTranslation(const QVector3D &position
float zTrans = 0.0f;
if (!isAbsolute) {
// Convert row and column to translation on graph
- xTrans = (((position.x() + 0.5f) * m_cachedBarSpacing.width()) - m_rowWidth)
- / m_scaleFactor;
- zTrans = (m_columnDepth - ((position.z() + 0.5f) * m_cachedBarSpacing.height()))
- / m_scaleFactor;
+ xTrans = (((position.x() - m_axisCacheX.min() + 0.5f) * m_cachedBarSpacing.width())
+ - m_rowWidth) / m_scaleFactor;
+ zTrans = (m_columnDepth - ((position.z() - m_axisCacheZ.min() + 0.5f)
+ * m_cachedBarSpacing.height())) / m_scaleFactor;
yTrans = m_axisCacheY.positionAt(position.y());
} else {
- xTrans = position.x() * m_scaleX;
+ xTrans = position.x() * m_xScaleFactor;
yTrans = position.y() + m_backgroundAdjustment;
- zTrans = position.z() * m_scaleZ;
+ zTrans = position.z() * -m_zScaleFactor;
}
return QVector3D(xTrans, yTrans, zTrans);
}
@@ -2667,4 +2846,18 @@ void Bars3DRenderer::updateAspectRatio(float ratio)
Q_UNUSED(ratio)
}
+void Bars3DRenderer::updateFloorLevel(float level)
+{
+ foreach (SeriesRenderCache *cache, m_renderCacheList)
+ cache->setDataDirty(true);
+ m_floorLevel = level;
+ calculateHeightAdjustment();
+}
+
+void Bars3DRenderer::updateMargin(float margin)
+{
+ Abstract3DRenderer::updateMargin(margin);
+ calculateSceneScalingFactors();
+}
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/engine/bars3drenderer_p.h b/src/datavisualization/engine/bars3drenderer_p.h
index 3a0ab3b8..094b8fd9 100644
--- a/src/datavisualization/engine/bars3drenderer_p.h
+++ b/src/datavisualization/engine/bars3drenderer_p.h
@@ -66,9 +66,7 @@ private:
ShaderHelper *m_depthShader;
ShaderHelper *m_selectionShader;
ShaderHelper *m_backgroundShader;
- ShaderHelper *m_labelShader;
GLuint m_bgrTexture;
- GLuint m_depthTexture;
GLuint m_selectionTexture;
GLuint m_depthFrameBuffer;
GLuint m_selectionFrameBuffer;
@@ -86,7 +84,6 @@ private:
GLfloat m_scaleFactor;
GLfloat m_maxSceneSize;
QPoint m_visualSelectedBarPos;
- bool m_resetCameraBaseOrientation;
QPoint m_selectedBarPos;
BarSeriesRenderCache *m_selectedSeriesCache;
BarRenderItem m_dummyBarRenderItem;
@@ -100,6 +97,10 @@ private:
bool m_haveUniformColorSeries;
bool m_haveGradientSeries;
float m_zeroPosition;
+ float m_xScaleFactor;
+ float m_zScaleFactor;
+ float m_floorLevel;
+ float m_actualFloorLevel;
public:
explicit Bars3DRenderer(Bars3DController *controller);
@@ -116,9 +117,13 @@ public:
QVector3D convertPositionToTranslation(const QVector3D &position, bool isAbsolute);
void updateAspectRatio(float ratio);
+ void updateFloorLevel(float level);
+ void updateMargin(float margin);
protected:
virtual void initializeOpenGL();
+ virtual void fixCameraTarget(QVector3D &target);
+ virtual void getVisibleItemBounds(QVector3D &minBounds, QVector3D &maxBounds);
public slots:
void updateMultiSeriesScaling(bool uniform);
@@ -146,18 +151,25 @@ private:
void drawSlicedScene();
void drawScene(GLuint defaultFboHandle);
void drawLabels(bool drawSelection, const Q3DCamera *activeCamera,
- const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix,
- GLfloat rowScaleFactor, GLfloat columnScaleFactor);
+ const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix);
+
+ bool drawBars(BarRenderItem **selectedBar, const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix, const QMatrix4x4 &viewMatrix,
+ GLint startRow, GLint stopRow, GLint stepRow,
+ GLint startBar, GLint stopBar, GLint stepBar, GLfloat reflection = 1.0f);
+ void drawBackground(GLfloat backgroundRotation, const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix, const QMatrix4x4 &viewMatrix,
+ bool reflectingDraw = false, bool drawingSelectionBuffer = false);
+ void drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix,
+ const QMatrix4x4 &projectionViewMatrix,
+ const QMatrix4x4 &viewMatrix);
void loadBackgroundMesh();
void initSelectionShader();
void initBackgroundShaders(const QString &vertexShader, const QString &fragmentShader);
- void initLabelShaders(const QString &vertexShader, const QString &fragmentShader);
void initSelectionBuffer();
-#if !defined(QT_OPENGL_ES_2)
void initDepthShader();
void updateDepthBuffer();
-#endif
void calculateSceneScalingFactors();
void calculateHeightAdjustment();
Abstract3DController::SelectionType isSelected(int row, int bar,
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index b8726840..d4352702 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -69,10 +69,9 @@ Drawer::~Drawer()
void Drawer::initializeOpenGL()
{
- if (!m_textureHelper) {
- initializeOpenGLFunctions();
+ initializeOpenGLFunctions();
+ if (!m_textureHelper)
m_textureHelper = new TextureHelper();
- }
}
void Drawer::setTheme(Q3DTheme *theme)
@@ -93,8 +92,11 @@ QFont Drawer::font() const
}
void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLuint textureId,
- GLuint depthTextureId)
+ GLuint depthTextureId, GLuint textureId3D)
{
+#if defined(QT_OPENGL_ES_2)
+ Q_UNUSED(textureId3D)
+#endif
if (textureId) {
// Activate texture
glActiveTexture(GL_TEXTURE0);
@@ -108,6 +110,14 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui
glBindTexture(GL_TEXTURE_2D, depthTextureId);
shader->setUniformValue(shader->shadow(), 1);
}
+#if !defined(QT_OPENGL_ES_2)
+ if (textureId3D) {
+ // Activate texture
+ glActiveTexture(GL_TEXTURE2);
+ glBindTexture(GL_TEXTURE_3D, textureId3D);
+ shader->setUniformValue(shader->texture(), 2);
+ }
+#endif
// 1st attribute buffer : vertices
glEnableVertexAttribArray(shader->posAtt());
@@ -115,14 +125,18 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui
glVertexAttribPointer(shader->posAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
// 2nd attribute buffer : normals
- glEnableVertexAttribArray(shader->normalAtt());
- glBindBuffer(GL_ARRAY_BUFFER, object->normalBuf());
- glVertexAttribPointer(shader->normalAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ if (shader->normalAtt() >= 0) {
+ glEnableVertexAttribArray(shader->normalAtt());
+ glBindBuffer(GL_ARRAY_BUFFER, object->normalBuf());
+ glVertexAttribPointer(shader->normalAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ }
// 3rd attribute buffer : UVs
- glEnableVertexAttribArray(shader->uvAtt());
- glBindBuffer(GL_ARRAY_BUFFER, object->uvBuf());
- glVertexAttribPointer(shader->uvAtt(), 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ if (shader->uvAtt() >= 0) {
+ glEnableVertexAttribArray(shader->uvAtt());
+ glBindBuffer(GL_ARRAY_BUFFER, object->uvBuf());
+ glVertexAttribPointer(shader->uvAtt(), 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ }
// Index buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object->elementBuf());
@@ -134,11 +148,19 @@ void Drawer::drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLui
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- glDisableVertexAttribArray(shader->uvAtt());
- glDisableVertexAttribArray(shader->normalAtt());
+ if (shader->uvAtt() >= 0)
+ glDisableVertexAttribArray(shader->uvAtt());
+ if (shader->normalAtt() >= 0)
+ glDisableVertexAttribArray(shader->normalAtt());
glDisableVertexAttribArray(shader->posAtt());
// Release textures
+#if !defined(QT_OPENGL_ES_2)
+ if (textureId3D) {
+ glActiveTexture(GL_TEXTURE2);
+ glBindTexture(GL_TEXTURE_3D, 0);
+ }
+#endif
if (depthTextureId) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
@@ -206,13 +228,27 @@ void Drawer::drawPoint(ShaderHelper *shader)
glDisableVertexAttribArray(shader->posAtt());
}
-void Drawer::drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object)
+void Drawer::drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object, GLuint textureId)
{
+ if (textureId) {
+ // Activate texture
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ shader->setUniformValue(shader->texture(), 0);
+ }
+
// 1st attribute buffer : vertices
glEnableVertexAttribArray(shader->posAtt());
glBindBuffer(GL_ARRAY_BUFFER, object->pointBuf());
glVertexAttribPointer(shader->posAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ // 2nd attribute buffer : UVs
+ if (textureId) {
+ glEnableVertexAttribArray(shader->uvAtt());
+ glBindBuffer(GL_ARRAY_BUFFER, object->uvBuf());
+ glVertexAttribPointer(shader->uvAtt(), 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
+ }
+
// Draw the points
glDrawArrays(GL_POINTS, 0, object->indexCount());
@@ -220,6 +256,12 @@ void Drawer::drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object)
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(shader->posAtt());
+
+ if (textureId) {
+ glDisableVertexAttribArray(shader->uvAtt());
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ }
}
void Drawer::drawLine(ShaderHelper *shader)
diff --git a/src/datavisualization/engine/drawer_p.h b/src/datavisualization/engine/drawer_p.h
index ffcea315..0c96724c 100644
--- a/src/datavisualization/engine/drawer_p.h
+++ b/src/datavisualization/engine/drawer_p.h
@@ -75,11 +75,11 @@ public:
inline GLfloat scaledFontSize() const { return m_scaledFontSize; }
void drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLuint textureId = 0,
- GLuint depthTextureId = 0);
+ GLuint depthTextureId = 0, GLuint textureId3D = 0);
void drawSelectionObject(ShaderHelper *shader, AbstractObjectHelper *object);
void drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object);
void drawPoint(ShaderHelper *shader);
- void drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object);
+ void drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object, GLuint textureId);
void drawLine(ShaderHelper *shader);
void drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix,
diff --git a/src/datavisualization/engine/engine.pri b/src/datavisualization/engine/engine.pri
index 96fa7fa9..60703e96 100644
--- a/src/datavisualization/engine/engine.pri
+++ b/src/datavisualization/engine/engine.pri
@@ -57,3 +57,5 @@ SOURCES += $$PWD/qabstract3dgraph.cpp \
RESOURCES += engine/engine.qrc
OTHER_FILES += $$PWD/meshes/* $$PWD/shaders/*
+
+INCLUDEPATH += $$PWD
diff --git a/src/datavisualization/engine/engine.qrc b/src/datavisualization/engine/engine.qrc
index 673b6ee0..0ef169c9 100644
--- a/src/datavisualization/engine/engine.qrc
+++ b/src/datavisualization/engine/engine.qrc
@@ -57,5 +57,18 @@
<file alias="fragmentTexture">shaders/texture.frag</file>
<file alias="fragmentTextureES2">shaders/texture_ES2.frag</file>
<file alias="vertexTexture">shaders/texture.vert</file>
+ <file alias="fragmentTexturedSurfaceShadowFlat">shaders/surfaceTexturedShadowFlat.frag</file>
+ <file alias="fragmentSurfaceTexturedFlat">shaders/surfaceTexturedFlat.frag</file>
+ <file alias="fragmentTexture3D">shaders/texture3d.frag</file>
+ <file alias="vertexTexture3D">shaders/texture3d.vert</file>
+ <file alias="fragmentTexture3DSlice">shaders/texture3dslice.frag</file>
+ <file alias="vertexShadowNoMatrices">shaders/shadowNoMatrices.vert</file>
+ <file alias="vertexNoMatrices">shaders/defaultNoMatrices.vert</file>
+ <file alias="fragmentTexture3DLowDef">shaders/texture3dlowdef.frag</file>
+ <file alias="vertexPointES2_UV">shaders/point_ES2_UV.vert</file>
+ <file alias="fragment3DSliceFrames">shaders/3dsliceframes.frag</file>
+ <file alias="vertexPosition">shaders/position.vert</file>
+ <file alias="fragmentPositionMap">shaders/positionmap.frag</file>
+ <file alias="fragmentTexturedSurfaceShadow">shaders/surfaceTexturedShadow.frag</file>
</qresource>
</RCC>
diff --git a/src/datavisualization/engine/q3dbars.cpp b/src/datavisualization/engine/q3dbars.cpp
index bb7aca89..d42c11b7 100644
--- a/src/datavisualization/engine/q3dbars.cpp
+++ b/src/datavisualization/engine/q3dbars.cpp
@@ -331,6 +331,26 @@ QBar3DSeries *Q3DBars::selectedSeries() const
}
/*!
+ * \property Q3DBars::floorLevel
+ *
+ * The desired floor level for the bar graph in Y-axis data coordinates.
+ * The actual floor level cannot go below Y-axis minimum or above Y-axis maximum.
+ * Defaults to zero.
+ */
+void Q3DBars::setFloorLevel(float level)
+{
+ if (level != floorLevel()) {
+ dptr()->m_shared->setFloorLevel(level);
+ emit floorLevelChanged(level);
+ }
+}
+
+float Q3DBars::floorLevel() const
+{
+ return dptrc()->m_shared->floorLevel();
+}
+
+/*!
* Adds \a axis to the graph. The axes added via addAxis are not yet taken to use,
* addAxis is simply used to give the ownership of the \a axis to the graph.
* The \a axis must not be null or added to another graph.
diff --git a/src/datavisualization/engine/q3dbars.h b/src/datavisualization/engine/q3dbars.h
index 7f9c981f..df1c846e 100644
--- a/src/datavisualization/engine/q3dbars.h
+++ b/src/datavisualization/engine/q3dbars.h
@@ -40,6 +40,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DBars : public QAbstract3DGraph
Q_PROPERTY(QValue3DAxis *valueAxis READ valueAxis WRITE setValueAxis NOTIFY valueAxisChanged)
Q_PROPERTY(QBar3DSeries *primarySeries READ primarySeries WRITE setPrimarySeries NOTIFY primarySeriesChanged)
Q_PROPERTY(QBar3DSeries *selectedSeries READ selectedSeries NOTIFY selectedSeriesChanged)
+ Q_PROPERTY(float floorLevel READ floorLevel WRITE setFloorLevel NOTIFY floorLevelChanged)
public:
explicit Q3DBars(const QSurfaceFormat *format = 0, QWindow *parent = 0);
@@ -75,6 +76,8 @@ public:
QList<QAbstract3DAxis *> axes() const;
QBar3DSeries *selectedSeries() const;
+ void setFloorLevel(float level);
+ float floorLevel() const;
signals:
void multiSeriesUniformChanged(bool uniform);
@@ -86,6 +89,7 @@ signals:
void valueAxisChanged(QValue3DAxis *axis);
void primarySeriesChanged(QBar3DSeries *series);
void selectedSeriesChanged(QBar3DSeries *series);
+ void floorLevelChanged(float level);
private:
Q3DBarsPrivate *dptr();
diff --git a/src/datavisualization/engine/q3dcamera.cpp b/src/datavisualization/engine/q3dcamera.cpp
index 06fd570c..897c3779 100644
--- a/src/datavisualization/engine/q3dcamera.cpp
+++ b/src/datavisualization/engine/q3dcamera.cpp
@@ -110,8 +110,36 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
/*!
* \qmlproperty float Camera3D::zoomLevel
*
- * This property contains the the camera zoom level in percentage. 100.0 means there is no zoom
- * in or out set in the camera.
+ * This property contains the the camera zoom level in percentage. The default value of \c{100.0}
+ * means there is no zoom in or out set in the camera.
+ * The value is limited within the bounds defined by minZoomLevel and maxZoomLevel properties.
+ *
+ * \sa minZoomLevel, maxZoomLevel
+ */
+
+/*!
+ * \qmlproperty float Camera3D::minZoomLevel
+ *
+ * This property contains the the minimum allowed camera zoom level.
+ * If the new minimum level is more than the existing maximum level, the maximum level is
+ * adjusted to the new minimum as well.
+ * If current zoomLevel is outside the new bounds, it is adjusted as well.
+ * The minZoomLevel cannot be set below \c{1.0}.
+ * Defaults to \c{10.0}.
+ *
+ * \sa zoomLevel, maxZoomLevel
+ */
+
+/*!
+ * \qmlproperty float Camera3D::maxZoomLevel
+ *
+ * This property contains the the maximum allowed camera zoom level.
+ * If the new maximum level is less than the existing minimum level, the minimum level is
+ * adjusted to the new maximum as well.
+ * If current zoomLevel is outside the new bounds, it is adjusted as well.
+ * Defaults to \c{500.0f}.
+ *
+ * \sa zoomLevel, minZoomLevel
*/
/*!
@@ -137,6 +165,19 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
*/
/*!
+ * \qmlproperty vector3d Camera3D::target
+ * \since QtDataVisualization 1.2
+ *
+ * Holds the camera \a target as a vector3d. Defaults to \c {vector3d(0.0, 0.0, 0.0)}.
+ *
+ * Valid coordinate values are between \c{-1.0...1.0}, where the edge values indicate
+ * the edges of the corresponding axis range. Any values outside this range are clamped to the edge.
+ *
+ * \note For bar graphs, the Y-coordinate is ignored and camera always targets a point on
+ * the horizontal background.
+ */
+
+/*!
* Constructs a new 3D camera with position set to origin, up direction facing towards the Y-axis
* and looking at origin by default. An optional \a parent parameter can be given and is then passed
* to QObject constructor.
@@ -160,22 +201,11 @@ Q3DCamera::~Q3DCamera()
*/
void Q3DCamera::copyValuesFrom(const Q3DObject &source)
{
- Q3DObject::copyValuesFrom(source);
+ // Note: Do not copy values from parent, as we are handling the position internally
const Q3DCamera &sourceCamera = static_cast<const Q3DCamera &>(source);
- d_ptr->m_target.setX(sourceCamera.d_ptr->m_target.x());
- d_ptr->m_target.setY(sourceCamera.d_ptr->m_target.y());
- d_ptr->m_target.setZ(sourceCamera.d_ptr->m_target.z());
-
- d_ptr->m_up.setX(sourceCamera.d_ptr->m_up.x());
- d_ptr->m_up.setY(sourceCamera.d_ptr->m_up.y());
- d_ptr->m_up.setZ(sourceCamera.d_ptr->m_up.z());
-
- float *values = new float[16];
- sourceCamera.d_ptr->m_viewMatrix.copyDataTo(values);
- d_ptr->m_viewMatrix = QMatrix4x4(values);
- delete[] values;
+ d_ptr->m_requestedTarget = sourceCamera.d_ptr->m_requestedTarget;
d_ptr->m_xRotation = sourceCamera.d_ptr->m_xRotation;
d_ptr->m_yRotation = sourceCamera.d_ptr->m_yRotation;
@@ -189,6 +219,8 @@ void Q3DCamera::copyValuesFrom(const Q3DObject &source)
d_ptr->m_wrapYRotation = sourceCamera.d_ptr->m_wrapYRotation;
d_ptr->m_zoomLevel = sourceCamera.d_ptr->m_zoomLevel;
+ d_ptr->m_minZoomLevel = sourceCamera.d_ptr->m_minZoomLevel;
+ d_ptr->m_maxZoomLevel = sourceCamera.d_ptr->m_maxZoomLevel;
d_ptr->m_activePreset = sourceCamera.d_ptr->m_activePreset;
}
@@ -389,6 +421,9 @@ void Q3DCamera::setCameraPreset(CameraPreset preset)
break;
}
+ // All presets target the center of the graph
+ setTarget(zeroVector);
+
if (d_ptr->m_activePreset != preset) {
d_ptr->m_activePreset = preset;
setDirty(true);
@@ -399,8 +434,11 @@ void Q3DCamera::setCameraPreset(CameraPreset preset)
/*!
* \property Q3DCamera::zoomLevel
*
- * This property contains the the camera zoom level in percentage. \c 100.0f means there is no zoom
- * in or out set in the camera.
+ * This property contains the the camera zoom level in percentage. The default value of \c{100.0f}
+ * means there is no zoom in or out set in the camera.
+ * The value is limited within the bounds defined by minZoomLevel and maxZoomLevel properties.
+ *
+ * \sa minZoomLevel, maxZoomLevel
*/
float Q3DCamera::zoomLevel() const
{
@@ -409,10 +447,73 @@ float Q3DCamera::zoomLevel() const
void Q3DCamera::setZoomLevel(float zoomLevel)
{
- if (d_ptr->m_zoomLevel != zoomLevel) {
- d_ptr->m_zoomLevel = zoomLevel;
+ float newZoomLevel = qBound(d_ptr->m_minZoomLevel, zoomLevel, d_ptr->m_maxZoomLevel);
+
+ if (d_ptr->m_zoomLevel != newZoomLevel) {
+ d_ptr->m_zoomLevel = newZoomLevel;
+ setDirty(true);
+ emit zoomLevelChanged(newZoomLevel);
+ }
+}
+
+/*!
+ * \property Q3DCamera::minZoomLevel
+ *
+ * This property contains the the minimum allowed camera zoom level.
+ * If the new minimum level is more than the existing maximum level, the maximum level is
+ * adjusted to the new minimum as well.
+ * If current zoomLevel is outside the new bounds, it is adjusted as well.
+ * The minZoomLevel cannot be set below \c{1.0f}.
+ * Defaults to \c{10.0f}.
+ *
+ * \sa zoomLevel, maxZoomLevel
+ */
+float Q3DCamera::minZoomLevel() const
+{
+ return d_ptr->m_minZoomLevel;
+}
+
+void Q3DCamera::setMinZoomLevel(float zoomLevel)
+{
+ // Don't allow minimum to be below one, as that can cause zoom to break.
+ float newMinLevel = qMax(zoomLevel, 1.0f);
+ if (d_ptr->m_minZoomLevel != newMinLevel) {
+ d_ptr->m_minZoomLevel = newMinLevel;
+ if (d_ptr->m_maxZoomLevel < newMinLevel)
+ setMaxZoomLevel(newMinLevel);
+ setZoomLevel(d_ptr->m_zoomLevel);
setDirty(true);
- emit zoomLevelChanged(zoomLevel);
+ emit minZoomLevelChanged(newMinLevel);
+ }
+}
+
+/*!
+ * \property Q3DCamera::maxZoomLevel
+ *
+ * This property contains the the maximum allowed camera zoom level.
+ * If the new maximum level is less than the existing minimum level, the minimum level is
+ * adjusted to the new maximum as well.
+ * If current zoomLevel is outside the new bounds, it is adjusted as well.
+ * Defaults to \c{500.0f}.
+ *
+ * \sa zoomLevel, minZoomLevel
+ */
+float Q3DCamera::maxZoomLevel() const
+{
+ return d_ptr->m_maxZoomLevel;
+}
+
+void Q3DCamera::setMaxZoomLevel(float zoomLevel)
+{
+ // Don't allow maximum to be below one, as that can cause zoom to break.
+ float newMaxLevel = qMax(zoomLevel, 1.0f);
+ if (d_ptr->m_maxZoomLevel != newMaxLevel) {
+ d_ptr->m_maxZoomLevel = newMaxLevel;
+ if (d_ptr->m_minZoomLevel > newMaxLevel)
+ setMinZoomLevel(newMaxLevel);
+ setZoomLevel(d_ptr->m_zoomLevel);
+ setDirty(true);
+ emit maxZoomLevelChanged(newMaxLevel);
}
}
@@ -459,16 +560,61 @@ void Q3DCamera::setWrapYRotation(bool isEnabled)
/*!
* Utility function that sets the camera rotations and distance.\a horizontal and \a vertical
* define the camera rotations to be used.
- * Optional \a zoom parameter can be given to set the zoom percentage of the camera in range of
- * \c{10.0f - 500.0f}.
+ * Optional \a zoom parameter can be given to set the zoom percentage of the camera within
+ * the bounds defined by minZoomLevel and maxZoomLevel properties.
*/
void Q3DCamera::setCameraPosition(float horizontal, float vertical, float zoom)
{
- setZoomLevel(qBound(10.0f, zoom, 500.0f));
+ setZoomLevel(zoom);
setXRotation(horizontal);
setYRotation(vertical);
}
+/*!
+ * \property Q3DCamera::target
+ * \since QtDataVisualization 1.2
+ *
+ * Holds the camera \a target as a QVector3D. Defaults to \c {QVector3D(0.0, 0.0, 0.0)}.
+ *
+ * Valid coordinate values are between \c{-1.0...1.0}, where the edge values indicate
+ * the edges of the corresponding axis range. Any values outside this range are clamped to the edge.
+ *
+ * \note For bar graphs, the Y-coordinate is ignored and camera always targets a point on
+ * the horizontal background.
+ */
+QVector3D Q3DCamera::target() const
+{
+ return d_ptr->m_requestedTarget;
+}
+
+void Q3DCamera::setTarget(const QVector3D &target)
+{
+ QVector3D newTarget = target;
+
+ if (newTarget.x() < -1.0f)
+ newTarget.setX(-1.0f);
+ else if (newTarget.x() > 1.0f)
+ newTarget.setX(1.0f);
+
+ if (newTarget.y() < -1.0f)
+ newTarget.setY(-1.0f);
+ else if (newTarget.y() > 1.0f)
+ newTarget.setY(1.0f);
+
+ if (newTarget.z() < -1.0f)
+ newTarget.setZ(-1.0f);
+ else if (newTarget.z() > 1.0f)
+ newTarget.setZ(1.0f);
+
+ if (d_ptr->m_requestedTarget != newTarget) {
+ if (d_ptr->m_activePreset != CameraPresetNone)
+ d_ptr->m_activePreset = CameraPresetNone;
+ d_ptr->m_requestedTarget = newTarget;
+ setDirty(true);
+ emit targetChanged(newTarget);
+ }
+}
+
Q3DCameraPrivate::Q3DCameraPrivate(Q3DCamera *q) :
q_ptr(q),
m_isViewMatrixUpdateActive(true),
@@ -479,6 +625,8 @@ Q3DCameraPrivate::Q3DCameraPrivate(Q3DCamera *q) :
m_maxXRotation(180.0f),
m_maxYRotation(90.0f),
m_zoomLevel(100.0f),
+ m_minZoomLevel(10.0f),
+ m_maxZoomLevel(500.0f),
m_wrapXRotation(true),
m_wrapYRotation(false),
m_activePreset(Q3DCamera::CameraPresetNone)
@@ -645,9 +793,9 @@ void Q3DCameraPrivate::updateViewMatrix(float zoomAdjustment)
QMatrix4x4 viewMatrix;
// Apply to view matrix
- viewMatrix.lookAt(q_ptr->position(), m_target, m_up);
+ viewMatrix.lookAt(q_ptr->position(), m_actualTarget, m_up);
// Compensate for translation (if d_ptr->m_target is off origin)
- viewMatrix.translate(m_target.x(), m_target.y(), m_target.z());
+ viewMatrix.translate(m_actualTarget.x(), m_actualTarget.y(), m_actualTarget.z());
// Apply rotations
// Handle x and z rotation when y -angle is other than 0
viewMatrix.rotate(m_xRotation, 0, qCos(qDegreesToRadians(m_yRotation)),
@@ -657,7 +805,7 @@ void Q3DCameraPrivate::updateViewMatrix(float zoomAdjustment)
// handle zoom by scaling
viewMatrix.scale(zoom / 100.0f);
// Compensate for translation (if d_ptr->m_target is off origin)
- viewMatrix.translate(-m_target.x(), -m_target.y(), -m_target.z());
+ viewMatrix.translate(-m_actualTarget.x(), -m_actualTarget.y(), -m_actualTarget.z());
setViewMatrix(viewMatrix);
}
@@ -713,9 +861,9 @@ void Q3DCameraPrivate::setBaseOrientation(const QVector3D &basePosition,
const QVector3D &target,
const QVector3D &baseUp)
{