fixes from review

This commit is contained in:
Denis Rouzaud 2022-02-21 09:45:04 +01:00
parent 7b86867cfa
commit e9fc54c0bd
9 changed files with 30 additions and 33 deletions

View File

@ -13,9 +13,9 @@ class QgsMapToolCaptureLayerGeometry : QgsMapToolCapture
{
%Docstring(signature="appended")
:py:class:`QgsMapToolCaptureLayerGeometry` is a base class for map tools digitizing layer geometries
It will implement avoid intersections
This map tool subclass automatically handles intersection avoidance with other layers in the active project whenever a geometry is digitized by the user.
.. versionadded:: 3.24
.. versionadded:: 3.26
%End
%TypeHeaderCode
@ -31,30 +31,22 @@ Constructor
virtual void layerGeometryCaptured( const QgsGeometry &geometry );
%Docstring
Called when the geometry is captured
A more specific handler is also called afterwards (pointCaptured, lineCaptured or polygonCaptured)
.. versionadded:: 3.24
A more specific handler is also called afterwards (layerPointCaptured, layerLineCaptured or layerPolygonCaptured)
%End
virtual void layerPointCaptured( const QgsPoint &point );
%Docstring
Called when a point is captured
geometryCaptured is called just before
.. versionadded:: 3.24
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this point-specific signal.
%End
virtual void layerLineCaptured( const QgsCurve *line );
%Docstring
Called when a line is captured
geometryCaptured is called just before
.. versionadded:: 3.24
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this line-specific signal.
%End
virtual void layerPolygonCaptured( const QgsCurvePolygon *polygon );
%Docstring
Called when a polygon is captured
geometryCaptured is called just before
.. versionadded:: 3.24
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this polygon-specific signal.
%End
};

View File

@ -153,7 +153,7 @@ transfers ownership to the caller.
%Docstring
Creates a :py:class:`QgsPoint` with ZM support if necessary (according to the
WkbType of the current layer). If the point is snapped, then the Z
value is took from the snapped point.
value is derived from the snapped point.
:param e: A mouse event

View File

@ -70,7 +70,6 @@ bool QgsMapToolCaptureAnnotationItem::supportsTechnique( CaptureTechnique techni
case CaptureTechnique::StraightSegments:
case CaptureTechnique::CircularString:
case CaptureTechnique::Streaming:
return true;
case CaptureTechnique::Shape:
return true;
}

View File

@ -25,7 +25,7 @@ class QgsMapCanvas;
* \ingroup gui
* \brief QgsMapToolCaptureLayerGeometry is a base class for map tools digitizing layer geometries
* This map tool subclass automatically handles intersection avoidance with other layers in the active project whenever a geometry is digitized by the user.
* \since QGIS 3.24
* \since QGIS 3.26
*/
class GUI_EXPORT QgsMapToolCaptureLayerGeometry : public QgsMapToolCapture
{
@ -38,29 +38,25 @@ class GUI_EXPORT QgsMapToolCaptureLayerGeometry : public QgsMapToolCapture
/**
* Called when the geometry is captured
* A more specific handler is also called afterwards (pointCaptured, lineCaptured or polygonCaptured)
* \since QGIS 3.24
* A more specific handler is also called afterwards (layerPointCaptured, layerLineCaptured or layerPolygonCaptured)
*/
virtual void layerGeometryCaptured( const QgsGeometry &geometry ) {Q_UNUSED( geometry )} SIP_FORCE
/**
* Called when a point is captured
* geometryCaptured is called just before
* \since QGIS 3.24
* The generic geometryCaptured() signal will be emitted immediately before this point-specific signal.
*/
virtual void layerPointCaptured( const QgsPoint &point ) {Q_UNUSED( point )} SIP_FORCE
/**
* Called when a line is captured
* geometryCaptured is called just before
* \since QGIS 3.24
* The generic geometryCaptured() signal will be emitted immediately before this line-specific signal.
*/
virtual void layerLineCaptured( const QgsCurve *line ) {Q_UNUSED( line )} SIP_FORCE
/**
* Called when a polygon is captured
* geometryCaptured is called just before
* \since QGIS 3.24
* The generic geometryCaptured() signal will be emitted immediately before this polygon-specific signal.
*/
virtual void layerPolygonCaptured( const QgsCurvePolygon *polygon ) {Q_UNUSED( polygon )} SIP_FORCE
};

View File

@ -21,6 +21,11 @@
#include <QKeyEvent>
QgsMapToolShapeAbstract::~QgsMapToolShapeAbstract()
{
clean();
}
void QgsMapToolShapeAbstract::keyPressEvent( QKeyEvent *e )
{
e->ignore();

View File

@ -61,7 +61,7 @@ class GUI_EXPORT QgsMapToolShapeAbstract
Q_ASSERT( parentTool );
}
virtual ~QgsMapToolShapeAbstract() = default;
virtual ~QgsMapToolShapeAbstract();
//! Returns the id of the shape tool (equivalent to the one from the metadata)
QString id() const {return mId;}
@ -76,13 +76,13 @@ class GUI_EXPORT QgsMapToolShapeAbstract
virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) = 0;
/**
* Eventually filters a key press event
* Filters a key press event
* Ignores the event in default implementation
*/
virtual void keyPressEvent( QKeyEvent *e );
/**
* Eventually filters a key press event
* Filters a key release event
* Ignores the event in default implementation
*/
virtual void keyReleaseEvent( QKeyEvent *e );

View File

@ -46,6 +46,7 @@ void QgsMapToolShapeRegistry::removeMapTool( const QString &id )
{
if ( ( *it )->id() == id )
{
delete *it;
it = mMapTools.erase( it );
}
else

View File

@ -30,7 +30,7 @@ class QgsMapToolCapture;
/**
* \ingroup gui
* \brief Keeps track of the registered shape map tools
* \since QGIS 3.24
* \since QGIS 3.26
*/
class GUI_EXPORT QgsMapToolShapeRegistry
{
@ -50,7 +50,8 @@ class GUI_EXPORT QgsMapToolShapeRegistry
void addMapTool( QgsMapToolShapeMetadata *mapTool SIP_TRANSFER );
/**
* Removes a registered relation widget with given \a widgetType
* Removes a registered map tool at the given \id
* The tool will be deleted.
*/
void removeMapTool( const QString &id );
@ -75,7 +76,7 @@ class GUI_EXPORT QgsMapToolShapeRegistry
/**
* \ingroup gui
* \brief QgsMapToolShapeMetadata is a base class for shape map tools metadata to be used in QgsMapToolShapeRegistry
* \since QGIS 3.24
* \since QGIS 3.26
*/
class GUI_EXPORT QgsMapToolShapeMetadata
{
@ -97,7 +98,10 @@ class GUI_EXPORT QgsMapToolShapeMetadata
//! Returns the shape category of the tool
virtual QgsMapToolShapeAbstract::ShapeCategory category() const = 0;
//! Creates the shape map tool for the given \a parentTool
/**
* Creates the shape map tool for the given \a parentTool
* Caller takes ownership of the returned object.
*/
virtual QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentlTool ) const SIP_FACTORY = 0;
};

View File

@ -177,7 +177,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
/**
* Creates a QgsPoint with ZM support if necessary (according to the
* WkbType of the current layer). If the point is snapped, then the Z
* value is took from the snapped point.
* value is derived from the snapped point.
*
* \param e A mouse event
*