-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenSimPlot_dialog.py
71 lines (56 loc) · 2.71 KB
/
GenSimPlot_dialog.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
# -*- coding: utf-8 -*-
"""
Package: GenSimPlot
File: GenSimPlot_dialog.py
Version: 2.1
Author: Milan Koren
Year: 2024
URL: https://github.com/milan-koren/GenSimPlot
License: EUPL v1.2 (European Union Public License), https://eupl.eu/
"""
import sys
import os
from qgis.PyQt import uic
from qgis.PyQt import QtWidgets
sys.path.append(os.path.dirname(__file__))
from qgis.core import *
from .GenSimPlotUtilities import GProgressDialog
from .GenSimPlotUtilities import GenSimPlotUtilities
import GenSimPlotLib
# This loads .ui file
FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), "GenSimPlot_dialog.ui"))
class GenSimPlotDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
super(GenSimPlotDialog, self).__init__(parent)
self.setupUi(self)
self.btnBox.accepted.connect(self.OnOK)
self.btnBrowseInputShp.clicked.connect(self.OnBrowseInputShp)
self.btnBrowseOutputShp.clicked.connect(self.OnBrowseOutputShp)
self.cmbShape.currentIndexChanged.connect(self.OnShapeChanged)
def OnBrowseInputShp(self):
GenSimPlotUtilities.browseInputPolygonShp(self, self.tbInputShpFN, self.cmbFields)
def OnBrowseOutputShp(self):
GenSimPlotUtilities.OnBrowseOutputShp(self, self.tbOutputShpFN)
def OnShapeChanged(self):
self.cmbPosition.setDisabled(self.cmbShape.currentText() == "best")
self.cmbPlacement.setDisabled(self.cmbShape.currentText() == "best")
def OnOK(self):
inputShp = self.tbInputShpFN.text()
outputShp = self.tbOutputShpFN.text()
inputIDField = self.cmbFields.currentText()
plotShape = self.cmbShape.currentText()
plotPosition = self.cmbPosition.currentText()
plotPlacement = self.cmbPlacement.currentText()
progressDlg = GProgressDialog()
progressDlg.show()
if (plotShape == "circle"):
GenSimPlotLib.PlotGenerator().generateCirclePlots(inputShp, inputIDField, outputShp, plotPosition, plotPlacement, progressDlg)
elif (plotShape == "ellipse"):
GenSimPlotLib.PlotGenerator().generateEllipsePlots(inputShp, inputIDField, outputShp, plotPosition, plotPlacement, progressDlg)
elif (plotShape == "rectangle"):
GenSimPlotLib.PlotGenerator().generateRectanglePlots(inputShp, inputIDField, outputShp, plotPosition, plotPlacement, progressDlg)
elif (plotShape == "square"):
GenSimPlotLib.PlotGenerator().generateSquarePlots(inputShp, inputIDField, outputShp, plotPosition, plotPlacement, progressDlg)
else:
GenSimPlotLib.PlotGenerator().generateBestPlots(inputShp, inputIDField, outputShp, progressDlg)
progressDlg.close()