KChart

KChartMarkerAttributes.cpp
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "KChartMarkerAttributes.h"
21 
22 #include "KChartMath_p.h"
23 
24 #include <QColor>
25 #include <QMap>
26 #include <QPen>
27 #include <QPainterPath>
28 #include <QSizeF>
29 #include <QDebug>
30 #include <qglobal.h>
31 
32 using namespace KChart;
33 
34 class Q_DECL_HIDDEN MarkerAttributes::Private
35 {
36  friend class ::KChart::MarkerAttributes;
37 public:
38  Private();
39 private:
40  bool visible;
41  bool threeD;
42  QMap<uint,uint> markerStylesMap;
43  uint markerStyle;
44  MarkerSizeMode markerSizeMode;
45  QSizeF markerSize;
46  QColor markerColor;
47  QPainterPath customMarkerPath;
48  QPen markerPen;
49 };
50 
51 MarkerAttributes::Private::Private()
52  : visible( false ),
53  threeD( false ),
54  markerStyle( MarkerSquare ),
55  markerSizeMode( AbsoluteSize ),
56  markerSize( 10, 10 ),
57  markerPen( Qt::black )
58 {
59 }
60 
61 
62 MarkerAttributes::MarkerAttributes()
63  : _d( new Private )
64 {
65 
66 }
67 
68 MarkerAttributes::MarkerAttributes( const MarkerAttributes& r )
69  : _d( new Private( *r._d ) )
70 {
71 
72 }
73 
74 MarkerAttributes & MarkerAttributes::operator=( const MarkerAttributes& r )
75 {
77  copy.swap( *this );
78  return *this;
79 }
80 
81 MarkerAttributes::~MarkerAttributes()
82 {
83  delete _d; _d = nullptr;
84 }
85 
86 #define d d_func()
87 
88 bool MarkerAttributes::operator==( const MarkerAttributes& r ) const
89 {
90  /*
91  qDebug() << "MarkerAttributes::operator== finds"
92  << "b" << (isVisible() == r.isVisible())
93  << "c" << (markerStylesMap() == r.markerStylesMap())
94  << "d" << (markerStyle() == r.markerStyle()) << markerStyle() <<r.markerStyle()
95  << "e" << (markerSize() == r.markerSize())
96  << "f" << (markerColor() == r.markerColor())
97  << "p" << (customMarkerPath() == r.customMarkerPath())
98  << "g" << (pen() == r.pen())
99  << "h" << (markerColor() == r.markerColor()) << markerColor() << r.markerColor();
100  */
101  return ( isVisible() == r.isVisible() &&
102  markerStylesMap() == r.markerStylesMap() &&
103  markerStyle() == r.markerStyle() &&
104  markerStyle() == r.markerStyle() &&
105  markerSizeMode() == r.markerSizeMode() &&
106  markerColor() == r.markerColor() &&
107  customMarkerPath() == r.customMarkerPath() &&
108  pen() == r.pen() );
109 }
110 
111 
112 
113 void MarkerAttributes::setVisible( bool visible )
114 {
115  d->visible = visible;
116 }
117 
118 bool MarkerAttributes::isVisible() const
119 {
120  return d->visible;
121 }
122 
123 void MarkerAttributes::setThreeD( bool value )
124 {
125  d->threeD = value;
126 }
127 
128 bool MarkerAttributes::threeD() const
129 {
130  return d->threeD;
131 }
132 
133 void MarkerAttributes::setMarkerStylesMap( const MarkerStylesMap & map )
134 {
135  d->markerStylesMap = map;
136 }
137 
138 MarkerAttributes::MarkerStylesMap MarkerAttributes::markerStylesMap() const
139 {
140  return d->markerStylesMap;
141 }
142 
144 {
145  d->markerStyle = style;
146 }
147 
148 uint MarkerAttributes::markerStyle() const
149 {
150  return d->markerStyle;
151 }
152 
154 {
155  d->markerSize = size;
156 }
157 
158 QSizeF MarkerAttributes::markerSize() const
159 {
160  return d->markerSize;
161 }
162 
164 {
165  d->markerSizeMode = mode;
166 }
167 
168 MarkerAttributes::MarkerSizeMode MarkerAttributes::markerSizeMode() const
169 {
170  return d->markerSizeMode;
171 }
172 
173 
174 void MarkerAttributes::setMarkerColor( const QColor& color )
175 {
176  d->markerColor = color;
177 }
178 
179 QColor MarkerAttributes::markerColor() const
180 {
181  return d->markerColor;
182 }
183 
184 void MarkerAttributes::setCustomMarkerPath( const QPainterPath& path )
185 {
186  d->customMarkerPath = path;
187 }
188 
189 QPainterPath MarkerAttributes::customMarkerPath() const
190 {
191  return d->customMarkerPath;
192 }
193 
194 void MarkerAttributes::setPen( const QPen& pen )
195 {
196  d->markerPen = pen;
197 }
198 
199 QPen MarkerAttributes::pen() const
200 {
201  return d->markerPen;
202 }
203 
204 #undef d
205 
206 #ifndef QT_NO_DEBUG_STREAM
207 QDebug operator<<( QDebug dbg, const MarkerAttributes & ma ) {
208  return dbg << "KChart::MarkerAttributes("
209  << "visible=" << ma.isVisible()
210  << "markerStylesMap=" << ma.markerStylesMap()
211  << "markerStyle=" << ma.markerStyle()
212  << "markerColor=" << ma.markerColor()
213  << "customMarkerPath=" << ma.customMarkerPath()
214  << "pen=" << ma.pen()
215  << ")";
216 }
217 #endif
218 
AbsoluteSize
A set of attributes controlling the appearance of data set markers.
QStyle * style() const const
bool isVisible() const const
QSize size() const const
KIOCORE_EXPORT CopyJob * copy(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
QPen pen() const
Retrieve the pen to be used for painting datapoints globally.
void setMarkerSizeMode(MarkerSizeMode mode)
With this method you can change the way the actual marker size is calculated.
void setMarkerStyle(uint style)
Set the marker-style to use.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
Global namespace.
void setMarkerSize(const QSizeF &size)
Normally you need to specify a valid QSizeF here, but for Legends you can use the invalid size QSizeF...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 22:42:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.