Skip to content

Commit

Permalink
Applied patch from ticket #1522 for Zoom Next functionality.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gsherman committed Apr 18, 2009
1 parent 5773a2b commit 598677b
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 11 deletions.
Binary file added images/themes/classic/mActionZoomNext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/default/mActionZoomNext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/gis/mActionZoomNext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/nkids/mActionZoomNext.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -32,6 +32,8 @@ class QgisInterface : QObject
virtual void zoomFull()=0;
//! Zoom to previous view extent
virtual void zoomToPrevious()=0;
//! Zoom to next view extent
virtual void zoomToNext()=0;
//! Zoome to extent of the active layer
virtual void zoomToActiveLayer()=0;

Expand Down
3 changes: 3 additions & 0 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -90,6 +90,9 @@ class QgsMapCanvas : QGraphicsView
//! Zoom to the previous extent (view)
void zoomToPreviousExtent();

//! Zoom to the next extent (view)
void zoomToNextExtent();

/**Zooms to the extend of the selected features*/
void zoomToSelected();

Expand Down
16 changes: 15 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -724,6 +724,10 @@ void QgisApp::createActions()
mActionZoomLast->setStatusTip( tr( "Zoom to Last Extent" ) );
connect( mActionZoomLast, SIGNAL( triggered() ), this, SLOT( zoomToPrevious() ) );

mActionZoomNext = new QAction( getThemeIcon( "mActionZoomNext.png" ), tr( "Zoom Next" ), this );
mActionZoomNext->setStatusTip( tr( "Zoom to Forward Extent" ) );
connect( mActionZoomNext, SIGNAL( triggered() ), this, SLOT( zoomToNext() ) );

mActionZoomActualSize = new QAction( tr( "Zoom Actual Size" ), this );
mActionZoomActualSize->setStatusTip( tr( "Zoom to Actual Size" ) );
connect( mActionZoomActualSize, SIGNAL( triggered() ), this, SLOT( zoomActualSize() ) );
Expand Down Expand Up @@ -1098,6 +1102,7 @@ void QgisApp::createMenus()
mViewMenu->addAction( mActionZoomToLayer );
mViewMenu->addAction( mActionZoomToSelected );
mViewMenu->addAction( mActionZoomLast );
mViewMenu->addAction( mActionZoomNext );
mViewMenu->addAction( mActionZoomActualSize );
mActionViewSeparator2 = mViewMenu->addSeparator();

Expand Down Expand Up @@ -1274,6 +1279,7 @@ void QgisApp::createToolBars()
mMapNavToolBar->addAction( mActionZoomToSelected );
mMapNavToolBar->addAction( mActionZoomToLayer );
mMapNavToolBar->addAction( mActionZoomLast );
mMapNavToolBar->addAction( mActionZoomNext );
mMapNavToolBar->addAction( mActionDraw );
mToolbarMenu->addAction( mMapNavToolBar->toggleViewAction() );
//
Expand Down Expand Up @@ -1489,6 +1495,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionZoomToSelected->setIcon( getThemeIcon( "/mActionZoomToSelected.png" ) );
mActionPan->setIcon( getThemeIcon( "/mActionPan.png" ) );
mActionZoomLast->setIcon( getThemeIcon( "/mActionZoomLast.png" ) );
mActionZoomNext->setIcon( getThemeIcon( "/mActionZoomNext.png" ) );
mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
Expand Down Expand Up @@ -3856,6 +3863,14 @@ void QgisApp::zoomToPrevious()

}

void QgisApp::zoomToNext()
{
mMapCanvas->zoomToNextExtent();
// notify the project we've made a change
QgsProject::instance()->dirty( true );

}

void QgisApp::zoomActualSize()
{
mMapLegend->legendLayerZoomNative();
Expand Down Expand Up @@ -5807,4 +5822,3 @@ QPixmap QgisApp::getThemePixmap( const QString theName )
return QPixmap( myDefaultPath );
}
}

4 changes: 4 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -235,6 +235,7 @@ class QgisApp : public QMainWindow
QAction *actionZoomToLayer() { return mActionZoomToLayer; }
QAction *actionZoomToSelected() { return mActionZoomToSelected; }
QAction *actionZoomLast() { return mActionZoomLast; }
QAction *actionZoomNext() { return mActionZoomNext; }
QAction *actionZoomActualSize() { return mActionZoomActualSize; }
QAction *actionViewSeparator2() { return mActionViewSeparator2; }
QAction *actionMapTips() { return mActionMapTips; }
Expand Down Expand Up @@ -326,6 +327,8 @@ class QgisApp : public QMainWindow
void zoomFull();
//! Zoom to the previous extent
void zoomToPrevious();
//! Zoom to the forward extent
void zoomToNext();
//! Zoom to selected features
void zoomToSelected();

Expand Down Expand Up @@ -711,6 +714,7 @@ class QgisApp : public QMainWindow
QAction *mActionZoomToLayer;
QAction *mActionZoomToSelected;
QAction *mActionZoomLast;
QAction *mActionZoomNext;
QAction *mActionZoomActualSize;
QAction *mActionViewSeparator2;
QAction *mActionMapTips;
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -55,6 +55,11 @@ void QgisAppInterface::zoomToPrevious()
qgis->zoomToPrevious();
}

void QgisAppInterface::zoomToNext()
{
qgis->zoomToNext();
}

void QgisAppInterface::zoomToActiveLayer()
{
qgis->zoomToLayerExtent();
Expand Down Expand Up @@ -245,6 +250,7 @@ QAction *QgisAppInterface::actionZoomFullExtent() { return qgis->actionZoomFullE
QAction *QgisAppInterface::actionZoomToLayer() { return qgis->actionZoomToLayer(); }
QAction *QgisAppInterface::actionZoomToSelected() { return qgis->actionZoomToSelected(); }
QAction *QgisAppInterface::actionZoomLast() { return qgis->actionZoomLast(); }
QAction *QgisAppInterface::actionZoomNext() { return qgis->actionZoomNext(); }
QAction *QgisAppInterface::actionZoomActualSize() { return qgis->actionZoomActualSize(); }
QAction *QgisAppInterface::actionViewSeparator2() { return qgis->actionViewSeparator2(); }
QAction *QgisAppInterface::actionMapTips() { return qgis->actionMapTips(); }
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -47,6 +47,8 @@ class QgisAppInterface : public QgisInterface
void zoomFull();
//! Zoom map to previous extent
void zoomToPrevious();
//! Zoom map to next extent
void zoomToNext();
//! Zoom to active layer
void zoomToActiveLayer();

Expand Down Expand Up @@ -183,6 +185,7 @@ class QgisAppInterface : public QgisInterface
virtual QAction *actionZoomToLayer();
virtual QAction *actionZoomToSelected();
virtual QAction *actionZoomLast();
virtual QAction *actionZoomNext();
virtual QAction *actionZoomActualSize();
virtual QAction *actionViewSeparator2();
virtual QAction *actionMapTips();
Expand Down
3 changes: 3 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -71,6 +71,9 @@ class GUI_EXPORT QgisInterface : public QObject
//! Zoom to previous view extent
virtual void zoomToPrevious() = 0;

//! Zoom to next view extent
virtual void zoomToNext() = 0;

//! Zoom to extent of the active layer
virtual void zoomToActiveLayer() = 0;

Expand Down
53 changes: 44 additions & 9 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -85,7 +85,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
setScene( mScene );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

mLastExtentIndex=-1;
mCurrentLayer = NULL;
mMapOverview = NULL;
mMapTool = NULL;
Expand Down Expand Up @@ -493,8 +493,17 @@ void QgsMapCanvas::setExtent( QgsRectangle const & r )
updateScale();
if ( mMapOverview )
mMapOverview->drawExtentRect();
mLastExtent = current;
if (mLastExtent.size()>20) mLastExtent.removeAt(0);

//clear all extent items after current index
for (int i=mLastExtent.size()-1; i>mLastExtentIndex; i--)
{
mLastExtent.removeAt(i);
}


mLastExtent.append(extent()) ;
mLastExtentIndex=mLastExtent.size()-1;
// notify canvas items of change
updateCanvasItemPositions();

Expand Down Expand Up @@ -541,17 +550,43 @@ void QgsMapCanvas::zoomToFullExtent()

void QgsMapCanvas::zoomToPreviousExtent()
{
if ( mDrawing )
{
return;
}
if ( mDrawing )
{
return;
}

if (mLastExtentIndex>1)
{
mLastExtentIndex--;
mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
emit extentsChanged();
updateScale();
if ( mMapOverview )
mMapOverview->drawExtentRect();
}

QgsRectangle current = extent();
setExtent( mLastExtent );
mLastExtent = current;
refresh();
} // zoomToPreviousExtent

void QgsMapCanvas::zoomToNextExtent()
{
if ( mDrawing )
{
return;
}
if (mLastExtentIndex<mLastExtent.size()-1)
{
mLastExtentIndex++;
mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
emit extentsChanged();
updateScale();
if ( mMapOverview )
mMapOverview->drawExtentRect();
}
refresh();
}// zoomToNextExtent



bool QgsMapCanvas::hasCrsTransformEnabled()
{
Expand Down
7 changes: 6 additions & 1 deletion src/gui/qgsmapcanvas.h
Expand Up @@ -29,6 +29,7 @@

#include <QDomDocument>
#include <QGraphicsView>
#include <QtCore>

class QWheelEvent;
class QPixmap;
Expand Down Expand Up @@ -142,6 +143,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Zoom to the previous extent (view)
void zoomToPreviousExtent();

//! Zoom to the Next extent (view)
void zoomToNextExtent();

/**Zooms to the extend of the selected features*/
void zoomToSelected();

Expand Down Expand Up @@ -412,7 +416,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
QgsMapTool* mLastNonZoomMapTool;

//! recently used extent
QgsRectangle mLastExtent;
QList <QgsRectangle> mLastExtent;
int mLastExtentIndex;

//! Scale factor multiple for default zoom in/out
double mWheelZoomFactor;
Expand Down

0 comments on commit 598677b

Please sign in to comment.