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
7#include "GeoDataLineStyle.h"
8
9#include "GeoDataTypes.h"
10
11#include <QDataStream>
12
13namespace Marble
14{
15
16class 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
53GeoDataLineStyle::~GeoDataLineStyle()
54{
55 delete d;
56}
57
59{
61 *d = *other.d;
62 return *this;
63}
64
65bool 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
79bool GeoDataLineStyle::operator!=( const GeoDataLineStyle &other ) const
80{
81 return !this->operator==( other );
82}
83
84const char* GeoDataLineStyle::nodeType() const
85{
86 return GeoDataTypes::GeoDataLineStyleType;
87}
88
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
144void 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
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{
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}
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.
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 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 setDashPattern(const QVector< qreal > &pattern)
Sets the dash pattern.
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.
QVector< qreal > dashPattern() const
Return the current dash pattern.
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 Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.