@@ -1,37 +1,37 | |||||
1 | #ifndef CHARTVIEW_H_ |
|
1 | #ifndef CHARTVIEW_H_ | |
2 | #define CHARTVIEW_H_ |
|
2 | #define CHARTVIEW_H_ | |
3 |
|
3 | |||
4 | #include <QChartView> |
|
4 | #include <QChartView> | |
5 | #include <QTimer> |
|
5 | #include <QTimer> | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 | class QSplineSeries; |
|
9 | class QSplineSeries; | |
10 | class QLineSeries; |
|
10 | class QLineSeries; | |
11 | QTCOMMERCIALCHART_END_NAMESPACE |
|
11 | QTCOMMERCIALCHART_END_NAMESPACE | |
12 |
|
12 | |||
13 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
13 | QTCOMMERCIALCHART_USE_NAMESPACE | |
14 |
|
14 | |||
15 | //![1] |
|
15 | //![1] | |
16 | class ChartView: public QChartView |
|
16 | class ChartView: public QChartView | |
17 | { |
|
17 | { | |
18 | Q_OBJECT |
|
18 | Q_OBJECT | |
19 | public: |
|
19 | public: | |
20 | ChartView(QWidget* parent=0); |
|
20 | ChartView(QWidget* parent = 0); | |
21 | virtual ~ChartView(); |
|
21 | virtual ~ChartView(); | |
22 |
|
22 | |||
23 | public slots: |
|
23 | public slots: | |
24 | void handleTimeout(); |
|
24 | void handleTimeout(); | |
25 |
|
25 | |||
26 | private: |
|
26 | private: | |
27 | QTimer m_timer; |
|
27 | QTimer m_timer; | |
28 | QLineSeries* m_series0; |
|
28 | QLineSeries* m_series0; | |
29 | QSplineSeries* m_series1; |
|
29 | QSplineSeries* m_series1; | |
30 | QStringList m_titles; |
|
30 | QStringList m_titles; | |
31 | qreal m_step; |
|
31 | qreal m_step; | |
32 | qreal m_x; |
|
32 | qreal m_x; | |
33 | qreal m_y; |
|
33 | qreal m_y; | |
34 | }; |
|
34 | }; | |
35 | //![1] |
|
35 | //![1] | |
36 |
|
36 | |||
37 | #endif /* CHARTVIEW_H_ */ |
|
37 | #endif /* CHARTVIEW_H_ */ |
@@ -1,29 +1,29 | |||||
1 | #ifndef CHARTVIEW_H_ |
|
1 | #ifndef CHARTVIEW_H_ | |
2 | #define CHARTVIEW_H_ |
|
2 | #define CHARTVIEW_H_ | |
3 |
|
3 | |||
4 | #include <QChartView> |
|
4 | #include <QChartView> | |
5 | #include <QTimer> |
|
5 | #include <QTimer> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
7 | QTCOMMERCIALCHART_USE_NAMESPACE | |
8 |
|
8 | |||
9 | //![1] |
|
9 | //![1] | |
10 | class ChartView: public QChartView |
|
10 | class ChartView: public QChartView | |
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
13 | public: | |
14 | ChartView(QWidget* parent=0); |
|
14 | ChartView(QWidget* parent = 0); | |
15 | virtual ~ChartView(); |
|
15 | virtual ~ChartView(); | |
16 |
|
16 | |||
17 | public slots: |
|
17 | public slots: | |
18 | void handleTimeout(); |
|
18 | void handleTimeout(); | |
19 | void handlePointClicked(const QPointF& point); |
|
19 | void handlePointClicked(const QPointF& point); | |
20 |
|
20 | |||
21 | private: |
|
21 | private: | |
22 | QTimer m_timer; |
|
22 | QTimer m_timer; | |
23 | QList<QSeries*> m_series; |
|
23 | QList<QSeries*> m_series; | |
24 | QStringList m_titles; |
|
24 | QStringList m_titles; | |
25 | int m_index; |
|
25 | int m_index; | |
26 | }; |
|
26 | }; | |
27 | //![1] |
|
27 | //![1] | |
28 |
|
28 | |||
29 | #endif /* CHARTVIEW_H_ */ |
|
29 | #endif /* CHARTVIEW_H_ */ |
@@ -1,76 +1,73 | |||||
1 | #ifndef AREACHARTITEM_H |
|
1 | #ifndef AREACHARTITEM_H | |
2 | #define AREACHARTITEM_H |
|
2 | #define AREACHARTITEM_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "linechartitem_p.h" |
|
5 | #include "linechartitem_p.h" | |
6 | #include <QPen> |
|
6 | #include <QPen> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QAreaSeries; |
|
10 | class QAreaSeries; | |
11 | class AreaChartItem; |
|
11 | class AreaChartItem; | |
12 |
|
12 | |||
13 | class AreaChartItem : public ChartItem |
|
13 | class AreaChartItem : public ChartItem | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 | AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter); |
|
17 | AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter); | |
18 | ~ AreaChartItem(); |
|
18 | ~ AreaChartItem(); | |
19 |
|
19 | |||
20 | //from QGraphicsItem |
|
20 | //from QGraphicsItem | |
21 | QRectF boundingRect() const; |
|
21 | QRectF boundingRect() const; | |
22 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
22 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |
23 | QPainterPath shape() const; |
|
23 | QPainterPath shape() const; | |
24 |
|
24 | |||
25 |
LineChartItem* upperLineItem() const { return m_upper |
|
25 | LineChartItem* upperLineItem() const { return m_upper; } | |
26 |
LineChartItem* lowerLineItem() const { return m_lower |
|
26 | LineChartItem* lowerLineItem() const { return m_lower; } | |
27 |
|
27 | |||
28 | void updatePath(); |
|
28 | void updatePath(); | |
29 |
|
29 | |||
30 | protected: |
|
30 | protected: | |
31 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
31 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
32 |
|
32 | |||
33 | signals: |
|
33 | signals: | |
34 | void clicked(const QPointF &point); |
|
34 | void clicked(const QPointF &point); | |
35 |
|
35 | |||
36 | public slots: |
|
36 | public slots: | |
37 | void handleUpdated(); |
|
37 | void handleUpdated(); | |
38 | void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
38 | void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
39 | void handleGeometryChanged(const QRectF &size); |
|
39 | void handleGeometryChanged(const QRectF &size); | |
40 |
|
40 | |||
41 | private: |
|
41 | private: | |
42 | QAreaSeries* m_series; |
|
42 | QAreaSeries* m_series; | |
43 | LineChartItem* m_upper; |
|
43 | LineChartItem* m_upper; | |
44 | LineChartItem* m_lower; |
|
44 | LineChartItem* m_lower; | |
45 | QPainterPath m_path; |
|
45 | QPainterPath m_path; | |
46 | QRectF m_rect; |
|
46 | QRectF m_rect; | |
47 | QRectF m_clipRect; |
|
47 | QRectF m_clipRect; | |
48 | QPen m_linePen; |
|
48 | QPen m_linePen; | |
49 | QPen m_pointPen; |
|
49 | QPen m_pointPen; | |
50 | QBrush m_brush; |
|
50 | QBrush m_brush; | |
51 | bool m_pointsVisible; |
|
51 | bool m_pointsVisible; | |
52 |
|
52 | |||
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | class AreaBoundItem : public LineChartItem |
|
55 | class AreaBoundItem : public LineChartItem | |
56 | { |
|
56 | { | |
57 | public: |
|
57 | public: | |
58 | AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries):LineChartItem(lineSeries,0), |
|
58 | AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries) : LineChartItem(lineSeries, 0), m_item(item) {} | |
59 | m_item(item){ |
|
59 | ~AreaBoundItem(){} | |
60 | }; |
|
|||
61 |
|
60 | |||
62 | ~AreaBoundItem(){}; |
|
61 | void setLayout(QVector<QPointF> &points) { | |
63 |
|
||||
64 | void setLayout(QVector<QPointF> &points){ |
|
|||
65 | LineChartItem::setLayout(points); |
|
62 | LineChartItem::setLayout(points); | |
66 | m_item->updatePath(); |
|
63 | m_item->updatePath(); | |
67 | } |
|
64 | } | |
68 |
|
65 | |||
69 | private: |
|
66 | private: | |
70 | AreaChartItem* m_item; |
|
67 | AreaChartItem* m_item; | |
71 |
|
68 | |||
72 | }; |
|
69 | }; | |
73 |
|
70 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
71 | QTCOMMERCIALCHART_END_NAMESPACE | |
75 |
|
72 | |||
76 | #endif |
|
73 | #endif |
@@ -1,52 +1,52 | |||||
1 | #ifndef QAREASERIES_H_ |
|
1 | #ifndef QAREASERIES_H_ | |
2 | #define QAREASERIES_H_ |
|
2 | #define QAREASERIES_H_ | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qseries.h> |
|
5 | #include <qseries.h> | |
6 | #include <QPen> |
|
6 | #include <QPen> | |
7 | #include <QBrush> |
|
7 | #include <QBrush> | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 | class QLineSeries; |
|
10 | class QLineSeries; | |
11 |
|
11 | |||
12 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries |
|
12 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | public: |
|
15 | public: | |
16 | QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries=0); |
|
16 | QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); | |
17 | virtual ~QAreaSeries(); |
|
17 | virtual ~QAreaSeries(); | |
18 |
|
18 | |||
19 | public: // from QChartSeries |
|
19 | public: // from QChartSeries | |
20 | virtual QSeriesType type() const { return QSeries::SeriesTypeArea;} |
|
20 | virtual QSeriesType type() const { return QSeries::SeriesTypeArea; } | |
21 |
|
21 | |||
22 | QLineSeries* upperSeries() const { return m_upperSeries;} |
|
22 | QLineSeries* upperSeries() const { return m_upperSeries; } | |
23 | QLineSeries* lowerSeries() const { return m_lowerSeries;} |
|
23 | QLineSeries* lowerSeries() const { return m_lowerSeries; } | |
24 |
|
24 | |||
25 | void setPen(const QPen &pen); |
|
25 | void setPen(const QPen &pen); | |
26 | QPen pen() const { return m_pen;} |
|
26 | QPen pen() const { return m_pen;} | |
27 |
|
27 | |||
28 | void setBrush(const QBrush &brush); |
|
28 | void setBrush(const QBrush &brush); | |
29 | QBrush brush() const { return m_brush;} |
|
29 | QBrush brush() const { return m_brush;} | |
30 |
|
30 | |||
31 | void setPointsVisible(bool visible); |
|
31 | void setPointsVisible(bool visible); | |
32 | bool pointsVisible() const {return m_pointsVisible;} |
|
32 | bool pointsVisible() const { return m_pointsVisible; } | |
33 |
|
33 | |||
34 | // bool setModel(QAbstractItemModel* model); |
|
34 | // bool setModel(QAbstractItemModel* model); | |
35 | // void setModelMappingUpper(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); |
|
35 | // void setModelMappingUpper(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); | |
36 | // void setModelMappingLower(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); |
|
36 | // void setModelMappingLower(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); | |
37 |
|
37 | |||
38 | signals: |
|
38 | signals: | |
39 | void updated(); |
|
39 | void updated(); | |
40 | void clicked(const QPointF &point); |
|
40 | void clicked(const QPointF &point); | |
41 |
|
41 | |||
42 | private: |
|
42 | private: | |
43 | QBrush m_brush; |
|
43 | QBrush m_brush; | |
44 | QPen m_pen; |
|
44 | QPen m_pen; | |
45 | QLineSeries* m_upperSeries; |
|
45 | QLineSeries* m_upperSeries; | |
46 | QLineSeries* m_lowerSeries; |
|
46 | QLineSeries* m_lowerSeries; | |
47 | bool m_pointsVisible; |
|
47 | bool m_pointsVisible; | |
48 | }; |
|
48 | }; | |
49 |
|
49 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
50 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
51 | |||
52 | #endif |
|
52 | #endif |
@@ -1,123 +1,123 | |||||
1 | #ifndef AXISITEM_H_ |
|
1 | #ifndef AXISITEM_H_ | |
2 | #define AXISITEM_H_ |
|
2 | #define AXISITEM_H_ | |
3 |
|
3 | |||
4 | #include "chart_p.h" |
|
4 | #include "chart_p.h" | |
5 | #include <QGraphicsItem> |
|
5 | #include <QGraphicsItem> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | class QChartAxis; |
|
9 | class QChartAxis; | |
10 | class ChartPresenter; |
|
10 | class ChartPresenter; | |
11 |
|
11 | |||
12 | class Axis : public Chart |
|
12 | class Axis : public Chart | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | public: |
|
15 | public: | |
16 | enum AxisType{X_AXIS,Y_AXIS}; |
|
16 | enum AxisType{X_AXIS,Y_AXIS}; | |
17 |
|
17 | |||
18 | Axis(QChartAxis *axis, ChartPresenter *presenter, AxisType type = X_AXIS); |
|
18 | Axis(QChartAxis *axis, ChartPresenter *presenter, AxisType type = X_AXIS); | |
19 | ~Axis(); |
|
19 | ~Axis(); | |
20 |
|
20 | |||
21 |
AxisType axisType() const {return m_type;} |
|
21 | AxisType axisType() const { return m_type; } | |
22 |
|
22 | |||
23 | void setAxisOpacity(qreal opacity); |
|
23 | void setAxisOpacity(qreal opacity); | |
24 | qreal axisOpacity() const; |
|
24 | qreal axisOpacity() const; | |
25 |
|
25 | |||
26 | void setGridOpacity(qreal opacity); |
|
26 | void setGridOpacity(qreal opacity); | |
27 | qreal gridOpacity() const; |
|
27 | qreal gridOpacity() const; | |
28 |
|
28 | |||
29 | void setLabelsOpacity(qreal opacity); |
|
29 | void setLabelsOpacity(qreal opacity); | |
30 | qreal labelsOpacity() const; |
|
30 | qreal labelsOpacity() const; | |
31 |
|
31 | |||
32 | void setShadesOpacity(qreal opacity); |
|
32 | void setShadesOpacity(qreal opacity); | |
33 | qreal shadesOpacity() const; |
|
33 | qreal shadesOpacity() const; | |
34 |
|
34 | |||
35 | void setLabelsAngle(int angle); |
|
35 | void setLabelsAngle(int angle); | |
36 | int labelsAngle()const { return m_labelsAngle; } |
|
36 | int labelsAngle()const { return m_labelsAngle; } | |
37 |
|
37 | |||
38 | void setShadesBrush(const QBrush &brush); |
|
38 | void setShadesBrush(const QBrush &brush); | |
39 | void setShadesPen(const QPen &pen); |
|
39 | void setShadesPen(const QPen &pen); | |
40 |
|
40 | |||
41 | void setAxisPen(const QPen &pen); |
|
41 | void setAxisPen(const QPen &pen); | |
42 | void setGridPen(const QPen &pen); |
|
42 | void setGridPen(const QPen &pen); | |
43 |
|
43 | |||
44 | void setLabelsPen(const QPen &pen); |
|
44 | void setLabelsPen(const QPen &pen); | |
45 | void setLabelsBrush(const QBrush &brush); |
|
45 | void setLabelsBrush(const QBrush &brush); | |
46 | void setLabelsFont(const QFont &font); |
|
46 | void setLabelsFont(const QFont &font); | |
47 |
|
47 | |||
48 | inline QRectF geometry() const { return m_rect; } |
|
48 | inline QRectF geometry() const { return m_rect; } | |
49 |
inline QVector<qreal> layout() { return m_layoutVector;} |
|
49 | inline QVector<qreal> layout() { return m_layoutVector; } | |
50 |
|
50 | |||
51 | public slots: |
|
51 | public slots: | |
52 | void handleAxisUpdated(); |
|
52 | void handleAxisUpdated(); | |
53 | void handleAxisCategoriesUpdated(); |
|
53 | void handleAxisCategoriesUpdated(); | |
54 | void handleRangeChanged(qreal min , qreal max,int tickCount); |
|
54 | void handleRangeChanged(qreal min , qreal max,int tickCount); | |
55 | void handleGeometryChanged(const QRectF &size); |
|
55 | void handleGeometryChanged(const QRectF &size); | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | private: |
|
58 | private: | |
59 | inline bool isEmpty(); |
|
59 | inline bool isEmpty(); | |
60 | void createItems(int count); |
|
60 | void createItems(int count); | |
61 | void deleteItems(int count); |
|
61 | void deleteItems(int count); | |
62 |
|
62 | |||
63 | QVector<qreal> calculateLayout() const; |
|
63 | QVector<qreal> calculateLayout() const; | |
64 | void updateLayout(QVector<qreal> &layout); |
|
64 | void updateLayout(QVector<qreal> &layout); | |
65 | void setLayout(QVector<qreal> &layout); |
|
65 | void setLayout(QVector<qreal> &layout); | |
66 |
|
66 | |||
67 | bool createLabels(QStringList &labels,qreal min, qreal max,int ticks) const; |
|
67 | bool createLabels(QStringList &labels,qreal min, qreal max,int ticks) const; | |
68 | void axisSelected(); |
|
68 | void axisSelected(); | |
69 |
|
69 | |||
70 | private: |
|
70 | private: | |
71 | QChartAxis* m_chartAxis; |
|
71 | QChartAxis* m_chartAxis; | |
72 | AxisType m_type; |
|
72 | AxisType m_type; | |
73 | QRectF m_rect; |
|
73 | QRectF m_rect; | |
74 | int m_labelsAngle; |
|
74 | int m_labelsAngle; | |
75 | QGraphicsItemGroup m_grid; |
|
75 | QGraphicsItemGroup m_grid; | |
76 | QGraphicsItemGroup m_shades; |
|
76 | QGraphicsItemGroup m_shades; | |
77 | QGraphicsItemGroup m_labels; |
|
77 | QGraphicsItemGroup m_labels; | |
78 | QGraphicsItemGroup m_axis; |
|
78 | QGraphicsItemGroup m_axis; | |
79 | QVector<qreal> m_layoutVector; |
|
79 | QVector<qreal> m_layoutVector; | |
80 | qreal m_min; |
|
80 | qreal m_min; | |
81 | qreal m_max; |
|
81 | qreal m_max; | |
82 | int m_ticksCount; |
|
82 | int m_ticksCount; | |
83 | qreal m_zoomFactor; |
|
83 | qreal m_zoomFactor; | |
84 |
|
84 | |||
85 | friend class AxisAnimation; |
|
85 | friend class AxisAnimation; | |
86 | friend class AxisItem; |
|
86 | friend class AxisItem; | |
87 |
|
87 | |||
88 | }; |
|
88 | }; | |
89 |
|
89 | |||
90 | class AxisItem: public QGraphicsLineItem |
|
90 | class AxisItem: public QGraphicsLineItem | |
91 | { |
|
91 | { | |
92 | public: |
|
92 | public: | |
93 |
|
93 | |||
94 |
AxisItem(Axis *axis, QGraphicsItem *parent=0) : QGraphicsLineItem(parent), m_axis(axis) {} |
|
94 | AxisItem(Axis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {} | |
95 |
|
95 | |||
96 | protected: |
|
96 | protected: | |
97 | void mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
97 | void mousePressEvent(QGraphicsSceneMouseEvent *event) | |
98 | { |
|
98 | { | |
99 | Q_UNUSED(event) |
|
99 | Q_UNUSED(event) | |
100 | m_axis->axisSelected(); |
|
100 | m_axis->axisSelected(); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | QRectF boundingRect() const |
|
103 | QRectF boundingRect() const | |
104 | { |
|
104 | { | |
105 | return shape().boundingRect(); |
|
105 | return shape().boundingRect(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | QPainterPath shape() const |
|
108 | QPainterPath shape() const | |
109 | { |
|
109 | { | |
110 | QPainterPath path = QGraphicsLineItem::shape(); |
|
110 | QPainterPath path = QGraphicsLineItem::shape(); | |
111 | QRectF rect = path.boundingRect(); |
|
111 | QRectF rect = path.boundingRect(); | |
112 | path.addRect(rect.adjusted(0,0,m_axis->axisType()!=Axis::X_AXIS?8:0,m_axis->axisType()!=Axis::Y_AXIS?8:0)); |
|
112 | path.addRect(rect.adjusted(0,0,m_axis->axisType()!=Axis::X_AXIS?8:0,m_axis->axisType()!=Axis::Y_AXIS?8:0)); | |
113 | return path; |
|
113 | return path; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | private: |
|
116 | private: | |
117 | Axis* m_axis; |
|
117 | Axis* m_axis; | |
118 |
|
118 | |||
119 | }; |
|
119 | }; | |
120 |
|
120 | |||
121 | QTCOMMERCIALCHART_END_NAMESPACE |
|
121 | QTCOMMERCIALCHART_END_NAMESPACE | |
122 |
|
122 | |||
123 | #endif /* AXISITEM_H_ */ |
|
123 | #endif /* AXISITEM_H_ */ |
@@ -1,114 +1,114 | |||||
1 | #ifndef QCHARTAXIS_H_ |
|
1 | #ifndef QCHARTAXIS_H_ | |
2 | #define QCHARTAXIS_H_ |
|
2 | #define QCHARTAXIS_H_ | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qchartaxiscategories.h> |
|
5 | #include <qchartaxiscategories.h> | |
6 | #include <QPen> |
|
6 | #include <QPen> | |
7 | #include <QFont> |
|
7 | #include <QFont> | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
10 | |||
11 | class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject |
|
11 | class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject | |
12 | { |
|
12 | { | |
13 | Q_OBJECT |
|
13 | Q_OBJECT | |
14 | public: |
|
14 | public: | |
15 |
|
15 | |||
16 | QChartAxis(QObject *parent =0); |
|
16 | QChartAxis(QObject *parent =0); | |
17 | ~QChartAxis(); |
|
17 | ~QChartAxis(); | |
18 |
|
18 | |||
19 | //axis handling |
|
19 | //axis handling | |
20 |
bool isAxisVisible() const { return m_axisVisible;} |
|
20 | bool isAxisVisible() const { return m_axisVisible; } | |
21 | void setAxisVisible(bool visible); |
|
21 | void setAxisVisible(bool visible); | |
22 | void setAxisPen(const QPen &pen); |
|
22 | void setAxisPen(const QPen &pen); | |
23 |
QPen axisPen() const { return m_axisPen;} |
|
23 | QPen axisPen() const { return m_axisPen; } | |
24 |
|
24 | |||
25 | //grid handling |
|
25 | //grid handling | |
26 |
bool isGridLineVisible() const { return m_gridLineVisible;} |
|
26 | bool isGridLineVisible() const { return m_gridLineVisible; } | |
27 | void setGridLineVisible(bool visible); |
|
27 | void setGridLineVisible(bool visible); | |
28 | void setGridLinePen(const QPen &pen); |
|
28 | void setGridLinePen(const QPen &pen); | |
29 | QPen gridLinePen() const {return m_gridLinePen;} |
|
29 | QPen gridLinePen() const { return m_gridLinePen; } | |
30 |
|
30 | |||
31 | //labels handling |
|
31 | //labels handling | |
32 |
bool labelsVisible() const { return m_labelsVisible;} |
|
32 | bool labelsVisible() const { return m_labelsVisible; } | |
33 | void setLabelsVisible(bool visible); |
|
33 | void setLabelsVisible(bool visible); | |
34 | void setLabelsPen(const QPen &pen); |
|
34 | void setLabelsPen(const QPen &pen); | |
35 | QPen labelsPen() const { return m_labelsPen;} |
|
35 | QPen labelsPen() const { return m_labelsPen;} | |
36 | void setLabelsBrush(const QBrush &brush); |
|
36 | void setLabelsBrush(const QBrush &brush); | |
37 | QBrush labelsBrush() const { return m_labelsBrush;} |
|
37 | QBrush labelsBrush() const { return m_labelsBrush; } | |
38 | void setLabelsFont(const QFont &font); |
|
38 | void setLabelsFont(const QFont &font); | |
39 | QFont labelsFont() const { return m_labelsFont;} |
|
39 | QFont labelsFont() const { return m_labelsFont; } | |
40 | void setLabelsAngle(int angle); |
|
40 | void setLabelsAngle(int angle); | |
41 |
int labelsAngle() const { return m_labelsAngle;} |
|
41 | int labelsAngle() const { return m_labelsAngle; } | |
42 |
|
42 | |||
43 | //shades handling |
|
43 | //shades handling | |
44 |
bool shadesVisible() const { return m_shadesVisible;} |
|
44 | bool shadesVisible() const { return m_shadesVisible; } | |
45 | void setShadesVisible(bool visible); |
|
45 | void setShadesVisible(bool visible); | |
46 | void setShadesPen(const QPen &pen); |
|
46 | void setShadesPen(const QPen &pen); | |
47 | QPen shadesPen() const { return m_shadesPen;} |
|
47 | QPen shadesPen() const { return m_shadesPen; } | |
48 | void setShadesBrush(const QBrush &brush); |
|
48 | void setShadesBrush(const QBrush &brush); | |
49 | QBrush shadesBrush() const { return m_shadesBrush;} |
|
49 | QBrush shadesBrush() const { return m_shadesBrush; } | |
50 | void setShadesOpacity(qreal opacity); |
|
50 | void setShadesOpacity(qreal opacity); | |
51 | qreal shadesOpacity() const { return m_shadesOpacity;} |
|
51 | qreal shadesOpacity() const { return m_shadesOpacity; } | |
52 |
|
52 | |||
53 | //range handling |
|
53 | //range handling | |
54 | void setMin(qreal min); |
|
54 | void setMin(qreal min); | |
55 |
qreal min() const { return m_min;} |
|
55 | qreal min() const { return m_min; } | |
56 | void setMax(qreal max); |
|
56 | void setMax(qreal max); | |
57 |
qreal max() const { return m_max;} |
|
57 | qreal max() const { return m_max; } | |
58 | void setRange(qreal min, qreal max); |
|
58 | void setRange(qreal min, qreal max); | |
59 |
|
59 | |||
60 | //ticks handling |
|
60 | //ticks handling | |
61 | void setTicksCount(int count); |
|
61 | void setTicksCount(int count); | |
62 | int ticksCount() const { return m_ticksCount;} |
|
62 | int ticksCount() const { return m_ticksCount;} | |
63 |
|
63 | |||
64 | void setNiceNumbers(bool enabled); |
|
64 | void setNiceNumbers(bool enabled); | |
65 | bool niceNumbers() const { return m_niceNumbers;} |
|
65 | bool niceNumbers() const { return m_niceNumbers;} | |
66 |
|
66 | |||
67 | QChartAxisCategories* categories() { return &m_category; } |
|
67 | QChartAxisCategories* categories() { return &m_category; } | |
68 |
|
68 | |||
69 | void show(); |
|
69 | void show(); | |
70 | void hide(); |
|
70 | void hide(); | |
71 |
|
71 | |||
72 | signals: |
|
72 | signals: | |
73 | void minChanged(qreal min); |
|
73 | void minChanged(qreal min); | |
74 | void maxChanged(qreal max); |
|
74 | void maxChanged(qreal max); | |
75 | void rangeChanged(qreal min, qreal max); |
|
75 | void rangeChanged(qreal min, qreal max); | |
76 | void ticksCountChanged(int count); |
|
76 | void ticksCountChanged(int count); | |
77 |
|
77 | |||
78 | //interal signal |
|
78 | //interal signal | |
79 | void updated(); |
|
79 | void updated(); | |
80 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); |
|
80 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |
81 | //internal slot |
|
81 | //internal slot | |
82 | public slots: |
|
82 | public slots: | |
83 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
83 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
84 |
|
84 | |||
85 | private: |
|
85 | private: | |
86 | bool m_axisVisible; |
|
86 | bool m_axisVisible; | |
87 | QPen m_axisPen; |
|
87 | QPen m_axisPen; | |
88 | QBrush m_axisBrush; |
|
88 | QBrush m_axisBrush; | |
89 |
|
89 | |||
90 | bool m_gridLineVisible; |
|
90 | bool m_gridLineVisible; | |
91 | QPen m_gridLinePen; |
|
91 | QPen m_gridLinePen; | |
92 |
|
92 | |||
93 | bool m_labelsVisible; |
|
93 | bool m_labelsVisible; | |
94 | QPen m_labelsPen; |
|
94 | QPen m_labelsPen; | |
95 | QBrush m_labelsBrush; |
|
95 | QBrush m_labelsBrush; | |
96 | QFont m_labelsFont; |
|
96 | QFont m_labelsFont; | |
97 | int m_labelsAngle; |
|
97 | int m_labelsAngle; | |
98 |
|
98 | |||
99 | bool m_shadesVisible; |
|
99 | bool m_shadesVisible; | |
100 | QPen m_shadesPen; |
|
100 | QPen m_shadesPen; | |
101 | QBrush m_shadesBrush; |
|
101 | QBrush m_shadesBrush; | |
102 | qreal m_shadesOpacity; |
|
102 | qreal m_shadesOpacity; | |
103 |
|
103 | |||
104 | qreal m_min; |
|
104 | qreal m_min; | |
105 | qreal m_max; |
|
105 | qreal m_max; | |
106 |
|
106 | |||
107 | int m_ticksCount; |
|
107 | int m_ticksCount; | |
108 | QChartAxisCategories m_category; |
|
108 | QChartAxisCategories m_category; | |
109 |
|
109 | |||
110 | bool m_niceNumbers; |
|
110 | bool m_niceNumbers; | |
111 | }; |
|
111 | }; | |
112 |
|
112 | |||
113 | QTCOMMERCIALCHART_END_NAMESPACE |
|
113 | QTCOMMERCIALCHART_END_NAMESPACE | |
114 | #endif /* QCHARTAXIS_H_ */ |
|
114 | #endif /* QCHARTAXIS_H_ */ |
@@ -1,61 +1,61 | |||||
1 | #include "chart_p.h" |
|
1 | #include "chart_p.h" | |
2 | #include "chartpresenter_p.h" |
|
2 | #include "chartpresenter_p.h" | |
3 |
|
3 | |||
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | Chart::Chart(ChartPresenter *presenter):QObject(presenter), |
|
7 | Chart::Chart(ChartPresenter *presenter):QObject(presenter), | |
8 | m_animator(0), |
|
8 | m_animator(0), | |
9 | m_presenter(presenter) |
|
9 | m_presenter(presenter) | |
10 | { |
|
10 | { | |
11 |
} |
|
11 | } | |
12 |
|
12 | |||
13 | void Chart::setAnimator(ChartAnimator* animator) |
|
13 | void Chart::setAnimator(ChartAnimator* animator) | |
14 | { |
|
14 | { | |
15 | m_animator=animator; |
|
15 | m_animator=animator; | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | ChartAnimator* Chart::animator() const |
|
18 | ChartAnimator* Chart::animator() const | |
19 | { |
|
19 | { | |
20 | return m_animator; |
|
20 | return m_animator; | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | ChartPresenter* Chart::presenter() const |
|
23 | ChartPresenter* Chart::presenter() const | |
24 | { |
|
24 | { | |
25 | return m_presenter; |
|
25 | return m_presenter; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | void Chart::handleGeometryChanged(const QRectF& rect) |
|
28 | void Chart::handleGeometryChanged(const QRectF& rect) | |
29 | { |
|
29 | { | |
30 | Q_UNUSED(rect); |
|
30 | Q_UNUSED(rect); | |
31 | qWarning()<<"Slot not implemented"; |
|
31 | qWarning()<<"Slot not implemented"; | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | void Chart::handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY) |
|
34 | void Chart::handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY) | |
35 | { |
|
35 | { | |
36 | Q_UNUSED(minX); |
|
36 | Q_UNUSED(minX); | |
37 | Q_UNUSED(maxX); |
|
37 | Q_UNUSED(maxX); | |
38 | Q_UNUSED(minY); |
|
38 | Q_UNUSED(minY); | |
39 | Q_UNUSED(maxY); |
|
39 | Q_UNUSED(maxY); | |
40 | qWarning()<<"Slot not implemented"; |
|
40 | qWarning()<<"Slot not implemented"; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | void Chart::rangeXChanged(qreal min, qreal max, int tickXCount) |
|
43 | void Chart::rangeXChanged(qreal min, qreal max, int tickXCount) | |
44 | { |
|
44 | { | |
45 | Q_UNUSED(min); |
|
45 | Q_UNUSED(min); | |
46 | Q_UNUSED(max); |
|
46 | Q_UNUSED(max); | |
47 | Q_UNUSED(tickXCount); |
|
47 | Q_UNUSED(tickXCount); | |
48 | qWarning()<<"Slot not implemented"; |
|
48 | qWarning()<<"Slot not implemented"; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void Chart::rangeYChanged(qreal min, qreal max, int tickYCount) |
|
51 | void Chart::rangeYChanged(qreal min, qreal max, int tickYCount) | |
52 | { |
|
52 | { | |
53 | Q_UNUSED(min); |
|
53 | Q_UNUSED(min); | |
54 | Q_UNUSED(max); |
|
54 | Q_UNUSED(max); | |
55 | Q_UNUSED(tickYCount); |
|
55 | Q_UNUSED(tickYCount); | |
56 | qWarning()<<"Slot not implemented"; |
|
56 | qWarning()<<"Slot not implemented"; | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | #include "moc_chart_p.cpp" |
|
59 | #include "moc_chart_p.cpp" | |
60 |
|
60 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,61 +1,61 | |||||
1 | #ifndef CHARTDATASET_P_H_ |
|
1 | #ifndef CHARTDATASET_P_H_ | |
2 | #define CHARTDATASET_P_H_ |
|
2 | #define CHARTDATASET_P_H_ | |
3 |
|
3 | |||
4 | #include "qseries.h" |
|
4 | #include "qseries.h" | |
5 | #include "domain_p.h" |
|
5 | #include "domain_p.h" | |
6 | #include <QVector> |
|
6 | #include <QVector> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QChartAxis; |
|
10 | class QChartAxis; | |
11 | class QBarSeries; |
|
11 | class QBarSeries; | |
12 |
|
12 | |||
13 | class ChartDataSet : public QObject |
|
13 | class ChartDataSet : public QObject | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 | ChartDataSet(QObject* parent=0); |
|
17 | ChartDataSet(QObject* parent=0); | |
18 | virtual ~ChartDataSet(); |
|
18 | virtual ~ChartDataSet(); | |
19 |
|
19 | |||
20 | void addSeries(QSeries* series,QChartAxis *axisY = 0); |
|
20 | void addSeries(QSeries* series,QChartAxis *axisY = 0); | |
21 | void removeSeries(QSeries* series); |
|
21 | void removeSeries(QSeries* series); | |
22 | void removeAllSeries(); |
|
22 | void removeAllSeries(); | |
23 |
|
23 | |||
24 | void zoomInDomain(const QRectF& rect, const QSizeF& size); |
|
24 | void zoomInDomain(const QRectF& rect, const QSizeF& size); | |
25 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); |
|
25 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); | |
26 | void scrollDomain(int dx,int dy,const QSizeF& size); |
|
26 | void scrollDomain(int dx,int dy,const QSizeF& size); | |
27 |
|
27 | |||
28 | int seriesCount(QSeries::QSeriesType type); |
|
28 | int seriesCount(QSeries::QSeriesType type); | |
29 | int seriesIndex(QSeries *series); |
|
29 | int seriesIndex(QSeries *series); | |
30 |
|
30 | |||
31 | Domain* domain(QSeries* series) const; |
|
31 | Domain* domain(QSeries* series) const; | |
32 | Domain* domain(QChartAxis* axis) const; |
|
32 | Domain* domain(QChartAxis* axis) const; | |
33 | QChartAxis* axis(QSeries* series) const; |
|
33 | QChartAxis* axis(QSeries* series) const; | |
34 |
|
34 | |||
35 |
QChartAxis* axisX() const { return m_axisX;} |
|
35 | QChartAxis* axisX() const { return m_axisX; } | |
36 | QChartAxis* axisY(QSeries* series = 0) const; |
|
36 | QChartAxis* axisY(QSeries* series = 0) const; | |
37 |
|
37 | |||
38 | signals: |
|
38 | signals: | |
39 | void seriesAdded(QSeries* series,Domain* domain); |
|
39 | void seriesAdded(QSeries* series,Domain* domain); | |
40 | void seriesRemoved(QSeries* series); |
|
40 | void seriesRemoved(QSeries* series); | |
41 | void axisAdded(QChartAxis* axis,Domain* domain); |
|
41 | void axisAdded(QChartAxis* axis,Domain* domain); | |
42 | void axisRemoved(QChartAxis* axis); |
|
42 | void axisRemoved(QChartAxis* axis); | |
43 |
|
43 | |||
44 | private: |
|
44 | private: | |
45 | QStringList createLabels(QChartAxis* axis,qreal min, qreal max); |
|
45 | QStringList createLabels(QChartAxis* axis,qreal min, qreal max); | |
46 | void calculateDomain(QSeries* series,Domain* domain); |
|
46 | void calculateDomain(QSeries* series,Domain* domain); | |
47 | void setupCategories(QBarSeries* series); |
|
47 | void setupCategories(QBarSeries* series); | |
48 |
|
48 | |||
49 | private: |
|
49 | private: | |
50 | QMap<QSeries*, QChartAxis*> m_seriesAxisMap; |
|
50 | QMap<QSeries*, QChartAxis*> m_seriesAxisMap; | |
51 | QMap<QChartAxis*, Domain*> m_axisDomainMap; |
|
51 | QMap<QChartAxis*, Domain*> m_axisDomainMap; | |
52 | QChartAxis* m_axisX; |
|
52 | QChartAxis* m_axisX; | |
53 | QChartAxis* m_axisY; |
|
53 | QChartAxis* m_axisY; | |
54 |
|
54 | |||
55 | int m_domainIndex; |
|
55 | int m_domainIndex; | |
56 | bool m_axisXInitialized; |
|
56 | bool m_axisXInitialized; | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
59 | QTCOMMERCIALCHART_END_NAMESPACE | |
60 |
|
60 | |||
61 | #endif /* CHARTENGINE_P_H_ */ |
|
61 | #endif /* CHARTENGINE_P_H_ */ |
@@ -1,19 +1,19 | |||||
1 | #ifndef CHARTITEM_H_ |
|
1 | #ifndef CHARTITEM_H_ | |
2 | #define CHARTITEM_H_ |
|
2 | #define CHARTITEM_H_ | |
3 |
|
3 | |||
4 | #include "chart_p.h" |
|
4 | #include "chart_p.h" | |
5 | #include "chartpresenter_p.h" |
|
5 | #include "chartpresenter_p.h" | |
6 | #include <QGraphicsItem> |
|
6 | #include <QGraphicsItem> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class ChartItem : public QGraphicsItem, public Chart |
|
10 | class ChartItem : public QGraphicsItem, public Chart | |
11 | { |
|
11 | { | |
12 | enum ChartItemTypes{ AXIS_ITEM = UserType+1, XYLINE_ITEM}; |
|
12 | enum ChartItemTypes{ AXIS_ITEM = UserType + 1, XYLINE_ITEM }; | |
13 | public: |
|
13 | public: | |
14 |
ChartItem(ChartPresenter *presenter):QGraphicsItem(presenter?presenter->rootItem():0),Chart(presenter){} |
|
14 | ChartItem(ChartPresenter *presenter) : QGraphicsItem(presenter ? presenter->rootItem() : 0), Chart(presenter) {} | |
15 | }; |
|
15 | }; | |
16 |
|
16 | |||
17 | QTCOMMERCIALCHART_END_NAMESPACE |
|
17 | QTCOMMERCIALCHART_END_NAMESPACE | |
18 |
|
18 | |||
19 | #endif /* CHARTITEM_H_ */ |
|
19 | #endif /* CHARTITEM_H_ */ |
@@ -1,71 +1,71 | |||||
1 | #ifndef DOMAIN_H_ |
|
1 | #ifndef DOMAIN_H_ | |
2 | #define DOMAIN_H_ |
|
2 | #define DOMAIN_H_ | |
3 | #include "qchartglobal.h" |
|
3 | #include "qchartglobal.h" | |
4 | #include <QRectF> |
|
4 | #include <QRectF> | |
5 | #include <QSizeF> |
|
5 | #include <QSizeF> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | class Domain: public QObject { |
|
9 | class Domain: public QObject { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | public: |
|
11 | public: | |
12 | explicit Domain(QObject* object=0); |
|
12 | explicit Domain(QObject* object=0); | |
13 | virtual ~Domain(); |
|
13 | virtual ~Domain(); | |
14 |
|
14 | |||
15 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
15 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
16 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount); |
|
16 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount); | |
17 | void setRangeX(qreal min, qreal max); |
|
17 | void setRangeX(qreal min, qreal max); | |
18 | void setRangeX(qreal min, qreal max, int tickCount); |
|
18 | void setRangeX(qreal min, qreal max, int tickCount); | |
19 | void setRangeY(qreal min, qreal max); |
|
19 | void setRangeY(qreal min, qreal max); | |
20 | void setRangeY(qreal min, qreal max, int tickCount); |
|
20 | void setRangeY(qreal min, qreal max, int tickCount); | |
21 | void setMinX(qreal min); |
|
21 | void setMinX(qreal min); | |
22 | void setMaxX(qreal max); |
|
22 | void setMaxX(qreal max); | |
23 | void setMinY(qreal min); |
|
23 | void setMinY(qreal min); | |
24 | void setMaxY(qreal max); |
|
24 | void setMaxY(qreal max); | |
25 |
|
25 | |||
26 |
qreal minX() const {return m_minX;} |
|
26 | qreal minX() const { return m_minX; } | |
27 |
qreal maxX() const {return m_maxX;} |
|
27 | qreal maxX() const { return m_maxX; } | |
28 |
qreal minY() const {return m_minY;} |
|
28 | qreal minY() const { return m_minY; } | |
29 |
qreal maxY() const {return m_maxY;} |
|
29 | qreal maxY() const { return m_maxY; } | |
30 |
|
30 | |||
31 | qreal spanX() const; |
|
31 | qreal spanX() const; | |
32 | qreal spanY() const; |
|
32 | qreal spanY() const; | |
33 | bool isEmpty() const; |
|
33 | bool isEmpty() const; | |
34 |
|
34 | |||
35 | int tickXCount() const {return m_tickXCount;} |
|
35 | int tickXCount() const {return m_tickXCount;} | |
36 | int tickYCount() const {return m_tickYCount;} |
|
36 | int tickYCount() const {return m_tickYCount;} | |
37 |
|
37 | |||
38 | friend bool operator== (const Domain &domain1, const Domain &domain2); |
|
38 | friend bool operator== (const Domain &domain1, const Domain &domain2); | |
39 | friend bool operator!= (const Domain &domain1, const Domain &domain2); |
|
39 | friend bool operator!= (const Domain &domain1, const Domain &domain2); | |
40 | friend QDebug operator<<(QDebug dbg, const Domain &domain); |
|
40 | friend QDebug operator<<(QDebug dbg, const Domain &domain); | |
41 |
|
41 | |||
42 | void zoomIn(const QRectF& rect, const QSizeF& size); |
|
42 | void zoomIn(const QRectF& rect, const QSizeF& size); | |
43 | void zoomOut(const QRectF& rect, const QSizeF& size); |
|
43 | void zoomOut(const QRectF& rect, const QSizeF& size); | |
44 | void move(int dx,int dy,const QSizeF& size); |
|
44 | void move(int dx,int dy,const QSizeF& size); | |
45 |
|
45 | |||
46 | signals: |
|
46 | signals: | |
47 | void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
47 | void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
48 | void rangeXChanged(qreal min, qreal max, int tickXCount); |
|
48 | void rangeXChanged(qreal min, qreal max, int tickXCount); | |
49 | void rangeYChanged(qreal min, qreal max, int tickYCount); |
|
49 | void rangeYChanged(qreal min, qreal max, int tickYCount); | |
50 |
|
50 | |||
51 | public slots: |
|
51 | public slots: | |
52 | void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,bool niceNumbers = false); |
|
52 | void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,bool niceNumbers = false); | |
53 | void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,bool niceNumbers = false); |
|
53 | void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,bool niceNumbers = false); | |
54 |
|
54 | |||
55 | private: |
|
55 | private: | |
56 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); |
|
56 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); | |
57 | qreal niceNumber(qreal x,bool celing); |
|
57 | qreal niceNumber(qreal x,bool celing); | |
58 |
|
58 | |||
59 | private: |
|
59 | private: | |
60 | qreal m_minX; |
|
60 | qreal m_minX; | |
61 | qreal m_maxX; |
|
61 | qreal m_maxX; | |
62 | qreal m_minY; |
|
62 | qreal m_minY; | |
63 | qreal m_maxY; |
|
63 | qreal m_maxY; | |
64 | int m_tickXCount; |
|
64 | int m_tickXCount; | |
65 | int m_tickYCount; |
|
65 | int m_tickYCount; | |
66 | bool m_niceNumbers; |
|
66 | bool m_niceNumbers; | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
70 |
|
70 | |||
71 | #endif |
|
71 | #endif |
@@ -1,117 +1,117 | |||||
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 QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QSeries> |
|
24 | #include <QSeries> | |
25 | #include <QGraphicsWidget> |
|
25 | #include <QGraphicsWidget> | |
26 |
|
26 | |||
27 | class QGraphicsSceneResizeEvent; |
|
27 | class QGraphicsSceneResizeEvent; | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QSeries; |
|
31 | class QSeries; | |
32 | class QChartAxis; |
|
32 | class QChartAxis; | |
33 | class QLegend; |
|
33 | class QLegend; | |
34 | struct QChartPrivate; |
|
34 | struct QChartPrivate; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
36 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | public: |
|
39 | public: | |
40 | enum ChartTheme { |
|
40 | enum ChartTheme { | |
41 | ChartThemeDefault, |
|
41 | ChartThemeDefault, | |
42 | ChartThemeLight, |
|
42 | ChartThemeLight, | |
43 | ChartThemeBlueCerulean, |
|
43 | ChartThemeBlueCerulean, | |
44 | ChartThemeDark, |
|
44 | ChartThemeDark, | |
45 | ChartThemeBrownSand, |
|
45 | ChartThemeBrownSand, | |
46 | ChartThemeBlueNcs, |
|
46 | ChartThemeBlueNcs, | |
47 | ChartThemeHighContrast, |
|
47 | ChartThemeHighContrast, | |
48 | ChartThemeBlueIcy, |
|
48 | ChartThemeBlueIcy, | |
49 | ChartThemeCount |
|
49 | ChartThemeCount | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | enum AnimationOption { |
|
52 | enum AnimationOption { | |
53 | NoAnimation = 0x0, |
|
53 | NoAnimation = 0x0, | |
54 | GridAxisAnimations = 0x1, |
|
54 | GridAxisAnimations = 0x1, | |
55 | SeriesAnimations =0x2, |
|
55 | SeriesAnimations =0x2, | |
56 | AllAnimations = 0x3 |
|
56 | AllAnimations = 0x3 | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
59 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
59 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
60 |
|
60 | |||
61 | public: |
|
61 | public: | |
62 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
62 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
63 | ~QChart(); |
|
63 | ~QChart(); | |
64 |
|
64 | |||
65 | void addSeries(QSeries *series, QChartAxis *axisY = 0); |
|
65 | void addSeries(QSeries *series, QChartAxis *axisY = 0); | |
66 | void removeSeries(QSeries *series); |
|
66 | void removeSeries(QSeries *series); | |
67 | void removeAllSeries(); |
|
67 | void removeAllSeries(); | |
68 |
|
68 | |||
69 | void setTheme(QChart::ChartTheme theme); |
|
69 | void setTheme(QChart::ChartTheme theme); | |
70 | QChart::ChartTheme theme() const; |
|
70 | QChart::ChartTheme theme() const; | |
71 |
|
71 | |||
72 | void setTitle(const QString& title); |
|
72 | void setTitle(const QString& title); | |
73 | QString title() const; |
|
73 | QString title() const; | |
74 | void setTitleFont(const QFont& font); |
|
74 | void setTitleFont(const QFont& font); | |
75 | QFont titleFont() const; |
|
75 | QFont titleFont() const; | |
76 | void setTitleBrush(const QBrush &brush); |
|
76 | void setTitleBrush(const QBrush &brush); | |
77 | QBrush titleBrush() const; |
|
77 | QBrush titleBrush() const; | |
78 | void setBackgroundBrush(const QBrush& brush); |
|
78 | void setBackgroundBrush(const QBrush& brush); | |
79 | QBrush backgroundBrush() const; |
|
79 | QBrush backgroundBrush() const; | |
80 | void setBackgroundPen(const QPen& pen); |
|
80 | void setBackgroundPen(const QPen& pen); | |
81 | QPen backgroundPen() const; |
|
81 | QPen backgroundPen() const; | |
82 |
|
82 | |||
83 | void setBackgroundVisible(bool visible); |
|
83 | void setBackgroundVisible(bool visible); | |
84 | bool isBackgroundVisible() const; |
|
84 | bool isBackgroundVisible() const; | |
85 |
|
85 | |||
86 | void setAnimationOptions(AnimationOptions options); |
|
86 | void setAnimationOptions(AnimationOptions options); | |
87 | AnimationOptions animationOptions() const; |
|
87 | AnimationOptions animationOptions() const; | |
88 |
|
88 | |||
89 | void zoomIn(); |
|
89 | void zoomIn(); | |
90 | void zoomIn(const QRectF& rect); |
|
90 | void zoomIn(const QRectF& rect); | |
91 | void zoomOut(); |
|
91 | void zoomOut(); | |
92 | void scrollLeft(); |
|
92 | void scrollLeft(); | |
93 | void scrollRight(); |
|
93 | void scrollRight(); | |
94 | void scrollUp(); |
|
94 | void scrollUp(); | |
95 | void scrollDown(); |
|
95 | void scrollDown(); | |
96 |
|
96 | |||
97 | QChartAxis* axisX() const; |
|
97 | QChartAxis* axisX() const; | |
98 | QChartAxis* axisY() const; |
|
98 | QChartAxis* axisY() const; | |
99 |
|
99 | |||
100 | QLegend& legend() const; |
|
100 | QLegend& legend() const; | |
101 | QLegend* takeLegend(); |
|
101 | QLegend* takeLegend(); | |
102 | void giveLegend(QLegend* legend); |
|
102 | void giveLegend(QLegend* legend); | |
103 |
|
103 | |||
104 | protected: |
|
104 | protected: | |
105 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
105 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
106 |
|
106 | |||
107 | protected: |
|
107 | protected: | |
108 | QScopedPointer<QChartPrivate> d_ptr; |
|
108 | QScopedPointer<QChartPrivate> d_ptr; | |
109 | friend class QChartView; |
|
109 | friend class QChartView; | |
110 |
Q_DISABLE_COPY(QChart) |
|
110 | Q_DISABLE_COPY(QChart) | |
111 | }; |
|
111 | }; | |
112 |
|
112 | |||
113 | QTCOMMERCIALCHART_END_NAMESPACE |
|
113 | QTCOMMERCIALCHART_END_NAMESPACE | |
114 |
|
114 | |||
115 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
115 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
116 |
|
116 | |||
117 | #endif |
|
117 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now