MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / drawLegendIcon

Method drawLegendIcon

qcustomplot/qcustomplot.cpp:20420–20452  ·  view source on GitHub ↗

inherits documentation from base class */

Source from the content-addressed store, hash-verified

20418
20419/* inherits documentation from base class */
20420void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
20421{
20422 // draw fill:
20423 if (mBrush.style() != Qt::NoBrush)
20424 {
20425 applyFillAntialiasingHint(painter);
20426 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush);
20427 }
20428 // draw line vertically centered:
20429 if (mLineStyle != lsNone)
20430 {
20431 applyDefaultAntialiasingHint(painter);
20432 painter->setPen(mPen);
20433 painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens
20434 }
20435 // draw scatter symbol:
20436 if (!mScatterStyle.isNone())
20437 {
20438 applyScattersAntialiasingHint(painter);
20439 // scale scatter pixmap if it's too large to fit in legend icon rect:
20440 if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height()))
20441 {
20442 QCPScatterStyle scaledStyle(mScatterStyle);
20443 scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
20444 scaledStyle.applyTo(painter, mPen);
20445 scaledStyle.drawShape(painter, QRectF(rect).center());
20446 } else
20447 {
20448 mScatterStyle.applyTo(painter, mPen);
20449 mScatterStyle.drawShape(painter, QRectF(rect).center());
20450 }
20451 }
20452}
20453
20454/*! \internal
20455

Callers 1

drawMethod · 0.80

Calls 8

setPenMethod · 0.80
drawLineMethod · 0.80
setPixmapMethod · 0.80
applyToMethod · 0.80
drawShapeMethod · 0.80
setBrushMethod · 0.80
setAntialiasingMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected