patch.txt

Patch for Zoom to previous, zoom to next - Dorofeev -, 2009-02-02 05:16 AM

Download (7.76 KB)

 
1
### Eclipse Workspace Patch 1.0
2
#P Release-1_0_0
3
Index: src/app/qgisappinterface.cpp
4
===================================================================
5
--- src/app/qgisappinterface.cpp	(revision 10051)
6
+++ src/app/qgisappinterface.cpp	(working copy)
7
@@ -219,6 +219,7 @@
8
 QAction *QgisAppInterface::actionZoomToLayer() { return qgis->actionZoomToLayer(); }
9
 QAction *QgisAppInterface::actionZoomToSelected() { return qgis->actionZoomToSelected(); }
10
 QAction *QgisAppInterface::actionZoomLast() { return qgis->actionZoomLast(); }
11
+QAction *QgisAppInterface::actionZoomNext() { return qgis->actionZoomNext(); }
12
 QAction *QgisAppInterface::actionZoomActualSize() { return qgis->actionZoomActualSize(); }
13
 QAction *QgisAppInterface::actionViewSeparator2() { return qgis->actionViewSeparator2(); }
14
 QAction *QgisAppInterface::actionMapTips() { return qgis->actionMapTips(); }
15
Index: src/gui/qgsmapcanvas.h
16
===================================================================
17
--- src/gui/qgsmapcanvas.h	(revision 10051)
18
+++ src/gui/qgsmapcanvas.h	(working copy)
19
@@ -29,6 +29,7 @@
20
 
21
 #include <QDomDocument>
22
 #include <QGraphicsView>
23
+#include <QtCore>
24
 
25
 class QWheelEvent;
26
 class QPixmap;
27
@@ -142,6 +143,9 @@
28
     //! Zoom to the previous extent (view)
29
     void zoomToPreviousExtent();
30
 
31
+    //! Zoom to the Next extent (view)
32
+    void zoomToNextExtent();
33
+
34
     /**Zooms to the extend of the selected features*/
35
     void zoomToSelected();
36
 
37
@@ -412,7 +416,8 @@
38
     QgsMapTool* mLastNonZoomMapTool;
39
 
40
     //! recently used extent
41
-    QgsRectangle mLastExtent;
42
+    QList <QgsRectangle> mLastExtent;
43
+    int mLastExtentIndex;
44
 
45
     //! Scale factor multiple for default zoom in/out
46
     double mWheelZoomFactor;
47
Index: src/app/qgisapp.cpp
48
===================================================================
49
--- src/app/qgisapp.cpp	(revision 10051)
50
+++ src/app/qgisapp.cpp	(working copy)
51
@@ -723,6 +723,10 @@
52
   mActionZoomLast->setStatusTip( tr( "Zoom to Last Extent" ) );
53
   connect( mActionZoomLast, SIGNAL( triggered() ), this, SLOT( zoomToPrevious() ) );
54
 
55
+  mActionZoomNext = new QAction( getThemeIcon( "mActionZoomNext.png" ), tr( "Zoom Next" ), this );
56
+  mActionZoomNext->setStatusTip( tr( "Zoom to Forward Extent" ) );
57
+  connect( mActionZoomNext, SIGNAL( triggered() ), this, SLOT( zoomToNext() ) );
58
+
59
   mActionZoomActualSize = new QAction( tr( "Zoom Actual Size" ), this );
60
   mActionZoomActualSize->setStatusTip( tr( "Zoom to Actual Size" ) );
61
   connect( mActionZoomActualSize, SIGNAL( triggered() ), this, SLOT( zoomActualSize() ) );
62
@@ -1085,6 +1089,7 @@
63
   mViewMenu->addAction( mActionZoomToLayer );
64
   mViewMenu->addAction( mActionZoomToSelected );
65
   mViewMenu->addAction( mActionZoomLast );
66
+  mViewMenu->addAction( mActionZoomNext );
67
   mViewMenu->addAction( mActionZoomActualSize );
68
   mActionViewSeparator2 = mViewMenu->addSeparator();
69
 
70
@@ -1255,6 +1260,7 @@
71
   mMapNavToolBar->addAction( mActionZoomToSelected );
72
   mMapNavToolBar->addAction( mActionZoomToLayer );
73
   mMapNavToolBar->addAction( mActionZoomLast );
74
+  mMapNavToolBar->addAction( mActionZoomNext );
75
   mMapNavToolBar->addAction( mActionDraw );
76
   mToolbarMenu->addAction( mMapNavToolBar->toggleViewAction() );
77
   //
78
@@ -1469,6 +1475,7 @@
79
   mActionZoomToSelected->setIcon( getThemeIcon( "/mActionZoomToSelected.png" ) );
80
   mActionPan->setIcon( getThemeIcon( "/mActionPan.png" ) );
81
   mActionZoomLast->setIcon( getThemeIcon( "/mActionZoomLast.png" ) );
82
+  mActionZoomNext->setIcon( getThemeIcon( "/mActionZoomNext.png" ) );
83
   mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
84
   mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
85
   mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
86
@@ -3602,6 +3609,14 @@
87
 
88
 }
89
 
90
+void QgisApp::zoomToNext()
91
+{
92
+  mMapCanvas->zoomToNextExtent();
93
+  // notify the project we've made a change
94
+  QgsProject::instance()->dirty( true );
95
+
96
+}
97
+
98
 void QgisApp::zoomActualSize()
99
 {
100
   mMapLegend->legendLayerZoomNative();
101
@@ -5559,4 +5574,3 @@
102
     return QPixmap( myDefaultPath );
103
   }
104
 }
105
-
106
Index: src/app/qgisappinterface.h
107
===================================================================
108
--- src/app/qgisappinterface.h	(revision 10051)
109
+++ src/app/qgisappinterface.h	(working copy)
110
@@ -178,6 +178,7 @@
111
     virtual QAction *actionZoomToLayer();
112
     virtual QAction *actionZoomToSelected();
113
     virtual QAction *actionZoomLast();
114
+    virtual QAction *actionZoomNext();
115
     virtual QAction *actionZoomActualSize();
116
     virtual QAction *actionViewSeparator2();
117
     virtual QAction *actionMapTips();
118
Index: src/app/qgisapp.h
119
===================================================================
120
--- src/app/qgisapp.h	(revision 10051)
121
+++ src/app/qgisapp.h	(working copy)
122
@@ -230,6 +230,7 @@
123
     QAction *actionZoomToLayer() { return mActionZoomToLayer; }
124
     QAction *actionZoomToSelected() { return mActionZoomToSelected; }
125
     QAction *actionZoomLast() { return mActionZoomLast; }
126
+    QAction *actionZoomNext() { return mActionZoomNext; }
127
     QAction *actionZoomActualSize() { return mActionZoomActualSize; }
128
     QAction *actionViewSeparator2() { return mActionViewSeparator2; }
129
     QAction *actionMapTips() { return mActionMapTips; }
130
@@ -320,6 +321,8 @@
131
     void zoomFull();
132
     //! Zoom to the previous extent
133
     void zoomToPrevious();
134
+    //! Zoom to the forward extent
135
+    void zoomToNext();
136
     //! Zoom to selected features
137
     void zoomToSelected();
138
 
139
@@ -689,6 +692,7 @@
140
     QAction *mActionZoomToLayer;
141
     QAction *mActionZoomToSelected;
142
     QAction *mActionZoomLast;
143
+    QAction *mActionZoomNext;
144
     QAction *mActionZoomActualSize;
145
     QAction *mActionViewSeparator2;
146
     QAction *mActionMapTips;
147
Index: images/themes/default/mActionZoomNext.png
148
===================================================================
149
Cannot display: file marked as a binary type.
150
svn:mime-type = application/octet-stream
151

    
152
Property changes on: images/themes/default/mActionZoomNext.png
153
___________________________________________________________________
154
Added: svn:mime-type
155
   + application/octet-stream
156

    
157
Index: src/gui/qgsmapcanvas.cpp
158
===================================================================
159
--- src/gui/qgsmapcanvas.cpp	(revision 10051)
160
+++ src/gui/qgsmapcanvas.cpp	(working copy)
161
@@ -82,7 +82,7 @@
162
   setScene( mScene );
163
   setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
164
   setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
165
-
166
+  mLastExtentIndex=-1;
167
   mCurrentLayer = NULL;
168
   mMapOverview = NULL;
169
   mMapTool = NULL;
170
@@ -464,8 +464,17 @@
171
   updateScale();
172
   if ( mMapOverview )
173
     mMapOverview->drawExtentRect();
174
-  mLastExtent = current;
175
+  if (mLastExtent.size()>20) mLastExtent.removeAt(0);
176
+
177
+  //clear all extent items after current index
178
+  for (int i=mLastExtent.size()-1; i>mLastExtentIndex; i--)
179
+  {
180
+	  mLastExtent.removeAt(i);
181
+  }
182
 
183
+
184
+  mLastExtent.append(extent()) ;
185
+  mLastExtentIndex=mLastExtent.size()-1;
186
   // notify canvas items of change
187
   updateCanvasItemPositions();
188
 
189
@@ -512,17 +521,43 @@
190
 
191
 void QgsMapCanvas::zoomToPreviousExtent()
192
 {
193
-  if ( mDrawing )
194
-  {
195
-    return;
196
-  }
197
+	 if ( mDrawing )
198
+	 {
199
+    	return;
200
+	 }
201
+
202
+	if (mLastExtentIndex>1)
203
+	{
204
+		mLastExtentIndex--;
205
+		mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
206
+		emit extentsChanged();
207
+		updateScale();
208
+		if ( mMapOverview )
209
+			 mMapOverview->drawExtentRect();
210
+	}
211
 
212
-  QgsRectangle current = extent();
213
-  setExtent( mLastExtent );
214
-  mLastExtent = current;
215
   refresh();
216
 } // zoomToPreviousExtent
217
 
218
+void QgsMapCanvas::zoomToNextExtent()
219
+{
220
+	if ( mDrawing )
221
+	{
222
+	    return;
223
+	}
224
+	if (mLastExtentIndex<mLastExtent.size()-1)
225
+	{
226
+		mLastExtentIndex++;
227
+		mMapRenderer->setExtent(mLastExtent[mLastExtentIndex]);
228
+		emit extentsChanged();
229
+		updateScale();
230
+		  if ( mMapOverview )
231
+		    mMapOverview->drawExtentRect();
232
+	}
233
+	refresh();
234
+}// zoomToNextExtent
235
+
236
+
237
 
238
 bool QgsMapCanvas::hasCrsTransformEnabled()
239
 {