diff options
Diffstat (limited to 'examples/datavisualization/texturesurface')
17 files changed, 0 insertions, 1205 deletions
diff --git a/examples/datavisualization/texturesurface/CMakeLists.txt b/examples/datavisualization/texturesurface/CMakeLists.txt deleted file mode 100644 index 5da2e03e..00000000 --- a/examples/datavisualization/texturesurface/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(texturesurface LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS DataVisualization) - -qt_add_executable(texturesurface - custominputhandler.cpp custominputhandler.h - highlightseries.cpp highlightseries.h - main.cpp - surfacegraph.cpp surfacegraph.h - topographicseries.cpp topographicseries.h -) -set_target_properties(texturesurface PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(texturesurface PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - Qt::DataVisualization -) - -set_source_files_properties("maptexture.jpg" - PROPERTIES QT_RESOURCE_ALIAS "maptexture" -) -set_source_files_properties("topography.png" - PROPERTIES QT_RESOURCE_ALIAS "topography" -) -set(texturedsurface_resource_files - "maptexture.jpg" - "topography.png" -) - -qt6_add_resources(texturesurface "texturedsurface" - PREFIX - "/maps" - FILES - ${texturedsurface_resource_files} -) - -install(TARGETS texturesurface - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/datavisualization/texturesurface/custominputhandler.cpp b/examples/datavisualization/texturesurface/custominputhandler.cpp deleted file mode 100644 index e8e693a0..00000000 --- a/examples/datavisualization/texturesurface/custominputhandler.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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->angleDelta().y()); - - 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 deleted file mode 100644 index 0cb53102..00000000 --- a/examples/datavisualization/texturesurface/custominputhandler.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CUSTOMINPUTHANDLER_H -#define CUSTOMINPUTHANDLER_H - -#include <QtDataVisualization/Q3DInputHandler> -#include <QtDataVisualization/QAbstract3DGraph> -#include <QtDataVisualization/QValue3DAxis> -#include "highlightseries.h" - -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 Binary files differdeleted file mode 100644 index 76819607..00000000 --- a/examples/datavisualization/texturesurface/doc/images/texturesurface-example.png +++ /dev/null diff --git a/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc b/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc deleted file mode 100644 index c1cdc208..00000000 --- a/examples/datavisualization/texturesurface/doc/src/texturesurface.qdoc +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 - - \include examples-run.qdocinc - - \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 deleted file mode 100644 index ef6da1b4..00000000 --- a/examples/datavisualization/texturesurface/highlightseries.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "highlightseries.h" - -//! [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 deleted file mode 100644 index c489e50c..00000000 --- a/examples/datavisualization/texturesurface/highlightseries.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef HIGHLIGHTSERIES_H -#define HIGHLIGHTSERIES_H - -#include <QtDataVisualization/QSurface3DSeries> - -#include "topographicseries.h" - -class HighlightSeries : public QSurface3DSeries -{ - Q_OBJECT -public: - explicit HighlightSeries(); - ~HighlightSeries(); - - void setTopographicSeries(TopographicSeries *series); - inline void setMinHeight(float height) { m_minHeight = height; } - -public Q_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 deleted file mode 100644 index 749daf31..00000000 --- a/examples/datavisualization/texturesurface/license.txt +++ /dev/null @@ -1,77 +0,0 @@ -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 deleted file mode 100644 index fc45247f..00000000 --- a/examples/datavisualization/texturesurface/main.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 <QtWidgets/QMessageBox> -#include <QtGui/QScreen> -#include <QtGui/QPainter> - -int main(int argc, char **argv) -{ - qputenv("QSG_RHI_BACKEND", "opengl"); - QApplication app(argc, argv); - Q3DSurface *graph = new Q3DSurface(); - QWidget *container = QWidget::createWindowContainer(graph); - - if (!graph->hasContext()) { - QMessageBox msgBox; - msgBox.setText("Couldn't initialize the OpenGL context."); - msgBox.exec(); - return -1; - } - - 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("Highlight 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 Binary files differdeleted file mode 100644 index ae5d66eb..00000000 --- a/examples/datavisualization/texturesurface/maptexture.jpg +++ /dev/null diff --git a/examples/datavisualization/texturesurface/surfacegraph.cpp b/examples/datavisualization/texturesurface/surfacegraph.cpp deleted file mode 100644 index 84999bc6..00000000 --- a/examples/datavisualization/texturesurface/surfacegraph.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "surfacegraph.h" -#include "topographicseries.h" - -#include <QtDataVisualization/QValue3DAxis> -#include <QtDataVisualization/Q3DTheme> - -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 deleted file mode 100644 index 20a39f81..00000000 --- a/examples/datavisualization/texturesurface/surfacegraph.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SURFACEGRAPH_H -#define SURFACEGRAPH_H - -#include <QtDataVisualization/Q3DSurface> -#include <QtDataVisualization/QSurface3DSeries> -#include <QtWidgets/QSlider> -#include "topographicseries.h" -#include "highlightseries.h" - -#include "custominputhandler.h" - -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 deleted file mode 100644 index 94b96d24..00000000 --- a/examples/datavisualization/texturesurface/texturedsurface.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<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 deleted file mode 100644 index efef1944..00000000 --- a/examples/datavisualization/texturesurface/texturesurface.pro +++ /dev/null @@ -1,25 +0,0 @@ -android|ios|winrt { - error( "This example is not supported for android, ios, or winrt." ) -} - -!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 deleted file mode 100644 index 01b6625b..00000000 --- a/examples/datavisualization/texturesurface/topographicseries.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "topographicseries.h" - -//! [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); - setBaseColor(Qt::white); -} - -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 deleted file mode 100644 index 7137a858..00000000 --- a/examples/datavisualization/texturesurface/topographicseries.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TOPOGRAPHICSERIES_H -#define TOPOGRAPHICSERIES_H - -#include <QtDataVisualization/QSurface3DSeries> - -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 Q_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 Binary files differdeleted file mode 100644 index 9349cdb3..00000000 --- a/examples/datavisualization/texturesurface/topography.png +++ /dev/null |