void TracingItem::setStroke(Chart::Style, QColor color, bool) { const QColor black(Qt::black); const QPen outline(black); QColor alphaColor(color); QColor darkColor; darkColor = color.darker(180); alphaColor.setAlpha(196); QBrush alphaBrush(alphaColor); my.pointCurve->setLegendColor(color); my.spanSymbol->setWidth(6); my.spanSymbol->setBrush(alphaBrush); my.spanSymbol->setPen(outline); my.dropSymbol->setWidth(1); my.dropSymbol->setBrush(Qt::NoBrush); my.dropSymbol->setPen(outline); my.pointSymbol->setSize(8); my.pointSymbol->setColor(color); my.pointSymbol->setPen(outline); my.selectionSymbol->setSize(8); my.selectionSymbol->setColor(color.dark(180)); my.selectionSymbol->setPen(outline); }
QPixmap BrushStyle::getSample(qreal scale, qreal alpha, bool selected, const QColor &color, bool emptyBackground) { QPixmap backgroundPixmap( (selected) ? BRUSH_SAMPLE_SELECTED_BG : BRUSH_SAMPLE_BACKGROUND); if (emptyBackground) backgroundPixmap.fill(Qt::transparent); // Scale the sample QSizeF pointSize(BRUSH_SAMPLE_SIDE, BRUSH_SAMPLE_SIDE); if (scale != 1.0) { pointSize.setWidth(pointSize.width() * scale); pointSize.setHeight(pointSize.height() * scale); } // Apply color and alpha QColor alphaColor(Qt::black); if (color.isValid()) alphaColor = color; if (alpha != 1.0) alphaColor.setAlphaF(alpha); // Draw sample in the middle of background QPainter painter(&backgroundPixmap); painter.setRenderHint(QPainter::Antialiasing); QRectF pointRect(QPointF(0, 0), pointSize); pointRect.moveTo(backgroundPixmap.width() / 2 - pointSize.width() / 2, backgroundPixmap.height() / 2 - pointSize.height() / 2); if (color.isValid() && color.value() > 210 && color.saturation() < 50) painter.setPen("#d0d0d0"); else painter.setPen(Qt::NoPen); painter.setBrush(alphaColor); painter.drawEllipse(pointRect); painter.end(); return backgroundPixmap; }