Marble

GeoDataAbstractView.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Gaurav Gupta <[email protected]>
4 // SPDX-FileCopyrightText: 2013 Dennis Nienhüser <[email protected]>
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 
15 namespace Marble {
16 
17 class GeoDataAbstractViewPrivate
18 {
19 public:
20  GeoDataAbstractViewPrivate();
21 
22  GeoDataTimeSpan m_timeSpan;
23  GeoDataTimeStamp m_timeStamp;
24  AltitudeMode m_altitudeMode;
25 };
26 
27 GeoDataAbstractViewPrivate::GeoDataAbstractViewPrivate() :
28  m_timeSpan(),
29  m_timeStamp(),
30  m_altitudeMode( ClampToGround )
31 {
32  // do nothing
33 }
34 
35 GeoDataAbstractView::GeoDataAbstractView() :
36  d( new GeoDataAbstractViewPrivate() )
37 {
38  // do nothing
39 }
40 
41 GeoDataAbstractView::~GeoDataAbstractView()
42 {
43  delete d;
44 }
45 
46 GeoDataAbstractView::GeoDataAbstractView( const GeoDataAbstractView &other ) :
47  GeoDataObject( other ),
48  d( new GeoDataAbstractViewPrivate( *other.d ) )
49 {
50  // nothing to do
51 }
52 
53 GeoDataAbstractView &GeoDataAbstractView::operator =( const GeoDataAbstractView &other )
54 {
55  GeoDataObject::operator=( other );
56  *d = *other.d;
57  return *this;
58 }
59 
60 bool 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 
81 GeoDataCoordinates 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 
99 bool 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 
107 const GeoDataTimeSpan &GeoDataAbstractView::timeSpan() const
108 {
109  return d->m_timeSpan;
110 }
111 
112 GeoDataTimeSpan &GeoDataAbstractView::timeSpan()
113 {
114  return d->m_timeSpan;
115 }
116 
117 void GeoDataAbstractView::setTimeSpan( const GeoDataTimeSpan &timeSpan )
118 {
119  d->m_timeSpan = timeSpan;
120 }
121 
122 GeoDataTimeStamp &GeoDataAbstractView::timeStamp()
123 {
124  return d->m_timeStamp;
125 }
126 
127 const GeoDataTimeStamp &GeoDataAbstractView::timeStamp() const
128 {
129  return d->m_timeStamp;
130 }
131 
132 void GeoDataAbstractView::setTimeStamp( const GeoDataTimeStamp &timeStamp )
133 {
134  d->m_timeStamp = timeStamp;
135 }
136 
137 AltitudeMode GeoDataAbstractView::altitudeMode() const
138 {
139  return d->m_altitudeMode;
140 }
141 
142 void GeoDataAbstractView::setAltitudeMode(const AltitudeMode altitudeMode)
143 {
144  d->m_altitudeMode = altitudeMode;
145 }
146 
147 }
Binds a QML item to a specific geodetic location in screen coordinates.
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Altitude always sticks to ground level.
Definition: MarbleGlobal.h:132
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:23:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.