[Qgis-developer] PyQGIS: how to set "Enable snapping on intersection" option?

Gino Pirelli luipir at gmail.com
Fri Mar 21 05:05:24 PDT 2014


I solved adding the same peace of code of the C++ apply method

in my case the code is

        project = QgsProject.instance()
        layerSnappingList = [layer1Id, later2Id]
        layerSnappingEnabledList = ["enabled", "enabled"]
        layerSnappingToleranceUnitList = ["0", "0"]
        layerSnapToList = ["to_vertex", "to_vertex"]
        layerSnappingToleranceList = ["0.300000", "0.300000"]
        project.writeEntry("Digitizing", "/IntersectionSnapping",
Qt.Checked)
        project.writeEntry("Digitizing", "/LayerSnappingList",
layerSnappingList)
        project.writeEntry("Digitizing", "/LayerSnappingEnabledList",
layerSnappingEnabledList)
        project.writeEntry("Digitizing", "/LayerSnappingToleranceUnitList",
layerSnappingToleranceUnitList)
        project.writeEntry("Digitizing", "/LayerSnapToList",
layerSnapToList)
        project.writeEntry("Digitizing", "/LayerSnappingToleranceList",
layerSnappingToleranceList)



On 21 March 2014 10:39, Gino Pirelli <luipir at gmail.com> wrote:

> thanks Jacob
>
> seems it works setting all QgsProject parameters as in:
>
> void QgsSnappingDialog::apply()
>
>
> My doubt is that probably should be useful to add a default option on snapping/digitinzing as "snap on intersection background" getting all layer in background by default.
>
>
> I'll try to propose this new config option in Vienna next week... the main reason to have a default behavior is that if you add a new layer I expect snapping should work also with the new layer, but It doesn't work if no one set list of snapping layer in the QgsProject (doing apply in SnappingOptions)
>
>
> thank you
>
>
>
> Luigi Pirelli (luigi.pirelli at faunalia.it - luipir at gmail.com)
>
>
>
>
> On 21 March 2014 10:16, Jakob Lanstorp <jlanstorp at gmail.com> wrote:
>
>> Looks like this setting is not exposed in the API of QgsSnapper or
>> QSettings:
>>
>>
>> http://qgis.org/api/2.2/classQgsSnapper.html#addd2b16ecac193e56f7bdedd6b78ac59
>> <
>> http://qgis.org/api/2.2/classQgsSnapper.html#addd2b16ecac193e56f7bdedd6b78ac59
>> >
>>
>> and
>>
>> from PyQt4.QtCore import QSettings
>> print QSettings().allKeys()
>>
>>
>>
>>
>> -----
>> Jakob Lanstorp
>> --
>> View this message in context:
>> http://osgeo-org.1560.x6.nabble.com/PyQGIS-how-to-set-Enable-snapping-on-intersection-option-tp5130203p5130271.html
>> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140321/eb22dbb9/attachment.html>


More information about the Qgis-developer mailing list