@@ -90,6 +90,7 void AreaChartItem::updatePath() | |||||
90 |
|
90 | |||
91 | void AreaChartItem::handleUpdated() |
|
91 | void AreaChartItem::handleUpdated() | |
92 | { |
|
92 | { | |
|
93 | setVisible(m_series->isVisible()); | |||
93 | m_pointsVisible = m_series->pointsVisible(); |
|
94 | m_pointsVisible = m_series->pointsVisible(); | |
94 | m_linePen = m_series->pen(); |
|
95 | m_linePen = m_series->pen(); | |
95 | m_brush = m_series->brush(); |
|
96 | m_brush = m_series->brush(); | |
@@ -120,20 +121,18 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt | |||||
120 | Q_UNUSED(widget) |
|
121 | Q_UNUSED(widget) | |
121 | Q_UNUSED(option) |
|
122 | Q_UNUSED(option) | |
122 |
|
123 | |||
123 | if (m_series->isVisible()) { |
|
124 | painter->save(); | |
124 |
|
|
125 | painter->setPen(m_linePen); | |
125 |
|
|
126 | painter->setBrush(m_brush); | |
126 | painter->setBrush(m_brush); |
|
127 | painter->setClipRect(m_clipRect); | |
127 | painter->setClipRect(m_clipRect); |
|
128 | painter->drawPath(m_path); | |
128 | painter->drawPath(m_path); |
|
129 | if (m_pointsVisible) { | |
129 | if (m_pointsVisible) { |
|
130 | painter->setPen(m_pointPen); | |
130 | painter->setPen(m_pointPen); |
|
131 | painter->drawPoints(m_upper->geometryPoints()); | |
131 | painter->drawPoints(m_upper->geometryPoints()); |
|
132 | if (m_lower) | |
132 | if (m_lower) |
|
133 | painter->drawPoints(m_lower->geometryPoints()); | |
133 | painter->drawPoints(m_lower->geometryPoints()); |
|
|||
134 | } |
|
|||
135 | painter->restore(); |
|
|||
136 | } |
|
134 | } | |
|
135 | painter->restore(); | |||
137 | } |
|
136 | } | |
138 |
|
137 | |||
139 | void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
138 | void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
@@ -30,10 +30,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
30 |
|
30 | |||
31 | //TODO: optimize : remove points which are not visible |
|
31 | //TODO: optimize : remove points which are not visible | |
32 |
|
32 | |||
33 |
LineChartItem::LineChartItem(QLineSeries* series,ChartPresenter *presenter): |
|
33 | LineChartItem::LineChartItem(QLineSeries* series,ChartPresenter *presenter): | |
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
34 | XYChart(series, presenter), | |
35 | m_series(series), |
|
35 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
36 | m_pointsVisible(false) |
|
36 | m_series(series), | |
|
37 | m_pointsVisible(false) | |||
37 | { |
|
38 | { | |
38 | setZValue(ChartPresenter::LineChartZValue); |
|
39 | setZValue(ChartPresenter::LineChartZValue); | |
39 | QObject::connect(series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated())); |
|
40 | QObject::connect(series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated())); | |
@@ -77,6 +78,7 void LineChartItem::updateGeometry() | |||||
77 |
|
78 | |||
78 | void LineChartItem::handleUpdated() |
|
79 | void LineChartItem::handleUpdated() | |
79 | { |
|
80 | { | |
|
81 | setVisible(m_series->isVisible()); | |||
80 | m_pointsVisible = m_series->pointsVisible(); |
|
82 | m_pointsVisible = m_series->pointsVisible(); | |
81 | m_linePen = m_series->pen(); |
|
83 | m_linePen = m_series->pen(); | |
82 | m_pointPen = m_series->pen(); |
|
84 | m_pointPen = m_series->pen(); | |
@@ -91,17 +93,15 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt | |||||
91 | Q_UNUSED(widget) |
|
93 | Q_UNUSED(widget) | |
92 | Q_UNUSED(option) |
|
94 | Q_UNUSED(option) | |
93 |
|
95 | |||
94 | if (m_series->isVisible()) { |
|
96 | painter->save(); | |
95 |
|
|
97 | painter->setPen(m_linePen); | |
96 |
|
|
98 | painter->setClipRect(clipRect()); | |
97 | painter->setClipRect(clipRect()); |
|
99 | painter->drawPath(m_path); | |
98 | painter->drawPath(m_path); |
|
100 | if (m_pointsVisible){ | |
99 | if(m_pointsVisible){ |
|
101 | painter->setPen(m_pointPen); | |
100 |
|
|
102 | painter->drawPoints(geometryPoints()); | |
101 | painter->drawPoints(geometryPoints()); |
|
|||
102 | } |
|
|||
103 | painter->restore(); |
|
|||
104 | } |
|
103 | } | |
|
104 | painter->restore(); | |||
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
107 | void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
@@ -34,6 +34,7 ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *prese | |||||
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_visible(true), | |||
37 | m_shape(QScatterSeries::MarkerShapeRectangle), |
|
38 | m_shape(QScatterSeries::MarkerShapeRectangle), | |
38 | m_size(15) |
|
39 | m_size(15) | |
39 | { |
|
40 | { | |
@@ -132,7 +133,7 void ScatterChartItem::updateGeometry() | |||||
132 | const QRectF& rect = item->boundingRect(); |
|
133 | const QRectF& rect = item->boundingRect(); | |
133 | item->setPoint(point); |
|
134 | item->setPoint(point); | |
134 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); |
|
135 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); | |
135 | if(!clipRect().contains(point)) { |
|
136 | if(!m_visible || !clipRect().contains(point)) { | |
136 | item->setVisible(false); |
|
137 | item->setVisible(false); | |
137 | } |
|
138 | } | |
138 | else { |
|
139 | else { | |
@@ -172,8 +173,11 void ScatterChartItem::handleUpdated() | |||||
172 |
|
173 | |||
173 | if(count==0) return; |
|
174 | if(count==0) return; | |
174 |
|
175 | |||
175 | bool recreate = m_size != m_series->markerSize() || m_shape != m_series->markerShape(); |
|
176 | bool recreate = m_visible != m_series->isVisible() | |
|
177 | || m_size != m_series->markerSize() | |||
|
178 | || m_shape != m_series->markerShape(); | |||
176 |
|
179 | |||
|
180 | m_visible = m_series->isVisible(); | |||
177 | m_size = m_series->markerSize(); |
|
181 | m_size = m_series->markerSize(); | |
178 | m_shape = m_series->markerShape(); |
|
182 | m_shape = m_series->markerShape(); | |
179 |
|
183 |
@@ -62,6 +62,7 protected: | |||||
62 | private: |
|
62 | private: | |
63 | QScatterSeries *m_series; |
|
63 | QScatterSeries *m_series; | |
64 | QGraphicsItemGroup m_items; |
|
64 | QGraphicsItemGroup m_items; | |
|
65 | bool m_visible; | |||
65 | int m_shape; |
|
66 | int m_shape; | |
66 | int m_size; |
|
67 | int m_size; | |
67 | QRectF m_rect; |
|
68 | QRectF m_rect; |
@@ -135,6 +135,7 void SplineChartItem::updateGeometry() | |||||
135 |
|
135 | |||
136 | void SplineChartItem::handleUpdated() |
|
136 | void SplineChartItem::handleUpdated() | |
137 | { |
|
137 | { | |
|
138 | setVisible(m_series->isVisible()); | |||
138 | m_pointsVisible = m_series->pointsVisible(); |
|
139 | m_pointsVisible = m_series->pointsVisible(); | |
139 | m_linePen = m_series->pen(); |
|
140 | m_linePen = m_series->pen(); | |
140 | m_pointPen = m_series->pen(); |
|
141 | m_pointPen = m_series->pen(); | |
@@ -148,17 +149,16 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||||
148 | { |
|
149 | { | |
149 | Q_UNUSED(widget) |
|
150 | Q_UNUSED(widget) | |
150 | Q_UNUSED(option) |
|
151 | Q_UNUSED(option) | |
151 | if (m_series->isVisible()) { |
|
152 | ||
152 |
|
|
153 | painter->save(); | |
153 |
|
|
154 | painter->setClipRect(clipRect()); | |
154 |
|
|
155 | painter->setPen(m_linePen); | |
155 |
|
|
156 | painter->drawPath(m_path); | |
156 |
|
|
157 | if (m_pointsVisible) { | |
157 |
|
|
158 | painter->setPen(m_pointPen); | |
158 |
|
|
159 | painter->drawPoints(geometryPoints()); | |
159 | } |
|
|||
160 | painter->restore(); |
|
|||
161 | } |
|
160 | } | |
|
161 | painter->restore(); | |||
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
164 | void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
General Comments 0
You need to be logged in to leave comments.
Login now