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

KDE's Doxygen guidelines are available online.