MCPcopy Create free account
hub / github.com/KDE/labplot / paint

Method paint

src/backend/worksheet/plots/cartesian/Histogram.cpp:1554–1602  ·  view source on GitHub ↗

! Reimplementation of QGraphicsItem::paint(). This function does the actual painting of the curve. \sa QGraphicsItem::paint(). */

Source from the content-addressed store, hash-verified

1552 \sa QGraphicsItem::paint().
1553 */
1554void HistogramPrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) {
1555 if (!isVisible())
1556 return;
1557
1558 painter->setPen(Qt::NoPen);
1559 painter->setBrush(Qt::NoBrush);
1560 painter->setRenderHint(QPainter::SmoothPixmapTransform);
1561
1562 if (!q->isPrinting() && Settings::group(QStringLiteral("Settings_Worksheet")).readEntry<bool>("DoubleBuffering", true))
1563 painter->drawPixmap(m_boundingRectangle.topLeft(), m_pixmap); // draw the cached pixmap (fast)
1564 else
1565 draw(painter); // draw directly again (slow)
1566
1567 // no need to handle the selection/hover effect if the cached pixmap is empty
1568 if (m_pixmap.isNull())
1569 return;
1570
1571 if (m_hovered && !isSelected() && !q->isPrinting()) {
1572 if (m_hoverEffectImageIsDirty) {
1573 QPixmap pix = m_pixmap;
1574 QPainter p(&pix);
1575 p.setCompositionMode(QPainter::CompositionMode_SourceIn); // source (shadow) pixels merged with the alpha channel of the destination (m_pixmap)
1576 p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Shadow));
1577 p.end();
1578
1579 m_hoverEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5);
1580 m_hoverEffectImageIsDirty = false;
1581 }
1582
1583 painter->drawImage(m_boundingRectangle.topLeft(), m_hoverEffectImage, m_pixmap.rect());
1584 return;
1585 }
1586
1587 if (isSelected() && !q->isPrinting()) {
1588 if (m_selectionEffectImageIsDirty) {
1589 QPixmap pix = m_pixmap;
1590 QPainter p(&pix);
1591 p.setCompositionMode(QPainter::CompositionMode_SourceIn);
1592 p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Highlight));
1593 p.end();
1594
1595 m_selectionEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5);
1596 m_selectionEffectImageIsDirty = false;
1597 }
1598
1599 painter->drawImage(m_boundingRectangle.topLeft(), m_selectionEffectImage, m_pixmap.rect());
1600 return;
1601 }
1602}
1603
1604/*!
1605 * checks if the mousePress event was done near the histogram shape

Callers

nothing calls this directly

Calls 8

groupFunction · 0.85
setPenMethod · 0.80
setBrushMethod · 0.80
isPrintingMethod · 0.80
isNullMethod · 0.80
rectMethod · 0.80
colorMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected