mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-16 00:05:54 -05:00
[api] Add a public method to clear the rubber band for the
QgsMapToolExtent Otherwise plugins have no way to remove this from the canvas
This commit is contained in:
parent
d68cd295db
commit
34735aa9ef
@ -57,6 +57,13 @@ If the aspect ratio isn't fixed, the width and height will be set to zero.
|
|||||||
QgsRectangle extent() const;
|
QgsRectangle extent() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the current extent drawn onto the canvas.
|
Returns the current extent drawn onto the canvas.
|
||||||
|
%End
|
||||||
|
|
||||||
|
void clearRubberBand();
|
||||||
|
%Docstring
|
||||||
|
Removes the tool's rubber band from the canvas.
|
||||||
|
|
||||||
|
.. versionadded:: 3.20
|
||||||
%End
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -34,8 +34,7 @@ void QgsMapToolExtent::activate()
|
|||||||
|
|
||||||
void QgsMapToolExtent::deactivate()
|
void QgsMapToolExtent::deactivate()
|
||||||
{
|
{
|
||||||
mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
|
clearRubberBand();
|
||||||
|
|
||||||
QgsMapTool::deactivate();
|
QgsMapTool::deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +94,11 @@ QgsRectangle QgsMapToolExtent::extent() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsMapToolExtent::clearRubberBand()
|
||||||
|
{
|
||||||
|
mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsMapToolExtent::calculateEndPoint( QgsPointXY &point )
|
void QgsMapToolExtent::calculateEndPoint( QgsPointXY &point )
|
||||||
{
|
{
|
||||||
if ( mRatio.width() > 0 && mRatio.height() > 0 )
|
if ( mRatio.width() > 0 && mRatio.height() > 0 )
|
||||||
@ -112,8 +116,6 @@ void QgsMapToolExtent::drawExtent()
|
|||||||
if ( qgsDoubleNear( mStartPoint.x(), mEndPoint.x() ) && qgsDoubleNear( mStartPoint.y(), mEndPoint.y() ) )
|
if ( qgsDoubleNear( mStartPoint.x(), mEndPoint.x() ) && qgsDoubleNear( mStartPoint.y(), mEndPoint.y() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
|
|
||||||
|
|
||||||
QgsRectangle rect( mStartPoint, mEndPoint );
|
QgsRectangle rect( mStartPoint, mEndPoint );
|
||||||
|
|
||||||
mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
|
mRubberBand->reset( QgsWkbTypes::PolygonGeometry );
|
||||||
|
|||||||
@ -64,6 +64,13 @@ class GUI_EXPORT QgsMapToolExtent : public QgsMapTool
|
|||||||
*/
|
*/
|
||||||
QgsRectangle extent() const;
|
QgsRectangle extent() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the tool's rubber band from the canvas.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.20
|
||||||
|
*/
|
||||||
|
void clearRubberBand();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
//! signal emitted on extent change
|
//! signal emitted on extent change
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user