PDA

View Full Version : list of QwtCurves



gyre
19th December 2007, 18:30
This may be a stupid q...
Does QwtPlot keep a list of all attached curves ?
If so...how can I get it ?
If not -> :(

Uwe
19th December 2007, 19:39
QwtPlot has a list of all attached items ( see QwtPlotDict::itemList() ). For all curves you have to filter it using Rtti_PlotCurve ( or a dynamic_cast, when you have rtti enabled ).

Uwe

gyre
19th December 2007, 20:41
thanks buddy...
I have another problem :( (as usual ...)
I have created mainwindow in Qt Designer and I have put a QwtPlot inside that mainwindow...
It gets created as 1000x1000(X x Y) plot...
When I attach some curves to it they get displayed nicely...with autoscale...
But I have implemented QwtZoomer as in examples:

class Zoomer: public QwtPlotZoomer
{

public:
Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas)
:QwtPlotZoomer(xAxis, yAxis, canvas)
{
setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner);
setTrackerMode(QwtPicker::AlwaysOff);
setRubberBand(QwtPicker::NoRubberBand);

// RightButton: zoom out by 1
// Ctrl+RightButton: zoom out to full size
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);

setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
};

It is connected through the tool button(toggle) to this slot:


void MainWindow::enableZoomMode(bool on)
{
dataPanner->setEnabled(on);

dataZoomer[0]->setEnabled(on);
dataZoomer[0]->zoom(0);

dataZoomer[1]->setEnabled(on);
dataZoomer[1]->zoom(0);

dataPicker->setEnabled(!on);
}
The problem with this zoomer is that even when curves are displayed ok...when I toggle zoom button WHEN THE VALUES the curves display are small the curves are upon this toggle decreased too much so they are somwhere in the left corner of the plot...I think it is because the graph is initially created as 1000x1000 and zoom causes that somehow(since the max X values are 8 and max Y values are 10 )...So does anyone know how to make this work so the curves wouldnt decrease so much ?

Uwe
19th December 2007, 21:01
Whenever you change the scales behind the back of the zoomer you have to reinitialize the zoomer: see QwtPlotZoomer::setZoomBase().

Otherwise zooming out will return to the axes you had, when the zoomer was initialized the last time. In your case it is 1000x1000, what are the default axes ranges, because you created your zoomer before the first replot with data was done.

Uwe

gyre
19th December 2007, 21:33
Whenever you change the scales behind the back of the zoomer you have to reinitialize the zoomer: see QwtPlotZoomer::setZoomBase().

Otherwise zooming out will return to the axes you had, when the zoomer was initialized the last time. In your case it is 1000x1000, what are the default axes ranges, because you created your zoomer before the first replot with data was done.

Uwe

so every time the zoom button is toggled I have to call setZoomBase() on the zoomer ?

gyre
20th December 2007, 01:06
QwtPlot has a list of all attached items ( see QwtPlotDict::itemList() ). For all curves you have to filter it using Rtti_PlotCurve ( or a dynamic_cast, when you have rtti enabled ).

Uwe

I thought this :

plot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
will remove all item from plot...but it does nothing...
I need to remove all curves from the plot...
What should I do ?