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 "GeoDataTypes.h"
12#include "GeoDataTimeSpan.h"
13#include "GeoDataTimeStamp.h"
14
15namespace Marble {
16
17class GeoDataAbstractViewPrivate
18{
19public:
20 GeoDataAbstractViewPrivate();
21
22 GeoDataTimeSpan m_timeSpan;
23 GeoDataTimeStamp m_timeStamp;
24 AltitudeMode m_altitudeMode;
25};
26
27GeoDataAbstractViewPrivate::GeoDataAbstractViewPrivate() :
28 m_timeSpan(),
29 m_timeStamp(),
30 m_altitudeMode( ClampToGround )
31{
32 // do nothing
33}
34
35GeoDataAbstractView::GeoDataAbstractView() :
36 d( new GeoDataAbstractViewPrivate() )
37{
38 // do nothing
39}
40
41GeoDataAbstractView::~GeoDataAbstractView()
42{
43 delete d;
44}
45
46GeoDataAbstractView::GeoDataAbstractView( const GeoDataAbstractView &other ) :
47 GeoDataObject( other ),
48 d( new GeoDataAbstractViewPrivate( *other.d ) )
49{
50 // nothing to do
51}
52
53GeoDataAbstractView &GeoDataAbstractView::operator =( const GeoDataAbstractView &other )
54{
55 GeoDataObject::operator=( other );
56 *d = *other.d;
57 return *this;
58}
59
60bool GeoDataAbstractView::operator==(const GeoDataAbstractView &other) const
61{
62 if (nodeType() != other.nodeType()) {
63 return false;
64 }
65
66 if (nodeType() == GeoDataTypes::GeoDataCameraType) {
67 const GeoDataCamera &thisCam = static_cast<const GeoDataCamera &>(*this);
68 const GeoDataCamera &otherCam = static_cast<const GeoDataCamera &>(other);
69
70 return thisCam == otherCam;
71 } else if (nodeType() == GeoDataTypes::GeoDataLookAtType) {
72 const GeoDataLookAt &thisLookAt = static_cast<const GeoDataLookAt &>(*this);
73 const GeoDataLookAt &otherLookAt = static_cast<const GeoDataLookAt &>(other);
74
75 return thisLookAt == otherLookAt;
76 }
77
78 return false;
79}
80
81GeoDataCoordinates GeoDataAbstractView::coordinates() const
82{
83 if ( nodeType() == GeoDataTypes::GeoDataLookAtType) {
84 const GeoDataLookAt *lookAt = static_cast<const GeoDataLookAt*>( this );
85 if( lookAt ){
86 return lookAt->coordinates();
87 }
88 }
89 else if( nodeType() == GeoDataTypes::GeoDataCameraType ){
90 const GeoDataCamera *camera = static_cast<const GeoDataCamera*>( this );
91 if ( camera ){
92 return camera->coordinates();
93 }
94 }
95 return GeoDataCoordinates();
96}
97
98
99bool GeoDataAbstractView::equals(const GeoDataAbstractView &other) const
100{
101 return GeoDataObject::equals(other) &&
102 d->m_timeSpan == other.d->m_timeSpan &&
103 d->m_timeStamp == other.d->m_timeStamp &&
104 d->m_altitudeMode == other.d->m_altitudeMode;
105}
106
107const GeoDataTimeSpan &GeoDataAbstractView::timeSpan() const
108{
109 return d->m_timeSpan;
110}
111
112GeoDataTimeSpan &GeoDataAbstractView::timeSpan()
113{
114 return d->m_timeSpan;
115}
116
117void GeoDataAbstractView::setTimeSpan( const GeoDataTimeSpan &timeSpan )
118{
119 d->m_timeSpan = timeSpan;
120}
121
122GeoDataTimeStamp &GeoDataAbstractView::timeStamp()
123{
124 return d->m_timeStamp;
125}
126
127const GeoDataTimeStamp &GeoDataAbstractView::timeStamp() const
128{
129 return d->m_timeStamp;
130}
131
132void GeoDataAbstractView::setTimeStamp( const GeoDataTimeStamp &timeStamp )
133{
134 d->m_timeStamp = timeStamp;
135}
136
137AltitudeMode GeoDataAbstractView::altitudeMode() const
138{
139 return d->m_altitudeMode;
140}
141
142void GeoDataAbstractView::setAltitudeMode(const AltitudeMode altitudeMode)
143{
144 d->m_altitudeMode = altitudeMode;
145}
146
147}
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 Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.