1 /***************************************************************************
2     qgsmaptoolpointsymbol.h
3     -----------------------
4     begin                : April 2016
5     copyright            : (C) 2016 by Marco Hugentobler, Nyall Dawson
6     email                : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #ifndef QGSMAPTOOLPOINTSYMBOL_H
17 #define QGSMAPTOOLPOINTSYMBOL_H
18 
19 #include "qgsmaptooledit.h"
20 #include "qgsfeature.h"
21 #include "qgis_app.h"
22 
23 class QgsMarkerSymbol;
24 
25 /**
26  * \ingroup app
27  * \class QgsMapToolPointSymbol
28  * \brief An abstract base class that allows interactive manipulation of the symbols for point layers. Handles
29  * snapping the mouse press to a feature, and detecting whether the clicked feature has symbology which is
30  * compatible with the map tool.
31  */
32 class APP_EXPORT QgsMapToolPointSymbol: public QgsMapToolEdit
33 {
34     Q_OBJECT
35 
36   public:
37     QgsMapToolPointSymbol( QgsMapCanvas *canvas );
38 
flags()39     Flags flags() const override { return QgsMapTool::EditTool; }
40 
41     void canvasPressEvent( QgsMapMouseEvent *e ) override;
42 
43   protected:
44     QgsVectorLayer *mActiveLayer = nullptr;
45     QgsFeatureId mFeatureNumber;
46 
47     //! Screen coordinate of the snapped feature
48     QPoint mSnappedPoint;
49 
50     virtual void canvasPressOnFeature( QgsMapMouseEvent *e, const QgsFeature &feature, const QgsPointXY &snappedPoint ) = 0;
51 
52     virtual bool checkSymbolCompatibility( QgsMarkerSymbol *markerSymbol, QgsRenderContext &context ) = 0;
53 
noCompatibleSymbols()54     virtual void noCompatibleSymbols() {}
55 
56 };
57 
58 #endif // QGSMAPTOOLPOINTSYMBOL_H
59