how to make the plot display the last curve drawn ??
Hello guys,
How can i make the plot display the last curve i draw ??
for example, i draw curve 1 then i draw curve two in coodinate that far a way of curve one ... now i need to zoom and look for curve2 >>>
how can i make the plot show the last curve with out me looking for it.
and is there away where i can click on the legend and make it move to the clicked curve ??
Thanks
Re: how to make the plot display the last curve drawn ??
Use autoscaling ( read about QwtPlot::setAxisAutoScale() ). All else you need to do is to set/unset the QwtPlotItem::AutoScale flags of your curves depending on your current context before calling replot.
Uwe
Re: how to make the plot display the last curve drawn ??
I think i still doing something wrong,
I tried doing :
Code:
setAxisAutoScale
(QwtPlot::xBottom);
// before I call replot(), i set
myCurve
->setItemAttribute
(QwtPlotItem::AutoScale,
true);
but still i have to look for the curve on the plot, could you please tell me what is the the wrong thing im doing ?
Thanks
Re: how to make the plot display the last curve drawn ??
Code:
myCurve1
->setItemAttribute
( QwtPlotItem::AutoScale,
false );
myCurve2
->setItemAttribute
( QwtPlotItem::AutoScale,
true );
plot
->setAxisAutoScale
(QwtPlot::xBottom);
plot
->setAxisAutoScale
(QwtPlot::yLeft);
plot->replot();
or
Code:
QRectF br
= myCurve2
->boundingRect
();
plot
->setAxisAutoScale
(QwtPlot::xBottom, br.
left(), br.
right() );
plot
->setAxisAutoScale
(QwtPlot::yLeft, br.
top(), br.
bottom() );
Uwe
Re: how to make the plot display the last curve drawn ??
thanks Uwe,
this exactlly what i need... but the second way when i use the boundingRect for the curve,
The method
Quote:
Code:
plot
->setAxisAutoScale
(QwtPlot::xBottom, br.
left(), br.
right() );
is not exist.
Is it in a new version of qwt ?
Re: how to make the plot display the last curve drawn ??
No, of course it is: QwtPlot::setAxisScale.
Uwe
Re: how to make the plot display the last curve drawn ??
using the Auto Scale works great, but there is affects other scales.
Let me elaborate it.
I am using
Code:
rescaler = new QwtPlotRescaler( myplot->canvas() );
rescaler
->setReferenceAxis
( QwtPlot::xBottom );
rescaler
->setAspectRatio
( QwtPlot::yLeft,
1.0 );
rescaler
->setAspectRatio
( QwtPlot::yRight,
0.0 );
rescaler
->setAspectRatio
( QwtPlot::xTop,
0.0 );
rescaler
->setAspectRatio
( QwtPlot::xBottom,
1.0 );
rescaler->setRescalePolicy( QwtPlotRescaler::Fixed );
this code to prevent the curve to be stretched and lose its real shape.
but when i use the AutoScale before i replot, the curve get stretched , where i have to zoom in and out so the rescaler works and the curve gets its "unstreached shape".
how can i fix this issue.
Thanks