From 8134d51cfae00a02334cadee4a2c0ce6ed229a35 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 9 Aug 2006 12:26:14 +0000 Subject: [PATCH] Fix for bug IPAL8977(3.0.0: Add funcitonality for operating of viewer actions by buttons). --- src/Plot2d/Plot2d_ViewFrame.cxx | 129 ++++++++++++++++++++++++-------- src/Plot2d/Plot2d_ViewFrame.h | 10 +++ 2 files changed, 107 insertions(+), 32 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index f7b862f7b..35b590480 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -1414,6 +1414,7 @@ void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me ) parent()->eventFilter(this, aEvent); } } + setFocus(); } /*! Slot, called when user moves mouse @@ -1425,41 +1426,11 @@ void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me ) if ( myOperation != NoOpId) { if ( myOperation == ZoomId ) { - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); - - myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2() + dy ) ); - myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - dx ) ); - if (mySecondY) { - QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); - myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), - myPlot->invTransform( QwtPlot::yRight, y2Map.i2() + dy ) ); - } - myPlot->replot(); + this->incrementalZoom( dx, dy ); myPnt = me.pos(); } else if ( myOperation == PanId ) { - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); - - myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-dy ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-dy ) ); - myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-dx ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-dx ) ); - if (mySecondY) { - QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); - myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, y2Map.i1()-dy ), - myPlot->invTransform( QwtPlot::yRight, y2Map.i2()-dy ) ); - } - myPlot->replot(); + this->incrementalPan( dx, dy ); myPnt = me.pos(); } } @@ -1980,3 +1951,97 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); } } + +/*! + Incremental zooming operation +*/ +void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) { + QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + + myPlot->setAxisScale( QwtPlot::yLeft, + myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-incrY ), + myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-incrY ) ); + myPlot->setAxisScale( QwtPlot::xBottom, + myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-incrX ), + myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-incrX ) ); + if (mySecondY) { + QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); + myPlot->setAxisScale( QwtPlot::yRight, + myPlot->invTransform( QwtPlot::yRight, y2Map.i1()-incrY ), + myPlot->invTransform( QwtPlot::yRight, y2Map.i2()-incrY ) ); + } + myPlot->replot(); +} + +/*! + Incremental panning operation +*/ +void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) { + QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + + myPlot->setAxisScale( QwtPlot::yLeft, + myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), + myPlot->invTransform( QwtPlot::yLeft, yMap.i2() + incrY ) ); + myPlot->setAxisScale( QwtPlot::xBottom, + myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), + myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - incrX ) ); + if (mySecondY) { + QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); + myPlot->setAxisScale( QwtPlot::yRight, + myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), + myPlot->invTransform( QwtPlot::yRight, y2Map.i2() + incrY ) ); + } + myPlot->replot(); +} + +#define INCREMENT_FOR_OP 10 + +/*! + Performs incremental panning to the left +*/ +void Plot2d_ViewFrame::onPanLeft() +{ + this->incrementalPan( -INCREMENT_FOR_OP, 0 ); +} + +/*! + Performs incremental panning to the right +*/ +void Plot2d_ViewFrame::onPanRight() +{ + this->incrementalPan( INCREMENT_FOR_OP, 0 ); +} + +/*! + Performs incremental panning to the top +*/ +void Plot2d_ViewFrame::onPanUp() +{ + this->incrementalPan( 0, -INCREMENT_FOR_OP ); +} + +/*! + Performs incremental panning to the bottom +*/ +void Plot2d_ViewFrame::onPanDown() +{ + this->incrementalPan( 0, INCREMENT_FOR_OP ); +} + +/*! + Performs incremental zooming in +*/ +void Plot2d_ViewFrame::onZoomIn() +{ + this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP ); +} + +/*! + Performs incremental zooming out +*/ +void Plot2d_ViewFrame::onZoomOut() +{ + this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP ); +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 2c38caf1d..6a6aaf171 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -121,6 +121,9 @@ public: QString getVisualParameters(); void setVisualParameters( const QString& parameters ); + void incrementalPan ( const int incrX, const int incrY ); + void incrementalZoom( const int incrX, const int incrY ); + protected: int testOperation( const QMouseEvent& ); void readPreferences(); @@ -138,6 +141,13 @@ public slots: void onFitData(); void onChangeBackground(); + void onPanLeft(); + void onPanRight(); + void onPanUp(); + void onPanDown(); + void onZoomIn(); + void onZoomOut(); + protected slots: void plotMousePressed( const QMouseEvent& ); void plotMouseMoved( const QMouseEvent& ); -- 2.39.2