@@ -1,92 +1,93 | |||||
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 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Rectangle { |
|
24 | Rectangle { | |
25 | width: parent.width |
|
25 | width: parent.width | |
26 | height: parent.height |
|
26 | height: parent.height | |
27 | property int __activeIndex: 1 |
|
27 | property int __activeIndex: 1 | |
28 | property real __intervalCoefficient: 0 |
|
28 | property real __intervalCoefficient: 0 | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | ChartView { |
|
31 | ChartView { | |
32 | id: chartView |
|
32 | id: chartView | |
33 | anchors.fill: parent |
|
33 | anchors.fill: parent | |
34 | title: "Wheel of fortune" |
|
34 | title: "Wheel of fortune" | |
35 | legend: ChartView.LegendDisabled |
|
35 | legend: ChartView.LegendDisabled | |
36 |
|
36 | |||
37 | PieSeries { |
|
37 | PieSeries { | |
38 | id: wheelOfFortune |
|
38 | id: wheelOfFortune | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | SplineSeries { |
|
41 | SplineSeries { | |
42 | id: splineSeries |
|
42 | id: splineSeries | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | ScatterSeries { |
|
45 | ScatterSeries { | |
46 | id: scatterSeries |
|
46 | id: scatterSeries | |
47 | } |
|
47 | } | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | Component.onCompleted: { |
|
51 | Component.onCompleted: { | |
52 | __intervalCoefficient = Math.random() + 0.1; |
|
52 | __intervalCoefficient = Math.random() + 0.1; | |
53 | console.log("__intervalCoefficient: " + __intervalCoefficient); |
|
53 | console.log("__intervalCoefficient: " + __intervalCoefficient); | |
54 |
|
54 | |||
55 | for (var i = 0; i < 20; i++) |
|
55 | for (var i = 0; i < 20; i++) | |
56 | wheelOfFortune.append("", 1); |
|
56 | wheelOfFortune.append("", 1); | |
57 |
|
57 | |||
58 | var interval = 1; |
|
58 | var interval = 1; | |
59 | for (var j = 0; interval < 800; j++) { |
|
59 | for (var j = 0; interval < 800; j++) { | |
60 | interval = __intervalCoefficient * j * j; |
|
60 | interval = __intervalCoefficient * j * j; | |
61 | splineSeries.append(j, interval); |
|
61 | splineSeries.append(j, interval); | |
62 | } |
|
62 | } | |
63 | chartView.axisX.max = j; |
|
63 | chartView.axisX.max = j; | |
64 | chartView.axisY.max = 1000; |
|
64 | chartView.axisY.max = 1000; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | Timer { |
|
67 | Timer { | |
68 | triggeredOnStart: true |
|
68 | triggeredOnStart: true | |
69 | running: true |
|
69 | running: true | |
70 | repeat: true |
|
70 | repeat: true | |
71 | interval: 100 |
|
71 | interval: 100 | |
72 | onTriggered: { |
|
72 | onTriggered: { | |
73 | var index = __activeIndex % wheelOfFortune.count; |
|
73 | var index = __activeIndex % wheelOfFortune.count; | |
74 | if (interval < 700) { |
|
74 | if (interval < 700) { | |
75 | scatterSeries.clear(); |
|
75 | scatterSeries.clear(); | |
76 | wheelOfFortune.at(index).exploded = false; |
|
76 | wheelOfFortune.at(index).exploded = false; | |
77 | __activeIndex++; |
|
77 | __activeIndex++; | |
78 | index = __activeIndex % wheelOfFortune.count; |
|
78 | index = __activeIndex % wheelOfFortune.count; | |
79 | wheelOfFortune.at(index).exploded = true; |
|
79 | wheelOfFortune.at(index).exploded = true; | |
80 | interval = splineSeries.at(__activeIndex).y; |
|
80 | interval = splineSeries.at(__activeIndex).y; | |
81 | scatterSeries.append(__activeIndex, interval); |
|
81 | scatterSeries.append(__activeIndex, interval); | |
82 | scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000"); |
|
82 | scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000"); | |
|
83 | scatterSeries.markerSize += 0.5; | |||
83 | } else { |
|
84 | } else { | |
84 | // Switch the colors of the slice and the border |
|
85 | // Switch the colors of the slice and the border | |
85 | wheelOfFortune.at(index).borderWidth = 2; |
|
86 | wheelOfFortune.at(index).borderWidth = 2; | |
86 | var borderColor = wheelOfFortune.at(index).borderColor; |
|
87 | var borderColor = wheelOfFortune.at(index).borderColor; | |
87 | wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color; |
|
88 | wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color; | |
88 | wheelOfFortune.at(index).color = borderColor; |
|
89 | wheelOfFortune.at(index).color = borderColor; | |
89 | } |
|
90 | } | |
90 | } |
|
91 | } | |
91 | } |
|
92 | } | |
92 | } |
|
93 | } |
@@ -1,53 +1,52 | |||||
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 CUSTOMTABLEMODEL_H |
|
21 | #ifndef CUSTOMTABLEMODEL_H | |
22 | #define CUSTOMTABLEMODEL_H |
|
22 | #define CUSTOMTABLEMODEL_H | |
23 |
|
23 | |||
24 | #include <QAbstractTableModel> |
|
24 | #include <QAbstractTableModel> | |
25 | #include <QHash> |
|
25 | #include <QHash> | |
26 |
|
26 | |||
27 | class CustomTableModel : public QAbstractTableModel |
|
27 | class CustomTableModel : public QAbstractTableModel | |
28 | { |
|
28 | { | |
29 | Q_OBJECT |
|
29 | Q_OBJECT | |
30 | Q_PROPERTY(int count READ rowCount) |
|
30 | Q_PROPERTY(int count READ rowCount) | |
31 |
|
31 | |||
32 | public: |
|
32 | public: | |
33 | explicit CustomTableModel(QObject *parent = 0); |
|
33 | explicit CustomTableModel(QObject *parent = 0); | |
34 |
|
34 | |||
35 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; |
|
35 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | |
36 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; |
|
36 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | |
37 | QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
|
37 | QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; | |
38 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
|
38 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | |
39 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); |
|
39 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); | |
40 | Qt::ItemFlags flags ( const QModelIndex & index ) const; |
|
40 | Qt::ItemFlags flags ( const QModelIndex & index ) const; | |
41 | void insertColumn(int column, const QModelIndex &parent = QModelIndex()); |
|
41 | void insertColumn(int column, const QModelIndex &parent = QModelIndex()); | |
42 | void insertRow(int row, const QModelIndex &parent = QModelIndex()); |
|
42 | void insertRow(int row, const QModelIndex &parent = QModelIndex()); | |
43 | /*Q_INVOKABLE*/ //bool removeRow(int row, const QModelIndex &parent = QModelIndex()); |
|
|||
44 | Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); |
|
43 | Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); | |
45 | Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex()); |
|
44 | Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex()); | |
46 |
|
45 | |||
47 | private: |
|
46 | private: | |
48 | QList<QVector<QVariant> * > m_data; |
|
47 | QList<QVector<QVariant> * > m_data; | |
49 | int m_columnCount; |
|
48 | int m_columnCount; | |
50 | int m_rowCount; |
|
49 | int m_rowCount; | |
51 | }; |
|
50 | }; | |
52 |
|
51 | |||
53 | #endif // CUSTOMTABLEMODEL_H |
|
52 | #endif // CUSTOMTABLEMODEL_H |
@@ -1,36 +1,36 | |||||
1 | #include "chartview.h" |
|
1 | #include "chartview.h" | |
2 | #include <QScatterSeries> |
|
2 | #include <QScatterSeries> | |
3 |
|
3 | |||
4 | ChartView::ChartView(QWidget *parent) : |
|
4 | ChartView::ChartView(QWidget *parent) : | |
5 | QChartView(new QChart(), parent) |
|
5 | QChartView(new QChart(), parent) | |
6 | { |
|
6 | { | |
7 | //![1] |
|
7 | //![1] | |
8 | QScatterSeries *series0 = new QScatterSeries(); |
|
8 | QScatterSeries *series0 = new QScatterSeries(); | |
9 | series0->setName("scatter1"); |
|
9 | series0->setName("scatter1"); | |
10 | series0->setShape(QScatterSeries::MarkerShapeCircle); |
|
10 | series0->setMarkerShape(QScatterSeries::MarkerShapeCircle); | |
11 | series0->setSize(15.0); |
|
11 | series0->setMarkerSize(15.0); | |
12 |
|
12 | |||
13 | QScatterSeries *series1 = new QScatterSeries(); |
|
13 | QScatterSeries *series1 = new QScatterSeries(); | |
14 | series1->setName("scatter2"); |
|
14 | series1->setName("scatter2"); | |
15 | series1->setShape(QScatterSeries::MarkerShapeCircle); |
|
15 | series1->setMarkerShape(QScatterSeries::MarkerShapeCircle); | |
16 | series1->setSize(20.0); |
|
16 | series1->setMarkerSize(20.0); | |
17 | //![1] |
|
17 | //![1] | |
18 |
|
18 | |||
19 | //![2] |
|
19 | //![2] | |
20 | series0->append(0, 6); |
|
20 | series0->append(0, 6); | |
21 | series0->append(2, 4); |
|
21 | series0->append(2, 4); | |
22 | series0->append(3, 8); |
|
22 | series0->append(3, 8); | |
23 | series0->append(7, 4); |
|
23 | series0->append(7, 4); | |
24 | series0->append(10, 5); |
|
24 | series0->append(10, 5); | |
25 |
|
25 | |||
26 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); |
|
26 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); | |
27 | //![2] |
|
27 | //![2] | |
28 |
|
28 | |||
29 | //![3] |
|
29 | //![3] | |
30 | setRenderHint(QPainter::Antialiasing); |
|
30 | setRenderHint(QPainter::Antialiasing); | |
31 | chart()->addSeries(series0); |
|
31 | chart()->addSeries(series0); | |
32 | chart()->addSeries(series1); |
|
32 | chart()->addSeries(series1); | |
33 | chart()->setTitle("Simple scatterchart example"); |
|
33 | chart()->setTitle("Simple scatterchart example"); | |
34 | chart()->setBackgroundDropShadowEnabled(false); |
|
34 | chart()->setBackgroundDropShadowEnabled(false); | |
35 | //![3] |
|
35 | //![3] | |
36 | } |
|
36 | } |
@@ -1,85 +1,88 | |||||
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 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qaxiscategories.h" |
|
24 | #include "qaxiscategories.h" | |
25 | #include "declarativechart.h" |
|
25 | #include "declarativechart.h" | |
26 | #include "declarativexypoint.h" |
|
26 | #include "declarativexypoint.h" | |
27 | #include "declarativelineseries.h" |
|
27 | #include "declarativelineseries.h" | |
28 | #include "declarativesplineseries.h" |
|
28 | #include "declarativesplineseries.h" | |
29 | #include "declarativeareaseries.h" |
|
29 | #include "declarativeareaseries.h" | |
30 | #include "declarativescatterseries.h" |
|
30 | #include "declarativescatterseries.h" | |
31 | #include "declarativebarseries.h" |
|
31 | #include "declarativebarseries.h" | |
32 | #include "declarativepieseries.h" |
|
32 | #include "declarativepieseries.h" | |
33 | #include <QHPieModelMapper> |
|
33 | #include <QHPieModelMapper> | |
34 | #include <QVPieModelMapper> |
|
34 | #include <QVPieModelMapper> | |
35 | #include <QXYModelMapper> |
|
35 | #include <QXYModelMapper> | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
39 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | virtual void registerTypes(const char *uri) |
|
43 | virtual void registerTypes(const char *uri) | |
44 | { |
|
44 | { | |
45 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
45 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
46 |
|
46 | |||
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
48 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
48 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
49 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
49 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
50 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
50 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
51 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
51 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
52 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
52 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
53 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
53 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
54 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); |
|
54 | qmlRegisterType<DeclarativeGroupedBarSeries>(uri, 1, 0, "GroupedBarSeries"); | |
55 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
55 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
56 | qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice"); |
|
56 | qmlRegisterType<DeclarativePieSlice>(uri, 1, 0, "PieSlice"); | |
57 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
57 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
58 |
|
58 | |||
|
59 | ||||
|
60 | qmlRegisterUncreatableType<QScatterSeries>(uri, 1, 0, "QScatterSeries", | |||
|
61 | QLatin1String("Trying to create uncreatable: QScatterSeries.")); | |||
59 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
62 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
60 | QLatin1String("Trying to create uncreatable: QPieSeries.")); |
|
63 | QLatin1String("Trying to create uncreatable: QPieSeries.")); | |
61 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
64 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
62 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
65 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
66 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
67 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
65 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
68 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
66 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
69 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
67 |
|
70 | |||
68 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
71 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
69 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
72 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
70 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
73 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", | |
71 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
74 | QLatin1String("Trying to create uncreatable: Axis.")); | |
72 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
75 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
73 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
76 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
74 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
77 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
75 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
78 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
76 | } |
|
79 | } | |
77 | }; |
|
80 | }; | |
78 |
|
81 | |||
79 | #include "plugin.moc" |
|
82 | #include "plugin.moc" | |
80 |
|
83 | |||
81 | QTCOMMERCIALCHART_END_NAMESPACE |
|
84 | QTCOMMERCIALCHART_END_NAMESPACE | |
82 |
|
85 | |||
83 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
86 | QTCOMMERCIALCHART_USE_NAMESPACE | |
84 |
|
87 | |||
85 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
88 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
@@ -1,121 +1,123 | |||||
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 | #include "qlineseries.h" |
|
21 | #include "qlineseries.h" | |
22 | #include "qlineseries_p.h" |
|
22 | #include "qlineseries_p.h" | |
23 | #include "linechartitem_p.h" |
|
23 | #include "linechartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 | \class QLineSeries |
|
31 | \class QLineSeries | |
32 | \brief The QLineSeries class is used for making line charts. |
|
32 | \brief The QLineSeries class is used for making line charts. | |
33 |
|
33 | |||
34 | \mainclass |
|
34 | \mainclass | |
35 |
|
35 | |||
36 | A line chart is used to show information as a series of data points |
|
36 | A line chart is used to show information as a series of data points | |
37 | connected by straight lines. |
|
37 | connected by straight lines. | |
38 |
|
38 | |||
39 | \image examples_linechart.png |
|
39 | \image examples_linechart.png | |
40 |
|
40 | |||
41 | Creating basic line chart is simple: |
|
41 | Creating basic line chart is simple: | |
42 | \code |
|
42 | \code | |
43 | QLineSeries* series = new QLineSeries(); |
|
43 | QLineSeries* series = new QLineSeries(); | |
44 | series->append(0, 6); |
|
44 | series->append(0, 6); | |
45 | series->append(2, 4); |
|
45 | series->append(2, 4); | |
46 | ... |
|
46 | ... | |
47 | chart->addSeries(series); |
|
47 | chart->addSeries(series); | |
48 | \endcode |
|
48 | \endcode | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn virtual SeriesType QLineSeries::type() const |
|
52 | \fn virtual SeriesType QLineSeries::type() const | |
53 | \brief Returns type of series. |
|
53 | \brief Returns type of series. | |
54 | \sa QAbstractSeries, SeriesType |
|
54 | \sa QAbstractSeries, SeriesType | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | Constructs empty series object which is a child of \a parent. |
|
58 | Constructs empty series object which is a child of \a parent. | |
59 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
59 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
60 | */ |
|
60 | */ | |
61 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent) |
|
61 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent) | |
62 | { |
|
62 | { | |
63 |
|
63 | |||
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | \internal |
|
67 | \internal | |
68 | */ |
|
68 | */ | |
69 | QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent) |
|
69 | QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent) | |
70 | { |
|
70 | { | |
71 |
|
71 | |||
72 | } |
|
72 | } | |
73 | /*! |
|
73 | /*! | |
74 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
74 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
75 | and are deleted when mentioned object are destroyed. |
|
75 | and are deleted when mentioned object are destroyed. | |
76 | */ |
|
76 | */ | |
77 | QLineSeries::~QLineSeries() |
|
77 | QLineSeries::~QLineSeries() | |
78 | { |
|
78 | { | |
79 | Q_D(QLineSeries); |
|
79 | Q_D(QLineSeries); | |
80 | if(d->m_dataset){ |
|
80 | if(d->m_dataset){ | |
81 | d->m_dataset->removeSeries(this); |
|
81 | d->m_dataset->removeSeries(this); | |
82 | } |
|
82 | } | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | QAbstractSeries::SeriesType QLineSeries::type() const |
|
85 | QAbstractSeries::SeriesType QLineSeries::type() const | |
86 | { |
|
86 | { | |
87 | return QAbstractSeries::SeriesTypeLine; |
|
87 | return QAbstractSeries::SeriesTypeLine; | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | /* |
|
90 | /* | |
91 | QDebug operator<< (QDebug debug, const QLineSeries series) |
|
91 | QDebug operator<< (QDebug debug, const QLineSeries series) | |
92 | { |
|
92 | { | |
93 | Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size()); |
|
93 | Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size()); | |
94 | int size = series.d_func()->m_x.size(); |
|
94 | int size = series.d_func()->m_x.size(); | |
95 | for (int i=0; i<size; i++) { |
|
95 | for (int i=0; i<size; i++) { | |
96 | debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") "; |
|
96 | debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") "; | |
97 | } |
|
97 | } | |
98 | return debug.space(); |
|
98 | return debug.space(); | |
99 | } |
|
99 | } | |
100 | */ |
|
100 | */ | |
101 |
|
101 | |||
102 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
102 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
103 |
|
103 | |||
104 | QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q) |
|
104 | QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q) | |
105 | { |
|
105 | { | |
106 |
|
106 | |||
107 | }; |
|
107 | }; | |
108 |
|
108 | |||
109 | Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
109 | Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
110 | { |
|
110 | { | |
111 | Q_Q(QLineSeries); |
|
111 | Q_Q(QLineSeries); | |
112 | LineChartItem* line = new LineChartItem(q,presenter); |
|
112 | LineChartItem* line = new LineChartItem(q,presenter); | |
113 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
113 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
114 | line->setAnimator(presenter->animator()); |
|
114 | line->setAnimator(presenter->animator()); | |
115 | line->setAnimation(new XYAnimation(line)); |
|
115 | line->setAnimation(new XYAnimation(line)); | |
116 | } |
|
116 | } | |
117 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
117 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
118 | return line; |
|
118 | return line; | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
|
121 | #include "moc_qlineseries.cpp" | |||
|
122 | ||||
121 | QTCOMMERCIALCHART_END_NAMESPACE |
|
123 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,52 +1,52 | |||||
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 QLINESERIES_H |
|
21 | #ifndef QLINESERIES_H | |
22 | #define QLINESERIES_H |
|
22 | #define QLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | class QLineSeriesPrivate; |
|
30 | class QLineSeriesPrivate; | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries |
|
32 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries | |
33 | { |
|
33 | { | |
|
34 | Q_OBJECT | |||
|
35 | ||||
34 | public: |
|
36 | public: | |
35 | explicit QLineSeries(QObject *parent = 0); |
|
37 | explicit QLineSeries(QObject *parent = 0); | |
36 | ~QLineSeries(); |
|
38 | ~QLineSeries(); | |
37 |
|
||||
38 | QAbstractSeries::SeriesType type() const; |
|
39 | QAbstractSeries::SeriesType type() const; | |
39 |
|
40 | |||
40 | protected: |
|
41 | protected: | |
41 | QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0); |
|
42 | QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0); | |
42 |
|
43 | |||
43 | private: |
|
44 | private: | |
44 | Q_DECLARE_PRIVATE(QLineSeries) |
|
45 | Q_DECLARE_PRIVATE(QLineSeries) | |
45 | Q_DISABLE_COPY(QLineSeries) |
|
46 | Q_DISABLE_COPY(QLineSeries) | |
46 | friend class LineChartItem; |
|
47 | friend class LineChartItem; | |
47 |
|
||||
48 | }; |
|
48 | }; | |
49 |
|
49 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
50 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
51 | |||
52 | #endif |
|
52 | #endif |
@@ -1,155 +1,156 | |||||
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 | #include "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QScatterSeries |
|
29 | \class QScatterSeries | |
30 | \brief The QScatterSeries class is used for making scatter charts. |
|
30 | \brief The QScatterSeries class is used for making scatter charts. | |
31 |
|
31 | |||
32 | \mainclass |
|
32 | \mainclass | |
33 |
|
33 | |||
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
35 | and the vertical axis. |
|
35 | and the vertical axis. | |
36 |
|
36 | |||
37 | \image examples_scatterchart.png |
|
37 | \image examples_scatterchart.png | |
38 |
|
38 | |||
39 | Creating basic scatter chart is simple: |
|
39 | Creating basic scatter chart is simple: | |
40 | \code |
|
40 | \code | |
41 | QScatterSeries* series = new QScatterSeries(); |
|
41 | QScatterSeries* series = new QScatterSeries(); | |
42 | series->append(0, 6); |
|
42 | series->append(0, 6); | |
43 | series->append(2, 4); |
|
43 | series->append(2, 4); | |
44 | ... |
|
44 | ... | |
45 | chart->addSeries(series); |
|
45 | chart->addSeries(series); | |
46 | \endcode |
|
46 | \endcode | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \enum QScatterSeries::MarkerShape |
|
50 | \enum QScatterSeries::MarkerShape | |
51 |
|
51 | |||
52 | This enum describes the shape used when rendering marker items. |
|
52 | This enum describes the shape used when rendering marker items. | |
53 |
|
53 | |||
54 | \value MarkerShapeCircle |
|
54 | \value MarkerShapeCircle | |
55 | \value MarkerShapeRectangle |
|
55 | \value MarkerShapeRectangle | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn QChartSeriesType QScatterSeries::type() const |
|
59 | \fn QChartSeriesType QScatterSeries::type() const | |
60 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
60 | \brief Returns QChartSeries::SeriesTypeScatter. | |
61 | \sa QAbstractSeries, SeriesType |
|
61 | \sa QAbstractSeries, SeriesType | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | Constructs a series object which is a child of \a parent. |
|
67 | Constructs a series object which is a child of \a parent. | |
68 | */ |
|
68 | */ | |
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
70 | { |
|
70 | { | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
75 | */ |
|
75 | */ | |
76 | QScatterSeries::~QScatterSeries() |
|
76 | QScatterSeries::~QScatterSeries() | |
77 | { |
|
77 | { | |
78 | Q_D(QScatterSeries); |
|
78 | Q_D(QScatterSeries); | |
79 | if(d->m_dataset) { |
|
79 | if(d->m_dataset) { | |
80 | d->m_dataset->removeSeries(this); |
|
80 | d->m_dataset->removeSeries(this); | |
81 | } |
|
81 | } | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
84 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
85 | { |
|
85 | { | |
86 | return QAbstractSeries::SeriesTypeScatter; |
|
86 | return QAbstractSeries::SeriesTypeScatter; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | Returns the shape used for drawing markers. |
|
90 | Returns the shape used for drawing markers. | |
91 | */ |
|
91 | */ | |
92 |
QScatterSeries::MarkerShape QScatterSeries:: |
|
92 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const | |
93 | { |
|
93 | { | |
94 | Q_D(const QScatterSeries); |
|
94 | Q_D(const QScatterSeries); | |
95 | return d->m_shape; |
|
95 | return d->m_shape; | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
99 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
100 | is defined by chart theme setting. |
|
100 | is defined by chart theme setting. | |
101 | */ |
|
101 | */ | |
102 | void QScatterSeries::setShape(MarkerShape shape) |
|
102 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
103 | { |
|
103 | { | |
104 | Q_D(QScatterSeries); |
|
104 | Q_D(QScatterSeries); | |
105 | if (d->m_shape != shape) { |
|
105 | if (d->m_shape != shape) { | |
106 | d->m_shape = shape; |
|
106 | d->m_shape = shape; | |
107 | emit d->updated(); |
|
107 | emit d->updated(); | |
108 | } |
|
108 | } | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | Returns the size of the marker items. |
|
112 | Returns the size of the marker items. | |
113 | */ |
|
113 | */ | |
114 |
qreal QScatterSeries:: |
|
114 | qreal QScatterSeries::markerSize() const | |
115 | { |
|
115 | { | |
116 | Q_D(const QScatterSeries); |
|
116 | Q_D(const QScatterSeries); | |
117 | return d->m_size; |
|
117 | return d->m_size; | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Set the \a size of the marker items. The default size is 15. |
|
121 | Set the \a size of the marker items. The default size is 15. | |
122 | */ |
|
122 | */ | |
123 | void QScatterSeries::setSize(qreal size) |
|
123 | void QScatterSeries::setMarkerSize(qreal size) | |
124 | { |
|
124 | { | |
125 | Q_D(QScatterSeries); |
|
125 | Q_D(QScatterSeries); | |
126 |
|
126 | |||
127 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
127 | if (!qFuzzyIsNull(d->m_size - size)) { | |
128 | d->m_size = size; |
|
128 | d->m_size = size; | |
129 | emit d->updated(); |
|
129 | emit d->updated(); | |
130 | } |
|
130 | } | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
134 |
|
134 | |||
135 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
135 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), | |
136 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
136 | m_shape(QScatterSeries::MarkerShapeCircle), | |
137 | m_size(15.0) |
|
137 | m_size(15.0) | |
138 | { |
|
138 | { | |
139 |
|
139 | |||
140 | }; |
|
140 | }; | |
141 |
|
141 | |||
142 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
142 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
143 | { |
|
143 | { | |
144 | Q_Q(QScatterSeries); |
|
144 | Q_Q(QScatterSeries); | |
145 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
145 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
146 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
146 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
147 | scatter->setAnimator(presenter->animator()); |
|
147 | scatter->setAnimator(presenter->animator()); | |
148 | scatter->setAnimation(new XYAnimation(scatter)); |
|
148 | scatter->setAnimation(new XYAnimation(scatter)); | |
149 | } |
|
149 | } | |
150 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
150 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
151 | return scatter; |
|
151 | return scatter; | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
|
154 | #include "moc_qscatterseries.cpp" | |||
154 |
|
155 | |||
155 | QTCOMMERCIALCHART_END_NAMESPACE |
|
156 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,60 +1,62 | |||||
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 QSCATTERSERIES_H |
|
21 | #ifndef QSCATTERSERIES_H | |
22 | #define QSCATTERSERIES_H |
|
22 | #define QSCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QScatterSeriesPrivate; |
|
29 | class QScatterSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries | |
32 | { |
|
32 | { | |
|
33 | Q_OBJECT | |||
|
34 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape) | |||
|
35 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize) | |||
|
36 | Q_ENUMS(MarkerShape) | |||
33 |
|
37 | |||
34 | public: |
|
38 | public: | |
35 | enum MarkerShape { |
|
39 | enum MarkerShape { | |
36 | MarkerShapeCircle, |
|
40 | MarkerShapeCircle, | |
37 | MarkerShapeRectangle |
|
41 | MarkerShapeRectangle | |
38 | }; |
|
42 | }; | |
39 |
|
43 | |||
40 | public: |
|
44 | public: | |
41 | explicit QScatterSeries(QObject *parent = 0); |
|
45 | explicit QScatterSeries(QObject *parent = 0); | |
42 | ~QScatterSeries(); |
|
46 | ~QScatterSeries(); | |
43 |
|
||||
44 | QAbstractSeries::SeriesType type() const; |
|
47 | QAbstractSeries::SeriesType type() const; | |
45 |
|
48 | MarkerShape markerShape() const; | ||
46 |
MarkerShape shape |
|
49 | void setMarkerShape(MarkerShape shape); | |
47 | void setShape(MarkerShape shape); |
|
50 | qreal markerSize() const; | |
48 | qreal size() const; |
|
51 | void setMarkerSize(qreal size); | |
49 | void setSize(qreal size); |
|
|||
50 |
|
52 | |||
51 | private: |
|
53 | private: | |
52 | Q_DECLARE_PRIVATE(QScatterSeries) |
|
54 | Q_DECLARE_PRIVATE(QScatterSeries) | |
53 | Q_DISABLE_COPY(QScatterSeries) |
|
55 | Q_DISABLE_COPY(QScatterSeries) | |
54 | friend class ScatterChartItem; |
|
56 | friend class ScatterChartItem; | |
55 |
|
57 | |||
56 | }; |
|
58 | }; | |
57 |
|
59 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
60 | QTCOMMERCIALCHART_END_NAMESPACE | |
59 |
|
61 | |||
60 | #endif // QSCATTERSERIES_H |
|
62 | #endif // QSCATTERSERIES_H |
@@ -1,198 +1,199 | |||||
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 | #include "scatterchartitem_p.h" |
|
21 | #include "scatterchartitem_p.h" | |
22 | #include "qscatterseries.h" |
|
22 | #include "qscatterseries.h" | |
23 | #include "qscatterseries_p.h" |
|
23 | #include "qscatterseries_p.h" | |
24 | #include "chartpresenter_p.h" |
|
24 | #include "chartpresenter_p.h" | |
25 | #include <QPainter> |
|
25 | #include <QPainter> | |
26 | #include <QGraphicsScene> |
|
26 | #include <QGraphicsScene> | |
27 | #include <QDebug> |
|
27 | #include <QDebug> | |
28 | #include <QGraphicsSceneMouseEvent> |
|
28 | #include <QGraphicsSceneMouseEvent> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) : |
|
32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) : | |
33 | XYChart(series,presenter), |
|
33 | XYChart(series,presenter), | |
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
35 | m_series(series), |
|
35 | m_series(series), | |
36 | m_items(this), |
|
36 | m_items(this), | |
37 | m_shape(QScatterSeries::MarkerShapeRectangle), |
|
37 | m_shape(QScatterSeries::MarkerShapeRectangle), | |
38 | m_size(15) |
|
38 | m_size(15) | |
39 | { |
|
39 | { | |
40 | QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
40 | QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated())); | |
41 |
|
41 | |||
42 | setZValue(ChartPresenter::ScatterSeriesZValue); |
|
42 | setZValue(ChartPresenter::ScatterSeriesZValue); | |
43 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
43 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
44 |
|
44 | |||
45 | handleUpdated(); |
|
45 | handleUpdated(); | |
46 |
|
46 | |||
47 | m_items.setHandlesChildEvents(false); |
|
47 | m_items.setHandlesChildEvents(false); | |
48 |
|
48 | |||
49 | // TODO: how to draw a drop shadow? |
|
49 | // TODO: how to draw a drop shadow? | |
50 | // QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect(); |
|
50 | // QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect(); | |
51 | // dropShadow->setOffset(2.0); |
|
51 | // dropShadow->setOffset(2.0); | |
52 | // dropShadow->setBlurRadius(2.0); |
|
52 | // dropShadow->setBlurRadius(2.0); | |
53 | // setGraphicsEffect(dropShadow); |
|
53 | // setGraphicsEffect(dropShadow); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | QRectF ScatterChartItem::boundingRect() const |
|
56 | QRectF ScatterChartItem::boundingRect() const | |
57 | { |
|
57 | { | |
58 | return m_rect; |
|
58 | return m_rect; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void ScatterChartItem::createPoints(int count) |
|
61 | void ScatterChartItem::createPoints(int count) | |
62 | { |
|
62 | { | |
63 | for (int i = 0; i < count; ++i) { |
|
63 | for (int i = 0; i < count; ++i) { | |
64 |
|
64 | |||
65 | QGraphicsItem *item = 0; |
|
65 | QGraphicsItem *item = 0; | |
66 |
|
66 | |||
67 | switch (m_shape) { |
|
67 | switch (m_shape) { | |
68 | case QScatterSeries::MarkerShapeCircle: { |
|
68 | case QScatterSeries::MarkerShapeCircle: { | |
69 | QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size); |
|
69 | QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size); | |
70 | const QRectF& rect = i->boundingRect(); |
|
70 | const QRectF& rect = i->boundingRect(); | |
71 | i->setPos(-rect.width()/2,-rect.height()/2); |
|
71 | i->setPos(-rect.width()/2,-rect.height()/2); | |
72 | item = new Marker(i,this); |
|
72 | item = new Marker(i,this); | |
73 | break; |
|
73 | break; | |
74 | } |
|
74 | } | |
75 | case QScatterSeries::MarkerShapeRectangle: { |
|
75 | case QScatterSeries::MarkerShapeRectangle: { | |
76 | QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size); |
|
76 | QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size); | |
77 | i->setPos(-m_size/2,-m_size/2); |
|
77 | i->setPos(-m_size/2,-m_size/2); | |
78 | item = new Marker(i,this); |
|
78 | item = new Marker(i,this); | |
79 | break; |
|
79 | break; | |
80 | } |
|
80 | } | |
81 | default: |
|
81 | default: | |
82 | qWarning()<<"Unsupported marker type"; |
|
82 | qWarning()<<"Unsupported marker type"; | |
83 | break; |
|
83 | break; | |
84 |
|
84 | |||
85 | } |
|
85 | } | |
86 | m_items.addToGroup(item); |
|
86 | m_items.addToGroup(item); | |
87 | } |
|
87 | } | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void ScatterChartItem::deletePoints(int count) |
|
90 | void ScatterChartItem::deletePoints(int count) | |
91 | { |
|
91 | { | |
92 | QList<QGraphicsItem *> items = m_items.childItems(); |
|
92 | QList<QGraphicsItem *> items = m_items.childItems(); | |
93 |
|
93 | |||
94 | for (int i = 0; i < count; ++i) { |
|
94 | for (int i = 0; i < count; ++i) { | |
95 | delete(items.takeLast()); |
|
95 | delete(items.takeLast()); | |
96 | } |
|
96 | } | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | void ScatterChartItem::markerSelected(Marker *marker) |
|
99 | void ScatterChartItem::markerSelected(Marker *marker) | |
100 | { |
|
100 | { | |
101 | emit XYChart::clicked(marker->point()); |
|
101 | emit XYChart::clicked(marker->point()); | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void ScatterChartItem::updateGeometry() |
|
104 | void ScatterChartItem::updateGeometry() | |
105 | { |
|
105 | { | |
106 |
|
106 | |||
107 | const QVector<QPointF>& points = geometryPoints(); |
|
107 | const QVector<QPointF>& points = geometryPoints(); | |
108 |
|
108 | |||
109 | if(points.size()==0) |
|
109 | if(points.size()==0) | |
110 | { |
|
110 | { | |
111 | deletePoints(m_items.childItems().count()); |
|
111 | deletePoints(m_items.childItems().count()); | |
112 | return; |
|
112 | return; | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | int diff = m_items.childItems().size() - points.size(); |
|
115 | int diff = m_items.childItems().size() - points.size(); | |
116 |
|
116 | |||
117 | if(diff>0) { |
|
117 | if(diff>0) { | |
118 | deletePoints(diff); |
|
118 | deletePoints(diff); | |
119 | } |
|
119 | } | |
120 | else if(diff<0) { |
|
120 | else if(diff<0) { | |
121 | createPoints(-diff); |
|
121 | createPoints(-diff); | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | if(diff!=0) handleUpdated(); |
|
124 | if(diff!=0) handleUpdated(); | |
125 |
|
125 | |||
126 | QList<QGraphicsItem*> items = m_items.childItems(); |
|
126 | QList<QGraphicsItem*> items = m_items.childItems(); | |
127 |
|
127 | |||
128 | for (int i = 0; i < points.size(); i++) { |
|
128 | for (int i = 0; i < points.size(); i++) { | |
129 | Marker* item = static_cast<Marker*>(items.at(i)); |
|
129 | Marker* item = static_cast<Marker*>(items.at(i)); | |
130 | const QPointF& point = points.at(i); |
|
130 | const QPointF& point = points.at(i); | |
131 | const QRectF& rect = item->boundingRect(); |
|
131 | const QRectF& rect = item->boundingRect(); | |
132 | item->setPoint(point); |
|
132 | item->setPoint(point); | |
133 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); |
|
133 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); | |
134 | if(!clipRect().contains(point)) { |
|
134 | if(!clipRect().contains(point)) { | |
135 | item->setVisible(false); |
|
135 | item->setVisible(false); | |
136 | } |
|
136 | } | |
137 | else { |
|
137 | else { | |
138 | item->setVisible(true); |
|
138 | item->setVisible(true); | |
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | prepareGeometryChange(); |
|
142 | prepareGeometryChange(); | |
143 | m_rect = clipRect(); |
|
143 | m_rect = clipRect(); | |
144 | setPos(origin()); |
|
144 | setPos(origin()); | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
147 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
148 | { |
|
148 | { | |
149 | Q_UNUSED(painter) |
|
149 | Q_UNUSED(painter) | |
150 | Q_UNUSED(option) |
|
150 | Q_UNUSED(option) | |
151 | Q_UNUSED(widget) |
|
151 | Q_UNUSED(widget) | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | void ScatterChartItem::setPen(const QPen& pen) |
|
154 | void ScatterChartItem::setPen(const QPen& pen) | |
155 | { |
|
155 | { | |
156 | foreach(QGraphicsItem* item , m_items.childItems()) { |
|
156 | foreach(QGraphicsItem* item , m_items.childItems()) { | |
157 | static_cast<Marker*>(item)->setPen(pen); |
|
157 | static_cast<Marker*>(item)->setPen(pen); | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | void ScatterChartItem::setBrush(const QBrush& brush) |
|
161 | void ScatterChartItem::setBrush(const QBrush& brush) | |
162 | { |
|
162 | { | |
163 | foreach(QGraphicsItem* item , m_items.childItems()) { |
|
163 | foreach(QGraphicsItem* item , m_items.childItems()) { | |
164 | static_cast<Marker*>(item)->setBrush(brush); |
|
164 | static_cast<Marker*>(item)->setBrush(brush); | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void ScatterChartItem::handleUpdated() |
|
168 | void ScatterChartItem::handleUpdated() | |
169 | { |
|
169 | { | |
170 |
|
||||
171 | int count = m_items.childItems().count(); |
|
170 | int count = m_items.childItems().count(); | |
172 |
|
171 | |||
173 | if(count==0) return; |
|
172 | if(count==0) return; | |
174 |
|
173 | |||
175 |
bool recreate = m_size != m_series-> |
|
174 | bool recreate = m_size != m_series->markerSize() || m_shape != m_series->markerShape(); | |
176 |
|
||||
177 | //TODO: only rewrite on size change |
|
|||
178 |
|
175 | |||
179 |
m_size = m_series-> |
|
176 | m_size = m_series->markerSize(); | |
180 |
m_shape = m_series-> |
|
177 | m_shape = m_series->markerShape(); | |
181 |
|
178 | |||
182 | if(recreate) { |
|
179 | if(recreate) { | |
|
180 | // TODO: optimize handleUpdate to recreate points only in case shape changed | |||
183 | deletePoints(count); |
|
181 | deletePoints(count); | |
184 | createPoints(count); |
|
182 | createPoints(count); | |
|
183 | ||||
|
184 | // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points | |||
|
185 | updateGeometry(); | |||
185 | } |
|
186 | } | |
186 |
|
187 | |||
187 | setPen(m_series->pen()); |
|
188 | setPen(m_series->pen()); | |
188 | setBrush(m_series->brush()); |
|
189 | setBrush(m_series->brush()); | |
189 | } |
|
190 | } | |
190 |
|
191 | |||
191 | void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
192 | void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
192 | { |
|
193 | { | |
193 | emit XYChart::clicked(calculateDomainPoint(event->pos())); |
|
194 | emit XYChart::clicked(calculateDomainPoint(event->pos())); | |
194 | } |
|
195 | } | |
195 |
|
196 | |||
196 | #include "moc_scatterchartitem_p.cpp" |
|
197 | #include "moc_scatterchartitem_p.cpp" | |
197 |
|
198 | |||
198 | QTCOMMERCIALCHART_END_NAMESPACE |
|
199 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,51 +1,51 | |||||
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 QSPLINESERIES_H |
|
21 | #ifndef QSPLINESERIES_H | |
22 | #define QSPLINESERIES_H |
|
22 | #define QSPLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qlineseries.h> |
|
25 | #include <qlineseries.h> | |
26 | #include <QList> |
|
26 | #include <QList> | |
27 | #include <QPointF> |
|
27 | #include <QPointF> | |
28 | #include <QtGlobal> |
|
28 | #include <QtGlobal> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSplineSeriesPrivate; |
|
32 | class QSplineSeriesPrivate; | |
33 |
|
33 | |||
34 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries |
|
34 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | public: |
|
|||
38 |
|
37 | |||
|
38 | public: | |||
39 | explicit QSplineSeries(QObject *parent = 0); |
|
39 | explicit QSplineSeries(QObject *parent = 0); | |
40 | ~QSplineSeries(); |
|
40 | ~QSplineSeries(); | |
41 | QAbstractSeries::SeriesType type() const; |
|
41 | QAbstractSeries::SeriesType type() const; | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | Q_DECLARE_PRIVATE(QSplineSeries) |
|
44 | Q_DECLARE_PRIVATE(QSplineSeries) | |
45 | Q_DISABLE_COPY(QSplineSeries) |
|
45 | Q_DISABLE_COPY(QSplineSeries) | |
46 | friend class SplineChartItem; |
|
46 | friend class SplineChartItem; | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 | QTCOMMERCIALCHART_END_NAMESPACE |
|
49 | QTCOMMERCIALCHART_END_NAMESPACE | |
50 |
|
50 | |||
51 | #endif // QSPLINESERIES_H |
|
51 | #endif // QSPLINESERIES_H |
@@ -1,189 +1,190 | |||||
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 | #include "dataseriedialog.h" |
|
21 | #include "dataseriedialog.h" | |
22 | #include <QDialogButtonBox> |
|
22 | #include <QDialogButtonBox> | |
23 | #include <QGridLayout> |
|
23 | #include <QGridLayout> | |
24 | #include <QCheckBox> |
|
24 | #include <QCheckBox> | |
25 | #include <QPushButton> |
|
25 | #include <QPushButton> | |
26 | #include <QGroupBox> |
|
26 | #include <QGroupBox> | |
27 | #include <QRadioButton> |
|
27 | #include <QRadioButton> | |
28 | #include <QLabel> |
|
28 | #include <QLabel> | |
29 | #include <QDebug> |
|
29 | #include <QDebug> | |
30 |
|
30 | |||
31 | DataSerieDialog::DataSerieDialog(QWidget *parent) : |
|
31 | DataSerieDialog::DataSerieDialog(QWidget *parent) : | |
32 | QDialog(parent) |
|
32 | QDialog(parent) | |
33 | { |
|
33 | { | |
34 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); |
|
34 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); | |
35 | QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); |
|
35 | QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); | |
36 | connect(b, SIGNAL(clicked()), this, SLOT(accept())); |
|
36 | connect(b, SIGNAL(clicked()), this, SLOT(accept())); | |
37 | b = addSeriesBox->addButton(QDialogButtonBox::Cancel); |
|
37 | b = addSeriesBox->addButton(QDialogButtonBox::Cancel); | |
38 | connect(b, SIGNAL(clicked()), this, SLOT(reject())); |
|
38 | connect(b, SIGNAL(clicked()), this, SLOT(reject())); | |
39 |
|
39 | |||
40 | QGridLayout *grid = new QGridLayout(); |
|
40 | QGridLayout *grid = new QGridLayout(); | |
41 |
|
41 | |||
42 | m_seriesTypeSelector = seriesTypeSelector(); |
|
42 | m_seriesTypeSelector = seriesTypeSelector(); | |
43 | m_columnCountSelector = columnCountSelector(); |
|
43 | m_columnCountSelector = columnCountSelector(); | |
44 | m_rowCountSelector = rowCountSelector(); |
|
44 | m_rowCountSelector = rowCountSelector(); | |
45 | m_dataCharacteristicsSelector = dataCharacteristicsSelector(); |
|
45 | m_dataCharacteristicsSelector = dataCharacteristicsSelector(); | |
46 |
|
46 | |||
47 | grid->addWidget(m_seriesTypeSelector, 0, 0); |
|
47 | grid->addWidget(m_seriesTypeSelector, 0, 0); | |
48 | grid->addWidget(m_columnCountSelector, 0, 1); |
|
48 | grid->addWidget(m_columnCountSelector, 0, 1); | |
49 | grid->addWidget(m_rowCountSelector, 1, 1); |
|
49 | grid->addWidget(m_rowCountSelector, 1, 1); | |
50 | grid->addWidget(m_dataCharacteristicsSelector, 1, 0); |
|
50 | grid->addWidget(m_dataCharacteristicsSelector, 1, 0); | |
51 | m_labelsSelector = new QCheckBox("Labels defined"); |
|
51 | m_labelsSelector = new QCheckBox("Labels defined"); | |
52 | m_labelsSelector->setChecked(true); |
|
52 | m_labelsSelector->setChecked(true); | |
53 | grid->addWidget(m_labelsSelector, 2, 0); |
|
53 | grid->addWidget(m_labelsSelector, 2, 0); | |
54 | grid->addWidget(addSeriesBox, 3, 1); |
|
54 | grid->addWidget(addSeriesBox, 3, 1); | |
55 |
|
55 | |||
56 | setLayout(grid); |
|
56 | setLayout(grid); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QGroupBox *DataSerieDialog::seriesTypeSelector() |
|
59 | QGroupBox *DataSerieDialog::seriesTypeSelector() | |
60 | { |
|
60 | { | |
61 | QVBoxLayout *layout = new QVBoxLayout(); |
|
61 | QVBoxLayout *layout = new QVBoxLayout(); | |
62 |
|
62 | |||
63 | QRadioButton *line = new QRadioButton("Line"); |
|
63 | QRadioButton *line = new QRadioButton("Line"); | |
64 | line->setChecked(true); |
|
64 | line->setChecked(true); | |
65 | layout->addWidget(line); |
|
65 | layout->addWidget(line); | |
66 | layout->addWidget(new QRadioButton("Area")); |
|
66 | layout->addWidget(new QRadioButton("Area")); | |
67 | layout->addWidget(new QRadioButton("Pie")); |
|
67 | layout->addWidget(new QRadioButton("Pie")); | |
68 | layout->addWidget(new QRadioButton("Bar")); |
|
68 | layout->addWidget(new QRadioButton("Bar")); | |
69 | layout->addWidget(new QRadioButton("Grouped bar")); |
|
69 | layout->addWidget(new QRadioButton("Grouped bar")); | |
70 | layout->addWidget(new QRadioButton("Stacked bar")); |
|
70 | layout->addWidget(new QRadioButton("Stacked bar")); | |
71 | layout->addWidget(new QRadioButton("Percent bar")); |
|
71 | layout->addWidget(new QRadioButton("Percent bar")); | |
72 | layout->addWidget(new QRadioButton("Scatter")); |
|
72 | layout->addWidget(new QRadioButton("Scatter")); | |
73 | layout->addWidget(new QRadioButton("Spline")); |
|
73 | layout->addWidget(new QRadioButton("Spline")); | |
74 |
|
74 | |||
75 | QGroupBox *groupBox = new QGroupBox("Series type"); |
|
75 | QGroupBox *groupBox = new QGroupBox("Series type"); | |
76 | groupBox->setLayout(layout); |
|
76 | groupBox->setLayout(layout); | |
77 | selectRadio(groupBox, 0); |
|
77 | selectRadio(groupBox, 0); | |
78 |
|
78 | |||
79 | return groupBox; |
|
79 | return groupBox; | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | QGroupBox *DataSerieDialog::columnCountSelector() |
|
82 | QGroupBox *DataSerieDialog::columnCountSelector() | |
83 | { |
|
83 | { | |
84 | QVBoxLayout *layout = new QVBoxLayout(); |
|
84 | QVBoxLayout *layout = new QVBoxLayout(); | |
85 |
|
85 | |||
86 | QRadioButton *radio = new QRadioButton("1"); |
|
86 | QRadioButton *radio = new QRadioButton("1"); | |
87 | radio->setChecked(true); |
|
87 | radio->setChecked(true); | |
88 | layout->addWidget(radio); |
|
88 | layout->addWidget(radio); | |
89 | layout->addWidget(new QRadioButton("2")); |
|
89 | layout->addWidget(new QRadioButton("2")); | |
90 | layout->addWidget(new QRadioButton("3")); |
|
90 | layout->addWidget(new QRadioButton("3")); | |
91 | layout->addWidget(new QRadioButton("4")); |
|
91 | layout->addWidget(new QRadioButton("4")); | |
92 | layout->addWidget(new QRadioButton("5")); |
|
92 | layout->addWidget(new QRadioButton("5")); | |
93 | layout->addWidget(new QRadioButton("8")); |
|
93 | layout->addWidget(new QRadioButton("8")); | |
94 | layout->addWidget(new QRadioButton("10")); |
|
94 | layout->addWidget(new QRadioButton("10")); | |
95 | layout->addWidget(new QRadioButton("100")); |
|
95 | layout->addWidget(new QRadioButton("100")); | |
96 |
|
96 | |||
97 | QGroupBox *groupBox = new QGroupBox("Column count"); |
|
97 | QGroupBox *groupBox = new QGroupBox("Column count"); | |
98 | groupBox->setLayout(layout); |
|
98 | groupBox->setLayout(layout); | |
99 | selectRadio(groupBox, 0); |
|
99 | selectRadio(groupBox, 0); | |
100 |
|
100 | |||
101 | return groupBox; |
|
101 | return groupBox; | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | QGroupBox *DataSerieDialog::rowCountSelector() |
|
104 | QGroupBox *DataSerieDialog::rowCountSelector() | |
105 | { |
|
105 | { | |
106 | QVBoxLayout *layout = new QVBoxLayout(); |
|
106 | QVBoxLayout *layout = new QVBoxLayout(); | |
107 |
|
107 | |||
108 | layout->addWidget(new QRadioButton("1")); |
|
108 | layout->addWidget(new QRadioButton("1")); | |
109 | QRadioButton *radio = new QRadioButton("10"); |
|
109 | QRadioButton *radio = new QRadioButton("10"); | |
110 | radio->setChecked(true); |
|
110 | radio->setChecked(true); | |
111 | layout->addWidget(radio); |
|
111 | layout->addWidget(radio); | |
112 | layout->addWidget(new QRadioButton("50")); |
|
112 | layout->addWidget(new QRadioButton("50")); | |
113 | layout->addWidget(new QRadioButton("100")); |
|
113 | layout->addWidget(new QRadioButton("100")); | |
|
114 | layout->addWidget(new QRadioButton("1000")); | |||
114 | layout->addWidget(new QRadioButton("10000")); |
|
115 | layout->addWidget(new QRadioButton("10000")); | |
115 | layout->addWidget(new QRadioButton("100000")); |
|
116 | layout->addWidget(new QRadioButton("100000")); | |
116 | layout->addWidget(new QRadioButton("1000000")); |
|
117 | layout->addWidget(new QRadioButton("1000000")); | |
117 |
|
118 | |||
118 | QGroupBox *groupBox = new QGroupBox("Row count"); |
|
119 | QGroupBox *groupBox = new QGroupBox("Row count"); | |
119 | groupBox->setLayout(layout); |
|
120 | groupBox->setLayout(layout); | |
120 | selectRadio(groupBox, 0); |
|
121 | selectRadio(groupBox, 0); | |
121 |
|
122 | |||
122 | return groupBox; |
|
123 | return groupBox; | |
123 | } |
|
124 | } | |
124 |
|
125 | |||
125 | QGroupBox *DataSerieDialog::dataCharacteristicsSelector() |
|
126 | QGroupBox *DataSerieDialog::dataCharacteristicsSelector() | |
126 | { |
|
127 | { | |
127 | QVBoxLayout *layout = new QVBoxLayout(); |
|
128 | QVBoxLayout *layout = new QVBoxLayout(); | |
128 |
|
129 | |||
129 | layout->addWidget(new QRadioButton("Linear")); |
|
130 | layout->addWidget(new QRadioButton("Linear")); | |
130 | layout->addWidget(new QRadioButton("Constant")); |
|
131 | layout->addWidget(new QRadioButton("Constant")); | |
131 | layout->addWidget(new QRadioButton("Random")); |
|
132 | layout->addWidget(new QRadioButton("Random")); | |
132 | layout->addWidget(new QRadioButton("Sin")); |
|
133 | layout->addWidget(new QRadioButton("Sin")); | |
133 | layout->addWidget(new QRadioButton("Sin + random")); |
|
134 | layout->addWidget(new QRadioButton("Sin + random")); | |
134 |
|
135 | |||
135 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); |
|
136 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); | |
136 | groupBox->setLayout(layout); |
|
137 | groupBox->setLayout(layout); | |
137 | selectRadio(groupBox, 0); |
|
138 | selectRadio(groupBox, 0); | |
138 |
|
139 | |||
139 | return groupBox; |
|
140 | return groupBox; | |
140 | } |
|
141 | } | |
141 |
|
142 | |||
142 | void DataSerieDialog::accept() |
|
143 | void DataSerieDialog::accept() | |
143 | { |
|
144 | { | |
144 | accepted(radioSelection(m_seriesTypeSelector), |
|
145 | accepted(radioSelection(m_seriesTypeSelector), | |
145 | radioSelection(m_columnCountSelector).toInt(), |
|
146 | radioSelection(m_columnCountSelector).toInt(), | |
146 | radioSelection(m_rowCountSelector).toInt(), |
|
147 | radioSelection(m_rowCountSelector).toInt(), | |
147 | radioSelection(m_dataCharacteristicsSelector), |
|
148 | radioSelection(m_dataCharacteristicsSelector), | |
148 | m_labelsSelector->isChecked()); |
|
149 | m_labelsSelector->isChecked()); | |
149 | QDialog::accept(); |
|
150 | QDialog::accept(); | |
150 | } |
|
151 | } | |
151 |
|
152 | |||
152 | void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection) |
|
153 | void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection) | |
153 | { |
|
154 | { | |
154 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); |
|
155 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); | |
155 | Q_ASSERT(layout); |
|
156 | Q_ASSERT(layout); | |
156 | Q_ASSERT(layout->count()); |
|
157 | Q_ASSERT(layout->count()); | |
157 |
|
158 | |||
158 | QLayoutItem *item = 0; |
|
159 | QLayoutItem *item = 0; | |
159 | if (defaultSelection == -1) { |
|
160 | if (defaultSelection == -1) { | |
160 | item = layout->itemAt(0); |
|
161 | item = layout->itemAt(0); | |
161 | } else if (layout->count() > defaultSelection) { |
|
162 | } else if (layout->count() > defaultSelection) { | |
162 | item = layout->itemAt(defaultSelection); |
|
163 | item = layout->itemAt(defaultSelection); | |
163 | } |
|
164 | } | |
164 | Q_ASSERT(item); |
|
165 | Q_ASSERT(item); | |
165 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); |
|
166 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); | |
166 | Q_ASSERT(radio); |
|
167 | Q_ASSERT(radio); | |
167 | radio->setChecked(true); |
|
168 | radio->setChecked(true); | |
168 | } |
|
169 | } | |
169 |
|
170 | |||
170 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) |
|
171 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) | |
171 | { |
|
172 | { | |
172 | QString selection; |
|
173 | QString selection; | |
173 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); |
|
174 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); | |
174 | Q_ASSERT(layout); |
|
175 | Q_ASSERT(layout); | |
175 |
|
176 | |||
176 | for (int i(0); i < layout->count(); i++) { |
|
177 | for (int i(0); i < layout->count(); i++) { | |
177 | QLayoutItem *item = layout->itemAt(i); |
|
178 | QLayoutItem *item = layout->itemAt(i); | |
178 | Q_ASSERT(item); |
|
179 | Q_ASSERT(item); | |
179 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); |
|
180 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); | |
180 | Q_ASSERT(radio); |
|
181 | Q_ASSERT(radio); | |
181 | if (radio->isChecked()) { |
|
182 | if (radio->isChecked()) { | |
182 | selection = radio->text(); |
|
183 | selection = radio->text(); | |
183 | break; |
|
184 | break; | |
184 | } |
|
185 | } | |
185 | } |
|
186 | } | |
186 |
|
187 | |||
187 | qDebug() << "radioSelection: " << selection; |
|
188 | qDebug() << "radioSelection: " << selection; | |
188 | return selection; |
|
189 | return selection; | |
189 | } |
|
190 | } |
General Comments 0
You need to be logged in to leave comments.
Login now