1 /*************************************************************************** 2 qgsappmaptools.h 3 -------------------------------------- 4 Date : March 2021 5 Copyright : (C) 2021 by 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 QGSAPPMAPTOOLS_H 17 #define QGSAPPMAPTOOLS_H 18 19 #include <QList> 20 #include <QHash> 21 #include <QPointer> 22 #include <QWidgetAction> 23 24 25 class QgsMapTool; 26 class QgsMapToolCapture; 27 28 class QgsMapCanvas; 29 class QgsAdvancedDigitizingDockWidget; 30 class QgsSpinBox; 31 32 class QgsStreamDigitizingSettingsAction: public QWidgetAction 33 { 34 Q_OBJECT 35 36 public: 37 38 QgsStreamDigitizingSettingsAction( QWidget *parent = nullptr ); 39 ~QgsStreamDigitizingSettingsAction() override; 40 41 private: 42 QgsSpinBox *mStreamToleranceSpinBox = nullptr; 43 }; 44 45 46 class QgsAppMapTools 47 { 48 public: 49 enum Tool 50 { 51 ZoomIn, 52 ZoomOut, 53 Pan, 54 Identify, 55 FeatureAction, 56 MeasureDistance, 57 MeasureArea, 58 MeasureAngle, 59 MeasureBearing, 60 AddFeature, 61 CircularStringCurvePoint, 62 CircularStringRadius, 63 Circle2Points, 64 Circle3Points, 65 Circle3Tangents, 66 Circle2TangentsPoint, 67 CircleCenterPoint, 68 EllipseCenter2Points, 69 EllipseCenterPoint, 70 EllipseExtent, 71 EllipseFoci, 72 RectangleCenterPoint, 73 RectangleExtent, 74 Rectangle3PointsDistance, 75 Rectangle3PointsProjected, 76 RegularPolygon2Points, 77 RegularPolygonCenterPoint, 78 RegularPolygonCenterCorner, 79 MoveFeature, 80 MoveFeatureCopy, 81 OffsetCurve, 82 ReshapeFeatures, 83 SplitFeatures, 84 SplitParts, 85 SelectFeatures, 86 SelectPolygon, 87 SelectFreehand, 88 SelectRadius, 89 VertexAdd, 90 VertexMove, 91 VertexDelete, 92 AddRing, 93 FillRing, 94 AddPart, 95 SimplifyFeature, 96 DeleteRing, 97 DeletePart, 98 VertexTool, 99 VertexToolActiveLayer, 100 RotatePointSymbolsTool, 101 OffsetPointSymbolTool, 102 Annotation, 103 FormAnnotation, 104 HtmlAnnotation, 105 SvgAnnotation, 106 TextAnnotation, 107 PinLabels, 108 ShowHideLabels, 109 MoveLabel, 110 RotateFeature, 111 ScaleFeature, 112 RotateLabel, 113 ChangeLabelProperties, 114 ReverseLine, 115 TrimExtendFeature, 116 EditMeshFrame, 117 AnnotationEdit 118 }; 119 120 QgsAppMapTools( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock ); 121 ~QgsAppMapTools(); 122 123 /** 124 * Returns the specified \a tool. 125 */ 126 QgsMapTool *mapTool( Tool tool ); 127 128 /** 129 * Returns the specified \a tool. 130 */ mapTool(Tool tool)131 template <class ToolType> ToolType *mapTool( Tool tool ) 132 { 133 QgsMapTool *t = mapTool( tool ); 134 return qobject_cast< ToolType * >( t ); 135 } 136 137 /** 138 * Returns a list of all QgsMapToolCapture derived tools. 139 */ 140 QList< QgsMapToolCapture * > captureTools() const; 141 142 /** 143 * Returns the stream digitizing settings action; 144 */ 145 QWidgetAction *streamDigitizingSettingsAction(); 146 147 private: 148 149 QHash< Tool, QPointer< QgsMapTool > > mTools; 150 QgsStreamDigitizingSettingsAction *mStreamDigitizingSettingsAction = nullptr; 151 152 // Disable copying as we have pointer members. 153 QgsAppMapTools( const QgsAppMapTools & ) = delete; 154 QgsAppMapTools &operator= ( const QgsAppMapTools & ) = delete; 155 }; 156 157 #endif // QGSAPPMAPTOOLS_H 158