##// END OF EJS Templates
Q_SIGNALS and Q_SLOTS
sauimone -
r775:02f25710c73d
parent child
Show More
@@ -1,95 +1,95
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:BSD$
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
10 ** You may use this file under the terms of the BSD license as follows:
11 **
11 **
12 ** "Redistribution and use in source and binary forms, with or without
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
13 ** modification, are permitted provided that the following conditions are
14 ** met:
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
19 ** the documentation and/or other materials provided with the
20 ** distribution.
20 ** distribution.
21 ** * Neither the name of Digia nor the names of its contributors
21 ** * Neither the name of Digia nor the names of its contributors
22 ** may be used to endorse or promote products derived from this
22 ** may be used to endorse or promote products derived from this
23 ** software without specific prior written permission.
23 ** software without specific prior written permission.
24 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 ** $QT_END_LICENSE$
36 ** $QT_END_LICENSE$
37 **
37 **
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
39 **
39 **
40 ****************************************************************************/
40 ****************************************************************************/
41
41
42 #ifndef THEMEWINDOW_H_
42 #ifndef THEMEWINDOW_H_
43 #define THEMEWINDOW_H_
43 #define THEMEWINDOW_H_
44 #include <QWidget>
44 #include <QWidget>
45 #include <QChartGlobal>
45 #include <QChartGlobal>
46
46
47 class QComboBox;
47 class QComboBox;
48 class QCheckBox;
48 class QCheckBox;
49
49
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51 class QChartView;
51 class QChartView;
52 class QChart;
52 class QChart;
53 QTCOMMERCIALCHART_END_NAMESPACE
53 QTCOMMERCIALCHART_END_NAMESPACE
54
54
55 typedef QPair<QPointF, QString> Data;
55 typedef QPair<QPointF, QString> Data;
56 typedef QList<Data> DataList;
56 typedef QList<Data> DataList;
57 typedef QList<DataList> DataTable;
57 typedef QList<DataList> DataTable;
58
58
59 QTCOMMERCIALCHART_USE_NAMESPACE
59 QTCOMMERCIALCHART_USE_NAMESPACE
60
60
61 class ThemeWidget: public QWidget
61 class ThemeWidget: public QWidget
62 {
62 {
63 Q_OBJECT
63 Q_OBJECT
64 public:
64 public:
65 explicit ThemeWidget(QWidget *parent = 0);
65 explicit ThemeWidget(QWidget *parent = 0);
66 ~ThemeWidget();
66 ~ThemeWidget();
67
67
68 private slots:
68 private Q_SLOTS:
69 void updateUI();
69 void updateUI();
70
70
71 private:
71 private:
72 DataTable generateRandomData(int listCount,int valueMax,int valueCount) const;
72 DataTable generateRandomData(int listCount,int valueMax,int valueCount) const;
73 QComboBox* createThemeBox() const;
73 QComboBox* createThemeBox() const;
74 QComboBox* createAnimationBox() const;
74 QComboBox* createAnimationBox() const;
75 void connectSignals();
75 void connectSignals();
76 QChart* createAreaChart() const;
76 QChart* createAreaChart() const;
77 QChart* createBarChart(int valueCount) const;
77 QChart* createBarChart(int valueCount) const;
78 QChart* createPieChart() const;
78 QChart* createPieChart() const;
79 QChart* createLineChart() const;
79 QChart* createLineChart() const;
80 QChart* createSplineChart() const;
80 QChart* createSplineChart() const;
81 QChart* createScatterChart() const;
81 QChart* createScatterChart() const;
82
82
83 private:
83 private:
84 int m_listCount;
84 int m_listCount;
85 int m_valueMax;
85 int m_valueMax;
86 int m_valueCount;
86 int m_valueCount;
87 QList<QChartView*> m_charts;
87 QList<QChartView*> m_charts;
88 DataTable m_dataTable;
88 DataTable m_dataTable;
89
89
90 QComboBox *m_themeComboBox;
90 QComboBox *m_themeComboBox;
91 QCheckBox *m_antialiasCheckBox;
91 QCheckBox *m_antialiasCheckBox;
92 QComboBox *m_animatedComboBox;
92 QComboBox *m_animatedComboBox;
93 };
93 };
94
94
95 #endif /* THEMEWINDOW_H_ */
95 #endif /* THEMEWINDOW_H_ */
@@ -1,39 +1,39
1 #ifndef DECLARATIVEBARSERIES_H
1 #ifndef DECLARATIVEBARSERIES_H
2 #define DECLARATIVEBARSERIES_H
2 #define DECLARATIVEBARSERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include <QDeclarativeItem>
5 #include <QDeclarativeItem>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class QChart;
9 class QChart;
10 class QBarSeries;
10 class QBarSeries;
11
11
12 class DeclarativeBarSeries : public QDeclarativeItem
12 class DeclarativeBarSeries : public QDeclarativeItem
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories)
15 Q_PROPERTY(QStringList barCategories READ barCategories WRITE setBarCategories)
16
16
17 public:
17 public:
18 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
18 explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0);
19
19
20 public: // from QDeclarativeParserStatus
20 public: // from QDeclarativeParserStatus
21 void componentComplete();
21 void componentComplete();
22
22
23 public:
23 public:
24 void setBarCategories(QStringList categories);
24 void setBarCategories(QStringList categories);
25 QStringList barCategories();
25 QStringList barCategories();
26
26
27 signals:
27 Q_SIGNALS:
28
28
29 public slots:
29 public Q_SLOTS:
30
30
31 public:
31 public:
32 QChart *m_chart;
32 QChart *m_chart;
33 QBarSeries *m_series;
33 QBarSeries *m_series;
34 QStringList m_categories;
34 QStringList m_categories;
35 };
35 };
36
36
37 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
38
38
39 #endif // DECLARATIVEBARSERIES_H
39 #endif // DECLARATIVEBARSERIES_H
@@ -1,39 +1,39
1 #ifndef DECLARATIVEPIESERIES_H
1 #ifndef DECLARATIVEPIESERIES_H
2 #define DECLARATIVEPIESERIES_H
2 #define DECLARATIVEPIESERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qpieslice.h"
5 #include "qpieslice.h"
6 #include <QDeclarativeItem>
6 #include <QDeclarativeItem>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QPieSeries;
10 class QPieSeries;
11 class QChart;
11 class QChart;
12
12
13 class DeclarativePieSeries : public QDeclarativeItem
13 class DeclarativePieSeries : public QDeclarativeItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> data READ data)
16 Q_PROPERTY(QDeclarativeListProperty<QPieSlice> data READ data)
17
17
18 public:
18 public:
19 explicit DeclarativePieSeries(QDeclarativeItem *parent = 0);
19 explicit DeclarativePieSeries(QDeclarativeItem *parent = 0);
20 QDeclarativeListProperty<QPieSlice> data();
20 QDeclarativeListProperty<QPieSlice> data();
21
21
22 signals:
22 Q_SIGNALS:
23
23
24 public slots:
24 public Q_SLOTS:
25 static void appendData(QDeclarativeListProperty<QPieSlice> *list,
25 static void appendData(QDeclarativeListProperty<QPieSlice> *list,
26 QPieSlice *element);
26 QPieSlice *element);
27
27
28 private slots:
28 private Q_SLOTS:
29 void setParentForSeries();
29 void setParentForSeries();
30
30
31 private:
31 private:
32 QChart *m_chart;
32 QChart *m_chart;
33 QPieSeries *m_series;
33 QPieSeries *m_series;
34 QList<QPieSlice *> m_data;
34 QList<QPieSlice *> m_data;
35 };
35 };
36
36
37 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
38
38
39 #endif // DECLARATIVEPIESERIES_H
39 #endif // DECLARATIVEPIESERIES_H
@@ -1,45 +1,45
1 #ifndef DECLARATIVE_XY_SERIES_H
1 #ifndef DECLARATIVE_XY_SERIES_H
2 #define DECLARATIVE_XY_SERIES_H
2 #define DECLARATIVE_XY_SERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "declarativexypoint.h"
5 #include "declarativexypoint.h"
6 #include "qxyseries.h"
6 #include "qxyseries.h"
7 #include <QDeclarativeItem>
7 #include <QDeclarativeItem>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QChart;
11 class QChart;
12
12
13 class DeclarativeXySeries : public QDeclarativeItem
13 class DeclarativeXySeries : public QDeclarativeItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points)
16 Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points)
17
17
18 public:
18 public:
19 explicit DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent = 0);
19 explicit DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent = 0);
20 ~DeclarativeXySeries();
20 ~DeclarativeXySeries();
21
21
22 public: // from QDeclarativeParserStatus
22 public: // from QDeclarativeParserStatus
23 void componentComplete();
23 void componentComplete();
24
24
25 public:
25 public:
26 QDeclarativeListProperty<DeclarativeXyPoint> points();
26 QDeclarativeListProperty<DeclarativeXyPoint> points();
27
27
28 signals:
28 Q_SIGNALS:
29
29
30 public slots:
30 public Q_SLOTS:
31 static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list,
31 static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list,
32 DeclarativeXyPoint *element);
32 DeclarativeXyPoint *element);
33
33
34 private slots:
34 private Q_SLOTS:
35
35
36 public:
36 public:
37 QSeries::QSeriesType m_seriesType;
37 QSeries::QSeriesType m_seriesType;
38 QChart *m_chart;
38 QChart *m_chart;
39 QXYSeries *m_series;
39 QXYSeries *m_series;
40 QList<DeclarativeXyPoint *> m_points;
40 QList<DeclarativeXyPoint *> m_points;
41 };
41 };
42
42
43 QTCOMMERCIALCHART_END_NAMESPACE
43 QTCOMMERCIALCHART_END_NAMESPACE
44
44
45 #endif // DECLARATIVE_XY_SERIES_H
45 #endif // DECLARATIVE_XY_SERIES_H
@@ -1,72 +1,72
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 Q_SIGNALS:
34 void clicked(const QPointF &point);
34 void clicked(const QPointF &point);
35
35
36 public slots:
36 public Q_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), m_item(item) {}
58 AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries) : LineChartItem(lineSeries, 0), m_item(item) {}
59 ~AreaBoundItem() {}
59 ~AreaBoundItem() {}
60
60
61 void setLayout(QVector<QPointF> &points) {
61 void setLayout(QVector<QPointF> &points) {
62 LineChartItem::setLayout(points);
62 LineChartItem::setLayout(points);
63 m_item->updatePath();
63 m_item->updatePath();
64 }
64 }
65
65
66 private:
66 private:
67 AreaChartItem* m_item;
67 AreaChartItem* m_item;
68 };
68 };
69
69
70 QTCOMMERCIALCHART_END_NAMESPACE
70 QTCOMMERCIALCHART_END_NAMESPACE
71
71
72 #endif
72 #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 Q_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 Q_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 Q_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 Q_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,38 +1,38
1 #ifndef QCHARTAXISCATEGORIES_H_
1 #ifndef QCHARTAXISCATEGORIES_H_
2 #define QCHARTAXISCATEGORIES_H_
2 #define QCHARTAXISCATEGORIES_H_
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qbarseries.h>
5 #include <qbarseries.h>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
9 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
10 {
10 {
11 Q_OBJECT
11 Q_OBJECT
12 private:
12 private:
13 QChartAxisCategories();
13 QChartAxisCategories();
14 public:
14 public:
15 ~QChartAxisCategories();
15 ~QChartAxisCategories();
16
16
17 void insert(const QBarCategories &category);
17 void insert(const QBarCategories &category);
18 void insert(qreal value,QString label);
18 void insert(qreal value,QString label);
19 void remove(qreal value);
19 void remove(qreal value);
20 QList<qreal> values() const;
20 QList<qreal> values() const;
21 QString label(qreal value) const;
21 QString label(qreal value) const;
22 void clear();
22 void clear();
23 int count();
23 int count();
24
24
25 //internal signal
25 //internal signal
26 signals:
26 Q_SIGNALS:
27 void updated();
27 void updated();
28
28
29 private:
29 private:
30 QMap<qreal,QString> m_map;
30 QMap<qreal,QString> m_map;
31
31
32 friend class QChartAxis;
32 friend class QChartAxis;
33 };
33 };
34
34
35
35
36 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
37
37
38 #endif /* QCHARTAXISCATEGORIES_H_ */
38 #endif /* QCHARTAXISCATEGORIES_H_ */
@@ -1,75 +1,73
1 #ifndef BARCHARTITEM_H
1 #ifndef BARCHARTITEM_H
2 #define BARCHARTITEM_H
2 #define BARCHARTITEM_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5 #include "qbarseries.h"
5 #include "qbarseries.h"
6 #include <QPen>
6 #include <QPen>
7 #include <QBrush>
7 #include <QBrush>
8 #include <QGraphicsItem>
8 #include <QGraphicsItem>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 class Bar;
12 class Bar;
13 class BarValue;
13 class BarValue;
14 class QChartAxisCategories;
14 class QChartAxisCategories;
15 class QChart;
15 class QChart;
16
16
17 //typedef QVector<QRectF> BarLayout;
17 //typedef QVector<QRectF> BarLayout;
18
18
19 class BarChartItem : public ChartItem
19 class BarChartItem : public ChartItem
20 {
20 {
21 Q_OBJECT
21 Q_OBJECT
22 public:
22 public:
23 BarChartItem(QBarSeries *series, ChartPresenter *presenter);
23 BarChartItem(QBarSeries *series, ChartPresenter *presenter);
24 virtual ~BarChartItem();
24 virtual ~BarChartItem();
25
25
26 // Common implemantation of different presenters. Not to be instantiated.
26 // Common implemantation of different presenters. Not to be instantiated.
27 // TODO: combine this with BarPresenter and derive other presenters from it?
27 // TODO: combine this with BarPresenter and derive other presenters from it?
28
28
29 public:
29 public:
30 // From QGraphicsItem
30 // From QGraphicsItem
31 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
31 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
32 QRectF boundingRect() const;
32 QRectF boundingRect() const;
33
33
34 // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it
34 // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it
35 virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes
35 virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes
36 private slots:
37
36
38 public:
39 virtual QVector<QRectF> calculateLayout();
37 virtual QVector<QRectF> calculateLayout();
40 void applyLayout(const QVector<QRectF> &layout);
38 void applyLayout(const QVector<QRectF> &layout);
41 void setLayout(const QVector<QRectF> &layout);
39 void setLayout(const QVector<QRectF> &layout);
42 void updateLayout(const QVector<QRectF> &layout);
40 void updateLayout(const QVector<QRectF> &layout);
43
41
44 QRectF geometry() const { return m_rect;}
42 QRectF geometry() const { return m_rect;}
45
43
46 public slots:
44 public Q_SLOTS:
47 void handleModelChanged(int index);
45 void handleModelChanged(int index);
48 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
46 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
49 void handleGeometryChanged(const QRectF &size);
47 void handleGeometryChanged(const QRectF &size);
50 void handleLayoutChanged();
48 void handleLayoutChanged();
51
49
52 // Internal slots
50 // Internal slots
53 void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled)
51 void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled)
54
52
55 protected:
53 protected:
56
54
57 // TODO: consider these.
55 // TODO: consider these.
58 qreal m_domainMinX;
56 qreal m_domainMinX;
59 qreal m_domainMaxX;
57 qreal m_domainMaxX;
60 qreal m_domainMinY;
58 qreal m_domainMinY;
61 qreal m_domainMaxY;
59 qreal m_domainMaxY;
62
60
63 QRectF m_rect;
61 QRectF m_rect;
64 bool m_layoutSet; // True, if component has been laid out.
62 bool m_layoutSet; // True, if component has been laid out.
65 QVector<QRectF> m_layout;
63 QVector<QRectF> m_layout;
66
64
67 // Not owned.
65 // Not owned.
68 QBarSeries *m_series;
66 QBarSeries *m_series;
69 QList<Bar *> m_bars;
67 QList<Bar *> m_bars;
70 QList<BarValue *> m_floatingValues;
68 QList<BarValue *> m_floatingValues;
71 };
69 };
72
70
73 QTCOMMERCIALCHART_END_NAMESPACE
71 QTCOMMERCIALCHART_END_NAMESPACE
74
72
75 #endif // BARCHARTITEM_H
73 #endif // BARCHARTITEM_H
@@ -1,57 +1,57
1 #ifndef BARCHARTMODEL_H
1 #ifndef BARCHARTMODEL_H
2 #define BARCHARTMODEL_H
2 #define BARCHARTMODEL_H
3
3
4 #include <QObject>
4 #include <QObject>
5 #include <QStringList>
5 #include <QStringList>
6 #include "qchartglobal.h"
6 #include "qchartglobal.h"
7 #include <qseries.h>
7 #include <qseries.h>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 // Model for bar chart. Internal class.
11 // Model for bar chart. Internal class.
12 // TODO: Implement as QAbstractItemModel?
12 // TODO: Implement as QAbstractItemModel?
13
13
14 class QBarSet;
14 class QBarSet;
15
15
16 class BarChartModel : public QObject //, public QAbstractItemModel
16 class BarChartModel : public QObject //, public QAbstractItemModel
17 {
17 {
18 Q_OBJECT
18 Q_OBJECT
19 public:
19 public:
20 explicit BarChartModel(QStringList categories, QObject *parent = 0);
20 explicit BarChartModel(QStringList categories, QObject *parent = 0);
21
21
22 QStringList category();
22 QStringList category();
23 void addBarSet(QBarSet *set);
23 void addBarSet(QBarSet *set);
24 void removeBarSet(QBarSet *set);
24 void removeBarSet(QBarSet *set);
25 void insertBarSet(int i, QBarSet *set);
25 void insertBarSet(int i, QBarSet *set);
26 void insertCategory(int i, QString category);
26 void insertCategory(int i, QString category);
27 void removeCategory(int i);
27 void removeCategory(int i);
28 QBarSet *setAt(int index);
28 QBarSet *setAt(int index);
29 QList<QBarSet *> barSets();
29 QList<QBarSet *> barSets();
30
30
31 int barsetCount(); // Number of sets in model
31 int barsetCount(); // Number of sets in model
32 int categoryCount(); // Number of categories
32 int categoryCount(); // Number of categories
33
33
34 qreal max(); // Maximum value of all sets
34 qreal max(); // Maximum value of all sets
35 qreal min(); // Minimum value of all sets
35 qreal min(); // Minimum value of all sets
36 qreal valueAt(int set, int category);
36 qreal valueAt(int set, int category);
37 qreal percentageAt(int set, int category);
37 qreal percentageAt(int set, int category);
38
38
39 qreal categorySum(int category);
39 qreal categorySum(int category);
40 qreal maxCategorySum(); // returns maximum sum of sets in all categories.
40 qreal maxCategorySum(); // returns maximum sum of sets in all categories.
41
41
42 QString categoryName(int category);
42 QString categoryName(int category);
43
43
44 signals:
44 Q_SIGNALS:
45 void modelUpdated();
45 void modelUpdated();
46
46
47 public slots:
47 public Q_SLOTS:
48
48
49 private:
49 private:
50
50
51 QList<QBarSet *> m_dataModel;
51 QList<QBarSet *> m_dataModel;
52 QStringList m_category;
52 QStringList m_category;
53 };
53 };
54
54
55 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
56
56
57 #endif // BARCHARTMODEL_H
57 #endif // BARCHARTMODEL_H
@@ -1,97 +1,97
1 #ifndef BARSERIES_H
1 #ifndef BARSERIES_H
2 #define BARSERIES_H
2 #define BARSERIES_H
3
3
4 #include <qseries.h>
4 #include <qseries.h>
5 #include <QStringList>
5 #include <QStringList>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 typedef QStringList QBarCategories;
9 typedef QStringList QBarCategories;
10
10
11 class QBarSet;
11 class QBarSet;
12 class BarChartModel;
12 class BarChartModel;
13 class BarCategory;
13 class BarCategory;
14
14
15 // Container for series
15 // Container for series
16 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries
16 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries
17 {
17 {
18 Q_OBJECT
18 Q_OBJECT
19 public:
19 public:
20 QBarSeries(QStringList categories, QObject *parent = 0);
20 QBarSeries(QStringList categories, QObject *parent = 0);
21
21
22 virtual QSeriesType type() const { return QSeries::SeriesTypeBar; }
22 virtual QSeriesType type() const { return QSeries::SeriesTypeBar; }
23
23
24 void addBarSet(QBarSet *set); // Takes ownership of set
24 void addBarSet(QBarSet *set); // Takes ownership of set
25 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
25 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
26 void insertBarSet(int i, QBarSet *set);
26 void insertBarSet(int i, QBarSet *set);
27 void insertCategory(int i, QString category);
27 void insertCategory(int i, QString category);
28 void removeCategory(int i);
28 void removeCategory(int i);
29 int barsetCount();
29 int barsetCount();
30 int categoryCount();
30 int categoryCount();
31 QList<QBarSet*> barSets();
31 QList<QBarSet*> barSets();
32 QBarCategories categories() const;
32 QBarCategories categories() const;
33
33
34 bool setModel(QAbstractItemModel *model);
34 bool setModel(QAbstractItemModel *model);
35 QAbstractItemModel *modelExt() { return m_model; }
35 QAbstractItemModel *modelExt() { return m_model; }
36 void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical);
36 void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical);
37 void setModelMappingShift(int first, int count);
37 void setModelMappingShift(int first, int count);
38
38
39 public:
39 public:
40 // TODO: Functions below this are not part of api and will be moved
40 // TODO: Functions below this are not part of api and will be moved
41 // to private implementation, when we start using it
41 // to private implementation, when we start using it
42 // TODO: TO PIMPL --->
42 // TODO: TO PIMPL --->
43 QBarSet* barsetAt(int index);
43 QBarSet* barsetAt(int index);
44 QString categoryName(int category);
44 QString categoryName(int category);
45 qreal min();
45 qreal min();
46 qreal max();
46 qreal max();
47 qreal valueAt(int set, int category);
47 qreal valueAt(int set, int category);
48 qreal percentageAt(int set, int category);
48 qreal percentageAt(int set, int category);
49 qreal categorySum(int category);
49 qreal categorySum(int category);
50 qreal maxCategorySum();
50 qreal maxCategorySum();
51 BarChartModel& model();
51 BarChartModel& model();
52 // <--- TO PIMPL
52 // <--- TO PIMPL
53
53
54 signals:
54 Q_SIGNALS:
55 //void changed(int index);
55 //void changed(int index);
56 void clicked(QBarSet *barset, QString category); // Up to user of api, what to do with these signals
56 void clicked(QBarSet *barset, QString category); // Up to user of api, what to do with these signals
57 void rightClicked(QBarSet *barset, QString category);
57 void rightClicked(QBarSet *barset, QString category);
58
58
59 //
59 //
60 void updatedBars();
60 void updatedBars();
61 void restructuredBar(int);
61 void restructuredBar(int);
62
62
63 // TODO: internal signals, these to private implementation.
63 // TODO: internal signals, these to private implementation.
64 // TODO: TO PIMPL --->
64 // TODO: TO PIMPL --->
65 void showToolTip(QPoint pos, QString tip);
65 void showToolTip(QPoint pos, QString tip);
66 // <--- TO PIMPL
66 // <--- TO PIMPL
67
67
68 public Q_SLOTS:
68 public Q_SLOTS:
69 void setToolTipEnabled(bool enabled = true); // enables tooltips
69 void setToolTipEnabled(bool enabled = true); // enables tooltips
70
70
71 // TODO: TO PIMPL --->
71 // TODO: TO PIMPL --->
72 void barsetClicked(QString category);
72 void barsetClicked(QString category);
73 void barsetRightClicked(QString category);
73 void barsetRightClicked(QString category);
74 // <--- TO PIMPL
74 // <--- TO PIMPL
75
75
76 private Q_SLOTS:
76 private Q_SLOTS:
77 // slots for updating bars when data in model changes
77 // slots for updating bars when data in model changes
78 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
78 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
79 void modelDataAdded(QModelIndex parent, int start, int end);
79 void modelDataAdded(QModelIndex parent, int start, int end);
80 void modelDataRemoved(QModelIndex parent, int start, int end);
80 void modelDataRemoved(QModelIndex parent, int start, int end);
81 void barsetChanged();
81 void barsetChanged();
82
82
83 protected:
83 protected:
84 BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good.
84 BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good.
85
85
86 QAbstractItemModel* m_model;
86 QAbstractItemModel* m_model;
87 int m_mapCategories;
87 int m_mapCategories;
88 int m_mapBarBottom;
88 int m_mapBarBottom;
89 int m_mapBarTop;
89 int m_mapBarTop;
90 int m_mapFirst;
90 int m_mapFirst;
91 int m_mapCount;
91 int m_mapCount;
92 Qt::Orientation m_mapOrientation;
92 Qt::Orientation m_mapOrientation;
93 };
93 };
94
94
95 QTCOMMERCIALCHART_END_NAMESPACE
95 QTCOMMERCIALCHART_END_NAMESPACE
96
96
97 #endif // BARSERIES_H
97 #endif // BARSERIES_H
@@ -1,35 +1,35
1 #ifndef CHART_H_
1 #ifndef CHART_H_
2 #define CHART_H_
2 #define CHART_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include <QRect>
5 #include <QRect>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class ChartAnimator;
9 class ChartAnimator;
10 class ChartPresenter;
10 class ChartPresenter;
11
11
12 class Chart: public QObject
12 class Chart: public QObject
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16 explicit Chart(ChartPresenter *presenter);
16 explicit Chart(ChartPresenter *presenter);
17
17
18 public slots:
18 public Q_SLOTS:
19 virtual void handleGeometryChanged(const QRectF& rect);
19 virtual void handleGeometryChanged(const QRectF& rect);
20 virtual void handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY);
20 virtual void handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY);
21 virtual void rangeXChanged(qreal min, qreal max, int tickXCount);
21 virtual void rangeXChanged(qreal min, qreal max, int tickXCount);
22 virtual void rangeYChanged(qreal min, qreal max, int tickYCount);
22 virtual void rangeYChanged(qreal min, qreal max, int tickYCount);
23
23
24 void setAnimator(ChartAnimator* animator);
24 void setAnimator(ChartAnimator* animator);
25 ChartAnimator* animator() const;
25 ChartAnimator* animator() const;
26 ChartPresenter* presenter() const;
26 ChartPresenter* presenter() const;
27
27
28 private:
28 private:
29 ChartAnimator* m_animator;
29 ChartAnimator* m_animator;
30 ChartPresenter* m_presenter;
30 ChartPresenter* m_presenter;
31 };
31 };
32
32
33 QTCOMMERCIALCHART_END_NAMESPACE
33 QTCOMMERCIALCHART_END_NAMESPACE
34
34
35 #endif
35 #endif
@@ -1,88 +1,88
1 #ifndef CHARTPRESENTER_H_
1 #ifndef CHARTPRESENTER_H_
2 #define CHARTPRESENTER_H_
2 #define CHARTPRESENTER_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
6 #include "qchartaxis.h"
6 #include "qchartaxis.h"
7 #include <QRectF>
7 #include <QRectF>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class Chart;
11 class Chart;
12 class QSeries;
12 class QSeries;
13 class ChartDataSet;
13 class ChartDataSet;
14 class Domain;
14 class Domain;
15 class Axis;
15 class Axis;
16 class ChartTheme;
16 class ChartTheme;
17 class ChartAnimator;
17 class ChartAnimator;
18
18
19 class ChartPresenter: public QObject
19 class ChartPresenter: public QObject
20 {
20 {
21 Q_OBJECT
21 Q_OBJECT
22 public:
22 public:
23 enum ZValues {
23 enum ZValues {
24 BackgroundZValue = -1,
24 BackgroundZValue = -1,
25 ShadesZValue,
25 ShadesZValue,
26 GridZValue,
26 GridZValue,
27 LineChartZValue,
27 LineChartZValue,
28 BarSeriesZValue,
28 BarSeriesZValue,
29 ScatterSeriesZValue,
29 ScatterSeriesZValue,
30 PieSeriesZValue,
30 PieSeriesZValue,
31 AxisZValue,
31 AxisZValue,
32 LegendZValue
32 LegendZValue
33 };
33 };
34
34
35 ChartPresenter(QChart* chart,ChartDataSet *dataset);
35 ChartPresenter(QChart* chart,ChartDataSet *dataset);
36 virtual ~ChartPresenter();
36 virtual ~ChartPresenter();
37
37
38 int padding() const { return m_padding; }
38 int padding() const { return m_padding; }
39 int backgroundPadding() const { return m_backgroundPadding; }
39 int backgroundPadding() const { return m_backgroundPadding; }
40 QRectF geometry() const { return m_rect; }
40 QRectF geometry() const { return m_rect; }
41 ChartAnimator* animator() const { return m_animator; }
41 ChartAnimator* animator() const { return m_animator; }
42 ChartTheme *chartTheme() const { return m_chartTheme; }
42 ChartTheme *chartTheme() const { return m_chartTheme; }
43 ChartDataSet *dataSet() const { return m_dataset; }
43 ChartDataSet *dataSet() const { return m_dataset; }
44 QGraphicsItem* rootItem() const { return m_chart; }
44 QGraphicsItem* rootItem() const { return m_chart; }
45
45
46 void setTheme(QChart::ChartTheme theme,bool force = true);
46 void setTheme(QChart::ChartTheme theme,bool force = true);
47 QChart::ChartTheme theme();
47 QChart::ChartTheme theme();
48
48
49 void setAnimationOptions(QChart::AnimationOptions options);
49 void setAnimationOptions(QChart::AnimationOptions options);
50 QChart::AnimationOptions animationOptions() const;
50 QChart::AnimationOptions animationOptions() const;
51
51
52 void zoomIn();
52 void zoomIn();
53 void zoomIn(const QRectF& rect);
53 void zoomIn(const QRectF& rect);
54 void zoomOut();
54 void zoomOut();
55 void scroll(int dx,int dy);
55 void scroll(int dx,int dy);
56
56
57 private:
57 private:
58 void createConnections();
58 void createConnections();
59 void resetAllElements();
59 void resetAllElements();
60
60
61 public slots:
61 public Q_SLOTS:
62 void handleSeriesAdded(QSeries* series,Domain* domain);
62 void handleSeriesAdded(QSeries* series,Domain* domain);
63 void handleSeriesRemoved(QSeries* series);
63 void handleSeriesRemoved(QSeries* series);
64 void handleAxisAdded(QChartAxis* axis,Domain* domain);
64 void handleAxisAdded(QChartAxis* axis,Domain* domain);
65 void handleAxisRemoved(QChartAxis* axis);
65 void handleAxisRemoved(QChartAxis* axis);
66 void handleGeometryChanged();
66 void handleGeometryChanged();
67
67
68 signals:
68 Q_SIGNALS:
69 void geometryChanged(const QRectF& rect);
69 void geometryChanged(const QRectF& rect);
70
70
71 private:
71 private:
72 QChart* m_chart;
72 QChart* m_chart;
73 ChartAnimator* m_animator;
73 ChartAnimator* m_animator;
74 ChartDataSet* m_dataset;
74 ChartDataSet* m_dataset;
75 ChartTheme *m_chartTheme;
75 ChartTheme *m_chartTheme;
76 QMap<QSeries*,Chart*> m_chartItems;
76 QMap<QSeries*,Chart*> m_chartItems;
77 QMap<QChartAxis*,Axis*> m_axisItems;
77 QMap<QChartAxis*,Axis*> m_axisItems;
78 QRectF m_rect;
78 QRectF m_rect;
79 QChart::AnimationOptions m_options;
79 QChart::AnimationOptions m_options;
80 bool m_themeForce;
80 bool m_themeForce;
81 int m_padding;
81 int m_padding;
82 int m_backgroundPadding;
82 int m_backgroundPadding;
83
83
84 };
84 };
85
85
86 QTCOMMERCIALCHART_END_NAMESPACE
86 QTCOMMERCIALCHART_END_NAMESPACE
87
87
88 #endif /* CHARTPRESENTER_H_ */
88 #endif /* CHARTPRESENTER_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 Q_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 Q_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,38 +1,38
1 #ifndef LEGENDSCROLLBUTTON_P_H
1 #ifndef LEGENDSCROLLBUTTON_P_H
2 #define LEGENDSCROLLBUTTON_P_H
2 #define LEGENDSCROLLBUTTON_P_H
3
3
4 #include <QObject>
4 #include <QObject>
5 #include <qchartglobal.h>
5 #include <qchartglobal.h>
6 #include <QGraphicsPolygonItem>
6 #include <QGraphicsPolygonItem>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class LegendScrollButton : public QObject, public QGraphicsPolygonItem
10 class LegendScrollButton : public QObject, public QGraphicsPolygonItem
11 {
11 {
12 Q_OBJECT
12 Q_OBJECT
13 public:
13 public:
14 enum ScrollButtonId {
14 enum ScrollButtonId {
15 ScrollButtonIdLeft,
15 ScrollButtonIdLeft,
16 ScrollButtonIdRight,
16 ScrollButtonIdRight,
17 ScrollButtonIdUp,
17 ScrollButtonIdUp,
18 ScrollButtonIdDown
18 ScrollButtonIdDown
19 };
19 };
20
20
21 explicit LegendScrollButton(ScrollButtonId id, QGraphicsItem *parent = 0);
21 explicit LegendScrollButton(ScrollButtonId id, QGraphicsItem *parent = 0);
22 ScrollButtonId id();
22 ScrollButtonId id();
23
23
24 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
24 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
25
25
26 signals:
26 Q_SIGNALS:
27 void clicked(QGraphicsSceneMouseEvent* event);
27 void clicked(QGraphicsSceneMouseEvent* event);
28
28
29 public slots:
29 public Q_SLOTS:
30
30
31 private:
31 private:
32
32
33 ScrollButtonId mId;
33 ScrollButtonId mId;
34 };
34 };
35
35
36 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
37
37
38 #endif // LEGENDSCROLLBUTTON_P_H
38 #endif // LEGENDSCROLLBUTTON_P_H
@@ -1,44 +1,44
1 #ifndef LINECHARTITEM_H
1 #ifndef LINECHARTITEM_H
2 #define LINECHARTITEM_H
2 #define LINECHARTITEM_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "xychartitem_p.h"
5 #include "xychartitem_p.h"
6 #include <QPen>
6 #include <QPen>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QLineSeries;
10 class QLineSeries;
11 class ChartPresenter;
11 class ChartPresenter;
12
12
13 class LineChartItem : public XYChartItem
13 class LineChartItem : public XYChartItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 public:
16 public:
17 explicit LineChartItem(QLineSeries *series,ChartPresenter *presenter);
17 explicit LineChartItem(QLineSeries *series,ChartPresenter *presenter);
18 ~LineChartItem() {};
18 ~LineChartItem() {};
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 public slots:
25 public Q_SLOTS:
26 void handleUpdated();
26 void handleUpdated();
27
27
28 protected:
28 protected:
29 void setLayout(QVector<QPointF>& points);
29 void setLayout(QVector<QPointF>& points);
30
30
31 private:
31 private:
32 QLineSeries* m_series;
32 QLineSeries* m_series;
33 QGraphicsItemGroup m_items;
33 QGraphicsItemGroup m_items;
34 QPainterPath m_path;
34 QPainterPath m_path;
35 QRectF m_rect;
35 QRectF m_rect;
36 QPen m_linePen;
36 QPen m_linePen;
37 QPen m_pointPen;
37 QPen m_pointPen;
38 bool m_pointsVisible;
38 bool m_pointsVisible;
39
39
40 };
40 };
41
41
42 QTCOMMERCIALCHART_END_NAMESPACE
42 QTCOMMERCIALCHART_END_NAMESPACE
43
43
44 #endif
44 #endif
@@ -1,111 +1,111
1 #ifndef QLEGEND_H
1 #ifndef QLEGEND_H
2 #define QLEGEND_H
2 #define QLEGEND_H
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <QGraphicsObject>
5 #include <QGraphicsObject>
6 #include <QPen>
6 #include <QPen>
7 #include <QBrush>
7 #include <QBrush>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class Domain;
11 class Domain;
12 class LegendMarker;
12 class LegendMarker;
13 class QPieSlice;
13 class QPieSlice;
14 class QXYSeries;
14 class QXYSeries;
15 class QBarSet;
15 class QBarSet;
16 class QBarSeries;
16 class QBarSeries;
17 class QPieSeries;
17 class QPieSeries;
18 class LegendScrollButton;
18 class LegendScrollButton;
19 class QSeries;
19 class QSeries;
20
20
21 // TODO: This as widget
21 // TODO: This as widget
22 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsObject
22 class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsObject
23 {
23 {
24 Q_OBJECT
24 Q_OBJECT
25 public:
25 public:
26
26
27 // We only support these alignments (for now)
27 // We only support these alignments (for now)
28 enum Layout {
28 enum Layout {
29 LayoutTop = Qt::AlignTop,
29 LayoutTop = Qt::AlignTop,
30 LayoutBottom = Qt::AlignBottom,
30 LayoutBottom = Qt::AlignBottom,
31 LayoutLeft = Qt::AlignLeft,
31 LayoutLeft = Qt::AlignLeft,
32 LayoutRight = Qt::AlignRight
32 LayoutRight = Qt::AlignRight
33 };
33 };
34
34
35 explicit QLegend(QGraphicsItem *parent = 0);
35 explicit QLegend(QGraphicsItem *parent = 0);
36
36
37 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
37 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
38 QRectF boundingRect() const;
38 QRectF boundingRect() const;
39
39
40 void setBrush(const QBrush &brush);
40 void setBrush(const QBrush &brush);
41 QBrush brush() const;
41 QBrush brush() const;
42
42
43 void setPen(const QPen &pen);
43 void setPen(const QPen &pen);
44 QPen pen() const;
44 QPen pen() const;
45
45
46 void setAlignmnent(QLegend::Layout alignment);
46 void setAlignmnent(QLegend::Layout alignment);
47 QLegend::Layout alignment() const;
47 QLegend::Layout alignment() const;
48
48
49 QSizeF maximumSize() const;
49 QSizeF maximumSize() const;
50 void setMaximumSize(const QSizeF size);
50 void setMaximumSize(const QSizeF size);
51
51
52 QSizeF size() const;
52 QSizeF size() const;
53 void setSize(const QSizeF size);
53 void setSize(const QSizeF size);
54 void setPos(const QPointF &pos);
54 void setPos(const QPointF &pos);
55
55
56 signals:
56 Q_SIGNALS:
57 // for interactions.
57 // for interactions.
58 void clicked(QSeries *series, Qt::MouseButton button);
58 void clicked(QSeries *series, Qt::MouseButton button);
59 void clicked(QBarSet *barset, Qt::MouseButton button);
59 void clicked(QBarSet *barset, Qt::MouseButton button);
60 void clicked(QPieSlice *slice, Qt::MouseButton button);
60 void clicked(QPieSlice *slice, Qt::MouseButton button);
61
61
62 public slots:
62 public Q_SLOTS:
63 // PIMPL --->
63 // PIMPL --->
64 void handleSeriesAdded(QSeries *series, Domain *domain);
64 void handleSeriesAdded(QSeries *series, Domain *domain);
65 void handleSeriesRemoved(QSeries *series);
65 void handleSeriesRemoved(QSeries *series);
66 void handleAdded(QList<QPieSlice *> slices);
66 void handleAdded(QList<QPieSlice *> slices);
67 void handleRemoved(QList<QPieSlice *> slices);
67 void handleRemoved(QList<QPieSlice *> slices);
68 void handleMarkerDestroyed();
68 void handleMarkerDestroyed();
69 void handleScrollButtonClicked(QGraphicsSceneMouseEvent *event);
69 void handleScrollButtonClicked(QGraphicsSceneMouseEvent *event);
70 // PIMPL <---
70 // PIMPL <---
71
71
72 private:
72 private:
73 // PIMPL --->
73 // PIMPL --->
74 void connectSeries(QSeries *series);
74 void connectSeries(QSeries *series);
75 void disconnectSeries(QSeries *series);
75 void disconnectSeries(QSeries *series);
76 void createMarkers(QSeries *series);
76 void createMarkers(QSeries *series);
77 void appendMarkers(QXYSeries *series); // All line series are derived from QXYSeries, so this works for now
77 void appendMarkers(QXYSeries *series); // All line series are derived from QXYSeries, so this works for now
78 void appendMarkers(QBarSeries *series);
78 void appendMarkers(QBarSeries *series);
79 void appendMarkers(QPieSeries *series);
79 void appendMarkers(QPieSeries *series);
80 void deleteMarkers(QSeries *series);
80 void deleteMarkers(QSeries *series);
81 void updateLayout();
81 void updateLayout();
82 void rescaleScrollButtons(const QSize &size);
82 void rescaleScrollButtons(const QSize &size);
83 QSizeF maximumMarkerSize();
83 QSizeF maximumMarkerSize();
84 void checkFirstMarkerBounds();
84 void checkFirstMarkerBounds();
85 bool scrollButtonsVisible();
85 bool scrollButtonsVisible();
86
86
87 QPointF m_pos;
87 QPointF m_pos;
88 QSizeF m_size;
88 QSizeF m_size;
89 QSizeF m_minimumSize;
89 QSizeF m_minimumSize;
90 QSizeF m_maximumSize;
90 QSizeF m_maximumSize;
91
91
92 QList<LegendMarker *> m_markers;
92 QList<LegendMarker *> m_markers;
93
93
94 QBrush m_brush;
94 QBrush m_brush;
95 QPen m_pen;
95 QPen m_pen;
96 QLegend::Layout m_alignment;
96 QLegend::Layout m_alignment;
97
97
98 int mFirstMarker;
98 int mFirstMarker;
99
99
100 LegendScrollButton *m_scrollButtonLeft;
100 LegendScrollButton *m_scrollButtonLeft;
101 LegendScrollButton *m_scrollButtonRight;
101 LegendScrollButton *m_scrollButtonRight;
102 LegendScrollButton *m_scrollButtonUp;
102 LegendScrollButton *m_scrollButtonUp;
103 LegendScrollButton *m_scrollButtonDown;
103 LegendScrollButton *m_scrollButtonDown;
104
104
105 qreal m_margin;
105 qreal m_margin;
106 // <--- PIMPL
106 // <--- PIMPL
107 };
107 };
108
108
109 QTCOMMERCIALCHART_END_NAMESPACE
109 QTCOMMERCIALCHART_END_NAMESPACE
110
110
111 #endif // QLEGEND_H
111 #endif // QLEGEND_H
@@ -1,120 +1,120
1 #ifndef SCATTERPRESENTER_H
1 #ifndef SCATTERPRESENTER_H
2 #define SCATTERPRESENTER_H
2 #define SCATTERPRESENTER_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "xychartitem_p.h"
5 #include "xychartitem_p.h"
6 #include <QGraphicsEllipseItem>
6 #include <QGraphicsEllipseItem>
7 #include <QPen>
7 #include <QPen>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QScatterSeries;
11 class QScatterSeries;
12 class Marker;
12 class Marker;
13
13
14 class ScatterChartItem : public XYChartItem
14 class ScatterChartItem : public XYChartItem
15 {
15 {
16 Q_OBJECT
16 Q_OBJECT
17 public:
17 public:
18 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
18 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
19
19
20 public:
20 public:
21 //from QGraphicsItem
21 //from QGraphicsItem
22 QRectF boundingRect() const;
22 QRectF boundingRect() const;
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
24
24
25 void setPen(const QPen &pen);
25 void setPen(const QPen &pen);
26 void setBrush(const QBrush &brush);
26 void setBrush(const QBrush &brush);
27
27
28 void markerSelected(Marker *item);
28 void markerSelected(Marker *item);
29
29
30 public slots:
30 public Q_SLOTS:
31 void handleUpdated();
31 void handleUpdated();
32
32
33 private:
33 private:
34 void createPoints(int count);
34 void createPoints(int count);
35 void deletePoints(int count);
35 void deletePoints(int count);
36
36
37 protected:
37 protected:
38 void setLayout(QVector<QPointF> &points);
38 void setLayout(QVector<QPointF> &points);
39
39
40 private:
40 private:
41 QScatterSeries *m_series;
41 QScatterSeries *m_series;
42 QGraphicsItemGroup m_items;
42 QGraphicsItemGroup m_items;
43 int m_shape;
43 int m_shape;
44 int m_size;
44 int m_size;
45 QRectF m_rect;
45 QRectF m_rect;
46
46
47 };
47 };
48
48
49
49
50 class Marker: public QAbstractGraphicsShapeItem
50 class Marker: public QAbstractGraphicsShapeItem
51 {
51 {
52
52
53 public:
53 public:
54
54
55 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent)
55 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent)
56 {
56 {
57 };
57 };
58
58
59 ~Marker()
59 ~Marker()
60 {
60 {
61 delete m_item;
61 delete m_item;
62 }
62 }
63
63
64 void setIndex(int index)
64 void setIndex(int index)
65 {
65 {
66 m_index=index;
66 m_index=index;
67 }
67 }
68
68
69 int index() const
69 int index() const
70 {
70 {
71 return m_index;
71 return m_index;
72 }
72 }
73
73
74 QPainterPath shape() const
74 QPainterPath shape() const
75 {
75 {
76 return m_item->shape();
76 return m_item->shape();
77 }
77 }
78
78
79 QRectF boundingRect() const
79 QRectF boundingRect() const
80 {
80 {
81 return m_item->boundingRect();
81 return m_item->boundingRect();
82 }
82 }
83
83
84 bool contains(const QPointF &point) const
84 bool contains(const QPointF &point) const
85 {
85 {
86 return m_item->contains(point);
86 return m_item->contains(point);
87 }
87 }
88
88
89 void setPen(const QPen &pen)
89 void setPen(const QPen &pen)
90 {
90 {
91 m_item->setPen(pen);
91 m_item->setPen(pen);
92 }
92 }
93
93
94 void setBrush(const QBrush &brush)
94 void setBrush(const QBrush &brush)
95 {
95 {
96 m_item->setBrush(brush);
96 m_item->setBrush(brush);
97 }
97 }
98
98
99 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
99 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
100 {
100 {
101 m_item->paint(painter,option,widget);
101 m_item->paint(painter,option,widget);
102 }
102 }
103
103
104 protected:
104 protected:
105
105
106 void mousePressEvent(QGraphicsSceneMouseEvent *event)
106 void mousePressEvent(QGraphicsSceneMouseEvent *event)
107 {
107 {
108 Q_UNUSED(event)
108 Q_UNUSED(event)
109 m_parent->markerSelected(this);
109 m_parent->markerSelected(this);
110 }
110 }
111
111
112 private:
112 private:
113 QAbstractGraphicsShapeItem* m_item;
113 QAbstractGraphicsShapeItem* m_item;
114 ScatterChartItem* m_parent;
114 ScatterChartItem* m_parent;
115 int m_index;
115 int m_index;
116 };
116 };
117
117
118 QTCOMMERCIALCHART_END_NAMESPACE
118 QTCOMMERCIALCHART_END_NAMESPACE
119
119
120 #endif // SCATTERPRESENTER_H
120 #endif // SCATTERPRESENTER_H
@@ -1,47 +1,47
1 #ifndef QSPLINESERIES_H
1 #ifndef QSPLINESERIES_H
2 #define QSPLINESERIES_H
2 #define QSPLINESERIES_H
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qlineseries.h>
5 #include <qlineseries.h>
6 #include <QList>
6 #include <QList>
7 #include <QPointF>
7 #include <QPointF>
8 #include <QtGlobal>
8 #include <QtGlobal>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries
12 class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16
16
17 QSplineSeries(QObject *parent = 0);
17 QSplineSeries(QObject *parent = 0);
18 QSeriesType type() const {return QSeries::SeriesTypeSpline;}
18 QSeriesType type() const {return QSeries::SeriesTypeSpline;}
19
19
20 // int count() const { return m_x.size(); }
20 // int count() const { return m_x.size(); }
21 QPointF controlPoint(int index) const {return m_controlPoints[index];}
21 QPointF controlPoint(int index) const {return m_controlPoints[index];}
22 bool setModel(QAbstractItemModel *model);
22 bool setModel(QAbstractItemModel *model);
23
23
24 void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
24 void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
25 void setModelMappingShift(int first, int count);
25 void setModelMappingShift(int first, int count);
26
26
27 // TODO: allow the user to set custom control points
27 // TODO: allow the user to set custom control points
28 // void setCustomControlPoints(QList<QPointsF> controlPoints);
28 // void setCustomControlPoints(QList<QPointsF> controlPoints);
29 // bool calculateControlPointsAutomatically();
29 // bool calculateControlPointsAutomatically();
30 // void setCalculateControlPointsAutomatically();
30 // void setCalculateControlPointsAutomatically();
31
31
32
32
33 private:
33 private:
34 void calculateControlPoints();
34 void calculateControlPoints();
35 QList<qreal> getFirstControlPoints(QList<qreal> rhs);
35 QList<qreal> getFirstControlPoints(QList<qreal> rhs);
36
36
37 private slots:
37 private Q_SLOTS:
38 void updateControlPoints();
38 void updateControlPoints();
39
39
40 private:
40 private:
41 QList<QPointF> m_controlPoints;
41 QList<QPointF> m_controlPoints;
42
42
43 };
43 };
44
44
45 QTCOMMERCIALCHART_END_NAMESPACE
45 QTCOMMERCIALCHART_END_NAMESPACE
46
46
47 #endif // QSPLINESERIES_H
47 #endif // QSPLINESERIES_H
@@ -1,44 +1,44
1 #ifndef SPLINECHARTITEM_P_H
1 #ifndef SPLINECHARTITEM_P_H
2 #define SPLINECHARTITEM_P_H
2 #define SPLINECHARTITEM_P_H
3
3
4 #include "qsplineseries.h"
4 #include "qsplineseries.h"
5 #include "xychartitem_p.h"
5 #include "xychartitem_p.h"
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class SplineChartItem : public XYChartItem
9 class SplineChartItem : public XYChartItem
10 {
10 {
11 Q_OBJECT
11 Q_OBJECT
12 public:
12 public:
13 SplineChartItem(QSplineSeries *series, ChartPresenter *presenter);
13 SplineChartItem(QSplineSeries *series, ChartPresenter *presenter);
14
14
15 //from QGraphicsItem
15 //from QGraphicsItem
16 QRectF boundingRect() const;
16 QRectF boundingRect() const;
17 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
17 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
18 QPainterPath shape() const;
18 QPainterPath shape() const;
19
19
20 public slots:
20 public Q_SLOTS:
21 void handleUpdated();
21 void handleUpdated();
22
22
23 protected:
23 protected:
24 void setLayout(QVector<QPointF> &points,QVector<QPointF> &controlPoints);
24 void setLayout(QVector<QPointF> &points,QVector<QPointF> &controlPoints);
25 void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index);
25 void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index);
26
26
27 private:
27 private:
28 QPointF calculateGeometryControlPoint(int index) const;
28 QPointF calculateGeometryControlPoint(int index) const;
29
29
30 private:
30 private:
31 QSplineSeries* m_series;
31 QSplineSeries* m_series;
32 QPainterPath m_path;
32 QPainterPath m_path;
33 QRectF m_rect;
33 QRectF m_rect;
34 QPen m_linePen;
34 QPen m_linePen;
35 QPen m_pointPen;
35 QPen m_pointPen;
36 bool m_pointsVisible;
36 bool m_pointsVisible;
37 QVector<QPointF> m_controlPoints;
37 QVector<QPointF> m_controlPoints;
38
38
39 friend class SplineAnimation;
39 friend class SplineAnimation;
40 };
40 };
41
41
42 QTCOMMERCIALCHART_END_NAMESPACE
42 QTCOMMERCIALCHART_END_NAMESPACE
43
43
44 #endif // SPLINECHARTITEM_P_H
44 #endif // SPLINECHARTITEM_P_H
@@ -1,80 +1,80
1 #ifndef QXYSERIES_H_
1 #ifndef QXYSERIES_H_
2 #define QXYSERIES_H_
2 #define QXYSERIES_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
10
11 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
11 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14 protected:
14 protected:
15 QXYSeries(QObject *parent = 0);
15 QXYSeries(QObject *parent = 0);
16 virtual ~QXYSeries();
16 virtual ~QXYSeries();
17
17
18 public:
18 public:
19 void add(qreal x, qreal y);
19 void add(qreal x, qreal y);
20 void add(const QPointF &point);
20 void add(const QPointF &point);
21 void add(const QList<QPointF> points);
21 void add(const QList<QPointF> points);
22 void replace(qreal x,qreal y);
22 void replace(qreal x,qreal y);
23 void replace(const QPointF &point);
23 void replace(const QPointF &point);
24 void remove(qreal x);
24 void remove(qreal x);
25 void remove(qreal x, qreal y);
25 void remove(qreal x, qreal y);
26 void remove(const QPointF &point);
26 void remove(const QPointF &point);
27 void removeAll();
27 void removeAll();
28
28
29 int count() const;
29 int count() const;
30 qreal x(int pos) const;
30 qreal x(int pos) const;
31 qreal y(int pos) const;
31 qreal y(int pos) const;
32 QList<QPointF> data();
32 QList<QPointF> data();
33
33
34 QXYSeries& operator << (const QPointF &point);
34 QXYSeries& operator << (const QPointF &point);
35 QXYSeries& operator << (const QList<QPointF> points);
35 QXYSeries& operator << (const QList<QPointF> points);
36
36
37 void setPen(const QPen &pen);
37 void setPen(const QPen &pen);
38 QPen pen() const {return m_pen;}
38 QPen pen() const {return m_pen;}
39 void setBrush(const QBrush &brush);
39 void setBrush(const QBrush &brush);
40 QBrush brush() const {return m_brush;}
40 QBrush brush() const {return m_brush;}
41
41
42 bool setModel(QAbstractItemModel *model);
42 bool setModel(QAbstractItemModel *model);
43 QAbstractItemModel* model() { return m_model; }
43 QAbstractItemModel* model() { return m_model; }
44
44
45 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
45 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
46 virtual void setModelMappingShift(int first, int count = 0);
46 virtual void setModelMappingShift(int first, int count = 0);
47
47
48 private slots:
48 private Q_SLOTS:
49 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
49 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
50 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
50 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
51 void modelDataAdded(QModelIndex parent, int start, int end);
51 void modelDataAdded(QModelIndex parent, int start, int end);
52 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
52 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
53 void modelDataRemoved(QModelIndex parent, int start, int end);
53 void modelDataRemoved(QModelIndex parent, int start, int end);
54
54
55 signals:
55 Q_SIGNALS:
56 void clicked(const QPointF &point);
56 void clicked(const QPointF &point);
57 void updated();
57 void updated();
58 void pointReplaced(int index);
58 void pointReplaced(int index);
59 void pointRemoved(int index);
59 void pointRemoved(int index);
60 void pointAdded(int index);
60 void pointAdded(int index);
61
61
62 protected:
62 protected:
63 QVector<qreal> m_x;
63 QVector<qreal> m_x;
64 QVector<qreal> m_y;
64 QVector<qreal> m_y;
65
65
66 QPen m_pen;
66 QPen m_pen;
67 QBrush m_brush;
67 QBrush m_brush;
68
68
69 int m_mapX;
69 int m_mapX;
70 int m_mapY;
70 int m_mapY;
71 int m_mapFirst;
71 int m_mapFirst;
72 int m_mapCount;
72 int m_mapCount;
73 bool m_mapLimited;
73 bool m_mapLimited;
74 Qt::Orientation m_mapOrientation;
74 Qt::Orientation m_mapOrientation;
75 int tempItemsRemoved;
75 int tempItemsRemoved;
76 };
76 };
77
77
78 QTCOMMERCIALCHART_END_NAMESPACE
78 QTCOMMERCIALCHART_END_NAMESPACE
79
79
80 #endif
80 #endif
@@ -1,65 +1,65
1 #ifndef XYCHARTITEM_H
1 #ifndef XYCHARTITEM_H
2 #define XYCHARTITEM_H
2 #define XYCHARTITEM_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "chartitem_p.h"
5 #include "chartitem_p.h"
6 #include <QPen>
6 #include <QPen>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class ChartPresenter;
10 class ChartPresenter;
11 class QXYSeries;
11 class QXYSeries;
12
12
13 class XYChartItem : public ChartItem
13 class XYChartItem : public ChartItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 public:
16 public:
17 explicit XYChartItem(QXYSeries *series, ChartPresenter *presenter);
17 explicit XYChartItem(QXYSeries *series, ChartPresenter *presenter);
18 ~XYChartItem(){};
18 ~XYChartItem(){};
19
19
20 QVector<QPointF> points() const {return m_points;}
20 QVector<QPointF> points() const {return m_points;}
21 QRectF clipRect() const { return m_clipRect;}
21 QRectF clipRect() const { return m_clipRect;}
22
22
23
23
24 public slots:
24 public Q_SLOTS:
25 void handlePointAdded(int index);
25 void handlePointAdded(int index);
26 void handlePointRemoved(int index);
26 void handlePointRemoved(int index);
27 void handlePointReplaced(int index);
27 void handlePointReplaced(int index);
28 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
28 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
29 void handleGeometryChanged(const QRectF &size);
29 void handleGeometryChanged(const QRectF &size);
30
30
31 signals:
31 Q_SIGNALS:
32 void clicked(const QPointF& point);
32 void clicked(const QPointF& point);
33
33
34 protected:
34 protected:
35
35
36 virtual void setLayout(QVector<QPointF> &points);
36 virtual void setLayout(QVector<QPointF> &points);
37 virtual void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index = 0);
37 virtual void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index = 0);
38
38
39 QPointF calculateGeometryPoint(const QPointF &point) const;
39 QPointF calculateGeometryPoint(const QPointF &point) const;
40 QPointF calculateGeometryPoint(int index) const;
40 QPointF calculateGeometryPoint(int index) const;
41 QPointF calculateDomainPoint(const QPointF &point) const;
41 QPointF calculateDomainPoint(const QPointF &point) const;
42 QVector<QPointF> calculateGeometryPoints() const;
42 QVector<QPointF> calculateGeometryPoints() const;
43 void mousePressEvent(QGraphicsSceneMouseEvent *event);
43 void mousePressEvent(QGraphicsSceneMouseEvent *event);
44
44
45 private:
45 private:
46 inline bool isEmpty();
46 inline bool isEmpty();
47
47
48 private:
48 private:
49 qreal m_minX;
49 qreal m_minX;
50 qreal m_maxX;
50 qreal m_maxX;
51 qreal m_minY;
51 qreal m_minY;
52 qreal m_maxY;
52 qreal m_maxY;
53 QXYSeries* m_series;
53 QXYSeries* m_series;
54 QSizeF m_size;
54 QSizeF m_size;
55 QRectF m_clipRect;
55 QRectF m_clipRect;
56 QVector<QPointF> m_points;
56 QVector<QPointF> m_points;
57
57
58 friend class XYAnimation;
58 friend class XYAnimation;
59 friend class AreaChartItem;
59 friend class AreaChartItem;
60
60
61 };
61 };
62
62
63 QTCOMMERCIALCHART_END_NAMESPACE
63 QTCOMMERCIALCHART_END_NAMESPACE
64
64
65 #endif
65 #endif
General Comments 0
You need to be logged in to leave comments. Login now