This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gridGenerator_dockwidget.py
98 lines (84 loc) · 4.79 KB
/
gridGenerator_dockwidget.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
# -*- coding: utf-8 -*-
"""
/***************************************************************************
GridGeneratorDockWidget
A QGIS plugin
Creates UTM and geopgraphic symbology and labels for given bounding feature.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2019-04-21
git sha : $Format:%H$
copyright : (C) 2021 by Joao Felipe Aguiar Guimaraes
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. *
* *
***************************************************************************/
"""
import os
from qgis.PyQt import QtWidgets, uic
from qgis.PyQt.QtCore import pyqtSignal
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.core import QgsMapLayerProxyModel
from .gui.gridAndLabelCreator import *
from .gui.utmZoneSelection import *
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'gridGenerator_dockwidget_base.ui'))
class GridGeneratorDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
closingPlugin = pyqtSignal()
def __init__(self, parent=None):
"""Constructor."""
super(GridGeneratorDockWidget, self).__init__(parent)
self.gridAndLabelCreator = GridAndLabelCreator()
self.setupUi(self)
self.iface = iface
self.mapLayerSelection.setFilters(QgsMapLayerProxyModel.PolygonLayer)
self.mapLayerSelection.layerChanged.connect(self.idSelection.setLayer)
self.okButton.pressed.connect(self.send_inputs)
self.resetButton.pressed.connect(self.send_reset)
def send_inputs(self):
if (not self.mapLayerSelection.currentLayer()) and (self.idSelection.currentField()) and (self.idValue.value()) and (self.utmSpacing.value()) and (self.crossesX.value()) and (self.crossesY.value()) and (self.mapScale.value()) and (self.labelFontSize.value()) and (self.fontType.currentFont()) and (self.fontTypeLL.currentFont()) and (self.width_geo.value()) and (self.width_utm.value()) and (self.width_buffer_geo.value()) and (self.width_buffer_utm.value()):
return
layer = self.mapLayerSelection.currentLayer()
id_attr = self.idSelection.currentField()
id_value = self.idValue.value()
spacing = self.utmSpacing.value()
crossX = self.crossesX.value()
crossY = self.crossesY.value()
scale = self.mapScale.value()
geo_grid_color = self.geo_grid_color.color()
utm_grid_color = self.utm_grid_color.color()
geo_grid_buffer_color = self.geo_grid_buffer_color.color()
utm_grid_buffer_color = self.utm_grid_buffer_color.color()
fontSize = self.labelFontSize.value()
font = self.fontType.currentFont()
fontLL = self.fontTypeLL.currentFont()
llcolor = self.llColor.color()
linwidth_geo = self.width_geo.value()
linwidth_utm = self.width_utm.value()
linwidth_buffer_geo = self.width_buffer_geo.value()
linwidth_buffer_utm = self.width_buffer_utm.value()
masks_check = self.maskCheckBox.isChecked()
if layer == None:
QMessageBox.information(self, u"Aviso", u"Nenhuma camada selecionada.\nSelecione uma camada vetorial poligonal para gerar o grid.")
return
else:
testFeature = layer.getFeatures('"' + id_attr + '"' + '=' + str(id_value))
featureList = [i for i in testFeature]
if not featureList:
QMessageBox.critical(None, u"Erro", u"Escolha um valor existente do atributo de identificação")
return
else:
dialogUTMZoneSelection = UTMZoneSelection(self.iface, layer, id_attr, id_value, spacing, crossX, crossY, scale, fontSize, font, fontLL, llcolor, linwidth_geo, linwidth_utm, linwidth_buffer_geo, linwidth_buffer_utm, geo_grid_color, utm_grid_color, geo_grid_buffer_color, utm_grid_buffer_color, masks_check)
dialogUTMZoneSelection.setDialog()
def send_reset(self):
layer = self.mapLayerSelection.currentLayer()
self.gridAndLabelCreator.reset(layer)
def closeEvent(self, event):
self.closingPlugin.emit()
event.accept()