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