• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • data
GeoDataColorStyle.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Murad Tagirov <tmurad@gmail.com>
9 // Copyright 2012 Mohammed Nafees <nafees.technocool@gmail.com>
10 //
11 
12 #include "GeoDataColorStyle.h"
13 
14 #include "cstdlib"
15 
16 #include "GeoDataTypes.h"
17 
18 namespace Marble
19 {
20 
21 class GeoDataColorStylePrivate
22 {
23  public:
24  GeoDataColorStylePrivate()
25  : m_color( Qt::white ),
26  m_colorMode( GeoDataColorStyle::Normal )
27  {
28  }
29 
30  const char* nodeType() const
31  {
32  return GeoDataTypes::GeoDataColorStyleType;
33  }
34 
36  QColor m_color;
37 
39  QColor m_randomColor;
40 
42  GeoDataColorStyle::ColorMode m_colorMode;
43 };
44 
45 GeoDataColorStyle::GeoDataColorStyle()
46  : d( new GeoDataColorStylePrivate )
47 {
48 }
49 
50 GeoDataColorStyle::GeoDataColorStyle( const GeoDataColorStyle& other )
51  : GeoDataObject( other ),
52  d( new GeoDataColorStylePrivate( *other.d ) )
53 {
54 }
55 
56 GeoDataColorStyle::~GeoDataColorStyle()
57 {
58  delete d;
59 }
60 
61 GeoDataColorStyle& GeoDataColorStyle::operator=( const GeoDataColorStyle& other )
62 {
63  GeoDataObject::operator=( other );
64  *d = *other.d;
65  return *this;
66 }
67 
68 bool GeoDataColorStyle::operator==( const GeoDataColorStyle &other ) const
69 {
70  return equals(other) && d->m_color == other.d->m_color &&
71  d->m_colorMode == other.d->m_colorMode;
72 }
73 
74 bool GeoDataColorStyle::operator!=( const GeoDataColorStyle &other ) const
75 {
76  return !this->operator==(other);
77 }
78 
79 const char* GeoDataColorStyle::nodeType() const
80 {
81  return d->nodeType();
82 }
83 
84 void GeoDataColorStyle::setColor( const QColor &value )
85 {
86  d->m_color = value;
87 
88  qreal red = d->m_color.redF();
89  qreal green = d->m_color.greenF();
90  qreal blue = d->m_color.blueF();
91  d->m_randomColor = d->m_color;
92  qreal const randMax = RAND_MAX;
93  d->m_randomColor.setRedF(red*(qrand()/randMax));
94  d->m_randomColor.setGreenF(green*(qrand()/randMax));
95  d->m_randomColor.setBlueF(blue*(qrand()/randMax));
96 }
97 
98 QColor GeoDataColorStyle::color() const
99 {
100  return d->m_color;
101 }
102 
103 QColor GeoDataColorStyle::paintedColor() const
104 {
105  return d->m_colorMode == Normal ? d->m_color : d->m_randomColor;
106 }
107 
108 void GeoDataColorStyle::setColorMode( const ColorMode &colorMode )
109 {
110  d->m_colorMode = colorMode;
111 }
112 
113 GeoDataColorStyle::ColorMode GeoDataColorStyle::colorMode() const
114 {
115  return d->m_colorMode;
116 }
117 
118 void GeoDataColorStyle::pack( QDataStream& stream ) const
119 {
120  GeoDataObject::pack( stream );
121 
122  stream << d->m_color;
123  // FIXME: Why is not colorMode saved?
124 // stream << m_colorMode;
125 }
126 
127 void GeoDataColorStyle::unpack( QDataStream& stream )
128 {
129  GeoDataObject::unpack( stream );
130 
131  stream >> d->m_color;
132  // FIXME: Why is not colorMode saved?
133 // stream >> m_colorMode;
134 }
135 
136 }
GeoDataColorStyle.h
Marble::GeoDataColorStyle::~GeoDataColorStyle
virtual ~GeoDataColorStyle()
Definition: GeoDataColorStyle.cpp:56
QDataStream
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataColorStyle::setColor
void setColor(const QColor &value)
Set a new color.
Definition: GeoDataColorStyle.cpp:84
Marble::GeoDataColorStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataColorStyle.cpp:79
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
Marble::GeoDataObject::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:114
Marble::GeoDataColorStyle::colorMode
ColorMode colorMode() const
Return the color mode.
Definition: GeoDataColorStyle.cpp:113
Marble::GeoDataColorStyle::operator==
bool operator==(const GeoDataColorStyle &other) const
Definition: GeoDataColorStyle.cpp:68
Marble::GeoDataColorStyle::GeoDataColorStyle
GeoDataColorStyle()
Definition: GeoDataColorStyle.cpp:45
Marble::GeoDataColorStyle::pack
virtual void pack(QDataStream &stream) const
Serialize the style to a stream.
Definition: GeoDataColorStyle.cpp:118
Marble::GeoDataColorStyle::ColorMode
ColorMode
The color mode.
Definition: GeoDataColorStyle.h:79
Marble::GeoDataTypes::GeoDataColorStyleType
const char * GeoDataColorStyleType
Definition: GeoDataTypes.cpp:33
Marble::GeoDataColorStyle
an abstract base class for various style classes
Definition: GeoDataColorStyle.h:64
Marble::GeoDataColorStyle::operator!=
bool operator!=(const GeoDataColorStyle &other) const
Definition: GeoDataColorStyle.cpp:74
QColor
Marble::GeoDataColorStyle::Normal
Definition: GeoDataColorStyle.h:79
Marble::GeoDataColorStyle::setColorMode
void setColorMode(const ColorMode &colorMode)
Set a new color mode.
Definition: GeoDataColorStyle.cpp:108
Marble::GeoDataColorStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataColorStyle.cpp:127
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::GeoDataColorStyle::color
QColor color() const
Return the color component.
Definition: GeoDataColorStyle.cpp:98
Marble::GeoDataObject::unpack
virtual void unpack(QDataStream &steam)
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:120
GeoDataTypes.h
Marble::GeoDataColorStyle::operator=
GeoDataColorStyle & operator=(const GeoDataColorStyle &other)
assignment operator
Definition: GeoDataColorStyle.cpp:61
Marble::GeoDataColorStyle::paintedColor
QColor paintedColor() const
Returns the color that should be painted: Either color() or a randomized version of it...
Definition: GeoDataColorStyle.cpp:103
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal