##// END OF EJS Templates
Adds visiblePoints handling to area chart
Michal Klocek -
r563:c49efba21573
parent child
Show More
@@ -11,7 +11,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 AreaChartItem::AreaChartItem(QAreaSeries* areaSeries,QGraphicsItem *parent):ChartItem(parent),
11 AreaChartItem::AreaChartItem(QAreaSeries* areaSeries,QGraphicsItem *parent):ChartItem(parent),
12 m_series(areaSeries),
12 m_series(areaSeries),
13 m_upper(0),
13 m_upper(0),
14 m_lower(0)
14 m_lower(0),
15 m_pointsVisible(false)
15 {
16 {
16 //m_items.setZValue(ChartPresenter::LineChartZValue);
17 //m_items.setZValue(ChartPresenter::LineChartZValue);
17 m_upper = new AreaBoundItem(this,m_series->upperSeries());
18 m_upper = new AreaBoundItem(this,m_series->upperSeries());
@@ -63,8 +64,12 void AreaChartItem::updatePath()
63
64
64 void AreaChartItem::handleUpdated()
65 void AreaChartItem::handleUpdated()
65 {
66 {
66 m_pen = m_series->pen();
67 m_pointsVisible = m_series->pointsVisible();
68 m_linePen = m_series->pen();
67 m_brush = m_series->brush();
69 m_brush = m_series->brush();
70 m_pointPen = m_series->pen();
71 m_pointPen.setWidthF(2*m_pointPen.width());
72
68 update();
73 update();
69 }
74 }
70
75
@@ -90,10 +95,15 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
90 Q_UNUSED(widget);
95 Q_UNUSED(widget);
91 Q_UNUSED(option);
96 Q_UNUSED(option);
92 painter->save();
97 painter->save();
93 painter->setPen(m_pen);
98 painter->setPen(m_linePen);
94 painter->setBrush(m_brush);
99 painter->setBrush(m_brush);
95 painter->setClipRect(m_clipRect);
100 painter->setClipRect(m_clipRect);
96 painter->drawPath(m_path);
101 painter->drawPath(m_path);
102 if(m_pointsVisible){
103 painter->setPen(m_pointPen);
104 painter->drawPoints(m_upper->points());
105 if(m_lower) painter->drawPoints(m_lower->points());
106 }
97 painter->restore();
107 painter->restore();
98 }
108 }
99
109
@@ -25,7 +25,6 public:
25 LineChartItem* upperLineItem() const { return m_upper ;}
25 LineChartItem* upperLineItem() const { return m_upper ;}
26 LineChartItem* lowerLineItem() const { return m_lower ;}
26 LineChartItem* lowerLineItem() const { return m_lower ;}
27
27
28 void setPointsVisible(bool visible);
29 void updatePath();
28 void updatePath();
30 public slots:
29 public slots:
31 void handleUpdated();
30 void handleUpdated();
@@ -39,8 +38,11 private:
39 QPainterPath m_path;
38 QPainterPath m_path;
40 QRectF m_rect;
39 QRectF m_rect;
41 QRectF m_clipRect;
40 QRectF m_clipRect;
42 QPen m_pen;
41 QPen m_linePen;
42 QPen m_pointPen;
43 QBrush m_brush;
43 QBrush m_brush;
44 bool m_pointsVisible;
45
44 };
46 };
45
47
46 class AreaBoundItem : public LineChartItem
48 class AreaBoundItem : public LineChartItem
General Comments 0
You need to be logged in to leave comments. Login now