2 Attachment(s)
QwtPlotZoomer: cut of markers close to canvas borders
Hello you all, I'm usign QT 4.7 and QWT 6.0.0 RC5
In a previous post I looked for suggests to implement a railway flow, and thanks to your advices I made the work.
At the present I'm in trouble with the use of QwtPlotZoomer. I'm using it to control automatically the zoom with mouse facilities patterns.
When the user zoom in and zoom out into the zoom stack, no problem.
When the user choose the maximum zoom out the curves are plotted too close the border of the canvas, cutting off some markers. Please see the comparison shots attached.
How can I fix this issue ? I would that zoom doesn't cut off the labels of the qwtplotmarkers.
Re: QwtPlotZoomer: cut of markers close to canvas borders
Well, all texts of your screenshots are so blurred, that I can only guess.
With QwtPlotMarker::setLabelAlignment() you can define, how the text label of a marker is aligned to its position - but what you are looking for is some sort of auto-placement, that takes care, that the label is always visible.
So you have to derive from QwtPlotMarker and overload - hmm ... drawLabel is not virtual, so it is QwtPlotMarker::draw. Do something like this:
Code:
void YourMarker
::draw( QPainter *painter,
const QRectF &canvasRect
) const {
xMap.transform( xValue() ), yMap.transform( yValue() );
symbol().drawSymbol( painter, pos );
const QSizeF textSize
= label
().
textSize( painter
->font
() );
QRectF textRect
= ...
// do your auto placement
label().draw( painter, textRect );
}
Uwe