From d1f00b1c0524d9ce61e87ec15dbbe05fee3a1ecc 2012-03-14 11:20:50 From: Marek Rosa Date: 2012-03-14 11:20:50 Subject: [PATCH] Fixed colors in spline --- diff --git a/examples/splinechart/splinewidget.cpp b/examples/splinechart/splinewidget.cpp index 33c0dd5..353d1bb 100644 --- a/examples/splinechart/splinewidget.cpp +++ b/examples/splinechart/splinewidget.cpp @@ -14,14 +14,14 @@ SplineWidget::SplineWidget(QWidget *parent) // qsrand(time(NULL)); //! [1] //create QSplineSeries - series = new QSplineSeries; + series = new QSplineSeries(this); //! [1] //! [2] // customize the series presentation settings QPen seriesPen(Qt::blue); seriesPen.setWidth(3); - series->setPen(seriesPen); +// series->setPen(seriesPen); //! [2] //! [add points to series] @@ -32,20 +32,32 @@ SplineWidget::SplineWidget(QWidget *parent) series->add(QPointF(300, 140)); series->add(QPointF(350, 160)); //! [add points to series] -// series->add(QPointF(400, 120)); -// series->add(QPointF(450, 150)); -// series->add(QPointF(500, 145)); -// series->add(QPointF(550, 170)); + + QSplineSeries* series2 = new QSplineSeries; + + series2->add(QPointF(400, 120)); + series2->add(QPointF(450, 150)); + series2->add(QPointF(500, 145)); + series2->add(QPointF(550, 170)); + // series->add(QPointF(600, 190)); // series->add(QPointF(650, 210)); // series->add(QPointF(700, 190)); // series->add(QPointF(750, 180)); // series->add(QPointF(800, 170)); + QSplineSeries* series3 = new QSplineSeries; + series3->add(QPointF(600, 190)); + series3->add(QPointF(650, 210)); + series3->add(QPointF(700, 190)); + series3->add(QPointF(750, 180)); + series3->add(QPointF(800, 170)); //! [3] // create chart view QChartView* chart = new QChartView; chart->addSeries(series); + chart->addSeries(series2); + chart->addSeries(series3); chart->setChartTitle("Spline chart example"); chart->axisX()->setMax(1500); diff --git a/src/charttheme.cpp b/src/charttheme.cpp index c03ea9b..21741d1 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -192,7 +192,6 @@ void ChartTheme::decorate(PieChartItem* item, QPieSeries* series, int index) void ChartTheme::decorate(QSplineSeries* series, int index) { QPen pen; - if(pen == series->pen()){ pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); pen.setWidthF(2); diff --git a/src/splinechart/splinechartitem.cpp b/src/splinechart/splinechartitem.cpp index 9643f1e..2e441cf 100644 --- a/src/splinechart/splinechartitem.cpp +++ b/src/splinechart/splinechartitem.cpp @@ -57,7 +57,6 @@ void SplineChartItem::setLayout(QVector& points) void SplineChartItem::handleUpdated() { - //m_items.setVisible(m_series->pointsVisible()); m_pen = m_series->pen(); update(); } @@ -70,27 +69,28 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o Q_UNUSED(option); painter->save(); painter->setClipRect(clipRect()); - painter->setPen(m_pen); +// painter->setPen(m_pen); + painter->setPen(m_series->pen()); painter->drawPath(m_path); - const QVector points = XYChartItem::points(); - - for (int i = 0; i < points.size() - 1; i++) - { - painter->setPen(Qt::red); - painter->drawEllipse(points[i], 2, 2); - - painter->setPen(Qt::blue); - // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i)); - // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1)); - // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4); - // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4); - } - if (points.count() > 0) - { - painter->setPen(Qt::red); - painter->drawEllipse(points[points.count() - 1], 2, 2); - } +// const QVector points = XYChartItem::points(); + +// for (int i = 0; i < points.size() - 1; i++) +// { +// painter->setPen(Qt::red); +// painter->drawEllipse(points[i], 2, 2); + +// painter->setPen(Qt::blue); +// // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i)); +// // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1)); +// // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4); +// // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4); +// } +// if (points.count() > 0) +// { +// painter->setPen(Qt::red); +// painter->drawEllipse(points[points.count() - 1], 2, 2); +// } painter->restore(); }