Marble

GeoDataVec2.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
4 //
5 
6 #include "GeoDataVec2.h"
7 
8 #include "MarbleDebug.h"
9 
10 namespace Marble {
11 
12 class GeoDataVec2Private
13 {
14 public:
15  GeoDataVec2Private();
16 
17  GeoDataVec2::Unit m_xunit;
18  GeoDataVec2::Unit m_yunit;
19 
20  static GeoDataVec2::Unit parseUnits( const QString &value );
21 };
22 
23 GeoDataVec2Private::GeoDataVec2Private() :
24  m_xunit(GeoDataVec2::Fraction), m_yunit(GeoDataVec2::Fraction)
25 {
26 }
27 
28 GeoDataVec2::GeoDataVec2() :
29  d( new GeoDataVec2Private )
30 {
31 }
32 
33 GeoDataVec2::GeoDataVec2(qreal x, qreal y, const QString &xunits, const QString &yunits) :
34  d( new GeoDataVec2Private )
35 {
36  setX( x );
37  setY( y );
38  d->m_xunit = GeoDataVec2Private::parseUnits( xunits );
39  d->m_yunit = GeoDataVec2Private::parseUnits( yunits );
40 }
41 
42 GeoDataVec2::Unit GeoDataVec2Private::parseUnits( const QString &value )
43 {
44  if (value == QLatin1String("fraction")) {
45  return GeoDataVec2::Fraction;
46  }
47  if (value == QLatin1String("pixels")) {
48  return GeoDataVec2::Pixels;
49  }
50  if (value == QLatin1String("insetPixels")) {
51  return GeoDataVec2::InsetPixels;
52  }
53 
54  mDebug() << "Warning: Unknown units value " << value << " - falling back to default 'fraction'";
55  return GeoDataVec2::Fraction;
56 }
57 
58 GeoDataVec2::GeoDataVec2( const Marble::GeoDataVec2 &other ) :
59  QPointF(other), d( new GeoDataVec2Private( *other.d ) )
60 {
61 }
62 
63 GeoDataVec2 &GeoDataVec2::operator=( const GeoDataVec2 &other )
64 {
65  QPointF::operator=(other);
66  *d = *other.d;
67  return *this;
68 }
69 
70 bool GeoDataVec2::operator==(const GeoDataVec2& other) const
71 {
72  return x() == other.x() && y() == other.y() &&
73  d->m_xunit == other.d->m_xunit && d->m_yunit == other.d->m_yunit;
74 }
75 
76 bool GeoDataVec2::operator!=(const GeoDataVec2& other) const
77 {
78  return !this->operator==(other);
79 }
80 
81 GeoDataVec2::~GeoDataVec2()
82 {
83  delete d;
84 }
85 
86 GeoDataVec2::Unit GeoDataVec2::xunit() const
87 {
88  return d->m_xunit;
89 }
90 
91 void GeoDataVec2::setXunits(Unit xunit)
92 {
93  d->m_xunit = xunit;
94 }
95 
96 GeoDataVec2::Unit GeoDataVec2::yunit() const
97 {
98  return d->m_yunit;
99 }
100 
101 void GeoDataVec2::setYunits(Unit yunit)
102 {
103  d->m_yunit = yunit;
104 }
105 
106 }
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.