diff options
Diffstat (limited to 'src/datavis3dqml2')
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2.pro | 54 | ||||
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2_plugin.cpp | 48 | ||||
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2_plugin.h | 64 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativebars.cpp | 380 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativebars_p.h | 206 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativebarsrenderer.cpp | 86 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativebarsrenderer_p.h | 65 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemaps.cpp | 229 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemaps_p.h | 139 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemapsrenderer.cpp | 79 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemapsrenderer_p.h | 62 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativescatter.cpp | 328 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativescatter_p.h | 175 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativescatterrenderer.cpp | 87 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativescatterrenderer_p.h | 65 | ||||
-rw-r--r-- | src/datavis3dqml2/qmldir | 3 |
16 files changed, 0 insertions, 2070 deletions
diff --git a/src/datavis3dqml2/datavis3dqml2.pro b/src/datavis3dqml2/datavis3dqml2.pro deleted file mode 100644 index c994c5be..00000000 --- a/src/datavis3dqml2/datavis3dqml2.pro +++ /dev/null @@ -1,54 +0,0 @@ -TEMPLATE = lib -TARGET = datavis3dqml2 -QT += qml quick datavis3d -CONFIG += qt plugin - -TARGET = $$qtLibraryTarget($$TARGET) -uri = com.digia.QtDataVis3D - -static { - DEFINES += QT_DATAVIS3D_STATICLIB - CONFIG -= static staticlib -} - -# Input -INCLUDEPATH += ../datavis3d/engine \ - ../datavis3d/global \ - ../datavis3d/data - -SOURCES += \ - datavis3dqml2_plugin.cpp \ - declarativebars.cpp \ - declarativebarsrenderer.cpp \ - declarativescatter.cpp \ - declarativescatterrenderer.cpp \ - declarativemaps.cpp \ - declarativemapsrenderer.cpp - -HEADERS += \ - datavis3dqml2_plugin.h \ - declarativebars_p.h \ - declarativebarsrenderer_p.h \ - declarativescatter_p.h \ - declarativescatterrenderer_p.h \ - declarativemaps_p.h \ - declarativemapsrenderer_p.h - -OTHER_FILES = qmldir - -!equals(_PRO_FILE_PWD_, $$OUT_PWD) { - copy_qmldir.target = $$OUT_PWD/qmldir - copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir - copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" - QMAKE_EXTRA_TARGETS += copy_qmldir - PRE_TARGETDEPS += $$copy_qmldir.target -} - -qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} - diff --git a/src/datavis3dqml2/datavis3dqml2_plugin.cpp b/src/datavis3dqml2/datavis3dqml2_plugin.cpp deleted file mode 100644 index d1e534f8..00000000 --- a/src/datavis3dqml2/datavis3dqml2_plugin.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "datavis3dqml2_plugin.h" - -#include <qqml.h> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -void Datavis3dqml2Plugin::registerTypes(const char *uri) -{ - // @uri com.digia.QtDataVis3D - qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", - QLatin1String("Trying to create uncreatable: AbstractItemModel.")); - qmlRegisterUncreatableType<QDataVis>(uri, 1, 0, "DataVis", - QLatin1String("Trying to create uncreatable: DataVis.")); - qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", - QLatin1String("Trying to create uncreatable: AbstractAxis.")); - - qmlRegisterType<QItemModelBarDataMapping>(uri, 1, 0, "BarDataMapping"); - qmlRegisterType<QItemModelMapDataMapping>(uri, 1, 0, "MapDataMapping"); - qmlRegisterType<QItemModelScatterDataMapping>(uri, 1, 0, "ScatterDataMapping"); - - qmlRegisterType<DeclarativeBars>(uri, 1, 0, "Bars3D"); - qmlRegisterType<DeclarativeMaps>(uri, 1, 0, "Maps3D"); - qmlRegisterType<DeclarativeScatter>(uri, 1, 0, "Scatter3D"); - - qmlRegisterType<QValueAxis>(uri, 1, 0, "ValueAxis"); - qmlRegisterType<QCategoryAxis>(uri, 1, 0, "CategoryAxis"); -} - -QT_DATAVIS3D_END_NAMESPACE - diff --git a/src/datavis3dqml2/datavis3dqml2_plugin.h b/src/datavis3dqml2/datavis3dqml2_plugin.h deleted file mode 100644 index ac88e1b5..00000000 --- a/src/datavis3dqml2/datavis3dqml2_plugin.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 DATAVIS3DQML2_PLUGIN_H -#define DATAVIS3DQML2_PLUGIN_H - -#include "datavis3dglobal_p.h" -#include "declarativebars_p.h" -#include "declarativemaps_p.h" -#include "declarativescatter_p.h" -#include "qitemmodelbardatamapping.h" -#include "qitemmodelmapdatamapping.h" -#include "qitemmodelscatterdatamapping.h" -#include "qvalueaxis.h" -#include "qcategoryaxis.h" - -#include <QQmlExtensionPlugin> - -QT_DATAVIS3D_USE_NAMESPACE - -Q_DECLARE_METATYPE(DeclarativeBars *) -Q_DECLARE_METATYPE(DeclarativeMaps *) -Q_DECLARE_METATYPE(DeclarativeScatter *) - -Q_DECLARE_METATYPE(QItemModelBarDataMapping *) -Q_DECLARE_METATYPE(QItemModelMapDataMapping *) -Q_DECLARE_METATYPE(QItemModelScatterDataMapping *) -Q_DECLARE_METATYPE(QAbstractItemModel *) -Q_DECLARE_METATYPE(QDataVis *) - -Q_DECLARE_METATYPE(QAbstractAxis *) -Q_DECLARE_METATYPE(QCategoryAxis *) -Q_DECLARE_METATYPE(QValueAxis *) - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class Datavis3dqml2Plugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri); -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif // DATAVIS3DQML2_PLUGIN_H - diff --git a/src/datavis3dqml2/declarativebars.cpp b/src/datavis3dqml2/declarativebars.cpp deleted file mode 100644 index 2e4dbf04..00000000 --- a/src/datavis3dqml2/declarativebars.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativebars_p.h" -#include "declarativebarsrenderer_p.h" -#include "qitemmodelbardataproxy.h" -#include "qvalueaxis.h" - -QT_DATAVIS3D_BEGIN_NAMESPACE - -const QString smoothString(QStringLiteral("Smooth")); - -DeclarativeBars::DeclarativeBars(QQuickItem *parent) - : QQuickItem(parent), - m_shared(0), - m_initialisedSize(0, 0), - m_cameraPreset(QDataVis::NoPreset), - m_theme(QDataVis::ThemeDefault) -{ - setFlags(QQuickItem::ItemHasContents); - setAcceptedMouseButtons(Qt::AllButtons); - - // TODO: These seem to have no effect; find a way to activate anti-aliasing - setAntialiasing(true); - setSmooth(true); - - // Create the shared component on the main GUI thread. - m_shared = new Bars3dController(boundingRect().toRect()); - QObject::connect(m_shared, &Abstract3DController::shadowQualityChanged, this, - &DeclarativeBars::handleShadowQualityUpdate); - - m_shared->setDataProxy(new QItemModelBarDataProxy); -} - -DeclarativeBars::~DeclarativeBars() -{ - delete m_shared; -} - -void DeclarativeBars::handleShadowQualityUpdate(QDataVis::ShadowQuality quality) -{ - emit shadowQualityChanged(quality); -} - -void DeclarativeBars::classBegin() -{ - qDebug() << "classBegin"; -} - -void DeclarativeBars::componentComplete() -{ - qDebug() << "componentComplete"; -} - -QSGNode *DeclarativeBars::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) -{ - // If old node exists and has right size, reuse it. - if (oldNode && m_initialisedSize == boundingRect().size().toSize()) { - // Update bounding rectangle (that has same size as before). - static_cast<DeclarativeBarsRenderer *>( oldNode )->setRect(boundingRect()); - return oldNode; - } - - // Create a new render node when size changes or if there is no node yet - m_initialisedSize = boundingRect().size().toSize(); - - // Delete old node - if (oldNode) - delete oldNode; - - // Create a new one and set it's bounding rectangle - DeclarativeBarsRenderer *node = new DeclarativeBarsRenderer(window(), m_shared); - node->setRect(boundingRect()); - m_shared->setBoundingRect(boundingRect().toRect()); - return node; -} - -void DeclarativeBars::setupSampleSpace(int rowCount, int columnCount) -{ - m_shared->setupSampleSpace(rowCount, columnCount); -} - -void DeclarativeBars::setBarColor(QColor baseColor, QColor heightColor, QColor depthColor, - bool uniform) -{ - m_shared->setObjectColor(baseColor, heightColor, depthColor, uniform); -} - -void DeclarativeBars::setCameraPosition(qreal horizontal, qreal vertical, int distance) -{ - m_shared->setCameraPosition(GLfloat(horizontal), GLfloat(vertical), GLint(distance)); -} - -void DeclarativeBars::setData(QAbstractItemModel *data) -{ - static_cast<QItemModelBarDataProxy *>(m_shared->dataProxy())->setItemModel(data); -} - -QAbstractItemModel *DeclarativeBars::data() -{ - return static_cast<QItemModelBarDataProxy *>(m_shared->dataProxy())->itemModel(); -} - -void DeclarativeBars::setMapping(QItemModelBarDataMapping *mapping) -{ - static_cast<QItemModelBarDataProxy *>(m_shared->dataProxy())->setMapping(mapping); -} - -QCategoryAxis *DeclarativeBars::axisX() const -{ - return static_cast<QCategoryAxis *>(m_shared->axisX()); -} - -void DeclarativeBars::setAxisX(QCategoryAxis *axis) -{ - m_shared->setAxisX(axis); -} - -QValueAxis *DeclarativeBars::axisY() const -{ - return static_cast<QValueAxis *>(m_shared->axisY()); -} - -void DeclarativeBars::setAxisY(QValueAxis *axis) -{ - m_shared->setAxisY(axis); -} - -QCategoryAxis *DeclarativeBars::axisZ() const -{ - return static_cast<QCategoryAxis *>(m_shared->axisZ()); -} - -void DeclarativeBars::setAxisZ(QCategoryAxis *axis) -{ - m_shared->setAxisZ(axis); -} - -QItemModelBarDataMapping *DeclarativeBars::mapping() const -{ - return static_cast<QItemModelBarDataProxy *>(m_shared->dataProxy())->mapping(); -} - -void DeclarativeBars::setBarThickness(QSizeF thickness) -{ - m_shared->setBarSpecs(thickness, barSpacing(), isBarSpacingRelative()); -} - -QSizeF DeclarativeBars::barThickness() -{ - return m_shared->barThickness(); -} - -void DeclarativeBars::setBarSpacing(QSizeF spacing) -{ - m_shared->setBarSpecs(barThickness(), spacing, isBarSpacingRelative()); -} - -QSizeF DeclarativeBars::barSpacing() -{ - return m_shared->barSpacing(); -} - -void DeclarativeBars::setBarSpacingRelative(bool relative) -{ - m_shared->setBarSpecs(barThickness(), barSpacing(), relative); -} - -bool DeclarativeBars::isBarSpacingRelative() -{ - return m_shared->isBarSpecRelative(); -} - -void DeclarativeBars::setBarType(QDataVis::MeshStyle style) -{ - QString objFile = m_shared->meshFileName(); - bool smooth = objFile.endsWith(smoothString); - m_shared->setBarType(style, smooth); -} - -QDataVis::MeshStyle DeclarativeBars::barType() -{ - QString objFile = m_shared->meshFileName(); - if (objFile.contains("/sphere")) - return QDataVis::Spheres; - else - return QDataVis::Dots; -} - -void DeclarativeBars::setBarSmooth(bool smooth) -{ - QString objFile = m_shared->meshFileName(); - if (objFile.endsWith(smoothString)) { - if (smooth) - return; // Already smooth; do nothing - else // Rip Smooth off the end - objFile.resize(objFile.indexOf(smoothString)); - } else { - if (!smooth) // Already flat; do nothing - return; - else // Append Smooth to the end - objFile.append(smoothString); - } - m_shared->setMeshFileName(objFile); -} - -bool DeclarativeBars::barSmooth() -{ - QString objFile = m_shared->meshFileName(); - return objFile.endsWith(smoothString); -} - -void DeclarativeBars::setMeshFileName(const QString &objFileName) -{ - m_shared->setMeshFileName(objFileName); -} - -QString DeclarativeBars::meshFileName() -{ - return m_shared->meshFileName(); -} - -void DeclarativeBars::setCameraPreset(QDataVis::CameraPreset preset) -{ - // TODO: Implement correctly once "improved camera api" (QTRD-2122) is implemented - // We need to save this locally, as there are no getters for it in controller - m_cameraPreset = preset; - m_shared->setCameraPreset(preset); -} - -QDataVis::CameraPreset DeclarativeBars::cameraPreset() -{ - return m_cameraPreset; -} - -void DeclarativeBars::setTheme(QDataVis::ColorTheme theme) -{ - // TODO: Implement correctly once "user-modifiable themes" (QTRD-2120) is implemented - // We need to save this locally, as there are no getters for it in controller - m_theme = theme; - m_shared->setColorTheme(theme); -} - -QDataVis::ColorTheme DeclarativeBars::theme() -{ - return m_theme; -} - -void DeclarativeBars::setFontSize(float fontsize) -{ - m_shared->setFontSize(fontsize); -} - -float DeclarativeBars::fontSize() -{ - return m_shared->fontSize(); -} - -void DeclarativeBars::setFont(const QFont &font) -{ - m_shared->setFont(font); -} - -QFont DeclarativeBars::font() -{ - return m_shared->font(); -} - -void DeclarativeBars::setLabelTransparency(QDataVis::LabelTransparency transparency) -{ - m_shared->setLabelTransparency(transparency); -} - -QDataVis::LabelTransparency DeclarativeBars::labelTransparency() -{ - return m_shared->labelTransparency(); -} - -void DeclarativeBars::setGridVisible(bool visible) -{ - m_shared->setGridEnabled(visible); -} - -bool DeclarativeBars::isGridVisible() -{ - return m_shared->gridEnabled(); -} - -void DeclarativeBars::setBackgroundVisible(bool visible) -{ - m_shared->setBackgroundEnabled(visible); -} - -bool DeclarativeBars::isBackgroundVisible() -{ - return m_shared->backgroundEnabled(); -} - -void DeclarativeBars::setSelectionMode(QDataVis::SelectionMode mode) -{ - m_shared->setSelectionMode(mode); -} - -QDataVis::SelectionMode DeclarativeBars::selectionMode() -{ - return m_shared->selectionMode(); -} - -void DeclarativeBars::setShadowQuality(QDataVis::ShadowQuality quality) -{ - m_shared->setShadowQuality(quality); -} - -QDataVis::ShadowQuality DeclarativeBars::shadowQuality() -{ - return m_shared->shadowQuality(); -} - -int DeclarativeBars::rows() const -{ - return m_shared->rowCount(); -} - -void DeclarativeBars::setRows(int rows) -{ - setupSampleSpace(rows, columns()); -} - -int DeclarativeBars::columns() const -{ - return m_shared->columnCount(); -} - -void DeclarativeBars::setColumns(int columns) -{ - setupSampleSpace(rows(), columns); -} - -void DeclarativeBars::mousePressEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mousePressEvent(event, mousePos); -} - -void DeclarativeBars::mouseReleaseEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseReleaseEvent(event, mousePos); -} - -void DeclarativeBars::mouseMoveEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseMoveEvent(event, mousePos); -} - -void DeclarativeBars::wheelEvent(QWheelEvent *event) -{ - m_shared->wheelEvent(event); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativebars_p.h b/src/datavis3dqml2/declarativebars_p.h deleted file mode 100644 index 07dc21d4..00000000 --- a/src/datavis3dqml2/declarativebars_p.h +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVEBARS_P_H -#define DECLARATIVEBARS_P_H - -#include "datavis3dglobal_p.h" -#include "bars3dcontroller_p.h" -#include "declarativebars_p.h" -#include "qitemmodelbardatamapping.h" -#include "qvalueaxis.h" -#include "qcategoryaxis.h" - -#include <QAbstractItemModel> -#include <QQuickItem> -#include <QObject> -#include <QQuickWindow> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeBars : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QAbstractItemModel *data READ data WRITE setData) - Q_PROPERTY(QItemModelBarDataMapping *mapping READ mapping WRITE setMapping) - Q_PROPERTY(QCategoryAxis *axisX READ axisX WRITE setAxisX) - Q_PROPERTY(QValueAxis *axisY READ axisY WRITE setAxisY) - Q_PROPERTY(QCategoryAxis *axisZ READ axisZ WRITE setAxisZ) - Q_PROPERTY(QtDataVis3D::QDataVis::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) - Q_PROPERTY(QtDataVis3D::QDataVis::LabelTransparency labelTransparency READ labelTransparency WRITE setLabelTransparency) - Q_PROPERTY(QtDataVis3D::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality) - Q_PROPERTY(QtDataVis3D::QDataVis::MeshStyle barType READ barType WRITE setBarType) - Q_PROPERTY(QtDataVis3D::QDataVis::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset) - Q_PROPERTY(QtDataVis3D::QDataVis::ColorTheme theme READ theme WRITE setTheme) - Q_PROPERTY(QSizeF barThickness READ barThickness WRITE setBarThickness) - Q_PROPERTY(QSizeF barSpacing READ barSpacing WRITE setBarSpacing) - Q_PROPERTY(bool barSpacingRelative READ isBarSpacingRelative WRITE setBarSpacingRelative) - Q_PROPERTY(bool barSmooth READ barSmooth WRITE setBarSmooth) - Q_PROPERTY(QString meshFileName READ meshFileName WRITE setMeshFileName) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(float fontSize READ fontSize WRITE setFontSize) - Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible) - Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) - Q_PROPERTY(int rows READ rows WRITE setRows) - Q_PROPERTY(int columns READ columns WRITE setColumns) - Q_ENUMS(QtDataVis3D::QDataVis::SelectionMode) - Q_ENUMS(QtDataVis3D::QDataVis::ShadowQuality) - Q_ENUMS(QtDataVis3D::QDataVis::LabelTransparency) - Q_ENUMS(QtDataVis3D::QDataVis::MeshStyle) - Q_ENUMS(QtDataVis3D::QDataVis::CameraPreset) - Q_ENUMS(QtDataVis3D::QDataVis::ColorTheme) - -public: - explicit DeclarativeBars(QQuickItem *parent = 0); - ~DeclarativeBars(); - - void classBegin(); - void componentComplete(); - - // how many samples per row and column - Q_INVOKABLE void setupSampleSpace(int rowCount, int columnCount); - - // Set color if you don't want to use themes. Set uniform to false if you want the (height) - // color to change from bottom to top - Q_INVOKABLE void setBarColor(QColor baseColor, QColor heightColor, QColor depthColor, - bool uniform = true); - - // Set camera rotation if you don't want to use the presets (in horizontal (-180...180) and - // vertical (0...90) (or (-90...90) if there are negative values) angles and distance in - // percentage (10...500)) - Q_INVOKABLE void setCameraPosition(qreal horizontal, qreal vertical, int distance); - - // Add whole data set. - void setData(QAbstractItemModel *data); - QAbstractItemModel *data(); - - QItemModelBarDataMapping *mapping() const; - void setMapping(QItemModelBarDataMapping *mapping); - - QCategoryAxis *axisX() const; - void setAxisX(QCategoryAxis *axis); - QValueAxis *axisY() const; - void setAxisY(QValueAxis *axis); - QCategoryAxis *axisZ() const; - void setAxisZ(QCategoryAxis *axis); - - // Set bar thickness. Y -component sets the thickness of z -direction. - void setBarThickness(QSizeF thickness); - QSizeF barThickness(); - - // Set spacing between bars. Y -component sets the spacing of z -direction. - // If spacing is relative, 0.0f means side-to-side and 1.0f = one thickness in between. - void setBarSpacing(QSizeF spacing); - QSizeF barSpacing(); - - // Set bar spacing relative to thickness or absolute - void setBarSpacingRelative(bool relative); - bool isBarSpacingRelative(); - - // Bar type - void setBarType(QDataVis::MeshStyle style); - QDataVis::MeshStyle barType(); - - // Bar smoothing - void setBarSmooth(bool smooth); - bool barSmooth(); - - // override object type with own mesh - void setMeshFileName(const QString &objFileName); - QString meshFileName(); - - // Select preset camera placement - void setCameraPreset(QDataVis::CameraPreset preset); - QDataVis::CameraPreset cameraPreset(); - - // Set theme (object colors, shaders, window color, background colors, light intensity and text - // colors are affected) - void setTheme(QDataVis::ColorTheme theme); - QDataVis::ColorTheme theme(); - - // Change selection mode; single bar, bar and row, bar and column, or all - void setSelectionMode(QDataVis::SelectionMode mode); - QDataVis::SelectionMode selectionMode(); - - // Font size adjustment - void setFontSize(float fontsize); - float fontSize(); - - // Set font - void setFont(const QFont &font); - QFont font(); - - // Label transparency adjustment - void setLabelTransparency(QDataVis::LabelTransparency transparency); - QDataVis::LabelTransparency labelTransparency(); - - // Enable or disable background grid - void setGridVisible(bool visible); - bool isGridVisible(); - - // Enable or disable background mesh - void setBackgroundVisible(bool visible); - bool isBackgroundVisible(); - - // Adjust shadow quality - void setShadowQuality(QDataVis::ShadowQuality quality); - QDataVis::ShadowQuality shadowQuality(); - - int rows() const; - void setRows(int rows); - - int columns() const; - void setColumns(int columns); - -public slots: - // Used to detect when shadow quality changes autonomously due to e.g. resizing. - void handleShadowQualityUpdate(QDataVis::ShadowQuality quality); - -signals: - // Signals shadow quality changes. - void shadowQualityChanged(QDataVis::ShadowQuality quality); - -protected: - Bars3dController *m_shared; - - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - -private: - QSize m_initialisedSize; - QDataVis::CameraPreset m_cameraPreset; - QDataVis::ColorTheme m_theme; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/declarativebarsrenderer.cpp b/src/datavis3dqml2/declarativebarsrenderer.cpp deleted file mode 100644 index 1ecd4003..00000000 --- a/src/datavis3dqml2/declarativebarsrenderer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativebarsrenderer_p.h" - -#include <QtQuick/QQuickWindow> -#include <QtGui/QOpenGLFramebufferObject> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -DeclarativeBarsRenderer::DeclarativeBarsRenderer(QQuickWindow *window, Bars3dController *renderer) - : m_fbo(0), - m_texture(0), - m_window(window), - m_barsRenderer(renderer) -{ - connect(m_window, SIGNAL(beforeSynchronizing()), this, SLOT(synchDataToRenderer()), Qt::DirectConnection); - connect(m_window, SIGNAL(beforeRendering()), this, SLOT(renderFBO()), Qt::DirectConnection); -} - -DeclarativeBarsRenderer::~DeclarativeBarsRenderer() -{ - delete m_texture; - delete m_fbo; -} - -void DeclarativeBarsRenderer::synchDataToRenderer() -{ - m_barsRenderer->initializeOpenGL(); - m_barsRenderer->synchDataToRenderer(); -} - -void DeclarativeBarsRenderer::renderFBO() -{ - QSize size = rect().size().toSize(); - - // Create FBO - if (!m_fbo) { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::Depth); - m_fbo = new QOpenGLFramebufferObject(size, format); - m_texture = m_window->createTextureFromId(m_fbo->texture(), size); - - setTexture(m_texture); - - // Flip texture - // TODO: Can be gotten rid of once support for texture flipping becomes available (in Qt5.2) - QSize ts = m_texture->textureSize(); - QRectF sourceRect(0, 0, ts.width(), ts.height()); - float tmp = sourceRect.top(); - sourceRect.setTop(sourceRect.bottom()); - sourceRect.setBottom(tmp); - QSGGeometry *geometry = this->geometry(); - QSGGeometry::updateTexturedRectGeometry(geometry, rect(), - m_texture->convertToNormalizedSourceRect(sourceRect)); - markDirty(DirtyMaterial); - //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size(); - } - - // Call the shared rendering function - m_fbo->bind(); - - m_barsRenderer->render(m_fbo->handle()); - - m_fbo->release(); - - // New view is in the FBO, request repaint of scene graph - m_window->update(); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativebarsrenderer_p.h b/src/datavis3dqml2/declarativebarsrenderer_p.h deleted file mode 100644 index 1b40d3df..00000000 --- a/src/datavis3dqml2/declarativebarsrenderer_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVEBARSRENDERER_H -#define DECLARATIVEBARSRENDERER_H - -#include "datavis3dglobal_p.h" -#include "bars3dcontroller_p.h" -#include <qsgsimpletexturenode.h> - -class QOpenGLFramebufferObject; -class QSGTexture; -class QQuickWindow; - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeBarsRenderer : public QObject, public QSGSimpleTextureNode -{ - Q_OBJECT - -public: - DeclarativeBarsRenderer(QQuickWindow *window, Bars3dController *shared); - ~DeclarativeBarsRenderer(); - -public slots: - // Used to synch up data model from controller to renderer while main thread is locked - void synchDataToRenderer(); - // Renders view to FBO before render cycle starts. - void renderFBO(); - -private: - QOpenGLFramebufferObject *m_fbo; - QSGTexture *m_texture; - QQuickWindow *m_window; - Bars3dController *m_barsRenderer; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/declarativemaps.cpp b/src/datavis3dqml2/declarativemaps.cpp deleted file mode 100644 index 7be239f2..00000000 --- a/src/datavis3dqml2/declarativemaps.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativemaps_p.h" -#include "declarativemapsrenderer_p.h" -#include "qitemmodelmapdataproxy.h" - -QT_DATAVIS3D_BEGIN_NAMESPACE - -DeclarativeMaps::DeclarativeMaps(QQuickItem *parent) - : QQuickItem(parent), - m_shared(0), - m_initializedSize(0, 0) -{ - setFlags(QQuickItem::ItemHasContents); - setAcceptedMouseButtons(Qt::AllButtons); - - // TODO: These seem to have no effect; find a way to activate anti-aliasing - setAntialiasing(true); - setSmooth(true); -} - -DeclarativeMaps::~DeclarativeMaps() -{ - delete m_shared; -} - -void DeclarativeMaps::classBegin() -{ - qDebug() << "classBegin"; -} - -void DeclarativeMaps::componentComplete() -{ - qDebug() << "componentComplete"; -} - -QSGNode *DeclarativeMaps::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) -{ - if (!m_shared) { - m_shared = new Maps3DController(boundingRect().toRect()); - m_shared->setDataProxy(new QItemModelMapDataProxy); - m_shared->initializeOpenGL(); - } - - // If old node exists and has right size, reuse it. - if (oldNode && m_initializedSize == boundingRect().size().toSize()) { - // Update bounding rectangle (that has same size as before). - static_cast<DeclarativeMapsRenderer *>( oldNode )->setRect(boundingRect()); - return oldNode; - } - - // Create a new render node when size changes or if there is no node yet - m_initializedSize = boundingRect().size().toSize(); - - // Delete old node - if (oldNode) - delete oldNode; - - // Create a new one and set it's bounding rectangle - DeclarativeMapsRenderer *node = new DeclarativeMapsRenderer(window(), m_shared); - node->setRect(boundingRect()); - m_shared->setBoundingRect(boundingRect().toRect()); - return node; -} - -void DeclarativeMaps::setData(QAbstractItemModel *data) -{ - static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->setItemModel(data); -} - -QAbstractItemModel *DeclarativeMaps::data() -{ - return static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->itemModel(); -} - -void DeclarativeMaps::setBarSpecs(const QVector3D &thickness, - Q3DMaps::AdjustmentDirection direction) -{ - m_shared->setBarSpecs(thickness, direction); -} - -void DeclarativeMaps::setBarType(QDataVis::MeshStyle style, bool smooth) -{ - m_shared->setBarType(style, smooth); -} - -void DeclarativeMaps::setMeshFileName(const QString &objFileName) -{ - m_shared->setMeshFileName(objFileName); -} - -void DeclarativeMaps::setCameraPreset(QDataVis::CameraPreset preset) -{ - m_shared->setCameraPreset(preset); -} - -void DeclarativeMaps::setCameraPosition(GLfloat horizontal, GLfloat vertical, GLint distance) -{ - m_shared->setCameraPosition(horizontal, vertical, distance); -} - -void DeclarativeMaps::setTheme(QDataVis::ColorTheme theme) -{ - m_shared->setTheme(theme); -} - -void DeclarativeMaps::setBarColor(QColor baseColor, QColor heightColor, bool uniform) -{ - m_shared->setBarColor(baseColor, heightColor, uniform); -} - -void DeclarativeMaps::setAreaSpecs(const QRect &areaRect, const QImage &image) -{ - m_shared->setAreaSpecs(areaRect, image); -} - -void DeclarativeMaps::setImage(const QImage &image) -{ - m_shared->setImage(image); -} - -void DeclarativeMaps::setImage(const QString &imageUrl) -{ - m_shared->setImage(QImage(imageUrl)); -} - -void DeclarativeMaps::setSelectionMode(QDataVis::SelectionMode mode) -{ - m_shared->setSelectionMode(mode); -} - -QDataVis::SelectionMode DeclarativeMaps::selectionMode() -{ - return m_shared->selectionMode(); -} - -void DeclarativeMaps::setFontSize(float fontsize) -{ - m_shared->setFontSize(fontsize); -} - -float DeclarativeMaps::fontSize() -{ - return m_shared->fontSize(); -} - -void DeclarativeMaps::setFont(const QFont &font) -{ - m_shared->setFont(font); -} - -QFont DeclarativeMaps::font() -{ - return m_shared->font(); -} - -void DeclarativeMaps::setLabelTransparency(QDataVis::LabelTransparency transparency) -{ - m_shared->setLabelTransparency(transparency); -} - -QDataVis::LabelTransparency DeclarativeMaps::labelTransparency() -{ - return m_shared->labelTransparency(); -} - -void DeclarativeMaps::setShadowQuality(QDataVis::ShadowQuality quality) -{ - m_shared->setShadowQuality(quality); -} - -QDataVis::ShadowQuality DeclarativeMaps::shadowQuality() -{ - return m_shared->shadowQuality(); -} - -QItemModelMapDataMapping *DeclarativeMaps::mapping() const -{ - return static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->mapping(); -} - -void DeclarativeMaps::setMapping(QItemModelMapDataMapping *mapping) -{ - static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->setMapping(mapping); -} - -void DeclarativeMaps::mousePressEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mousePressEvent(event, mousePos); -} - -void DeclarativeMaps::mouseReleaseEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseReleaseEvent(event, mousePos); -} - -void DeclarativeMaps::mouseMoveEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseMoveEvent(event, mousePos); -} - -void DeclarativeMaps::wheelEvent(QWheelEvent *event) -{ - m_shared->wheelEvent(event); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativemaps_p.h b/src/datavis3dqml2/declarativemaps_p.h deleted file mode 100644 index ba2da0b3..00000000 --- a/src/datavis3dqml2/declarativemaps_p.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVEMAPS_P_H -#define DECLARATIVEMAPS_P_H - -#include "datavis3dglobal_p.h" -#include "maps3dcontroller_p.h" -#include "declarativemaps_p.h" -#include "qitemmodelmapdatamapping.h" - -#include <QAbstractItemModel> -#include <QQuickItem> -#include <QObject> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeMaps : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QAbstractItemModel *data READ data WRITE setData) - Q_PROPERTY(QtDataVis3D::QDataVis::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) - Q_PROPERTY(QtDataVis3D::QDataVis::LabelTransparency labelTransparency READ labelTransparency WRITE setLabelTransparency) - Q_PROPERTY(QtDataVis3D::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(float fontSize READ fontSize WRITE setFontSize) - Q_PROPERTY(QItemModelMapDataMapping *mapping READ mapping WRITE setMapping) - Q_ENUMS(QtDataVis3D::QDataVis::SelectionMode) - Q_ENUMS(QtDataVis3D::QDataVis::ShadowQuality) - Q_ENUMS(QtDataVis3D::QDataVis::LabelTransparency) - -public: - explicit DeclarativeMaps(QQuickItem *parent = 0); - ~DeclarativeMaps(); - - void classBegin(); - void componentComplete(); - - void setData(QAbstractItemModel *data); - QAbstractItemModel *data(); - - // bar specifications; base thickness in x, y and z, enum to indicate which direction is increased with value - // TODO: Start using thickness also in adjustment direction; use it as a relative value. - // For example, in AdjustAll mode setting thickness to (0.1f, 1.0f, 0.5f) would apply value to - // x at 10%, y at 100% and z at 50%. If a dimension is not included, given thickness states its absolute value. - Q_INVOKABLE void setBarSpecs(const QVector3D &thickness = QVector3D(1.0f, 1.0f, 1.0f), - Q3DMaps::AdjustmentDirection direction = Q3DMaps::AdjustHeight); - - // bar type; bars (=cubes), pyramids, cones, cylinders, balls, etc. - Q_INVOKABLE void setBarType(QDataVis::MeshStyle style, bool smooth = false); - - // override bar type with own mesh - Q_INVOKABLE void setMeshFileName(const QString &objFileName); - - // Select preset camera placement - Q_INVOKABLE void setCameraPreset(QDataVis::CameraPreset preset); - - // Set camera rotation if you don't want to use the presets (in horizontal (180...180) and - // vertical (0...90) angles and distance in percentage (10...500)) - Q_INVOKABLE void setCameraPosition(GLfloat horizontal, GLfloat vertical, GLint distance = 100); - - // Set theme (bar colors, shaders, window color, background colors, light intensity and text colors are affected) - Q_INVOKABLE void setTheme(QDataVis::ColorTheme theme); - - // Set color if you don't want to use themes. Set uniform to false if you want the (height) color to change from bottom to top - Q_INVOKABLE void setBarColor(QColor baseColor, QColor heightColor, bool uniform = true); - - // Set area specs - Q_INVOKABLE void setAreaSpecs(const QRect &areaRect, const QImage &image); - - // Set area image - Q_INVOKABLE void setImage(const QImage &image); - Q_INVOKABLE void setImage(const QString &imageUrl); - - // Change selection mode; single bar, bar and row, bar and column, or all - void setSelectionMode(QDataVis::SelectionMode mode); - QDataVis::SelectionMode selectionMode(); - - // Font size adjustment - void setFontSize(float fontsize); - float fontSize(); - - // Set font - void setFont(const QFont &font); - QFont font(); - - // Label transparency adjustment - void setLabelTransparency(QDataVis::LabelTransparency transparency); - QDataVis::LabelTransparency labelTransparency(); - - // Adjust shadow quality - void setShadowQuality(QDataVis::ShadowQuality quality); - QDataVis::ShadowQuality shadowQuality(); - - QItemModelMapDataMapping *mapping() const; - void setMapping(QItemModelMapDataMapping *mapping); - -protected: - Maps3DController *m_shared; - - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - -private: - QSize m_initializedSize; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/declarativemapsrenderer.cpp b/src/datavis3dqml2/declarativemapsrenderer.cpp deleted file mode 100644 index 6e8dc2db..00000000 --- a/src/datavis3dqml2/declarativemapsrenderer.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativemapsrenderer_p.h" - -#include <QtQuick/QQuickWindow> -#include <QtGui/QOpenGLFramebufferObject> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -DeclarativeMapsRenderer::DeclarativeMapsRenderer(QQuickWindow *window, Maps3DController *renderer) - : m_fbo(0), - m_texture(0), - m_window(window), - m_mapsRenderer(renderer) -{ - connect(m_window, SIGNAL(beforeRendering()), this, SLOT(render()), Qt::DirectConnection); -} - -DeclarativeMapsRenderer::~DeclarativeMapsRenderer() -{ - delete m_texture; - delete m_fbo; -} - -void DeclarativeMapsRenderer::render() -{ - QSize size = rect().size().toSize(); - - // Create FBO - if (!m_fbo) { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::Depth); - m_fbo = new QOpenGLFramebufferObject(size, format); - m_texture = m_window->createTextureFromId(m_fbo->texture(), size); - - setTexture(m_texture); - - // Flip texture - // TODO: Can be gotten rid of once support for texture flipping becomes available (in Qt5.2) - QSize ts = m_texture->textureSize(); - QRectF sourceRect(0, 0, ts.width(), ts.height()); - float tmp = sourceRect.top(); - sourceRect.setTop(sourceRect.bottom()); - sourceRect.setBottom(tmp); - QSGGeometry *geometry = this->geometry(); - QSGGeometry::updateTexturedRectGeometry(geometry, rect(), - m_texture->convertToNormalizedSourceRect(sourceRect)); - markDirty(DirtyMaterial); - //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size(); - } - - // Call the shared rendering function - m_fbo->bind(); - - m_mapsRenderer->render(m_fbo->handle()); - - m_fbo->release(); - - // New view is in the FBO, request repaint of scene graph - m_window->update(); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativemapsrenderer_p.h b/src/datavis3dqml2/declarativemapsrenderer_p.h deleted file mode 100644 index 755764c9..00000000 --- a/src/datavis3dqml2/declarativemapsrenderer_p.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVEMAPSRENDERER_P_H -#define DECLARATIVEMAPSRENDERER_P_H - -#include "datavis3dglobal_p.h" -#include "maps3dcontroller_p.h" -#include <qsgsimpletexturenode.h> - -class QOpenGLFramebufferObject; -class QSGTexture; -class QQuickWindow; - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeMapsRenderer : public QObject, public QSGSimpleTextureNode -{ - Q_OBJECT - -public: - DeclarativeMapsRenderer(QQuickWindow *window, Maps3DController *shared); - ~DeclarativeMapsRenderer(); - -public slots: - void render(); - -private: - QOpenGLFramebufferObject *m_fbo; - QSGTexture *m_texture; - QQuickWindow *m_window; - Maps3DController *m_mapsRenderer; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/declarativescatter.cpp b/src/datavis3dqml2/declarativescatter.cpp deleted file mode 100644 index 6731035e..00000000 --- a/src/datavis3dqml2/declarativescatter.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativescatter_p.h" -#include "declarativescatterrenderer_p.h" -#include "qitemmodelscatterdataproxy.h" - -QT_DATAVIS3D_BEGIN_NAMESPACE - -const QString smoothString(QStringLiteral("Smooth")); - -DeclarativeScatter::DeclarativeScatter(QQuickItem *parent) - : QQuickItem(parent), - m_shared(0), - m_initialisedSize(0, 0), - m_cameraPreset(QDataVis::NoPreset), - m_theme(QDataVis::ThemeDefault) -{ - setFlags(QQuickItem::ItemHasContents); - setAcceptedMouseButtons(Qt::AllButtons); - - // TODO: These seem to have no effect; find a way to activate anti-aliasing - setAntialiasing(true); - setSmooth(true); - - // Create the shared component on the main GUI thread. - m_shared = new Scatter3DController(boundingRect().toRect()); - QObject::connect(m_shared, &Abstract3DController::shadowQualityChanged, this, - &DeclarativeScatter::handleShadowQualityUpdate); - - m_shared->setDataProxy(new QItemModelScatterDataProxy); -} - -DeclarativeScatter::~DeclarativeScatter() -{ - delete m_shared; -} - -void DeclarativeScatter::handleShadowQualityUpdate(QDataVis::ShadowQuality quality) -{ - emit shadowQualityChanged(quality); -} - -void DeclarativeScatter::classBegin() -{ - qDebug() << "classBegin"; -} - -void DeclarativeScatter::componentComplete() -{ - qDebug() << "componentComplete"; -} - -QSGNode *DeclarativeScatter::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) -{ - // If old node exists and has right size, reuse it. - if (oldNode && m_initialisedSize == boundingRect().size().toSize()) { - // Update bounding rectangle (that has same size as before). - static_cast<DeclarativeScatterRenderer *>( oldNode )->setRect(boundingRect()); - return oldNode; - } - - // Create a new render node when size changes or if there is no node yet - m_initialisedSize = boundingRect().size().toSize(); - - // Delete old node - if (oldNode) - delete oldNode; - - // Create a new one and set it's bounding rectangle - DeclarativeScatterRenderer *node = new DeclarativeScatterRenderer(window(), m_shared); - node->setRect(boundingRect()); - m_shared->setBoundingRect(boundingRect().toRect()); - return node; -} - -void DeclarativeScatter::setCameraPosition(qreal horizontal, qreal vertical, int distance) -{ - m_shared->setCameraPosition(GLfloat(horizontal), GLfloat(vertical), GLint(distance)); -} - -void DeclarativeScatter::setObjectColor(QColor baseColor, QColor heightColor, QColor depthColor, - bool uniform) -{ - m_shared->setObjectColor(baseColor, heightColor, depthColor, uniform); -} - -void DeclarativeScatter::setData(QAbstractItemModel *data) -{ - static_cast<QItemModelScatterDataProxy *>(m_shared->dataProxy())->setItemModel(data); -} - -QAbstractItemModel *DeclarativeScatter::data() -{ - return static_cast<QItemModelScatterDataProxy *>(m_shared->dataProxy())->itemModel(); -} - -void DeclarativeScatter::setMapping(QItemModelScatterDataMapping *mapping) -{ - static_cast<QItemModelScatterDataProxy *>(m_shared->dataProxy())->setMapping(mapping); -} - -QItemModelScatterDataMapping *DeclarativeScatter::mapping() const -{ - return static_cast<QItemModelScatterDataProxy *>(m_shared->dataProxy())->mapping(); -} - -QValueAxis *DeclarativeScatter::axisX() const -{ - return static_cast<QValueAxis *>(m_shared->axisX()); -} - -void DeclarativeScatter::setAxisX(QValueAxis *axis) -{ - m_shared->setAxisX(axis); -} - -QValueAxis *DeclarativeScatter::axisY() const -{ - return static_cast<QValueAxis *>(m_shared->axisY()); -} - -void DeclarativeScatter::setAxisY(QValueAxis *axis) -{ - m_shared->setAxisY(axis); -} - -QValueAxis *DeclarativeScatter::axisZ() const -{ - return static_cast<QValueAxis *>(m_shared->axisZ()); -} - -void DeclarativeScatter::setAxisZ(QValueAxis *axis) -{ - m_shared->setAxisZ(axis); -} - -void DeclarativeScatter::setObjectType(QDataVis::MeshStyle style) -{ - QString objFile = m_shared->meshFileName(); - bool smooth = objFile.endsWith(smoothString); - m_shared->setObjectType(style, smooth); -} - -QDataVis::MeshStyle DeclarativeScatter::objectType() -{ - QString objFile = m_shared->meshFileName(); - if (objFile.contains("/sphere")) - return QDataVis::Spheres; - else - return QDataVis::Dots; -} - -void DeclarativeScatter::setObjectSmooth(bool smooth) -{ - QString objFile = m_shared->meshFileName(); - if (objFile.endsWith(smoothString)) { - if (smooth) - return; // Already smooth; do nothing - else // Rip Smooth off the end - objFile.resize(objFile.indexOf(smoothString)); - } else { - if (!smooth) // Already flat; do nothing - return; - else // Append Smooth to the end - objFile.append(smoothString); - } - m_shared->setMeshFileName(objFile); -} - -bool DeclarativeScatter::objectSmooth() -{ - QString objFile = m_shared->meshFileName(); - return objFile.endsWith(smoothString); -} - -void DeclarativeScatter::setMeshFileName(const QString &objFileName) -{ - m_shared->setMeshFileName(objFileName); -} - -QString DeclarativeScatter::meshFileName() -{ - return m_shared->meshFileName(); -} - -void DeclarativeScatter::setCameraPreset(QDataVis::CameraPreset preset) -{ - // TODO: Implement correctly once "improved camera api" (QTRD-2122) is implemented - // We need to save this locally, as there are no getters for it in controller - m_cameraPreset = preset; - m_shared->setCameraPreset(preset); -} - -QDataVis::CameraPreset DeclarativeScatter::cameraPreset() -{ - return m_cameraPreset; -} - -void DeclarativeScatter::setTheme(QDataVis::ColorTheme theme) -{ - // TODO: Implement correctly once "user-modifiable themes" (QTRD-2120) is implemented - // We need to save this locally, as there are no getters for it in controller - m_theme = theme; - m_shared->setColorTheme(theme); - - // TODO: Investigate why the beforeSynchronizing() signal requires update and is not sent automatically when this value changes, - // but is sent wen e.g. enable/disable background changes. - update(); -} - -QDataVis::ColorTheme DeclarativeScatter::theme() -{ - return m_theme; -} - -void DeclarativeScatter::setFontSize(float fontsize) -{ - m_shared->setFontSize(fontsize); -} - -float DeclarativeScatter::fontSize() -{ - return m_shared->fontSize(); -} - -void DeclarativeScatter::setFont(const QFont &font) -{ - m_shared->setFont(font); -} - -QFont DeclarativeScatter::font() -{ - return m_shared->font(); -} - -void DeclarativeScatter::setLabelTransparency(QDataVis::LabelTransparency transparency) -{ - m_shared->setLabelTransparency(transparency); -} - -QDataVis::LabelTransparency DeclarativeScatter::labelTransparency() -{ - return m_shared->labelTransparency(); -} - -void DeclarativeScatter::setGridVisible(bool visible) -{ - m_shared->setGridEnabled(visible); -} - -bool DeclarativeScatter::isGridVisible() -{ - return m_shared->gridEnabled(); -} - -void DeclarativeScatter::setBackgroundVisible(bool visible) -{ - m_shared->setBackgroundEnabled(visible); -} - -bool DeclarativeScatter::isBackgroundVisible() -{ - return m_shared->backgroundEnabled(); -} - -void DeclarativeScatter::setSelectionMode(QDataVis::SelectionMode mode) -{ - m_shared->setSelectionMode(mode); -} - -QDataVis::SelectionMode DeclarativeScatter::selectionMode() -{ - return m_shared->selectionMode(); -} - -void DeclarativeScatter::setShadowQuality(QDataVis::ShadowQuality quality) -{ - m_shared->setShadowQuality(quality); -} - -QDataVis::ShadowQuality DeclarativeScatter::shadowQuality() -{ - return m_shared->shadowQuality(); -} - -void DeclarativeScatter::mousePressEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mousePressEvent(event, mousePos); -} - -void DeclarativeScatter::mouseReleaseEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseReleaseEvent(event, mousePos); -} - -void DeclarativeScatter::mouseMoveEvent(QMouseEvent *event) -{ - QPoint mousePos = event->pos(); - //mousePos.setY(height() - mousePos.y()); - m_shared->mouseMoveEvent(event, mousePos); -} - -void DeclarativeScatter::wheelEvent(QWheelEvent *event) -{ - m_shared->wheelEvent(event); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativescatter_p.h b/src/datavis3dqml2/declarativescatter_p.h deleted file mode 100644 index dce5c021..00000000 --- a/src/datavis3dqml2/declarativescatter_p.h +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVESCATTER_P_H -#define DECLARATIVESCATTER_P_H - -#include "datavis3dglobal_p.h" -#include "scatter3dcontroller_p.h" -#include "declarativescatter_p.h" -#include "qitemmodelscatterdatamapping.h" -#include "qvalueaxis.h" - -#include <QAbstractItemModel> -#include <QQuickItem> -#include <QObject> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeScatter : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QAbstractItemModel *data READ data WRITE setData) - Q_PROPERTY(QItemModelScatterDataMapping *mapping READ mapping WRITE setMapping) - Q_PROPERTY(QValueAxis *axisX READ axisX WRITE setAxisX) - Q_PROPERTY(QValueAxis *axisY READ axisY WRITE setAxisY) - Q_PROPERTY(QValueAxis *axisZ READ axisZ WRITE setAxisZ) - Q_PROPERTY(QtDataVis3D::QDataVis::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) - Q_PROPERTY(QtDataVis3D::QDataVis::LabelTransparency labelTransparency READ labelTransparency WRITE setLabelTransparency) - Q_PROPERTY(QtDataVis3D::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality) - Q_PROPERTY(QtDataVis3D::QDataVis::MeshStyle objectType READ objectType WRITE setObjectType) - Q_PROPERTY(QtDataVis3D::QDataVis::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset) - Q_PROPERTY(QtDataVis3D::QDataVis::ColorTheme theme READ theme WRITE setTheme) - Q_PROPERTY(bool objectSmooth READ objectSmooth WRITE setObjectSmooth) - Q_PROPERTY(QString meshFileName READ meshFileName WRITE setMeshFileName) - Q_PROPERTY(QFont font READ font WRITE setFont) - Q_PROPERTY(float fontSize READ fontSize WRITE setFontSize) - Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible) - Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) - Q_ENUMS(QtDataVis3D::QDataVis::SelectionMode) - Q_ENUMS(QtDataVis3D::QDataVis::ShadowQuality) - Q_ENUMS(QtDataVis3D::QDataVis::LabelTransparency) - Q_ENUMS(QtDataVis3D::QDataVis::MeshStyle) - Q_ENUMS(QtDataVis3D::QDataVis::CameraPreset) - Q_ENUMS(QtDataVis3D::QDataVis::ColorTheme) - -public: - explicit DeclarativeScatter(QQuickItem *parent = 0); - ~DeclarativeScatter(); - - void classBegin(); - void componentComplete(); - - // Set camera rotation if you don't want to use the presets (in horizontal (-180...180) and - // vertical (-90...90) angles and distance in percentage (10...500)) - Q_INVOKABLE void setCameraPosition(qreal horizontal, qreal vertical, int distance); - - // Set color if you don't want to use themes. Set uniform to false if you want the (height) - // color to change from bottom to top - Q_INVOKABLE void setObjectColor(QColor baseColor, QColor heightColor, QColor depthColor, - bool uniform = true); - - // Add whole data set. - void setData(QAbstractItemModel *data); - QAbstractItemModel *data(); - - QItemModelScatterDataMapping *mapping() const; - void setMapping(QItemModelScatterDataMapping *mapping); - - QValueAxis *axisX() const; - void setAxisX(QValueAxis *axis); - QValueAxis *axisY() const; - void setAxisY(QValueAxis *axis); - QValueAxis *axisZ() const; - void setAxisZ(QValueAxis *axis); - - // Object type - void setObjectType(QDataVis::MeshStyle style); - QDataVis::MeshStyle objectType(); - - // Object smoothing - void setObjectSmooth(bool smooth); - bool objectSmooth(); - - // override object type with own mesh - void setMeshFileName(const QString &objFileName); - QString meshFileName(); - - // Select preset camera placement - void setCameraPreset(QDataVis::CameraPreset preset); - QDataVis::CameraPreset cameraPreset(); - - // Set theme (object colors, shaders, window color, background colors, light intensity and text - // colors are affected) - void setTheme(QDataVis::ColorTheme theme); - QDataVis::ColorTheme theme(); - - // Change selection mode - void setSelectionMode(QDataVis::SelectionMode mode); - QDataVis::SelectionMode selectionMode(); - - // Font size adjustment - void setFontSize(float fontsize); - float fontSize(); - - // Set font - void setFont(const QFont &font); - QFont font(); - - // Label transparency adjustment - void setLabelTransparency(QDataVis::LabelTransparency transparency); - QDataVis::LabelTransparency labelTransparency(); - - // Enable or disable background grid - void setGridVisible(bool visible); - bool isGridVisible(); - - // Enable or disable background mesh - void setBackgroundVisible(bool visible); - bool isBackgroundVisible(); - - // Adjust shadow quality - void setShadowQuality(QDataVis::ShadowQuality quality); - QDataVis::ShadowQuality shadowQuality(); - -public slots: - // Used to detect when shadow quality changes autonomously due to e.g. resizing. - void handleShadowQualityUpdate(QDataVis::ShadowQuality quality); - -signals: - // Signals shadow quality changes. - void shadowQualityChanged(QDataVis::ShadowQuality quality); - -protected: - Scatter3DController *m_shared; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - -private: - QSize m_initialisedSize; - QDataVis::CameraPreset m_cameraPreset; - QDataVis::ColorTheme m_theme; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/declarativescatterrenderer.cpp b/src/datavis3dqml2/declarativescatterrenderer.cpp deleted file mode 100644 index 23c59c26..00000000 --- a/src/datavis3dqml2/declarativescatterrenderer.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 "declarativescatterrenderer_p.h" - -#include <QtQuick/QQuickWindow> -#include <QtGui/QOpenGLFramebufferObject> - -QT_DATAVIS3D_BEGIN_NAMESPACE - -DeclarativeScatterRenderer::DeclarativeScatterRenderer(QQuickWindow *window, - Scatter3DController *renderer) - : m_fbo(0), - m_texture(0), - m_window(window), - m_scatterRenderer(renderer) -{ - connect(m_window, SIGNAL(beforeSynchronizing()), this, SLOT(synchDataToRenderer()), Qt::DirectConnection); - connect(m_window, SIGNAL(beforeRendering()), this, SLOT(renderFBO()), Qt::DirectConnection); -} - -DeclarativeScatterRenderer::~DeclarativeScatterRenderer() -{ - delete m_texture; - delete m_fbo; -} - -void DeclarativeScatterRenderer::synchDataToRenderer() -{ - m_scatterRenderer->initializeOpenGL(); - m_scatterRenderer->synchDataToRenderer(); -} - -void DeclarativeScatterRenderer::renderFBO() -{ - QSize size = rect().size().toSize(); - - // Create FBO - if (!m_fbo) { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::Depth); - m_fbo = new QOpenGLFramebufferObject(size, format); - m_texture = m_window->createTextureFromId(m_fbo->texture(), size); - - setTexture(m_texture); - - // Flip texture - // TODO: Can be gotten rid of once support for texture flipping becomes available (in Qt5.2) - QSize ts = m_texture->textureSize(); - QRectF sourceRect(0, 0, ts.width(), ts.height()); - float tmp = sourceRect.top(); - sourceRect.setTop(sourceRect.bottom()); - sourceRect.setBottom(tmp); - QSGGeometry *geometry = this->geometry(); - QSGGeometry::updateTexturedRectGeometry(geometry, rect(), - m_texture->convertToNormalizedSourceRect(sourceRect)); - markDirty(DirtyMaterial); - //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size(); - } - - // Call the shared rendering function - m_fbo->bind(); - - m_scatterRenderer->render(m_fbo->handle()); - - m_fbo->release(); - - // New view is in the FBO, request repaint of scene graph - m_window->update(); -} - -QT_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativescatterrenderer_p.h b/src/datavis3dqml2/declarativescatterrenderer_p.h deleted file mode 100644 index 498b1d83..00000000 --- a/src/datavis3dqml2/declarativescatterrenderer_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 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 QtDataVis3D 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 QtDataVis3D 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 DECLARATIVESCATTERRENDERER_P_H -#define DECLARATIVESCATTERRENDERER_P_H - -#include "datavis3dglobal_p.h" -#include "scatter3dcontroller_p.h" -#include <qsgsimpletexturenode.h> - -class QOpenGLFramebufferObject; -class QSGTexture; -class QQuickWindow; - -QT_DATAVIS3D_BEGIN_NAMESPACE - -class DeclarativeScatterRenderer : public QObject, public QSGSimpleTextureNode -{ - Q_OBJECT - -public: - DeclarativeScatterRenderer(QQuickWindow *window, Scatter3DController *shared); - ~DeclarativeScatterRenderer(); - -public slots: - // Used to synch up data model from controller to renderer while main thread is locked - void synchDataToRenderer(); - // Renders view to FBO before render cycle starts. - void renderFBO(); - -private: - QOpenGLFramebufferObject *m_fbo; - QSGTexture *m_texture; - QQuickWindow *m_window; - Scatter3DController *m_scatterRenderer; -}; - -QT_DATAVIS3D_END_NAMESPACE - -#endif diff --git a/src/datavis3dqml2/qmldir b/src/datavis3dqml2/qmldir deleted file mode 100644 index 876138db..00000000 --- a/src/datavis3dqml2/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module com.digia.QtDataVis3D -plugin datavis3dqml2 - |