diff options
-rw-r--r-- | src/datavis3d/engine/q3dmaps.cpp | 180 | ||||
-rw-r--r-- | src/datavis3d/engine/q3dmaps.h | 44 | ||||
-rw-r--r-- | src/datavis3d/engine/q3dmaps_p.h | 1 | ||||
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2.pro | 8 | ||||
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2_plugin.cpp | 2 | ||||
-rw-r--r-- | src/datavis3dqml2/datavis3dqml2_plugin.h | 6 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemaps.cpp | 86 | ||||
-rw-r--r-- | src/datavis3dqml2/declarativemaps.h | 105 |
8 files changed, 327 insertions, 105 deletions
diff --git a/src/datavis3d/engine/q3dmaps.cpp b/src/datavis3d/engine/q3dmaps.cpp index 48c16f1f..ad864042 100644 --- a/src/datavis3d/engine/q3dmaps.cpp +++ b/src/datavis3d/engine/q3dmaps.cpp @@ -1213,6 +1213,20 @@ void Q3DMaps::setBarColor(QColor baseColor, QColor heightColor, bool uniform) d_ptr->m_theme->m_uniformColor = uniform; } +void Q3DMaps::setAreaSpecs(const QRect &areaRect, const QImage &image) +{ + d_ptr->calculateSceneScalingFactors(areaRect); + setImage(image); +} + +void Q3DMaps::setImage(const QImage &image) +{ + d_ptr->m_bgrHasAlpha = image.hasAlphaChannel(); + if (d_ptr->m_bgrTexture) + glDeleteTextures(1, &d_ptr->m_bgrTexture); + d_ptr->m_bgrTexture = d_ptr->m_textureHelper->create2DTexture(image, true, true); +} + void Q3DMaps::setSelectionMode(SelectionMode mode) { d_ptr->m_selectionMode = mode; @@ -1221,11 +1235,21 @@ void Q3DMaps::setSelectionMode(SelectionMode mode) //d_ptr->m_sceneViewPort = QRect(0, 0, width(), height()); } +SelectionMode Q3DMaps::selectionMode() +{ + return d_ptr->m_selectionMode; +} + void Q3DMaps::setWindowTitle(const QString &title) { setTitle(title); } +QString Q3DMaps::windowTitle() +{ + return title(); +} + void Q3DMaps::setFontSize(float fontsize) { d_ptr->m_font.setPointSizeF(fontsize); @@ -1233,6 +1257,11 @@ void Q3DMaps::setFontSize(float fontsize) d_ptr->m_updateLabels = true; } +float Q3DMaps::fontSize() +{ + return d_ptr->m_font.pointSizeF(); +} + void Q3DMaps::setFont(const QFont &font) { d_ptr->m_font = font; @@ -1240,6 +1269,11 @@ void Q3DMaps::setFont(const QFont &font) d_ptr->m_updateLabels = true; } +QFont Q3DMaps::font() +{ + return d_ptr->m_font; +} + void Q3DMaps::setLabelTransparency(LabelTransparency transparency) { d_ptr->m_labelTransparency = transparency; @@ -1247,9 +1281,75 @@ void Q3DMaps::setLabelTransparency(LabelTransparency transparency) d_ptr->m_updateLabels = true; } -void Q3DMaps::setGridEnabled(bool enable) +LabelTransparency Q3DMaps::labelTransparency() { - d_ptr->m_gridEnabled = enable; + return d_ptr->m_labelTransparency; +} + +void Q3DMaps::setShadowQuality(ShadowQuality quality) +{ + d_ptr->m_shadowQuality = quality; + switch (quality) { + case ShadowLow: + //qDebug() << "ShadowLow"; + d_ptr->m_shadowQualityToShader = 33.3f; + break; + case ShadowMedium: + //qDebug() << "ShadowMedium"; + d_ptr->m_shadowQualityToShader = 100.0f; + break; + case ShadowHigh: + //qDebug() << "ShadowHigh"; + d_ptr->m_shadowQualityToShader = 200.0f; + break; + default: + d_ptr->m_shadowQualityToShader = 0.0f; + break; + } + if (d_ptr->m_isInitialized) { +#if !defined(QT_OPENGL_ES_2) + if (d_ptr->m_shadowQuality > ShadowNone) { + // Re-init depth buffer + d_ptr->initDepthBuffer(); + // Re-init shaders + if (!d_ptr->m_theme->m_uniformColor) { + d_ptr->initShaders(QStringLiteral(":/shaders/vertexShadow"), + QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY")); + } else { + d_ptr->initShaders(QStringLiteral(":/shaders/vertexShadow"), + QStringLiteral(":/shaders/fragmentShadowNoTex")); + } + d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"), + QStringLiteral(":/shaders/fragmentShadow")); + } else { + // Re-init shaders + if (!d_ptr->m_theme->m_uniformColor) { + d_ptr->initShaders(QStringLiteral(":/shaders/vertex"), + QStringLiteral(":/shaders/fragmentColorOnY")); + } else { + d_ptr->initShaders(QStringLiteral(":/shaders/vertex"), + QStringLiteral(":/shaders/fragment")); + } + d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexTexture"), + QStringLiteral(":/shaders/fragmentTexture")); + } +#else + if (!d_ptr->m_theme->m_uniformColor) { + d_ptr->initShaders(QStringLiteral(":/shaders/vertexES2"), + QStringLiteral(":/shaders/fragmentColorOnYES2")); + } else { + d_ptr->initShaders(QStringLiteral(":/shaders/vertexES2"), + QStringLiteral(":/shaders/fragmentES2")); + } + d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexTexture"), // Same vertex shader ok for ES2 + QStringLiteral(":/shaders/fragmentTextureES2")); +#endif + } +} + +ShadowQuality Q3DMaps::shadowQuality() +{ + return d_ptr->m_shadowQuality; } bool Q3DMaps::addDataItem(QDataItem* dataItem) @@ -1356,81 +1456,6 @@ bool Q3DMaps::setData(QDataRow *dataRow) return true; } -void Q3DMaps::setAreaSpecs(const QRect &areaRect, const QImage &image) -{ - d_ptr->calculateSceneScalingFactors(areaRect); - setImage(image); -} - -void Q3DMaps::setImage(const QImage &image) -{ - d_ptr->m_bgrHasAlpha = image.hasAlphaChannel(); - if (d_ptr->m_bgrTexture) - glDeleteTextures(1, &d_ptr->m_bgrTexture); - d_ptr->m_bgrTexture = d_ptr->m_textureHelper->create2DTexture(image, true, true); -} - -void Q3DMaps::setShadowQuality(ShadowQuality quality) -{ - d_ptr->m_shadowQuality = quality; - switch (quality) { - case ShadowLow: - //qDebug() << "ShadowLow"; - d_ptr->m_shadowQualityToShader = 33.3f; - break; - case ShadowMedium: - //qDebug() << "ShadowMedium"; - d_ptr->m_shadowQualityToShader = 100.0f; - break; - case ShadowHigh: - //qDebug() << "ShadowHigh"; - d_ptr->m_shadowQualityToShader = 200.0f; - break; - default: - d_ptr->m_shadowQualityToShader = 0.0f; - break; - } - if (d_ptr->m_isInitialized) { -#if !defined(QT_OPENGL_ES_2) - if (d_ptr->m_shadowQuality > ShadowNone) { - // Re-init depth buffer - d_ptr->initDepthBuffer(); - // Re-init shaders - if (!d_ptr->m_theme->m_uniformColor) { - d_ptr->initShaders(QStringLiteral(":/shaders/vertexShadow"), - QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY")); - } else { - d_ptr->initShaders(QStringLiteral(":/shaders/vertexShadow"), - QStringLiteral(":/shaders/fragmentShadowNoTex")); - } - d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"), - QStringLiteral(":/shaders/fragmentShadow")); - } else { - // Re-init shaders - if (!d_ptr->m_theme->m_uniformColor) { - d_ptr->initShaders(QStringLiteral(":/shaders/vertex"), - QStringLiteral(":/shaders/fragmentColorOnY")); - } else { - d_ptr->initShaders(QStringLiteral(":/shaders/vertex"), - QStringLiteral(":/shaders/fragment")); - } - d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexTexture"), - QStringLiteral(":/shaders/fragmentTexture")); - } -#else - if (!d_ptr->m_theme->m_uniformColor) { - d_ptr->initShaders(QStringLiteral(":/shaders/vertexES2"), - QStringLiteral(":/shaders/fragmentColorOnYES2")); - } else { - d_ptr->initShaders(QStringLiteral(":/shaders/vertexES2"), - QStringLiteral(":/shaders/fragmentES2")); - } - d_ptr->initBackgroundShaders(QStringLiteral(":/shaders/vertexTexture"), // Same vertex shader ok for ES2 - QStringLiteral(":/shaders/fragmentTextureES2")); -#endif - } -} - Q3DMapsPrivate::Q3DMapsPrivate(Q3DMaps *q) : q_ptr(q), m_paintDevice(0), @@ -1477,7 +1502,6 @@ Q3DMapsPrivate::Q3DMapsPrivate(Q3DMaps *q) m_selectionFrameBuffer(0), m_selectionDepthBuffer(0), m_updateLabels(true), - m_gridEnabled(true), m_shadowQuality(ShadowLow), m_shadowQualityToShader(33.3f), m_bgrHasAlpha(false) diff --git a/src/datavis3d/engine/q3dmaps.h b/src/datavis3d/engine/q3dmaps.h index de59f27e..d9880d3a 100644 --- a/src/datavis3d/engine/q3dmaps.h +++ b/src/datavis3d/engine/q3dmaps.h @@ -46,6 +46,8 @@ #include "QtDataVis3D/qdatavis3namespace.h" #include "q3dwindow.h" +#include <QFont> + class QOpenGLShaderProgram; class QImage; class QRect; @@ -61,6 +63,10 @@ class LabelItem; class QTENTERPRISE_DATAVIS3D_EXPORT Q3DMaps : public Q3DWindow { Q_OBJECT + Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(float fontSize READ fontSize WRITE setFontSize) + public: enum AdjustmentDirection { AdjustHeight = 0, // map value to y @@ -120,33 +126,37 @@ public: // 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); - // TODO: valon siirto / asetus + // Set area specs + Q_INVOKABLE void setAreaSpecs(const QRect &areaRect, const QImage &image); + + // Set area image + Q_INVOKABLE void setImage(const QImage &image); + + // TODO: light placement API + // Change selection mode; single bar, bar and row, bar and column, or all - Q_INVOKABLE void setSelectionMode(SelectionMode mode); + void setSelectionMode(SelectionMode mode); + SelectionMode selectionMode(); // Set window title - Q_INVOKABLE void setWindowTitle(const QString &title); + void setWindowTitle(const QString &title); + QString windowTitle(); - // Font size adjustment (should it be in enum (smallest, smaller, small, normal, large, larger, largest), or just GLfloat? - Q_INVOKABLE void setFontSize(GLfloat fontsize); + // Font size adjustment + void setFontSize(float fontsize); + float fontSize(); // Set font - Q_INVOKABLE void setFont(const QFont &font); + void setFont(const QFont &font); + QFont font(); // Label transparency adjustment - Q_INVOKABLE void setLabelTransparency(LabelTransparency transparency); - - // Enable or disable background grid - Q_INVOKABLE void setGridEnabled(bool enable); - - // Set area specs - Q_INVOKABLE void setAreaSpecs(const QRect &areaRect, const QImage &image); - - // Set area image - Q_INVOKABLE void setImage(const QImage &image); + void setLabelTransparency(LabelTransparency transparency); + LabelTransparency labelTransparency(); // Adjust shadow quality - Q_INVOKABLE void setShadowQuality(ShadowQuality quality); + void setShadowQuality(ShadowQuality quality); + ShadowQuality shadowQuality(); protected: #if defined(Q_OS_ANDROID) diff --git a/src/datavis3d/engine/q3dmaps_p.h b/src/datavis3d/engine/q3dmaps_p.h index 707dabac..4c94d85e 100644 --- a/src/datavis3d/engine/q3dmaps_p.h +++ b/src/datavis3d/engine/q3dmaps_p.h @@ -163,7 +163,6 @@ public: GLuint m_selectionFrameBuffer; GLuint m_selectionDepthBuffer; bool m_updateLabels; - bool m_gridEnabled; Q3DMaps::AdjustmentDirection m_adjustDirection; ShadowQuality m_shadowQuality; GLfloat m_shadowQualityToShader; diff --git a/src/datavis3dqml2/datavis3dqml2.pro b/src/datavis3dqml2/datavis3dqml2.pro index 153aed9b..2f0c6300 100644 --- a/src/datavis3dqml2/datavis3dqml2.pro +++ b/src/datavis3dqml2/datavis3dqml2.pro @@ -15,8 +15,8 @@ SOURCES += \ datavis3dqml2_plugin.cpp \ datavisview.cpp \ scenerenderernode.cpp \ - declarativebars.cpp #\ - #declarative3dmaps.cpp \ + declarativebars.cpp \ + declarativemaps.cpp #\ #declarativedataitem.cpp \ #declarativedatarow.cpp \ #declarativedataset.cpp @@ -25,8 +25,8 @@ HEADERS += \ datavis3dqml2_plugin.h \ datavisview.h \ scenerenderernode_p.h \ - declarativebars.h #\ - #declarative3dmaps.h \ + declarativebars.h \ + declarativemaps.h #\ #declarativedataitem.h \ #declarativedatarow.h \ #declarativedataset.h diff --git a/src/datavis3dqml2/datavis3dqml2_plugin.cpp b/src/datavis3dqml2/datavis3dqml2_plugin.cpp index 49ab8355..9ff0c6c1 100644 --- a/src/datavis3dqml2/datavis3dqml2_plugin.cpp +++ b/src/datavis3dqml2/datavis3dqml2_plugin.cpp @@ -51,7 +51,7 @@ void Datavis3dqml2Plugin::registerTypes(const char *uri) // @uri com.digia.QtDataVis3D qmlRegisterType<DataVisView>(uri, 1, 0, "DataVisView"); qmlRegisterType<DeclarativeBars>(uri, 1, 0, "Bars"); - qmlRegisterType<Q3DMaps>(uri, 1, 0, "Maps"); + qmlRegisterType<DeclarativeMaps>(uri, 1, 0, "Maps"); qmlRegisterType<QDataItem>(uri, 1, 0, "DataItem"); qmlRegisterType<QDataRow>(uri, 1, 0, "DataRow"); qmlRegisterType<QDataSet>(uri, 1, 0, "DataSet"); diff --git a/src/datavis3dqml2/datavis3dqml2_plugin.h b/src/datavis3dqml2/datavis3dqml2_plugin.h index 467da543..9dcf00cb 100644 --- a/src/datavis3dqml2/datavis3dqml2_plugin.h +++ b/src/datavis3dqml2/datavis3dqml2_plugin.h @@ -44,13 +44,12 @@ #include "QtDataVis3D/qdatavis3dglobal.h" #include "QtDataVis3D/qdatavis3namespace.h" -#include "q3dmaps.h" #include "qdataitem.h" #include "qdatarow.h" #include "qdataset.h" #include "declarativebars.h" -//#include "declarative3dmaps.h" +#include "declarativemaps.h" //#include "declarativedataitem.h" //#include "declarativedatarow.h" //#include "declarativedataset.h" @@ -59,14 +58,13 @@ QTENTERPRISE_DATAVIS3D_USE_NAMESPACE -//Q_DECLARE_METATYPE(Declarative3DMaps *) //Q_DECLARE_METATYPE(DeclarativeDataItem *) //Q_DECLARE_METATYPE(DeclarativeDataRow *) //Q_DECLARE_METATYPE(DeclarativeDataSet *) Q_DECLARE_METATYPE(DeclarativeBars *) +Q_DECLARE_METATYPE(DeclarativeMaps *) -Q_DECLARE_METATYPE(Q3DMaps *) Q_DECLARE_METATYPE(QDataItem *) Q_DECLARE_METATYPE(QDataRow *) Q_DECLARE_METATYPE(QDataSet *) diff --git a/src/datavis3dqml2/declarativemaps.cpp b/src/datavis3dqml2/declarativemaps.cpp new file mode 100644 index 00000000..a5bb2318 --- /dev/null +++ b/src/datavis3dqml2/declarativemaps.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtDataVis3D module. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "declarativemaps.h" + +#include <QDebug> + +QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE + +DeclarativeMaps::DeclarativeMaps() +{ +} + +DeclarativeMaps::~DeclarativeMaps() +{ +} + +void DeclarativeMaps::setSelMode(DeclarativeMaps::SelectionMode mode) +{ + setSelectionMode(QtDataVis3D::SelectionMode(mode)); +} + +DeclarativeMaps::SelectionMode DeclarativeMaps::selMode() +{ + return DeclarativeMaps::SelectionMode(selectionMode()); +} + +void DeclarativeMaps::setTransparency(DeclarativeMaps::LabelTransparency transparency) +{ + setLabelTransparency(QtDataVis3D::LabelTransparency(transparency)); +} + +DeclarativeMaps::LabelTransparency DeclarativeMaps::transparency() +{ + return DeclarativeMaps::LabelTransparency(labelTransparency()); +} + +void DeclarativeMaps::setShadow(DeclarativeMaps::ShadowQuality quality) +{ + setShadowQuality(QtDataVis3D::ShadowQuality(quality)); +} + +DeclarativeMaps::ShadowQuality DeclarativeMaps::shadow() +{ + return DeclarativeMaps::ShadowQuality(shadowQuality()); +} + +QTENTERPRISE_DATAVIS3D_END_NAMESPACE diff --git a/src/datavis3dqml2/declarativemaps.h b/src/datavis3dqml2/declarativemaps.h new file mode 100644 index 00000000..aef00c76 --- /dev/null +++ b/src/datavis3dqml2/declarativemaps.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtDataVis3D module. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DECLARATIVEMAPS_H +#define DECLARATIVEMAPS_H + +#include "QtDataVis3D/qdatavis3dglobal.h" +#include "QtDataVis3D/qdatavis3namespace.h" +#include "q3dmaps.h" + +QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE + +class DeclarativeMaps : public Q3DMaps +{ + Q_OBJECT + Q_PROPERTY(SelectionMode selectionMode READ selMode WRITE setSelMode) + Q_PROPERTY(LabelTransparency labelTransparency READ transparency WRITE setTransparency) + Q_PROPERTY(ShadowQuality shadowQuality READ shadow WRITE setShadow) + Q_ENUMS(SelectionMode) + Q_ENUMS(ShadowQuality) + Q_ENUMS(LabelTransparency) + +public: + // Duplicated here to be able to use the same enums + enum SelectionMode { + ModeNone = 0, + ModeBar, + ModeBarAndRow, + ModeBarAndColumn, + ModeBarRowAndColumn, + ModeZoomRow, + ModeZoomColumn + }; + + enum ShadowQuality { + ShadowNone = 0, + ShadowLow = 1, + ShadowMedium = 3, + ShadowHigh = 5 + }; + + enum LabelTransparency { + TransparencyNone = 0, // Full solid, using colors from theme + TransparencyFromTheme, // Use colors and transparencies from theme + TransparencyNoBackground // Draw just text on transparent background + }; + +public: + explicit DeclarativeMaps(); + ~DeclarativeMaps(); + + // Change selection mode; single bar, bar and row, bar and column, or all + void setSelMode(DeclarativeMaps::SelectionMode mode); + DeclarativeMaps::SelectionMode selMode(); + + // Label transparency adjustment + void setTransparency(DeclarativeMaps::LabelTransparency transparency); + DeclarativeMaps::LabelTransparency transparency(); + + // Adjust shadow quality + void setShadow(DeclarativeMaps::ShadowQuality quality); + DeclarativeMaps::ShadowQuality shadow(); +}; + +QTENTERPRISE_DATAVIS3D_END_NAMESPACE + +#endif |