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

Method updateMagnificationWindow

src/frontend/worksheet/WorksheetView.cpp:988–1013  ·  view source on GitHub ↗

! * Updates the magnified content of the scene under the cursor that is shown in the magnification window. * \pos is the current position of the cursor in scene coordinates which defines the middle of the magnification window. */

Source from the content-addressed store, hash-verified

986 * \pos is the current position of the cursor in scene coordinates which defines the middle of the magnification window.
987 */
988void WorksheetView::updateMagnificationWindow(const QPointF& pos) {
989 m_magnificationWindow->setVisible(false);
990
991 // copy the part of the view to be shown magnified
992 const int size = Worksheet::convertToSceneUnits(2.0, Worksheet::Unit::Centimeter) / transform().m11();
993 const QRectF copyRect(pos.x() - size / (2 * magnificationFactor),
994 pos.y() - size / (2 * magnificationFactor),
995 size / magnificationFactor,
996 size / magnificationFactor);
997 QPixmap px = grab(mapFromScene(copyRect).boundingRect());
998 px = px.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
999
1000 // draw the bounding rect
1001 QPainter painter(&px);
1002 const QPen pen = QPen(Qt::darkGray, 2 / transform().m11());
1003 painter.setPen(pen);
1004 QRect rect = px.rect();
1005 rect.setWidth(rect.width() - pen.widthF() / 2);
1006 rect.setHeight(rect.height() - pen.widthF() / 2);
1007 painter.drawRect(rect);
1008
1009 // set the pixmap and show it again
1010 m_magnificationWindow->setPixmap(px);
1011 m_magnificationWindow->setPos(pos.x() - px.width() / 2, pos.y() - px.height() / 2);
1012 m_magnificationWindow->setVisible(true);
1013}
1014
1015void WorksheetView::contextMenuEvent(QContextMenuEvent* e) {
1016 if ((m_magnificationWindow && m_magnificationWindow->isVisible() && items(e->pos()).size() == 1) || !itemAt(e->pos())) {

Callers

nothing calls this directly

Calls 11

xMethod · 0.80
setPenMethod · 0.80
rectMethod · 0.80
setHeightMethod · 0.80
heightMethod · 0.80
QPenClass · 0.50
setVisibleMethod · 0.45
yMethod · 0.45
boundingRectMethod · 0.45
setWidthMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected