1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com> 4 // 5 6 7 #include "GeoDataCamera.h" 8 #include "GeoDataCamera_p.h" 9 10 #include "GeoDataTypes.h" 11 12 #include <QDataStream> 13 14 namespace Marble 15 { 16 GeoDataCamera()17GeoDataCamera::GeoDataCamera() : 18 GeoDataAbstractView(), 19 d( new GeoDataCameraPrivate ) 20 { 21 } 22 GeoDataCamera(const GeoDataCamera & other)23GeoDataCamera::GeoDataCamera( const GeoDataCamera& other ) : 24 GeoDataAbstractView(), 25 d( other.d ) 26 { 27 d->ref.ref(); 28 } 29 operator =(const GeoDataCamera & other)30GeoDataCamera& GeoDataCamera::operator=( const GeoDataCamera &other ) 31 { 32 GeoDataAbstractView::operator=( other ); 33 qAtomicAssign( d, other.d ); 34 return *this; 35 } 36 operator ==(const GeoDataCamera & other) const37bool GeoDataCamera::operator==( const GeoDataCamera &other ) const 38 { 39 return equals(other) && 40 d->m_coordinates == other.d->m_coordinates && 41 d->m_roll == other.d->m_roll && 42 d->m_heading == other.d->m_heading && 43 d->m_tilt == other.d->m_tilt && 44 altitudeMode() == other.altitudeMode(); 45 } 46 operator !=(const GeoDataCamera & other) const47bool GeoDataCamera::operator!=( const GeoDataCamera &other ) const 48 { 49 return !this->operator==(other); 50 } 51 ~GeoDataCamera()52GeoDataCamera::~GeoDataCamera() 53 { 54 if( !d->ref.deref() ) { 55 delete d; 56 } 57 } 58 copy() const59GeoDataAbstractView *GeoDataCamera::copy() const 60 { 61 return new GeoDataCamera( *this ); 62 } 63 setCoordinates(const GeoDataCoordinates & coordinates)64void GeoDataCamera::setCoordinates( const GeoDataCoordinates& coordinates ) 65 { 66 detach(); 67 d->m_coordinates = coordinates; 68 } 69 nodeType() const70const char* GeoDataCamera::nodeType() const 71 { 72 return GeoDataTypes::GeoDataCameraType; 73 } 74 setAltitude(qreal altitude)75void GeoDataCamera::setAltitude( qreal altitude ) 76 { 77 detach(); 78 d->m_coordinates.setAltitude( altitude ); 79 } 80 altitude() const81qreal GeoDataCamera::altitude() const 82 { 83 return d->m_coordinates.altitude(); 84 } 85 setLatitude(qreal latitude,GeoDataCoordinates::Unit unit)86void GeoDataCamera::setLatitude( qreal latitude, GeoDataCoordinates::Unit unit ) 87 { 88 detach(); 89 d->m_coordinates.setLatitude( latitude, unit ); 90 } 91 latitude(GeoDataCoordinates::Unit unit) const92qreal GeoDataCamera::latitude( GeoDataCoordinates::Unit unit ) const 93 { 94 return d->m_coordinates.latitude( unit ); 95 } 96 setLongitude(qreal longitude,GeoDataCoordinates::Unit unit)97void GeoDataCamera::setLongitude( qreal longitude, GeoDataCoordinates::Unit unit ) 98 { 99 detach(); 100 d->m_coordinates.setLongitude( longitude, unit ); 101 } 102 longitude(GeoDataCoordinates::Unit unit) const103qreal GeoDataCamera::longitude( GeoDataCoordinates::Unit unit ) const 104 { 105 return d->m_coordinates.longitude( unit ); 106 } 107 coordinates() const108GeoDataCoordinates GeoDataCamera::coordinates() const 109 { 110 return d->m_coordinates; 111 } 112 setRoll(qreal roll)113void GeoDataCamera::setRoll(qreal roll) 114 { 115 detach(); 116 d->m_roll = roll; 117 } 118 roll() const119qreal GeoDataCamera::roll() const 120 { 121 return d->m_roll; 122 } 123 heading() const124qreal GeoDataCamera::heading() const 125 { 126 return d->m_heading; 127 } 128 setHeading(qreal heading)129void GeoDataCamera::setHeading(qreal heading) 130 { 131 detach(); 132 d->m_heading = heading; 133 } 134 tilt() const135qreal GeoDataCamera::tilt() const 136 { 137 return d->m_tilt; 138 } 139 setTilt(qreal tilt)140void GeoDataCamera::setTilt(qreal tilt) 141 { 142 detach(); 143 d->m_tilt = tilt; 144 } 145 detach()146void GeoDataCamera::detach() 147 { 148 qAtomicDetach( d ); 149 } 150 151 } 152