File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,7 @@ void PlotMarker::setPen(const QPen &pen)
540540
541541void 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
553554QRectF 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
558578void PlotMarker::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
You can’t perform that action at this time.
0 commit comments