Marble

GeoDataLineStyle.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
4 //
5 
6 
7 #include "GeoDataLineStyle.h"
8 
9 #include "GeoDataTypes.h"
10 
11 #include <QDataStream>
12 
13 namespace Marble
14 {
15 
16 class GeoDataLineStylePrivate
17 {
18  public:
19  GeoDataLineStylePrivate()
20  : m_width( 1.0 ), m_physicalWidth( 0.0 ),
21  m_capStyle( Qt::FlatCap ), m_penStyle( Qt::SolidLine ),
22  m_cosmeticOutline( false ), m_background( false )
23  {
24  }
25 
26  /// The current width of the line
27  float m_width;
28  /// The current real width of the line
29  float m_physicalWidth;
30  Qt::PenCapStyle m_capStyle;
31  Qt::PenStyle m_penStyle;
32  bool m_cosmeticOutline;
33  bool m_background;
34  QVector< qreal > m_pattern;
35 };
36 
38  : d (new GeoDataLineStylePrivate )
39 {
40 }
41 
43  : GeoDataColorStyle( other ), d (new GeoDataLineStylePrivate( *other.d ) )
44 {
45 }
46 
48  : d ( new GeoDataLineStylePrivate )
49 {
50  setColor( color );
51 }
52 
53 GeoDataLineStyle::~GeoDataLineStyle()
54 {
55  delete d;
56 }
57 
59 {
61  *d = *other.d;
62  return *this;
63 }
64 
65 bool GeoDataLineStyle::operator==( const GeoDataLineStyle &other ) const
66 {
67  if ( GeoDataColorStyle::operator!=( other ) ) {
68  return false;
69  }
70 
71  return d->m_width == other.d->m_width &&
72  d->m_physicalWidth == other.d->m_physicalWidth &&
73  d->m_capStyle == other.d->m_capStyle &&
74  d->m_penStyle == other.d->m_penStyle &&
75  d->m_background == other.d->m_background &&
76  d->m_pattern == other.d->m_pattern;
77 }
78 
79 bool GeoDataLineStyle::operator!=( const GeoDataLineStyle &other ) const
80 {
81  return !this->operator==( other );
82 }
83 
84 const char* GeoDataLineStyle::nodeType() const
85 {
86  return GeoDataTypes::GeoDataLineStyleType;
87 }
88 
89 void GeoDataLineStyle::setWidth(float width)
90 {
91  d->m_width = width;
92 }
93 
95 {
96  return d->m_width;
97 }
98 
100 {
101  return d->m_physicalWidth;
102 }
103 
105 {
106  d->m_physicalWidth = realWidth;
107 }
108 
110 {
111  return d->m_cosmeticOutline;
112 }
113 
115 {
116  d->m_cosmeticOutline = enabled;
117 }
118 
120 {
121  return d->m_capStyle;
122 }
123 
125 {
126  d->m_capStyle = style;
127 }
128 
130 {
131  return d->m_penStyle;
132 }
133 
135 {
136  d->m_penStyle = style;
137 }
138 
140 {
141  return d->m_background;
142 }
143 
144 void GeoDataLineStyle::setBackground( bool background )
145 {
146  d->m_background = background;
147 }
148 
150 {
151  return d->m_pattern;
152 }
153 
155 {
156  d->m_pattern = pattern;
157 }
158 
159 void GeoDataLineStyle::pack( QDataStream& stream ) const
160 {
161  GeoDataColorStyle::pack( stream );
162 
163  stream << d->m_width;
164  stream << d->m_physicalWidth;
165  stream << (int)d->m_penStyle;
166  stream << (int)d->m_capStyle;
167  stream << d->m_background;
168 }
169 
171 {
172  GeoDataColorStyle::unpack( stream );
173 
174  stream >> d->m_width;
175  stream >> d->m_physicalWidth;
176  int style;
177  stream >> style;
178  d->m_penStyle = ( Qt::PenStyle ) style;
179  stream >> style;
180  d->m_capStyle = ( Qt::PenCapStyle ) style;
181  stream >> d->m_background;
182 }
183 
184 }
GeoDataLineStyle & operator=(const GeoDataLineStyle &other)
assignment operator
float physicalWidth() const
Return the current physical width of the line.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
float width() const
Return the current width of the line.
void setPenStyle(Qt::PenStyle style)
Set pen cap style.
specifies the style how lines are drawn
Qt::PenStyle penStyle() const
Return the current pen cap style.
GeoDataLineStyle()
Construct a new GeoDataLineStyle.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
bool background() const
Return true if background get drawn.
QColor color() const
Return the color component.
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
Binds a QML item to a specific geodetic location in screen coordinates.
Qt::PenCapStyle capStyle() const
Return the current pen cap style.
void setPhysicalWidth(float realWidth)
Set the physical width of the line (in meters)
GeoDataColorStyle & operator=(const GeoDataColorStyle &other)
assignment operator
void setCapStyle(Qt::PenCapStyle style)
Set pen cap style.
an abstract base class for various style classes
void setWidth(float width)
Set the width of the line.
const char * nodeType() const override
Provides type information for downcasting a GeoData.
void setDashPattern(const QVector< qreal > &pattern)
Sets the dash pattern.
bool cosmeticOutline() const
Return whether the line has a cosmetic 1 pixel outline.
void setCosmeticOutline(bool enabled)
Set whether the line has a cosmetic 1 pixel outline.
SolidLine
QVector< qreal > dashPattern() const
Return the current dash pattern.
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
void setColor(const QColor &value)
Set a new color.
void setBackground(bool background)
Set whether to draw the solid background.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:53:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.