Marble

GeoDataAbstractView.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Gaurav Gupta <1989.gaurav@googlemail.com>
4// SPDX-FileCopyrightText: 2013 Dennis Nienhüser <nienhueser@kde.org>
5//
6
7#include "GeoDataAbstractView.h"
8
9#include "GeoDataCamera.h"
10#include "GeoDataLookAt.h"
11#include "GeoDataTimeSpan.h"
12#include "GeoDataTimeStamp.h"
13#include "GeoDataTypes.h"
14
15namespace Marble
16{
17
18class GeoDataAbstractViewPrivate
19{
20public:
21 GeoDataAbstractViewPrivate();
22
23 GeoDataTimeSpan m_timeSpan;
24 GeoDataTimeStamp m_timeStamp;
25 AltitudeMode m_altitudeMode;
26};
27
28GeoDataAbstractViewPrivate::GeoDataAbstractViewPrivate()
29 : m_timeSpan()
30 , m_timeStamp()
31 , m_altitudeMode(ClampToGround)
32{
33 // do nothing
34}
35
36GeoDataAbstractView::GeoDataAbstractView()
37 : d(new GeoDataAbstractViewPrivate())
38{
39 // do nothing
40}
41
42GeoDataAbstractView::~GeoDataAbstractView()
43{
44 delete d;
45}
46
47GeoDataAbstractView::GeoDataAbstractView(const GeoDataAbstractView &other)
48 : GeoDataObject(other)
49 , d(new GeoDataAbstractViewPrivate(*other.d))
50{
51 // nothing to do
52}
53
54GeoDataAbstractView &GeoDataAbstractView::operator=(const GeoDataAbstractView &other)
55{
56 GeoDataObject::operator=(other);
57 *d = *other.d;
58 return *this;
59}
60
61bool GeoDataAbstractView::operator==(const GeoDataAbstractView &other) const
62{
63 if (nodeType() != other.nodeType()) {
64 return false;
65 }
66
67 if (nodeType() == GeoDataTypes::GeoDataCameraType) {
68 const auto &thisCam = static_cast<const GeoDataCamera &>(*this);
69 const auto &otherCam = static_cast<const GeoDataCamera &>(other);
70
71 return thisCam == otherCam;
72 } else if (nodeType() == GeoDataTypes::GeoDataLookAtType) {
73 const auto &thisLookAt = static_cast<const GeoDataLookAt &>(*this);
74 const auto &otherLookAt = static_cast<const GeoDataLookAt &>(other);
75
76 return thisLookAt == otherLookAt;
77 }
78
79 return false;
80}
81
82GeoDataCoordinates GeoDataAbstractView::coordinates() const
83{
84 if (nodeType() == GeoDataTypes::GeoDataLookAtType) {
85 const auto lookAt = static_cast<const GeoDataLookAt *>(this);
86 if (lookAt) {
87 return lookAt->coordinates();
88 }
89 } else if (nodeType() == GeoDataTypes::GeoDataCameraType) {
90 const auto camera = static_cast<const GeoDataCamera *>(this);
91 if (camera) {
92 return camera->coordinates();
93 }
94 }
95 return {};
96}
97
98bool GeoDataAbstractView::equals(const GeoDataAbstractView &other) const
99{
100 return GeoDataObject::equals(other) && d->m_timeSpan == other.d->m_timeSpan && d->m_timeStamp == other.d->m_timeStamp
101 && d->m_altitudeMode == other.d->m_altitudeMode;
102}
103
104const GeoDataTimeSpan &GeoDataAbstractView::timeSpan() const
105{
106 return d->m_timeSpan;
107}
108
109GeoDataTimeSpan &GeoDataAbstractView::timeSpan()
110{
111 return d->m_timeSpan;
112}
113
114void GeoDataAbstractView::setTimeSpan(const GeoDataTimeSpan &timeSpan)
115{
116 d->m_timeSpan = timeSpan;
117}
118
119GeoDataTimeStamp &GeoDataAbstractView::timeStamp()
120{
121 return d->m_timeStamp;
122}
123
124const GeoDataTimeStamp &GeoDataAbstractView::timeStamp() const
125{
126 return d->m_timeStamp;
127}
128
129void GeoDataAbstractView::setTimeStamp(const GeoDataTimeStamp &timeStamp)
130{
131 d->m_timeStamp = timeStamp;
132}
133
134AltitudeMode GeoDataAbstractView::altitudeMode() const
135{
136 return d->m_altitudeMode;
137}
138
139void GeoDataAbstractView::setAltitudeMode(const AltitudeMode altitudeMode)
140{
141 d->m_altitudeMode = altitudeMode;
142}
143
144}
Q_SCRIPTABLE QString camera()
Binds a QML item to a specific geodetic location in screen coordinates.
@ ClampToGround
Altitude always sticks to ground level.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.