File indexing completed on 2024-05-12 03:50:08

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Gaurav Gupta <1989.gaurav@googlemail.com>
0004 // SPDX-FileCopyrightText: 2013 Dennis Nienhüser <nienhueser@kde.org>
0005 //
0006 
0007 #include "GeoDataAbstractView.h"
0008 
0009 #include "GeoDataCamera.h"
0010 #include "GeoDataLookAt.h"
0011 #include "GeoDataTypes.h"
0012 #include "GeoDataTimeSpan.h"
0013 #include "GeoDataTimeStamp.h"
0014 
0015 namespace Marble {
0016 
0017 class GeoDataAbstractViewPrivate
0018 {
0019 public:
0020     GeoDataAbstractViewPrivate();
0021 
0022     GeoDataTimeSpan m_timeSpan;
0023     GeoDataTimeStamp m_timeStamp;
0024     AltitudeMode m_altitudeMode;
0025 };
0026 
0027 GeoDataAbstractViewPrivate::GeoDataAbstractViewPrivate() :
0028     m_timeSpan(),
0029     m_timeStamp(),
0030     m_altitudeMode( ClampToGround )
0031 {
0032     // do nothing
0033 }
0034 
0035 GeoDataAbstractView::GeoDataAbstractView() :
0036     d( new GeoDataAbstractViewPrivate() )
0037 {
0038     // do nothing
0039 }
0040 
0041 GeoDataAbstractView::~GeoDataAbstractView()
0042 {
0043     delete d;
0044 }
0045 
0046 GeoDataAbstractView::GeoDataAbstractView( const GeoDataAbstractView &other ) :
0047     GeoDataObject( other ),
0048     d( new GeoDataAbstractViewPrivate( *other.d ) )
0049 {
0050     // nothing to do
0051 }
0052 
0053 GeoDataAbstractView &GeoDataAbstractView::operator =( const GeoDataAbstractView &other )
0054 {
0055     GeoDataObject::operator=( other );
0056     *d = *other.d;
0057     return *this;
0058 }
0059 
0060 bool GeoDataAbstractView::operator==(const GeoDataAbstractView &other) const
0061 {
0062     if (nodeType() != other.nodeType()) {
0063         return false;
0064     }
0065 
0066     if (nodeType() == GeoDataTypes::GeoDataCameraType) {
0067         const GeoDataCamera &thisCam = static_cast<const GeoDataCamera &>(*this);
0068         const GeoDataCamera &otherCam = static_cast<const GeoDataCamera &>(other);
0069 
0070         return thisCam == otherCam;
0071     } else if (nodeType() == GeoDataTypes::GeoDataLookAtType) {
0072         const GeoDataLookAt &thisLookAt = static_cast<const GeoDataLookAt &>(*this);
0073         const GeoDataLookAt &otherLookAt = static_cast<const GeoDataLookAt &>(other);
0074 
0075         return thisLookAt == otherLookAt;
0076     }
0077 
0078     return false;
0079 }
0080 
0081 GeoDataCoordinates GeoDataAbstractView::coordinates() const
0082 {
0083     if ( nodeType() == GeoDataTypes::GeoDataLookAtType) {
0084         const GeoDataLookAt *lookAt = static_cast<const GeoDataLookAt*>( this );
0085         if( lookAt ){
0086             return lookAt->coordinates();
0087         }
0088     }
0089     else if( nodeType() == GeoDataTypes::GeoDataCameraType ){
0090         const GeoDataCamera *camera = static_cast<const GeoDataCamera*>( this );
0091         if ( camera ){
0092             return camera->coordinates();
0093         }
0094     }
0095     return GeoDataCoordinates();
0096 }
0097 
0098 
0099 bool GeoDataAbstractView::equals(const GeoDataAbstractView &other) const
0100 {
0101     return GeoDataObject::equals(other) &&
0102            d->m_timeSpan == other.d->m_timeSpan &&
0103            d->m_timeStamp == other.d->m_timeStamp &&
0104            d->m_altitudeMode == other.d->m_altitudeMode;
0105 }
0106 
0107 const GeoDataTimeSpan &GeoDataAbstractView::timeSpan() const
0108 {
0109     return d->m_timeSpan;
0110 }
0111 
0112 GeoDataTimeSpan &GeoDataAbstractView::timeSpan()
0113 {
0114     return d->m_timeSpan;
0115 }
0116 
0117 void GeoDataAbstractView::setTimeSpan( const GeoDataTimeSpan &timeSpan )
0118 {
0119     d->m_timeSpan = timeSpan;
0120 }
0121 
0122 GeoDataTimeStamp &GeoDataAbstractView::timeStamp()
0123 {
0124     return d->m_timeStamp;
0125 }
0126 
0127 const GeoDataTimeStamp &GeoDataAbstractView::timeStamp() const
0128 {
0129     return d->m_timeStamp;
0130 }
0131 
0132 void GeoDataAbstractView::setTimeStamp( const GeoDataTimeStamp &timeStamp )
0133 {
0134     d->m_timeStamp = timeStamp;
0135 }
0136 
0137 AltitudeMode GeoDataAbstractView::altitudeMode() const
0138 {
0139     return d->m_altitudeMode;
0140 }
0141 
0142 void GeoDataAbstractView::setAltitudeMode(const AltitudeMode altitudeMode)
0143 {
0144     d->m_altitudeMode = altitudeMode;
0145 }
0146 
0147 }