diff options
author | Mika Salmela <mika.salmela@digia.com> | 2014-08-21 09:55:23 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2014-08-21 10:09:04 +0300 |
commit | 8fab0a9cfcbed9deb47f4a9bd101434985c1c611 (patch) | |
tree | 4c884d30f6bed5ce7471a16884b734ab8a347763 /examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc | |
parent | 7ef676c7cbe5e3a960a66150794be3a862642073 (diff) |
Gradient to highlight series
Added a gradient to highlight series on textured surface example.
Change-Id: I2fc17dfa79f986cf5b651d964eb3bcf5d65f1c80
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc')
-rw-r--r-- | examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc b/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc index a4aa219e..483b8110 100644 --- a/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc +++ b/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc @@ -21,14 +21,15 @@ \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 Highlight an area of the surface \li Use custom input handler to enable zooming and panning + \li Highlight an area of the surface \endlist \image texturesurface-example.png @@ -64,6 +65,28 @@ 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 @@ -81,25 +104,23 @@ \snippet texturesurface/highlightseries.cpp 1 - \section1 Use custom input handler to enable zooming and panning + \section1 A gradient to the highlight series - 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. + 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. - \snippet texturesurface/custominputhandler.cpp 0 + For the gradient color positions we define proportional values. - 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/highlightseries.cpp 2 - \snippet texturesurface/custominputhandler.cpp 1 + The gradient modification is done on \c handleGradientChange method and we connect it to react to + changes on Y axis. - 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/surfacegraph.cpp 1 - \snippet texturesurface/custominputhandler.cpp 2 + When a change on Y axis max value happens, we calculate the gradient color positions. + + \snippet texturesurface/highlightseries.cpp 3 */ |