-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdigitizingtools.py
More file actions
128 lines (111 loc) · 5.62 KB
/
digitizingtools.py
File metadata and controls
128 lines (111 loc) · 5.62 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- coding: utf-8 -*-
"""
/***************************************************************************
DigitizingTools
A QGIS plugin
Subsumes different tools useful during digitizing sessions
some code adopted/adapted from:
'CadTools Plugin', Copyright (C) Stefan Ziegler
-------------------
begin : 2013-02-25
copyright : (C) 2013 by Bernhard Ströbl
email : bernhard.stroebl@jena.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
from __future__ import absolute_import
from builtins import object
# Import the PyQt and QGIS libraries
from qgis.PyQt import QtCore, QtWidgets
from qgis.core import *
import os.path, sys
# Set up current path.
currentPath = os.path.dirname( __file__ )
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/tools'))
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from .dtDialog import DigitizingToolsAbout
#import the tools
import dtsplitmultipart
import dtcutter
import dtclipper
import dtfillring
import dtfillgap
import dtflipline
import dtsplitfeature
import dtmovenodebyarea
import dtmovesidebydistance
import dtmovesidebyarea
import dtmedianline
import dtextractpart
import dtmerge
import dtexchangegeometry
class DigitizingTools(object):
"""Main class for the plugin"""
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = QtCore.QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/DigitizingTools"
# initialize locale
QgsMessageLog.logMessage("dir = " + self.plugin_dir)
localePath = ""
try:
locale = QtCore.QSettings().value("locale/userLocale", "en", type=str)[0:2]
except:
locale = "en"
if QtCore.QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/digitizingtools_" + locale + ".qm"
if QtCore.QFileInfo(localePath).exists():
self.translator = QtCore.QTranslator()
self.translator.load(localePath)
QtCore.QCoreApplication.installTranslator(self.translator)
def initGui(self):
"""Customize QGIS' GUI"""
#. Add toolbar
self.toolBar = self.iface.addToolBar("DigitizingTools")
self.toolBar.setObjectName("DigitizingTools")
#. Add a menu
self.menuLabel = QtWidgets.QApplication.translate( "DigitizingTools","&DigitizingTools" )
self.digitizingtools_help = QtWidgets.QAction( QtWidgets.QApplication.translate("DigitizingTools", "Help" ), self.iface.mainWindow() )
self.digitizingtools_about = QtWidgets.QAction( QtWidgets.QApplication.translate("DigitizingTools", "About" ), self.iface.mainWindow() )
self.digitizingtools_about.setObjectName("DtAbout")
self.digitizingtools_settings = QtWidgets.QAction( QtWidgets.QApplication.translate("DigitizingTools", "Settings" ), self.iface.mainWindow() )
self.iface.addPluginToMenu(self.menuLabel, self.digitizingtools_about)
#. Add the tools
self.multiPartSplitter = dtsplitmultipart.DtSplitMultiPartTool(self.iface, self.toolBar)
self.partExtractor = dtextractpart.DtExtractPartTool(self.iface, self.toolBar)
self.splitfeature = dtsplitfeature.DtSplitFeature(self.iface, self.toolBar)
self.merger = dtmerge.DtMerge(self.iface, self.toolBar)
self.exchangeGeometry = dtexchangegeometry.DtExchangeGeometry(self.iface, self.toolBar)
self.cutter = dtcutter.DtCutWithPolygon(self.iface, self.toolBar)
self.clipper = dtclipper.DtClipWithPolygon(self.iface, self.toolBar)
self.ringFiller = dtfillring.DtFillRing(self.iface, self.toolBar)
self.gapFiller = dtfillgap.DtFillGap(self.iface, self.toolBar)
self.gapFillerAll = dtfillgap.DtFillGapAllLayers(self.iface, self.toolBar)
self.flipLine = dtflipline.DtFlipLine(self.iface, self.toolBar)
self.moveNodeByArea = dtmovenodebyarea.DtMoveNodeByArea(self.iface, self.toolBar)
self.moveSideByDistance = dtmovesidebydistance.DtMoveSideByDistance(self.iface, self.toolBar)
self.moveSideByArea = dtmovesidebyarea.DtMoveSideByArea(self.iface, self.toolBar)
self.medianLine = dtmedianline.DtMedianLine(self.iface, self.toolBar)
self.digitizingtools_about.triggered.connect(self.doAbout)
#QObject.connect( self.digitizingtools_help, SIGNAL("triggered()"), self.doHelp )
#QObject.connect( self.digitizingtools_settings, SIGNAL("triggered()"), self.doSettings )
def doAbout(self):
d = DigitizingToolsAbout(self.iface)
d.exec_()
def doHelp(self):
webbrowser.open(currentPath + "/help/build/html/intro.html")
def doSettings(self):
settings = CadToolsSettingsGui(self.iface.mainWindow())
settings.show()
def unload(self):
# remove toolbar and menu
del self.toolBar
self.iface.removePluginMenu(self.menuLabel, self.digitizingtools_about)