Skip to content
Permalink
Browse files

Code cleanup

  • Loading branch information
TurboGraphxBeige authored and nyalldawson committed Jan 5, 2021
1 parent f3476a5 commit 69154c2bb8e3b6b93a084067eb9cb58836af34cd
@@ -21,6 +21,7 @@




class QgsMapCanvas : QGraphicsView
{
%Docstring
@@ -285,6 +286,13 @@ Centers canvas extent to feature ids
void panToSelected( QgsVectorLayer *layer = 0 );
%Docstring
Pan to the selected features of current (vector) layer keeping same extent.
%End

void panToAllSelected( const QList<QgsMapLayer *> *layers );
%Docstring
Pan to the combined extent of the selected features of all provided (vector) layers.

:param layers: A list of layers
%End

void flashFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids,
@@ -952,6 +960,13 @@ Zoom out with fixed factor
Zoom to the extent of the selected features of provided (vector) layer.

:param layer: optionally specify different than current layer
%End

void zoomToAllSelected( const QList<QgsMapLayer *> *layers );
%Docstring
Zoom to the combined extent of the selected features of all provided (vector) layers.

:param layers: A list of layers
%End

void setZoomResolutions( const QList<double> &resolutions );
@@ -8198,7 +8198,7 @@ void QgisApp::zoomToSelected()
QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();

if ( layers.size() > 1 && !layers.isEmpty() )
mMapCanvas->zoomToAllSelected(&layers);
mMapCanvas->zoomToAllSelected( &layers );

else
mMapCanvas->zoomToSelected();
@@ -8207,16 +8207,16 @@ void QgisApp::zoomToSelected()

void QgisApp::zoomToAllSelected()
{
const QList<QgsMapLayer *> layers = mMapCanvas->layers();
mMapCanvas->zoomToAllSelected(&layers);
const QList<QgsMapLayer *> layers = mMapCanvas->layers();
mMapCanvas->zoomToAllSelected( &layers );
}

void QgisApp::panToSelected()
{
QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();

if ( layers.size() > 1 && !layers.isEmpty() )
mMapCanvas->panToAllSelected(&layers);
mMapCanvas->panToAllSelected( &layers );

else
mMapCanvas->panToSelected();
@@ -8225,7 +8225,7 @@ void QgisApp::panToSelected()
void QgisApp::panToAllSelected()
{
const QList<QgsMapLayer *> layers = mMapCanvas->layers();
mMapCanvas->panToAllSelected(&layers);
mMapCanvas->panToAllSelected( &layers );
}

void QgisApp::pan()
@@ -161,18 +161,18 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
for ( int i = 0; i < selectedLayers.size(); ++i )
{
QgsMapLayer *layer = selectedLayers.at( i );
QgsVectorLayer *vLayer;
if (layer->type() == QgsMapLayerType(0) )

if ( layer->type() == QgsMapLayerType( 0 ) )
{
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );

if ( !vLayer->selectedFeatureIds().isEmpty() )
{
hasSelectedFeature = TRUE;
hasSelectedFeature = true;
break;
}
else
hasSelectedFeature = FALSE;
hasSelectedFeature = false;
}

}
@@ -314,16 +314,16 @@ void QgsLayerTreeViewDefaultActions::zoomToSelection( QgsMapCanvas *canvas )
{
QgsVectorLayer *layer;

if ( mView->currentLayer()->type() == QgsMapLayerType(0) )
if ( mView->currentLayer()->type() == QgsMapLayerType( 0 ) )
layer = qobject_cast<QgsVectorLayer *>( mView->currentLayer() );

QList<QgsMapLayer *> layers = mView->selectedLayers();

if ( layers.size() > 1 && !layers.isEmpty() )
canvas->zoomToAllSelected(&layers);
canvas->zoomToAllSelected( &layers );

else if ( layers.size() <= 1 && layer)
canvas->zoomToSelected(layer);
else if ( layers.size() <= 1 && layer )
canvas->zoomToSelected( layer );

}

@@ -1349,32 +1349,32 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
zoomToFeatureExtent( rect );
}

void QgsMapCanvas::zoomToAllSelected(const QList<QgsMapLayer *> *layers) {

void QgsMapCanvas::zoomToAllSelected( const QList<QgsMapLayer *> *layers )
{
QgsVectorLayer *layer;

QgsRectangle rect;
rect.setMinimal();
QgsRectangle selectionExtent;
selectionExtent.setMinimal();

for (int i = 0; i < layers->size(); ++i) {
if ( layers->at(i)->type() == QgsMapLayerType(0) )
layer = qobject_cast<QgsVectorLayer *>(layers->at(i));
for ( int i = 0; i < layers->size(); ++i )
{
if ( layers->at( i )->type() == QgsMapLayerType( 0 ) )
layer = qobject_cast<QgsVectorLayer *>( layers->at( i ) );

if (!layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0)
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
continue;

rect = layer->boundingBoxOfSelected();

if (rect.isNull())
if ( rect.isNull() )
continue;

rect = mapSettings().layerExtentToOutputExtent(layer, rect);
rect = mapSettings().layerExtentToOutputExtent( layer, rect );

if (layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty()) {
rect = optimalExtentForPointLayer(layer, rect.center());
}
if ( layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty() )
rect = optimalExtentForPointLayer( layer, rect.center() );

selectionExtent.combineExtentWith( rect );
}
@@ -1548,23 +1548,23 @@ void QgsMapCanvas::panToAllSelected( const QList<QgsMapLayer *> *layers )
QgsRectangle selectionExtent;
selectionExtent.setMinimal();

for (int i = 0; i < layers->size(); ++i) {
if ( layers->at(i)->type() == QgsMapLayerType(0) )
layer = qobject_cast<QgsVectorLayer *>(layers->at(i));
for ( int i = 0; i < layers->size(); ++i )
{
if ( layers->at( i )->type() == QgsMapLayerType( 0 ) )
layer = qobject_cast<QgsVectorLayer *>( layers->at( i ) );

if (!layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0)
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
continue;

rect = layer->boundingBoxOfSelected();

if (rect.isNull())
if ( rect.isNull() )
continue;

rect = mapSettings().layerExtentToOutputExtent(layer, rect);
rect = mapSettings().layerExtentToOutputExtent( layer, rect );

if (layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty()) {
rect = optimalExtentForPointLayer(layer, rect.center());
}
if ( layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty() )
rect = optimalExtentForPointLayer( layer, rect.center() );

selectionExtent.combineExtentWith( rect );
}

0 comments on commit 69154c2

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