##// END OF EJS Templates
Fix area series fill problem when component series have points visible...
Miikka Heikkinen -
r2452:7ed67b83fa6c
parent child
Show More
@@ -1,107 +1,110
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 // W A R N I N G
22 22 // -------------
23 23 //
24 24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 25 // implementation detail. This header file may change from version to
26 26 // version without notice, or even be removed.
27 27 //
28 28 // We mean it.
29 29
30 30 #ifndef AREACHARTITEM_H
31 31 #define AREACHARTITEM_H
32 32
33 33 #include "qchartglobal.h"
34 34 #include "linechartitem_p.h"
35 35 #include <QPen>
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 39 class QAreaSeries;
40 40 class AreaChartItem;
41 41
42 42 class AreaChartItem : public ChartItem
43 43 {
44 44 Q_OBJECT
45 45 public:
46 46 AreaChartItem(QAreaSeries *areaSeries, QGraphicsItem* item = 0);
47 47 ~AreaChartItem();
48 48
49 49 //from QGraphicsItem
50 50 QRectF boundingRect() const;
51 51 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
52 52 QPainterPath shape() const;
53 53
54 54 LineChartItem *upperLineItem() const { return m_upper; }
55 55 LineChartItem *lowerLineItem() const { return m_lower; }
56 56
57 57 void updatePath();
58 58
59 59 void setPresenter(ChartPresenter *presenter);
60 60 protected:
61 61 void mousePressEvent(QGraphicsSceneMouseEvent *event);
62 62 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
63 63 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
64 64
65 65 Q_SIGNALS:
66 66 void clicked(const QPointF &point);
67 67 void hovered(const QPointF &point, bool state);
68 68
69 69 public Q_SLOTS:
70 70 void handleUpdated();
71 71 void handleDomainUpdated();
72 72
73 73 private:
74 74 QAreaSeries *m_series;
75 75 LineChartItem *m_upper;
76 76 LineChartItem *m_lower;
77 77 QPainterPath m_path;
78 78 QRectF m_rect;
79 79 QPen m_linePen;
80 80 QPen m_pointPen;
81 81 QBrush m_brush;
82 82 bool m_pointsVisible;
83 83
84 84 };
85 85
86 86 class AreaBoundItem : public LineChartItem
87 87 {
88 88 public:
89 89 AreaBoundItem(AreaChartItem *area, QLineSeries *lineSeries,QGraphicsItem* item = 0)
90 90 : LineChartItem(lineSeries, item), m_item(area)
91 91 {
92 92 }
93 93 ~AreaBoundItem() {}
94 94
95 95 void updateGeometry()
96 96 {
97 // Turn off points drawing from component line chart item, as that
98 // messes up the fill for area series.
99 suppressPoints();
97 100 LineChartItem::updateGeometry();
98 101 m_item->updatePath();
99 102 }
100 103
101 104 private:
102 105 AreaChartItem *m_item;
103 106 };
104 107
105 108 QTCOMMERCIALCHART_END_NAMESPACE
106 109
107 110 #endif
@@ -1,78 +1,79
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2013 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 // W A R N I N G
22 22 // -------------
23 23 //
24 24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 25 // implementation detail. This header file may change from version to
26 26 // version without notice, or even be removed.
27 27 //
28 28 // We mean it.
29 29
30 30 #ifndef LINECHARTITEM_H
31 31 #define LINECHARTITEM_H
32 32
33 33 #include "qchartglobal.h"
34 34 #include "xychart_p.h"
35 35 #include <QPen>
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 39 class QLineSeries;
40 40 class ChartPresenter;
41 41
42 42 class LineChartItem : public XYChart
43 43 {
44 44 Q_OBJECT
45 45 Q_INTERFACES(QGraphicsItem)
46 46 public:
47 47 explicit LineChartItem(QLineSeries *series, QGraphicsItem* item = 0);
48 48 ~LineChartItem() {}
49 49
50 50 //from QGraphicsItem
51 51 QRectF boundingRect() const;
52 52 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
53 53 QPainterPath shape() const;
54 54
55 55 QPainterPath path() const { return m_linePath; }
56 56
57 57 public Q_SLOTS:
58 58 void handleUpdated();
59 59
60 60 protected:
61 61 void updateGeometry();
62 62 void mousePressEvent(QGraphicsSceneMouseEvent *event);
63 63 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
64 64 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
65 void suppressPoints() { m_pointsVisible = false; }
65 66
66 67 private:
67 68 QLineSeries *m_series;
68 69 QPainterPath m_path;
69 70 QPainterPath m_linePath;
70 71 QVector<QPointF> m_points;
71 72 QRectF m_rect;
72 73 QPen m_linePen;
73 74 bool m_pointsVisible;
74 75 };
75 76
76 77 QTCOMMERCIALCHART_END_NAMESPACE
77 78
78 79 #endif
General Comments 0
You need to be logged in to leave comments. Login now