Skip to content

Commit 3dc75d2

Browse files
committed
Optimize the way the frame marker is rendered over the static graph data to drastically reduce the plot time when seeking in ld-analyse.
1 parent 28d0665 commit 3dc75d2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tools/ld-analyse/plotwidget.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ void PlotMarker::setPen(const QPen &pen)
540540

541541
void PlotMarker::setPosition(const QPointF &pos)
542542
{
543+
prepareGeometryChange();
543544
m_dataPos = pos;
544545
update();
545546
}
@@ -552,7 +553,26 @@ void PlotMarker::setLabel(const QString &label)
552553

553554
QRectF PlotMarker::boundingRect() const
554555
{
555-
return m_plotRect;
556+
if (!m_plotWidget || m_plotRect.isEmpty()) return QRectF();
557+
558+
QPointF scenePos = m_plotWidget->mapFromData(m_dataPos);
559+
560+
// Only return the actual area occupied by the marker line (plus small margin)
561+
// This prevents unnecessary repainting of the entire plot
562+
const qreal margin = 2.0;
563+
564+
switch (m_style) {
565+
case VLine:
566+
return QRectF(scenePos.x() - margin, m_plotRect.top(),
567+
margin * 2, m_plotRect.height());
568+
case HLine:
569+
return QRectF(m_plotRect.left(), scenePos.y() - margin,
570+
m_plotRect.width(), margin * 2);
571+
case Cross:
572+
return m_plotRect; // Cross needs full area
573+
}
574+
575+
return QRectF();
556576
}
557577

558578
void PlotMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)

0 commit comments

Comments
 (0)