1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #include "declarativeareaseries_p.h" |
31 | #include "declarativelineseries_p.h" |
32 | |
33 | QT_CHARTS_BEGIN_NAMESPACE |
34 | |
35 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
36 | QAreaSeries(parent), |
37 | m_axes(new DeclarativeAxes(this)) |
38 | { |
39 | connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXChanged(QAbstractAxis*))); |
40 | connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYChanged(QAbstractAxis*))); |
41 | connect(sender: m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
42 | connect(sender: m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
43 | connect(sender: m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisAngularChanged(QAbstractAxis*))); |
44 | connect(sender: m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), receiver: this, SIGNAL(axisRadialChanged(QAbstractAxis*))); |
45 | connect(sender: this, SIGNAL(brushChanged()), receiver: this, SLOT(handleBrushChanged())); |
46 | } |
47 | |
48 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries *series) |
49 | { |
50 | QAreaSeries::setUpperSeries(series); |
51 | } |
52 | |
53 | DeclarativeLineSeries *DeclarativeAreaSeries::upperSeries() const |
54 | { |
55 | return qobject_cast<DeclarativeLineSeries *>(object: QAreaSeries::upperSeries()); |
56 | } |
57 | |
58 | void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries *series) |
59 | { |
60 | QAreaSeries::setLowerSeries(series); |
61 | } |
62 | |
63 | DeclarativeLineSeries *DeclarativeAreaSeries::lowerSeries() const |
64 | { |
65 | return qobject_cast<DeclarativeLineSeries *>(object: QAreaSeries::lowerSeries()); |
66 | } |
67 | |
68 | qreal DeclarativeAreaSeries::borderWidth() const |
69 | { |
70 | return pen().widthF(); |
71 | } |
72 | |
73 | void DeclarativeAreaSeries::setBorderWidth(qreal width) |
74 | { |
75 | if (width != pen().widthF()) { |
76 | QPen p = pen(); |
77 | p.setWidthF(width); |
78 | setPen(p); |
79 | emit borderWidthChanged(width); |
80 | } |
81 | } |
82 | |
83 | QString DeclarativeAreaSeries::brushFilename() const |
84 | { |
85 | return m_brushFilename; |
86 | } |
87 | |
88 | void DeclarativeAreaSeries::setBrushFilename(const QString &brushFilename) |
89 | { |
90 | QImage brushImage(brushFilename); |
91 | if (QAreaSeries::brush().textureImage() != brushImage) { |
92 | QBrush brush = QAreaSeries::brush(); |
93 | brush.setTextureImage(brushImage); |
94 | QAreaSeries::setBrush(brush); |
95 | m_brushFilename = brushFilename; |
96 | m_brushImage = brushImage; |
97 | emit brushFilenameChanged(brushFilename); |
98 | } |
99 | } |
100 | |
101 | void DeclarativeAreaSeries::handleBrushChanged() |
102 | { |
103 | // If the texture image of the brush has changed along the brush |
104 | // the brush file name needs to be cleared. |
105 | if (!m_brushFilename.isEmpty() && QAreaSeries::brush().textureImage() != m_brushImage) { |
106 | m_brushFilename.clear(); |
107 | emit brushFilenameChanged(brushFilename: QString("" )); |
108 | } |
109 | } |
110 | |
111 | void DeclarativeAreaSeries::setBrush(const QBrush &brush) |
112 | { |
113 | QAreaSeries::setBrush(brush); |
114 | emit brushChanged(); |
115 | } |
116 | |
117 | QBrush DeclarativeAreaSeries::brush() const |
118 | { |
119 | return QAreaSeries::brush(); |
120 | } |
121 | |
122 | QT_CHARTS_END_NAMESPACE |
123 | |
124 | #include "moc_declarativeareaseries_p.cpp" |
125 | |