33# classification of remote sensing images, providing tools for the download,
44# the preprocessing and postprocessing of images.
55# begin: 2012-12-29
6- # Copyright (C) 2012-2023 by Luca Congedo.
6+ # Copyright (C) 2012-2024 by Luca Congedo.
77# Author: Luca Congedo
88# Email: ing.congedoluca@gmail.com
99#
2121# If not, see <https://www.gnu.org/licenses/>.
2222
2323
24- from PyQt5 .QtWidgets import QMessageBox , QToolButton
24+ from PyQt5 .QtWidgets import QMessageBox , QToolButton , QApplication
25+ # noinspection PyUnresolvedReferences
2526from qgis .core import Qgis
2627
2728cfg = __import__ (str (__name__ ).split ('.' )[0 ] + '.core.config' , fromlist = ['' ])
@@ -52,7 +53,13 @@ def msg_bar(title, message):
5253
5354# message bar information
5455def msg_bar_info (message ):
55- msg_bar (cfg .translate ('SCP information' ), message )
56+ # noinspection PyTypeChecker
57+ msg_bar (
58+ QApplication .translate (
59+ 'semiautomaticclassificationplugin' ,
60+ 'SCP information'
61+ ), message
62+ )
5663
5764
5865# Message bar error
@@ -67,7 +74,11 @@ def msg_bar_critical(title, message):
6774
6875# Message bar error
6976def msg_bar_error (message ):
70- msg_bar_critical (cfg .translate ('Error' ), message = message )
77+ # noinspection PyTypeChecker
78+ msg_bar_critical (
79+ QApplication .translate ('semiautomaticclassificationplugin' , 'Error' ),
80+ message = message
81+ )
7182
7283
7384# message bar warning
@@ -82,7 +93,12 @@ def _msg_bar_warning(title, message):
8293
8394# message bar warning
8495def msg_bar_warning (message ):
85- _msg_bar_warning (title = cfg .translate ('Warning' ), message = message )
96+ # noinspection PyTypeChecker
97+ _msg_bar_warning (
98+ title = QApplication .translate (
99+ 'semiautomaticclassificationplugin' , 'Warning'
100+ ), message = message
101+ )
86102
87103
88104''' Messages for callback '''
@@ -108,111 +124,234 @@ def error(message):
108124
109125
110126def msg_test (message ):
111- msg_box (cfg .translate ('Test results' ), message )
127+ # noinspection PyTypeChecker
128+ msg_box (
129+ QApplication .translate (
130+ 'semiautomaticclassificationplugin' , 'Test results'
131+ ), message
132+ )
112133
113134
114135def msg_inf_1 ():
115- msg_bar_info (cfg .translate ('Training input cannot be edited' ))
136+ # noinspection PyTypeChecker
137+ msg_bar_info (
138+ QApplication .translate (
139+ 'semiautomaticclassificationplugin' ,
140+ 'Training input cannot be edited'
141+ )
142+ )
116143
117144
118145def msg_inf_2 ():
119- msg_bar_info (cfg .translate ('At least 3 points are required' ))
146+ # noinspection PyTypeChecker
147+ msg_bar_info (
148+ QApplication .translate (
149+ 'semiautomaticclassificationplugin' ,
150+ 'At least 3 points are required'
151+ )
152+ )
120153
121154
122155def msg_inf_3 ():
123- msg_bar_info (cfg .translate ('Detailed log is active' ))
156+ # noinspection PyTypeChecker
157+ msg_bar_info (
158+ QApplication .translate (
159+ 'semiautomaticclassificationplugin' , 'Detailed log is active'
160+ )
161+ )
124162
125163
126164def msg_inf_4 ():
127- msg_bar_info (cfg .translate ('Training vector exported' ))
165+ # noinspection PyTypeChecker
166+ msg_bar_info (
167+ QApplication .translate (
168+ 'semiautomaticclassificationplugin' , 'Training vector exported'
169+ )
170+ )
128171
129172
130173def msg_inf_5 ():
131- msg_bar_info (cfg .translate ('Enter class values' ))
174+ # noinspection PyTypeChecker
175+ msg_bar_info (
176+ QApplication .translate (
177+ 'semiautomaticclassificationplugin' , 'Enter class values'
178+ )
179+ )
132180
133181
134182def msg_inf_6 ():
135- msg_bar_info (cfg .translate ('Process completed' ))
183+ # noinspection PyTypeChecker
184+ msg_bar_info (
185+ QApplication .translate (
186+ 'semiautomaticclassificationplugin' , 'Process completed'
187+ )
188+ )
189+
190+
191+ def msg_inf_7 ():
192+ # noinspection PyTypeChecker
193+ msg_bar_info (
194+ QApplication .translate (
195+ 'semiautomaticclassificationplugin' , 'Training Band set updated'
196+ )
197+ )
136198
137199
138200""" Errors """
139201
140202
141203def msg_err_1 ():
142- msg_bar_error (cfg .translate ('Process failed' ))
204+ # noinspection PyTypeChecker
205+ msg_bar_error (
206+ QApplication .translate (
207+ 'semiautomaticclassificationplugin' , 'Process failed'
208+ )
209+ )
143210
144211
145212def msg_err_2 ():
146- msg_bar_error (cfg .translate ('Bandset not found' ))
213+ # noinspection PyTypeChecker
214+ msg_bar_error (
215+ QApplication .translate (
216+ 'semiautomaticclassificationplugin' , 'Bandset not found'
217+ )
218+ )
147219
148220
149221def msg_err_3 ():
150- msg_bar_error (cfg .translate ('Area coordinates error' ))
222+ # noinspection PyTypeChecker
223+ msg_bar_error (
224+ QApplication .translate (
225+ 'semiautomaticclassificationplugin' , 'Area coordinates error'
226+ )
227+ )
151228
152229
153230def msg_err_4 ():
154- msg_bar_error (cfg .translate ('Unable to create RGB color composite' ))
231+ # noinspection PyTypeChecker
232+ msg_bar_error (
233+ QApplication .translate (
234+ 'semiautomaticclassificationplugin' ,
235+ 'Unable to create RGB color composite'
236+ )
237+ )
155238
156239
157240def msg_err_5 ():
158- msg_bar_error (cfg .translate ('Unable to open file' ))
241+ # noinspection PyTypeChecker
242+ msg_bar_error (
243+ QApplication .translate (
244+ 'semiautomaticclassificationplugin' , 'Unable to open file'
245+ )
246+ )
159247
160248
161249def msg_err_6 ():
162- msg_bar_error (cfg .translate ('Unable to calculate' ))
250+ # noinspection PyTypeChecker
251+ msg_bar_error (
252+ QApplication .translate (
253+ 'semiautomaticclassificationplugin' , 'Unable to calculate'
254+ )
255+ )
163256
164257
165258def msg_err_7 ():
166- msg_bar_error (cfg .translate ('Expression error' ))
259+ # noinspection PyTypeChecker
260+ msg_bar_error (
261+ QApplication .translate (
262+ 'semiautomaticclassificationplugin' , 'Expression error'
263+ )
264+ )
265+
266+
267+ def msg_err_8 ():
268+ # noinspection PyTypeChecker
269+ msg_bar_error (
270+ QApplication .translate (
271+ 'semiautomaticclassificationplugin' ,
272+ 'Incompatible CRS, please create a new training input'
273+ )
274+ )
167275
168276
169277""" Warnings """
170278
171279
172280def msg_war_1 ():
173- msg_bar_warning (cfg .translate ('Pixel resolution undefined' ))
281+ # noinspection PyTypeChecker
282+ msg_bar_warning (
283+ QApplication .translate (
284+ 'semiautomaticclassificationplugin' , 'Pixel resolution undefined'
285+ )
286+ )
174287
175288
176289def msg_war_2 ():
290+ # noinspection PyTypeChecker
177291 msg_bar_warning (
178- cfg .translate (
292+ QApplication .translate (
293+ 'semiautomaticclassificationplugin' ,
179294 'Unable to define hidden layer size, setting default 100'
180- )
295+ )
181296 )
182297
183298
184299def msg_war_3 ():
300+ # noinspection PyTypeChecker
185301 msg_bar_warning (
186- cfg .translate (
302+ QApplication .translate (
303+ 'semiautomaticclassificationplugin' ,
187304 'Point outside band set or band set not defined'
188- )
305+ )
189306 )
190307
191308
192309def msg_war_4 ():
193- msg_bar_warning (cfg .translate ('ROI not found' ))
310+ # noinspection PyTypeChecker
311+ msg_bar_warning (
312+ QApplication .translate (
313+ 'semiautomaticclassificationplugin' , 'ROI not found'
314+ )
315+ )
194316
195317
196318def msg_war_5 ():
319+ # noinspection PyTypeChecker
197320 msg_bar_warning (
198- cfg .translate (
321+ QApplication .translate (
322+ 'semiautomaticclassificationplugin' ,
199323 'Select a training input; input is not loaded'
200- )
324+ )
201325 )
202326
203327
204328def msg_war_6 (bandset_number = None ):
329+ # noinspection PyTypeChecker
205330 msg_bar_warning (
206- cfg .translate ('Band set' ) + ' ' + str (bandset_number ) + ' '
207- + cfg .translate ('is empty' )
331+ QApplication .translate (
332+ 'semiautomaticclassificationplugin' , 'Band set'
333+ ) + ' ' + str (bandset_number ) + ' '
334+ + QApplication .translate (
335+ 'semiautomaticclassificationplugin' , 'is empty'
336+ )
208337 )
209338
210339
211340def msg_war_7 ():
212- msg_bar_warning (cfg .translate (
213- 'No band found. Check metadata inside the directory' )
214- )
341+ # noinspection PyTypeChecker
342+ msg_bar_warning (
343+ QApplication .translate (
344+ 'semiautomaticclassificationplugin' ,
345+ 'No band found. Check metadata inside the directory'
346+ )
347+ )
215348
216349
217350def msg_war_8 ():
218- msg_bar_warning (cfg .translate ('No tool selected' ))
351+ # noinspection PyTypeChecker
352+ msg_bar_warning (
353+ QApplication .translate (
354+ 'semiautomaticclassificationplugin' ,
355+ 'No tool selected'
356+ )
357+ )
0 commit comments