Skip to content

Commit

Permalink
Flatline label can be drawn outside viewable window
Browse files Browse the repository at this point in the history
When doing error+compare plots the Flatline label
was being drawn on top of the curve in any case.
In the case of an error+compare, the flatline could be
at the very top of the window, which pushed the
label offscreen.  This fix simply draws the
Flatline label below the curve if drawing above
goes offscreen.
  • Loading branch information
keithvetter committed Nov 12, 2024
1 parent 26c270c commit 9351c3b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libkoviz/bookview_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,17 @@ void CurvesView::_paintErrorplot(const QTransform &T,
QTransform I;
painter.setTransform(I);
QRectF tbox = T.mapRect(ebox);
painter.drawText(tbox.topLeft()-QPointF(0,5),label);
double top = tbox.y()-fontMetrics().ascent();
QPoint drawPt;
if ( top >= 0 ) {
// Draw label over curve
drawPt = tbox.topLeft().toPoint()-QPoint(0,5);
} else {
// Draw label under curve since it would drawn off page
drawPt = tbox.topLeft().toPoint()+
QPoint(0,fontMetrics().ascent()) + QPoint(0,5);
}
painter.drawText(drawPt,label);
} else if ( errorPath->elementCount() == 0 ) {
// Empty plot
QTransform I;
Expand Down

0 comments on commit 9351c3b

Please sign in to comment.