##// END OF EJS Templates
All the series to use the same z-plane
Tero Ahola -
r1260:bb770bf92581
parent child
Show More
@@ -1,142 +1,145
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 #ifndef CHARTPRESENTER_H
21 #ifndef CHARTPRESENTER_H
22 #define CHARTPRESENTER_H
22 #define CHARTPRESENTER_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
25 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
26 #include <QRectF>
26 #include <QRectF>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class Chart;
30 class Chart;
31 class QAbstractSeries;
31 class QAbstractSeries;
32 class ChartDataSet;
32 class ChartDataSet;
33 class Domain;
33 class Domain;
34 class ChartAxis;
34 class ChartAxis;
35 class ChartTheme;
35 class ChartTheme;
36 class ChartAnimator;
36 class ChartAnimator;
37 class ChartBackground;
37 class ChartBackground;
38 class ChartAnimation;
38 class ChartAnimation;
39
39
40 class ChartPresenter: public QObject
40 class ChartPresenter: public QObject
41 {
41 {
42 Q_OBJECT
42 Q_OBJECT
43 public:
43 public:
44 enum ZValues {
44 enum ZValues {
45 BackgroundZValue = -1,
45 BackgroundZValue = -1,
46 ShadesZValue,
46 ShadesZValue,
47 GridZValue,
47 GridZValue,
48 LineChartZValue,
48 SeriesZValue,
49 BarSeriesZValue,
49 LineChartZValue = SeriesZValue,
50 ScatterSeriesZValue,
50 BarSeriesZValue = SeriesZValue,
51 PieSeriesZValue,
51 ScatterSeriesZValue = SeriesZValue,
52 PieSeriesZValue = SeriesZValue,
52 AxisZValue,
53 AxisZValue,
53 LegendZValue
54 LegendZValue
54 };
55 };
55 enum State {ShowState,
56
57 enum State {
58 ShowState,
56 ScrollUpState,
59 ScrollUpState,
57 ScrollDownState,
60 ScrollDownState,
58 ScrollLeftState,
61 ScrollLeftState,
59 ScrollRightState,
62 ScrollRightState,
60 ZoomInState,
63 ZoomInState,
61 ZoomOutState
64 ZoomOutState
62 };
65 };
63
66
64 ChartPresenter(QChart* chart,ChartDataSet *dataset);
67 ChartPresenter(QChart* chart,ChartDataSet *dataset);
65 virtual ~ChartPresenter();
68 virtual ~ChartPresenter();
66
69
67 ChartAnimator* animator() const { return m_animator; }
70 ChartAnimator* animator() const { return m_animator; }
68 ChartTheme *chartTheme() const { return m_chartTheme; }
71 ChartTheme *chartTheme() const { return m_chartTheme; }
69 ChartDataSet *dataSet() const { return m_dataset; }
72 ChartDataSet *dataSet() const { return m_dataset; }
70 QGraphicsItem* rootItem() const { return m_chart; }
73 QGraphicsItem* rootItem() const { return m_chart; }
71
74
72 void setTheme(QChart::ChartTheme theme,bool force = true);
75 void setTheme(QChart::ChartTheme theme,bool force = true);
73 QChart::ChartTheme theme();
76 QChart::ChartTheme theme();
74
77
75 void setAnimationOptions(QChart::AnimationOptions options);
78 void setAnimationOptions(QChart::AnimationOptions options);
76 QChart::AnimationOptions animationOptions() const;
79 QChart::AnimationOptions animationOptions() const;
77
80
78 void zoomIn(qreal factor);
81 void zoomIn(qreal factor);
79 void zoomIn(const QRectF& rect);
82 void zoomIn(const QRectF& rect);
80 void zoomOut(qreal factor);
83 void zoomOut(qreal factor);
81 void scroll(int dx,int dy);
84 void scroll(int dx,int dy);
82
85
83 void setGeometry(const QRectF& rect);
86 void setGeometry(const QRectF& rect);
84 QRectF chartGeometry() const { return m_chartRect; }
87 QRectF chartGeometry() const { return m_chartRect; }
85
88
86 void setMinimumMarginHeight(ChartAxis* axis, qreal height);
89 void setMinimumMarginHeight(ChartAxis* axis, qreal height);
87 void setMinimumMarginWidth(ChartAxis* axis, qreal width);
90 void setMinimumMarginWidth(ChartAxis* axis, qreal width);
88 qreal minimumLeftMargin() const { return m_minLeftMargin; }
91 qreal minimumLeftMargin() const { return m_minLeftMargin; }
89 qreal minimumBottomMargin() const { return m_minBottomMargin; }
92 qreal minimumBottomMargin() const { return m_minBottomMargin; }
90
93
91 void startAnimation(ChartAnimation* animation);
94 void startAnimation(ChartAnimation* animation);
92 State state() const { return m_state; }
95 State state() const { return m_state; }
93 QPointF statePoint() const { return m_statePoint; }
96 QPointF statePoint() const { return m_statePoint; }
94 public: //TODO: fix me
97 public: //TODO: fix me
95 void resetAllElements();
98 void resetAllElements();
96 void createChartBackgroundItem();
99 void createChartBackgroundItem();
97 void createChartTitleItem();
100 void createChartTitleItem();
98 QRectF margins() const { return m_chartMargins;}
101 QRectF margins() const { return m_chartMargins;}
99
102
100 public Q_SLOTS:
103 public Q_SLOTS:
101 void handleSeriesAdded(QAbstractSeries* series,Domain* domain);
104 void handleSeriesAdded(QAbstractSeries* series,Domain* domain);
102 void handleSeriesRemoved(QAbstractSeries* series);
105 void handleSeriesRemoved(QAbstractSeries* series);
103 void handleAxisAdded(QAxis* axis,Domain* domain);
106 void handleAxisAdded(QAxis* axis,Domain* domain);
104 void handleAxisRemoved(QAxis* axis);
107 void handleAxisRemoved(QAxis* axis);
105 void updateLayout();
108 void updateLayout();
106
109
107 private Q_SLOTS:
110 private Q_SLOTS:
108 void handleAnimationFinished();
111 void handleAnimationFinished();
109
112
110 Q_SIGNALS:
113 Q_SIGNALS:
111 void geometryChanged(const QRectF& rect);
114 void geometryChanged(const QRectF& rect);
112 void animationsFinished();
115 void animationsFinished();
113
116
114 private:
117 private:
115 QChart* m_chart;
118 QChart* m_chart;
116 ChartAnimator* m_animator;
119 ChartAnimator* m_animator;
117 ChartDataSet* m_dataset;
120 ChartDataSet* m_dataset;
118 ChartTheme *m_chartTheme;
121 ChartTheme *m_chartTheme;
119 QMap<QAbstractSeries *, Chart *> m_chartItems;
122 QMap<QAbstractSeries *, Chart *> m_chartItems;
120 QMap<QAxis *, ChartAxis *> m_axisItems;
123 QMap<QAxis *, ChartAxis *> m_axisItems;
121 QRectF m_rect;
124 QRectF m_rect;
122 QRectF m_chartRect;
125 QRectF m_chartRect;
123 QChart::AnimationOptions m_options;
126 QChart::AnimationOptions m_options;
124 qreal m_minLeftMargin;
127 qreal m_minLeftMargin;
125 qreal m_minBottomMargin;
128 qreal m_minBottomMargin;
126 State m_state;
129 State m_state;
127 QPointF m_statePoint;
130 QPointF m_statePoint;
128 QList<ChartAnimation*> m_animations;
131 QList<ChartAnimation*> m_animations;
129
132
130 public: //TODO: fixme
133 public: //TODO: fixme
131 ChartBackground* m_backgroundItem;
134 ChartBackground* m_backgroundItem;
132 QGraphicsSimpleTextItem* m_titleItem;
135 QGraphicsSimpleTextItem* m_titleItem;
133 int m_marginBig;
136 int m_marginBig;
134 int m_marginSmall;
137 int m_marginSmall;
135 int m_marginTiny;
138 int m_marginTiny;
136 QRectF m_chartMargins;
139 QRectF m_chartMargins;
137 QRectF m_legendMargins;
140 QRectF m_legendMargins;
138 };
141 };
139
142
140 QTCOMMERCIALCHART_END_NAMESPACE
143 QTCOMMERCIALCHART_END_NAMESPACE
141
144
142 #endif /* CHARTPRESENTER_H_ */
145 #endif /* CHARTPRESENTER_H_ */
General Comments 0
You need to be logged in to leave comments. Login now