MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / setStyle

Method setStyle

pj_plotting/widget/src/PlotWidgetBase.cpp:545–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545void 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
585QColor PlotWidgetBase::nextColor() {
586 return colorFromIndex(next_color_index_++);

Callers 3

setCurveStyleMethod · 0.45
applyGhostPensMethod · 0.45
applyToWidgetFunction · 0.45

Calls 9

dotWidthValueFunction · 0.85
lineWidthValueFunction · 0.85
setCurveAttributeMethod · 0.80
QPenClass · 0.50
QSizeClass · 0.50
setPenMethod · 0.45
colorMethod · 0.45
penMethod · 0.45
setSymbolMethod · 0.45

Tested by

no test coverage detected