Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make create annotation map tools available in public API #58933

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ whenever this signal is emitted.

virtual ~QgsCreateAnnotationItemMapToolInterface();

virtual QgsCreateAnnotationItemMapToolHandler *handler() = 0;
virtual QgsCreateAnnotationItemMapToolHandler *handler() const = 0;
%Docstring
Returns the handler object for the map tool.
%End
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ whenever this signal is emitted.

virtual ~QgsCreateAnnotationItemMapToolInterface();

virtual QgsCreateAnnotationItemMapToolHandler *handler() = 0;
virtual QgsCreateAnnotationItemMapToolHandler *handler() const = 0;
%Docstring
Returns the handler object for the map tool.
%End
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ set(QGIS_GUI_HDRS
annotations/qgsannotationitemguiregistry.h
annotations/qgsannotationitemwidget.h
annotations/qgscreateannotationitemmaptool.h
annotations/qgscreateannotationitemmaptool_impl.h
annotations/qgsmaptoolmodifyannotation.h

attributeformconfig/qgsattributeformcontaineredit.h
Expand Down
2 changes: 1 addition & 1 deletion src/gui/annotations/qgscreateannotationitemmaptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class GUI_EXPORT QgsCreateAnnotationItemMapToolInterface
/**
* Returns the handler object for the map tool.
*/
virtual QgsCreateAnnotationItemMapToolHandler *handler() = 0;
virtual QgsCreateAnnotationItemMapToolHandler *handler() const = 0;

/**
* Returns a reference to the associated map tool.
Expand Down
8 changes: 4 additions & 4 deletions src/gui/annotations/qgscreateannotationitemmaptool_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ QgsMapToolCaptureAnnotationItem::QgsMapToolCaptureAnnotationItem( QgsMapCanvas *
mToolName = tr( "Annotation tool" );
}

QgsCreateAnnotationItemMapToolHandler *QgsMapToolCaptureAnnotationItem::handler()
QgsCreateAnnotationItemMapToolHandler *QgsMapToolCaptureAnnotationItem::handler() const
{
return mHandler;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ void QgsCreatePointTextItemMapTool::cadCanvasPressEvent( QgsMapMouseEvent *event
mHandler->pushCreatedItem( createdItem.release() );
}

QgsCreateAnnotationItemMapToolHandler *QgsCreatePointTextItemMapTool::handler()
QgsCreateAnnotationItemMapToolHandler *QgsCreatePointTextItemMapTool::handler() const
{
return mHandler;
}
Expand Down Expand Up @@ -369,7 +369,7 @@ void QgsCreatePictureItemMapTool::keyPressEvent( QKeyEvent *event )
}
}

QgsCreateAnnotationItemMapToolHandler *QgsCreatePictureItemMapTool::handler()
QgsCreateAnnotationItemMapToolHandler *QgsCreatePictureItemMapTool::handler() const
{
return mHandler;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ void QgsCreateRectangleTextItemMapTool::keyPressEvent( QKeyEvent *event )
}
}

QgsCreateAnnotationItemMapToolHandler *QgsCreateRectangleTextItemMapTool::handler()
QgsCreateAnnotationItemMapToolHandler *QgsCreateRectangleTextItemMapTool::handler() const
{
return mHandler;
}
Expand Down
114 changes: 87 additions & 27 deletions src/gui/annotations/qgscreateannotationitemmaptool_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,32 @@
#define QGSCREATEANNOTATIONITEMMAPTOOLIMPL_H

#include "qgis_gui.h"
#include "qgis_sip.h"
#include "qgscreateannotationitemmaptool.h"
#include "qgsmaptoolcapture.h"
#include "qgssettingstree.h"

#define SIP_NO_FILE

class QgsSettingsEntryString;
class QgsSettingsTreeNode;

///@cond PRIVATE

class QgsMapToolCaptureAnnotationItem: public QgsMapToolCapture, public QgsCreateAnnotationItemMapToolInterface
/**
* \class QgsMapToolCaptureAnnotationItem
* \ingroup gui
*
* \brief A base class to digitize annotation items using QgsMapToolCapture
*
* \note Not available in Python bindings.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsMapToolCaptureAnnotationItem: public QgsMapToolCapture, public QgsCreateAnnotationItemMapToolInterface
{
Q_OBJECT
public:
//! Constructor
QgsMapToolCaptureAnnotationItem( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode );
QgsCreateAnnotationItemMapToolHandler *handler() override;
QgsCreateAnnotationItemMapToolHandler *handler() const override;
QgsMapTool *mapTool() override;
QgsMapLayer *layer() const override;
QgsMapToolCapture::Capabilities capabilities() const override;
Expand All @@ -45,17 +53,25 @@ class QgsMapToolCaptureAnnotationItem: public QgsMapToolCapture, public QgsCreat

};

class QgsCreatePointTextItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
/**
* \class QgsCreatePointTextItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize point text items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreatePointTextItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
{
Q_OBJECT

public:

//! Constructor
QgsCreatePointTextItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
~QgsCreatePointTextItemMapTool() override;

void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
QgsCreateAnnotationItemMapToolHandler *handler() override;
QgsCreateAnnotationItemMapToolHandler *handler() const override;
QgsMapTool *mapTool() override;

private:
Expand All @@ -65,107 +81,151 @@ class QgsCreatePointTextItemMapTool: public QgsMapToolAdvancedDigitizing, public
};


class QgsCreateMarkerItemMapTool: public QgsMapToolCaptureAnnotationItem
/**
* \class QgsCreateMarkerItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize marker items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreateMarkerItemMapTool: public QgsMapToolCaptureAnnotationItem
{
Q_OBJECT

public:

//! Constructor
QgsCreateMarkerItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

void cadCanvasReleaseEvent( QgsMapMouseEvent *event ) override;

};

class QgsCreateLineItemMapTool: public QgsMapToolCaptureAnnotationItem
/**
* \class QgsCreateLineItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize line items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreateLineItemMapTool: public QgsMapToolCaptureAnnotationItem
{
Q_OBJECT

public:

//! Constructor
QgsCreateLineItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

private slots:
void lineCaptured( const QgsCurve *line ) override;
};

class QgsCreatePolygonItemMapTool: public QgsMapToolCaptureAnnotationItem
/**
* \class QgsCreatePolygonItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize polygon items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreatePolygonItemMapTool: public QgsMapToolCaptureAnnotationItem
{
Q_OBJECT

public:

//! Constructor
QgsCreatePolygonItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

private slots:
void polygonCaptured( const QgsCurvePolygon *polygon ) override;
};


class QgsCreateRectangleTextItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
/**
* \class QgsCreateRectangleTextItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize rectangle text items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreateRectangleTextItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
{
Q_OBJECT

public:

//! Constructor
QgsCreateRectangleTextItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;

QgsCreateAnnotationItemMapToolHandler *handler() override;
QgsCreateAnnotationItemMapToolHandler *handler() const override;
QgsMapTool *mapTool() override;

private:

QgsCreateAnnotationItemMapToolHandler *mHandler = nullptr;

QRectF mRect;
QgsPointXY mFirstPoint;
QObjectUniquePtr< QgsRubberBand > mRubberBand;
};


class QgsCreatePictureItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
/**
* \class QgsCreatePictureItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize picture items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreatePictureItemMapTool: public QgsMapToolAdvancedDigitizing, public QgsCreateAnnotationItemMapToolInterface
{
Q_OBJECT

public:
static inline QgsSettingsTreeNode *sTreePicture = QgsCreateAnnotationItemMapToolInterface::sTreeAnnotationTools->createChildNode( QStringLiteral( "picture-item" ) );
static const QgsSettingsEntryString *settingLastSourceFolder;

//! Constructor
QgsCreatePictureItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;

QgsCreateAnnotationItemMapToolHandler *handler() override;
QgsCreateAnnotationItemMapToolHandler *handler() const override;
QgsMapTool *mapTool() override;

private:

//! Constructor
QgsCreateAnnotationItemMapToolHandler *mHandler = nullptr;

QRectF mRect;
QgsPointXY mFirstPoint;
QObjectUniquePtr< QgsRubberBand > mRubberBand;
};


class QgsCreateLineTextItemMapTool: public QgsMapToolCaptureAnnotationItem
/**
* \class QgsCreateLineTextItemMapTool
* \ingroup gui
*
* \brief A map tool to digitize line text items.
*
* \since QGIS 3.40
*/
class GUI_EXPORT QgsCreateLineTextItemMapTool: public QgsMapToolCaptureAnnotationItem
{
Q_OBJECT

public:

//! Constructor
QgsCreateLineTextItemMapTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );

private slots:
void lineCaptured( const QgsCurve *line ) override;
};

///@endcond PRIVATE

#endif // QGSCREATEANNOTATIONITEMMAPTOOLIMPL_H
Loading