File tree 4 files changed +17
-9
lines changed
4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -93,8 +93,9 @@ class QgsMapCanvas : QGraphicsView
93
93
//! Zoom to the next extent (view)
94
94
void zoomToNextExtent();
95
95
96
- /**Zooms to the extend of the selected features*/
97
- void zoomToSelected();
96
+ /** Zoom to the extent of the selected features of current (vector) layer.
97
+ Added in version 1.2: optionally specify different than current layer */
98
+ void zoomToSelected(QgsVectorLayer* layer = NULL);
98
99
99
100
/** \brief Sets the map tool currently being used on the canvas */
100
101
void setMapTool(QgsMapTool* mapTool);
Original file line number Diff line number Diff line change 30
30
#include " qgisapp.h"
31
31
#include " qgssearchquerybuilder.h"
32
32
#include " qgslogger.h"
33
+ #include " qgsmapcanvas.h"
33
34
34
35
35
36
class QgsAttributeTableTableDock : public QDockWidget
@@ -201,7 +202,7 @@ void QgsAttributeTableDialog::on_mCopySelectedRowsButton_clicked()
201
202
202
203
void QgsAttributeTableDialog::on_mZoomMapToSelectedRowsButton_clicked ()
203
204
{
204
- QgisApp::instance ()->zoomToSelected ();
205
+ QgisApp::instance ()->mapCanvas ()-> zoomToSelected (mLayer );
205
206
}
206
207
207
208
void QgsAttributeTableDialog::on_mInvertSelectionButton_clicked ()
Original file line number Diff line number Diff line change @@ -613,18 +613,22 @@ void QgsMapCanvas::mapUnitsChanged()
613
613
refresh ();
614
614
}
615
615
616
- void QgsMapCanvas::zoomToSelected ()
616
+ void QgsMapCanvas::zoomToSelected (QgsVectorLayer* layer )
617
617
{
618
618
if ( mDrawing )
619
619
{
620
620
return ;
621
621
}
622
622
623
- QgsVectorLayer *lyr = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
623
+ if (layer == NULL )
624
+ {
625
+ // use current layer by default
626
+ layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
627
+ }
624
628
625
- if ( lyr )
629
+ if ( layer )
626
630
{
627
- QgsRectangle rect = mMapRenderer ->layerExtentToOutputExtent ( lyr, lyr ->boundingBoxOfSelected () );
631
+ QgsRectangle rect = mMapRenderer ->layerExtentToOutputExtent ( layer, layer ->boundingBoxOfSelected () );
628
632
629
633
// no selected features, only one selected point feature
630
634
// or two point features with the same x- or y-coordinates
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class QgsMapLayer;
49
49
class QgsLegend ;
50
50
class QgsLegendView ;
51
51
class QgsRubberBand ;
52
+ class QgsVectorLayer ;
52
53
53
54
class QgsMapRenderer ;
54
55
class QgsMapCanvasMap ;
@@ -146,8 +147,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
146
147
// ! Zoom to the Next extent (view)
147
148
void zoomToNextExtent ();
148
149
149
- /* *Zooms to the extend of the selected features*/
150
- void zoomToSelected ();
150
+ /* * Zoom to the extent of the selected features of current (vector) layer.
151
+ Added in version 1.2: optionally specify different than current layer */
152
+ void zoomToSelected (QgsVectorLayer* layer = NULL );
151
153
152
154
/* * \brief Sets the map tool currently being used on the canvas */
153
155
void setMapTool ( QgsMapTool* mapTool );
You can’t perform that action at this time.
0 commit comments