Marble

GeoDataPolyStyle.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 "GeoDataPolyStyle.h"
7#include "GeoDataTypes.h"
8#include "MarbleDirs.h"
9
10#include <QDataStream>
11#include <QImage>
12
13namespace Marble
14{
15
16class GeoDataPolyStylePrivate
17{
18public:
19 GeoDataPolyStylePrivate()
20 : m_fill(true)
21 , m_outline(true)
22 , m_brushStyle(Qt::SolidPattern)
23 , m_colorIndex(0)
24 {
25 }
26
27 /// whether to fill the polygon
28 bool m_fill;
29 /// whether to draw the outline
30 bool m_outline;
31 Qt::BrushStyle m_brushStyle;
32 /// The value of colorIndex will be maped to a color for brush
33 quint8 m_colorIndex;
34 QString m_texturePath;
35 QImage m_textureImage;
36};
37
39 : d(new GeoDataPolyStylePrivate)
40{
41}
42
44 : GeoDataColorStyle(other)
45 , d(new GeoDataPolyStylePrivate(*other.d))
46{
47}
48
50 : d(new GeoDataPolyStylePrivate)
51{
53}
54
55GeoDataPolyStyle::~GeoDataPolyStyle()
56{
57 delete d;
58}
59
61{
63 *d = *other.d;
64 return *this;
65}
66
67bool GeoDataPolyStyle::operator==(const GeoDataPolyStyle &other) const
68{
69 if (GeoDataColorStyle::operator!=(other)) {
70 return false;
71 }
72
73 return d->m_fill == other.d->m_fill && d->m_outline == other.d->m_outline && d->m_brushStyle == other.d->m_brushStyle;
74}
75
76bool GeoDataPolyStyle::operator!=(const GeoDataPolyStyle &other) const
77{
78 return !this->operator==(other);
79}
80
81const char *GeoDataPolyStyle::nodeType() const
82{
83 return GeoDataTypes::GeoDataPolyStyleType;
84}
85
87{
88 d->m_fill = fill;
89}
90
92{
93 return d->m_fill;
94}
95
97{
98 d->m_outline = outline;
99}
100
102{
103 return d->m_outline;
104}
105
107{
108 d->m_brushStyle = style;
109}
110
112{
113 return d->m_brushStyle;
114}
115
116void GeoDataPolyStyle::setColorIndex(quint8 colorIndex)
117{
118 d->m_colorIndex = colorIndex;
119}
120
122{
123 return d->m_colorIndex;
124}
125
126void GeoDataPolyStyle::setTexturePath(const QString &texturePath)
127{
128 d->m_texturePath = texturePath;
129 d->m_textureImage = QImage();
130}
131
132QString GeoDataPolyStyle::texturePath() const
133{
134 return d->m_texturePath;
135}
136
137QImage GeoDataPolyStyle::textureImage() const
138{
139 if (!d->m_textureImage.isNull()) {
140 return d->m_textureImage;
141 } else if (!d->m_texturePath.isEmpty()) {
142 d->m_textureImage = QImage(resolvePath(d->m_texturePath));
143 }
144
145 return d->m_textureImage;
146}
147
149{
151
152 stream << d->m_fill;
153 stream << d->m_outline;
154 stream << d->m_colorIndex;
155}
156
158{
160
161 stream >> d->m_fill;
162 stream >> d->m_outline;
163 stream >> d->m_colorIndex;
164}
165
166}
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 polygons are drawn
GeoDataPolyStyle()
Construct a new GeoDataPolyStyle.
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
const char * nodeType() const override
Provides type information for downcasting a GeoNode.
void setBrushStyle(const Qt::BrushStyle style)
Set brush style.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
Qt::BrushStyle brushStyle() const
Return brush style.
GeoDataPolyStyle & operator=(const GeoDataPolyStyle &other)
assignment operator
void setColorIndex(quint8 colorIndex)
Set the color index which will be used to assign color to brush.
quint8 colorIndex() const
Return the value of color index.
bool fill() const
Return true if polygons get filled.
void setFill(bool fill)
Set whether to fill the polygon.
void setOutline(bool outline)
Set whether to draw the outline.
bool outline() const
Return true if outlines of polygons get drawn.
Binds a QML item to a specific geodetic location in screen coordinates.
bool isNull() const const
bool isEmpty() const const
SolidPattern
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.