1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36 
37 #include "qmaprouteobjectqsg_p_p.h"
38 
39 QT_BEGIN_NAMESPACE
40 
QMapRouteObjectPrivateQSG(QGeoMapObject * q)41 QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(QGeoMapObject *q)
42     : QMapRouteObjectPrivate(q)
43 {
44     QScopedPointer<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(q));
45     m_polyline.swap(poly);
46     m_polyline->m_componentCompleted = true;
47 }
48 
QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate & other)49 QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate &other)
50     : QMapRouteObjectPrivate(other)
51 {
52     QScopedPointer<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(other.q));
53     m_polyline.swap(poly);
54     m_polyline->m_componentCompleted = true;
55     setRoute(other.declarativeGeoRoute());
56 }
57 
~QMapRouteObjectPrivateQSG()58 QMapRouteObjectPrivateQSG::~QMapRouteObjectPrivateQSG()
59 {
60     if (m_map)
61         m_map->removeMapObject(q);
62 }
63 
updateGeometry()64 void QMapRouteObjectPrivateQSG::updateGeometry()
65 {
66     m_polyline->updateGeometry();
67 }
68 
updateMapObjectNode(QSGNode * oldNode,VisibleNode ** visibleNode,QSGNode * root,QQuickWindow * window)69 QSGNode *QMapRouteObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
70                                                         VisibleNode **visibleNode,
71                                                         QSGNode *root,
72                                                         QQuickWindow *window)
73 {
74     return m_polyline->updateMapObjectNode(oldNode, visibleNode, root, window);
75 }
76 
setRoute(const QDeclarativeGeoRoute * route)77 void QMapRouteObjectPrivateQSG::setRoute(const QDeclarativeGeoRoute *route)
78 {
79     const QList<QGeoCoordinate> &path = route->route().path();
80     m_polyline->setColor(QColor("deepskyblue")); // ToDo: support MapParameters for this
81     m_polyline->setWidth(4);
82     m_polyline->setPath(path); // SGNodeChanged emitted by m_polyline
83 }
84 
clone()85 QGeoMapObjectPrivate *QMapRouteObjectPrivateQSG::clone()
86 {
87     return new QMapRouteObjectPrivateQSG(static_cast<QMapRouteObjectPrivate &>(*this));
88 }
89 
setMap(QGeoMap * map)90 void QMapRouteObjectPrivateQSG::setMap(QGeoMap *map)
91 {
92     QGeoMapObjectPrivate::setMap(map);
93     m_polyline->setMap(map);
94 }
95 
96 
setVisible(bool visible)97 void QMapRouteObjectPrivateQSG::setVisible(bool visible)
98 {
99     m_visible = visible;
100     m_polyline->setVisible(visible);
101 }
102 
geoShape() const103 QGeoShape QMapRouteObjectPrivateQSG::geoShape() const
104 {
105     return m_polyline->geoShape();
106 }
107 
108 QT_END_NAMESPACE
109