MCPcopy Create free account
hub / github.com/LUX-Core/lux / drawLegendIcon

Method drawLegendIcon

src/qt/qcustomplot.cpp:20365–20397  ·  view source on GitHub ↗

inherits documentation from base class */

Source from the content-addressed store, hash-verified

20363
20364/* inherits documentation from base class */
20365void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const
20366{
20367 // draw fill:
20368 if (mBrush.style() != Qt::NoBrush)
20369 {
20370 applyFillAntialiasingHint(painter);
20371 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush);
20372 }
20373 // draw line vertically centered:
20374 if (mLineStyle != lsNone)
20375 {
20376 applyDefaultAntialiasingHint(painter);
20377 painter->setPen(mPen);
20378 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
20379 }
20380 // draw scatter symbol:
20381 if (!mScatterStyle.isNone())
20382 {
20383 applyScattersAntialiasingHint(painter);
20384 // scale scatter pixmap if it's too large to fit in legend icon rect:
20385 if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height()))
20386 {
20387 QCPScatterStyle scaledStyle(mScatterStyle);
20388 scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
20389 scaledStyle.applyTo(painter, mPen);
20390 scaledStyle.drawShape(painter, QRectF(rect).center());
20391 } else
20392 {
20393 mScatterStyle.applyTo(painter, mPen);
20394 mScatterStyle.drawShape(painter, QRectF(rect).center());
20395 }
20396 }
20397}
20398
20399/*! \internal
20400

Callers 1

drawMethod · 0.80

Calls 10

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

Tested by

no test coverage detected