forked from bstroebl/DigitizingTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigitizingtools.py
124 lines (107 loc) · 5.47 KB
/
digitizingtools.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
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
# -*- 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. *
* *
***************************************************************************/
"""
# Import the PyQt and QGIS libraries
from PyQt4 import QtCore, QtGui
from qgis.core import *
from dtDialog import DigitizingToolsAbout
import os.path, sys
# Set up current path.
currentPath = os.path.dirname( __file__ )
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/tools'))
#import the tools
import dtsplitmultipart
import dtcutter
import dtclipper
import dtfillring
import dtfillgap
import dtsplitter
import dtflipline
import dtprolongline
import dtmovenodebyarea
import dtmovesidebydistance
import dtmovesidebyarea
import dtmedianline
import dtextractpart
import dtmerge
import dtexchangegeometry
class DigitizingTools:
"""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.qgisUserDbFilePath()).path() + "/python/plugins/DigitizingTools"
# initialize locale
localePath = ""
locale = QtCore.QSettings().value("locale/userLocale", "en", type=str)[0:2]
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)
if QtCore.qVersion() > '4.3.3':
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 = QtGui.QApplication.translate( "DigitizingTools","&DigitizingTools" )
self.digitizingtools_help = QtGui.QAction( QtGui.QApplication.translate("DigitizingTools", "Help" ), self.iface.mainWindow() )
self.digitizingtools_about = QtGui.QAction( QtGui.QApplication.translate("DigitizingTools", "About" ), self.iface.mainWindow() )
self.digitizingtools_about.setObjectName("DtAbout")
self.digitizingtools_settings = QtGui.QAction( QtGui.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.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.splitter = dtsplitter.DtSplitWithLine(self.iface, self.toolBar)
self.flipLine = dtflipline.DtFlipLine(self.iface, self.toolBar)
self.prolongLine = dtprolongline.DtProlongLine(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)