Skip to content
Permalink
Browse files

[FEATURE][needs-doc] Vertex tool can work on the current layer only

  • Loading branch information
pblottiere authored and nyalldawson committed May 4, 2018
1 parent 9259d60 commit 6363aba94e36d4611da234cf3e5a5b364e697f71
@@ -626,6 +626,7 @@
<file>themes/default/mIconSnappingSegment.svg</file>
<file>themes/default/mIconTopologicalEditing.svg</file>
<file>themes/default/mIconSnappingIntersection.svg</file>
<file>themes/default/mIconEditVerticesAllLayers.svg</file>
<file>themes/default/mActionMoveFeatureCopy.svg</file>
<file>themes/default/mActionMoveFeatureCopyLine.svg</file>
<file>themes/default/mActionMoveFeatureCopyPoint.svg</file>
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
viewBox="0 0 24 24"
width="24"
version="1.1"
id="svg44"
sodipodi:docname="mIconEditVerticesAllLayers.svg"
inkscape:version="0.92.3pre0 (0ab9bec, 2018-03-03)">
<metadata
id="metadata50">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs48" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1918"
inkscape:window-height="528"
id="namedview46"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="-3.7627119"
inkscape:cy="9.206675"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="0"
inkscape:current-layer="svg44" />
<g
transform="matrix(1.0740922,0,0,1.1040932,-1.2156489,-11.850452)"
id="g14">
<g
style="fill-rule:evenodd;stroke-width:0.60000002"
transform="translate(38,24.5)"
id="g6">
<path
style="fill:#b9770e;fill-opacity:0.9901962;stroke:#986005"
inkscape:connector-curvature="0"
d="m -17.5,7 -10,-10 2,-2 10,10 z"
id="path2-3" />
<path
style="fill:#d5d5d5;stroke:#717171"
inkscape:connector-curvature="0"
d="m -26,0.5 h -1 l -1,-1 v -1 l 3.5,-3.5 3,-1 1,1 z"
id="path4-6" />
</g>
<g
style="stroke-width:2.5119009"
transform="matrix(0.23888159,0,0,0.23884426,24.846478,14.810562)"
id="g12">
<path
style="fill:#d5d5d5;stroke:#717171"
inkscape:connector-curvature="0"
d="m -35.438573,40.244016 c 0,0 18.020569,-18.033655 18.199486,-18.212697 0.05144,-0.222014 0.393619,-2.16821 0.393619,-2.16821 0.0255,-0.109664 0.09125,-0.205453 0.184286,-0.269013 l 5.372891,-3.502527 c 0.07604,-0.05192 0.16371,-0.07744 0.251379,-0.07744 0.115402,0 0.229909,0.04476 0.316236,0.131149 l 2.0785747,2.080032 c 0.1547644,0.154424 0.1748924,0.39837 0.04786,0.576518 l -3.6794367,5.377108 c -0.0662,0.09265 -0.165052,0.156662 -0.276428,0.179043 0,0 -1.835694,0.260059 -2.068733,0.307059 -0.189653,0.189338 -18.194121,18.207325 -18.194121,18.207325 -0.08409,0.08415 -0.197256,0.131149 -0.316236,0.131149 v 0 c -0.11898,0 -0.232592,-0.047 -0.316237,-0.131149 l -1.993588,-1.994985 c -0.174445,-0.175462 -0.174445,-0.458798 4.87e-4,-0.633365 z"
id="path8-7" />
<path
style="fill:#fce94f;stroke:#c4a000"
inkscape:connector-curvature="0"
d="m -61.565894,61.279774 16.753833,-16.766031 c 0.88922,-0.889843 1.985537,-1.355355 3.156105,-1.355355 0.220069,0 0.444609,0.03581 0.669151,0.06893 0.227225,-0.226936 1.205009,-1.205854 1.383927,-1.384897 0.02728,-0.29542 0.328314,-3.594288 0.328314,-3.594288 0.0022,-0.02372 0.0063,-0.047 0.01207,-0.07027 0.122111,-0.478939 0.412405,-0.81375 0.795288,-0.918937 0.08364,-0.02283 0.16863,-0.03402 0.254063,-0.03402 0.308185,0 0.624869,0.145024 0.898165,0.418959 l 7.099447,7.105321 c 0.349337,0.349581 0.489786,0.769885 0.384672,1.153036 -0.105114,0.383152 -0.439689,0.674098 -0.918742,0.796294 -0.02326,0.0063 -0.04652,0.01029 -0.07023,0.01208 0,0 -3.295659,0.301688 -3.590873,0.328097 -0.178918,0.179042 -1.156702,1.15796 -1.38348,1.385345 0.209781,1.419363 -0.228566,2.77248 -1.285969,3.82749 l -16.754281,16.766031 c -0.901297,0.901929 -2.009244,1.378631 -3.204412,1.378631 -1.414343,0 -2.851945,-0.660222 -4.048903,-1.857571 -2.275831,-2.277874 -2.47264,-5.262967 -0.478157,-7.258849 z"
id="path10-5" />
</g>
</g>
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749;stroke-linecap:round;stroke-linejoin:round"
d="M 13.174803,2.6733591 H 4.4480969 L 0.95741448,12.970375"
id="path16" />
<path
inkscape:connector-curvature="0"
style="fill:#dcdcdc;stroke:#5c5c5c;stroke-width:0.69227749"
d="M 2.7027558,0.95718984 H 6.1934382 V 4.3895283 H 2.7027558 Z"
id="path18" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749"
d="M 2.7027558,4.3895283 6.1934382,0.95718984"
id="path20" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749"
d="M 2.7027558,0.95718984 6.1934382,4.3895283"
id="path22" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749;stroke-linecap:round;stroke-linejoin:round"
d="M 16.665486,6.1056976 H 7.9387792 L 4.4480972,16.402713"
id="path16-0" />
<path
inkscape:connector-curvature="0"
style="fill:#dcdcdc;stroke:#5c5c5c;stroke-width:0.69227749"
d="m 6.1934382,4.3895283 h 3.490683 v 3.4323388 h -3.490683 z"
id="path18-9" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749"
d="M 6.1934382,7.8218671 9.6841212,4.3895283"
id="path20-3" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#5c5c5c;stroke-width:0.69227749"
d="m 6.1934382,4.3895283 3.490683,3.4323388"
id="path22-6" />
</svg>
@@ -191,6 +191,10 @@ Returns if the snapping on intersection is enabled
Sets if the snapping on intersection is enabled
%End

bool editVerticesOnAllLayers() const;

void setEditVerticesOnAllLayers( bool enabled );

SIP_PYDICT individualLayerSettings() const;
%Docstring
Returns individual snapping settings for all layers
@@ -969,6 +969,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

//default snap mode
mSnappingEnabledDefault->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool() );
mEditVerticesOnAllLayersDefault->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/default_edit_vertices_on_all_layers_enabled" ), true ).toBool() );
mDefaultSnapModeComboBox->addItem( tr( "Vertex" ), QgsSnappingConfig::Vertex );
mDefaultSnapModeComboBox->addItem( tr( "Vertex and segment" ), QgsSnappingConfig::VertexAndSegment );
mDefaultSnapModeComboBox->addItem( tr( "Segment" ), QgsSnappingConfig::Segment );
@@ -1517,6 +1518,7 @@ void QgsOptions::saveOptions()
//default snap mode
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), mSnappingEnabledDefault->isChecked() );
mSettings->setEnumValue( QStringLiteral( "/qgis/digitizing/default_snap_type" ), ( QgsSnappingConfig::SnappingType )mDefaultSnapModeComboBox->currentData().toInt() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_edit_vertices_on_all_layers_enabled" ), mEditVerticesOnAllLayersDefault->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), mDefaultSnappingToleranceSpinBox->value() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/search_radius_vertex_edit" ), mSearchRadiusVertexEditSpinBox->value() );
mSettings->setEnumValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ),
@@ -194,6 +194,14 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
tracingMenu->addAction( widgetAction );
mEnableTracingAction->setMenu( tracingMenu );

// vertex tool may select vertices from all layers
mEditVerticesAllLayersAction = new QAction( tr( "Edit vertices of all editable layers at once" ), this );
mEditVerticesAllLayersAction->setCheckable( true );
mEditVerticesAllLayersAction->setIcon( QIcon( QgsApplication::getThemeIcon( "/mIconEditVerticesAllLayers.svg" ) ) );
mEditVerticesAllLayersAction->setToolTip( tr( "The vertex editor tool allows to edit vertices from many layers at once. This option allows to restore previous behavior, ie only edit active layer. Useful with transaction groups and database trigger design interfering with multi layer editing" ) );
mEditVerticesAllLayersAction->setObjectName( QStringLiteral( "EditVerticesAllLayersAction" ) );
connect( mEditVerticesAllLayersAction, &QAction::toggled, this, &QgsSnappingWidget::enableEditVerticesOnAllLayers );

// layout
if ( mDisplayMode == ToolBar )
{
@@ -221,6 +229,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
tb->addAction( mTopologicalEditingAction );
tb->addAction( mIntersectionSnappingAction );
tb->addAction( mEnableTracingAction );
tb->addAction( mEditVerticesAllLayersAction );
}
else
{
@@ -249,6 +258,12 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
interButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
layout->addWidget( interButton );

QToolButton *editButton = new QToolButton();
editButton->addAction( mEditVerticesAllLayersAction );
editButton->setDefaultAction( mEditVerticesAllLayersAction );
editButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
layout->addWidget( editButton );

layout->setContentsMargins( 0, 0, 0, 0 );
layout->setAlignment( Qt::AlignRight );
layout->setSpacing( mDisplayMode == Widget ? 3 : 0 );
@@ -343,6 +358,11 @@ void QgsSnappingWidget::projectSnapSettingsChanged()
mIntersectionSnappingAction->setChecked( config.intersectionSnapping() );
}

if ( config.editVerticesOnAllLayers() != mEditVerticesAllLayersAction->isChecked() )
{
mEditVerticesAllLayersAction->setChecked( config.editVerticesOnAllLayers() );
}

toggleSnappingWidgets( config.enabled() );
}

@@ -401,6 +421,12 @@ void QgsSnappingWidget::enableIntersectionSnapping( bool enabled )
mProject->setSnappingConfig( mConfig );
}

void QgsSnappingWidget::enableEditVerticesOnAllLayers( bool enabled )
{
mConfig.setEditVerticesOnAllLayers( enabled );
mProject->setSnappingConfig( mConfig );
}

void QgsSnappingWidget::onSnappingTreeLayersChanged()
{
mLayerTreeView->expandAll();
@@ -106,6 +106,8 @@ class APP_EXPORT QgsSnappingWidget : public QWidget

void enableIntersectionSnapping( bool enabled );

void enableEditVerticesOnAllLayers( bool enabled );

void modeButtonTriggered( QAction *action );
void typeButtonTriggered( QAction *action );

@@ -152,6 +154,8 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
QTreeView *mLayerTreeView = nullptr;
QgsFloatingWidget *mAdvancedConfigContainer = nullptr;

QAction *mEditVerticesAllLayersAction = nullptr;

void cleanGroup( QgsLayerTreeNode *node );
};

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

const bool allLayers = canvas()->snappingUtils()->config().editVerticesOnAllLayers();

// for each editable layer, select vertices
const auto layers = canvas()->layers();
for ( QgsMapLayer *layer : layers )
@@ -478,6 +480,9 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( !vlayer || !vlayer->isEditable() || !vlayer->isSpatial() )
continue;

if ( !allLayers && vlayer != currentVectorLayer() )
continue;

QgsRectangle layerRect = toLayerCoordinates( vlayer, map_rect );
QgsFeature f;
QgsFeatureIterator fi = vlayer->getFeatures( QgsFeatureRequest( layerRect ).setSubsetOfAttributes( QgsAttributeList() ) );
@@ -691,7 +696,7 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e )
}

// if there is no match from the current layer, try to use any editable vector layer
if ( !m.isValid() )
if ( !m.isValid() && oldConfig.editVerticesOnAllLayers() )
{
const auto layers = canvas()->layers();
for ( QgsMapLayer *layer : layers )
@@ -111,13 +111,15 @@ bool QgsSnappingConfig::operator==( const QgsSnappingConfig &other ) const
&& mTolerance == other.mTolerance
&& mUnits == other.mUnits
&& mIntersectionSnapping == other.mIntersectionSnapping
&& mEditVerticesOnAllLayers == other.mEditVerticesOnAllLayers
&& mIndividualLayerSettings == other.mIndividualLayerSettings;
}

void QgsSnappingConfig::reset()
{
// get defaults values. They are both used for standard and advanced configuration (per layer)
bool enabled = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool();
const bool editAllLayers = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_edit_vertices_on_all_layers_enabled" ), true ).toBool();
SnappingMode mode = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), AllLayers );
if ( mode == 0 )
{
@@ -130,6 +132,7 @@ void QgsSnappingConfig::reset()
QgsTolerance::UnitType units = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );

// assign main (standard) config
mEditVerticesOnAllLayers = editAllLayers;
mEnabled = enabled;
mMode = mode;
mType = type;
@@ -237,6 +240,16 @@ void QgsSnappingConfig::setIntersectionSnapping( bool enabled )
mIntersectionSnapping = enabled;
}

bool QgsSnappingConfig::editVerticesOnAllLayers() const
{
return mEditVerticesOnAllLayers;
}

void QgsSnappingConfig::setEditVerticesOnAllLayers( bool enabled )
{
mEditVerticesOnAllLayers = enabled;
}

QHash<QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettings> QgsSnappingConfig::individualLayerSettings() const
{
return mIndividualLayerSettings;
@@ -271,6 +284,7 @@ bool QgsSnappingConfig::operator!=( const QgsSnappingConfig &other ) const
|| mType != other.mType
|| mTolerance != other.mTolerance
|| mUnits != other.mUnits
|| mEditVerticesOnAllLayers != other.mEditVerticesOnAllLayers
|| mIndividualLayerSettings != other.mIndividualLayerSettings;
}

@@ -301,6 +315,9 @@ void QgsSnappingConfig::readProject( const QDomDocument &doc )
if ( snapSettingsElem.hasAttribute( QStringLiteral( "intersection-snapping" ) ) )
mIntersectionSnapping = snapSettingsElem.attribute( QStringLiteral( "intersection-snapping" ) ) == QLatin1String( "1" );

if ( snapSettingsElem.hasAttribute( QStringLiteral( "edit-vertices-on-all-layers" ) ) )
mEditVerticesOnAllLayers = snapSettingsElem.attribute( QStringLiteral( "edit-vertices-on-all-layers" ) ) == QLatin1String( "1" );

// do not clear the settings as they must be automatically synchronized with current layers
QDomNodeList nodes = snapSettingsElem.elementsByTagName( QStringLiteral( "individual-layer-settings" ) );
if ( nodes.count() )
@@ -344,6 +361,7 @@ void QgsSnappingConfig::writeProject( QDomDocument &doc )
snapSettingsElem.setAttribute( QStringLiteral( "tolerance" ), mTolerance );
snapSettingsElem.setAttribute( QStringLiteral( "unit" ), ( int )mUnits );
snapSettingsElem.setAttribute( QStringLiteral( "intersection-snapping" ), QString::number( mIntersectionSnapping ) );
snapSettingsElem.setAttribute( QStringLiteral( "edit-vertices-on-all-layers" ), QString::number( mEditVerticesOnAllLayers ) );

QDomElement ilsElement = doc.createElement( QStringLiteral( "individual-layer-settings" ) );
QHash<QgsVectorLayer *, IndividualLayerSettings>::const_iterator layerIt = mIndividualLayerSettings.constBegin();
@@ -172,6 +172,10 @@ class CORE_EXPORT QgsSnappingConfig
//! Sets if the snapping on intersection is enabled
void setIntersectionSnapping( bool enabled );

bool editVerticesOnAllLayers() const;

void setEditVerticesOnAllLayers( bool enabled );

//! Returns individual snapping settings for all layers
#ifndef SIP_RUN
QHash<QgsVectorLayer *, QgsSnappingConfig::IndividualLayerSettings> individualLayerSettings() const;
@@ -292,6 +296,7 @@ class CORE_EXPORT QgsSnappingConfig
double mTolerance = 0.0;
QgsTolerance::UnitType mUnits = QgsTolerance::ProjectUnits;
bool mIntersectionSnapping = false;
bool mEditVerticesOnAllLayers = true;

QHash<QgsVectorLayer *, IndividualLayerSettings> mIndividualLayerSettings;

@@ -4207,6 +4207,28 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_30">
<property name="title">
<string>Vertex tool</string>
</property>
<layout class="QGridLayout" name="_13">
<item row="0" column="0">
<widget class="QCheckBox" name="mEditVerticesOnAllLayersDefault">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The vertex editor tool allows to edit vertices from many layers at once. This option allows to restore previous behavior, ie only edit active layer. Useful with transaction groups and database trigger design interfering with multi layer editing&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Edit vertices of all editable layers at once by default</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mVertexMarkerGroupBox">
<property name="title">

0 comments on commit 6363aba

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