Skip to content
Permalink
Browse files

Merge pull request #9356 from qgis/backport-9348-on-release-3_4

Backport #9348 on release-3_4
  • Loading branch information
m-kuhn committed Mar 4, 2019
2 parents ad149db + f4ec69b commit 04f91f02889049dc29f68907218de4be1ba67269
Showing with 54 additions and 14 deletions.
  1. +1 −1 .travis.yml
  2. +44 −11 src/app/vertextool/qgsvertextool.cpp
  3. +9 −2 src/app/vertextool/qgsvertextool.h
@@ -9,7 +9,7 @@ cache:
directories:
- ${HOME}/.ccache
timeout: 1000
if: branch !~ /^backport-\d+-on-/
if: NOT branch =~ /^(cherry-pick-)?backport-\d+-on-/

env:
global:
@@ -436,7 +436,10 @@ void QgsVertexTool::cadCanvasPressEvent( QgsMapMouseEvent *e )
}

if ( !clickedOnHighlightedVertex && e->button() == Qt::LeftButton )
{
setHighlightedVertices( QList<Vertex>() ); // reset selection
updateLockedFeatureVertices();
}
}

if ( e->button() == Qt::LeftButton )
@@ -994,11 +997,7 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e )
// there's really nothing under the cursor or while cycling through the list of available features
// we got to the end of the list - let's deselect any feature we may have had selected
setHighlightedVertices( QList<Vertex>(), ModeReset );
mLockedFeature.reset();
if ( mVertexEditor )
{
mVertexEditor->updateEditor( nullptr );
}
cleanupLockedFeature();
}

// we have either locked ourselves to a feature or unlocked again
@@ -1328,11 +1327,7 @@ void QgsVertexTool::updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid
if ( mLockedFeature && mLockedFeature->featureId() == fid && mLockedFeature->layer() == layer )
{
// if show feature is called on a feature that's already binded to the vertex editor, toggle it off
mLockedFeature.reset();
if ( mVertexEditor )
{
mVertexEditor->updateEditor( nullptr );
}
cleanupLockedFeature();
return;
}

@@ -1345,16 +1340,42 @@ void QgsVertexTool::updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid
mLockedFeature->selectVertex( mSelectedVertices.at( i ).vertexId );
}
}

connect( mLockedFeature.get(), &QgsLockedFeature::selectionChanged, this, &QgsVertexTool::lockedFeatureSelectionChanged );
}

updateLockedFeatureVertices();

// make sure the vertex editor is alive and visible
showVertexEditor(); //#spellok

mVertexEditor->updateEditor( mLockedFeature.get() );
}

void QgsVertexTool::updateLockedFeatureVertices()
{
qDeleteAll( mLockedFeatureVerticesMarkers );
mLockedFeatureVerticesMarkers.clear();
if ( mVertexEditor && mLockedFeature )
{
const QList<QgsVertexEntry *> &vertexMap = mLockedFeature->vertexMap();
for ( const QgsVertexEntry *vertex : vertexMap )
{
if ( !vertex->isSelected() )
{
QgsVertexMarker *marker = new QgsVertexMarker( canvas() );
marker->setIconType( QgsVertexMarker::ICON_CIRCLE );
marker->setIconSize( QgsGuiUtils::scaleIconSize( 10 ) );
marker->setPenWidth( QgsGuiUtils::scaleIconSize( 3 ) );
marker->setColor( Qt::red );
marker->setFillColor( Qt::red );
marker->setCenter( toMapCoordinates( mLockedFeature->layer(), vertex->point() ) );
mLockedFeatureVerticesMarkers.append( marker );
}
}
}
}


void QgsVertexTool::showVertexEditor() //#spellok
{
if ( !mVertexEditor )
@@ -1382,6 +1403,16 @@ void QgsVertexTool::cleanupVertexEditor()
mVertexEditor.reset();
}

void QgsVertexTool::cleanupLockedFeature()
{
mLockedFeature.reset();
if ( mVertexEditor )
{
mVertexEditor->updateEditor( nullptr );
}
updateLockedFeatureVertices();
}

void QgsVertexTool::lockedFeatureSelectionChanged()
{
Q_ASSERT( mLockedFeature );
@@ -1396,6 +1427,8 @@ void QgsVertexTool::lockedFeatureSelectionChanged()
}

setHighlightedVertices( vertices, ModeReset );

updateLockedFeatureVertices();
}

static int _firstSelectedVertex( QgsLockedFeature &selectedFeature )
@@ -141,6 +141,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void cleanupVertexEditor();

void cleanupLockedFeature();

/**
* Temporarily override snapping config and snap to vertices and edges
of any editable vector layer, to allow selection of vertex for editing
@@ -292,6 +294,9 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void stopRangeVertexSelection();

//! update the highlight of vertices from the locked feature
void updateLockedFeatureVertices();

private:

// members used for temporary highlight of stuff
@@ -306,7 +311,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
QgsVertexMarker *mEdgeCenterMarker = nullptr;
//! rubber band for highlight of a whole feature on mouse over and not dragging anything
QgsRubberBand *mFeatureBand = nullptr;
//! rubber band for highlight of all vertices of a feature on mouse over and not dragging anything
//! rubber band for highlight of all vertices of a feature on mouse over and not dragging anything, also used for locked feature vertices
QgsRubberBand *mFeatureBandMarkers = nullptr;
//! source layer for mFeatureBand (null if mFeatureBand is null)
const QgsVectorLayer *mFeatureBandLayer = nullptr;
@@ -316,6 +321,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
QgsRubberBand *mVertexBand = nullptr;
//! highlight of an edge while mouse pointer is close to an edge and not dragging anything
QgsRubberBand *mEdgeBand = nullptr;
//! highlight of locked feature vertices (but not selected)
QList<QgsVertexMarker *> mLockedFeatureVerticesMarkers;

// members for dragging operation

@@ -437,7 +444,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

// support for vertex editor

//! Selected feature for the vertex editor
//! Locked feature for the vertex editor
std::unique_ptr<QgsLockedFeature> mLockedFeature;
//! Dock widget which allows editing vertices
std::unique_ptr<QgsVertexEditor> mVertexEditor;

0 comments on commit 04f91f0

Please sign in to comment.
You can’t perform that action at this time.