@@ -1677,15 +1677,15 @@ void QgsLegend::zoomToLayerExtent()
1677
1677
// find current Layer
1678
1678
QgsLegendLayer* currentLayer=dynamic_cast <QgsLegendLayer*>(currentItem ());
1679
1679
if (!currentLayer)
1680
- {
1681
- return ;
1682
- }
1680
+ {
1681
+ return ;
1682
+ }
1683
1683
1684
1684
std::list<QgsLegendLayerFile*> layerFiles = currentLayer->legendLayerFiles ();
1685
1685
if (layerFiles.size () == 0 )
1686
- {
1687
- return ;
1688
- }
1686
+ {
1687
+ return ;
1688
+ }
1689
1689
1690
1690
double xmin = DBL_MAX;
1691
1691
double ymin = DBL_MAX;
@@ -1698,42 +1698,45 @@ void QgsLegend::zoomToLayerExtent()
1698
1698
QgsMapLayer* theLayer;
1699
1699
1700
1700
for (std::list<QgsLegendLayerFile*>::iterator it= layerFiles.begin (); it != layerFiles.end (); ++it)
1701
+ {
1702
+ theLayer = (*it)->layer ();
1703
+ if (theLayer)
1701
1704
{
1702
- theLayer = (*it)->layer ();
1703
- if (theLayer)
1704
- {
1705
- layerExtent = theLayer->extent ();
1705
+ layerExtent = theLayer->extent ();
1706
1706
1707
1707
if (QgsProject::instance ()->readNumEntry (" SpatialRefSys" , " /ProjectionsEnabled" ,0 ) != 0
1708
1708
&& (ct = theLayer->coordinateTransform ()))
1709
1709
{
1710
- // transform layer extent to canvas coordinate system
1711
- transformedExtent = ct->transform (layerExtent);
1712
- }
1713
- else
1714
- {
1710
+ // transform layer extent to canvas coordinate system
1711
+ transformedExtent = ct->transform (layerExtent);
1712
+ }
1713
+ else
1714
+ {
1715
1715
// do not transform when projections are not enabled
1716
- transformedExtent = layerExtent;
1717
- }
1716
+ transformedExtent = layerExtent;
1717
+ }
1718
1718
1719
- if (transformedExtent.xMin () < xmin)
1720
- {
1721
- xmin = transformedExtent.xMin ();
1722
- }
1723
- if (transformedExtent.yMin () < ymin)
1724
- {
1725
- ymin = transformedExtent.yMin ();
1726
- }
1727
- if (transformedExtent.xMax () > xmax)
1728
- {
1729
- xmax = transformedExtent.xMax ();
1730
- }
1731
- if (transformedExtent.yMax () > ymax)
1732
- {
1733
- ymax = transformedExtent.yMax ();
1734
- }
1735
- }
1719
+ if (transformedExtent.xMin () < xmin)
1720
+ {
1721
+ xmin = transformedExtent.xMin ();
1722
+ }
1723
+
1724
+ if (transformedExtent.yMin () < ymin)
1725
+ {
1726
+ ymin = transformedExtent.yMin ();
1727
+ }
1728
+
1729
+ if (transformedExtent.xMax () > xmax)
1730
+ {
1731
+ xmax = transformedExtent.xMax ();
1732
+ }
1733
+
1734
+ if (transformedExtent.yMax () > ymax)
1735
+ {
1736
+ ymax = transformedExtent.yMax ();
1737
+ }
1736
1738
}
1739
+ }
1737
1740
1738
1741
// zoom to bounding box
1739
1742
mMapCanvas ->setExtent (QgsRect (xmin, ymin, xmax, ymax));
0 commit comments