summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-06-25 13:17:44 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-06-25 13:45:48 +0300
commitbb1c0b074db0cf6dbf4815f310b349e64e5422df (patch)
treee07fd7d4cb23ff0e5863a872449478b52eaf64e9
parenta2d8a5ae5a4b0f50ac420f713cce4cd7d9e1a024 (diff)
Axis abstraction
Axis related data is now stored in separate axis classes, but have not yet been exposed beyond QDataSet. Also contains unrelated gitignore change Change-Id: I130ee6557accfab672d5014f47bb74be08e6feef Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
-rw-r--r--.gitignore5
-rw-r--r--src/datavis3d/axis/axis.pri12
-rw-r--r--src/datavis3d/axis/qabstractaxis.cpp115
-rw-r--r--src/datavis3d/axis/qabstractaxis.h84
-rw-r--r--src/datavis3d/axis/qabstractaxis_p.h94
-rw-r--r--src/datavis3d/axis/qcategoryaxis.cpp91
-rw-r--r--src/datavis3d/axis/qcategoryaxis.h64
-rw-r--r--src/datavis3d/axis/qcategoryaxis_p.h74
-rw-r--r--src/datavis3d/axis/qvalueaxis.cpp70
-rw-r--r--src/datavis3d/axis/qvalueaxis.h62
-rw-r--r--src/datavis3d/axis/qvalueaxis_p.h74
-rw-r--r--src/datavis3d/common.pri4
-rw-r--r--src/datavis3d/datavis3d.pro1
-rw-r--r--src/datavis3d/engine/drawer.cpp5
-rw-r--r--src/datavis3d/engine/labelitem.cpp11
-rw-r--r--src/datavis3d/engine/labelitem_p.h1
-rw-r--r--src/datavis3d/engine/qdataset.cpp135
-rw-r--r--src/datavis3d/engine/qdataset.h1
-rw-r--r--src/datavis3d/engine/qdataset_p.h27
-rw-r--r--src/datavis3d/global/datavis3dglobal_p.h1
20 files changed, 806 insertions, 125 deletions
diff --git a/.gitignore b/.gitignore
index 24601177..064012c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -244,3 +244,8 @@ work
.obj/
+mkspecs/
+examples/spectrum/*.dll*
+examples/spectrum/*.exe*
+examples/spectrum/*.lib
+examples/spectrum/*.exp \ No newline at end of file
diff --git a/src/datavis3d/axis/axis.pri b/src/datavis3d/axis/axis.pri
new file mode 100644
index 00000000..7d5a1c6f
--- /dev/null
+++ b/src/datavis3d/axis/axis.pri
@@ -0,0 +1,12 @@
+HEADERS += \
+ $$PWD/qabstractaxis.h \
+ $$PWD/qabstractaxis_p.h \
+ $$PWD/qvalueaxis.h \
+ $$PWD/qvalueaxis_p.h \
+ $$PWD/qcategoryaxis.h \
+ $$PWD/qcategoryaxis_p.h
+
+SOURCES += \
+ $$PWD/qabstractaxis.cpp \
+ $$PWD/qvalueaxis.cpp \
+ $$PWD/qcategoryaxis.cpp
diff --git a/src/datavis3d/axis/qabstractaxis.cpp b/src/datavis3d/axis/qabstractaxis.cpp
new file mode 100644
index 00000000..31382bc6
--- /dev/null
+++ b/src/datavis3d/axis/qabstractaxis.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 "qabstractaxis.h"
+#include "qabstractaxis_p.h"
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate *d, QObject *parent) :
+ QObject(parent),
+ d_ptr(d)
+{
+}
+
+QAbstractAxis::~QAbstractAxis()
+{
+}
+
+QString QAbstractAxis::title() const
+{
+ return d_ptr->m_title;
+}
+
+QVector<QString> QAbstractAxis::labels() const
+{
+ return d_ptr->m_labels;
+}
+
+void QAbstractAxis::setTitle(QString title)
+{
+ if (d_ptr->m_title != title) {
+ d_ptr->m_title = title;
+ // Generate axis label texture
+ if (d_ptr->m_drawer)
+ d_ptr->m_drawer->generateLabelItem(&d_ptr->m_titleItem, title);
+ emit titleChanged(title);
+ }
+}
+
+// QAbstractAxisPrivate
+
+QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
+ : q_ptr(q),
+ m_drawer(0)
+{
+}
+
+QAbstractAxisPrivate::~QAbstractAxisPrivate()
+{
+ m_titleItem.clear();
+ for (int i = 0; i < m_labelItems.size(); i++)
+ m_labelItems[i].clear();
+}
+
+void QAbstractAxisPrivate::setDrawer(Drawer *drawer)
+{
+ m_drawer = drawer;
+ connect(m_drawer, SIGNAL(drawerChanged()), this, SLOT(updateTextures()));
+ updateTextures();
+}
+
+void QAbstractAxisPrivate::updateTextures()
+{
+ if (m_title.isEmpty())
+ m_titleItem.clear();
+ else
+ m_drawer->generateLabelItem(&m_titleItem, m_title);
+
+ updateLabels();
+}
+
+void QAbstractAxisPrivate::updateLabels()
+{
+ // Default implementation does nothing.
+}
+
+QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/axis/qabstractaxis.h b/src/datavis3d/axis/qabstractaxis.h
new file mode 100644
index 00000000..f64a4f35
--- /dev/null
+++ b/src/datavis3d/axis/qabstractaxis.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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 QABSTRACTAXIS_H
+#define QABSTRACTAXIS_H
+
+#include "qdatavis3dnamespace.h"
+#include <QObject>
+#include <QScopedPointer>
+#include <QVector>
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QAbstractAxisPrivate;
+
+class QT_DATAVIS3D_EXPORT QAbstractAxis : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
+
+protected:
+ explicit QAbstractAxis(QAbstractAxisPrivate *d, QObject *parent = 0);
+public:
+ virtual ~QAbstractAxis();
+
+ QString title() const;
+ QVector<QString> labels() const;
+
+public slots:
+ void setTitle(QString title);
+
+signals:
+ void titleChanged(QString newTitle);
+
+protected:
+ QScopedPointer<QAbstractAxisPrivate> d_ptr;
+
+private:
+ Q_DISABLE_COPY(QAbstractAxis)
+
+ friend class QDataSetPrivate;
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QABSTRACTAXIS_H
diff --git a/src/datavis3d/axis/qabstractaxis_p.h b/src/datavis3d/axis/qabstractaxis_p.h
new file mode 100644
index 00000000..82e0adbb
--- /dev/null
+++ b/src/datavis3d/axis/qabstractaxis_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//
+// 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.
+
+#include "qabstractaxis.h"
+#include "drawer_p.h"
+#include "labelitem_p.h"
+
+#ifndef QABSTRACTAXIS_P_H
+#define QABSTRACTAXIS_P_H
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QT_DATAVIS3D_EXPORT QAbstractAxisPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ QAbstractAxisPrivate(QAbstractAxis *q);
+ virtual ~QAbstractAxisPrivate();
+
+ void setDrawer(Drawer *drawer);
+ QVector<LabelItem> labelItems() { return m_labelItems; }
+ LabelItem titleItem() { return m_titleItem; }
+
+public slots:
+ void updateTextures();
+
+protected:
+ virtual void updateLabels();
+
+ QAbstractAxis *q_ptr;
+
+ QString m_title;
+ LabelItem m_titleItem;
+ Drawer *m_drawer; // not owned
+ QVector<QString> m_labels;
+ QVector<LabelItem> m_labelItems;
+
+ friend class QAbstractAxis;
+ friend class QValueAxis;
+ friend class QCategoryAxis;
+ friend class QDataSetPrivate;
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QABSTRACTAXIS_P_H
diff --git a/src/datavis3d/axis/qcategoryaxis.cpp b/src/datavis3d/axis/qcategoryaxis.cpp
new file mode 100644
index 00000000..30e466fc
--- /dev/null
+++ b/src/datavis3d/axis/qcategoryaxis.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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 "qcategoryaxis.h"
+#include "qcategoryaxis_p.h"
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+QCategoryAxis::QCategoryAxis(QObject *parent) :
+ QAbstractAxis(new QCategoryAxisPrivate(this), parent)
+{
+}
+
+QCategoryAxis::~QCategoryAxis()
+{
+}
+
+void QCategoryAxis::setLabels(const QVector<QString> &labels)
+{
+ int newSize(labels.size());
+ int oldSize(d_ptr->m_labels.size());
+
+ for (int i = oldSize - 1; i >= newSize; i--)
+ d_ptr->m_labelItems[i].clear();
+
+ d_ptr->m_labelItems.resize(newSize);
+
+ if (d_ptr->m_drawer) {
+ for (int i = 0; i < newSize; i++) {
+ if (i >= oldSize || labels.at(i) != d_ptr->m_labels.at(i))
+ d_ptr->m_drawer->generateLabelItem(&d_ptr->m_labelItems[i], labels.at(i));
+ }
+ }
+
+ d_ptr->m_labels = labels;
+}
+
+QCategoryAxisPrivate::QCategoryAxisPrivate(QCategoryAxis *q)
+ : QAbstractAxisPrivate(q)
+{
+}
+
+QCategoryAxisPrivate::~QCategoryAxisPrivate()
+{
+}
+
+void QCategoryAxisPrivate::updateLabels()
+{
+ for (int i = 0; i < m_labels.size(); i++)
+ m_drawer->generateLabelItem(&m_labelItems[i], m_labels.at(i));
+}
+
+QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/axis/qcategoryaxis.h b/src/datavis3d/axis/qcategoryaxis.h
new file mode 100644
index 00000000..e66b397f
--- /dev/null
+++ b/src/datavis3d/axis/qcategoryaxis.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** 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 QCATEGORYAXIS_H
+#define QCATEGORYAXIS_H
+
+#include "qabstractaxis.h"
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QT_DATAVIS3D_EXPORT QCategoryAxis : public QAbstractAxis
+{
+ Q_OBJECT
+public:
+ explicit QCategoryAxis(QObject *parent = 0);
+ ~QCategoryAxis();
+
+ void setLabels(const QVector<QString> &labels);
+
+private:
+ Q_DISABLE_COPY(QCategoryAxis)
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QCATEGORYAXIS_H
diff --git a/src/datavis3d/axis/qcategoryaxis_p.h b/src/datavis3d/axis/qcategoryaxis_p.h
new file mode 100644
index 00000000..174a2934
--- /dev/null
+++ b/src/datavis3d/axis/qcategoryaxis_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//
+// 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.
+
+#include "qcategoryaxis.h"
+#include "qabstractaxis_p.h"
+
+#ifndef QCATEGORYAXIS_P_H
+#define QCATEGORYAXIS_P_H
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QT_DATAVIS3D_EXPORT QCategoryAxisPrivate : public QAbstractAxisPrivate
+{
+ Q_OBJECT
+
+public:
+ QCategoryAxisPrivate(QCategoryAxis *q);
+ ~QCategoryAxisPrivate();
+
+protected:
+ void updateLabels();
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QCATEGORYAXIS_P_H
diff --git a/src/datavis3d/axis/qvalueaxis.cpp b/src/datavis3d/axis/qvalueaxis.cpp
new file mode 100644
index 00000000..757f8762
--- /dev/null
+++ b/src/datavis3d/axis/qvalueaxis.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 "qvalueaxis.h"
+#include "qvalueaxis_p.h"
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+QValueAxis::QValueAxis(QObject *parent) :
+ QAbstractAxis(new QValueAxisPrivate(this), parent)
+{
+}
+
+QValueAxis::~QValueAxis()
+{
+}
+
+QValueAxisPrivate::QValueAxisPrivate(QValueAxis *q)
+ : QAbstractAxisPrivate(q)
+{
+}
+
+QValueAxisPrivate::~QValueAxisPrivate()
+{
+}
+
+void QValueAxisPrivate::updateLabels()
+{
+ // TODO
+}
+
+QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/axis/qvalueaxis.h b/src/datavis3d/axis/qvalueaxis.h
new file mode 100644
index 00000000..bb496653
--- /dev/null
+++ b/src/datavis3d/axis/qvalueaxis.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 QVALUEAXIS_H
+#define QVALUEAXIS_H
+
+#include "qabstractaxis.h"
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QT_DATAVIS3D_EXPORT QValueAxis : public QAbstractAxis
+{
+ Q_OBJECT
+public:
+ explicit QValueAxis(QObject *parent = 0);
+ ~QValueAxis();
+
+private:
+ Q_DISABLE_COPY(QValueAxis)
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QVALUEAXIS_H
diff --git a/src/datavis3d/axis/qvalueaxis_p.h b/src/datavis3d/axis/qvalueaxis_p.h
new file mode 100644
index 00000000..50091e43
--- /dev/null
+++ b/src/datavis3d/axis/qvalueaxis_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//
+// 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.
+
+#include "qvalueaxis.h"
+#include "qabstractaxis_p.h"
+
+#ifndef QVALUEAXIS_P_H
+#define QVALUEAXIS_P_H
+
+QT_DATAVIS3D_BEGIN_NAMESPACE
+
+class QT_DATAVIS3D_EXPORT QValueAxisPrivate : public QAbstractAxisPrivate
+{
+ Q_OBJECT
+
+public:
+ QValueAxisPrivate(QValueAxis *q);
+ ~QValueAxisPrivate();
+
+protected:
+ void updateLabels();
+};
+
+QT_DATAVIS3D_END_NAMESPACE
+
+#endif // QVALUEAXIS_P_H
diff --git a/src/datavis3d/common.pri b/src/datavis3d/common.pri
index 8532fc77..8506b504 100644
--- a/src/datavis3d/common.pri
+++ b/src/datavis3d/common.pri
@@ -3,5 +3,5 @@
INCLUDEPATH += $$PWD/engine \
$$PWD/global \
- $$PWD/utils
-
+ $$PWD/utils \
+ $$PWD/axis
diff --git a/src/datavis3d/datavis3d.pro b/src/datavis3d/datavis3d.pro
index 82ae5618..eb2f6e8e 100644
--- a/src/datavis3d/datavis3d.pro
+++ b/src/datavis3d/datavis3d.pro
@@ -11,6 +11,7 @@ include($$PWD/common.pri)
include($$PWD/engine/engine.pri)
include($$PWD/global/global.pri)
include($$PWD/utils/utils.pri)
+include($$PWD/axis/axis.pri)
wince* {
# The Microsoft MIPS compiler crashes if /Og is specified.
diff --git a/src/datavis3d/engine/drawer.cpp b/src/datavis3d/engine/drawer.cpp
index 3fdaa58b..92d6b8db 100644
--- a/src/datavis3d/engine/drawer.cpp
+++ b/src/datavis3d/engine/drawer.cpp
@@ -308,10 +308,7 @@ void Drawer::generateLabelItem(LabelItem *item, const QString &text)
{
initializeOpenGL();
- // Delete previous texture, if there is one
- GLuint labelTexture = item->textureId();
- if (labelTexture)
- glDeleteTextures(1, &labelTexture);
+ item->clear();
// Create labels
// Print label into a QImage using QPainter
diff --git a/src/datavis3d/engine/labelitem.cpp b/src/datavis3d/engine/labelitem.cpp
index 7c76df5d..07798607 100644
--- a/src/datavis3d/engine/labelitem.cpp
+++ b/src/datavis3d/engine/labelitem.cpp
@@ -51,6 +51,8 @@ LabelItem::LabelItem()
LabelItem::~LabelItem()
{
+ // Note: Cannot delete texture here, unless we also implement
+ // reference counting for created textures.
}
void LabelItem::setSize(const QSize &size)
@@ -73,4 +75,13 @@ GLuint LabelItem::textureId()
return m_textureId;
}
+void LabelItem::clear()
+{
+ if (m_textureId) {
+ glDeleteTextures(1, &m_textureId);
+ m_textureId = 0;
+ }
+ m_size = QSize(0, 0);
+}
+
QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/engine/labelitem_p.h b/src/datavis3d/engine/labelitem_p.h
index 31666278..7a5f5f11 100644
--- a/src/datavis3d/engine/labelitem_p.h
+++ b/src/datavis3d/engine/labelitem_p.h
@@ -68,6 +68,7 @@ public:
QSize size();
void setTextureId(GLuint textureId);
GLuint textureId();
+ void clear();
private:
QSize m_size;
diff --git a/src/datavis3d/engine/qdataset.cpp b/src/datavis3d/engine/qdataset.cpp
index 38d8d0b4..1b2400b9 100644
--- a/src/datavis3d/engine/qdataset.cpp
+++ b/src/datavis3d/engine/qdataset.cpp
@@ -44,6 +44,10 @@
#include "qdatarow.h"
#include "qdatarow_p.h"
+#include "qvalueaxis.h"
+#include "qcategoryaxis.h"
+#include "qabstractaxis_p.h"
+
#include <QPoint>
#include <QString>
@@ -51,8 +55,6 @@
QT_DATAVIS3D_BEGIN_NAMESPACE
-const QString empty;
-
/*!
* \class QDataSet
* \inmodule QtDataVis3D
@@ -100,40 +102,12 @@ void QDataSet::setLabels(const QString &xAxis,
const QVector<QString> &labelsRow,
const QVector<QString> &labelsColumn)
{
- // skip empty labels, keep the previous ones
- if (xAxis != empty && d_ptr->m_xAxis != xAxis) {
- d_ptr->m_xAxis = xAxis;
- // Generate axis label texture
- if (d_ptr->m_drawer)
- d_ptr->m_drawer->generateLabelItem(&d_ptr->m_xAxisItem, xAxis);
- }
- if (zAxis != empty && d_ptr->m_zAxis != zAxis) {
- d_ptr->m_zAxis = zAxis;
- // Generate axis label texture
- if (d_ptr->m_drawer)
- d_ptr->m_drawer->generateLabelItem(&d_ptr->m_zAxisItem, zAxis);
- }
- if (yAxis != empty && d_ptr->m_yAxis != yAxis) {
- d_ptr->m_yAxis = yAxis;
- // Generate axis label texture
- if (d_ptr->m_drawer)
- d_ptr->m_drawer->generateLabelItem(&d_ptr->m_yAxisItem, yAxis);
- }
- d_ptr->m_labelsRow = labelsRow;
- d_ptr->m_labelsColumn = labelsColumn;
- // Generate row and column label textures
- if (d_ptr->m_drawer) {
- for (int itemCount = 0; itemCount < labelsColumn.size(); itemCount++) {
- d_ptr->m_labelItemsColumn.append(LabelItem());
- d_ptr->m_drawer->generateLabelItem(&d_ptr->m_labelItemsColumn[itemCount],
- labelsColumn.at(itemCount));
- }
- for (int itemCount = 0; itemCount < labelsRow.size(); itemCount++) {
- d_ptr->m_labelItemsRow.append(LabelItem());
- d_ptr->m_drawer->generateLabelItem(&d_ptr->m_labelItemsRow[itemCount],
- labelsRow.at(itemCount));
- }
- }
+ d_ptr->m_axisX->setTitle(xAxis);
+ d_ptr->m_axisZ->setTitle(zAxis);
+ d_ptr->m_axisY->setTitle(yAxis);
+
+ static_cast<QCategoryAxis *>(d_ptr->m_axisX)->setLabels(labelsRow);
+ static_cast<QCategoryAxis *>(d_ptr->m_axisZ)->setLabels(labelsColumn);
}
/*!
@@ -150,17 +124,9 @@ void QDataSet::addRow(QDataRow *row)
QDataSetPrivate::QDataSetPrivate(QDataSet *q)
: q_ptr(q),
m_set(QVector<QDataRow*>()),
- m_xAxis(QString()),
- m_zAxis(QString()),
- m_yAxis(QString()),
- m_labelsRow(QVector<QString>()),
- m_labelsColumn(QVector<QString>()),
- m_xAxisItem(LabelItem()),
- m_zAxisItem(LabelItem()),
- m_yAxisItem(LabelItem()),
- m_labelItemsRow(QVector<LabelItem>()),
- m_labelItemsColumn(QVector<LabelItem>()),
- m_drawer(0)
+ m_axisX(new QCategoryAxis()),
+ m_axisZ(new QCategoryAxis()),
+ m_axisY(new QValueAxis())
{
}
@@ -169,36 +135,13 @@ QDataSetPrivate::~QDataSetPrivate()
for (int itemCount = 0; itemCount < m_set.size(); itemCount++)
delete m_set.at(itemCount);
m_set.clear();
- // Delete axis textures
- GLuint textureid = m_xAxisItem.textureId();
- if (textureid)
- glDeleteTextures(1, &textureid);
- textureid = m_zAxisItem.textureId();
- if (textureid)
- glDeleteTextures(1, &textureid);
- textureid = m_yAxisItem.textureId();
- if (textureid)
- glDeleteTextures(1, &textureid);
- // Delete row and column textures
- for (int itemCount = 0; itemCount < m_labelItemsColumn.size(); itemCount++) {
- LabelItem item = m_labelItemsColumn.at(itemCount);
- textureid = item.textureId();
- if (textureid)
- glDeleteTextures(1, &textureid);
- }
- for (int itemCount = 0; itemCount < m_labelItemsRow.size(); itemCount++) {
- LabelItem item = m_labelItemsRow.at(itemCount);
- textureid = item.textureId();
- if (textureid)
- glDeleteTextures(1, &textureid);
- }
}
void QDataSetPrivate::setDrawer(Drawer *drawer)
{
- m_drawer = drawer;
- connect(m_drawer, SIGNAL(drawerChanged()), this, SLOT(updateTextures()));
- updateTextures();
+ m_axisX->d_ptr->setDrawer(drawer);
+ m_axisY->d_ptr->setDrawer(drawer);
+ m_axisZ->d_ptr->setDrawer(drawer);
}
QVector<QDataRow*> QDataSetPrivate::set()
@@ -216,37 +159,43 @@ QDataRow *QDataSetPrivate::getRow(int rowIndex)
QVector<QString> QDataSetPrivate::rowLabels()
{
- return m_labelsRow;
+ // TODO get rid of this function
+ return m_axisX->labels();
}
QVector<QString> QDataSetPrivate::columnLabels()
{
- return m_labelsColumn;
+ // TODO get rid of this function
+ return m_axisZ->labels();
}
QVector<LabelItem> QDataSetPrivate::rowLabelItems()
{
- return m_labelItemsRow;
+ // TODO get rid of this function
+ return m_axisX->d_ptr->labelItems();
}
QVector<LabelItem> QDataSetPrivate::columnLabelItems()
{
- return m_labelItemsColumn;
+ // TODO get rid of this function
+ return m_axisZ->d_ptr->labelItems();
}
void QDataSetPrivate::axisLabels(QString *xAxis, QString *zAxis, QString *yAxis)
{
- *xAxis = m_xAxis;
- *zAxis = m_zAxis;
- *yAxis = m_yAxis;
+ // TODO get rid of this function
+ *xAxis = m_axisX->title();
+ *zAxis = m_axisZ->title();
+ *yAxis = m_axisY->title();
}
void QDataSetPrivate::axisLabelItems(LabelItem *xAxisItem, LabelItem *zAxisItem,
LabelItem *yAxisItem)
{
- *xAxisItem = m_xAxisItem;
- *zAxisItem = m_zAxisItem;
- *yAxisItem = m_yAxisItem;
+ // TODO get rid of this function
+ *xAxisItem = m_axisX->d_ptr->titleItem();
+ *zAxisItem = m_axisZ->d_ptr->titleItem();
+ *yAxisItem = m_axisY->d_ptr->titleItem();
}
void QDataSetPrivate::verifySize(int colSize, int rowSize)
@@ -284,24 +233,4 @@ QPair<GLfloat, GLfloat> QDataSetPrivate::limitValues()
return limits;
}
-void QDataSetPrivate::updateTextures()
-{
- if (m_xAxis != empty)
- m_drawer->generateLabelItem(&m_xAxisItem, m_xAxis);
- if (m_zAxis != empty)
- m_drawer->generateLabelItem(&m_zAxisItem, m_zAxis);
- if (m_yAxis != empty)
- m_drawer->generateLabelItem(&m_yAxisItem, m_yAxis);
- for (int itemCount = 0; itemCount < m_labelsColumn.size(); itemCount++) {
- if (m_labelItemsColumn.size() < itemCount + 1)
- m_labelItemsColumn.append(LabelItem());
- m_drawer->generateLabelItem(&m_labelItemsColumn[itemCount], m_labelsColumn.at(itemCount));
- }
- for (int itemCount = 0; itemCount < m_labelsRow.size(); itemCount++) {
- if (m_labelItemsRow.size() < itemCount + 1)
- m_labelItemsRow.append(LabelItem());
- m_drawer->generateLabelItem(&m_labelItemsRow[itemCount], m_labelsRow.at(itemCount));
- }
-}
-
QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/engine/qdataset.h b/src/datavis3d/engine/qdataset.h
index e4054d35..b4f3bac4 100644
--- a/src/datavis3d/engine/qdataset.h
+++ b/src/datavis3d/engine/qdataset.h
@@ -62,6 +62,7 @@ public:
explicit QDataSet();
~QDataSet();
+ // TODO: Dataset specialized for bar chart. Generalize it to better serve other chart types.
Q_INVOKABLE void setLabels(const QString &xAxis = QString(),
const QString &zAxis = QString(),
const QString &yAxis = QString(),
diff --git a/src/datavis3d/engine/qdataset_p.h b/src/datavis3d/engine/qdataset_p.h
index 062494e9..1ef8b893 100644
--- a/src/datavis3d/engine/qdataset_p.h
+++ b/src/datavis3d/engine/qdataset_p.h
@@ -54,6 +54,7 @@
#include "datavis3dglobal_p.h"
#include "qdataset.h"
+#include "qabstractaxis.h"
#include "drawer_p.h"
#include "labelitem_p.h"
#include <QVector>
@@ -70,35 +71,29 @@ public:
~QDataSetPrivate();
void setDrawer(Drawer *drawer);
- QVector<QDataRow*> set();
+ QVector<QDataRow *> set();
QDataRow *getRow(int rowIndex);
+
+ // TODO: These functions need to go, these need to be asked from axes directly.
+ // Also, these are called a lot an each call constructs a new vector...
QVector<QString> rowLabels();
QVector<QString> columnLabels();
QVector<LabelItem> rowLabelItems();
QVector<LabelItem> columnLabelItems();
void axisLabels(QString *xAxis, QString *zAxis, QString *yAxis);
void axisLabelItems(LabelItem *xAxisItem, LabelItem *zAxisItem, LabelItem *yAxisItem);
+
void verifySize(int colSize, int rowSize = 0); // If rowSize is 0, don't verify rows
// first = min, second = max
QPair<GLfloat, GLfloat> limitValues();
-public Q_SLOTS:
- void updateTextures();
-
private:
QDataSet *q_ptr;
- QVector<QDataRow*> m_set;
- QString m_xAxis;
- QString m_zAxis;
- QString m_yAxis;
- QVector<QString> m_labelsRow;
- QVector<QString> m_labelsColumn;
- LabelItem m_xAxisItem;
- LabelItem m_zAxisItem;
- LabelItem m_yAxisItem;
- QVector<LabelItem> m_labelItemsRow;
- QVector<LabelItem> m_labelItemsColumn;
- Drawer *m_drawer;
+ QVector<QDataRow *> m_set;
+ QAbstractAxis *m_axisX;
+ QAbstractAxis *m_axisY;
+ QAbstractAxis *m_axisZ;
+
friend class QDataSet;
};
diff --git a/src/datavis3d/global/datavis3dglobal_p.h b/src/datavis3d/global/datavis3dglobal_p.h
index c0462e27..57d2e0e8 100644
--- a/src/datavis3d/global/datavis3dglobal_p.h
+++ b/src/datavis3d/global/datavis3dglobal_p.h
@@ -56,6 +56,7 @@
#include "qdatavis3dnamespace.h"
#include <QOpenGLFunctions>
#include <QVector3D>
+#include <QDebug>
//#define ROTATE_ZOOM_SELECTION