@@ -121,6 +121,13 @@ void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
121
121
{
122
122
if ( mMoveRubberBands .empty () )
123
123
{
124
+ QSettings settings;
125
+ bool ghostLine = settings.value ( " /qgis/digitizing/line_ghost" , false ).toBool ();
126
+ if ( !ghostLine )
127
+ {
128
+ delete mSelectRubberBand ;
129
+ mSelectRubberBand = nullptr ;
130
+ }
124
131
QgsGeometryRubberBand* rb = new QgsGeometryRubberBand ( mCanvas , mSelectedFeature ->geometry ()->type () );
125
132
QSettings settings;
126
133
QColor color (
@@ -242,6 +249,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
242
249
}
243
250
connect ( QgisApp::instance ()->layerTreeView (), SIGNAL ( currentLayerChanged ( QgsMapLayer* ) ), this , SLOT ( currentLayerChanged ( QgsMapLayer* ) ) );
244
251
connect ( mSelectedFeature , SIGNAL ( destroyed () ), this , SLOT ( selectedFeatureDestroyed () ) );
252
+ connect ( vlayer, SIGNAL ( geometryChanged ( QgsFeatureId, QgsGeometry & ) ), this , SLOT ( geometryChanged ( QgsFeatureId, QgsGeometry & ) ) );
245
253
connect ( vlayer, SIGNAL ( editingStopped () ), this , SLOT ( editingToggled () ) );
246
254
mIsPoint = vlayer->geometryType () == QGis::Point ;
247
255
mNodeEditor = new QgsNodeEditor ( vlayer, mSelectedFeature , mCanvas );
@@ -370,25 +378,37 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
370
378
371
379
void QgsMapToolNodeTool::updateSelectFeature ()
372
380
{
373
- delete mSelectRubberBand ;
381
+ updateSelectFeature ( *mSelectedFeature ->geometry () );
382
+ }
374
383
375
- mSelectRubberBand = new QgsGeometryRubberBand ( mCanvas , mSelectedFeature ->geometry ()->type () );
376
- mSelectRubberBand ->setBrushStyle ( Qt::SolidPattern );
384
+ void QgsMapToolNodeTool::updateSelectFeature ( QgsGeometry &geom )
385
+ {
386
+ delete mSelectRubberBand ;
377
387
378
- QSettings settings;
379
- QColor color (
380
- settings.value ( " /qgis/digitizing/fill_color_red" , 255 ).toInt (),
381
- settings.value ( " /qgis/digitizing/fill_color_green" , 0 ).toInt (),
382
- settings.value ( " /qgis/digitizing/fill_color_blue" , 0 ).toInt () );
383
- double myAlpha = settings.value ( " /qgis/digitizing/fill_color_alpha" , 30 ).toInt () / 255.0 ;
384
- color.setAlphaF ( myAlpha );
385
- mSelectRubberBand ->setFillColor ( color );
386
-
387
- QgsAbstractGeometryV2* rbGeom = mSelectedFeature ->geometry ()->geometry ()->clone ();
388
- QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
389
- if ( mCanvas ->mapSettings ().layerTransform ( vlayer ) )
390
- rbGeom->transform ( *mCanvas ->mapSettings ().layerTransform ( vlayer ) );
391
- mSelectRubberBand ->setGeometry ( rbGeom );
388
+ if ( geom.geometry () )
389
+ {
390
+ mSelectRubberBand = new QgsGeometryRubberBand ( mCanvas , mSelectedFeature ->geometry ()->type () );
391
+ mSelectRubberBand ->setBrushStyle ( Qt::SolidPattern );
392
+
393
+ QSettings settings;
394
+ QColor color (
395
+ settings.value ( " /qgis/digitizing/fill_color_red" , 255 ).toInt (),
396
+ settings.value ( " /qgis/digitizing/fill_color_green" , 0 ).toInt (),
397
+ settings.value ( " /qgis/digitizing/fill_color_blue" , 0 ).toInt () );
398
+ double myAlpha = settings.value ( " /qgis/digitizing/fill_color_alpha" , 30 ).toInt () / 255.0 ;
399
+ color.setAlphaF ( myAlpha );
400
+ mSelectRubberBand ->setFillColor ( color );
401
+
402
+ QgsAbstractGeometryV2* rbGeom = geom.geometry ()->clone ();
403
+ QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
404
+ if ( mCanvas ->mapSettings ().layerTransform ( vlayer ) )
405
+ rbGeom->transform ( *mCanvas ->mapSettings ().layerTransform ( vlayer ) );
406
+ mSelectRubberBand ->setGeometry ( rbGeom );
407
+ }
408
+ else
409
+ {
410
+ mSelectRubberBand = nullptr ;
411
+ }
392
412
}
393
413
394
414
void QgsMapToolNodeTool::selectedFeatureDestroyed ()
@@ -397,6 +417,16 @@ void QgsMapToolNodeTool::selectedFeatureDestroyed()
397
417
cleanTool ( false );
398
418
}
399
419
420
+ void QgsMapToolNodeTool::geometryChanged ( QgsFeatureId fid, QgsGeometry &geom )
421
+ {
422
+ QSettings settings;
423
+ bool ghostLine = settings.value ( " /qgis/digitizing/line_ghost" , false ).toBool ();
424
+ if ( !ghostLine && mSelectedFeature && ( mSelectedFeature ->featureId () == fid ) )
425
+ {
426
+ updateSelectFeature ( geom );
427
+ }
428
+ }
429
+
400
430
void QgsMapToolNodeTool::currentLayerChanged ( QgsMapLayer *layer )
401
431
{
402
432
if ( mSelectedFeature && layer != mSelectedFeature ->vlayer () )
@@ -512,8 +542,6 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
512
542
513
543
mDeselectOnRelease = -1 ;
514
544
}
515
-
516
- updateSelectFeature ();
517
545
}
518
546
519
547
void QgsMapToolNodeTool::deactivate ()
0 commit comments