Marble

GeoDataIconStyle.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5//
6
7#ifndef MARBLE_GEODATAICONSTYLE_H
8#define MARBLE_GEODATAICONSTYLE_H
9
10#include "GeoDataColorStyle.h"
11#include "GeoDataHotSpot.h"
12
13#include "geodata_export.h"
14
15#include <QSize>
16
17namespace Marble
18{
19
20class GeoDataIconStylePrivate;
21class RemoteIconLoader;
22
23// Limits for the user in case of scaling the icon too much
24static const QSize s_maximumIconSize = QSize(100, 100);
25static const QSize s_minimumIconSize = QSize(10, 10);
26
27/**
28 */
29class GEODATA_EXPORT GeoDataIconStyle : public GeoDataColorStyle
30{
31public:
32 GeoDataIconStyle();
33 GeoDataIconStyle(const GeoDataIconStyle &other);
34 explicit GeoDataIconStyle(const QString &iconPath, const QPointF &hotSpot = QPointF(0.5, 0.5));
35 ~GeoDataIconStyle() override;
36
37 GeoDataIconStyle &operator=(const GeoDataIconStyle &other);
38
39 bool operator==(const GeoDataIconStyle &other) const;
40 bool operator!=(const GeoDataIconStyle &other) const;
41
42 /// Provides type information for downcasting a GeoData
43 const char *nodeType() const override;
44
45 void setIcon(const QImage &icon);
46 QImage icon() const;
47
48 /**
49 * @brief Returns a scaled version of label icon
50 * @return the scaled icon
51 */
52 QImage scaledIcon() const;
53
54 /**
55 * @brief setIconPath Set the path to load the icon from. Any existing icon is invalidated.
56 * @param filename Path to the icon to load. Can also be a virtual file system like qrc:/
57 */
58 void setIconPath(const QString &filename);
59 QString iconPath() const;
60
61 void setHotSpot(const QPointF &hotSpot, GeoDataHotSpot::Units xunits, GeoDataHotSpot::Units yunits);
62 QPointF hotSpot(GeoDataHotSpot::Units &xunits, GeoDataHotSpot::Units &yunits) const;
63
64 /**
65 * @brief setSize Change the size of @see icon(). A null size (0, 0) is treated as a request to keep
66 * the original icon size. Otherwise the icon will be scaled to the given size. This is especially useful
67 * for vector graphics like .svg or to keep the memory footprint low when loading large images.
68 * @param size Size in pixel that @see icon() should have. When the icon was previously set by #setIcon,
69 * it is resized unless a null size is passed. Otherwise icon() will be scaled to the given size.
70 * @param aspectRatioMode Aspect ratio mode.
71 */
72 void setSize(const QSize &size, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
73
74 /**
75 * @brief size Returns the size @see icon() will have if it can be loaded from @see iconPath.
76 * A null size (default) is returned to indicate that the original size of the icon is used.
77 * @return size specified by @see setSize
78 */
79 QSize size() const;
80
81 void setScale(float scale);
82 float scale() const;
83
84 int heading() const;
85 void setHeading(int heading);
86
87 RemoteIconLoader *remoteIconLoader() const;
88
89 /*
90 * Serializable methods
91 */
92 void pack(QDataStream &stream) const override;
93 void unpack(QDataStream &stream) override;
94
95private:
96 GeoDataIconStylePrivate *const d;
97};
98
99}
100
101#endif
KIOCORE_EXPORT bool operator!=(const UDSEntry &entry, const UDSEntry &other)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.
AspectRatioMode
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.