Skip to content
Permalink
Browse files
Highlight the selected feature
  • Loading branch information
sbrunner committed Nov 7, 2015
1 parent 580f70a commit d73ef5b189bc0dd355a90b48cdc53b8aa996a025
Showing with 31 additions and 1 deletion.
  1. +23 −1 src/app/nodetool/qgsmaptoolnodetool.cpp
  2. +8 −0 src/app/nodetool/qgsmaptoolnodetool.h
@@ -212,13 +212,15 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
// remove previous warning
emit messageDiscarded();
mSelectedFeature = new QgsSelectedFeature( feature.id(), vlayer, mCanvas );
updateSelectFeature();
}
}
else {
// remove previous warning
emit messageDiscarded();

mSelectedFeature = new QgsSelectedFeature( snapResults[0].snappedAtGeometry, vlayer, mCanvas );
updateSelectFeature();
}
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
connect( mSelectedFeature, SIGNAL( destroyed() ), this, SLOT( selectedFeatureDestroyed() ) );
@@ -350,6 +352,21 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
}
}

void QgsMapToolNodeTool::updateSelectFeature()
{
if (mSelectRubberBand != NULL) {
delete mSelectRubberBand;
}
mSelectRubberBand = new QgsGeometryRubberBand( mCanvas, mSelectedFeature->geometry()->type() );
mSelectRubberBand->setBrushStyle( Qt::SolidPattern );
mSelectRubberBand->setFillColor( QColor( 255, 0, 0, 50 ) );
QgsAbstractGeometryV2* rbGeom = mSelectedFeature->geometry()->geometry()->clone();
QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
if ( mCanvas->mapSettings().layerTransform( vlayer ) )
rbGeom->transform( *mCanvas->mapSettings().layerTransform( vlayer ) );
mSelectRubberBand->setGeometry( rbGeom );
}

void QgsMapToolNodeTool::selectedFeatureDestroyed()
{
QgsDebugCall;
@@ -396,6 +413,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
{
// select another feature
mSelectedFeature->setSelectedFeature( mAnother, vlayer, mCanvas );
updateSelectFeature();
mIsPoint = vlayer->geometryType() == QGis::Point;
mSelectAnother = false;
}
@@ -494,6 +512,10 @@ void QgsMapToolNodeTool::cleanTool( bool deleteSelectedFeature )
{
removeRubberBands();

if ( mSelectRubberBand != NULL ) {
delete mSelectRubberBand;
mSelectRubberBand = NULL;
}
if ( mSelectedFeature )
{
QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
@@ -504,7 +526,7 @@ void QgsMapToolNodeTool::cleanTool( bool deleteSelectedFeature )
disconnect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );

if ( deleteSelectedFeature ) delete mSelectedFeature;
mSelectedFeature = 0;
mSelectedFeature = NULL;
}
if ( mNodeEditor )
{
@@ -66,6 +66,11 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
*/
QgsFeature getFeatureAtPoint( QgsMapMouseEvent* e );

/**
* Update select feature rubber band
*/
void updateSelectFeature();

/**
* Deletes the rubber band pointers and clears mRubberBands
*/
@@ -121,6 +126,9 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
/** Rubber bands during node move */
QMap<QgsFeatureId, QgsGeometryRubberBand*> mMoveRubberBands;

/** Rubber band for selected feature */
QgsGeometryRubberBand* mSelectRubberBand;

/** Vertices of features to move */
QMap<QgsFeatureId, QList< QPair<QgsVertexId, QgsPointV2> > > mMoveVertices;

1 comment on commit d73ef5b

@oper4

This comment has been minimized.

Copy link

@oper4 oper4 commented on d73ef5b Nov 8, 2015

Hi!

I'm the author of "bug" report (https://hub.qgis.org/issues/13793) - maybe it wolud be better in case of polygons just to show "semitransparent red" outline?
That's my point of view against "red semitransparent background" - when I edit common boundary of two polygons (snapping options/enable topological editing) using Node tool now only one of them has that red background - so it's weird. Second thing - during editing if I move the feature I still see its old position as a red trace... it's on screencast:
https://www.dropbox.com/s/o9ixhygs87jb2v2/clip4.mp4?dl=0

Currently all the time I digitize sth from rasters and wms's - that's why all my polygon layers have transparent background - and now it's useless to use Node tool as it appears sth on the screen.

Thanks

Piotr Kania

Please sign in to comment.