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 {
73 Normal,
74 Random
75 };
76
77 /**
78 * @brief Returns the color that should be painted: Either color() or a randomized
79 * version of it, depending on the colorMode() setting. Randomization happens once
80 * per setColor() call, i.e. repeated calls to paintedColor always return the same
81 * color unless setColor is called in between.
82 */
83 QColor paintedColor() const;
84
85 /**
86 * @brief Set a new color mode
87 * @param colorMode the new color mode value
88 */
89 void setColorMode(ColorMode colorMode);
90 /// Return the color mode
91 ColorMode colorMode() const;
92
93 /**
94 * assignment operator
95 * @param other the other colorstyle
96 */
97 GeoDataColorStyle &operator=(const GeoDataColorStyle &other);
98 bool operator==(const GeoDataColorStyle &other) const;
99 bool operator!=(const GeoDataColorStyle &other) const;
100
101 /**
102 * @brief Serialize the style to a stream
103 * @param stream the stream
104 */
105 void pack(QDataStream &stream) const override;
106 /**
107 * @brief Unserialize the style from a stream
108 * @param stream the stream
109 */
110 void unpack(QDataStream &stream) override;
111
114
115 ~GeoDataColorStyle() override;
116
117 /**
118 * @return Returns a foreground color suitable for e.g. text display on top of the given background color
119 */
120 static QString contrastColor(const QColor &color);
121
122private:
123 GeoDataColorStylePrivate *const d;
124};
125
126}
127
128#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 Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.