• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • data
GeoDataGeometry.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2008 Torsten Rahn <rahn@kde.org>
9 // Copyright 2008-2009 Patrick Spendrin <ps_ml@gmx.de>
10 // Copyright 2008 Inge Wallin <inge@lysator.liu.se>
11 //
12 
13 
14 #include "GeoDataGeometry.h"
15 #include "GeoDataGeometry_p.h"
16 
17 #include "GeoDataPoint.h"
18 #include "GeoDataPolygon.h"
19 #include "GeoDataLineString.h"
20 #include "GeoDataMultiGeometry.h"
21 
22 #include "MarbleDebug.h"
23 
24 
25 namespace Marble
26 {
27 
28 GeoDataGeometry::GeoDataGeometry()
29  : d( new GeoDataGeometryPrivate() )
30 {
31  d->ref.ref();
32 }
33 
34 GeoDataGeometry::GeoDataGeometry( const GeoDataGeometry& other )
35  : GeoDataObject(),
36  d( other.d )
37 {
38  d->ref.ref();
39 }
40 
41 GeoDataGeometry::GeoDataGeometry( GeoDataGeometryPrivate* priv )
42  : GeoDataObject(),
43  d( priv )
44 {
45  d->ref.ref();
46 }
47 
48 GeoDataGeometry::~GeoDataGeometry()
49 {
50  if (!d->ref.deref())
51  delete d;
52 }
53 
54 void GeoDataGeometry::detach()
55 {
56 #if QT_VERSION < 0x050000
57  if(d->ref == 1)
58 #else
59  if(d->ref.load() == 1)
60 #endif
61  return;
62 
63  GeoDataGeometryPrivate* new_d = d->copy();
64 
65  if (!d->ref.deref())
66  delete d;
67 
68  d = new_d;
69  d->ref.ref();
70 }
71 
72 GeoDataGeometryPrivate* GeoDataGeometry::p() const
73 {
74  return static_cast<GeoDataGeometryPrivate*>(d);
75 }
76 
77 const char* GeoDataGeometry::nodeType() const
78 {
79  return p()->nodeType();
80 }
81 
82 EnumGeometryId GeoDataGeometry::geometryId() const
83 {
84  return p()->geometryId();
85 }
86 
87 GeoDataGeometry& GeoDataGeometry::operator=( const GeoDataGeometry& other )
88 {
89  GeoDataObject::operator=( other );
90 
91  if (!d->ref.deref())
92  delete d;
93 
94  d = other.d;
95  d->ref.ref();
96 
97  return *this;
98 }
99 
100 bool GeoDataGeometry::extrude() const
101 {
102  return d->m_extrude;
103 }
104 
105 void GeoDataGeometry::setExtrude( bool extrude )
106 {
107  detach();
108  d->m_extrude = extrude;
109 }
110 
111 AltitudeMode GeoDataGeometry::altitudeMode() const
112 {
113  return d->m_altitudeMode;
114 }
115 
116 void GeoDataGeometry::setAltitudeMode( const AltitudeMode altitudeMode )
117 {
118  detach();
119  d->m_altitudeMode = altitudeMode;
120 }
121 
122 const GeoDataLatLonAltBox& GeoDataGeometry::latLonAltBox() const
123 {
124  return d->m_latLonAltBox;
125 }
126 
127 void GeoDataGeometry::pack( QDataStream& stream ) const
128 {
129  GeoDataObject::pack( stream );
130 
131  stream << d->m_extrude;
132  stream << d->m_altitudeMode;
133 }
134 
135 void GeoDataGeometry::unpack( QDataStream& stream )
136 {
137  detach();
138  GeoDataObject::unpack( stream );
139 
140  int am;
141  stream >> d->m_extrude;
142  stream >> am;
143  d->m_altitudeMode = (AltitudeMode) am;
144 }
145 
146 bool GeoDataGeometry::equals(const GeoDataGeometry &other) const
147 {
148  return GeoDataObject::equals(other) &&
149  d->m_extrude == other.d->m_extrude &&
150  d->m_altitudeMode == other.d->m_altitudeMode;
151 }
152 
153 }
Marble::GeoDataGeometry::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataGeometry.cpp:77
Marble::GeoDataGeometry::unpack
virtual void unpack(QDataStream &stream)
Unserialize the contents of the feature from stream.
Definition: GeoDataGeometry.cpp:135
Marble::GeoDataGeometryPrivate::m_extrude
bool m_extrude
Definition: GeoDataGeometry_p.h:72
Marble::GeoDataGeometryPrivate::ref
QAtomicInt ref
Definition: GeoDataGeometry_p.h:76
GeoDataPolygon.h
QDataStream
Marble::GeoDataGeometry::setExtrude
void setExtrude(bool extrude)
Definition: GeoDataGeometry.cpp:105
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataGeometry
A base class for all geodata features.
Definition: GeoDataGeometry.h:47
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
Marble::GeoDataGeometryPrivate::nodeType
virtual const char * nodeType() const
Definition: GeoDataGeometry_p.h:62
Marble::GeoDataObject::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:114
QAtomicInt::ref
bool ref()
Marble::GeoDataGeometry::detach
void detach()
Definition: GeoDataGeometry.cpp:54
GeoDataGeometry_p.h
MarbleDebug.h
Marble::GeoDataGeometryPrivate
Definition: GeoDataGeometry_p.h:25
Marble::GeoDataGeometry::pack
virtual void pack(QDataStream &stream) const
Serialize the contents of the feature to stream.
Definition: GeoDataGeometry.cpp:127
Marble::GeoDataGeometry::extrude
bool extrude() const
Definition: GeoDataGeometry.cpp:100
GeoDataMultiGeometry.h
Marble::GeoDataGeometry::~GeoDataGeometry
virtual ~GeoDataGeometry()
Definition: GeoDataGeometry.cpp:48
Marble::GeoDataGeometry::altitudeMode
AltitudeMode altitudeMode() const
Definition: GeoDataGeometry.cpp:111
Marble::AltitudeMode
AltitudeMode
Definition: MarbleGlobal.h:147
Marble::GeoDataGeometryPrivate::m_altitudeMode
AltitudeMode m_altitudeMode
Definition: GeoDataGeometry_p.h:73
GeoDataLineString.h
QAtomicInt::deref
bool deref()
Marble::GeoDataGeometry::operator=
GeoDataGeometry & operator=(const GeoDataGeometry &other)
Definition: GeoDataGeometry.cpp:87
Marble::GeoDataGeometryPrivate::geometryId
virtual EnumGeometryId geometryId() const
Definition: GeoDataGeometry_p.h:67
GeoDataPoint.h
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::EnumGeometryId
EnumGeometryId
Definition: Serializable.h:40
Marble::GeoDataObject::unpack
virtual void unpack(QDataStream &steam)
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:120
Marble::GeoDataGeometry::setAltitudeMode
void setAltitudeMode(const AltitudeMode altitudeMode)
Definition: GeoDataGeometry.cpp:116
Marble::GeoDataGeometryPrivate::m_latLonAltBox
GeoDataLatLonAltBox m_latLonAltBox
Definition: GeoDataGeometry_p.h:74
GeoDataGeometry.h
Marble::GeoDataGeometry::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Definition: GeoDataGeometry.cpp:122
Marble::GeoDataGeometry::equals
bool equals(const GeoDataGeometry &other) const
Definition: GeoDataGeometry.cpp:146
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
Marble::GeoDataGeometryPrivate::copy
virtual GeoDataGeometryPrivate * copy()
Definition: GeoDataGeometry_p.h:55
Marble::GeoDataGeometry::geometryId
virtual EnumGeometryId geometryId() const
Definition: GeoDataGeometry.cpp:82
Marble::GeoDataGeometry::GeoDataGeometry
GeoDataGeometry()
Definition: GeoDataGeometry.cpp:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal