Marble

GeoDataColorStyle.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// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
6//
7
8#ifndef MARBLE_GEODATACOLORSTYLE_H
9#define MARBLE_GEODATACOLORSTYLE_H
10
11#include "GeoDataObject.h"
12
13#include "geodata_export.h"
14
15class QColor;
16
17namespace Marble
18{
19
20class GeoDataColorStylePrivate;
21
22/**
23 * @short an abstract base class for various style classes
24 *
25 * A GeoDataColorStyle is an abstract class that is the base class for
26 * a number of different style classes. It provides settings for
27 * specifying the color and color mode of the extended style classes.
28 * A GeoDataColorStyle should never be instantiated directly.
29 *
30 * The color contains RGBA, (Red, Green, Blue, Alpha). Color and
31 * opacity (alpha) values have a range of 0 to 255 (00 to ff). For
32 * alpha, 00 is fully transparent and ff is fully opaque. For
33 * example, if you want to apply a blue color with 50 percent opacity
34 * to an overlay, you would specify the following:
35 * 7fff0000, where alpha=0x7f, blue=0xff, green=0x00,
36 * and red=0x00.
37 *
38 * The color mode can either be <b>normal</b> (no effect) or
39 * <b>random</b>. A value of <b>random</b> applies a random linear scale to
40 * the base color as follows.
41 *
42 * To achieve a truly random selection of colors, specify a base color
43 * of white (ffffffff). If you specify a single color component (for
44 * example, a value of ff0000ff for red), random color values for that
45 * one component (red) will be selected. In this case, the values
46 * would range from 00 (black) to ff (full red). If you specify
47 * values for two or for all three color components, a random linear
48 * scale is applied to each color component, with results ranging from
49 * black to the maximum values specified for each component. The
50 * opacity of a color comes from the alpha component of color and is
51 * never randomized.
52 *
53 * @see GeoDataIconStyle
54 * @see GeoDataLabelStyle
55 * @see GeoDataLineStyle
56 */
57class GEODATA_EXPORT GeoDataColorStyle : public GeoDataObject
58{
59public:
60 /// Provides type information for downcasting a GeoData
61 const char *nodeType() const override;
62
63 /**
64 * @brief Set a new color
65 * @param value the new color value
66 */
67 void setColor(const QColor &value);
68 /// Return the color component
69 QColor color() const;
70
71 /// The color mode
72 enum ColorMode { Normal, Random };
73
74 /**
75 * @brief Returns the color that should be painted: Either color() or a randomized
76 * version of it, depending on the colorMode() setting. Randomization happens once
77 * per setColor() call, i.e. repeated calls to paintedColor always return the same
78 * color unless setColor is called in between.
79 */
80 QColor paintedColor() const;
81
82 /**
83 * @brief Set a new color mode
84 * @param colorMode the new color mode value
85 */
86 void setColorMode(ColorMode colorMode);
87 /// Return the color mode
88 ColorMode colorMode() const;
89
90 /**
91 * assignment operator
92 * @param other the other colorstyle
93 */
94 GeoDataColorStyle &operator=(const GeoDataColorStyle &other);
95 bool operator==(const GeoDataColorStyle &other) const;
96 bool operator!=(const GeoDataColorStyle &other) const;
97
98 /**
99 * @brief Serialize the style to a stream
100 * @param stream the stream
101 */
102 void pack(QDataStream &stream) const override;
103 /**
104 * @brief Unserialize the style from a stream
105 * @param stream the stream
106 */
107 void unpack(QDataStream &stream) override;
108
111
112 ~GeoDataColorStyle() override;
113
114 /**
115 * @return Returns a foreground color suitable for e.g. text display on top of the given background color
116 */
117 static QString contrastColor(const QColor &color);
118
119private:
120 GeoDataColorStylePrivate *const d;
121};
122
123}
124
125#endif
an abstract base class for various style classes
A base class for all geodata objects.
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:14:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.