PDA

View Full Version : SetAxisScale problem



emrares
11th August 2009, 07:34
I have a big problem when i try to change the scale and i have previous specified a tick list.
For example

setAutoReplot( false );

setAxisScale(QwtPlot::xBottom, -9,5); // I specify a interval
replot();

// Here I specify a fix list of ticks

QwtScaleDiv* scdiv = axisScaleDiv(xBottom);
QwtValueList tick_lst= scdiv->ticks(QwtScaleDiv::MajorTick);
tick_lst.clear();
tick_lst.push_back(-8);
tick_lst.push_back(-4);
tick_lst.push_back(-2);
tick_lst.push_back(1);
tick_lst.push_back(5);
scdiv->setTicks(QwtScaleDiv::MajorTick,tick_lst); // set the ticks
replot();

The ticks are shown on the xBottom scale, but when i change the the interval with
setAxisScale(QwtPlot::xBottom, 6,10); the program crashes because of the ticks.

How can i delete the tick list, or how can i change the ticks?? I tried several methods but without any success.

emrares
11th August 2009, 11:12
I solved the problem.
First you obtain a pointer to the scale division of the XBottom ax.
QwtScaleDiv* scdiv = axisScaleDiv(xBottom);

tick_lst= scdiv->ticks(QwtScaleDiv::MajorTick); // get the tick list

tick_lst.clear(); // clear the tick list

tick_list.push_back( value ) // insert new values

scdiv->setTicks(QwtScaleDiv::MajorTick,tick_lst); // put the tick list back on the ax

The tick_lst must be declared as private in the class.
I had several other bugs, i spent 2 days on this bug.

Uwe
12th August 2009, 17:45
Better make a copy of the scale division, edit it and reassign it with setAxisScaleDiv().

Uwe