• 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
GeoDataLabelStyle.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 "GeoDataLabelStyle.h"
13 
14 #include <QFont>
15 
16 #include "GeoDataTypes.h"
17 
18 namespace Marble
19 {
20 #ifdef Q_OS_MACX
21 static const int defaultSize = 10;
22 #else
23 static const int defaultSize = 8;
24 #endif
25 
26 
27 class GeoDataLabelStylePrivate
28 {
29  public:
30  GeoDataLabelStylePrivate()
31  : m_scale( 1.0 ),
32  m_alignment( GeoDataLabelStyle::Corner ),
33  m_font( QFont("Sans Serif").family(), defaultSize, 50, false ),
34  m_glow( true )
35  {
36  }
37 
38  explicit GeoDataLabelStylePrivate( const QFont &font )
39  : m_scale( 1.0 ),
40  m_alignment( GeoDataLabelStyle::Corner ),
41  m_font( font ),
42  m_glow( true )
43  {
44  }
45 
46  const char* nodeType() const
47  {
48  return GeoDataTypes::GeoDataLabelStyleType;
49  }
50 
52  float m_scale;
54  GeoDataLabelStyle::Alignment m_alignment;
56  QFont m_font; // Not a KML property
58  bool m_glow; // Not a KML property
59 };
60 
61 GeoDataLabelStyle::GeoDataLabelStyle()
62  : d (new GeoDataLabelStylePrivate )
63 {
64  setColor( QColor( Qt::black ) );
65 }
66 
67 GeoDataLabelStyle::GeoDataLabelStyle( const GeoDataLabelStyle& other )
68  : GeoDataColorStyle( other ), d (new GeoDataLabelStylePrivate( *other.d ) )
69 {
70 }
71 
72 GeoDataLabelStyle::GeoDataLabelStyle( const QFont &font, const QColor &color )
73  : d (new GeoDataLabelStylePrivate( font ) )
74 {
75  setColor( color );
76 }
77 
78 GeoDataLabelStyle::~GeoDataLabelStyle()
79 {
80  delete d;
81 }
82 
83 GeoDataLabelStyle& GeoDataLabelStyle::operator=( const GeoDataLabelStyle& other )
84 {
85  GeoDataColorStyle::operator=( other );
86  *d = *other.d;
87  return *this;
88 }
89 
90 bool GeoDataLabelStyle::operator==( const GeoDataLabelStyle &other ) const
91 {
92  return d->m_scale == other.d->m_scale &&
93  d->m_alignment == other.d->m_alignment &&
94  d->m_font == other.d->m_font &&
95  d->m_glow == other.d->m_glow;
96 }
97 
98 bool GeoDataLabelStyle::operator!=( const GeoDataLabelStyle &other ) const
99 {
100  return !this->operator==( other );
101 }
102 
103 const char* GeoDataLabelStyle::nodeType() const
104 {
105  return d->nodeType();
106 }
107 
108 void GeoDataLabelStyle::setAlignment( GeoDataLabelStyle::Alignment alignment )
109 {
110  d->m_alignment = alignment;
111 }
112 
113 GeoDataLabelStyle::Alignment GeoDataLabelStyle::alignment() const
114 {
115  return d->m_alignment;
116 }
117 
118 void GeoDataLabelStyle::setScale( const float &scale )
119 {
120  d->m_scale = scale;
121 }
122 
123 float GeoDataLabelStyle::scale() const
124 {
125  return d->m_scale;
126 }
127 
128 void GeoDataLabelStyle::setFont( const QFont &font )
129 {
130  d->m_font = font;
131 }
132 
133 QFont GeoDataLabelStyle::font() const
134 {
135  return d->m_font;
136 }
137 
138 bool GeoDataLabelStyle::glow() const
139 {
140  return d->m_glow;
141 }
142 
143 void GeoDataLabelStyle::setGlow(bool on)
144 {
145  d->m_glow = on;
146 }
147 
148 void GeoDataLabelStyle::pack( QDataStream& stream ) const
149 {
150  GeoDataColorStyle::pack( stream );
151 
152  stream << d->m_scale;
153  stream << d->m_alignment;
154  stream << d->m_font;
155 }
156 
157 void GeoDataLabelStyle::unpack( QDataStream& stream )
158 {
159  int a;
160  GeoDataColorStyle::unpack( stream );
161 
162  stream >> d->m_scale;
163  stream >> a;
164  stream >> d->m_font;
165 
166  d->m_alignment = static_cast<GeoDataLabelStyle::Alignment>( a );
167 }
168 
169 }
Marble::GeoDataLabelStyle::scale
float scale() const
Return the current scale of the label.
Definition: GeoDataLabelStyle.cpp:123
Marble::GeoDataLabelStyle::operator==
bool operator==(const GeoDataLabelStyle &other) const
Definition: GeoDataLabelStyle.cpp:90
QDataStream
Marble::GeoDataLabelStyle::GeoDataLabelStyle
GeoDataLabelStyle()
Construct a new GeoDataLabelStyle.
Definition: GeoDataLabelStyle.cpp:61
Marble::GeoDataLabelStyle::~GeoDataLabelStyle
~GeoDataLabelStyle()
Definition: GeoDataLabelStyle.cpp:78
QFont
Marble::defaultSize
static const int defaultSize
Definition: GeoDataLabelStyle.cpp:23
Marble::GeoDataLabelStyle::operator=
GeoDataLabelStyle & operator=(const GeoDataLabelStyle &other)
assignment operator
Definition: GeoDataLabelStyle.cpp:83
Marble::GeoDataColorStyle::setColor
void setColor(const QColor &value)
Set a new color.
Definition: GeoDataColorStyle.cpp:84
Marble::GeoDataLabelStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataLabelStyle.cpp:103
Marble::GeoDataLabelStyle::Alignment
Alignment
Definition: GeoDataLabelStyle.h:39
Marble::GeoDataColorStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataColorStyle.cpp:118
GeoDataLabelStyle.h
Marble::GeoDataTypes::GeoDataLabelStyleType
const char * GeoDataLabelStyleType
Definition: GeoDataTypes.cpp:48
Marble::GeoDataColorStyle
an abstract base class for various style classes
Definition: GeoDataColorStyle.h:64
Marble::GeoDataLabelStyle::setFont
void setFont(const QFont &font)
Set the font of the label.
Definition: GeoDataLabelStyle.cpp:128
QColor
Marble::GeoDataLabelStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataLabelStyle.cpp:157
Marble::GeoDataLabelStyle::glow
bool glow() const
Return true if the text of the label should glow, false otherwise.
Definition: GeoDataLabelStyle.cpp:138
Marble::GeoDataLabelStyle::operator!=
bool operator!=(const GeoDataLabelStyle &other) const
Definition: GeoDataLabelStyle.cpp:98
Marble::GeoDataLabelStyle::setScale
void setScale(const float &scale)
Set the scale of the label.
Definition: GeoDataLabelStyle.cpp:118
Marble::GeoDataLabelStyle::alignment
GeoDataLabelStyle::Alignment alignment() const
Return the alignment of the label.
Definition: GeoDataLabelStyle.cpp:113
Marble::GeoDataLabelStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataLabelStyle.cpp:148
Marble::GeoDataLabelStyle
specifies how the name of a GeoDataFeature is drawn
Definition: GeoDataLabelStyle.h:36
Marble::GeoDataColorStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataColorStyle.cpp:127
Marble::GeoDataLabelStyle::Corner
Definition: GeoDataLabelStyle.h:39
Marble::GeoDataLabelStyle::setGlow
void setGlow(bool on)
Enable or disable a glow effect around the text of the label.
Definition: GeoDataLabelStyle.cpp:143
Marble::GeoDataLabelStyle::setAlignment
void setAlignment(GeoDataLabelStyle::Alignment alignment)
Set the alignment of the label.
Definition: GeoDataLabelStyle.cpp:108
Marble::GeoDataLabelStyle::font
QFont font() const
Return the current font of the label.
Definition: GeoDataLabelStyle.cpp:133
GeoDataTypes.h
Marble::GeoDataColorStyle::operator=
GeoDataColorStyle & operator=(const GeoDataColorStyle &other)
assignment operator
Definition: GeoDataColorStyle.cpp:61
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