File indexing completed on 2025-01-05 03:58:53
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com> 0004 // 0005 0006 0007 #include "GeoDataCamera.h" 0008 #include "GeoDataCamera_p.h" 0009 0010 #include "GeoDataTypes.h" 0011 0012 #include <QDataStream> 0013 0014 namespace Marble 0015 { 0016 0017 GeoDataCamera::GeoDataCamera() : 0018 GeoDataAbstractView(), 0019 d( new GeoDataCameraPrivate ) 0020 { 0021 } 0022 0023 GeoDataCamera::GeoDataCamera( const GeoDataCamera& other ) : 0024 GeoDataAbstractView(), 0025 d( other.d ) 0026 { 0027 d->ref.ref(); 0028 } 0029 0030 GeoDataCamera& GeoDataCamera::operator=( const GeoDataCamera &other ) 0031 { 0032 GeoDataAbstractView::operator=( other ); 0033 qAtomicAssign( d, other.d ); 0034 return *this; 0035 } 0036 0037 bool GeoDataCamera::operator==( const GeoDataCamera &other ) const 0038 { 0039 return equals(other) && 0040 d->m_coordinates == other.d->m_coordinates && 0041 d->m_roll == other.d->m_roll && 0042 d->m_heading == other.d->m_heading && 0043 d->m_tilt == other.d->m_tilt && 0044 altitudeMode() == other.altitudeMode(); 0045 } 0046 0047 bool GeoDataCamera::operator!=( const GeoDataCamera &other ) const 0048 { 0049 return !this->operator==(other); 0050 } 0051 0052 GeoDataCamera::~GeoDataCamera() 0053 { 0054 if( !d->ref.deref() ) { 0055 delete d; 0056 } 0057 } 0058 0059 GeoDataAbstractView *GeoDataCamera::copy() const 0060 { 0061 return new GeoDataCamera( *this ); 0062 } 0063 0064 void GeoDataCamera::setCoordinates( const GeoDataCoordinates& coordinates ) 0065 { 0066 detach(); 0067 d->m_coordinates = coordinates; 0068 } 0069 0070 const char* GeoDataCamera::nodeType() const 0071 { 0072 return GeoDataTypes::GeoDataCameraType; 0073 } 0074 0075 void GeoDataCamera::setAltitude( qreal altitude ) 0076 { 0077 detach(); 0078 d->m_coordinates.setAltitude( altitude ); 0079 } 0080 0081 qreal GeoDataCamera::altitude() const 0082 { 0083 return d->m_coordinates.altitude(); 0084 } 0085 0086 void GeoDataCamera::setLatitude( qreal latitude, GeoDataCoordinates::Unit unit ) 0087 { 0088 detach(); 0089 d->m_coordinates.setLatitude( latitude, unit ); 0090 } 0091 0092 qreal GeoDataCamera::latitude( GeoDataCoordinates::Unit unit ) const 0093 { 0094 return d->m_coordinates.latitude( unit ); 0095 } 0096 0097 void GeoDataCamera::setLongitude( qreal longitude, GeoDataCoordinates::Unit unit ) 0098 { 0099 detach(); 0100 d->m_coordinates.setLongitude( longitude, unit ); 0101 } 0102 0103 qreal GeoDataCamera::longitude( GeoDataCoordinates::Unit unit ) const 0104 { 0105 return d->m_coordinates.longitude( unit ); 0106 } 0107 0108 GeoDataCoordinates GeoDataCamera::coordinates() const 0109 { 0110 return d->m_coordinates; 0111 } 0112 0113 void GeoDataCamera::setRoll(qreal roll) 0114 { 0115 detach(); 0116 d->m_roll = roll; 0117 } 0118 0119 qreal GeoDataCamera::roll() const 0120 { 0121 return d->m_roll; 0122 } 0123 0124 qreal GeoDataCamera::heading() const 0125 { 0126 return d->m_heading; 0127 } 0128 0129 void GeoDataCamera::setHeading(qreal heading) 0130 { 0131 detach(); 0132 d->m_heading = heading; 0133 } 0134 0135 qreal GeoDataCamera::tilt() const 0136 { 0137 return d->m_tilt; 0138 } 0139 0140 void GeoDataCamera::setTilt(qreal tilt) 0141 { 0142 detach(); 0143 d->m_tilt = tilt; 0144 } 0145 0146 void GeoDataCamera::detach() 0147 { 0148 qAtomicDetach( d ); 0149 } 0150 0151 }