PDA

View Full Version : zoomer changes default axisscale vakues after Home key in a Qwtplot



john_k
15th September 2014, 20:49
Hi

I set my axes like

const QwtInterval xInterval = m_spectrogram->data()->interval( Qt::XAxis );
setAxisScale(xBottom, xInterval.minValue(), xInterval.maxValue(), 20);

const QwtInterval yInterval = m_spectrogram->data()->interval( Qt::YAxis );
setAxisScale(yLeft, yInterval.minValue(), yInterval.maxValue(), 5);

then I setup my zoomer

if(!m_zoomer)
{
m_zoomer = new MyZoomer(canvas());
}

m_zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home);

The plot has the X, Y axes I want when it starts but after zooming and returning to the default view through the Home key the axes do not return to the setting above.

This is all being done in a class derived from QwtPlot like in the Qwt examples.

Uwe
16th September 2014, 08:28
In cases where you don't create the zoomer - probably all beside the first one - you have to reinitialize the zoom base:


m_zoomer->setZoomBase( true );Uwe

john_k
16th September 2014, 13:15
Hi Uwe, thanks again for your response.

Here is what I have done and it works.

void MySurfacePlott::keyReleaseEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Home)
{
const QwtInterval xInterval = m_spectrogram->data()->interval( Qt::XAxis );
setAxisScale(xBottom, xInterval.minValue(), xInterval.maxValue(), 20);

const QwtInterval yInterval = m_spectrogram->data()->interval( Qt::YAxis );
setAxisScale(yLeft, yInterval.minValue(), yInterval.maxValue(), 5);

m_zoomer->setZoomBase( true );

}

QwtPlot::keyReleaseEvent(event);
}