-
Notifications
You must be signed in to change notification settings - Fork 4
/
qgis_gui_tools.py
95 lines (70 loc) · 3.3 KB
/
qgis_gui_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Interactive Map Tracking
A QGIS plugin
Tools for interactive_map_tracking
-------------------
begin : 2015-02-10
git sha : $Format:%H$
copyright : (C) 2015 by IGN
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
__author__ = 'latty'
from PyQt4.QtCore import QSettings
def push_state_tool_edit(_s, _name_in_setting, _action):
""" Push state (activate/desactivate) of QGIS Tool Edit
:param _s: Qt settings
:type _s: QSettings
:param _name_in_setting: name of this param in Qt settings
:type _name_in_setting: QSting
:param _action: QGIS Tool edit
:type _action: QAction
:return:
"""
if _action.isChecked():
_s.setValue("interactive_map_tracking_plugin/" + _name_in_setting, "true")
else:
_s.setValue("interactive_map_tracking_plugin/" + _name_in_setting, "false")
def pop_state_tool_edit(_s, _name_in_setting, _action):
""" Pop state (activate/desactivate) of QGIS Tool Edit
:param _s: Qt settings
:type _s: QSettings
:param _name_in_setting: name of this param in Qt settings
:type _name_in_setting: QSting
:param _action: QGIS Tool edit
:type _action: QAction
"""
if _s.value("interactive_map_tracking_plugin/" + _name_in_setting, "") == "true":
_action.activate(0)
def push_state_tools_editing(iface, _s):
""" Push state (activate/desactivate) of 'all' QGIS Tools edit (Node Tool, Add Feature, Move Feature, Identify)
:param iface: QGIS Interface
:type iface: QgsInterface
:param _s: Qt settings
:type _s: QSettings
"""
push_state_tool_edit(_s, "enabledNodeTool", iface.actionNodeTool())
push_state_tool_edit(_s, "enabledAddFeature", iface.actionAddFeature())
push_state_tool_edit(_s, "enabledMoveFeature", iface.actionMoveFeature())
push_state_tool_edit(_s, "enabledIdentify", iface.actionIdentify())
def pop_state_tools_editing(iface, _s):
""" Pop state (activate/desactivate) of 'all' QGIS Tools edit (Node Tool, Add Feature, Move Feature, Identify)
:param iface: QGIS Interface
:type iface: QgsInterface
:param _s: Qt settings
:type _s: QSettings
"""
pop_state_tool_edit(_s, "enabledNodeTool", iface.actionNodeTool())
pop_state_tool_edit(_s, "enabledAddFeature", iface.actionAddFeature())
pop_state_tool_edit(_s, "enabledMoveFeature", iface.actionMoveFeature())
pop_state_tool_edit(_s, "enabledIdentify", iface.actionIdentify())