##// END OF EJS Templates
Fixed isVisible implementation in XY series
Tero Ahola -
r1346:4fe424a18505
parent child
Show More
@@ -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,7 +121,6 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 painter->save();
125 painter->setPen(m_linePen);
125 painter->setPen(m_linePen);
126 painter->setBrush(m_brush);
126 painter->setBrush(m_brush);
@@ -134,7 +134,6 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
134 }
134 }
135 painter->restore();
135 painter->restore();
136 }
136 }
137 }
138
137
139 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
138 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
140 {
139 {
@@ -30,7 +30,8 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):XYChart(series,presenter),
33 LineChartItem::LineChartItem(QLineSeries* series,ChartPresenter *presenter):
34 XYChart(series, presenter),
34 QGraphicsItem(presenter ? presenter->rootItem() : 0),
35 QGraphicsItem(presenter ? presenter->rootItem() : 0),
35 m_series(series),
36 m_series(series),
36 m_pointsVisible(false)
37 m_pointsVisible(false)
@@ -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,7 +93,6 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()) {
95 painter->save();
96 painter->save();
96 painter->setPen(m_linePen);
97 painter->setPen(m_linePen);
97 painter->setClipRect(clipRect());
98 painter->setClipRect(clipRect());
@@ -102,7 +103,6 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
102 }
103 }
103 painter->restore();
104 painter->restore();
104 }
105 }
105 }
106
106
107 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
107 void LineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
108 {
108 {
@@ -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,7 +149,7 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 painter->save();
153 painter->save();
153 painter->setClipRect(clipRect());
154 painter->setClipRect(clipRect());
154 painter->setPen(m_linePen);
155 painter->setPen(m_linePen);
@@ -159,7 +160,6 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
159 }
160 }
160 painter->restore();
161 painter->restore();
161 }
162 }
162 }
163
163
164 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
164 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
165 {
165 {
General Comments 0
You need to be logged in to leave comments. Login now