Skip to content

Commit

Permalink
Rename QgsRectangle::buffer to buffered and mark as const
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 25, 2017
1 parent 7d6034d commit d704163
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -2005,6 +2005,7 @@ QgsRectangle {#qgis_api_break_3_0_QgsRectangle}

- The protected members were removed - QgsRectangle is not intended to be subclassed.
- unionRect was removed. Use combineExtentWith instead.
- buffer was renamed to buffered.

QgsRelation {#qgis_api_break_3_0_QgsRelation}
-----------
Expand Down
6 changes: 4 additions & 2 deletions python/core/geometry/qgsrectangle.sip
Expand Up @@ -163,18 +163,20 @@ Copy constructor

void grow( double delta );
%Docstring
Grows the rectangle by the specified amount.
Grows the rectangle in place by the specified amount.
.. seealso:: buffered()
%End

void include( const QgsPointXY &p );
%Docstring
Updates the rectangle to include the specified point.
%End

QgsRectangle buffer( double width );
QgsRectangle buffered( double width ) const;
%Docstring
Get rectangle enlarged by buffer.
.. versionadded:: 2.1
.. seealso:: grow()
:rtype: QgsRectangle
%End

Expand Down
Expand Up @@ -263,7 +263,7 @@ def run(item, action, mainwindow):
ext = node_extent
ext.combineExtentWith(edge_extent)
# Grow by 1/20 of largest side
ext = ext.buffer(max(ext.width(), ext.height()) / 20)
ext = ext.buffered(max(ext.width(), ext.height()) / 20)
canvas.setExtent(ext)

# restore canvas render flag
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsrectangle.cpp
Expand Up @@ -147,7 +147,7 @@ void QgsRectangle::include( const QgsPointXY &p )
setYMaximum( p.y() );
}

QgsRectangle QgsRectangle::buffer( double width )
QgsRectangle QgsRectangle::buffered( double width ) const
{
return QgsRectangle( mXmin - width, mYmin - width, mXmax + width, mYmax + width );
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/geometry/qgsrectangle.h
Expand Up @@ -161,7 +161,8 @@ class CORE_EXPORT QgsRectangle
void scale( double scaleFactor, double centerX, double centerY );

/**
* Grows the rectangle by the specified amount.
* Grows the rectangle in place by the specified amount.
* \see buffered()
*/
void grow( double delta );

Expand All @@ -173,8 +174,9 @@ class CORE_EXPORT QgsRectangle
/**
* Get rectangle enlarged by buffer.
* \since QGIS 2.1
* \see grow()
*/
QgsRectangle buffer( double width );
QgsRectangle buffered( double width ) const;

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Oct 3, 2017

Member

Can you update the\since to 3.0 and maybe add a previously buffer() since QGIS 2.1..

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Oct 3, 2017

Author Collaborator

Done in 4f34f94, thanks


/**
* Return the intersection with the given rectangle.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsgeometryrubberband.cpp
Expand Up @@ -157,5 +157,5 @@ QgsRectangle QgsGeometryRubberBand::rubberBandRectangle() const
qreal scale = mMapCanvas->mapUnitsPerPixel();
qreal s = ( mIconSize - 1 ) / 2.0 * scale;
qreal p = mPen.width() * scale;
return mGeometry->boundingBox().buffer( s + p );
return mGeometry->boundingBox().buffered( s + p );
}
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsfillsymbollayers.py
Expand Up @@ -72,7 +72,7 @@ def testSimpleLineWithOffset(self):

extent = geom.geometry().boundingBox()
# buffer extent by 10%
extent = extent.buffer((extent.height() + extent.width()) / 20.0)
extent = extent.buffered((extent.height() + extent.width()) / 20.0)

ms.setExtent(extent)
ms.setOutputSize(image.size())
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslinesymbollayers.py
Expand Up @@ -72,7 +72,7 @@ def testSimpleLineWithOffset(self):

extent = geom.geometry().boundingBox()
# buffer extent by 10%
extent = extent.buffer((extent.height() + extent.width()) / 20.0)
extent = extent.buffered((extent.height() + extent.width()) / 20.0)

ms.setExtent(extent)
ms.setOutputSize(image.size())
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgssymbol.py
Expand Up @@ -140,9 +140,9 @@ def renderGeometry(self, geom):
extent = geom.geometry().boundingBox()
# buffer extent by 10%
if extent.width() > 0:
extent = extent.buffer((extent.height() + extent.width()) / 20.0)
extent = extent.buffered((extent.height() + extent.width()) / 20.0)
else:
extent = extent.buffer(10)
extent = extent.buffered(10)

ms.setExtent(extent)
ms.setOutputSize(image.size())
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgssymbollayer.py
Expand Up @@ -382,7 +382,7 @@ def testRenderFillLayerDisabled(self):

extent = geom.geometry().boundingBox()
# buffer extent by 10%
extent = extent.buffer((extent.height() + extent.width()) / 20.0)
extent = extent.buffered((extent.height() + extent.width()) / 20.0)

ms.setExtent(extent)
ms.setOutputSize(image.size())
Expand Down Expand Up @@ -447,7 +447,7 @@ def testRenderLineLayerDisabled(self):

extent = geom.geometry().boundingBox()
# buffer extent by 10%
extent = extent.buffer((extent.height() + extent.width()) / 20.0)
extent = extent.buffered((extent.height() + extent.width()) / 20.0)

ms.setExtent(extent)
ms.setOutputSize(image.size())
Expand Down

0 comments on commit d704163

Please sign in to comment.