@@ -1621,7 +1621,81 @@ 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 )
1625
+ {
1626
+ // soon...
1627
+ }
1628
+
1629
+ bool QgsProject::snapSettingsForLayer ( const QString& layerId, bool & enabled, QgsSnapper::SnappingType &type, QgsTolerance::UnitType& units, double & tolerance,
1630
+ bool & avoidIntersection )
1631
+ {
1632
+ QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
1633
+ snapSettings ( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
1634
+ int idx = layerIdList.indexOf ( layerId );
1635
+ if ( idx == -1 )
1636
+ {
1637
+ return false ;
1638
+ }
1639
+
1640
+ // make sure all lists are long enough
1641
+ int minListEntries = idx + 1 ;
1642
+ if ( layerIdList.size () < minListEntries || enabledList.size () < minListEntries || snapTypeList.size () < minListEntries ||
1643
+ toleranceUnitList.size () < minListEntries || toleranceList.size () < minListEntries )
1644
+ {
1645
+ return false ;
1646
+ }
1647
+
1648
+ // enabled
1649
+ enabled = enabledList.at ( idx ) == " enabled" ;
1650
+
1651
+ // snap type
1652
+ QString snapType = snapTypeList.at ( idx );
1653
+ if ( snapType == " to_segment" )
1654
+ {
1655
+ type = QgsSnapper::SnapToSegment;
1656
+ }
1657
+ else if ( snapType == " to_vertex_and_segment" )
1658
+ {
1659
+ type = QgsSnapper::SnapToVertexAndSegment;
1660
+ }
1661
+ else // to vertex
1662
+ {
1663
+ type = QgsSnapper::SnapToVertex;
1664
+ }
1665
+
1666
+ // units
1667
+ if ( toleranceUnitList.at ( idx ) == " 1" )
1668
+ {
1669
+ units = QgsTolerance::Pixels;
1670
+ }
1671
+ else
1672
+ {
1673
+ units = QgsTolerance::MapUnits;
1674
+ }
1675
+
1676
+ // tolerance
1677
+ tolerance = toleranceList.at ( idx ).toDouble ();
1678
+
1679
+ // avoid intersection
1680
+ avoidIntersection = ( avoidIntersectionList.indexOf ( layerId ) != -1 );
1681
+
1682
+ return true ;
1683
+ }
1684
+
1685
+ void QgsProject::snapSettings ( QStringList& layerIdList, QStringList& enabledList, QStringList& snapTypeList, QStringList& toleranceUnitList, QStringList& toleranceList,
1686
+ QStringList& avoidIntersectionList )
1687
+ {
1688
+ layerIdList = readListEntry ( " Digitizing" , " /LayerSnappingList" );
1689
+ enabledList = readListEntry ( " Digitizing" , " /LayerSnappingEnabledList" );
1690
+ toleranceList = readListEntry ( " Digitizing" , " /LayerSnappingToleranceList" );
1691
+ toleranceUnitList = readListEntry ( " Digitizing" , " /LayerSnappingToleranceUnitList" );
1692
+ snapTypeList = readListEntry ( " Digitizing" , " /LayerSnapToList" );
1693
+ avoidIntersectionList = readListEntry ( " Digitizing" , " /AvoidIntersectionsList" );
1694
+ }
1695
+
1624
1696
void QgsProjectBadLayerDefaultHandler::handleBadLayers ( QList<QDomNode> /* layers*/ , QDomDocument /* projectDom*/ )
1625
1697
{
1626
1698
// just ignore any bad layers
1627
1699
}
1700
+
1701
+
0 commit comments