Marble

GeoDataVec2.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4//
5
6#include "GeoDataVec2.h"
7
8#include "MarbleDebug.h"
9
10namespace Marble {
11
12class GeoDataVec2Private
13{
14public:
15 GeoDataVec2Private();
16
17 GeoDataVec2::Unit m_xunit;
18 GeoDataVec2::Unit m_yunit;
19
20 static GeoDataVec2::Unit parseUnits( const QString &value );
21};
22
23GeoDataVec2Private::GeoDataVec2Private() :
24 m_xunit(GeoDataVec2::Fraction), m_yunit(GeoDataVec2::Fraction)
25{
26}
27
28GeoDataVec2::GeoDataVec2() :
29 d( new GeoDataVec2Private )
30{
31}
32
33GeoDataVec2::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
42GeoDataVec2::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
58GeoDataVec2::GeoDataVec2( const Marble::GeoDataVec2 &other ) :
59 QPointF(other), d( new GeoDataVec2Private( *other.d ) )
60{
61}
62
63GeoDataVec2 &GeoDataVec2::operator=( const GeoDataVec2 &other )
64{
65 QPointF::operator=(other);
66 *d = *other.d;
67 return *this;
68}
69
70bool 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
76bool GeoDataVec2::operator!=(const GeoDataVec2& other) const
77{
78 return !this->operator==(other);
79}
80
81GeoDataVec2::~GeoDataVec2()
82{
83 delete d;
84}
85
86GeoDataVec2::Unit GeoDataVec2::xunit() const
87{
88 return d->m_xunit;
89}
90
91void GeoDataVec2::setXunits(Unit xunit)
92{
93 d->m_xunit = xunit;
94}
95
96GeoDataVec2::Unit GeoDataVec2::yunit() const
97{
98 return d->m_yunit;
99}
100
101void GeoDataVec2::setYunits(Unit yunit)
102{
103 d->m_yunit = yunit;
104}
105
106}
Binds a QML item to a specific geodetic location in screen coordinates.
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:57:57 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.