Skip to content
Permalink
Browse files

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/qgis@10588 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman
gsherman committed Apr 18, 2009
1 parent 2a6a4c5 commit b02229baca1e8306ef50189e3163d65f30c13bcc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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;

@@ -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();

@@ -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() ) );
@@ -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();

@@ -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() );
//
@@ -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" ) );
@@ -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();
@@ -5807,4 +5822,3 @@ QPixmap QgisApp::getThemePixmap( const QString theName )
return QPixmap( myDefaultPath );
}
}

@@ -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; }
@@ -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();

@@ -711,6 +714,7 @@ class QgisApp : public QMainWindow
QAction *mActionZoomToLayer;
QAction *mActionZoomToSelected;
QAction *mActionZoomLast;
QAction *mActionZoomNext;
QAction *mActionZoomActualSize;
QAction *mActionViewSeparator2;
QAction *mActionMapTips;
@@ -55,6 +55,11 @@ void QgisAppInterface::zoomToPrevious()
qgis->zoomToPrevious();
}

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

void QgisAppInterface::zoomToActiveLayer()
{
qgis->zoomToLayerExtent();
@@ -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(); }
@@ -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();

@@ -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();
@@ -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;

@@ -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;
@@ -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();

@@ -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()
{
@@ -29,6 +29,7 @@

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

class QWheelEvent;
class QPixmap;
@@ -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();

@@ -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;

0 comments on commit b02229b

Please sign in to comment.
You can’t perform that action at this time.