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

marble

  • sources
  • kde-4.12
  • 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 const char* GeoDataIconStyle::nodeType() const
80 {
81  return d->nodeType();
82 }
83 
84 void GeoDataIconStyle::setIcon(const QImage &icon)
85 {
86  d->m_icon = icon;
87 }
88 
89 void GeoDataIconStyle::setIconPath( const QString& filename )
90 {
91  d->m_iconPath = filename;
92 }
93 
94 QString GeoDataIconStyle::iconPath() const
95 {
96  return d->m_iconPath;
97 }
98 
99 QImage GeoDataIconStyle::icon() const
100 {
101  if(!d->m_icon.isNull())
102  return d->m_icon;
103  else if(!d->m_iconPath.isEmpty()) {
104  d->m_icon = QImage( resolvePath( d->m_iconPath ) );
105  return d->m_icon;
106  }
107  else
108  return QImage();
109 }
110 
111 void GeoDataIconStyle::setHotSpot( const QPointF& hotSpot,
112  GeoDataHotSpot::Units xunits,
113  GeoDataHotSpot::Units yunits )
114 {
115  d->m_hotSpot.setHotSpot( hotSpot, xunits, yunits );
116 }
117 
118 QPointF GeoDataIconStyle::hotSpot( GeoDataHotSpot::Units &xunits, GeoDataHotSpot::Units &yunits ) const
119 {
120  return d->m_hotSpot.hotSpot( xunits, yunits );
121 }
122 
123 void GeoDataIconStyle::setScale( const float &scale )
124 {
125  d->m_scale = scale;
126 }
127 
128 float GeoDataIconStyle::scale() const
129 {
130  return d->m_scale;
131 }
132 
133 int GeoDataIconStyle::heading() const
134 {
135  return d->m_heading;
136 }
137 
138 void GeoDataIconStyle::setHeading( int heading )
139 {
140  d->m_heading = heading;
141 }
142 
143 void GeoDataIconStyle::pack( QDataStream& stream ) const
144 {
145  GeoDataColorStyle::pack( stream );
146 
147  stream << d->m_scale;
148  stream << d->m_icon;
149  d->m_hotSpot.pack( stream );
150 }
151 
152 void GeoDataIconStyle::unpack( QDataStream& stream )
153 {
154  GeoDataColorStyle::unpack( stream );
155 
156  stream >> d->m_scale;
157  stream >> d->m_icon;
158  d->m_hotSpot.unpack( stream );
159 }
160 
161 }
Marble::GeoDataIconStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataIconStyle.cpp:152
Marble::GeoDataIconStyle
Definition: GeoDataIconStyle.h:29
Marble::GeoDataIconStyle::~GeoDataIconStyle
~GeoDataIconStyle()
Definition: GeoDataIconStyle.cpp:67
Marble::GeoDataTypes::GeoDataIconStyleType
const char * GeoDataIconStyleType
Definition: GeoDataTypes.cpp:42
Marble::GeoDataIconStyle::setIcon
void setIcon(const QImage &icon)
Definition: GeoDataIconStyle.cpp:84
GeoDataIconStyle.h
Marble::GeoDataIconStyle::heading
int heading() const
Definition: GeoDataIconStyle.cpp:133
Marble::GeoDataHotSpot::Units
Units
Definition: GeoDataHotSpot.h:30
Marble::GeoDataIconStyle::setScale
void setScale(const float &scale)
Definition: GeoDataIconStyle.cpp:123
MarbleDebug.h
Marble::GeoDataIconStyle::hotSpot
QPointF hotSpot(GeoDataHotSpot::Units &xunits, GeoDataHotSpot::Units &yunits) const
Definition: GeoDataIconStyle.cpp:118
Marble::GeoDataColorStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataColorStyle.cpp:107
Marble::GeoDataColorStyle
an abstract base class for various style classes
Definition: GeoDataColorStyle.h:64
Marble::GeoDataIconStyle::scale
float scale() const
Definition: GeoDataIconStyle.cpp:128
MarbleDirs.h
Marble::GeoDataIconStyle::setIconPath
void setIconPath(const QString &filename)
Definition: GeoDataIconStyle.cpp:89
Marble::GeoDataObject::resolvePath
QString resolvePath(const QString &relativePath) const
Definition: GeoDataObject.cpp:95
Marble::GeoDataIconStyle::icon
QImage icon() const
Definition: GeoDataIconStyle.cpp:99
Marble::GeoDataIconStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataIconStyle.cpp:143
Marble::GeoDataIconStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataIconStyle.cpp:79
Marble::GeoDataColorStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataColorStyle.cpp:116
Marble::GeoDataIconStyle::setHeading
void setHeading(int heading)
Definition: GeoDataIconStyle.cpp:138
Marble::GeoDataIconStyle::GeoDataIconStyle
GeoDataIconStyle()
Definition: GeoDataIconStyle.cpp:52
Marble::GeoDataIconStyle::iconPath
QString iconPath() const
Definition: GeoDataIconStyle.cpp:94
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:111
Marble::GeoDataIconStyle::operator=
GeoDataIconStyle & operator=(const GeoDataIconStyle &other)
Definition: GeoDataIconStyle.cpp:72
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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