KChart

KChartMarkerAttributes.cpp
1 /*
2  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #include "KChartMarkerAttributes.h"
10 
11 #include "KChartMath_p.h"
12 
13 #include <QColor>
14 #include <QMap>
15 #include <QPen>
16 #include <QPainterPath>
17 #include <QSizeF>
18 #include <QDebug>
19 #include <qglobal.h>
20 
21 using namespace KChart;
22 
23 class Q_DECL_HIDDEN MarkerAttributes::Private
24 {
25  friend class ::KChart::MarkerAttributes;
26 public:
27  Private();
28 private:
29  bool visible;
30  bool threeD;
31  QMap<uint,uint> markerStylesMap;
32  uint markerStyle;
33  MarkerSizeMode markerSizeMode;
34  QSizeF markerSize;
35  QColor markerColor;
36  QPainterPath customMarkerPath;
37  QPen markerPen;
38 };
39 
40 MarkerAttributes::Private::Private()
41  : visible( false ),
42  threeD( false ),
43  markerStyle( MarkerSquare ),
44  markerSizeMode( AbsoluteSize ),
45  markerSize( 10, 10 ),
46  markerPen( Qt::black )
47 {
48 }
49 
50 
51 MarkerAttributes::MarkerAttributes()
52  : _d( new Private )
53 {
54 
55 }
56 
57 MarkerAttributes::MarkerAttributes( const MarkerAttributes& r )
58  : _d( new Private( *r._d ) )
59 {
60 
61 }
62 
63 MarkerAttributes & MarkerAttributes::operator=( const MarkerAttributes& r )
64 {
66  copy.swap( *this );
67  return *this;
68 }
69 
70 MarkerAttributes::~MarkerAttributes()
71 {
72  delete _d; _d = nullptr;
73 }
74 
75 #define d d_func()
76 
77 bool MarkerAttributes::operator==( const MarkerAttributes& r ) const
78 {
79  /*
80  qDebug() << "MarkerAttributes::operator== finds"
81  << "b" << (isVisible() == r.isVisible())
82  << "c" << (markerStylesMap() == r.markerStylesMap())
83  << "d" << (markerStyle() == r.markerStyle()) << markerStyle() <<r.markerStyle()
84  << "e" << (markerSize() == r.markerSize())
85  << "f" << (markerColor() == r.markerColor())
86  << "p" << (customMarkerPath() == r.customMarkerPath())
87  << "g" << (pen() == r.pen())
88  << "h" << (markerColor() == r.markerColor()) << markerColor() << r.markerColor();
89  */
90  return ( isVisible() == r.isVisible() &&
91  markerStylesMap() == r.markerStylesMap() &&
92  markerStyle() == r.markerStyle() &&
93  markerStyle() == r.markerStyle() &&
94  markerSizeMode() == r.markerSizeMode() &&
95  markerColor() == r.markerColor() &&
96  customMarkerPath() == r.customMarkerPath() &&
97  pen() == r.pen() );
98 }
99 
100 
101 
102 void MarkerAttributes::setVisible( bool visible )
103 {
104  d->visible = visible;
105 }
106 
107 bool MarkerAttributes::isVisible() const
108 {
109  return d->visible;
110 }
111 
112 void MarkerAttributes::setThreeD( bool value )
113 {
114  d->threeD = value;
115 }
116 
117 bool MarkerAttributes::threeD() const
118 {
119  return d->threeD;
120 }
121 
122 void MarkerAttributes::setMarkerStylesMap( const MarkerStylesMap & map )
123 {
124  d->markerStylesMap = map;
125 }
126 
127 MarkerAttributes::MarkerStylesMap MarkerAttributes::markerStylesMap() const
128 {
129  return d->markerStylesMap;
130 }
131 
133 {
134  d->markerStyle = style;
135 }
136 
137 uint MarkerAttributes::markerStyle() const
138 {
139  return d->markerStyle;
140 }
141 
143 {
144  d->markerSize = size;
145 }
146 
147 QSizeF MarkerAttributes::markerSize() const
148 {
149  return d->markerSize;
150 }
151 
153 {
154  d->markerSizeMode = mode;
155 }
156 
157 MarkerAttributes::MarkerSizeMode MarkerAttributes::markerSizeMode() const
158 {
159  return d->markerSizeMode;
160 }
161 
162 
163 void MarkerAttributes::setMarkerColor( const QColor& color )
164 {
165  d->markerColor = color;
166 }
167 
168 QColor MarkerAttributes::markerColor() const
169 {
170  return d->markerColor;
171 }
172 
173 void MarkerAttributes::setCustomMarkerPath( const QPainterPath& path )
174 {
175  d->customMarkerPath = path;
176 }
177 
178 QPainterPath MarkerAttributes::customMarkerPath() const
179 {
180  return d->customMarkerPath;
181 }
182 
183 void MarkerAttributes::setPen( const QPen& pen )
184 {
185  d->markerPen = pen;
186 }
187 
188 QPen MarkerAttributes::pen() const
189 {
190  return d->markerPen;
191 }
192 
193 #undef d
194 
195 #ifndef QT_NO_DEBUG_STREAM
196 QDebug operator<<( QDebug dbg, const MarkerAttributes & ma ) {
197  return dbg << "KChart::MarkerAttributes("
198  << "visible=" << ma.isVisible()
199  << "markerStylesMap=" << ma.markerStylesMap()
200  << "markerStyle=" << ma.markerStyle()
201  << "markerColor=" << ma.markerColor()
202  << "customMarkerPath=" << ma.customMarkerPath()
203  << "pen=" << ma.pen()
204  << ")";
205 }
206 #endif
207 
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
void setMarkerSizeMode(MarkerSizeMode mode)
With this method you can change the way the actual marker size is calculated.
void setMarkerSize(const QSizeF &size)
Normally you need to specify a valid QSizeF here, but for Legends you can use the invalid size QSizeF...
AbsoluteSize
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
A set of attributes controlling the appearance of data set markers.
void setMarkerStyle(uint style)
Set the marker-style to use.
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 03:50:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.