KChart

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

KDE's Doxygen guidelines are available online.