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
21using namespace KChart;
22
23class Q_DECL_HIDDEN MarkerAttributes::Private
24{
25 friend class ::KChart::MarkerAttributes;
26public:
27 Private();
28private:
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
40MarkerAttributes::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
51MarkerAttributes::MarkerAttributes()
52 : _d( new Private )
53{
54
55}
56
57MarkerAttributes::MarkerAttributes( const MarkerAttributes& r )
58 : _d( new Private( *r._d ) )
59{
60
61}
62
63MarkerAttributes & MarkerAttributes::operator=( const MarkerAttributes& r )
64{
66 copy.swap( *this );
67 return *this;
68}
69
70MarkerAttributes::~MarkerAttributes()
71{
72 delete _d; _d = nullptr;
73}
74
75#define d d_func()
76
77bool 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
102void MarkerAttributes::setVisible( bool visible )
103{
104 d->visible = visible;
105}
106
107bool MarkerAttributes::isVisible() const
108{
109 return d->visible;
110}
111
112void MarkerAttributes::setThreeD( bool value )
113{
114 d->threeD = value;
115}
116
117bool MarkerAttributes::threeD() const
118{
119 return d->threeD;
120}
121
122void MarkerAttributes::setMarkerStylesMap( const MarkerStylesMap & map )
123{
124 d->markerStylesMap = map;
125}
126
127MarkerAttributes::MarkerStylesMap MarkerAttributes::markerStylesMap() const
128{
129 return d->markerStylesMap;
130}
131
133{
134 d->markerStyle = style;
135}
136
137uint MarkerAttributes::markerStyle() const
138{
139 return d->markerStyle;
140}
141
143{
144 d->markerSize = size;
145}
146
147QSizeF MarkerAttributes::markerSize() const
148{
149 return d->markerSize;
150}
151
153{
154 d->markerSizeMode = mode;
155}
156
157MarkerAttributes::MarkerSizeMode MarkerAttributes::markerSizeMode() const
158{
159 return d->markerSizeMode;
160}
161
162
163void MarkerAttributes::setMarkerColor( const QColor& color )
164{
165 d->markerColor = color;
166}
167
168QColor MarkerAttributes::markerColor() const
169{
170 return d->markerColor;
171}
172
173void MarkerAttributes::setCustomMarkerPath( const QPainterPath& path )
174{
175 d->customMarkerPath = path;
176}
177
178QPainterPath MarkerAttributes::customMarkerPath() const
179{
180 return d->customMarkerPath;
181}
182
183void MarkerAttributes::setPen( const QPen& pen )
184{
185 d->markerPen = pen;
186}
187
188QPen MarkerAttributes::pen() const
189{
190 return d->markerPen;
191}
192
193#undef d
194
195#ifndef QT_NO_DEBUG_STREAM
196QDebug 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
A set of attributes controlling the appearance of data set markers.
void setMarkerStyle(uint style)
Set the marker-style to use.
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...
QString path(const QString &relativePath)
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
AbsoluteSize
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:04:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.