@@ -46,144 +46,3 @@ def __init__(self, alg):
46
46
self .paramTable = ParametersPanel (self , alg )
47
47
AlgorithmExecutionDialog .__init__ (self , alg , self .paramTable )
48
48
self .executed = False
49
-
50
-
51
- def setParamValues (self ):
52
- params = self .alg .parameters
53
- outputs = self .alg .outputs
54
-
55
- for param in params :
56
- if not self .setParamValue (param , self .paramTable .valueItems [param .name ]):
57
- return False
58
-
59
- for output in outputs :
60
- if output .hidden :
61
- continue
62
- output .value = self .paramTable .valueItems [output .name ].getValue ()
63
- if not SextanteConfig .getSetting (SextanteConfig .TABLE_LIKE_PARAM_PANEL ):
64
- if isinstance (output , (OutputRaster , OutputVector , OutputTable , OutputHTML )):
65
- output .open = self .paramTable .checkBoxes [output .name ].isChecked ()
66
-
67
- return True
68
-
69
- def setParamValue (self , param , widget ):
70
- if isinstance (param , ParameterRaster ):
71
- return param .setValue (widget .getValue ())
72
- elif isinstance (param , (ParameterVector , ParameterTable )):
73
- try :
74
- return param .setValue (widget .itemData (widget .currentIndex ()).toPyObject ())
75
- except :
76
- return param .setValue (widget .getValue ())
77
- elif isinstance (param , ParameterBoolean ):
78
- return param .setValue (widget .currentIndex () == 0 )
79
- elif isinstance (param , ParameterSelection ):
80
- return param .setValue (widget .currentIndex ())
81
- elif isinstance (param , ParameterFixedTable ):
82
- return param .setValue (widget .table )
83
- elif isinstance (param , ParameterRange ):
84
- return param .setValue (widget .getValue ())
85
- if isinstance (param , ParameterTableField ):
86
- return param .setValue (widget .currentText ())
87
- elif isinstance (param , ParameterMultipleInput ):
88
- if param .datatype == ParameterMultipleInput .TYPE_VECTOR_ANY :
89
- options = QGisLayers .getVectorLayers ()
90
- else :
91
- options = QGisLayers .getRasterLayers ()
92
- value = []
93
- for index in widget .selectedoptions :
94
- value .append (options [index ])
95
- return param .setValue (value )
96
- elif isinstance (param , (ParameterNumber , ParameterFile , ParameterCrs , ParameterExtent )):
97
- return param .setValue (widget .getValue ())
98
- else :
99
- return param .setValue (str (widget .text ()))
100
-
101
- @pyqtSlot ()
102
- def accept (self ):
103
- #~ try:
104
- if self .setParamValues ():
105
- msg = self .alg .checkParameterValuesBeforeExecuting ()
106
- if msg :
107
- QMessageBox .critical (self , "Unable to execute algorithm" , msg )
108
- return
109
- self .buttonBox .button (QtGui .QDialogButtonBox .Ok ).setEnabled (False )
110
- self .buttonBox .button (QtGui .QDialogButtonBox .Close ).setEnabled (False )
111
- buttons = self .paramTable .iterateButtons
112
- iterateParam = None
113
-
114
- for i in range (len (buttons .values ())):
115
- button = buttons .values ()[i ]
116
- if button .isChecked ():
117
- iterateParam = buttons .keys ()[i ]
118
- break
119
-
120
- self .progress .setMaximum (0 )
121
- self .progressLabel .setText ("Processing algorithm..." )
122
- QApplication .setOverrideCursor (QCursor (Qt .WaitCursor ))
123
- useThread = SextanteConfig .getSetting (SextanteConfig .USE_THREADS )
124
- if useThread :
125
- if iterateParam :
126
- self .algEx = AlgorithmExecutor (self .alg , iterateParam )
127
- else :
128
- command = self .alg .getAsCommand ()
129
- if command :
130
- SextanteLog .addToLog (SextanteLog .LOG_ALGORITHM , command )
131
- self .algEx = AlgorithmExecutor (self .alg )
132
- self .algEx .finished .connect (self .finish )
133
- self .algEx .error .connect (self .error )
134
- self .algEx .percentageChanged .connect (self .setPercentage )
135
- self .algEx .textChanged .connect (self .setText )
136
- self .algEx .iterated .connect (self .iterate )
137
- self .algEx .start ()
138
- SextanteLog .addToLog (SextanteLog .LOG_INFO ,
139
- "Algorithm %s started" % self .alg .name )
140
- self .buttonBox .button (QtGui .QDialogButtonBox .Cancel ).setEnabled (True )
141
- self .finish ()
142
- else :
143
- keepOpen = SextanteConfig .getSetting (SextanteConfig .KEEP_DIALOG_OPEN )
144
- if iterateParam :
145
- UnthreadedAlgorithmExecutor .runalgIterating (self .alg , iterateParam , self )
146
- else :
147
- command = self .alg .getAsCommand ()
148
- if command :
149
- SextanteLog .addToLog (SextanteLog .LOG_ALGORITHM , command )
150
- if UnthreadedAlgorithmExecutor .runalg (self .alg , self ):
151
- SextantePostprocessing .handleAlgorithmResults (self .alg , not keepOpen )
152
- self .executed = True
153
- QApplication .restoreOverrideCursor ()
154
- if not keepOpen :
155
- self .close ()
156
- else :
157
- self .progressLabel .setText ("" )
158
- self .progress .setMaximum (100 )
159
- self .progress .setValue (0 )
160
- self .buttonBox .button (QtGui .QDialogButtonBox .Ok ).setEnabled (True )
161
- self .buttonBox .button (QtGui .QDialogButtonBox .Close ).setEnabled (True )
162
- self .buttonBox .button (QtGui .QDialogButtonBox .Cancel ).setEnabled (False )
163
-
164
-
165
- else :
166
- QMessageBox .critical (self , "Unable to execute algorithm" , "Wrong or missing parameter values" )
167
-
168
- @pyqtSlot ()
169
- def finish (self ):
170
- self .executed = True
171
- SextanteLog .addToLog (SextanteLog .LOG_INFO ,
172
- "Algorithm %s finished correctly" % self .alg .name )
173
- QApplication .restoreOverrideCursor ()
174
- keepOpen = SextanteConfig .getSetting (SextanteConfig .KEEP_DIALOG_OPEN )
175
- if not keepOpen :
176
- self .close ()
177
- else :
178
- self .progressLabel .setText ("" )
179
- self .progress .setMaximum (100 )
180
- self .progress .setValue (0 )
181
- self .buttonBox .button (QtGui .QDialogButtonBox .Ok ).setEnabled (True )
182
- self .buttonBox .button (QtGui .QDialogButtonBox .Close ).setEnabled (True )
183
- self .buttonBox .button (QtGui .QDialogButtonBox .Cancel ).setEnabled (False )
184
-
185
- @pyqtSlot (int )
186
- def iterate (self , i ):
187
- SextanteLog .addToLog (SextanteLog .LOG_INFO ,
188
- "Algorithm %s iteration #%i completed" % (self .alg .name , i ))
189
-
0 commit comments