From c49efba21573e0eb95779f248096e75c2950fbf7 2012-03-13 15:28:43 From: Michal Klocek Date: 2012-03-13 15:28:43 Subject: [PATCH] Adds visiblePoints handling to area chart --- diff --git a/src/areachart/areachartitem.cpp b/src/areachart/areachartitem.cpp index 036c996..1205a42 100644 --- a/src/areachart/areachartitem.cpp +++ b/src/areachart/areachartitem.cpp @@ -11,7 +11,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE AreaChartItem::AreaChartItem(QAreaSeries* areaSeries,QGraphicsItem *parent):ChartItem(parent), m_series(areaSeries), m_upper(0), -m_lower(0) +m_lower(0), +m_pointsVisible(false) { //m_items.setZValue(ChartPresenter::LineChartZValue); m_upper = new AreaBoundItem(this,m_series->upperSeries()); @@ -63,8 +64,12 @@ void AreaChartItem::updatePath() void AreaChartItem::handleUpdated() { - m_pen = m_series->pen(); + m_pointsVisible = m_series->pointsVisible(); + m_linePen = m_series->pen(); m_brush = m_series->brush(); + m_pointPen = m_series->pen(); + m_pointPen.setWidthF(2*m_pointPen.width()); + update(); } @@ -90,10 +95,15 @@ void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt Q_UNUSED(widget); Q_UNUSED(option); painter->save(); - painter->setPen(m_pen); + painter->setPen(m_linePen); painter->setBrush(m_brush); painter->setClipRect(m_clipRect); painter->drawPath(m_path); + if(m_pointsVisible){ + painter->setPen(m_pointPen); + painter->drawPoints(m_upper->points()); + if(m_lower) painter->drawPoints(m_lower->points()); + } painter->restore(); } diff --git a/src/areachart/areachartitem_p.h b/src/areachart/areachartitem_p.h index 26db2ff..bec2e0b 100644 --- a/src/areachart/areachartitem_p.h +++ b/src/areachart/areachartitem_p.h @@ -25,7 +25,6 @@ public: LineChartItem* upperLineItem() const { return m_upper ;} LineChartItem* lowerLineItem() const { return m_lower ;} - void setPointsVisible(bool visible); void updatePath(); public slots: void handleUpdated(); @@ -39,8 +38,11 @@ private: QPainterPath m_path; QRectF m_rect; QRectF m_clipRect; - QPen m_pen; + QPen m_linePen; + QPen m_pointPen; QBrush m_brush; + bool m_pointsVisible; + }; class AreaBoundItem : public LineChartItem