Skip to content

Commit c67d09c

Browse files
pblottierenyalldawson
authored andcommittedJul 20, 2018
Add a dropdown menu for vertex tool and active layer option
1 parent 6363aba commit c67d09c

File tree

8 files changed

+209
-25
lines changed

8 files changed

+209
-25
lines changed
 

‎images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
<file>themes/default/mActionNewGeoPackageLayer.svg</file>
311311
<file>themes/default/mActionNewVectorLayer.svg</file>
312312
<file>themes/default/mActionVertexTool.svg</file>
313+
<file>themes/default/mActionVertexToolActiveLayer.svg</file>
313314
<file>themes/default/mActionOffsetCurve.svg</file>
314315
<file>themes/default/mActionOpenTable.svg</file>
315316
<file>themes/default/mActionAddTable.svg</file>
Lines changed: 136 additions & 17 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading

‎src/app/qgisapp.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ QgisApp::~QgisApp()
14411441
delete mMapTools.mMoveFeatureCopy;
14421442
delete mMapTools.mMoveLabel;
14431443
delete mMapTools.mVertexTool;
1444+
delete mMapTools.mVertexToolActiveLayer;
14441445
delete mMapTools.mOffsetCurve;
14451446
delete mMapTools.mPinLabels;
14461447
delete mMapTools.mReshapeFeatures;
@@ -2024,6 +2025,7 @@ void QgisApp::createActions()
20242025
connect( mActionMergeFeatureAttributes, &QAction::triggered, this, &QgisApp::mergeAttributesOfSelectedFeatures );
20252026
connect( mActionMultiEditAttributes, &QAction::triggered, this, &QgisApp::modifyAttributesOfSelectedFeatures );
20262027
connect( mActionVertexTool, &QAction::triggered, this, &QgisApp::vertexTool );
2028+
connect( mActionVertexToolActiveLayer, &QAction::triggered, this, &QgisApp::vertexToolActiveLayer );
20272029
connect( mActionRotatePointSymbols, &QAction::triggered, this, &QgisApp::rotatePointSymbols );
20282030
connect( mActionOffsetPointSymbol, &QAction::triggered, this, &QgisApp::offsetPointSymbol );
20292031
connect( mActionSnappingOptions, &QAction::triggered, this, &QgisApp::snappingOptions );
@@ -2311,6 +2313,7 @@ void QgisApp::createActionGroups()
23112313
mMapToolGroup->addAction( mActionMergeFeatures );
23122314
mMapToolGroup->addAction( mActionMergeFeatureAttributes );
23132315
mMapToolGroup->addAction( mActionVertexTool );
2316+
mMapToolGroup->addAction( mActionVertexToolActiveLayer );
23142317
mMapToolGroup->addAction( mActionRotatePointSymbols );
23152318
mMapToolGroup->addAction( mActionOffsetPointSymbol );
23162319
mMapToolGroup->addAction( mActionPinLabels );
@@ -2875,6 +2878,16 @@ void QgisApp::createToolBars()
28752878
connect( moveFeatureButton, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
28762879
mAdvancedDigitizeToolBar->insertWidget( mActionRotateFeature, moveFeatureButton );
28772880

2881+
// vertex tool button
2882+
QToolButton *vertexToolButton = new QToolButton( mDigitizeToolBar );
2883+
vertexToolButton->setPopupMode( QToolButton::MenuButtonPopup );
2884+
vertexToolButton->addAction( mActionVertexTool );
2885+
vertexToolButton->addAction( mActionVertexToolActiveLayer );
2886+
mAdvancedDigitizeToolBar->insertWidget( mActionDeleteSelected, vertexToolButton );
2887+
QAction *defActionVertexTool = mActionVertexTool;
2888+
vertexToolButton->setDefaultAction( defActionVertexTool );
2889+
connect( vertexToolButton, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
2890+
28782891
bt = new QToolButton();
28792892
bt->setPopupMode( QToolButton::MenuButtonPopup );
28802893
bt->addAction( mActionRotatePointSymbols );
@@ -3185,6 +3198,7 @@ void QgisApp::setTheme( const QString &themeName )
31853198
mActionSplitParts->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSplitParts.svg" ) ) );
31863199
mActionDeleteSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteSelected.svg" ) ) );
31873200
mActionVertexTool->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionVertexTool.svg" ) ) );
3201+
mActionVertexToolActiveLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionVertexToolActiveLayer.svg" ) ) );
31883202
mActionSimplifyFeature->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSimplify.svg" ) ) );
31893203
mActionUndo->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionUndo.svg" ) ) );
31903204
mActionRedo->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRedo.svg" ) ) );
@@ -3478,6 +3492,8 @@ void QgisApp::createCanvasTools()
34783492
mMapTools.mDeletePart->setAction( mActionDeletePart );
34793493
mMapTools.mVertexTool = new QgsVertexTool( mMapCanvas, mAdvancedDigitizingDockWidget );
34803494
mMapTools.mVertexTool->setAction( mActionVertexTool );
3495+
mMapTools.mVertexToolActiveLayer = new QgsVertexTool( mMapCanvas, mAdvancedDigitizingDockWidget, true );
3496+
mMapTools.mVertexToolActiveLayer->setAction( mActionVertexToolActiveLayer );
34813497
mMapTools.mRotatePointSymbolsTool = new QgsMapToolRotatePointSymbols( mMapCanvas );
34823498
mMapTools.mRotatePointSymbolsTool->setAction( mActionRotatePointSymbols );
34833499
mMapTools.mOffsetPointSymbolTool = new QgsMapToolOffsetPointSymbol( mMapCanvas );
@@ -8245,6 +8261,11 @@ void QgisApp::vertexTool()
82458261
mMapCanvas->setMapTool( mMapTools.mVertexTool );
82468262
}
82478263

8264+
void QgisApp::vertexToolActiveLayer()
8265+
{
8266+
mMapCanvas->setMapTool( mMapTools.mVertexToolActiveLayer );
8267+
}
8268+
82488269
void QgisApp::rotatePointSymbols()
82498270
{
82508271
mMapCanvas->setMapTool( mMapTools.mRotatePointSymbolsTool );
@@ -11927,6 +11948,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
1192711948
mActionRotateFeature->setEnabled( false );
1192811949
mActionOffsetCurve->setEnabled( false );
1192911950
mActionVertexTool->setEnabled( false );
11951+
mActionVertexToolActiveLayer->setEnabled( false );
1193011952
mActionDeleteSelected->setEnabled( false );
1193111953
mActionCutFeatures->setEnabled( false );
1193211954
mActionCopyFeatures->setEnabled( false );
@@ -12108,6 +12130,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
1210812130
mActionMoveFeatureCopy->setEnabled( isEditable && canChangeGeometry );
1210912131
mActionRotateFeature->setEnabled( isEditable && canChangeGeometry );
1211012132
mActionVertexTool->setEnabled( isEditable && canChangeGeometry );
12133+
mActionVertexToolActiveLayer->setEnabled( isEditable && canChangeGeometry );
1211112134

1211212135
if ( vlayer->geometryType() == QgsWkbTypes::PointGeometry )
1211312136
{
@@ -12262,6 +12285,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
1226212285
mActionFillRing->setEnabled( false );
1226312286
mActionAddPart->setEnabled( false );
1226412287
mActionVertexTool->setEnabled( false );
12288+
mActionVertexToolActiveLayer->setEnabled( false );
1226512289
mActionMoveFeature->setEnabled( false );
1226612290
mActionMoveFeatureCopy->setEnabled( false );
1226712291
mActionRotateFeature->setEnabled( false );

‎src/app/qgisapp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,8 +1392,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
13921392
void mergeAttributesOfSelectedFeatures();
13931393
//! Modifies the attributes of selected features via feature form
13941394
void modifyAttributesOfSelectedFeatures();
1395-
//! provides operations with nodes
1395+
//! provides operations with nodes on all layers
13961396
void vertexTool();
1397+
//! provides operations with nodes on active layer only
1398+
void vertexToolActiveLayer();
13971399
//! activates the rotate points tool
13981400
void rotatePointSymbols();
13991401
//! activates the offset point symbol tool
@@ -2000,6 +2002,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
20002002
QgsMapTool *mDeleteRing = nullptr;
20012003
QgsMapTool *mDeletePart = nullptr;
20022004
QgsMapTool *mVertexTool = nullptr;
2005+
QgsMapTool *mVertexToolActiveLayer = nullptr;
20032006
QgsMapTool *mRotatePointSymbolsTool = nullptr;
20042007
QgsMapTool *mOffsetPointSymbolTool = nullptr;
20052008
QgsMapTool *mAnnotation = nullptr;

‎src/app/vertextool/qgsvertextool.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ class SelectedMatchFilter : public QgsPointLocator::MatchFilter
227227
//
228228

229229

230-
QgsVertexTool::QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock )
230+
QgsVertexTool::QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock, bool activeLayerOnly )
231231
: QgsMapToolAdvancedDigitizing( canvas, cadDock )
232+
, mActiveLayerOnly( activeLayerOnly )
232233
{
233234
setAdvancedDigitizingAllowed( false );
234235

@@ -470,8 +471,6 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
470471
QList<Vertex> vertices;
471472
QList<Vertex> selectedVertices;
472473

473-
const bool allLayers = canvas()->snappingUtils()->config().editVerticesOnAllLayers();
474-
475474
// for each editable layer, select vertices
476475
const auto layers = canvas()->layers();
477476
for ( QgsMapLayer *layer : layers )
@@ -480,7 +479,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
480479
if ( !vlayer || !vlayer->isEditable() || !vlayer->isSpatial() )
481480
continue;
482481

483-
if ( !allLayers && vlayer != currentVectorLayer() )
482+
if ( mActiveLayerOnly && vlayer != currentVectorLayer() )
484483
continue;
485484

486485
QgsRectangle layerRect = toLayerCoordinates( vlayer, map_rect );
@@ -696,7 +695,7 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e )
696695
}
697696

698697
// if there is no match from the current layer, try to use any editable vector layer
699-
if ( !m.isValid() && oldConfig.editVerticesOnAllLayers() )
698+
if ( !m.isValid() && !mActiveLayerOnly )
700699
{
701700
const auto layers = canvas()->layers();
702701
for ( QgsMapLayer *layer : layers )

‎src/app/vertextool/qgsvertextool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
6161
{
6262
Q_OBJECT
6363
public:
64-
QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock );
64+
QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock, bool activeLayerOnly = false );
6565

6666
//! Cleanup canvas items we have created
6767
~QgsVertexTool() override;
@@ -404,6 +404,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
404404

405405
//! Starting vertex when using range selection (null if not yet selected)
406406
std::unique_ptr<Vertex> mRangeSelectionFirstVertex;
407+
408+
bool mActiveLayerOnly = false;
407409
};
408410

409411

‎src/ui/qgisapp.ui

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,10 @@
10171017
<normaloff>:/images/themes/default/mActionVertexTool.svg</normaloff>:/images/themes/default/mActionVertexTool.svg</iconset>
10181018
</property>
10191019
<property name="text">
1020-
<string>Vertex Tool</string>
1020+
<string>&amp;Vertex Tool on All Layers</string>
1021+
</property>
1022+
<property name="toolTip">
1023+
<string>Vertex Tool on All Layers</string>
10211024
</property>
10221025
</action>
10231026
<action name="mActionRotatePointSymbols">
@@ -3060,6 +3063,21 @@ Acts on currently active editable layer</string>
30603063
<string>Paste Layer/Group</string>
30613064
</property>
30623065
</action>
3066+
<action name="mActionVertexToolActiveLayer">
3067+
<property name="checkable">
3068+
<bool>true</bool>
3069+
</property>
3070+
<property name="icon">
3071+
<iconset resource="../../images/images.qrc">
3072+
<normaloff>:/images/themes/default/mActionVertexTool.svg</normaloff>:/images/themes/default/mActionVertexTool.svg</iconset>
3073+
</property>
3074+
<property name="text">
3075+
<string>&amp;Vertex Tool on Active Layer</string>
3076+
</property>
3077+
<property name="toolTip">
3078+
<string>Vertex Tool on Active Layer</string>
3079+
</property>
3080+
</action>
30633081
</widget>
30643082
<resources>
30653083
<include location="../../images/images.qrc"/>

0 commit comments

Comments
 (0)
Please sign in to comment.