@@ -1621,9 +1621,60 @@ bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& pro
1621
1621
return false ;
1622
1622
}
1623
1623
1624
- void QgsProject::setSnapSettingsForLayer ( const QString& layerId, bool enabled, QgsSnapper::SnappingType type, QgsTolerance::UnitType, double tolerance )
1624
+ void QgsProject::setSnapSettingsForLayer ( const QString& layerId, bool enabled, QgsSnapper::SnappingType type, QgsTolerance::UnitType unit , double tolerance, bool avoidIntersection )
1625
1625
{
1626
- // soon...
1626
+ QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1627
+ snapSettings ( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1628
+ int idx = layerIdList.indexOf ( layerId );
1629
+ if ( idx != -1 )
1630
+ {
1631
+ layerIdList.removeAt ( idx );
1632
+ enabledList.removeAt ( idx );
1633
+ snapTypeList.removeAt ( idx );
1634
+ toleranceUnitList.removeAt ( idx );
1635
+ toleranceList.removeAt ( idx );
1636
+ avoidIntersectionList.removeOne ( layerId );
1637
+ }
1638
+
1639
+ layerIdList.append ( layerId );
1640
+
1641
+ // enabled
1642
+ enabledList.append ( enabled ? " enabled" : " disabled" );
1643
+
1644
+ // snap type
1645
+ QString typeString;
1646
+ if ( type == QgsSnapper::SnapToSegment )
1647
+ {
1648
+ typeString = " to_segment" ;
1649
+ }
1650
+ else if ( type == QgsSnapper::SnapToVertexAndSegment )
1651
+ {
1652
+ typeString = " to_vertex_and_segment" ;
1653
+ }
1654
+ else
1655
+ {
1656
+ typeString = " to_vertex" ;
1657
+ }
1658
+ snapTypeList.append ( typeString );
1659
+
1660
+ // units
1661
+ toleranceUnitList.append ( unit == QgsTolerance::Pixels ? " 1" : " 0" );
1662
+
1663
+ // tolerance
1664
+ toleranceList.append ( QString::number ( tolerance ) );
1665
+
1666
+ // avoid intersection
1667
+ if ( avoidIntersection )
1668
+ {
1669
+ avoidIntersectionList.append ( layerId );
1670
+ }
1671
+
1672
+ writeEntry ( " Digitizing" , " /LayerSnappingList" , layerIdList );
1673
+ writeEntry ( " Digitizing" , " /LayerSnappingEnabledList" , enabledList );
1674
+ writeEntry ( " Digitizing" , " /LayerSnappingToleranceList" , toleranceList );
1675
+ writeEntry ( " Digitizing" , " /LayerSnappingToleranceUnitList" , toleranceUnitList );
1676
+ writeEntry ( " Digitizing" , " /LayerSnapToList" , snapTypeList );
1677
+ writeEntry ( " Digitizing" , " /AvoidIntersectionsList" , avoidIntersectionList );
1627
1678
}
1628
1679
1629
1680
bool QgsProject::snapSettingsForLayer ( const QString& layerId, bool & enabled, QgsSnapper::SnappingType &type, QgsTolerance::UnitType& units, double & tolerance,
0 commit comments