I'm using QWT 6.0.1 RC5, QT 4.8.0
I added a QwtPlotPanner in a QwtPlot and I would like axes were moving simultaneously to the shift of the canvas and not only once the panner is finished.
Then I associated a slot to the signal move (int dx , int dy) of the QwtPlotPanner :
note :cart is a QwtPlot.
scaleMapTmpX.
setScaleInterval(cart
->axisScaleDiv
(QwtPlot::xBottom)->upperBound
(),
cart
->axisScaleDiv
(QwtPlot::xBottom)->lowerBound
());
scaleMapTmpY.
setScaleInterval(cart
->axisScaleDiv
(QwtPlot::yLeft)->upperBound
(),
cart
->axisScaleDiv
(QwtPlot::yLeft)->lowerBound
());
double zoomPlotDragLowerBoundX
= cart
->axisScaleDiv
(QwtPlot::xBottom)->lowerBound
();
double zoomPlotDragUpperBoundX
= cart
->axisScaleDiv
(QwtPlot::xBottom)->upperBound
();
double zoomPlotDragLowerBoundY
= cart
->axisScaleDiv
(QwtPlot::yLeft)->lowerBound
();
double zoomPlotDragUpperBoundY
= cart
->axisScaleDiv
(QwtPlot::yLeft)->upperBound
();
double LowerBoundX = scaleMapTmpX.transform(zoomPlotDragLowerBoundX);
double UpperBoundX = scaleMapTmpX.transform(zoomPlotDragUpperBoundX);
double LowerBoundY = scaleMapTmpY.transform(zoomPlotDragLowerBoundY);
double UpperBoundY = scaleMapTmpY.transform(zoomPlotDragUpperBoundY);
cart
->setAxisScale
(QwtPlot::yLeft, scaleMapTmpY.
invTransform(LowerBoundY
+ dy
) ,
scaleMapTmpY.invTransform(UpperBoundY + dy) );
cart
->setAxisScale
(QwtPlot::xBottom, scaleMapTmpX.
invTransform(LowerBoundX
+ dx
) ,
scaleMapTmpX.invTransform(UpperBoundX + dx ));
cart->replot();
QwtScaleMap scaleMapTmpX = cart->canvasMap(QwtPlot::xBottom);
scaleMapTmpX.setScaleInterval(cart->axisScaleDiv(QwtPlot::xBottom)->upperBound(),
cart->axisScaleDiv(QwtPlot::xBottom)->lowerBound());
QwtScaleMap scaleMapTmpY = cart->canvasMap(QwtPlot::yLeft);
scaleMapTmpY.setScaleInterval(cart->axisScaleDiv(QwtPlot::yLeft)->upperBound(),
cart->axisScaleDiv(QwtPlot::yLeft)->lowerBound());
double zoomPlotDragLowerBoundX = cart->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
double zoomPlotDragUpperBoundX = cart->axisScaleDiv(QwtPlot::xBottom)->upperBound();
double zoomPlotDragLowerBoundY = cart->axisScaleDiv(QwtPlot::yLeft)->lowerBound();
double zoomPlotDragUpperBoundY = cart->axisScaleDiv(QwtPlot::yLeft)->upperBound();
double LowerBoundX = scaleMapTmpX.transform(zoomPlotDragLowerBoundX);
double UpperBoundX = scaleMapTmpX.transform(zoomPlotDragUpperBoundX);
double LowerBoundY = scaleMapTmpY.transform(zoomPlotDragLowerBoundY);
double UpperBoundY = scaleMapTmpY.transform(zoomPlotDragUpperBoundY);
cart->setAxisScale(QwtPlot::yLeft, scaleMapTmpY.invTransform(LowerBoundY + dy) ,
scaleMapTmpY.invTransform(UpperBoundY + dy) );
cart->setAxisScale(QwtPlot::xBottom, scaleMapTmpX.invTransform(LowerBoundX + dx) ,
scaleMapTmpX.invTransform(UpperBoundX + dx ));
cart->replot();
To copy to clipboard, switch view to plain text mode
In the posted code the axes aren't correctly redraw (in partular the shift isn't conveted in the right scale). Do you have a solution?
In the implementation of the signal move(int dx, int dy), dx and dy represent the offset in pixel or in another unit of measure?
Bookmarks