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