@@ -112,7 +112,7 @@ void VertexEntry::update()
112
112
113
113
QgsRubberBand* QgsMapToolNodeTool::createRubberBandMarker ( QgsPoint center, QgsVectorLayer* vlayer )
114
114
{
115
- // create rubber band marker for moving points
115
+ // create rubberband marker for moving points
116
116
QgsRubberBand* marker = new QgsRubberBand ( mCanvas , true );
117
117
marker->setColor ( Qt::red );
118
118
marker->setWidth ( 2 );
@@ -143,14 +143,14 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas ): QgsMapToolVertex
143
143
mClicked = false ;
144
144
mChangingGeometry = false ;
145
145
mIsPoint = false ;
146
- // signal handling change of layer structure
146
+ // signal handling change of layer structure
147
147
connect ( canvas, SIGNAL ( layersChanged () ), this , SLOT ( layersChanged () ) );
148
- // signal when destination srs changed to repaint coordinates
148
+ // signal when destination srs changed to repaint coordinates
149
149
connect ( canvas->mapRenderer (), SIGNAL ( destinationSrsChanged () ), this , SLOT ( coordinatesChanged () ) );
150
- // signal changing of coordinate renderer changed to repaint markers
150
+ // signal changing of coordinate renderer changed to repaint markers
151
151
connect ( canvas->mapRenderer (), SIGNAL ( hasCrsTransformEnabled ( bool ) ), this , SLOT ( coordinatesChanged () ) );
152
152
connect ( canvas, SIGNAL ( extentsChanged () ), this , SLOT ( coordinatesChanged () ) );
153
- // signal changing of current layer
153
+ // signal changing of current layer
154
154
connect ( QgisApp::instance ()->legend (), SIGNAL ( currentLayerChanged ( QgsMapLayer* ) ),
155
155
this , SLOT ( currentLayerChanged ( QgsMapLayer* ) ) );
156
156
}
@@ -162,7 +162,7 @@ QgsMapToolNodeTool::~QgsMapToolNodeTool()
162
162
163
163
void QgsMapToolNodeTool::layersChanged ()
164
164
{
165
- // deselection of feature when layer has changed
165
+ // deselection of feature when layer has changed
166
166
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
167
167
if ( mSelectionFeature != NULL && mSelectionFeature ->vlayer () != vlayer )
168
168
{
@@ -173,7 +173,7 @@ void QgsMapToolNodeTool::layersChanged()
173
173
174
174
void QgsMapToolNodeTool::currentLayerChanged ( QgsMapLayer* layer )
175
175
{
176
- // deselection of feature when current layer has changed
176
+ // deselection of feature when current layer has changed
177
177
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
178
178
if ( mSelectionFeature != NULL && mSelectionFeature ->vlayer () != vlayer )
179
179
{
@@ -185,10 +185,10 @@ void QgsMapToolNodeTool::currentLayerChanged( QgsMapLayer* layer )
185
185
186
186
void QgsMapToolNodeTool::featureDeleted ( QgsFeatureId featureId )
187
187
{
188
- // check if deleted feature is the one selected
188
+ // check if deleted feature is the one selected
189
189
if ( mSelectionFeature != NULL && featureId == mSelectionFeature ->featureId () )
190
190
{
191
- // if it's delete selection and disconnect signals since tool is not used anymore
191
+ // if it's delete selection and disconnect signals since tool is not used anymore
192
192
delete mSelectionFeature ;
193
193
mSelectionFeature = NULL ;
194
194
disconnect ( mCanvas ->currentLayer (), SIGNAL ( featureDeleted ( QgsFeatureId ) ) );
@@ -199,15 +199,15 @@ void QgsMapToolNodeTool::featureDeleted( QgsFeatureId featureId )
199
199
void QgsMapToolNodeTool::layerModified ( bool onlyGeometry )
200
200
{
201
201
Q_UNUSED ( onlyGeometry );
202
- // handling modification of
202
+ // handling modification of
203
203
QgsFeature feat;
204
204
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
205
205
if ( mSelectionFeature && !mChangingGeometry && vlayer->featureAtId ( mSelectionFeature ->featureId (), feat, true , false ) )
206
206
{
207
207
if ( !feat.geometry ()->isGeosEqual ( *mSelectionFeature ->feature ()->geometry () ) )
208
208
{
209
209
mSelectionFeature ->updateFromFeature ();
210
- // throw error
210
+ // throw error
211
211
}
212
212
}
213
213
}
@@ -224,81 +224,83 @@ void QgsMapToolNodeTool::createMovingRubberBands()
224
224
int vertex;
225
225
for ( int i = 0 ; i < vertexMap.size (); i++ )
226
226
{
227
- // create rubber band
227
+ // create rubberband
228
228
if ( vertexMap[i]->isSelected () && !vertexMap[i]->isInRubberBand () )
229
229
{
230
230
geometry->adjacentVertices ( i, beforeVertex, afterVertex );
231
231
vertex = i;
232
232
while ( beforeVertex != -1 )
233
- { // move forward NOTE: end if whole cycle is selected
234
- if ( vertexMap[beforeVertex]->isSelected () && beforeVertex != i ) // and take care of cycles
233
+ {
234
+ // move forward NOTE: end if whole cycle is selected
235
+ if ( vertexMap[beforeVertex]->isSelected () && beforeVertex != i ) // and take care of cycles
235
236
{
236
237
vertex = beforeVertex;
237
238
geometry->adjacentVertices ( vertex, beforeVertex, afterVertex );
238
239
}
239
240
else
240
- { // break if cycle is found
241
+ {
242
+ // break if cycle is found
241
243
break ;
242
244
}
243
245
}
244
- // we have first vertex of moving part
245
- // create rubber band and set default paramaters
246
+ // we have first vertex of moving part
247
+ // create rubberband and set default paramaters
246
248
QgsRubberBand* rb = new QgsRubberBand ( mCanvas , false );
247
249
rb->setWidth ( 2 );
248
250
rb->setColor ( Qt::blue );
249
251
int index = 0 ;
250
- if ( beforeVertex != -1 ) // adding first point which is not moving
252
+ if ( beforeVertex != -1 ) // adding first point which is not moving
251
253
{
252
254
rb->addPoint ( toMapCoordinates ( mCanvas ->currentLayer (), vertexMap[beforeVertex]->point () ), false );
253
255
vertexMap[beforeVertex]->setRubberBandValues ( true , lastRubberBand, index );
254
256
index++;
255
257
}
256
258
while ( vertex != -1 && vertexMap[vertex]->isSelected () && !vertexMap[vertex]->isInRubberBand () )
257
259
{
258
- // topology rubber band creation if needed
260
+ // topology rubberband creation if needed
259
261
if ( topologicalEditing )
260
262
{
261
- createTopologyRubbedBands ( vlayer, vertexMap, vertex );
263
+ createTopologyRubberBands ( vlayer, vertexMap, vertex );
262
264
}
263
- // adding point which will be moved
265
+ // adding point which will be moved
264
266
rb->addPoint ( toMapCoordinates ( mCanvas ->currentLayer (), vertexMap[vertex]->point () ), false );
265
- // setting values about added vertex
267
+ // setting values about added vertex
266
268
vertexMap[vertex]->setRubberBandValues ( true , lastRubberBand, index );
267
269
index++;
268
270
geometry->adjacentVertices ( vertex, beforeVertex, vertex );
269
271
}
270
- if ( vertex != -1 && !vertexMap[vertex]->isSelected () ) // add last point not moving if exists
272
+ if ( vertex != -1 && !vertexMap[vertex]->isSelected () ) // add last point not moving if exists
271
273
{
272
274
rb->addPoint ( toMapCoordinates ( mCanvas ->currentLayer (), vertexMap[vertex]->point () ), true );
273
275
vertexMap[vertex]->setRubberBandValues ( true , lastRubberBand, index );
274
276
index++;
275
277
}
276
- mQgsRubberBands .append ( rb );
278
+ mRubberBands .append ( rb );
277
279
lastRubberBand++;
278
280
}
279
281
}
280
282
}
281
283
282
- void QgsMapToolNodeTool::createTopologyRubbedBands ( QgsVectorLayer* vlayer, const QList<VertexEntry*> &vertexMap, int vertex )
284
+ void QgsMapToolNodeTool::createTopologyRubberBands ( QgsVectorLayer* vlayer, const QList<VertexEntry*> &vertexMap, int vertex )
283
285
{
284
286
QMultiMap<double , QgsSnappingResult> currentResultList;
285
287
QgsGeometry* geometry = mSelectionFeature ->feature ()->geometry ();
286
288
287
- // snapp from current vertex
289
+ // snap from current vertex
288
290
currentResultList.clear ();
289
291
vlayer->snapWithContext ( vertexMap[vertex]->point (), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
290
292
QMultiMap<double , QgsSnappingResult>::iterator resultIt = currentResultList.begin ();
291
293
292
294
for ( ; resultIt != currentResultList.end (); ++resultIt )
293
295
{
294
- // move all other
296
+ // move all other
295
297
if ( mSelectionFeature ->featureId () != resultIt.value ().snappedAtGeometry )
296
298
{
297
299
if ( mTopologyMovingVertexes .contains ( resultIt.value ().snappedAtGeometry ) )
298
300
{
299
301
if ( mTopologyMovingVertexes [resultIt.value ().snappedAtGeometry ]->contains ( resultIt.value ().snappedVertexNr ) )
300
302
{
301
- // skip vertex already exists in some rubberband
303
+ // skip vertex already exists in some rubberband
302
304
continue ;
303
305
}
304
306
}
@@ -310,26 +312,26 @@ void QgsMapToolNodeTool::createTopologyRubbedBands( QgsVectorLayer* vlayer, cons
310
312
311
313
int tVertex = resultIt.value ().snappedVertexNr ;
312
314
int tVertexBackup = -1 , tVertexAfter = -1 ;
313
- int tVertexFirst = tVertex;// vertex number to check for cycling
315
+ int tVertexFirst = tVertex; // vertex number to check for cycling
314
316
QgsFeature topolFeature;
315
317
316
318
vlayer->featureAtId ( resultIt.value ().snappedAtGeometry , topolFeature, true , false );
317
319
QgsGeometry* topolGeometry = topolFeature.geometry ();
318
320
319
- while ( tVertex != -1 ) // looking for first vertex to rubber band
321
+ while ( tVertex != -1 ) // looking for first vertex to rubberband
320
322
{
321
323
tVertexBackup = tVertex;
322
324
topolGeometry->adjacentVertices ( tVertex, tVertex, tVertexAfter );
323
325
if ( tVertex == -1 || tVertex == tVertexFirst )
324
- break ;// chceck if this is not first vertex of the feature or cycling error
325
- // if closest vertex is not from selected feature or is not selected end
326
+ break ; // check if this is not first vertex of the feature or cycling error
327
+ // if closest vertex is not from selected feature or is not selected end
326
328
double dist;
327
329
QgsPoint point = topolGeometry->vertexAt ( tVertex );
328
330
int at, before, after;
329
331
geometry->closestVertex ( point, at, before, after, dist );
330
- if ( dist > ZERO_TOLERANCE || !vertexMap[at]->isSelected () ) // problem with double precision
332
+ if ( dist > ZERO_TOLERANCE || !vertexMap[at]->isSelected () ) // problem with double precision
331
333
{
332
- break ; // found first vertex
334
+ break ; // found first vertex
333
335
}
334
336
}
335
337
@@ -340,14 +342,14 @@ void QgsMapToolNodeTool::createTopologyRubbedBands( QgsVectorLayer* vlayer, cons
340
342
{
341
343
addedPoints = mTopologyMovingVertexes [ resultIt.value ().snappedAtGeometry ];
342
344
}
343
- if ( tVertex == -1 ) // adding first point if needed
345
+ if ( tVertex == -1 ) // adding first point if needed
344
346
{
345
347
tVertex = tVertexBackup;
346
348
}
347
349
else
348
350
{
349
351
trb->addPoint ( topolGeometry->vertexAt ( tVertex ) );
350
- if ( tVertex == tVertexFirst ) // cycle first vertex need to be added also
352
+ if ( tVertex == tVertexFirst ) // cycle first vertex need to be added also
351
353
{
352
354
movingPoints->insert ( movingPointIndex );
353
355
}
@@ -357,21 +359,21 @@ void QgsMapToolNodeTool::createTopologyRubbedBands( QgsVectorLayer* vlayer, cons
357
359
358
360
while ( tVertex != -1 )
359
361
{
360
- // if closest vertex is not from selected feature or is not selected end
362
+ // if closest vertex is not from selected feature or is not selected end
361
363
double dist;
362
364
QgsPoint point = topolGeometry->vertexAt ( tVertex );
363
365
int at, before, after;
364
366
geometry->closestVertex ( point, at, before, after, dist );
365
367
// find first no matching vertex
366
- if ( dist > ZERO_TOLERANCE || !vertexMap[at]->isSelected () ) // problem with double precision
368
+ if ( dist > ZERO_TOLERANCE || !vertexMap[at]->isSelected () ) // problem with double precision
367
369
{
368
370
trb->addPoint ( topolGeometry->vertexAt ( tVertex ) );
369
- break ; // found first vertex
371
+ break ; // found first vertex
370
372
}
371
- else // add moving point to rubber band
373
+ else // add moving point to rubberband
372
374
{
373
375
if ( addedPoints->contains ( tVertex ) )
374
- break ; // just preventing to circle
376
+ break ; // just preventing to circle
375
377
trb->addPoint ( topolGeometry->vertexAt ( tVertex ) );
376
378
movingPoints->insert ( movingPointIndex );
377
379
movingPointIndex++;
@@ -387,7 +389,7 @@ void QgsMapToolNodeTool::createTopologyRubbedBands( QgsVectorLayer* vlayer, cons
387
389
388
390
void QgsMapToolNodeTool::coordinatesChanged ()
389
391
{
390
- // need to update vertex markers since coordinate systems have changed
392
+ // need to update vertex markers since coordinate systems have changed
391
393
if ( mSelectionFeature != NULL )
392
394
{
393
395
mSelectionFeature ->updateVertexMarkersPosition ();
@@ -412,8 +414,8 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
412
414
mSelectAnother = false ;
413
415
if ( mMoving )
414
416
{
415
- // create rubberband if none exists
416
- if ( mQgsRubberBands .empty () )
417
+ // create rubberband if none exists
418
+ if ( mRubberBands .empty () )
417
419
{
418
420
if ( mIsPoint )
419
421
{
@@ -423,7 +425,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
423
425
if ( vertexMap[i]->isSelected () )
424
426
{
425
427
QgsRubberBand* rb = createRubberBandMarker ( vertexMap[i]->point (), vlayer );
426
- mQgsRubberBands .append ( rb );
428
+ mRubberBands .append ( rb );
427
429
}
428
430
}
429
431
}
@@ -434,32 +436,32 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
434
436
}
435
437
else
436
438
{
437
- // move rubber band
439
+ // move rubberband
438
440
QList<QgsSnappingResult> snapResults;
439
441
QgsPoint firstCoords = mCanvas ->getCoordinateTransform ()->toMapPoint ( mLastCoordinates ->x (), mLastCoordinates ->y () );
440
442
QList<QgsPoint> excludePoints;
441
443
excludePoints.append ( mClosestVertex );
442
444
mSnapper .snapToBackgroundLayers ( e->pos (), snapResults, excludePoints );
443
- // get correct coordinates to move
445
+ // get correct coordinates to move
444
446
QgsPoint posMapCoord = snapPointFromResults ( snapResults, e->pos () );
445
447
if ( snapResults.size () > 0 )
446
448
{
447
449
firstCoords = toMapCoordinates ( vlayer, mClosestVertex );
448
450
}
449
451
450
- // special handling of points
452
+ // special handling of points
451
453
if ( mIsPoint )
452
454
{
453
455
double offsetX = posMapCoord.x () - firstCoords.x ();
454
456
double offsetY = posMapCoord.y () - firstCoords.y ();
455
- for ( int i = 0 ; i < mQgsRubberBands .size (); i++ )
457
+ for ( int i = 0 ; i < mRubberBands .size (); i++ )
456
458
{
457
- mQgsRubberBands [i]->setTranslationOffset ( offsetX, offsetY );
459
+ mRubberBands [i]->setTranslationOffset ( offsetX, offsetY );
458
460
}
459
461
return ;
460
462
}
461
463
462
- // move points
464
+ // move points
463
465
QList<VertexEntry*> &vertexMap = mSelectionFeature ->vertexMap ();
464
466
for ( int i = 0 ; i < vertexMap.size (); i++ )
465
467
{
@@ -470,15 +472,15 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
470
472
double x = mapCoords.x () + posMapCoord.x () - firstCoords.x ();
471
473
double y = mapCoords.y () + posMapCoord.y () - firstCoords.y ();
472
474
473
- mQgsRubberBands [vertexMap[i]->rubberBandNr ()]->movePoint ( vertexMap[i]->index (), QgsPoint ( x, y ) );
475
+ mRubberBands [vertexMap[i]->rubberBandNr ()]->movePoint ( vertexMap[i]->index (), QgsPoint ( x, y ) );
474
476
if ( vertexMap[i]->index () == 0 )
475
477
{
476
- mQgsRubberBands [vertexMap[i]->rubberBandNr ()]->movePoint ( 0 , QgsPoint ( x, y ) );
478
+ mRubberBands [vertexMap[i]->rubberBandNr ()]->movePoint ( 0 , QgsPoint ( x, y ) );
477
479
}
478
480
}
479
481
}
480
482
481
- // topological editing
483
+ // topological editing
482
484
double offsetX = posMapCoord.x () - mPosMapCoordBackup .x ();
483
485
double offsetY = posMapCoord.y () - mPosMapCoordBackup .y ();
484
486
for ( int i = 0 ; i < mTopologyRubberBand .size (); i++ )
@@ -546,7 +548,7 @@ bool QgsMapToolNodeTool::checkCorrectnessOfFeature( QgsVectorLayer *vlayer )
546
548
{
547
549
if ( !feat.geometry ()->isGeosEqual ( *mSelectionFeature ->feature ()->geometry () ) )
548
550
{
549
- // update markers when geometries are not valid
551
+ // update markers when geometries are not valid
550
552
mSelectionFeature ->updateFromFeature ();
551
553
}
552
554
}
@@ -583,22 +585,22 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
583
585
return ;
584
586
}
585
587
mSelectionFeature = new SelectionFeature ();
586
- mSelectionFeature ->setSelectedFeature ( snapResults[0 ].snappedAtGeometry , vlayer, NULL , mCanvas );
588
+ mSelectionFeature ->setSelectedFeature ( snapResults[0 ].snappedAtGeometry , vlayer, NULL , mCanvas );
587
589
mIsPoint = vlayer->dataProvider ()->geometryType () == QGis::WKBPoint
588
590
|| vlayer->dataProvider ()->geometryType () == QGis::WKBMultiPoint;
589
591
connectSignals ( vlayer );
590
592
}
591
593
else
592
594
{
593
- // check if feature is not modified from backgound and still exists
594
- // Note this code should never be reached signals should handle this error
595
+ // check if feature is not modified from background and still exists
596
+ // Note this code should never be reached signals should handle this error
595
597
if ( !checkCorrectnessOfFeature ( vlayer ) )
596
598
return ;
597
599
598
- // some feature already selected
600
+ // some feature already selected
599
601
QgsPoint mapCoordPoint = mCanvas ->getCoordinateTransform ()->toMapPoint ( e->pos ().x (), e->pos ().y () );
600
602
double tol = QgsTolerance::vertexSearchRadius ( vlayer, mCanvas ->mapRenderer () );
601
- // get geometry and find if snapping is near it
603
+ // get geometry and find if snapping is near it
602
604
QgsFeature f;
603
605
vlayer->featureAtId ( mSelectionFeature ->featureId (), f, true , false );
604
606
QgsGeometry* g = f.geometry ();
@@ -608,12 +610,12 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
608
610
dist = sqrt ( dist );
609
611
610
612
mSnapper .snapToCurrentLayer ( e->pos (), snapResults, QgsSnapper::SnapToVertex, tol );
611
- // if (snapResults.size() < 1)
613
+ // if (snapResults.size() < 1)
612
614
if ( dist > tol )
613
615
{
614
- // for points only selecting another feature
615
- // no vertexes found (selecting or inverting selection) if move
616
- // or select another feature if clicked there
616
+ // for points only selecting another feature
617
+ // no vertexes found (selecting or inverting selection) if move
618
+ // or select another feature if clicked there
617
619
QgsSnapper::SnappingType snapType = QgsSnapper::SnapToSegment;
618
620
if ( mIsPoint )
619
621
{
@@ -622,7 +624,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
622
624
mSnapper .snapToCurrentLayer ( e->pos (), snapResults, snapType, tol );
623
625
if ( snapResults.size () > 0 )
624
626
{
625
- // need to check all if there is a point in my selected feature
627
+ // need to check all if there is a point in my selected feature
626
628
mAnother = snapResults.first ().snappedAtGeometry ;
627
629
mSelectAnother = true ;
628
630
QList<QgsSnappingResult>::iterator it = snapResults.begin ();
@@ -661,7 +663,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
661
663
}
662
664
else
663
665
{
664
- // some vertex selected
666
+ // some vertex selected
665
667
mMoving = true ;
666
668
QgsPoint point = mCanvas ->getCoordinateTransform ()->toMapPoint ( e->pos ().x (), e->pos ().y () );
667
669
mClosestVertex = getClosestVertex ( toLayerCoordinates ( vlayer, point ) );
@@ -682,7 +684,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
682
684
}
683
685
else
684
686
{
685
- // select another feature
687
+ // select another feature
686
688
mAnother = snapResults.first ().snappedAtGeometry ;
687
689
mSelectAnother = true ;
688
690
}
@@ -709,8 +711,8 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
709
711
mClicked = false ;
710
712
mSelectionRectangle = false ;
711
713
QgsPoint coords = toMapCoordinates ( e->pos () );
712
- // QgsPoint coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
713
- // QgsPoint firstCoords = toMapCoordinates( *mLastCoordinates );
714
+ // QgsPoint coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
715
+ // QgsPoint firstCoords = toMapCoordinates( *mLastCoordinates );
714
716
QgsPoint firstCoords = mCanvas ->getCoordinateTransform ()->toMapPoint ( mLastCoordinates ->x (), mLastCoordinates ->y () );
715
717
if ( mQRubberBand != NULL )
716
718
{
@@ -722,7 +724,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
722
724
{
723
725
if ( mSelectAnother )
724
726
{
725
- // select another feature (this should deselect current one ;-) )
727
+ // select another feature (this should deselect current one ;-) )
726
728
mSelectionFeature ->setSelectedFeature ( mAnother , vlayer, NULL , mCanvas );
727
729
mIsPoint = vlayer->dataProvider ()->geometryType () == QGis::WKBPoint ||
728
730
vlayer->dataProvider ()->geometryType () == QGis::WKBMultiPoint;
@@ -735,7 +737,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
735
737
QgsPoint layerCoords = toLayerCoordinates ( vlayer, coords );
736
738
QgsPoint layerFirstCoords = toLayerCoordinates ( vlayer, firstCoords );
737
739
738
- // got correct coordinates
740
+ // got correct coordinates
739
741
double topX;
740
742
double bottomX;
741
743
if ( layerCoords.x () > layerFirstCoords.x () )
@@ -769,7 +771,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
769
771
excludePoints.append ( mClosestVertex );
770
772
mSnapper .snapToBackgroundLayers ( e->pos (), snapResults, excludePoints );
771
773
coords = snapPointFromResults ( snapResults, e->pos () );
772
- // coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
774
+ // coords = mCanvas->getCoordinateTransform()->toMapPoint( e->pos().x(), e->pos().y() );
773
775
int topologicalEditing = QgsProject::instance ()->readNumEntry ( " Digitizing" , " /TopologicalEditing" , 0 );
774
776
if ( snapResults.size () > 0 )
775
777
{
@@ -787,9 +789,9 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
787
789
mSelectionFeature ->moveSelectedVertexes ( changeX, changeY );
788
790
mCanvas ->refresh ();
789
791
mChangingGeometry = false ;
790
- // movingVertexes
792
+ // movingVertexes
791
793
}
792
- else // selecting vertexes by rubber band
794
+ else // selecting vertexes by rubberband
793
795
{
794
796
QList<VertexEntry*> &vertexMap = mSelectionFeature ->vertexMap ();
795
797
if ( !mCtrl )
@@ -801,7 +803,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
801
803
if ( vertexMap[i]->point ().x () < bottomX && vertexMap[i]->point ().y () > leftY
802
804
&& vertexMap[i]->point ().x () > topX && vertexMap[i]->point ().y () < rightY )
803
805
{
804
- // inverting selection is enough because all were deselected if ctrl is not pressed
806
+ // inverting selection is enough because all were deselected if ctrl is not pressed
805
807
mSelectionFeature ->invertVertexSelection ( i, false );
806
808
}
807
809
}
@@ -835,25 +837,23 @@ void QgsMapToolNodeTool::deactivate()
835
837
836
838
void QgsMapToolNodeTool::removeRubberBands ()
837
839
{
838
- // cleanup rubber bands and list
839
- QList<QgsRubberBand*>::iterator rb_it = mQgsRubberBands .begin ();
840
- for ( ; rb_it != mQgsRubberBands .end (); ++rb_it )
840
+ // cleanup rubberbands and list
841
+ foreach ( QgsRubberBand *rb, mRubberBands )
841
842
{
842
- delete *rb_it ;
843
+ delete rb ;
843
844
}
844
- mQgsRubberBands .clear ();
845
+ mRubberBands .clear ();
845
846
846
- rb_it = mTopologyRubberBand .begin ();
847
- for ( ; rb_it != mTopologyRubberBand .end (); ++rb_it )
847
+ foreach ( QgsRubberBand *rb, mTopologyRubberBand )
848
848
{
849
- delete *rb_it ;
849
+ delete rb ;
850
850
}
851
851
mTopologyRubberBand .clear ();
852
852
853
853
mTopologyMovingVertexes .clear ();
854
854
mTopologyRubberBandVertexes .clear ();
855
855
856
- // remove all data from selected feature (no change to rubber bands itself)
856
+ // remove all data from selected feature (no change to rubberbands itself)
857
857
if ( mSelectionFeature != NULL )
858
858
mSelectionFeature ->cleanRubberBandsData ();
859
859
}
@@ -876,11 +876,11 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
876
876
mSnapper .snapToCurrentLayer ( e->pos (), snapResults, QgsSnapper::SnapToSegment, tol );
877
877
if ( snapResults.size () < 1 )
878
878
{
879
- // nowhere to pul vertex
879
+ // nowhere to put vertex
880
880
}
881
881
else
882
882
{
883
- // some segment selected
883
+ // some segment selected
884
884
if ( snapResults.first ().snappedAtGeometry == mSelectionFeature ->featureId () )
885
885
{
886
886
if ( snapResults.first ().snappedVertexNr == -1 )
@@ -889,15 +889,15 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
889
889
QgsPoint layerCoords = toLayerCoordinates ( vlayer, coords );
890
890
if ( topologicalEditing )
891
891
{
892
- // snapp from adding position to this vertex when topological editing is enabled
892
+ // snap from adding position to this vertex when topological editing is enabled
893
893
currentResultList.clear ();
894
894
vlayer->snapWithContext ( layerCoords, ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToSegment );
895
895
}
896
896
897
897
vlayer->beginEditCommand ( tr ( " Inserted vertex" ) );
898
898
mChangingGeometry = true ;
899
899
900
- // add vertex
900
+ // add vertex
901
901
vlayer->insertVertex ( layerCoords.x (), layerCoords.y (), mSelectionFeature ->featureId (), snapResults.first ().afterVertexNr );
902
902
903
903
if ( topologicalEditing )
@@ -906,7 +906,7 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
906
906
907
907
for ( ; resultIt != currentResultList.end (); ++resultIt )
908
908
{
909
- // create vertexes on same position when topological editing is enabled
909
+ // create vertexes on same position when topological editing is enabled
910
910
if ( mSelectionFeature ->featureId () != resultIt.value ().snappedAtGeometry )
911
911
vlayer->insertVertex ( layerCoords.x (), layerCoords.y (), resultIt.value ().snappedAtGeometry , resultIt.value ().afterVertexNr );
912
912
}
@@ -958,8 +958,7 @@ void QgsMapToolNodeTool::keyReleaseEvent( QKeyEvent* e )
958
958
}
959
959
960
960
961
- // selection object
962
-
961
+ // selection object
963
962
964
963
SelectionFeature::SelectionFeature ()
965
964
{
@@ -1027,7 +1026,6 @@ void SelectionFeature::setSelectedFeature( QgsFeatureId featureId,
1027
1026
mFeature = feature;
1028
1027
}
1029
1028
1030
- // createvertexmap
1031
1029
createVertexMap ();
1032
1030
1033
1031
validateGeometry ();
@@ -1107,13 +1105,13 @@ void SelectionFeature::deleteSelectedVertexes()
1107
1105
{
1108
1106
if ( mVertexMap [i]->equals () != -1 )
1109
1107
{
1110
- // to avoid try to delete some vertex twice
1108
+ // to avoid try to delete some vertex twice
1111
1109
mVertexMap [ mVertexMap [i]->equals ()]->setSelected ( false );
1112
1110
}
1113
1111
1114
1112
if ( topologicalEditing )
1115
1113
{
1116
- // snapp from current vertex
1114
+ // snap from current vertex
1117
1115
currentResultList.clear ();
1118
1116
mVlayer ->snapWithContext ( mVertexMap [i]->point (), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
1119
1117
}
@@ -1131,7 +1129,7 @@ void SelectionFeature::deleteSelectedVertexes()
1131
1129
1132
1130
for ( ; resultIt != currentResultList.end (); ++resultIt )
1133
1131
{
1134
- // move all other
1132
+ // move all other
1135
1133
if ( mFeatureId != resultIt.value ().snappedAtGeometry )
1136
1134
mVlayer ->deleteVertex ( resultIt.value ().snappedAtGeometry , resultIt.value ().snappedVertexNr );
1137
1135
}
@@ -1176,7 +1174,7 @@ void SelectionFeature::moveSelectedVertexes( double changeX, double changeY )
1176
1174
{
1177
1175
if ( topologicalEditing )
1178
1176
{
1179
- // snapp from current vertex
1177
+ // snap from current vertex
1180
1178
currentResultList.clear ();
1181
1179
mVlayer ->snapWithContext ( mVertexMap [i]->point (), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
1182
1180
}
@@ -1191,7 +1189,7 @@ void SelectionFeature::moveSelectedVertexes( double changeX, double changeY )
1191
1189
1192
1190
for ( ; resultIt != currentResultList.end (); ++resultIt )
1193
1191
{
1194
- // move all other
1192
+ // move all other
1195
1193
if ( mFeatureId != resultIt.value ().snappedAtGeometry )
1196
1194
mVlayer ->moveVertex ( mVertexMap [i]->point ().x (), mVertexMap [i]->point ().y (),
1197
1195
resultIt.value ().snappedAtGeometry , resultIt.value ().snappedVertexNr );
@@ -1207,7 +1205,7 @@ void SelectionFeature::moveSelectedVertexes( double changeX, double changeY )
1207
1205
{
1208
1206
mVertexMap [ entry->equals ()]->moveCenter ( changeX, changeY );
1209
1207
mVertexMap [ entry->equals ()]->update ();
1210
- // for polygon delete both
1208
+ // for polygon delete both
1211
1209
}
1212
1210
}
1213
1211
}
@@ -1222,7 +1220,7 @@ void SelectionFeature::moveSelectedVertexes( double changeX, double changeY )
1222
1220
tr ( " Result geometry is invalid. Reverting last changes." ),
1223
1221
QMessageBox::Ok ,
1224
1222
QMessageBox::Ok );
1225
- // redo last operations
1223
+ // redo last operations
1226
1224
mVlayer ->destroyEditCommand ();
1227
1225
updateFromFeature ();
1228
1226
}
@@ -1236,10 +1234,10 @@ void SelectionFeature::moveSelectedVertexes( double changeX, double changeY )
1236
1234
1237
1235
void SelectionFeature::updateFromFeature ()
1238
1236
{
1239
- // delete old map
1237
+ // delete old map
1240
1238
deleteVertexMap ();
1241
1239
1242
- // create new map
1240
+ // create new map
1243
1241
createVertexMap ();
1244
1242
}
1245
1243
@@ -1268,7 +1266,8 @@ void SelectionFeature::createVertexMapPolygon()
1268
1266
int y = 0 ;
1269
1267
QgsPolygon polygon = mFeature ->geometry ()->asPolygon ();
1270
1268
if ( !polygon.empty () )
1271
- { // polygon
1269
+ {
1270
+ // polygon
1272
1271
for ( int i2 = 0 ; i2 < polygon.size (); i2++ )
1273
1272
{
1274
1273
const QgsPolyline& poly = polygon[i2];
@@ -1282,14 +1281,16 @@ void SelectionFeature::createVertexMapPolygon()
1282
1281
y += poly.size ();
1283
1282
}
1284
1283
}
1285
- else // multipolygon
1284
+ else // multipolygon
1286
1285
{
1287
1286
QgsMultiPolygon multiPolygon = mFeature ->geometry ()->asMultiPolygon ();
1288
1287
for ( int i2 = 0 ; i2 < multiPolygon.size (); i2++ )
1289
- { // iterating through polygons
1288
+ {
1289
+ // iterating through polygons
1290
1290
const QgsPolygon& poly2 = multiPolygon[i2];
1291
1291
for ( int i3 = 0 ; i3 < poly2.size (); i3++ )
1292
- { // iterating through polygon rings
1292
+ {
1293
+ // iterating through polygon rings
1293
1294
const QgsPolyline& poly = poly2[i3];
1294
1295
int i;
1295
1296
for ( i = 0 ; i < poly.size (); i++ )
@@ -1312,7 +1313,7 @@ void SelectionFeature::createVertexMapLine()
1312
1313
QgsMultiPolyline mLine = mFeature ->geometry ()->asMultiPolyline ();
1313
1314
for ( int i2 = 0 ; i2 < mLine .size (); i2++ )
1314
1315
{
1315
- // iterating through polylines
1316
+ // iterating through polylines
1316
1317
QgsPolyline poly = mLine [i2];
1317
1318
int i;
1318
1319
for ( i = 0 ; i < poly.size (); i++ )
@@ -1337,25 +1338,25 @@ void SelectionFeature::createVertexMapPoint()
1337
1338
{
1338
1339
if ( mFeature ->geometry ()->isMultipart () )
1339
1340
{
1340
- // multipoint
1341
+ // multipoint
1341
1342
QgsMultiPoint poly = mFeature ->geometry ()->asMultiPoint ();
1342
1343
int i;
1343
1344
for ( i = 0 ; i < poly.size (); i++ )
1344
1345
{
1345
- mVertexMap [i] = new VertexEntry ( mCanvas , mVlayer , poly[i], 1 , tr ( " point %1" ).arg ( i ) );
1346
+ mVertexMap . insert ( i, new VertexEntry ( mCanvas , mVlayer , poly[i], 1 , tr ( " point %1" ).arg ( i ) ) );
1346
1347
}
1347
1348
}
1348
1349
else
1349
1350
{
1350
- // single point
1351
- mVertexMap [ 1 ] = new VertexEntry ( mCanvas , mVlayer , mFeature ->geometry ()->asPoint (), 1 , tr ( " single point" ) );
1351
+ // single point
1352
+ mVertexMap . insert ( 1 , new VertexEntry ( mCanvas , mVlayer , mFeature ->geometry ()->asPoint (), 1 , tr ( " single point" ) ) );
1352
1353
}
1353
1354
}
1354
1355
1355
1356
void SelectionFeature::createVertexMap ()
1356
1357
{
1357
1358
mVlayer ->featureAtId ( mFeatureId , *mFeature );
1358
- // createvertexmap for correct geometry type
1359
+ // createvertexmap for correct geometry type
1359
1360
if ( mFeature ->geometry ()->type () == QGis::Polygon )
1360
1361
{
1361
1362
createVertexMapPolygon ();
@@ -1413,22 +1414,22 @@ void SelectionFeature::invertVertexSelection( int vertexNr, bool invert )
1413
1414
{
1414
1415
VertexEntry *entry = mVertexMap [vertexNr];
1415
1416
1416
- bool selected = entry->isSelected ();
1417
+ bool selected = ! entry->isSelected ();
1417
1418
1418
1419
entry->setSelected ( selected );
1419
1420
entry->update ();
1420
1421
1421
1422
if ( entry->equals () != -1 && invert )
1422
1423
{
1423
- entry = mVertexMap [ mVertexMap [vertexNr] ->equals ()];
1424
+ entry = mVertexMap [ entry ->equals ()];
1424
1425
entry->setSelected ( selected );
1425
1426
entry->update ();
1426
1427
}
1427
1428
}
1428
1429
1429
1430
void SelectionFeature::updateVertexMarkersPosition ()
1430
1431
{
1431
- // function for on-line updating vertex markers without refresh of canvas
1432
+ // function for on-line updating vertex markers without refresh of canvas
1432
1433
for ( int i = 0 ; i < mVertexMap .size (); i++ )
1433
1434
{
1434
1435
VertexEntry *entry = mVertexMap [i];
0 commit comments