Marble

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

KDE's Doxygen guidelines are available online.