KChart

KChartValueTrackerAttributes.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 "KChartValueTrackerAttributes.h"
21 #include "KChartMath_p.h"
22 
23 #include <QPen>
24 #include <QSizeF>
25 #include <QBrush>
26 
27 #define d d_func()
28 
29 using namespace KChart;
30 
31 class Q_DECL_HIDDEN ValueTrackerAttributes::Private
32 {
33  friend class ValueTrackerAttributes;
34  public:
35  Private();
36  private:
37  QPen linePen;
38  QPen markerPen;
39  QBrush markerBrush;
40  QBrush arrowBrush;
41  QSizeF markerSize;
42  bool enabled;
43  QBrush areaBrush;
44  Qt::Orientations orientations;
45 };
46 
47 ValueTrackerAttributes::Private::Private()
48  : linePen( QPen( QColor( 80, 80, 80, 200 ) ) ),
49  markerSize( QSizeF( 6.0, 6.0 ) ),
50  enabled( false ),
51  areaBrush( QBrush() ),
52  orientations(Qt::Vertical|Qt::Horizontal)
53 {
54  markerPen = linePen;
55  arrowBrush = linePen.color();
56 }
57 
58 
59 ValueTrackerAttributes::ValueTrackerAttributes()
60  : _d( new Private() )
61 {
62 }
63 
64 ValueTrackerAttributes::ValueTrackerAttributes( const ValueTrackerAttributes& r )
65  : _d( new Private( *r.d ) )
66 {
67 }
68 
69 ValueTrackerAttributes & ValueTrackerAttributes::operator=( const ValueTrackerAttributes& r )
70 {
71  if ( this == &r )
72  return *this;
73 
74  *d = *r.d;
75 
76  return *this;
77 }
78 
79 ValueTrackerAttributes::~ValueTrackerAttributes()
80 {
81  delete _d; _d = nullptr;
82 }
83 
84 
85 bool ValueTrackerAttributes::operator==( const ValueTrackerAttributes& r ) const
86 {
87  return ( linePen() == r.linePen() &&
88  markerPen() == r.markerPen() &&
89  markerBrush() == r.markerBrush() &&
90  arrowBrush() == r.arrowBrush() &&
91  areaBrush() == r.areaBrush() &&
92  markerSize() == r.markerSize() &&
93  isEnabled() == r.isEnabled() );
94 }
95 
97 {
98  d->linePen = pen;
99  d->markerPen = pen;
100  d->markerBrush = QBrush();
101  d->arrowBrush = pen.color();
102 }
103 
105 {
106  return d->linePen;
107 }
108 
109 void ValueTrackerAttributes::setLinePen( const QPen &pen )
110 {
111  d->linePen = pen;
112 }
113 
114 QPen ValueTrackerAttributes::linePen() const
115 {
116  return d->linePen;
117 }
118 
119 void ValueTrackerAttributes::setMarkerPen( const QPen &pen )
120 {
121  d->markerPen = pen;
122 }
123 
124 QPen ValueTrackerAttributes::markerPen() const
125 {
126  return d->markerPen;
127 }
128 
129 void ValueTrackerAttributes::setMarkerBrush( const QBrush &brush )
130 {
131  d->markerBrush = brush;
132 }
133 
134 QBrush ValueTrackerAttributes::markerBrush() const
135 {
136  return d->markerBrush;
137 }
138 
139 void ValueTrackerAttributes::setArrowBrush( const QBrush &brush )
140 {
141  d->arrowBrush = brush;
142 }
143 
144 QBrush ValueTrackerAttributes::arrowBrush() const
145 {
146  return d->arrowBrush;
147 }
148 
150 {
151  d->areaBrush = brush;
152 }
153 
155 {
156  return d->areaBrush;
157 }
158 
160 {
161  d->markerSize = size;
162 }
163 
165 {
166  return d->markerSize;
167 }
168 
170 {
171  return d->orientations;
172 }
173 
175 {
176  d->orientations = orientations;
177 }
178 
180 {
181  d->enabled = enabled;
182 }
183 
185 {
186  return d->enabled;
187 }
188 
189 #if !defined(QT_NO_DEBUG_STREAM)
191 {
192  dbg << "KChart::ValueTrackerAttributes("
193  << "linePen="<<va.linePen()
194  << "markerPen="<<va.markerPen()
195  << "markerBrush="<<va.markerBrush()
196  << "arrowBrush="<<va.arrowBrush()
197  << "markerSize="<<va.markerSize()
198  << "enabled="<<va.isEnabled()
199  << ")";
200  return dbg;
201 }
202 #endif /* QT_NO_DEBUG_STREAM */
void setOrientations(Qt::Orientations orientations)
Set the orientations used to show the value tracking.
void setEnabled(bool enabled)
Set whether value tracking should be enabled for a specific index or not.
QColor color() const const
void setMarkerSize(const QSizeF &size)
Set the size of the markers.
void setAreaBrush(const QBrush &brush)
Set the brush the area below the value tracking lines should be filled with.
void setPen(const QPen &pen)
Set the pen the value tracking lines and markers will be drawn with.
Cell-specific attributes regarding value tracking.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
typedef Orientations
Global namespace.
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.