Skip to content
Permalink
Browse files

Fixed #1706.

git-svn-id: http://svn.osgeo.org/qgis/trunk@10896 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jun 9, 2009
1 parent 18dd732 commit 43202ab685d33575fc5d60fc0363222cc90e1250
@@ -93,8 +93,9 @@ class QgsMapCanvas : QGraphicsView
//! Zoom to the next extent (view)
void zoomToNextExtent();

/**Zooms to the extend of the selected features*/
void zoomToSelected();
/** Zoom to the extent of the selected features of current (vector) layer.
Added in version 1.2: optionally specify different than current layer */
void zoomToSelected(QgsVectorLayer* layer = NULL);

/** \brief Sets the map tool currently being used on the canvas */
void setMapTool(QgsMapTool* mapTool);
@@ -30,6 +30,7 @@
#include "qgisapp.h"
#include "qgssearchquerybuilder.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"


class QgsAttributeTableTableDock : public QDockWidget
@@ -201,7 +202,7 @@ void QgsAttributeTableDialog::on_mCopySelectedRowsButton_clicked()

void QgsAttributeTableDialog::on_mZoomMapToSelectedRowsButton_clicked()
{
QgisApp::instance()->zoomToSelected();
QgisApp::instance()->mapCanvas()->zoomToSelected(mLayer);
}

void QgsAttributeTableDialog::on_mInvertSelectionButton_clicked()
@@ -613,18 +613,22 @@ void QgsMapCanvas::mapUnitsChanged()
refresh();
}

void QgsMapCanvas::zoomToSelected()
void QgsMapCanvas::zoomToSelected(QgsVectorLayer* layer)
{
if ( mDrawing )
{
return;
}

QgsVectorLayer *lyr = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
if (layer == NULL)
{
// use current layer by default
layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
}

if ( lyr )
if ( layer )
{
QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( lyr, lyr->boundingBoxOfSelected() );
QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );

// no selected features, only one selected point feature
//or two point features with the same x- or y-coordinates
@@ -49,6 +49,7 @@ class QgsMapLayer;
class QgsLegend;
class QgsLegendView;
class QgsRubberBand;
class QgsVectorLayer;

class QgsMapRenderer;
class QgsMapCanvasMap;
@@ -146,8 +147,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Zoom to the Next extent (view)
void zoomToNextExtent();

/**Zooms to the extend of the selected features*/
void zoomToSelected();
/** Zoom to the extent of the selected features of current (vector) layer.
Added in version 1.2: optionally specify different than current layer */
void zoomToSelected(QgsVectorLayer* layer = NULL);

/** \brief Sets the map tool currently being used on the canvas */
void setMapTool( QgsMapTool* mapTool );

0 comments on commit 43202ab

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