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

Method recalcShapeAndBoundingRect

src/backend/worksheet/WorksheetElementContainer.cpp:240–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void WorksheetElementContainerPrivate::recalcShapeAndBoundingRect() {
241 // if (q->isLoading())
242 // return;
243
244 // old logic calculating the bounding box as the box covering all children.
245 // we might need this logic later once we implement something like selection of multiple plots, etc.
246 // boundingRectangle = QRectF();
247 // QVector<WorksheetElement*> childList = q->children<WorksheetElement>(AbstractAspect::IncludeHidden | AbstractAspect::Compress);
248 // foreach (const WorksheetElement* elem, childList)
249 // boundingRectangle |= elem->graphicsItem()->mapRectToParent(elem->graphicsItem()->boundingRect());
250 //
251 qreal penWidth = 2.;
252 m_boundingRectangle = q->rect();
253 // QDEBUG(Q_FUNC_INFO << ", bound rect = " << boundingRectangle)
254 m_boundingRectangle = QRectF(-m_boundingRectangle.width() / 2. - penWidth / 2.,
255 -m_boundingRectangle.height() / 2. - penWidth / 2.,
256 m_boundingRectangle.width() + penWidth,
257 m_boundingRectangle.height() + penWidth);
258
259 QPainterPath path;
260 path.addRect(m_boundingRectangle);
261
262 // make the shape somewhat thicker than the hoveredPen to make the selection/hovering box more visible
263 m_shape = QPainterPath();
264 m_shape.addPath(WorksheetElement::shapeFromPath(path, QPen(QBrush(), penWidth)));
265}
266
267// Inherited from QGraphicsItem
268QRectF WorksheetElementContainerPrivate::boundingRect() const {

Callers 2

retransformMethod · 0.45
handleAspectAddedMethod · 0.45

Calls 6

QRectFClass · 0.85
rectMethod · 0.80
heightMethod · 0.80
QPenClass · 0.70
QBrushClass · 0.70
widthMethod · 0.45

Tested by

no test coverage detected