35
35
#include < QMouseEvent>
36
36
#include < QSettings>
37
37
38
- QgsMapToolAddFeature::QgsMapToolAddFeature ( QgsMapCanvas* canvas )
39
- : QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget() )
38
+ QgsMapToolAddFeature::QgsMapToolAddFeature ( QgsMapCanvas* canvas, CaptureMode mode )
39
+ : QgsMapToolCapture( canvas, QgisApp::instance()->cadDockWidget(), mode )
40
+ , mCheckGeometryType( true )
40
41
{
41
42
mToolName = tr ( " Add feature" );
42
43
}
@@ -100,7 +101,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
100
101
return ;
101
102
102
103
// check we only use this tool for point/multipoint layers
103
- if ( vlayer->geometryType () != QGis::Point )
104
+ if ( vlayer->geometryType () != QGis::Point && mCheckGeometryType )
104
105
{
105
106
emit messageEmitted ( tr ( " Wrong editing tool, cannot apply the 'capture point' tool on this vector layer" ), QgsMessageBar::WARNING );
106
107
return ;
@@ -137,6 +138,11 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
137
138
{
138
139
g = QgsGeometry::fromMultiPoint ( QgsMultiPoint () << savePoint );
139
140
}
141
+ else
142
+ {
143
+ // if layer supports more types (mCheckGeometryType is false)
144
+ g = QgsGeometry::fromPoint ( savePoint );
145
+ }
140
146
141
147
f.setGeometry ( g );
142
148
f.setValid ( true );
@@ -151,14 +157,14 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
151
157
else if ( mode () == CaptureLine || mode () == CapturePolygon )
152
158
{
153
159
// check we only use the line tool for line/multiline layers
154
- if ( mode () == CaptureLine && vlayer->geometryType () != QGis::Line )
160
+ if ( mode () == CaptureLine && vlayer->geometryType () != QGis::Line && mCheckGeometryType )
155
161
{
156
162
emit messageEmitted ( tr ( " Wrong editing tool, cannot apply the 'capture line' tool on this vector layer" ), QgsMessageBar::WARNING );
157
163
return ;
158
164
}
159
165
160
166
// check we only use the polygon tool for polygon/multipolygon layers
161
- if ( mode () == CapturePolygon && vlayer->geometryType () != QGis::Polygon )
167
+ if ( mode () == CapturePolygon && vlayer->geometryType () != QGis::Polygon && mCheckGeometryType )
162
168
{
163
169
emit messageEmitted ( tr ( " Wrong editing tool, cannot apply the 'capture polygon' tool on this vector layer" ), QgsMessageBar::WARNING );
164
170
return ;
0 commit comments