KChart

KChartLeveyJenningsGridAttributes.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 "KChartLeveyJenningsGridAttributes.h"
21 
22 #include "KChartMath_p.h"
23 
24 #include <QBrush>
25 #include <QMap>
26 #include <QPen>
27 
28 #define d d_func()
29 
30 using namespace KChart;
31 
32 class Q_DECL_HIDDEN LeveyJenningsGridAttributes::Private
33 {
34  friend class LeveyJenningsGridAttributes;
35 public:
36  Private();
37 private:
38  QMap< GridType, bool > visible;
41 };
42 
43 LeveyJenningsGridAttributes::Private::Private()
44 {
45  pens[ Calculated ].setCapStyle( Qt::FlatCap );
46  pens[ Calculated ].setColor( Qt::blue );
47  pens[ Expected ].setCapStyle( Qt::FlatCap );
48  pens[ Expected ].setColor( Qt::black );
49 
50  visible[ Calculated ] = true;
51  visible[ Expected ] = true;
52 
53  rangeBrushes[ LeveyJenningsGridAttributes::CriticalRange ] = QBrush( QColor( 255, 255, 192 ) );
54  rangeBrushes[ LeveyJenningsGridAttributes::OutOfRange ] = QBrush( QColor( 255, 128, 128 ) );
55 }
56 
57 
58 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes()
59  : _d( new Private() )
60 {
61  // this bloc left empty intentionally
62 }
63 
64 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes( const LeveyJenningsGridAttributes& r )
65  : _d( new Private( *r.d ) )
66 {
67 }
68 
69 LeveyJenningsGridAttributes & LeveyJenningsGridAttributes::operator=( const LeveyJenningsGridAttributes& r )
70 {
71  if ( this == &r )
72  return *this;
73 
74  *d = *r.d;
75 
76  return *this;
77 }
78 
79 LeveyJenningsGridAttributes::~LeveyJenningsGridAttributes()
80 {
81  delete _d; _d = nullptr;
82 }
83 
84 
85 bool LeveyJenningsGridAttributes::operator==( const LeveyJenningsGridAttributes& r ) const
86 {
87  return isGridVisible( Expected ) == r.isGridVisible( Expected ) &&
88  isGridVisible( Calculated ) == r.isGridVisible( Calculated ) &&
89  gridPen( Expected ) == r.gridPen( Expected ) &&
90  gridPen( Calculated ) == r.gridPen( Calculated );
91 }
92 
93 void LeveyJenningsGridAttributes::setRangeBrush( Range range, const QBrush& brush )
94 {
95  d->rangeBrushes[ range ] = brush;
96 }
97 
98 QBrush LeveyJenningsGridAttributes::rangeBrush( Range range ) const
99 {
100  return d->rangeBrushes[ range ];
101 }
102 
103 
104 void LeveyJenningsGridAttributes::setGridVisible( GridType type, bool visible )
105 {
106  d->visible[ type ] = visible;
107 }
108 
109 bool LeveyJenningsGridAttributes::isGridVisible( GridType type ) const
110 {
111  return d->visible[ type ];
112 }
113 
114 void LeveyJenningsGridAttributes::setGridPen( GridType type, const QPen& pen )
115 {
116  d->pens[ type ] = pen;
117  d->pens[ type ].setCapStyle( Qt::FlatCap );
118 }
119 
120 QPen LeveyJenningsGridAttributes::gridPen( GridType type ) const
121 {
122  return d->pens[ type ];
123 }
A set of attributes controlling the appearance of grids.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 22:39:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.