I am currently trying to allow two plots (each with the same starting x and y axes and zoom base) to zoom the same amount regardless of which plot is being zoomed in or out.
Currently I have the code below:
zoomerA->setMaxStackDepth(5);
zoomerB->setMaxStackDepth(5);
connect(zoomerA,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateBZoom()));
connect(zoomerB,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateAZoom()));
zoomerA = new QwtPlotZoomer(plotA->canvas());
zoomerA->setMaxStackDepth(5);
zoomerB = new QwtPlotZoomer(plotB->canvas());
zoomerB->setMaxStackDepth(5);
connect(zoomerA,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateBZoom()));
connect(zoomerB,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateAZoom()));
To copy to clipboard, switch view to plain text mode
void graphPage::updateBZoom()
{
zoomerB->setZoomStack(zoomerA->zoomStack(),zoomerA->zoomRectIndex());
}
void graphPage::updateAZoom()
{ zoomerA->setZoomStack(zoomerB->zoomStack(),zoomerB->zoomRectIndex());
}
void graphPage::updateBZoom()
{
zoomerB->setZoomStack(zoomerA->zoomStack(),zoomerA->zoomRectIndex());
}
void graphPage::updateAZoom()
{ zoomerA->setZoomStack(zoomerB->zoomStack(),zoomerB->zoomRectIndex());
}
To copy to clipboard, switch view to plain text mode
With this code it almost works until you get to the last rect in the stack. setZoomStack fails since zoomStack.count() == maxStackDepth() + 1 at this point.
Is this as simple as changing the code in the setZoomStack function from:
if ( d_data->maxStackDepth >= 0 &&
int(zoomStack.count()) > d_data->maxStackDepth )
{
return;
}
if ( d_data->maxStackDepth >= 0 &&
int(zoomStack.count()) > d_data->maxStackDepth )
{
return;
}
To copy to clipboard, switch view to plain text mode
to
if ( d_data->maxStackDepth >= 0 &&
int(zoomStack.count()) > d_data->maxStackDepth + 1 )
{
return;
}
if ( d_data->maxStackDepth >= 0 &&
int(zoomStack.count()) > d_data->maxStackDepth + 1 )
{
return;
}
To copy to clipboard, switch view to plain text mode
Or am I going about this completely the wrong way?
Bookmarks