@@ -66,10 +66,6 @@ void QgsSimplifyDialog::closeEvent( QCloseEvent *e )
66
66
67
67
QgsMapToolSimplify::QgsMapToolSimplify ( QgsMapCanvas *canvas )
68
68
: QgsMapToolEdit( canvas )
69
- , mDragging( false )
70
- , mOriginalVertexCount( 0 )
71
- , mReducedVertexCount( 0 )
72
- , mReducedHasErrors( false )
73
69
{
74
70
QgsSettings settings;
75
71
mTolerance = settings.value ( QStringLiteral ( " digitizing/simplify_tolerance" ), 1 ).toDouble ();
@@ -120,7 +116,7 @@ void QgsMapToolSimplify::updateSimplificationPreview()
120
116
QgsGeometry g = fSel .geometry ().simplify ( layerTolerance );
121
117
if ( !g.isNull () )
122
118
{
123
- mReducedVertexCount += vertexCount ( g );
119
+ mReducedVertexCount += g. constGet ()-> nCoordinates ( );
124
120
mRubberBands .at ( i )->setToGeometry ( g, vl );
125
121
}
126
122
else
@@ -132,45 +128,6 @@ void QgsMapToolSimplify::updateSimplificationPreview()
132
128
mSimplifyDialog ->enableOkButton ( !mReducedHasErrors );
133
129
}
134
130
135
-
136
- int QgsMapToolSimplify::vertexCount ( const QgsGeometry &g ) const
137
- {
138
- switch ( g.type () )
139
- {
140
- case QgsWkbTypes::LineGeometry:
141
- {
142
- int count = 0 ;
143
- if ( g.isMultipart () )
144
- {
145
- Q_FOREACH ( const QgsPolylineXY &polyline, g.asMultiPolyline () )
146
- count += polyline.count ();
147
- }
148
- else
149
- count = g.asPolyline ().count ();
150
- return count;
151
- }
152
- case QgsWkbTypes::PolygonGeometry:
153
- {
154
- int count = 0 ;
155
- if ( g.isMultipart () )
156
- {
157
- Q_FOREACH ( const QgsPolygonXY &polygon, g.asMultiPolygon () )
158
- Q_FOREACH ( const QgsPolylineXY &ring, polygon )
159
- count += ring.count ();
160
- }
161
- else
162
- {
163
- Q_FOREACH ( const QgsPolylineXY &ring, g.asPolygon () )
164
- count += ring.count ();
165
- }
166
- return count;
167
- }
168
- default :
169
- return 0 ;
170
- }
171
- }
172
-
173
-
174
131
void QgsMapToolSimplify::storeSimplified ()
175
132
{
176
133
QgsVectorLayer *vlayer = currentVectorLayer ();
@@ -192,8 +149,6 @@ void QgsMapToolSimplify::storeSimplified()
192
149
vlayer->triggerRepaint ();
193
150
}
194
151
195
-
196
-
197
152
void QgsMapToolSimplify::canvasPressEvent ( QgsMapMouseEvent *e )
198
153
{
199
154
if ( e->button () != Qt::LeftButton )
@@ -274,7 +229,8 @@ void QgsMapToolSimplify::canvasReleaseEvent( QgsMapMouseEvent *e )
274
229
mOriginalVertexCount = 0 ;
275
230
Q_FOREACH ( const QgsFeature &f, mSelectedFeatures )
276
231
{
277
- mOriginalVertexCount += vertexCount ( f.geometry () );
232
+ if ( f.hasGeometry () )
233
+ mOriginalVertexCount += f.geometry ().constGet ()->nCoordinates ();
278
234
279
235
QgsRubberBand *rb = new QgsRubberBand ( mCanvas );
280
236
rb->setColor ( QColor ( 255 , 0 , 0 , 65 ) );
0 commit comments