PDA

View Full Version : Multiple axes with a relation



pkj
21st February 2011, 04:40
I have an x axis which has its units in metres. I want to attach another x axes which shows units in foot. Right now I have 2 curves, 1 for each of the axes, getting painted one over the other.
Is it possible to have 2 axes with a known relation(like foot - metre) and have a single curve?

Uwe
21st February 2011, 06:46
class YourPlot: public QwtPlot
{
YourPlot( ... ):
QwtPlot( ... )
{
....
enableAxis( QwtPlot::xTop );
connect( axisWidget( QwtPlot::xBottom ),
SIGNAL( scaleDivChanged() ), SLOT( syncScales() ) );
}

void syncScales()
{
const QwtScaleDiv scaleDiv = axisScaleDiv( QwtPlot::xBottom );

const double min = scaleDiv.lowerBound() * ...;
const double max = scaleDiv.upperBound() * ...;

setAxisScale( QwtPlot::xTop, min, max );
}
}
Then attach your curve to xBottom.

Uwe