Skip to content

Commit 40650bb

Browse files
author
jef
committed
fix #1311
git-svn-id: http://svn.osgeo.org/qgis/trunk@10994 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fb09248 commit 40650bb

File tree

2 files changed

+24
-50
lines changed

2 files changed

+24
-50
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -583,26 +583,6 @@ unsigned char *QgsVectorLayer::drawPolygon(
583583
delete rings[i];
584584
}
585585

586-
#ifdef QGISDEBUGVERBOSE
587-
// this is only for verbose debug output -- no optimzation is
588-
// needed :)
589-
QgsDebugMsg( "Pixel points are:" );
590-
for ( int i = 0; i < pa.size(); ++i )
591-
{
592-
QgsDebugMsgLevel( "i" + QString::number( i ), 2 );
593-
QgsDebugMsgLevel( "pa[i].x()" + QString::number( pa[i].x() ), 2 );
594-
QgsDebugMsgLevel( "pa[i].y()" + QString::number( pa[i].y() ), 2 );
595-
}
596-
QgsDebugMsg( "Ring positions are:" );
597-
QgsDebugMsg( "Ring positions are:" );
598-
for ( int i = 0; i < ringDetails.size(); ++i )
599-
{
600-
QgsDebugMsgLevel( "ringDetails[i].first" + QString::number( ringDetails[i].first ), 2 );
601-
QgsDebugMsgLevel( "ringDetails[i].second" + QString::number( ringDetails[i].second ), 2 );
602-
}
603-
QgsDebugMsg( "Outer ring point is " + QString::number( outerRingPt.x() ) + ", " + QString::number( outerRingPt.y() ) );
604-
#endif
605-
606586
#if 0
607587
// A bit of code to aid in working out what values of
608588
// QgsClipper::minX, etc cause the X11 zoom bug.
@@ -1063,17 +1043,6 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
10631043
{
10641044
retval.set( -1.0, -1.0, 1.0, 1.0 );
10651045
}
1066-
else
1067-
{
1068-
const double padFactor = 1e-8;
1069-
double widthPad = retval.xMinimum() * padFactor;
1070-
double heightPad = retval.yMinimum() * padFactor;
1071-
double xmin = retval.xMinimum() - widthPad;
1072-
double xmax = retval.xMaximum() + widthPad;
1073-
double ymin = retval.yMinimum() - heightPad;
1074-
double ymax = retval.yMaximum() + heightPad;
1075-
retval.set( xmin, ymin, xmax, ymax );
1076-
}
10771046
}
10781047

10791048
return retval;

src/gui/qgsmapcanvas.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -626,28 +626,33 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer* layer )
626626
layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
627627
}
628628

629-
if ( layer )
629+
if ( layer == NULL )
630630
{
631-
QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );
631+
return;
632+
}
632633

633-
// no selected features, only one selected point feature
634-
//or two point features with the same x- or y-coordinates
635-
if ( rect.isEmpty() )
636-
{
637-
return;
638-
}
639-
//zoom to an area
640-
else
641-
{
642-
// Expand rect to give a bit of space around the selected
643-
// objects so as to keep them clear of the map boundaries
644-
// The same 5% should apply to all margins.
645-
rect.scale( 1.05 );
646-
setExtent( rect );
647-
refresh();
648-
return;
649-
}
634+
QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );
635+
636+
// no selected features, only one selected point feature
637+
//or two point features with the same x- or y-coordinates
638+
if ( rect.isEmpty() )
639+
{
640+
// zoom in
641+
QgsPoint c = rect.center();
642+
rect = extent();
643+
rect.expand( 0.25, &c );
650644
}
645+
//zoom to an area
646+
else
647+
{
648+
// Expand rect to give a bit of space around the selected
649+
// objects so as to keep them clear of the map boundaries
650+
// The same 5% should apply to all margins.
651+
rect.scale( 1.05 );
652+
}
653+
654+
setExtent( rect );
655+
refresh();
651656
} // zoomToSelected
652657

653658
void QgsMapCanvas::keyPressEvent( QKeyEvent * e )

0 commit comments

Comments
 (0)