summaryrefslogtreecommitdiffstats
path: root/src/datavis3dqml2/declarativebars_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavis3dqml2/declarativebars_p.h')
-rw-r--r--src/datavis3dqml2/declarativebars_p.h228
1 files changed, 169 insertions, 59 deletions
diff --git a/src/datavis3dqml2/declarativebars_p.h b/src/datavis3dqml2/declarativebars_p.h
index 62dcc708..07dc21d4 100644
--- a/src/datavis3dqml2/declarativebars_p.h
+++ b/src/datavis3dqml2/declarativebars_p.h
@@ -1,41 +1,18 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** 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.
**
-** $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
+** 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. 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.
+** a written agreement between you and Digia.
**
-** 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$
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
**
****************************************************************************/
@@ -43,7 +20,7 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists purely as an
+// 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.
//
@@ -52,45 +29,178 @@
#ifndef DECLARATIVEBARS_P_H
#define DECLARATIVEBARS_P_H
-#include "QtDataVis3D/qdatavis3dglobal.h"
-#include "QtDataVis3D/qdatavis3namespace.h"
-#include <QString>
+#include "datavis3dglobal_p.h"
+#include "bars3dcontroller_p.h"
+#include "declarativebars_p.h"
+#include "qitemmodelbardatamapping.h"
+#include "qvalueaxis.h"
+#include "qcategoryaxis.h"
-QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+#include <QAbstractItemModel>
+#include <QQuickItem>
+#include <QObject>
+#include <QQuickWindow>
-class QDataRow;
+QT_DATAVIS3D_BEGIN_NAMESPACE
-class DeclarativeBarsCachedStatePrivate
+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 DeclarativeBarsCachedStatePrivate();
- ~DeclarativeBarsCachedStatePrivate();
+ 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);
- bool m_isSampleSpaceSet;
- int m_cachedState;
- int m_samplesRow;
- int m_samplesColumn;
- QString m_labelRow;
- QString m_labelColumn;
- QString m_labelHeight;
+ int columns() const;
+ void setColumns(int columns);
- QDataRow *m_dataRow;
+public slots:
+ // Used to detect when shadow quality changes autonomously due to e.g. resizing.
+ void handleShadowQualityUpdate(QDataVis::ShadowQuality quality);
- bool m_isSelectionModeSet;
- SelectionMode m_selectionMode;
+signals:
+ // Signals shadow quality changes.
+ void shadowQualityChanged(QDataVis::ShadowQuality quality);
- bool m_isLabelTransparencySet;
- LabelTransparency m_labelTransparency;
+protected:
+ Bars3dController *m_shared;
- bool m_isShadowQualitySet;
- ShadowQuality m_shadowQuality;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void wheelEvent(QWheelEvent *event);
- bool m_isGridSet;
- bool m_isGridEnabled;
+private:
+ QSize m_initialisedSize;
+ QDataVis::CameraPreset m_cameraPreset;
+ QDataVis::ColorTheme m_theme;
};
-QTENTERPRISE_DATAVIS3D_END_NAMESPACE
-QTENTERPRISE_DATAVIS3D_USE_NAMESPACE
+QT_DATAVIS3D_END_NAMESPACE
-#endif // DECLARATIVEBARS_P_H
+#endif