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