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