• 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
GeoDataIconStyle.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 2007 Murad Tagirov <tmurad@gmail.com>
9 //
10 
11 
12 #include "GeoDataIconStyle.h"
13 #include "MarbleDirs.h"
14 #include "MarbleDebug.h"
15 
16 #include "GeoDataTypes.h"
17 
18 namespace Marble
19 {
20 
21 class GeoDataIconStylePrivate
22 {
23  public:
24  GeoDataIconStylePrivate()
25  : m_scale( 1.0 ),
26  m_iconPath( MarbleDirs::path( "bitmaps/default_location.png" ) ),
27  m_heading( 0 )
28  {
29  }
30 
31  GeoDataIconStylePrivate( const QImage& icon, const QPointF &hotSpot )
32  : m_scale( 1.0 ),
33  m_icon( icon ),
34  m_hotSpot( hotSpot ),
35  m_heading( 0 )
36  {
37  }
38 
39  const char* nodeType() const
40  {
41  return GeoDataTypes::GeoDataIconStyleType;
42  }
43 
44  float m_scale;
45 
46  QImage m_icon;
47  QString m_iconPath;
48  GeoDataHotSpot m_hotSpot;
49  int m_heading;
50 };
51 
52 GeoDataIconStyle::GeoDataIconStyle() :
53  d( new GeoDataIconStylePrivate() )
54 {
55 }
56 
57 GeoDataIconStyle::GeoDataIconStyle( const GeoDataIconStyle& other ) :
58  GeoDataColorStyle( other ), d( new GeoDataIconStylePrivate( *other.d ) )
59 {
60 }
61 
62 GeoDataIconStyle::GeoDataIconStyle( const QImage& icon, const QPointF &hotSpot ) :
63  d( new GeoDataIconStylePrivate( icon, hotSpot ) )
64 {
65 }
66 
67 GeoDataIconStyle::~GeoDataIconStyle()
68 {
69  delete d;
70 }
71 
72 GeoDataIconStyle& GeoDataIconStyle::operator=( const GeoDataIconStyle& other )
73 {
74  GeoDataColorStyle::operator=( other );
75  *d = *other.d;
76  return *this;
77 }
78 
79 bool GeoDataIconStyle::operator==( const GeoDataIconStyle &other ) const
80 {
81  if ( GeoDataColorStyle::operator!=( other ) ) {
82  return false;
83  }
84 
85  return d->m_scale == other.d->m_scale &&
86  d->m_icon == other.d->m_icon &&
87  d->m_iconPath == other.d->m_iconPath &&
88  d->m_hotSpot == other.d->m_hotSpot &&
89  d->m_heading == other.d->m_heading;
90 }
91 
92 bool GeoDataIconStyle::operator!=( const GeoDataIconStyle &other ) const
93 {
94  return !this->operator==( other );
95 }
96 
97 const char* GeoDataIconStyle::nodeType() const
98 {
99  return d->nodeType();
100 }
101 
102 void GeoDataIconStyle::setIcon(const QImage &icon)
103 {
104  d->m_icon = icon;
105 }
106 
107 void GeoDataIconStyle::setIconPath( const QString& filename )
108 {
109  d->m_iconPath = filename;
110 }
111 
112 QString GeoDataIconStyle::iconPath() const
113 {
114  return d->m_iconPath;
115 }
116 
117 QImage GeoDataIconStyle::icon() const
118 {
119  if(!d->m_icon.isNull())
120  return d->m_icon;
121  else if(!d->m_iconPath.isEmpty()) {
122  d->m_icon = QImage( resolvePath( d->m_iconPath ) );
123  return d->m_icon;
124  }
125  else
126  return QImage();
127 }
128 
129 void GeoDataIconStyle::setHotSpot( const QPointF& hotSpot,
130  GeoDataHotSpot::Units xunits,
131  GeoDataHotSpot::Units yunits )
132 {
133  d->m_hotSpot.setHotSpot( hotSpot, xunits, yunits );
134 }
135 
136 QPointF GeoDataIconStyle::hotSpot( GeoDataHotSpot::Units &xunits, GeoDataHotSpot::Units &yunits ) const
137 {
138  return d->m_hotSpot.hotSpot( xunits, yunits );
139 }
140 
141 void GeoDataIconStyle::setScale( const float &scale )
142 {
143  d->m_scale = scale;
144 }
145 
146 float GeoDataIconStyle::scale() const
147 {
148  return d->m_scale;
149 }
150 
151 int GeoDataIconStyle::heading() const
152 {
153  return d->m_heading;
154 }
155 
156 void GeoDataIconStyle::setHeading( int heading )
157 {
158  d->m_heading = heading;
159 }
160 
161 void GeoDataIconStyle::pack( QDataStream& stream ) const
162 {
163  GeoDataColorStyle::pack( stream );
164 
165  stream << d->m_scale;
166  stream << d->m_icon;
167  d->m_hotSpot.pack( stream );
168 }
169 
170 void GeoDataIconStyle::unpack( QDataStream& stream )
171 {
172  GeoDataColorStyle::unpack( stream );
173 
174  stream >> d->m_scale;
175  stream >> d->m_icon;
176  d->m_hotSpot.unpack( stream );
177 }
178 
179 }
Marble::GeoDataIconStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataIconStyle.cpp:170
Marble::GeoDataIconStyle
Definition: GeoDataIconStyle.h:29
Marble::GeoDataIconStyle::~GeoDataIconStyle
~GeoDataIconStyle()
Definition: GeoDataIconStyle.cpp:67
Marble::GeoDataTypes::GeoDataIconStyleType
const char * GeoDataIconStyleType
Definition: GeoDataTypes.cpp:46
Marble::GeoDataIconStyle::setIcon
void setIcon(const QImage &icon)
Definition: GeoDataIconStyle.cpp:102
GeoDataIconStyle.h
QDataStream
Marble::GeoDataIconStyle::heading
int heading() const
Definition: GeoDataIconStyle.cpp:151
Marble::GeoDataHotSpot::Units
Units
Definition: GeoDataHotSpot.h:30
Marble::GeoDataIconStyle::setScale
void setScale(const float &scale)
Definition: GeoDataIconStyle.cpp:141
MarbleDebug.h
Marble::GeoDataIconStyle::hotSpot
QPointF hotSpot(GeoDataHotSpot::Units &xunits, GeoDataHotSpot::Units &yunits) const
Definition: GeoDataIconStyle.cpp:136
QPointF
Marble::GeoDataColorStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataColorStyle.cpp:118
Marble::GeoDataIconStyle::operator==
bool operator==(const GeoDataIconStyle &other) const
Definition: GeoDataIconStyle.cpp:79
Marble::GeoDataColorStyle
an abstract base class for various style classes
Definition: GeoDataColorStyle.h:64
Marble::GeoDataIconStyle::scale
float scale() const
Definition: GeoDataIconStyle.cpp:146
MarbleDirs.h
Marble::GeoDataIconStyle::setIconPath
void setIconPath(const QString &filename)
Definition: GeoDataIconStyle.cpp:107
QString
Marble::GeoDataObject::resolvePath
QString resolvePath(const QString &relativePath) const
Definition: GeoDataObject.cpp:95
Marble::GeoDataIconStyle::icon
QImage icon() const
Definition: GeoDataIconStyle.cpp:117
Marble::GeoDataIconStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataIconStyle.cpp:161
QImage
Marble::GeoDataIconStyle::operator!=
bool operator!=(const GeoDataIconStyle &other) const
Definition: GeoDataIconStyle.cpp:92
Marble::GeoDataIconStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataIconStyle.cpp:97
Marble::GeoDataColorStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataColorStyle.cpp:127
Marble::GeoDataIconStyle::setHeading
void setHeading(int heading)
Definition: GeoDataIconStyle.cpp:156
Marble::GeoDataIconStyle::GeoDataIconStyle
GeoDataIconStyle()
Definition: GeoDataIconStyle.cpp:52
Marble::GeoDataIconStyle::iconPath
QString iconPath() const
Definition: GeoDataIconStyle.cpp:112
GeoDataTypes.h
Marble::GeoDataColorStyle::operator=
GeoDataColorStyle & operator=(const GeoDataColorStyle &other)
assignment operator
Definition: GeoDataColorStyle.cpp:61
Marble::GeoDataIconStyle::setHotSpot
void setHotSpot(const QPointF &hotSpot, GeoDataHotSpot::Units xunits, GeoDataHotSpot::Units yunits)
Definition: GeoDataIconStyle.cpp:129
Marble::GeoDataIconStyle::operator=
GeoDataIconStyle & operator=(const GeoDataIconStyle &other)
Definition: GeoDataIconStyle.cpp:72
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