| 543 | } |
| 544 | |
| 545 | void PlotWidgetBase::setStyle(QwtPlotCurve* curve, CurveStyle style) { |
| 546 | const double width = style == kDots ? dotWidthValue(lineWidth()) : lineWidthValue(lineWidth()); |
| 547 | curve->setPen(curve->pen().color(), width); |
| 548 | |
| 549 | // Qwt's QwtPlotCurve::LinesAndDots style on its own does not draw visible |
| 550 | // dots at the pen widths we use (1.4-4.2 px); attach an explicit symbol so |
| 551 | // each sample is rendered as a small filled circle. Cleared for plain Lines. |
| 552 | switch (style) { |
| 553 | case kLines: |
| 554 | curve->setStyle(QwtPlotCurve::Lines); |
| 555 | curve->setSymbol(nullptr); |
| 556 | break; |
| 557 | case kLinesAndDots: { |
| 558 | curve->setStyle(QwtPlotCurve::Lines); |
| 559 | const QColor color = curve->pen().color(); |
| 560 | const int dot_size = static_cast<int>(std::round(dotWidthValue(lineWidth()))); |
| 561 | curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, color, QPen(color), QSize(dot_size, dot_size))); |
| 562 | break; |
| 563 | } |
| 564 | case kDots: |
| 565 | curve->setStyle(QwtPlotCurve::Dots); |
| 566 | curve->setSymbol(nullptr); |
| 567 | break; |
| 568 | case kSticks: |
| 569 | curve->setStyle(QwtPlotCurve::Sticks); |
| 570 | curve->setSymbol(nullptr); |
| 571 | break; |
| 572 | case kSteps: |
| 573 | curve->setStyle(QwtPlotCurve::Steps); |
| 574 | curve->setCurveAttribute(QwtPlotCurve::Inverted, false); |
| 575 | curve->setSymbol(nullptr); |
| 576 | break; |
| 577 | case kStepsInverted: |
| 578 | curve->setStyle(QwtPlotCurve::Steps); |
| 579 | curve->setCurveAttribute(QwtPlotCurve::Inverted, true); |
| 580 | curve->setSymbol(nullptr); |
| 581 | break; |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | QColor PlotWidgetBase::nextColor() { |
| 586 | return colorFromIndex(next_color_index_++); |
no test coverage detected