KChart

KChartAbstractThreeDAttributes.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 "KChartAbstractThreeDAttributes.h"
21 #include "KChartAbstractThreeDAttributes_p.h"
22 
23 #include "KChartMath_p.h"
24 
25 #include <QDebug>
26 #include <QBrush>
27 
28 #define d d_func()
29 
30 
31 using namespace KChart;
32 
33 
34 AbstractThreeDAttributes::Private::Private()
35  : enabled( false ),
36  depth( 20 ),
37  threeDBrushEnabled( false )
38 {
39 }
40 
41 
42 AbstractThreeDAttributes::AbstractThreeDAttributes()
43  : _d( new Private() )
44 {
45 }
46 
47 AbstractThreeDAttributes::AbstractThreeDAttributes( const AbstractThreeDAttributes& r )
48  : _d( new Private( *r.d ) )
49 {
50 }
51 
52 AbstractThreeDAttributes& AbstractThreeDAttributes::operator= ( const AbstractThreeDAttributes& r )
53 {
54  if ( this == &r )
55  return *this;
56 
57  *d = *r.d;
58 
59  return *this;
60 }
61 
62 AbstractThreeDAttributes::~AbstractThreeDAttributes()
63 {
64  delete _d; _d = nullptr;
65 }
66 
67 
68 bool AbstractThreeDAttributes::operator==( const AbstractThreeDAttributes& r ) const
69 {
70  return isEnabled() == r.isEnabled() &&
71  depth() == r.depth() &&
72  isThreeDBrushEnabled() == r.isThreeDBrushEnabled();
73 }
74 
75 
76 void AbstractThreeDAttributes::init( )
77 {
78 
79 }
80 
81 void AbstractThreeDAttributes::setEnabled( bool enabled )
82 {
83  d->enabled = enabled;
84 }
85 
86 bool AbstractThreeDAttributes::isEnabled() const
87 {
88  return d->enabled;
89 }
90 
91 void AbstractThreeDAttributes::setDepth( qreal depth )
92 {
93  d->depth = depth;
94 }
95 
96 
97 qreal AbstractThreeDAttributes::depth() const
98 {
99  return d->depth;
100 }
101 
102 
103 qreal AbstractThreeDAttributes::validDepth() const
104 {
105  return isEnabled() ? d->depth : 0.0;
106 }
107 
108 bool AbstractThreeDAttributes::isThreeDBrushEnabled() const
109 {
110  return d->threeDBrushEnabled;
111 }
112 
113 void AbstractThreeDAttributes::setThreeDBrushEnabled( bool enabled )
114 {
115  d->threeDBrushEnabled = enabled;
116 }
117 
118 QBrush AbstractThreeDAttributes::threeDBrush( const QBrush& brush, const QRectF& rect ) const
119 {
120  if ( isThreeDBrushEnabled() ) {
121  QLinearGradient gr(rect.topLeft(), rect.bottomRight());
122  gr.setColorAt(0.0, brush.color());
123  gr.setColorAt(0.5, brush.color().lighter(180));
124  gr.setColorAt(1.0, brush.color());
125  return QBrush(gr);
126  }
127  return brush;
128 }
129 
130 #if !defined(QT_NO_DEBUG_STREAM)
132 {
133  dbg << "enabled="<<a.isEnabled()
134  << "depth="<<a.depth();
135  return dbg;
136 }
137 #endif /* QT_NO_DEBUG_STREAM */
void setColorAt(qreal position, const QColor &color)
const QColor & color() const const
bool isEnabled() const const
QPointF topLeft() const const
QRect rect() const const
QColor lighter(int factor) const const
QBrush brush() const
Retrieve the brush to be used for painting datapoints globally.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
QPointF bottomRight() const const
Global namespace.
int depth() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Sep 19 2020 22:36:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.