Skip to content

Commit

Permalink
make create annotation map tools available in public API
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 1, 2024
1 parent 6f3e33e commit 54865c2
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 23 deletions.
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
106 changes: 83 additions & 23 deletions src/gui/annotations/qgscreateannotationitemmaptool_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,30 @@
#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;
QgsMapTool *mapTool() override;
Expand All @@ -45,12 +53,20 @@ 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;

Expand All @@ -65,49 +81,80 @@ 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;
Expand All @@ -118,23 +165,30 @@ class QgsCreateRectangleTextItemMapTool: public QgsMapToolAdvancedDigitizing, pu
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;
Expand All @@ -145,27 +199,33 @@ class QgsCreatePictureItemMapTool: public QgsMapToolAdvancedDigitizing, public Q
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

0 comments on commit 54865c2

Please sign in to comment.