28
28
import math
29
29
30
30
from qgis .PyQt .QtCore import Qt
31
- from qgis .PyQt .QtWidgets import QDialog , QVBoxLayout , QHBoxLayout , QLabel , QLineEdit , QComboBox , QCheckBox , QDialogButtonBox , QMessageBox
31
+ from qgis .PyQt .QtWidgets import (QDialog ,
32
+ QVBoxLayout ,
33
+ QHBoxLayout ,
34
+ QLabel ,
35
+ QLineEdit ,
36
+ QComboBox ,
37
+ QCheckBox ,
38
+ QDialogButtonBox ,
39
+ QMessageBox )
32
40
33
41
from processing .core .parameters import (Parameter ,
34
42
ParameterBoolean ,
42
50
ParameterExtent ,
43
51
ParameterFile ,
44
52
ParameterPoint ,
53
+ ParameterCrs ,
45
54
ParameterTableMultipleField )
55
+ from processing .gui .CrsSelectionPanel import CrsSelectionPanel
46
56
47
57
48
58
class ModelerParameterDefinitionDialog (QDialog ):
@@ -58,6 +68,7 @@ class ModelerParameterDefinitionDialog(QDialog):
58
68
PARAMETER_EXTENT = 'Extent'
59
69
PARAMETER_FILE = 'File'
60
70
PARAMETER_POINT = 'Point'
71
+ PARAMETER_CRS = 'CRS'
61
72
62
73
# To add
63
74
PARAMETER_MULTIPLE = 'Multiple input'
@@ -74,7 +85,8 @@ class ModelerParameterDefinitionDialog(QDialog):
74
85
PARAMETER_TABLE_FIELD ,
75
86
PARAMETER_TABLE_MULTIPLE_FIELD ,
76
87
PARAMETER_VECTOR ,
77
- PARAMETER_POINT
88
+ PARAMETER_POINT ,
89
+ PARAMETER_CRS
78
90
]
79
91
80
92
def __init__ (self , alg , paramType = None , param = None ):
@@ -234,6 +246,14 @@ def setupUi(self):
234
246
self .defaultTextBox .setText (self .param .default )
235
247
self .horizontalLayoutParent .addWidget (self .defaultTextBox )
236
248
self .verticalLayout .addLayout (self .horizontalLayoutParent )
249
+ elif self .paramType == ModelerParameterDefinitionDialog .PARAMETER_CRS or \
250
+ isinstance (self .param , ParameterCrs ):
251
+ self .horizontalLayoutParent .addWidget (QLabel (self .tr ('Default value' )))
252
+ self .defaultTextBox = CrsSelectionPanel ('EPSG:4326' )
253
+ if self .param is not None :
254
+ self .defaultTextBox .setAuthId (self .param .default )
255
+ self .horizontalLayoutParent .addWidget (self .defaultTextBox )
256
+ self .verticalLayout .addLayout (self .horizontalLayoutParent )
237
257
238
258
self .horizontalLayoutRequired .addWidget (QLabel (self .tr ('Required' )))
239
259
self .yesNoCombo = QComboBox ()
@@ -355,6 +375,9 @@ def okPressed(self):
355
375
isinstance (self .param , ParameterPoint ):
356
376
self .param = ParameterPoint (name , description ,
357
377
unicode (self .defaultTextBox .text ()))
378
+ elif self .paramType == ModelerParameterDefinitionDialog .PARAMETER_CRS or \
379
+ isinstance (self .param , ParameterCrs ):
380
+ self .param = ParameterCrs (name , description , self .defaultTextBox .getValue (), self .yesNoCombo .currentIndex () == 1 )
358
381
self .param .optional = self .yesNoCombo .currentIndex () == 1
359
382
self .close ()
360
383
0 commit comments