summaryrefslogtreecommitdiffstats
path: root/src/datavis3dqml2/declarativemaps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavis3dqml2/declarativemaps.cpp')
-rw-r--r--src/datavis3dqml2/declarativemaps.cpp241
1 files changed, 192 insertions, 49 deletions
diff --git a/src/datavis3dqml2/declarativemaps.cpp b/src/datavis3dqml2/declarativemaps.cpp
index a5bb2318..7be239f2 100644
--- a/src/datavis3dqml2/declarativemaps.cpp
+++ b/src/datavis3dqml2/declarativemaps.cpp
@@ -1,86 +1,229 @@
/****************************************************************************
**
-** 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
**
****************************************************************************/
-#include "declarativemaps.h"
-
-#include <QDebug>
+#include "declarativemaps_p.h"
+#include "declarativemapsrenderer_p.h"
+#include "qitemmodelmapdataproxy.h"
-QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
+QT_DATAVIS3D_BEGIN_NAMESPACE
-DeclarativeMaps::DeclarativeMaps()
+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();
}
-void DeclarativeMaps::setSelMode(DeclarativeMaps::SelectionMode mode)
+QItemModelMapDataMapping *DeclarativeMaps::mapping() const
{
- setSelectionMode(QtDataVis3D::SelectionMode(mode));
+ return static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->mapping();
}
-DeclarativeMaps::SelectionMode DeclarativeMaps::selMode()
+void DeclarativeMaps::setMapping(QItemModelMapDataMapping *mapping)
{
- return DeclarativeMaps::SelectionMode(selectionMode());
+ static_cast<QItemModelMapDataProxy *>(m_shared->dataProxy())->setMapping(mapping);
}
-void DeclarativeMaps::setTransparency(DeclarativeMaps::LabelTransparency transparency)
+void DeclarativeMaps::mousePressEvent(QMouseEvent *event)
{
- setLabelTransparency(QtDataVis3D::LabelTransparency(transparency));
+ QPoint mousePos = event->pos();
+ //mousePos.setY(height() - mousePos.y());
+ m_shared->mousePressEvent(event, mousePos);
}
-DeclarativeMaps::LabelTransparency DeclarativeMaps::transparency()
+void DeclarativeMaps::mouseReleaseEvent(QMouseEvent *event)
{
- return DeclarativeMaps::LabelTransparency(labelTransparency());
+ QPoint mousePos = event->pos();
+ //mousePos.setY(height() - mousePos.y());
+ m_shared->mouseReleaseEvent(event, mousePos);
}
-void DeclarativeMaps::setShadow(DeclarativeMaps::ShadowQuality quality)
+void DeclarativeMaps::mouseMoveEvent(QMouseEvent *event)
{
- setShadowQuality(QtDataVis3D::ShadowQuality(quality));
+ QPoint mousePos = event->pos();
+ //mousePos.setY(height() - mousePos.y());
+ m_shared->mouseMoveEvent(event, mousePos);
}
-DeclarativeMaps::ShadowQuality DeclarativeMaps::shadow()
+void DeclarativeMaps::wheelEvent(QWheelEvent *event)
{
- return DeclarativeMaps::ShadowQuality(shadowQuality());
+ m_shared->wheelEvent(event);
}
-QTENTERPRISE_DATAVIS3D_END_NAMESPACE
+QT_DATAVIS3D_END_NAMESPACE