Skip to content

Commit 598677b

Browse files
author
gsherman
committed
Applied patch from ticket #1522 for Zoom Next functionality.
Includes icons for zoom next tool (same icon for all themes). git-svn-id: http://svn.osgeo.org/qgis/trunk@10588 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5773a2b commit 598677b

13 files changed

+86
-11
lines changed
2.07 KB
Loading
2.07 KB
Loading

images/themes/gis/mActionZoomNext.png

2.07 KB
Loading
2.07 KB
Loading

python/gui/qgisinterface.sip

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class QgisInterface : QObject
3232
virtual void zoomFull()=0;
3333
//! Zoom to previous view extent
3434
virtual void zoomToPrevious()=0;
35+
//! Zoom to next view extent
36+
virtual void zoomToNext()=0;
3537
//! Zoome to extent of the active layer
3638
virtual void zoomToActiveLayer()=0;
3739

python/gui/qgsmapcanvas.sip

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class QgsMapCanvas : QGraphicsView
9090
//! Zoom to the previous extent (view)
9191
void zoomToPreviousExtent();
9292

93+
//! Zoom to the next extent (view)
94+
void zoomToNextExtent();
95+
9396
/**Zooms to the extend of the selected features*/
9497
void zoomToSelected();
9598

src/app/qgisapp.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,10 @@ void QgisApp::createActions()
724724
mActionZoomLast->setStatusTip( tr( "Zoom to Last Extent" ) );
725725
connect( mActionZoomLast, SIGNAL( triggered() ), this, SLOT( zoomToPrevious() ) );
726726

727+
mActionZoomNext = new QAction( getThemeIcon( "mActionZoomNext.png" ), tr( "Zoom Next" ), this );
728+
mActionZoomNext->setStatusTip( tr( "Zoom to Forward Extent" ) );
729+
connect( mActionZoomNext, SIGNAL( triggered() ), this, SLOT( zoomToNext() ) );
730+
727731
mActionZoomActualSize = new QAction( tr( "Zoom Actual Size" ), this );
728732
mActionZoomActualSize->setStatusTip( tr( "Zoom to Actual Size" ) );
729733
connect( mActionZoomActualSize, SIGNAL( triggered() ), this, SLOT( zoomActualSize() ) );
@@ -1098,6 +1102,7 @@ void QgisApp::createMenus()
10981102
mViewMenu->addAction( mActionZoomToLayer );
10991103
mViewMenu->addAction( mActionZoomToSelected );
11001104
mViewMenu->addAction( mActionZoomLast );
1105+
mViewMenu->addAction( mActionZoomNext );
11011106
mViewMenu->addAction( mActionZoomActualSize );
11021107
mActionViewSeparator2 = mViewMenu->addSeparator();
11031108

@@ -1274,6 +1279,7 @@ void QgisApp::createToolBars()
12741279
mMapNavToolBar->addAction( mActionZoomToSelected );
12751280
mMapNavToolBar->addAction( mActionZoomToLayer );
12761281
mMapNavToolBar->addAction( mActionZoomLast );
1282+
mMapNavToolBar->addAction( mActionZoomNext );
12771283
mMapNavToolBar->addAction( mActionDraw );
12781284
mToolbarMenu->addAction( mMapNavToolBar->toggleViewAction() );
12791285
//
@@ -1489,6 +1495,7 @@ void QgisApp::setTheme( QString theThemeName )
14891495
mActionZoomToSelected->setIcon( getThemeIcon( "/mActionZoomToSelected.png" ) );
14901496
mActionPan->setIcon( getThemeIcon( "/mActionPan.png" ) );
14911497
mActionZoomLast->setIcon( getThemeIcon( "/mActionZoomLast.png" ) );
1498+
mActionZoomNext->setIcon( getThemeIcon( "/mActionZoomNext.png" ) );
14921499
mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
14931500
mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
14941501
mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
@@ -3856,6 +3863,14 @@ void QgisApp::zoomToPrevious()
38563863

38573864
}
38583865

3866+
void QgisApp::zoomToNext()
3867+
{
3868+
mMapCanvas->zoomToNextExtent();
3869+
// notify the project we've made a change
3870+
QgsProject::instance()->dirty( true );
3871+
3872+
}
3873+
38593874
void QgisApp::zoomActualSize()
38603875
{
38613876
mMapLegend->legendLayerZoomNative();
@@ -5807,4 +5822,3 @@ QPixmap QgisApp::getThemePixmap( const QString theName )
58075822
return QPixmap( myDefaultPath );
58085823
}
58095824
}
5810-

src/app/qgisapp.h

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class QgisApp : public QMainWindow
235235
QAction *actionZoomToLayer() { return mActionZoomToLayer; }
236236
QAction *actionZoomToSelected() { return mActionZoomToSelected; }
237237
QAction *actionZoomLast() { return mActionZoomLast; }
238+
QAction *actionZoomNext() { return mActionZoomNext; }
238239
QAction *actionZoomActualSize() { return mActionZoomActualSize; }
239240
QAction *actionViewSeparator2() { return mActionViewSeparator2; }
240241
QAction *actionMapTips() { return mActionMapTips; }
@@ -326,6 +327,8 @@ class QgisApp : public QMainWindow
326327
void zoomFull();
327328
//! Zoom to the previous extent
328329
void zoomToPrevious();
330+
//! Zoom to the forward extent
331+
void zoomToNext();
329332
//! Zoom to selected features
330333
void zoomToSelected();
331334

@@ -711,6 +714,7 @@ class QgisApp : public QMainWindow
711714
QAction *mActionZoomToLayer;
712715
QAction *mActionZoomToSelected;
713716
QAction *mActionZoomLast;
717+
QAction *mActionZoomNext;
714718
QAction *mActionZoomActualSize;
715719
QAction *mActionViewSeparator2;
716720
QAction *mActionMapTips;

src/app/qgisappinterface.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ void QgisAppInterface::zoomToPrevious()
5555
qgis->zoomToPrevious();
5656
}
5757

58+
void QgisAppInterface::zoomToNext()
59+
{
60+
qgis->zoomToNext();
61+
}
62+
5863
void QgisAppInterface::zoomToActiveLayer()
5964
{
6065
qgis->zoomToLayerExtent();
@@ -245,6 +250,7 @@ QAction *QgisAppInterface::actionZoomFullExtent() { return qgis->actionZoomFullE
245250
QAction *QgisAppInterface::actionZoomToLayer() { return qgis->actionZoomToLayer(); }
246251
QAction *QgisAppInterface::actionZoomToSelected() { return qgis->actionZoomToSelected(); }
247252
QAction *QgisAppInterface::actionZoomLast() { return qgis->actionZoomLast(); }
253+
QAction *QgisAppInterface::actionZoomNext() { return qgis->actionZoomNext(); }
248254
QAction *QgisAppInterface::actionZoomActualSize() { return qgis->actionZoomActualSize(); }
249255
QAction *QgisAppInterface::actionViewSeparator2() { return qgis->actionViewSeparator2(); }
250256
QAction *QgisAppInterface::actionMapTips() { return qgis->actionMapTips(); }

src/app/qgisappinterface.h

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class QgisAppInterface : public QgisInterface
4747
void zoomFull();
4848
//! Zoom map to previous extent
4949
void zoomToPrevious();
50+
//! Zoom map to next extent
51+
void zoomToNext();
5052
//! Zoom to active layer
5153
void zoomToActiveLayer();
5254

@@ -183,6 +185,7 @@ class QgisAppInterface : public QgisInterface
183185
virtual QAction *actionZoomToLayer();
184186
virtual QAction *actionZoomToSelected();
185187
virtual QAction *actionZoomLast();
188+
virtual QAction *actionZoomNext();
186189
virtual QAction *actionZoomActualSize();
187190
virtual QAction *actionViewSeparator2();
188191
virtual QAction *actionMapTips();

src/gui/qgisinterface.h

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class GUI_EXPORT QgisInterface : public QObject
7171
//! Zoom to previous view extent
7272
virtual void zoomToPrevious() = 0;
7373

74+
//! Zoom to next view extent
75+
virtual void zoomToNext() = 0;
76+
7477
//! Zoom to extent of the active layer
7578
virtual void zoomToActiveLayer() = 0;
7679

src/gui/qgsmapcanvas.cpp

+44-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
8585
setScene( mScene );
8686
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
8787
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
88-
88+
mLastExtentIndex=-1;
8989
mCurrentLayer = NULL;
9090
mMapOverview = NULL;
9191
mMapTool = NULL;
@@ -493,8 +493,17 @@ void QgsMapCanvas::setExtent( QgsRectangle const & r )
493493
updateScale();
494494
if ( mMapOverview )
495495
mMapOverview->drawExtentRect();
496-
mLastExtent = current;
496+
if (mLastExtent.size()>20) mLastExtent.removeAt(0);
497+
498+
//clear all extent items after current index
499+
for (int i=mLastExtent.size()-1; i>mLastExtentIndex; i--)
500+
{
501+
mLastExtent.removeAt(i);
502+
}
503+
497504

505+
mLastExtent.append(extent()) ;
506+
mLastExtentIndex=mLastExtent.size()-1;
498507
// notify canvas items of change
499508
updateCanvasItemPositions();
500509

@@ -541,17 +550,43 @@ void QgsMapCanvas::zoomToFullExtent()
541550

542551
void QgsMapCanvas::zoomToPreviousExtent()
543552
{
544-
if ( mDrawing )
545-
{
546-
return;
547-
}
553+
if ( mDrawing )
554+
{
555+
return;
556+
}
557+
558+
if (mLastExtentIndex>1)
559+
{
560+
mLastExtentIndex--;
561+
mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
562+
emit extentsChanged();
563+
updateScale();
564+
if ( mMapOverview )
565+
mMapOverview->drawExtentRect();
566+
}
548567

549-
QgsRectangle current = extent();
550-
setExtent( mLastExtent );
551-
mLastExtent = current;
552568
refresh();
553569
} // zoomToPreviousExtent
554570

571+
void QgsMapCanvas::zoomToNextExtent()
572+
{
573+
if ( mDrawing )
574+
{
575+
return;
576+
}
577+
if (mLastExtentIndex<mLastExtent.size()-1)
578+
{
579+
mLastExtentIndex++;
580+
mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
581+
emit extentsChanged();
582+
updateScale();
583+
if ( mMapOverview )
584+
mMapOverview->drawExtentRect();
585+
}
586+
refresh();
587+
}// zoomToNextExtent
588+
589+
555590

556591
bool QgsMapCanvas::hasCrsTransformEnabled()
557592
{

src/gui/qgsmapcanvas.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <QDomDocument>
3131
#include <QGraphicsView>
32+
#include <QtCore>
3233

3334
class QWheelEvent;
3435
class QPixmap;
@@ -142,6 +143,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
142143
//! Zoom to the previous extent (view)
143144
void zoomToPreviousExtent();
144145

146+
//! Zoom to the Next extent (view)
147+
void zoomToNextExtent();
148+
145149
/**Zooms to the extend of the selected features*/
146150
void zoomToSelected();
147151

@@ -412,7 +416,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
412416
QgsMapTool* mLastNonZoomMapTool;
413417

414418
//! recently used extent
415-
QgsRectangle mLastExtent;
419+
QList <QgsRectangle> mLastExtent;
420+
int mLastExtentIndex;
416421

417422
//! Scale factor multiple for default zoom in/out
418423
double mWheelZoomFactor;

0 commit comments

Comments
 (0)