I experimented with two plots...
I subclassed QwtPlotZoomer (see below)
{
public:
{
}
virtual void zoom
( const QRectF & rc
) {
QwtInterval intv
= plot
()->axisInterval
(QwtPlot::xBottom);
_otherPlot
->setAxisScale
(QwtPlot::xBottom, intv.
minValue(), intv.
maxValue());
intv
= plot
()->axisInterval
(QwtPlot::yLeft);
_otherPlot
->setAxisScale
(QwtPlot::yLeft, intv.
minValue(), intv.
maxValue());
_otherPlot->replot();
}
private:
QwtPlot* _otherPlot;
//This could be list of plots };
class Zoomer : public QwtPlotZoomer
{
public:
Zoomer( QwtPlot* otherPlot, QWidget*w):QwtPlotZoomer(w), _otherPlot(otherPlot)
{
}
virtual void zoom( const QRectF & rc)
{
QwtPlotZoomer::zoom(rc);
QwtInterval intv = plot()->axisInterval (QwtPlot::xBottom);
_otherPlot->setAxisScale(QwtPlot::xBottom, intv.minValue(), intv.maxValue());
intv = plot()->axisInterval (QwtPlot::yLeft);
_otherPlot->setAxisScale(QwtPlot::yLeft, intv.minValue(), intv.maxValue());
_otherPlot->replot();
}
private:
QwtPlot* _otherPlot; //This could be list of plots
};
To copy to clipboard, switch view to plain text mode
Now the custom zoomer is aware of _otherPlot whose scale is adjusted should any zooming occur.
Clients of custom plot do...
QwtPlot * plot = new QwtPlot(this);
QwtPlot * plot1 = new QwtPlot(this);
...
...
Zoomer* z = new Zoomer(plot1, plot->canvas());
Zoomer* z1 = new Zoomer(plot, plot1->canvas());
I did not check this thoroughly.
Added after 1 48 minutes:
Clients of custom plot do...
Error...
This should read Clients of Zoomer do ...
Bookmarks