Skip to content

Commit

Permalink
fix #1311
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10994 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jul 1, 2009
1 parent c5f5e7f commit 9eec5dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 50 deletions.
31 changes: 0 additions & 31 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,26 +583,6 @@ unsigned char *QgsVectorLayer::drawPolygon(
delete rings[i];
}

#ifdef QGISDEBUGVERBOSE
// this is only for verbose debug output -- no optimzation is
// needed :)
QgsDebugMsg( "Pixel points are:" );
for ( int i = 0; i < pa.size(); ++i )
{
QgsDebugMsgLevel( "i" + QString::number( i ), 2 );
QgsDebugMsgLevel( "pa[i].x()" + QString::number( pa[i].x() ), 2 );
QgsDebugMsgLevel( "pa[i].y()" + QString::number( pa[i].y() ), 2 );
}
QgsDebugMsg( "Ring positions are:" );
QgsDebugMsg( "Ring positions are:" );
for ( int i = 0; i < ringDetails.size(); ++i )
{
QgsDebugMsgLevel( "ringDetails[i].first" + QString::number( ringDetails[i].first ), 2 );
QgsDebugMsgLevel( "ringDetails[i].second" + QString::number( ringDetails[i].second ), 2 );
}
QgsDebugMsg( "Outer ring point is " + QString::number( outerRingPt.x() ) + ", " + QString::number( outerRingPt.y() ) );
#endif

#if 0
// A bit of code to aid in working out what values of
// QgsClipper::minX, etc cause the X11 zoom bug.
Expand Down Expand Up @@ -1063,17 +1043,6 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
{
retval.set( -1.0, -1.0, 1.0, 1.0 );
}
else
{
const double padFactor = 1e-8;
double widthPad = retval.xMinimum() * padFactor;
double heightPad = retval.yMinimum() * padFactor;
double xmin = retval.xMinimum() - widthPad;
double xmax = retval.xMaximum() + widthPad;
double ymin = retval.yMinimum() - heightPad;
double ymax = retval.yMaximum() + heightPad;
retval.set( xmin, ymin, xmax, ymax );
}
}

return retval;
Expand Down
43 changes: 24 additions & 19 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,28 +626,33 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer* layer )
layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
}

if ( layer )
if ( layer == NULL )
{
QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );
return;
}

// no selected features, only one selected point feature
//or two point features with the same x- or y-coordinates
if ( rect.isEmpty() )
{
return;
}
//zoom to an area
else
{
// Expand rect to give a bit of space around the selected
// objects so as to keep them clear of the map boundaries
// The same 5% should apply to all margins.
rect.scale( 1.05 );
setExtent( rect );
refresh();
return;
}
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
if ( rect.isEmpty() )
{
// zoom in
QgsPoint c = rect.center();
rect = extent();
rect.expand( 0.25, &c );
}
//zoom to an area
else
{
// Expand rect to give a bit of space around the selected
// objects so as to keep them clear of the map boundaries
// The same 5% should apply to all margins.
rect.scale( 1.05 );
}

setExtent( rect );
refresh();
} // zoomToSelected

void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
Expand Down

0 comments on commit 9eec5dd

Please sign in to comment.