@@ -10,20 +10,20 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
10 |
|
10 | |||
11 | //TODO: optimize : remove points which are not visible |
|
11 | //TODO: optimize : remove points which are not visible | |
12 |
|
12 | |||
13 |
AreaChartItem::AreaChartItem(QAreaSeries* |
|
13 | AreaChartItem::AreaChartItem(QAreaSeries *areaSeries,ChartPresenter *presenter) : ChartItem(presenter), | |
14 | m_series(areaSeries), |
|
14 | m_series(areaSeries), | |
15 | m_upper(0), |
|
15 | m_upper(0), | |
16 | m_lower(0), |
|
16 | m_lower(0), | |
17 | m_pointsVisible(false) |
|
17 | m_pointsVisible(false) | |
18 | { |
|
18 | { | |
19 | setZValue(ChartPresenter::LineChartZValue); |
|
19 | setZValue(ChartPresenter::LineChartZValue); | |
20 | m_upper = new AreaBoundItem(this,m_series->upperSeries()); |
|
20 | m_upper = new AreaBoundItem(this,m_series->upperSeries()); | |
21 | if(m_series->lowerSeries()){ |
|
21 | if (m_series->lowerSeries()) { | |
22 | m_lower = new AreaBoundItem(this,m_series->lowerSeries()); |
|
22 | m_lower = new AreaBoundItem(this,m_series->lowerSeries()); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 |
|
|
25 | connect(areaSeries,SIGNAL(updated()),this,SLOT(handleUpdated())); | |
26 |
|
|
26 | connect(this,SIGNAL(clicked(const QPointF&)),areaSeries,SIGNAL(clicked(const QPointF&))); | |
27 |
|
27 | |||
28 | handleUpdated(); |
|
28 | handleUpdated(); | |
29 | } |
|
29 | } | |
@@ -50,10 +50,9 void AreaChartItem::updatePath() | |||||
50 |
|
50 | |||
51 | path = m_upper->shape(); |
|
51 | path = m_upper->shape(); | |
52 |
|
52 | |||
53 | if(m_lower){ |
|
53 | if (m_lower) { | |
54 | path.connectPath(m_lower->shape().toReversed()); |
|
54 | path.connectPath(m_lower->shape().toReversed()); | |
55 | } |
|
55 | } else { | |
56 | else{ |
|
|||
57 | QPointF first = path.pointAtPercent(0); |
|
56 | QPointF first = path.pointAtPercent(0); | |
58 | QPointF last = path.pointAtPercent(1); |
|
57 | QPointF last = path.pointAtPercent(1); | |
59 | path.lineTo(last.x(),m_clipRect.bottom()); |
|
58 | path.lineTo(last.x(),m_clipRect.bottom()); | |
@@ -80,17 +79,17 void AreaChartItem::handleUpdated() | |||||
80 | void AreaChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
79 | void AreaChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
81 | { |
|
80 | { | |
82 | m_upper->handleDomainChanged(minX,maxX,minY,maxY); |
|
81 | m_upper->handleDomainChanged(minX,maxX,minY,maxY); | |
83 | if(m_lower) |
|
82 | if (m_lower) | |
84 | m_lower->handleDomainChanged(minX,maxX,minY,maxY); |
|
83 | m_lower->handleDomainChanged(minX,maxX,minY,maxY); | |
85 | } |
|
84 | } | |
86 |
|
85 | |||
87 |
void AreaChartItem::handleGeometryChanged(const QRectF& |
|
86 | void AreaChartItem::handleGeometryChanged(const QRectF &rect) | |
88 | { |
|
87 | { | |
89 | m_clipRect=rect.translated(-rect.topLeft()); |
|
88 | m_clipRect=rect.translated(-rect.topLeft()); | |
90 | setPos(rect.topLeft()); |
|
89 | setPos(rect.topLeft()); | |
91 | m_upper->handleGeometryChanged(rect); |
|
90 | m_upper->handleGeometryChanged(rect); | |
92 | if(m_lower) |
|
91 | if (m_lower) | |
93 | m_lower->handleGeometryChanged(rect); |
|
92 | m_lower->handleGeometryChanged(rect); | |
94 | } |
|
93 | } | |
95 | //painter |
|
94 | //painter | |
96 |
|
95 | |||
@@ -104,15 +103,16 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt | |||||
104 | painter->setBrush(m_brush); |
|
103 | painter->setBrush(m_brush); | |
105 | painter->setClipRect(m_clipRect); |
|
104 | painter->setClipRect(m_clipRect); | |
106 | painter->drawPath(m_path); |
|
105 | painter->drawPath(m_path); | |
107 | if(m_pointsVisible){ |
|
106 | if (m_pointsVisible) { | |
108 | painter->setPen(m_pointPen); |
|
107 | painter->setPen(m_pointPen); | |
109 | painter->drawPoints(m_upper->points()); |
|
108 | painter->drawPoints(m_upper->points()); | |
110 | if(m_lower) painter->drawPoints(m_lower->points()); |
|
109 | if (m_lower) | |
|
110 | painter->drawPoints(m_lower->points()); | |||
111 | } |
|
111 | } | |
112 | painter->restore(); |
|
112 | painter->restore(); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 |
void AreaChartItem::mousePressEvent( |
|
115 | void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
116 | { |
|
116 | { | |
117 | emit clicked(m_upper->calculateDomainPoint(event->pos())); |
|
117 | emit clicked(m_upper->calculateDomainPoint(event->pos())); | |
118 | } |
|
118 | } |
@@ -14,7 +14,7 class AreaChartItem : public ChartItem | |||||
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 |
AreaChartItem(QAreaSeries* |
|
17 | AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter); | |
18 | ~ AreaChartItem(); |
|
18 | ~ AreaChartItem(); | |
19 |
|
19 | |||
20 | //from QGraphicsItem |
|
20 | //from QGraphicsItem | |
@@ -28,15 +28,15 public: | |||||
28 | void updatePath(); |
|
28 | void updatePath(); | |
29 |
|
29 | |||
30 | protected: |
|
30 | protected: | |
31 |
void mousePressEvent( |
|
31 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
32 |
|
32 | |||
33 | signals: |
|
33 | signals: | |
34 |
void clicked(const QPointF& |
|
34 | void clicked(const QPointF &point); | |
35 |
|
35 | |||
36 | public slots: |
|
36 | public slots: | |
37 | void handleUpdated(); |
|
37 | void handleUpdated(); | |
38 | void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
38 | void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
39 |
void handleGeometryChanged(const QRectF& |
|
39 | void handleGeometryChanged(const QRectF &size); | |
40 |
|
40 | |||
41 | private: |
|
41 | private: | |
42 | QAreaSeries* m_series; |
|
42 | QAreaSeries* m_series; | |
@@ -55,13 +55,13 private: | |||||
55 | class AreaBoundItem : public LineChartItem |
|
55 | class AreaBoundItem : public LineChartItem | |
56 | { |
|
56 | { | |
57 | public: |
|
57 | public: | |
58 |
AreaBoundItem(AreaChartItem* |
|
58 | AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries):LineChartItem(lineSeries,0), | |
59 | m_item(item){ |
|
59 | m_item(item){ | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | ~AreaBoundItem(){}; |
|
62 | ~AreaBoundItem(){}; | |
63 |
|
63 | |||
64 |
void setLayout(QVector<QPointF>& |
|
64 | void setLayout(QVector<QPointF> &points){ | |
65 | LineChartItem::setLayout(points); |
|
65 | LineChartItem::setLayout(points); | |
66 | m_item->updatePath(); |
|
66 | m_item->updatePath(); | |
67 | } |
|
67 | } |
@@ -97,8 +97,8 QAreaSeries::~QAreaSeries() | |||||
97 | */ |
|
97 | */ | |
98 | void QAreaSeries::setPen(const QPen& pen) |
|
98 | void QAreaSeries::setPen(const QPen& pen) | |
99 | { |
|
99 | { | |
100 | if(m_pen!=pen){ |
|
100 | if (m_pen != pen) { | |
101 | m_pen=pen; |
|
101 | m_pen = pen; | |
102 | emit updated(); |
|
102 | emit updated(); | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } | |
@@ -106,10 +106,10 void QAreaSeries::setPen(const QPen& pen) | |||||
106 | /*! |
|
106 | /*! | |
107 | Sets \a brush used for filling the area. |
|
107 | Sets \a brush used for filling the area. | |
108 | */ |
|
108 | */ | |
109 |
void QAreaSeries::setBrush(const QBrush& |
|
109 | void QAreaSeries::setBrush(const QBrush &brush) | |
110 | { |
|
110 | { | |
111 | if(m_brush!=brush){ |
|
111 | if (m_brush != brush) { | |
112 | m_brush=brush; |
|
112 | m_brush = brush; | |
113 | emit updated(); |
|
113 | emit updated(); | |
114 | } |
|
114 | } | |
115 | } |
|
115 | } | |
@@ -118,8 +118,8 void QAreaSeries::setBrush(const QBrush& brush) | |||||
118 | */ |
|
118 | */ | |
119 | void QAreaSeries::setPointsVisible(bool visible) |
|
119 | void QAreaSeries::setPointsVisible(bool visible) | |
120 | { |
|
120 | { | |
121 | if(m_pointsVisible!=visible){ |
|
121 | if (m_pointsVisible != visible) { | |
122 | m_pointsVisible=visible; |
|
122 | m_pointsVisible = visible; | |
123 | emit updated(); |
|
123 | emit updated(); | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } |
@@ -3,7 +3,6 | |||||
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qseries.h> |
|
5 | #include <qseries.h> | |
6 | #include <QDebug> |
|
|||
7 | #include <QPen> |
|
6 | #include <QPen> | |
8 | #include <QBrush> |
|
7 | #include <QBrush> | |
9 |
|
8 | |||
@@ -14,7 +13,7 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries | |||||
14 | { |
|
13 | { | |
15 | Q_OBJECT |
|
14 | Q_OBJECT | |
16 | public: |
|
15 | public: | |
17 |
QAreaSeries(QLineSeries* |
|
16 | QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries=0); | |
18 | virtual ~QAreaSeries(); |
|
17 | virtual ~QAreaSeries(); | |
19 |
|
18 | |||
20 | public: // from QChartSeries |
|
19 | public: // from QChartSeries | |
@@ -23,10 +22,10 public: // from QChartSeries | |||||
23 | QLineSeries* upperSeries() const { return m_upperSeries;} |
|
22 | QLineSeries* upperSeries() const { return m_upperSeries;} | |
24 | QLineSeries* lowerSeries() const { return m_lowerSeries;} |
|
23 | QLineSeries* lowerSeries() const { return m_lowerSeries;} | |
25 |
|
24 | |||
26 |
void setPen(const QPen& |
|
25 | void setPen(const QPen &pen); | |
27 | QPen pen() const { return m_pen;} |
|
26 | QPen pen() const { return m_pen;} | |
28 |
|
27 | |||
29 |
void setBrush(const QBrush& |
|
28 | void setBrush(const QBrush &brush); | |
30 | QBrush brush() const { return m_brush;} |
|
29 | QBrush brush() const { return m_brush;} | |
31 |
|
30 | |||
32 | void setPointsVisible(bool visible); |
|
31 | void setPointsVisible(bool visible); | |
@@ -38,7 +37,7 public: // from QChartSeries | |||||
38 |
|
37 | |||
39 | signals: |
|
38 | signals: | |
40 | void updated(); |
|
39 | void updated(); | |
41 |
void clicked(const QPointF& |
|
40 | void clicked(const QPointF &point); | |
42 |
|
41 | |||
43 | private: |
|
42 | private: | |
44 | QBrush m_brush; |
|
43 | QBrush m_brush; |
@@ -14,8 +14,8 class LineChartItem : public XYChartItem | |||||
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 |
explicit LineChartItem(QLineSeries* |
|
17 | explicit LineChartItem(QLineSeries *series,ChartPresenter *presenter); | |
18 |
~ |
|
18 | ~LineChartItem() {}; | |
19 |
|
19 | |||
20 | //from QGraphicsItem |
|
20 | //from QGraphicsItem | |
21 | QRectF boundingRect() const; |
|
21 | QRectF boundingRect() const; |
@@ -45,8 +45,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
45 | Constructs empty series object which is a child of \a parent. |
|
45 | Constructs empty series object which is a child of \a parent. | |
46 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
46 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
47 | */ |
|
47 | */ | |
48 |
QLineSeries::QLineSeries(QObject* |
|
48 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(parent), | |
49 | m_pointsVisible(false) |
|
49 | m_pointsVisible(false) | |
50 | { |
|
50 | { | |
51 |
|
51 | |||
52 | } |
|
52 | } | |
@@ -61,11 +61,11 QLineSeries::~QLineSeries() | |||||
61 | /*! |
|
61 | /*! | |
62 | Sets \a pen used for drawing line connecting points. |
|
62 | Sets \a pen used for drawing line connecting points. | |
63 | */ |
|
63 | */ | |
64 |
void QLineSeries::setLinePen(const QPen& |
|
64 | void QLineSeries::setLinePen(const QPen &pen) | |
65 | { |
|
65 | { | |
66 | if(pen!=m_pen){ |
|
66 | if (pen != m_pen){ | |
67 | m_pen=pen; |
|
67 | m_pen = pen; | |
68 | emit QXYSeries::updated(); |
|
68 | emit QXYSeries::updated(); | |
69 | } |
|
69 | } | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
@@ -74,9 +74,9 void QLineSeries::setLinePen(const QPen& pen) | |||||
74 | */ |
|
74 | */ | |
75 | void QLineSeries::setPointsVisible(bool visible) |
|
75 | void QLineSeries::setPointsVisible(bool visible) | |
76 | { |
|
76 | { | |
77 | if(m_pointsVisible!=visible){ |
|
77 | if (m_pointsVisible != visible){ | |
78 | m_pointsVisible=visible; |
|
78 | m_pointsVisible = visible; | |
79 | emit QXYSeries::updated(); |
|
79 | emit QXYSeries::updated(); | |
80 | } |
|
80 | } | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
@@ -87,8 +87,8 QDebug operator<< (QDebug debug, const QLineSeries series) | |||||
87 |
|
87 | |||
88 | int size = series.m_x.size(); |
|
88 | int size = series.m_x.size(); | |
89 |
|
89 | |||
90 | for (int i=0;i<size;i++) { |
|
90 | for (int i=0; i<size; i++) { | |
91 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; |
|
91 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; | |
92 | } |
|
92 | } | |
93 | return debug.space(); |
|
93 | return debug.space(); | |
94 | } |
|
94 | } |
@@ -3,20 +3,18 | |||||
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qxyseries.h> |
|
5 | #include <qxyseries.h> | |
6 | #include <QDebug> |
|
|||
7 | #include <QPen> |
|
6 | #include <QPen> | |
8 | #include <QBrush> |
|
|||
9 |
|
7 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
9 | |||
12 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries |
|
10 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries | |
13 | { |
|
11 | { | |
14 | public: |
|
12 | public: | |
15 |
|
|
13 | QLineSeries(QObject *parent=0); | |
16 | virtual ~QLineSeries(); |
|
14 | virtual ~QLineSeries(); | |
17 |
|
15 | |||
18 |
|
|
16 | void setLinePen(const QPen &pen); | |
19 |
|
|
17 | QPen linePen() const {return m_pen;} | |
20 |
|
18 | |||
21 | void setPointsVisible(bool visible); |
|
19 | void setPointsVisible(bool visible); | |
22 | bool pointsVisible() const {return m_pointsVisible;} |
|
20 | bool pointsVisible() const {return m_pointsVisible;} |
@@ -70,8 +70,8 QScatterSeries::MarkerShape QScatterSeries::shape() const | |||||
70 | */ |
|
70 | */ | |
71 | void QScatterSeries::setShape(MarkerShape shape) |
|
71 | void QScatterSeries::setShape(MarkerShape shape) | |
72 | { |
|
72 | { | |
73 | if(m_shape!= shape){ |
|
73 | if (m_shape != shape) { | |
74 | m_shape=shape; |
|
74 | m_shape = shape; | |
75 | emit QXYSeries::updated(); |
|
75 | emit QXYSeries::updated(); | |
76 | } |
|
76 | } | |
77 | } |
|
77 | } | |
@@ -89,8 +89,8 qreal QScatterSeries::size() const | |||||
89 | */ |
|
89 | */ | |
90 | void QScatterSeries::setSize(qreal size) |
|
90 | void QScatterSeries::setSize(qreal size) | |
91 | { |
|
91 | { | |
92 | if(m_size != size){ |
|
92 | if (m_size != size) { | |
93 | m_size=size; |
|
93 | m_size = size; | |
94 | emit updated(); |
|
94 | emit updated(); | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } |
@@ -75,7 +75,7 void ScatterChartItem::deletePoints(int count) | |||||
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 |
void ScatterChartItem::markerSelected(Marker* |
|
78 | void ScatterChartItem::markerSelected(Marker *marker) | |
79 | { |
|
79 | { | |
80 | emit XYChartItem::clicked(QPointF(m_series->x(marker->index()), m_series->y(marker->index()))); |
|
80 | emit XYChartItem::clicked(QPointF(m_series->x(marker->index()), m_series->y(marker->index()))); | |
81 | } |
|
81 | } |
@@ -22,10 +22,10 public: | |||||
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& |
|
25 | void setPen(const QPen &pen); | |
26 |
void setBrush(const QBrush& |
|
26 | void setBrush(const QBrush &brush); | |
27 |
|
27 | |||
28 |
void markerSelected(Marker* |
|
28 | void markerSelected(Marker *item); | |
29 |
|
29 | |||
30 | public slots: |
|
30 | public slots: | |
31 | void handleUpdated(); |
|
31 | void handleUpdated(); | |
@@ -35,7 +35,7 private: | |||||
35 | void deletePoints(int count); |
|
35 | void deletePoints(int count); | |
36 |
|
36 | |||
37 | protected: |
|
37 | protected: | |
38 |
void setLayout(QVector<QPointF>& |
|
38 | void setLayout(QVector<QPointF> &points); | |
39 |
|
39 | |||
40 | private: |
|
40 | private: | |
41 | QScatterSeries *m_series; |
|
41 | QScatterSeries *m_series; | |
@@ -52,7 +52,7 class Marker: public QAbstractGraphicsShapeItem | |||||
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 |
|
54 | |||
55 |
Marker(QAbstractGraphicsShapeItem* |
|
55 | Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent) | |
56 | { |
|
56 | { | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
@@ -86,12 +86,12 public: | |||||
86 | return m_item->contains(point); |
|
86 | return m_item->contains(point); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 |
void setPen(const QPen& |
|
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& |
|
94 | void setBrush(const QBrush &brush) | |
95 | { |
|
95 | { | |
96 | m_item->setBrush(brush); |
|
96 | m_item->setBrush(brush); | |
97 | } |
|
97 | } |
@@ -89,8 +89,7 void QSplineSeries::calculateControlPoints() | |||||
89 | QList<qreal> yControl = getFirstControlPoints(rhs); |
|
89 | QList<qreal> yControl = getFirstControlPoints(rhs); | |
90 |
|
90 | |||
91 | // Fill output arrays. |
|
91 | // Fill output arrays. | |
92 | for (int i = 0; i < n; ++i) |
|
92 | for (int i = 0; i < n; ++i) { | |
93 | { |
|
|||
94 | // First control point |
|
93 | // First control point | |
95 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); |
|
94 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); | |
96 | // Second control point |
|
95 | // Second control point | |
@@ -112,8 +111,8 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs) | |||||
112 | qreal b = 2.0; |
|
111 | qreal b = 2.0; | |
113 | x.append(rhs[0] / b); |
|
112 | x.append(rhs[0] / b); | |
114 | tmp.append(0); |
|
113 | tmp.append(0); | |
115 |
for (int i = 1; i < rhs.size(); i++) |
|
114 | for (int i = 1; i < rhs.size(); i++) { | |
116 | { |
|
115 | // Decomposition and forward substitution. | |
117 | tmp.append(1 / b); |
|
116 | tmp.append(1 / b); | |
118 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; |
|
117 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; | |
119 | x.append((rhs[i] - x[i - 1]) / b); |
|
118 | x.append((rhs[i] - x[i - 1]) / b); | |
@@ -130,8 +129,7 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs) | |||||
130 | */ |
|
129 | */ | |
131 | void QSplineSeries::updateControlPoints() |
|
130 | void QSplineSeries::updateControlPoints() | |
132 | { |
|
131 | { | |
133 | if(count() > 1) |
|
132 | if (count() > 1) { | |
134 | { |
|
|||
135 | m_controlPoints.clear(); |
|
133 | m_controlPoints.clear(); | |
136 | calculateControlPoints(); |
|
134 | calculateControlPoints(); | |
137 | } |
|
135 | } |
@@ -2,10 +2,10 | |||||
2 | #define QSPLINESERIES_H |
|
2 | #define QSPLINESERIES_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <QtGlobal> |
|
|||
6 | #include <qlineseries.h> |
|
5 | #include <qlineseries.h> | |
7 | #include <QList> |
|
6 | #include <QList> | |
8 | #include <QPointF> |
|
7 | #include <QPointF> | |
|
8 | #include <QtGlobal> | |||
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
@@ -19,7 +19,7 public: | |||||
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* |
|
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); |
@@ -5,10 +5,10 | |||||
5 |
|
5 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
7 | |||
8 |
SplineChartItem::SplineChartItem(QSplineSeries* |
|
8 | SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presenter) : | |
9 | XYChartItem(series, presenter), |
|
9 | XYChartItem(series, presenter), | |
10 | m_series(series), |
|
10 | m_series(series), | |
11 | m_pointsVisible(false) |
|
11 | m_pointsVisible(false) | |
12 | { |
|
12 | { | |
13 | setZValue(ChartPresenter::LineChartZValue); |
|
13 | setZValue(ChartPresenter::LineChartZValue); | |
14 | QObject::connect(series,SIGNAL(updated()),this,SLOT(handleUpdated())); |
|
14 | QObject::connect(series,SIGNAL(updated()),this,SLOT(handleUpdated())); | |
@@ -25,26 +25,25 QPainterPath SplineChartItem::shape() const | |||||
25 | return m_path; |
|
25 | return m_path; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 |
void SplineChartItem::updateLayout(QVector<QPointF>& |
|
28 | void SplineChartItem::updateLayout(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index) | |
29 | { |
|
29 | { | |
30 | QVector<QPointF> controlPoints; |
|
30 | QVector<QPointF> controlPoints; | |
31 |
|
31 | |||
32 | controlPoints.resize(newPoints.count()*2-2); |
|
32 | controlPoints.resize(newPoints.count()*2-2); | |
33 |
|
33 | |||
34 | for (int i = 0; i < newPoints.size() - 1; i++) |
|
34 | for (int i = 0; i < newPoints.size() - 1; i++) { | |
35 | { |
|
|||
36 | controlPoints[2*i] = calculateGeometryControlPoint(2 * i); |
|
35 | controlPoints[2*i] = calculateGeometryControlPoint(2 * i); | |
37 | controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1); |
|
36 | controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1); | |
38 | } |
|
37 | } | |
39 |
|
38 | |||
40 | if(controlPoints.count()<2) { |
|
39 | if (controlPoints.count()<2) { | |
41 | setLayout(newPoints,controlPoints); |
|
40 | setLayout(newPoints,controlPoints); | |
42 | return; |
|
41 | return; | |
43 | } |
|
42 | } | |
44 |
|
43 | |||
45 | if(animator()){ |
|
44 | if (animator()) { | |
46 | animator()->updateLayout(this,oldPoints,newPoints,m_controlPoints,controlPoints,index); |
|
45 | animator()->updateLayout(this,oldPoints,newPoints,m_controlPoints,controlPoints,index); | |
47 | }else{ |
|
46 | } else { | |
48 | setLayout(newPoints,controlPoints); |
|
47 | setLayout(newPoints,controlPoints); | |
49 | } |
|
48 | } | |
50 | } |
|
49 | } | |
@@ -54,10 +53,9 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const | |||||
54 | return XYChartItem::calculateGeometryPoint(m_series->controlPoint(index)); |
|
53 | return XYChartItem::calculateGeometryPoint(m_series->controlPoint(index)); | |
55 | } |
|
54 | } | |
56 |
|
55 | |||
57 |
void SplineChartItem::setLayout(QVector<QPointF>& |
|
56 | void SplineChartItem::setLayout(QVector<QPointF> &points, QVector<QPointF> &controlPoints) | |
58 | { |
|
57 | { | |
59 | if(points.size()<2 || controlPoints.size()<2) |
|
58 | if ((points.size()<2) || (controlPoints.size()<2)) { | |
60 | { |
|
|||
61 | XYChartItem::setLayout(points); |
|
59 | XYChartItem::setLayout(points); | |
62 | m_controlPoints=controlPoints; |
|
60 | m_controlPoints=controlPoints; | |
63 | return; |
|
61 | return; | |
@@ -67,8 +65,7 void SplineChartItem::setLayout(QVector<QPointF>& points,QVector<QPointF>& contr | |||||
67 |
|
65 | |||
68 | QPainterPath splinePath(points.at(0)); |
|
66 | QPainterPath splinePath(points.at(0)); | |
69 |
|
67 | |||
70 | for (int i = 0; i < points.size() - 1; i++) |
|
68 | for (int i = 0; i < points.size() - 1; i++) { | |
71 | { |
|
|||
72 | const QPointF& point = points.at(i + 1); |
|
69 | const QPointF& point = points.at(i + 1); | |
73 | splinePath.cubicTo(controlPoints[2*i],controlPoints[2 * i + 1],point); |
|
70 | splinePath.cubicTo(controlPoints[2*i],controlPoints[2 * i + 1],point); | |
74 | } |
|
71 | } | |
@@ -102,9 +99,9 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||||
102 | painter->setClipRect(clipRect()); |
|
99 | painter->setClipRect(clipRect()); | |
103 | painter->setPen(m_linePen); |
|
100 | painter->setPen(m_linePen); | |
104 | painter->drawPath(m_path); |
|
101 | painter->drawPath(m_path); | |
105 | if(m_pointsVisible){ |
|
102 | if (m_pointsVisible) { | |
106 |
|
|
103 | painter->setPen(m_pointPen); | |
107 |
|
|
104 | painter->drawPoints(points()); | |
108 | } |
|
105 | } | |
109 | painter->restore(); |
|
106 | painter->restore(); | |
110 | } |
|
107 | } |
@@ -3,8 +3,6 | |||||
3 |
|
3 | |||
4 | #include "qsplineseries.h" |
|
4 | #include "qsplineseries.h" | |
5 | #include "xychartitem_p.h" |
|
5 | #include "xychartitem_p.h" | |
6 | #include <QGraphicsItem> |
|
|||
7 |
|
||||
8 |
|
6 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
8 | |||
@@ -12,7 +10,7 class SplineChartItem : public XYChartItem | |||||
12 | { |
|
10 | { | |
13 | Q_OBJECT |
|
11 | Q_OBJECT | |
14 | public: |
|
12 | public: | |
15 |
SplineChartItem(QSplineSeries* |
|
13 | SplineChartItem(QSplineSeries *series, ChartPresenter *presenter); | |
16 |
|
14 | |||
17 | //from QGraphicsItem |
|
15 | //from QGraphicsItem | |
18 | QRectF boundingRect() const; |
|
16 | QRectF boundingRect() const; | |
@@ -23,8 +21,8 public slots: | |||||
23 | void handleUpdated(); |
|
21 | void handleUpdated(); | |
24 |
|
22 | |||
25 | protected: |
|
23 | protected: | |
26 |
void setLayout(QVector<QPointF>& |
|
24 | void setLayout(QVector<QPointF> &points,QVector<QPointF> &controlPoints); | |
27 |
void updateLayout(QVector<QPointF>& |
|
25 | void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index); | |
28 |
|
26 | |||
29 | private: |
|
27 | private: | |
30 | QPointF calculateGeometryControlPoint(int index) const; |
|
28 | QPointF calculateGeometryControlPoint(int index) const; |
@@ -48,7 +48,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
48 | Constructs empty series object which is a child of \a parent. |
|
48 | Constructs empty series object which is a child of \a parent. | |
49 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
49 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
50 | */ |
|
50 | */ | |
51 |
QXYSeries::QXYSeries(QObject* |
|
51 | QXYSeries::QXYSeries(QObject *parent):QSeries(parent) | |
52 | { |
|
52 | { | |
53 | m_mapX = -1; |
|
53 | m_mapX = -1; | |
54 | m_mapY = -1; |
|
54 | m_mapY = -1; | |
@@ -81,7 +81,7 void QXYSeries::add(qreal x,qreal y) | |||||
81 | This is an overloaded function. |
|
81 | This is an overloaded function. | |
82 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
82 | Adds data \a point to the series. Points are connected with lines on the chart. | |
83 | */ |
|
83 | */ | |
84 |
void QXYSeries::add(const QPointF& |
|
84 | void QXYSeries::add(const QPointF &point) | |
85 | { |
|
85 | { | |
86 | add(point.x(),point.y()); |
|
86 | add(point.x(),point.y()); | |
87 | } |
|
87 | } | |
@@ -103,8 +103,8 void QXYSeries::add(const QList<QPointF> points) | |||||
103 | void QXYSeries::replace(qreal x,qreal y) |
|
103 | void QXYSeries::replace(qreal x,qreal y) | |
104 | { |
|
104 | { | |
105 | int index = m_x.indexOf(x); |
|
105 | int index = m_x.indexOf(x); | |
106 | m_x[index]=x; |
|
106 | m_x[index] = x; | |
107 | m_y[index]=y; |
|
107 | m_y[index] = y; | |
108 | emit pointReplaced(index); |
|
108 | emit pointReplaced(index); | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
@@ -112,7 +112,7 void QXYSeries::replace(qreal x,qreal y) | |||||
112 | This is an overloaded function. |
|
112 | This is an overloaded function. | |
113 | Replaces current y value of for given \a point x value with \a point y value. |
|
113 | Replaces current y value of for given \a point x value with \a point y value. | |
114 | */ |
|
114 | */ | |
115 |
void QXYSeries::replace(const QPointF& |
|
115 | void QXYSeries::replace(const QPointF &point) | |
116 | { |
|
116 | { | |
117 | replace(point.x(),point.y()); |
|
117 | replace(point.x(),point.y()); | |
118 | } |
|
118 | } | |
@@ -124,7 +124,7 void QXYSeries::remove(qreal x) | |||||
124 | { |
|
124 | { | |
125 | int index = m_x.indexOf(x); |
|
125 | int index = m_x.indexOf(x); | |
126 |
|
126 | |||
127 | if(index==-1) return; |
|
127 | if (index == -1) return; | |
128 |
|
128 | |||
129 | m_x.remove(index); |
|
129 | m_x.remove(index); | |
130 | m_y.remove(index); |
|
130 | m_y.remove(index); | |
@@ -138,11 +138,11 void QXYSeries::remove(qreal x) | |||||
138 | void QXYSeries::remove(qreal x,qreal y) |
|
138 | void QXYSeries::remove(qreal x,qreal y) | |
139 | { |
|
139 | { | |
140 | int index =-1; |
|
140 | int index =-1; | |
141 | do{ |
|
141 | do { | |
142 | index = m_x.indexOf(x,index+1); |
|
142 | index = m_x.indexOf(x,index+1); | |
143 | }while(index !=-1 && m_y.at(index)!=y); |
|
143 | } while (index !=-1 && m_y.at(index)!=y); | |
144 |
|
144 | |||
145 | if(index==-1) return; |
|
145 | if (index==-1) return; | |
146 |
|
146 | |||
147 | m_x.remove(index); |
|
147 | m_x.remove(index); | |
148 | m_y.remove(index); |
|
148 | m_y.remove(index); | |
@@ -152,7 +152,7 void QXYSeries::remove(qreal x,qreal y) | |||||
152 | /*! |
|
152 | /*! | |
153 | Removes current \a point x value. Note \a point y value is ignored. |
|
153 | Removes current \a point x value. Note \a point y value is ignored. | |
154 | */ |
|
154 | */ | |
155 |
void QXYSeries::remove(const QPointF& |
|
155 | void QXYSeries::remove(const QPointF &point) | |
156 | { |
|
156 | { | |
157 | remove(point.x(),point.y()); |
|
157 | remove(point.x(),point.y()); | |
158 | } |
|
158 | } | |
@@ -171,16 +171,17 void QXYSeries::removeAll() | |||||
171 | */ |
|
171 | */ | |
172 | qreal QXYSeries::x(int pos) const |
|
172 | qreal QXYSeries::x(int pos) const | |
173 | { |
|
173 | { | |
174 | if (m_model) |
|
174 | if (m_model) { | |
175 | if (m_mapOrientation == Qt::Vertical) |
|
175 | if (m_mapOrientation == Qt::Vertical) | |
176 | // consecutive data is read from model's column |
|
176 | // consecutive data is read from model's column | |
177 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble(); |
|
177 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble(); | |
178 | else |
|
178 | else | |
179 | // consecutive data is read from model's row |
|
179 | // consecutive data is read from model's row | |
180 | return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble(); |
|
180 | return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble(); | |
181 | else |
|
181 | } else { | |
182 | // model is not specified, return the data from series' internal data store |
|
182 | // model is not specified, return the data from series' internal data store | |
183 | return m_x.at(pos); |
|
183 | return m_x.at(pos); | |
|
184 | } | |||
184 | } |
|
185 | } | |
185 |
|
186 | |||
186 | /*! |
|
187 | /*! | |
@@ -188,16 +189,17 qreal QXYSeries::x(int pos) const | |||||
188 | */ |
|
189 | */ | |
189 | qreal QXYSeries::y(int pos) const |
|
190 | qreal QXYSeries::y(int pos) const | |
190 | { |
|
191 | { | |
191 | if (m_model) |
|
192 | if (m_model) { | |
192 | if (m_mapOrientation == Qt::Vertical) |
|
193 | if (m_mapOrientation == Qt::Vertical) | |
193 | // consecutive data is read from model's column |
|
194 | // consecutive data is read from model's column | |
194 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble(); |
|
195 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble(); | |
195 | else |
|
196 | else | |
196 | // consecutive data is read from model's row |
|
197 | // consecutive data is read from model's row | |
197 | return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble(); |
|
198 | return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble(); | |
198 | else |
|
199 | } else { | |
199 | // model is not specified, return the data from series' internal data store |
|
200 | // model is not specified, return the data from series' internal data store | |
200 | return m_y.at(pos); |
|
201 | return m_y.at(pos); | |
|
202 | } | |||
201 | } |
|
203 | } | |
202 |
|
204 | |||
203 | /*! |
|
205 | /*! | |
@@ -208,17 +210,14 int QXYSeries::count() const | |||||
208 | Q_ASSERT(m_x.size() == m_y.size()); |
|
210 | Q_ASSERT(m_x.size() == m_y.size()); | |
209 |
|
211 | |||
210 | if (m_model) { |
|
212 | if (m_model) { | |
211 | if (m_mapOrientation == Qt::Vertical) |
|
213 | if (m_mapOrientation == Qt::Vertical) { | |
212 | { |
|
|||
213 | // data is in a column. Return the number of mapped items if the model's column have enough items |
|
214 | // data is in a column. Return the number of mapped items if the model's column have enough items | |
214 | // or the number of items that can be mapped |
|
215 | // or the number of items that can be mapped | |
215 | if (m_mapLimited) |
|
216 | if (m_mapLimited) | |
216 | return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0)); |
|
217 | return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0)); | |
217 | else |
|
218 | else | |
218 | return qMax(m_model->rowCount() - m_mapFirst, 0); |
|
219 | return qMax(m_model->rowCount() - m_mapFirst, 0); | |
219 | } |
|
220 | } else { | |
220 | else |
|
|||
221 | { |
|
|||
222 | // data is in a row. Return the number of mapped items if the model's row have enough items |
|
221 | // data is in a row. Return the number of mapped items if the model's row have enough items | |
223 | // or the number of items that can be mapped |
|
222 | // or the number of items that can be mapped | |
224 | if (m_mapLimited) |
|
223 | if (m_mapLimited) | |
@@ -249,10 +248,10 QList<QPointF> QXYSeries::data() | |||||
249 | pen from chart theme is used. |
|
248 | pen from chart theme is used. | |
250 | \sa QChart::setChartTheme() |
|
249 | \sa QChart::setChartTheme() | |
251 | */ |
|
250 | */ | |
252 |
void QXYSeries::setPen(const QPen& |
|
251 | void QXYSeries::setPen(const QPen &pen) | |
253 | { |
|
252 | { | |
254 | if(pen!=m_pen){ |
|
253 | if (pen != m_pen) { | |
255 | m_pen=pen; |
|
254 | m_pen = pen; | |
256 | emit updated(); |
|
255 | emit updated(); | |
257 | } |
|
256 | } | |
258 | } |
|
257 | } | |
@@ -263,10 +262,10 void QXYSeries::setPen(const QPen& pen) | |||||
263 | \sa QChart::setChartTheme() |
|
262 | \sa QChart::setChartTheme() | |
264 | */ |
|
263 | */ | |
265 |
|
264 | |||
266 |
void QXYSeries::setBrush(const QBrush& |
|
265 | void QXYSeries::setBrush(const QBrush &brush) | |
267 | { |
|
266 | { | |
268 | if(brush!=m_brush){ |
|
267 | if (brush != m_brush) { | |
269 | m_brush=brush; |
|
268 | m_brush = brush; | |
270 | emit updated(); |
|
269 | emit updated(); | |
271 | } |
|
270 | } | |
272 | } |
|
271 | } | |
@@ -300,13 +299,10 void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |||||
300 | { |
|
299 | { | |
301 | Q_UNUSED(bottomRight) |
|
300 | Q_UNUSED(bottomRight) | |
302 |
|
301 | |||
303 | if (m_mapOrientation == Qt::Vertical) |
|
302 | if (m_mapOrientation == Qt::Vertical) { | |
304 | { |
|
|||
305 | if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount)) |
|
303 | if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount)) | |
306 | emit pointReplaced(topLeft.row() - m_mapFirst); |
|
304 | emit pointReplaced(topLeft.row() - m_mapFirst); | |
307 | } |
|
305 | } else { | |
308 | else |
|
|||
309 | { |
|
|||
310 | if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount)) |
|
306 | if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount)) | |
311 | emit pointReplaced(topLeft.column() - m_mapFirst); |
|
307 | emit pointReplaced(topLeft.column() - m_mapFirst); | |
312 | } |
|
308 | } | |
@@ -317,14 +313,12 void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) | |||||
317 | Q_UNUSED(parent) |
|
313 | Q_UNUSED(parent) | |
318 | // Q_UNUSED(end) |
|
314 | // Q_UNUSED(end) | |
319 |
|
315 | |||
320 | if (m_mapLimited) |
|
316 | if (m_mapLimited) { | |
321 | { |
|
317 | if (start >= m_mapFirst + m_mapCount) { | |
322 | if (start >= m_mapFirst + m_mapCount) |
|
|||
323 | // the added data is below mapped area |
|
318 | // the added data is below mapped area | |
324 | // therefore it has no relevance |
|
319 | // therefore it has no relevance | |
325 | return; |
|
320 | return; | |
326 | else |
|
321 | } else { | |
327 | { |
|
|||
328 | // the added data is in the mapped area or before it and update is needed |
|
322 | // the added data is in the mapped area or before it and update is needed | |
329 |
|
323 | |||
330 | // check how many mapped items there is currently (before new items are added) |
|
324 | // check how many mapped items there is currently (before new items are added) | |
@@ -332,13 +326,12 void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) | |||||
332 | // internal storage before new ones can be added |
|
326 | // internal storage before new ones can be added | |
333 |
|
327 | |||
334 | int itemsToRemove = qMin(count() - (start - m_mapFirst), end - start + 1); |
|
328 | int itemsToRemove = qMin(count() - (start - m_mapFirst), end - start + 1); | |
335 | if (m_mapCount == count()) |
|
329 | if (m_mapCount == count()) { | |
336 | for (int i = 0; i < itemsToRemove; i++) |
|
330 | for (int i = 0; i < itemsToRemove; i++) | |
337 | emit pointRemoved(count() - 1 - i); |
|
331 | emit pointRemoved(count() - 1 - i); | |
|
332 | } | |||
338 | } |
|
333 | } | |
339 | } |
|
334 | } else { | |
340 | else |
|
|||
341 | { |
|
|||
342 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) |
|
335 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) | |
343 | // nothing to do |
|
336 | // nothing to do | |
344 | // emit pointAdded(qMax(start - m_mapFirst, 0)); |
|
337 | // emit pointAdded(qMax(start - m_mapFirst, 0)); | |
@@ -350,23 +343,20 void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) | |||||
350 | Q_UNUSED(parent) |
|
343 | Q_UNUSED(parent) | |
351 | // Q_UNUSED(end) |
|
344 | // Q_UNUSED(end) | |
352 |
|
345 | |||
353 | if (m_mapLimited) |
|
346 | if (m_mapLimited) { | |
354 | { |
|
347 | if (start >= m_mapFirst + m_mapCount) { | |
355 | if (start >= m_mapFirst + m_mapCount) |
|
|||
356 | // the added data is below mapped area |
|
348 | // the added data is below mapped area | |
357 | // therefore it has no relevance |
|
349 | // therefore it has no relevance | |
358 | return; |
|
350 | return; | |
359 | else |
|
351 | } else { | |
360 | { |
|
|||
361 | // the added data is in the mapped area or before it |
|
352 | // the added data is in the mapped area or before it | |
362 | // update needed |
|
353 | // update needed | |
363 | if (count() > 0) |
|
354 | if (count() > 0) { | |
364 | for (int i = 0; i < qMin(m_mapCount - (start - m_mapFirst), end - start + 1); i++) |
|
355 | for (int i = 0; i < qMin(m_mapCount - (start - m_mapFirst), end - start + 1); i++) | |
365 | emit pointAdded(qMax(start + i - m_mapFirst, 0)); |
|
356 | emit pointAdded(qMax(start + i - m_mapFirst, 0)); | |
|
357 | } | |||
366 | } |
|
358 | } | |
367 | } |
|
359 | } else { | |
368 | else |
|
|||
369 | { |
|
|||
370 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
360 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
371 | for (int i = 0; i < end - start + 1; i++) |
|
361 | for (int i = 0; i < end - start + 1; i++) | |
372 | emit pointAdded(qMax(start + i - m_mapFirst, 0)); |
|
362 | emit pointAdded(qMax(start + i - m_mapFirst, 0)); | |
@@ -378,14 +368,12 void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end | |||||
378 | Q_UNUSED(parent) |
|
368 | Q_UNUSED(parent) | |
379 | // Q_UNUSED(end) |
|
369 | // Q_UNUSED(end) | |
380 |
|
370 | |||
381 | if (m_mapLimited) |
|
371 | if (m_mapLimited) { | |
382 | { |
|
372 | if (start >= m_mapFirst + m_mapCount) { | |
383 | if (start >= m_mapFirst + m_mapCount) |
|
|||
384 | // the removed data is below mapped area |
|
373 | // the removed data is below mapped area | |
385 | // therefore it has no relevance |
|
374 | // therefore it has no relevance | |
386 | return; |
|
375 | return; | |
387 | else |
|
376 | } else { | |
388 | { |
|
|||
389 | // the removed data is in the mapped area or before it |
|
377 | // the removed data is in the mapped area or before it | |
390 | // update needed |
|
378 | // update needed | |
391 |
|
379 | |||
@@ -397,9 +385,7 void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end | |||||
397 | for (int i = 0; i < itemsToRemove; i++) |
|
385 | for (int i = 0; i < itemsToRemove; i++) | |
398 | emit pointRemoved(qMax(start - m_mapFirst, 0)); |
|
386 | emit pointRemoved(qMax(start - m_mapFirst, 0)); | |
399 | } |
|
387 | } | |
400 | } |
|
388 | } else { | |
401 | else |
|
|||
402 | { |
|
|||
403 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
389 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
404 | for (int i = 0; i < end - start + 1; i++) |
|
390 | for (int i = 0; i < end - start + 1; i++) | |
405 | emit pointRemoved(qMax(start - m_mapFirst, 0)); |
|
391 | emit pointRemoved(qMax(start - m_mapFirst, 0)); | |
@@ -414,23 +400,18 void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) | |||||
414 | // how many items there were before data was removed |
|
400 | // how many items there were before data was removed | |
415 | // int oldCount = count() - 1; |
|
401 | // int oldCount = count() - 1; | |
416 |
|
402 | |||
417 | if (m_mapLimited) |
|
403 | if (m_mapLimited) { | |
418 | { |
|
404 | if (start >= m_mapFirst + m_mapCount) { | |
419 | if (start >= m_mapFirst + m_mapCount) |
|
|||
420 | // the removed data is below mapped area |
|
405 | // the removed data is below mapped area | |
421 | // therefore it has no relevance |
|
406 | // therefore it has no relevance | |
422 | return; |
|
407 | return; | |
423 | else |
|
408 | } else { | |
424 | { |
|
|||
425 | // if the current items count in the whole model is bigger than the index of the last item |
|
409 | // if the current items count in the whole model is bigger than the index of the last item | |
426 | // that was removed than it means there are some extra items available |
|
410 | // that was removed than it means there are some extra items available | |
427 | int extraItemsAvailable = 0; |
|
411 | int extraItemsAvailable = 0; | |
428 | if (m_mapOrientation == Qt::Vertical) |
|
412 | if (m_mapOrientation == Qt::Vertical) { | |
429 | { |
|
|||
430 | extraItemsAvailable = qMax(m_model->rowCount() - end, 0); |
|
413 | extraItemsAvailable = qMax(m_model->rowCount() - end, 0); | |
431 | } |
|
414 | } else { | |
432 | else |
|
|||
433 | { |
|
|||
434 | extraItemsAvailable = qMax(m_model->columnCount() - end, 0); |
|
415 | extraItemsAvailable = qMax(m_model->columnCount() - end, 0); | |
435 | } |
|
416 | } | |
436 |
|
417 | |||
@@ -440,18 +421,15 void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) | |||||
440 | for (int k = 0; k < toBeAdded; k++) |
|
421 | for (int k = 0; k < toBeAdded; k++) | |
441 | emit pointAdded(qMax(start - m_mapFirst, m_mapFirst) + k); |
|
422 | emit pointAdded(qMax(start - m_mapFirst, m_mapFirst) + k); | |
442 | } |
|
423 | } | |
443 | } |
|
424 | } else { | |
444 | else |
|
|||
445 | { |
|
|||
446 | // data was removed from XYSeries interal storage. Nothing more to do |
|
425 | // data was removed from XYSeries interal storage. Nothing more to do | |
447 | } |
|
426 | } | |
448 | } |
|
427 | } | |
449 |
|
428 | |||
450 |
bool QXYSeries::setModel(QAbstractItemModel* |
|
429 | bool QXYSeries::setModel(QAbstractItemModel *model) { | |
451 |
|
430 | |||
452 | // disconnect signals from old model |
|
431 | // disconnect signals from old model | |
453 | if(m_model) |
|
432 | if (m_model) { | |
454 | { |
|
|||
455 | disconnect(m_model, 0, this, 0); |
|
433 | disconnect(m_model, 0, this, 0); | |
456 | m_mapX = -1; |
|
434 | m_mapX = -1; | |
457 | m_mapY = -1; |
|
435 | m_mapY = -1; | |
@@ -462,37 +440,31 bool QXYSeries::setModel(QAbstractItemModel* model) { | |||||
462 | } |
|
440 | } | |
463 |
|
441 | |||
464 | // set new model |
|
442 | // set new model | |
465 | if(model) |
|
443 | if (model) { | |
466 | { |
|
|||
467 | m_model = model; |
|
444 | m_model = model; | |
468 | return true; |
|
445 | return true; | |
469 | } |
|
446 | } else { | |
470 | else |
|
447 | m_model = 0; | |
471 | { |
|
|||
472 | m_model = NULL; |
|
|||
473 | return false; |
|
448 | return false; | |
474 | } |
|
449 | } | |
475 | } |
|
450 | } | |
476 |
|
451 | |||
477 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
452 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
478 | { |
|
453 | { | |
479 |
if (m_model == |
|
454 | if (m_model == 0) | |
480 | return; |
|
455 | return; | |
481 | m_mapX = modelX; |
|
456 | m_mapX = modelX; | |
482 | m_mapY = modelY; |
|
457 | m_mapY = modelY; | |
483 | m_mapFirst = 0; |
|
458 | m_mapFirst = 0; | |
484 | m_mapOrientation = orientation; |
|
459 | m_mapOrientation = orientation; | |
485 | if (m_mapOrientation == Qt::Vertical) |
|
460 | if (m_mapOrientation == Qt::Vertical) { | |
486 | { |
|
|||
487 | // m_mapCount = m_model->rowCount(); |
|
461 | // m_mapCount = m_model->rowCount(); | |
488 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
462 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
489 | connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
463 | connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
490 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
464 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
491 | connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); |
|
465 | connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); | |
492 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
466 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
493 | } |
|
467 | } else { | |
494 | else |
|
|||
495 | { |
|
|||
496 | // m_mapCount = m_model->columnCount(); |
|
468 | // m_mapCount = m_model->columnCount(); | |
497 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
469 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
498 | connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
470 | connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
@@ -505,10 +477,9 void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientat | |||||
505 | void QXYSeries::setModelMappingShift(int first, int count) |
|
477 | void QXYSeries::setModelMappingShift(int first, int count) | |
506 | { |
|
478 | { | |
507 | m_mapFirst = first; |
|
479 | m_mapFirst = first; | |
508 | if (count == 0) |
|
480 | if (count == 0) { | |
509 | m_mapLimited = false; |
|
481 | m_mapLimited = false; | |
510 | else |
|
482 | } else { | |
511 | { |
|
|||
512 | m_mapCount = count; |
|
483 | m_mapCount = count; | |
513 | m_mapLimited = true; |
|
484 | m_mapLimited = true; | |
514 | } |
|
485 | } |
@@ -3,7 +3,6 | |||||
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qseries.h> |
|
5 | #include <qseries.h> | |
6 | #include <QDebug> |
|
|||
7 | #include <QPen> |
|
6 | #include <QPen> | |
8 | #include <QBrush> |
|
7 | #include <QBrush> | |
9 |
|
8 | |||
@@ -13,18 +12,18 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries | |||||
13 | { |
|
12 | { | |
14 | Q_OBJECT |
|
13 | Q_OBJECT | |
15 | protected: |
|
14 | protected: | |
16 |
QXYSeries(QObject* |
|
15 | QXYSeries(QObject *parent=0); | |
17 | virtual ~QXYSeries(); |
|
16 | virtual ~QXYSeries(); | |
18 |
|
17 | |||
19 | public: |
|
18 | public: | |
20 | void add(qreal x, qreal y); |
|
19 | void add(qreal x, qreal y); | |
21 |
void add(const QPointF& |
|
20 | void add(const QPointF &point); | |
22 | void add(const QList<QPointF> points); |
|
21 | void add(const QList<QPointF> points); | |
23 | void replace(qreal x,qreal y); |
|
22 | void replace(qreal x,qreal y); | |
24 |
void replace(const QPointF& |
|
23 | void replace(const QPointF &point); | |
25 | void remove(qreal x); |
|
24 | void remove(qreal x); | |
26 | void remove(qreal x, qreal y); |
|
25 | void remove(qreal x, qreal y); | |
27 |
void remove(const QPointF& |
|
26 | void remove(const QPointF &point); | |
28 | void removeAll(); |
|
27 | void removeAll(); | |
29 |
|
28 | |||
30 | int count() const; |
|
29 | int count() const; | |
@@ -35,12 +34,12 public: | |||||
35 | QXYSeries& operator << (const QPointF &point); |
|
34 | QXYSeries& operator << (const QPointF &point); | |
36 | QXYSeries& operator << (const QList<QPointF> points); |
|
35 | QXYSeries& operator << (const QList<QPointF> points); | |
37 |
|
36 | |||
38 |
void setPen(const QPen& |
|
37 | void setPen(const QPen &pen); | |
39 | QPen pen() const {return m_pen;} |
|
38 | QPen pen() const {return m_pen;} | |
40 |
void setBrush(const QBrush& |
|
39 | void setBrush(const QBrush &pen); | |
41 | QBrush brush() const {return m_brush;} |
|
40 | QBrush brush() const {return m_brush;} | |
42 |
|
41 | |||
43 |
bool setModel(QAbstractItemModel* |
|
42 | bool setModel(QAbstractItemModel *model); | |
44 | QAbstractItemModel* model() {return m_model;} |
|
43 | QAbstractItemModel* model() {return m_model;} | |
45 |
|
44 | |||
46 | 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); | |
@@ -54,7 +53,7 public: | |||||
54 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
53 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
55 |
|
54 | |||
56 | signals: |
|
55 | signals: | |
57 |
void clicked(const QPointF& |
|
56 | void clicked(const QPointF &point); | |
58 | void updated(); |
|
57 | void updated(); | |
59 | void pointReplaced(int index); |
|
58 | void pointReplaced(int index); | |
60 | void pointRemoved(int index); |
|
59 | void pointRemoved(int index); |
@@ -10,20 +10,20 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
10 |
|
10 | |||
11 | //TODO: optimize : remove points which are not visible |
|
11 | //TODO: optimize : remove points which are not visible | |
12 |
|
12 | |||
13 |
XYChartItem::XYChartItem(QXYSeries* |
|
13 | XYChartItem::XYChartItem(QXYSeries *series, ChartPresenter *presenter):ChartItem(presenter), | |
14 | m_minX(0), |
|
14 | m_minX(0), | |
15 | m_maxX(0), |
|
15 | m_maxX(0), | |
16 | m_minY(0), |
|
16 | m_minY(0), | |
17 | m_maxY(0), |
|
17 | m_maxY(0), | |
18 | m_series(series) |
|
18 | m_series(series) | |
19 | { |
|
19 | { | |
20 |
|
|
20 | connect(series,SIGNAL(pointReplaced(int)),this,SLOT(handlePointReplaced(int))); | |
21 |
|
|
21 | connect(series,SIGNAL(pointAdded(int)),this,SLOT(handlePointAdded(int))); | |
22 |
|
|
22 | connect(series,SIGNAL(pointRemoved(int)),this,SLOT(handlePointRemoved(int))); | |
23 |
|
|
23 | connect(this,SIGNAL(clicked(const QPointF&)),series,SIGNAL(clicked(const QPointF&))); | |
24 | } |
|
24 | } | |
25 |
|
25 | |||
26 |
QPointF XYChartItem::calculateGeometryPoint(const QPointF& |
|
26 | QPointF XYChartItem::calculateGeometryPoint(const QPointF &point) const | |
27 | { |
|
27 | { | |
28 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
28 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); | |
29 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
29 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); | |
@@ -50,14 +50,14 QVector<QPointF> XYChartItem::calculateGeometryPoints() const | |||||
50 | QVector<QPointF> points; |
|
50 | QVector<QPointF> points; | |
51 | points.reserve(m_series->count()); |
|
51 | points.reserve(m_series->count()); | |
52 | for (int i = 0; i < m_series->count(); ++i) { |
|
52 | for (int i = 0; i < m_series->count(); ++i) { | |
53 | qreal x = (m_series->x(i) - m_minX)* deltaX; |
|
53 | qreal x = (m_series->x(i) - m_minX)* deltaX; | |
54 | qreal y = (m_series->y(i) - m_minY)*-deltaY + m_size.height(); |
|
54 | qreal y = (m_series->y(i) - m_minY)*-deltaY + m_size.height(); | |
55 | points << QPointF(x,y); |
|
55 | points << QPointF(x,y); | |
56 | } |
|
56 | } | |
57 | return points; |
|
57 | return points; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 |
QPointF XYChartItem::calculateDomainPoint(const QPointF& |
|
60 | QPointF XYChartItem::calculateDomainPoint(const QPointF &point) const | |
61 | { |
|
61 | { | |
62 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); |
|
62 | const qreal deltaX = m_size.width()/(m_maxX-m_minX); | |
63 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); |
|
63 | const qreal deltaY = m_size.height()/(m_maxY-m_minY); | |
@@ -66,16 +66,16 QPointF XYChartItem::calculateDomainPoint(const QPointF& point) const | |||||
66 | return QPointF(x,y); |
|
66 | return QPointF(x,y); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 |
void XYChartItem::updateLayout(QVector<QPointF>& |
|
69 | void XYChartItem::updateLayout(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index) | |
70 | { |
|
70 | { | |
71 | if(animator()){ |
|
71 | if (animator()) { | |
72 | animator()->updateLayout(this,oldPoints,newPoints,index); |
|
72 | animator()->updateLayout(this,oldPoints,newPoints,index); | |
73 | }else{ |
|
73 | } else { | |
74 | setLayout(newPoints); |
|
74 | setLayout(newPoints); | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 |
void XYChartItem::setLayout(QVector<QPointF>& |
|
78 | void XYChartItem::setLayout(QVector<QPointF> &points) | |
79 | { |
|
79 | { | |
80 | m_points = points; |
|
80 | m_points = points; | |
81 | update(); |
|
81 | update(); | |
@@ -121,20 +121,20 void XYChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal | |||||
121 | m_minY=minY; |
|
121 | m_minY=minY; | |
122 | m_maxY=maxY; |
|
122 | m_maxY=maxY; | |
123 |
|
123 | |||
124 | if(isEmpty()) return; |
|
124 | if (isEmpty()) return; | |
125 | QVector<QPointF> points = calculateGeometryPoints(); |
|
125 | QVector<QPointF> points = calculateGeometryPoints(); | |
126 | updateLayout(m_points,points); |
|
126 | updateLayout(m_points,points); | |
127 | update(); |
|
127 | update(); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 |
void XYChartItem::handleGeometryChanged(const QRectF& |
|
130 | void XYChartItem::handleGeometryChanged(const QRectF &rect) | |
131 | { |
|
131 | { | |
132 | Q_ASSERT(rect.isValid()); |
|
132 | Q_ASSERT(rect.isValid()); | |
133 | m_size=rect.size(); |
|
133 | m_size=rect.size(); | |
134 | m_clipRect=rect.translated(-rect.topLeft()); |
|
134 | m_clipRect=rect.translated(-rect.topLeft()); | |
135 | setPos(rect.topLeft()); |
|
135 | setPos(rect.topLeft()); | |
136 |
|
136 | |||
137 | if(isEmpty()) return; |
|
137 | if (isEmpty()) return; | |
138 | QVector<QPointF> points = calculateGeometryPoints(); |
|
138 | QVector<QPointF> points = calculateGeometryPoints(); | |
139 | updateLayout(m_points,points); |
|
139 | updateLayout(m_points,points); | |
140 | update(); |
|
140 | update(); | |
@@ -146,7 +146,7 bool XYChartItem::isEmpty() | |||||
146 | return !m_clipRect.isValid() || m_maxX - m_minX == 0 || m_maxY - m_minY ==0 ; |
|
146 | return !m_clipRect.isValid() || m_maxX - m_minX == 0 || m_maxY - m_minY ==0 ; | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 |
void XYChartItem::mousePressEvent( |
|
149 | void XYChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
150 | { |
|
150 | { | |
151 | emit clicked(calculateDomainPoint(event->pos())); |
|
151 | emit clicked(calculateDomainPoint(event->pos())); | |
152 | } |
|
152 | } |
@@ -14,8 +14,8 class XYChartItem : public ChartItem | |||||
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 |
explicit XYChartItem(QXYSeries* |
|
17 | explicit XYChartItem(QXYSeries *series, ChartPresenter *presenter); | |
18 |
~ |
|
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;} | |
@@ -26,21 +26,21 public slots: | |||||
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& |
|
29 | void handleGeometryChanged(const QRectF &size); | |
30 |
|
30 | |||
31 | signals: |
|
31 | 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>& |
|
36 | virtual void setLayout(QVector<QPointF> &points); | |
37 |
virtual void updateLayout(QVector<QPointF>& |
|
37 | virtual void updateLayout(QVector<QPointF> &oldPoints,QVector<QPointF> &newPoints,int index = 0); | |
38 |
|
38 | |||
39 |
QPointF calculateGeometryPoint(const QPointF& |
|
39 | QPointF calculateGeometryPoint(const QPointF &point) const; | |
40 | QPointF calculateGeometryPoint(int index) const; |
|
40 | QPointF calculateGeometryPoint(int index) const; | |
41 |
QPointF calculateDomainPoint(const QPointF& |
|
41 | QPointF calculateDomainPoint(const QPointF &point) const; | |
42 | QVector<QPointF> calculateGeometryPoints() const; |
|
42 | QVector<QPointF> calculateGeometryPoints() const; | |
43 |
void mousePressEvent( |
|
43 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
44 |
|
44 | |||
45 | private: |
|
45 | private: | |
46 | inline bool isEmpty(); |
|
46 | inline bool isEmpty(); |
General Comments 0
You need to be logged in to leave comments.
Login now