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

Method paint

src/backend/worksheet/plots/cartesian/BarPlot.cpp:1340–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1338}
1339
1340void BarPlotPrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) {
1341 if (!isVisible())
1342 return;
1343
1344 painter->setPen(Qt::NoPen);
1345 painter->setBrush(Qt::NoBrush);
1346 painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
1347
1348 if (!q->isPrinting() && Settings::group(QStringLiteral("Settings_Worksheet")).readEntry<bool>("DoubleBuffering", true))
1349 painter->drawPixmap(m_boundingRectangle.topLeft(), m_pixmap); // draw the cached pixmap (fast)
1350 else
1351 draw(painter); // draw directly again (slow)
1352
1353 // no need to handle the selection/hover effect if the cached pixmap is empty
1354 if (m_pixmap.isNull())
1355 return;
1356
1357 if (m_hovered && !isSelected() && !q->isPrinting()) {
1358 if (m_hoverEffectImageIsDirty) {
1359 QPixmap pix = m_pixmap;
1360 QPainter p(&pix);
1361 p.setCompositionMode(QPainter::CompositionMode_SourceIn); // source (shadow) pixels merged with the alpha channel of the destination (m_pixmap)
1362 p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Shadow));
1363 p.end();
1364
1365 m_hoverEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5);
1366 m_hoverEffectImageIsDirty = false;
1367 }
1368
1369 painter->drawImage(m_boundingRectangle.topLeft(), m_hoverEffectImage, m_pixmap.rect());
1370 return;
1371 }
1372
1373 if (isSelected() && !q->isPrinting()) {
1374 if (m_selectionEffectImageIsDirty) {
1375 QPixmap pix = m_pixmap;
1376 QPainter p(&pix);
1377 p.setCompositionMode(QPainter::CompositionMode_SourceIn);
1378 p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Highlight));
1379 p.end();
1380
1381 m_selectionEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5);
1382 m_selectionEffectImageIsDirty = false;
1383 }
1384
1385 painter->drawImage(m_boundingRectangle.topLeft(), m_selectionEffectImage, m_pixmap.rect());
1386 return;
1387 }
1388}
1389
1390// ##############################################################################
1391// ################## Serialization/Deserialization ###########################

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