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

marble

  • sources
  • kde-4.12
  • 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 "cstdlib"
13 
14 #include "GeoDataColorStyle.h"
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 const char* GeoDataColorStyle::nodeType() const
69 {
70  return d->nodeType();
71 }
72 
73 void GeoDataColorStyle::setColor( const QColor &value )
74 {
75  d->m_color = value;
76 
77  qreal red = d->m_color.redF();
78  qreal green = d->m_color.greenF();
79  qreal blue = d->m_color.blueF();
80  d->m_randomColor = d->m_color;
81  qreal const randMax = RAND_MAX;
82  d->m_randomColor.setRedF(red*(qrand()/randMax));
83  d->m_randomColor.setGreenF(green*(qrand()/randMax));
84  d->m_randomColor.setBlueF(blue*(qrand()/randMax));
85 }
86 
87 QColor GeoDataColorStyle::color() const
88 {
89  return d->m_color;
90 }
91 
92 QColor GeoDataColorStyle::paintedColor() const
93 {
94  return d->m_colorMode == Normal ? d->m_color : d->m_randomColor;
95 }
96 
97 void GeoDataColorStyle::setColorMode( const ColorMode &colorMode )
98 {
99  d->m_colorMode = colorMode;
100 }
101 
102 GeoDataColorStyle::ColorMode GeoDataColorStyle::colorMode() const
103 {
104  return d->m_colorMode;
105 }
106 
107 void GeoDataColorStyle::pack( QDataStream& stream ) const
108 {
109  GeoDataObject::pack( stream );
110 
111  stream << d->m_color;
112  // FIXME: Why is not colorMode saved?
113 // stream << m_colorMode;
114 }
115 
116 void GeoDataColorStyle::unpack( QDataStream& stream )
117 {
118  GeoDataObject::unpack( stream );
119 
120  stream >> d->m_color;
121  // FIXME: Why is not colorMode saved?
122 // stream >> m_colorMode;
123 }
124 
125 }
GeoDataColorStyle.h
Marble::GeoDataColorStyle::~GeoDataColorStyle
virtual ~GeoDataColorStyle()
Definition: GeoDataColorStyle.cpp:56
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:73
Marble::GeoDataColorStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataColorStyle.cpp:68
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:102
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:107
Marble::GeoDataColorStyle::ColorMode
ColorMode
The color mode.
Definition: GeoDataColorStyle.h:79
Marble::GeoDataTypes::GeoDataColorStyleType
const char * GeoDataColorStyleType
Definition: GeoDataTypes.cpp:31
Marble::GeoDataColorStyle
an abstract base class for various style classes
Definition: GeoDataColorStyle.h:64
Marble::GeoDataColorStyle::Normal
Definition: GeoDataColorStyle.h:79
Marble::GeoDataColorStyle::setColorMode
void setColorMode(const ColorMode &colorMode)
Set a new color mode.
Definition: GeoDataColorStyle.cpp:97
Marble::GeoDataColorStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataColorStyle.cpp:116
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::GeoDataColorStyle::color
QColor color() const
Return the color component.
Definition: GeoDataColorStyle.cpp:87
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:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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