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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Gaurav Gupta <1989.gaurav@googlemail.com>
0004 // SPDX-FileCopyrightText: 2010 Bastian Holst <bastianholst@gmx.de>
0005 //
0006 
0007 //own
0008 #include "GeoDataLookAt.h"
0009 #include "GeoDataLookAt_p.h"
0010 
0011 #include "GeoDataTypes.h"
0012 
0013 #include "MarbleDebug.h"
0014 
0015 namespace Marble
0016 {
0017 
0018 GeoDataLookAt::GeoDataLookAt() :
0019     GeoDataAbstractView(),
0020     d( new GeoDataLookAtPrivate )
0021 {
0022 }
0023 
0024 GeoDataLookAt::GeoDataLookAt( const GeoDataLookAt& other ) :
0025     GeoDataAbstractView(),
0026     d( other.d )
0027 {
0028     d->ref.ref();
0029 }
0030 
0031 GeoDataLookAt& GeoDataLookAt::operator=( const GeoDataLookAt &other )                                   
0032 {
0033     GeoDataAbstractView::operator=( other );
0034     qAtomicAssign( d, other.d );
0035     return *this;
0036 }
0037 
0038 bool GeoDataLookAt::operator==(const GeoDataLookAt &other) const
0039 {
0040     return equals(other) &&
0041            d->m_coordinates == other.d->m_coordinates &&
0042            d->m_range == other.d->m_range;
0043 }
0044 
0045 bool GeoDataLookAt::operator!=(const GeoDataLookAt &other) const
0046 {
0047     return !this->operator==( other );
0048 }
0049 
0050 GeoDataLookAt::~GeoDataLookAt()
0051 {
0052     if( !d->ref.deref() )
0053         delete d;
0054 }
0055 
0056 GeoDataAbstractView *GeoDataLookAt::copy() const
0057 {
0058     return new GeoDataLookAt( *this );
0059 }
0060 
0061 void GeoDataLookAt::setCoordinates( const GeoDataCoordinates& coordinates )
0062 {
0063     d->m_coordinates = coordinates;
0064 }
0065 
0066 const char* GeoDataLookAt::nodeType() const
0067 {
0068     return GeoDataTypes::GeoDataLookAtType;
0069 }
0070 
0071 void GeoDataLookAt::setAltitude( qreal altitude )
0072 {
0073     detach();
0074     d->m_coordinates.setAltitude( altitude );
0075 }
0076 
0077 qreal GeoDataLookAt::altitude() const
0078 {
0079     return d->m_coordinates.altitude();
0080 }
0081 
0082 void GeoDataLookAt::setLatitude( qreal latitude, GeoDataCoordinates::Unit unit )
0083 {
0084     detach();
0085     d->m_coordinates.setLatitude( latitude,unit );
0086 }
0087 
0088 qreal GeoDataLookAt::latitude( GeoDataCoordinates::Unit unit ) const
0089 {
0090     return d->m_coordinates.latitude( unit );
0091 }
0092 
0093 void GeoDataLookAt::setLongitude( qreal longitude, GeoDataCoordinates::Unit unit )
0094 {
0095     detach();
0096     d->m_coordinates.setLongitude( longitude, unit );
0097 }
0098 
0099 qreal GeoDataLookAt::longitude( GeoDataCoordinates::Unit unit ) const
0100 {
0101     return d->m_coordinates.longitude( unit );
0102 }
0103 
0104 GeoDataCoordinates GeoDataLookAt::coordinates() const
0105 {
0106     return d->m_coordinates;
0107 }
0108 
0109 void GeoDataLookAt::setRange( qreal range )
0110 {
0111     detach();
0112     d->m_range = range;
0113 }
0114 
0115 qreal GeoDataLookAt::range() const
0116 {
0117     return d->m_range;
0118 }
0119 
0120 void GeoDataLookAt::detach()
0121 {
0122     qAtomicDetach( d );
0123 }
0124 
0125 }