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
7#include "GeoDataPolyStyle.h"
8#include "GeoDataTypes.h"
9#include "MarbleDirs.h"
10
11#include <QDataStream>
12#include <QImage>
13
14namespace Marble
15{
16
17class GeoDataPolyStylePrivate
18{
19 public:
20 GeoDataPolyStylePrivate()
21 : m_fill(true)
22 , m_outline(true)
23 , m_brushStyle(Qt::SolidPattern)
24 , m_colorIndex(0)
25 {
26 }
27
28 /// whether to fill the polygon
29 bool m_fill;
30 /// whether to draw the outline
31 bool m_outline;
32 Qt::BrushStyle m_brushStyle;
33 /// The value of colorIndex will be maped to a color for brush
34 quint8 m_colorIndex;
35 QString m_texturePath;
36 QImage m_textureImage;
37};
38
40 : d( new GeoDataPolyStylePrivate )
41{
42}
43
45 : GeoDataColorStyle( other ), d( new GeoDataPolyStylePrivate( *other.d ) )
46{
47}
48
50 : d( new GeoDataPolyStylePrivate )
51{
52 setColor( color );
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 &&
74 d->m_outline == other.d->m_outline &&
75 d->m_brushStyle == other.d->m_brushStyle;
76}
77
78bool GeoDataPolyStyle::operator!=( const GeoDataPolyStyle &other ) const
79{
80 return !this->operator==( other );
81}
82
83const char* GeoDataPolyStyle::nodeType() const
84{
85 return GeoDataTypes::GeoDataPolyStyleType;
86}
87
89{
90 d->m_fill = fill;
91}
92
94{
95 return d->m_fill;
96}
97
99{
100 d->m_outline = outline;
101}
102
104{
105 return d->m_outline;
106}
107
109{
110 d->m_brushStyle = style;
111}
112
114{
115 return d->m_brushStyle;
116}
117
118void GeoDataPolyStyle::setColorIndex( quint8 colorIndex )
119{
120 d->m_colorIndex = colorIndex;
121}
122
124{
125 return d->m_colorIndex;
126}
127
128void GeoDataPolyStyle::setTexturePath( const QString& texturePath )
129{
130 d->m_texturePath = texturePath;
131 d->m_textureImage = QImage();
132}
133
134QString GeoDataPolyStyle::texturePath() const
135{
136 return d->m_texturePath;
137}
138
139QImage GeoDataPolyStyle::textureImage() const
140{
141 if ( !d->m_textureImage.isNull() ) {
142 return d->m_textureImage;
143 } else if ( !d->m_texturePath.isEmpty() ) {
144 d->m_textureImage = QImage( resolvePath( d->m_texturePath ) );
145 }
146
147 return d->m_textureImage;
148}
149
151{
152 GeoDataColorStyle::pack( stream );
153
154 stream << d->m_fill;
155 stream << d->m_outline;
156 stream << d->m_colorIndex;
157}
158
160{
162
163 stream >> d->m_fill;
164 stream >> d->m_outline;
165 stream >> d->m_colorIndex;
166}
167
168}
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 Fri May 17 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.