Commit 82be8627bf49122179937c640eb40b330969d181
Committed by
GitHub
1 parent
6484ce45
Exists in
master
Using kwargs protocol from pypubsub (args1 deprecated) closes #141 (#143)
args1 pypubsub protocol was deprecated since wxpython3. In wxpython4 it was removed. This code updates invesalius to the new pypubsub protocol (kwargs).
Showing
37 changed files
with
1134 additions
and
1354 deletions
Show diff stats
app.py
@@ -47,7 +47,7 @@ try: | @@ -47,7 +47,7 @@ try: | ||
47 | except ImportError: | 47 | except ImportError: |
48 | from wx import SplashScreen | 48 | from wx import SplashScreen |
49 | #from wx.lib.pubsub import setupv1 #new wx | 49 | #from wx.lib.pubsub import setupv1 #new wx |
50 | -from wx.lib.pubsub import setuparg1# as psv1 | 50 | +# from wx.lib.pubsub import setuparg1# as psv1 |
51 | #from wx.lib.pubsub import Publisher | 51 | #from wx.lib.pubsub import Publisher |
52 | #import wx.lib.pubsub as ps | 52 | #import wx.lib.pubsub as ps |
53 | from wx.lib.pubsub import pub as Publisher | 53 | from wx.lib.pubsub import pub as Publisher |
@@ -117,7 +117,7 @@ class InVesalius(wx.App): | @@ -117,7 +117,7 @@ class InVesalius(wx.App): | ||
117 | Open drag & drop files under darwin | 117 | Open drag & drop files under darwin |
118 | """ | 118 | """ |
119 | path = os.path.abspath(filename) | 119 | path = os.path.abspath(filename) |
120 | - Publisher.sendMessage('Open project', path) | 120 | + Publisher.sendMessage('Open project', filepath=path) |
121 | 121 | ||
122 | def Startup2(self): | 122 | def Startup2(self): |
123 | self.control = self.splash.control | 123 | self.control = self.splash.control |
@@ -347,10 +347,10 @@ def use_cmd_optargs(options, args): | @@ -347,10 +347,10 @@ def use_cmd_optargs(options, args): | ||
347 | # If import DICOM argument... | 347 | # If import DICOM argument... |
348 | if options.dicom_dir: | 348 | if options.dicom_dir: |
349 | import_dir = options.dicom_dir | 349 | import_dir = options.dicom_dir |
350 | - Publisher.sendMessage('Import directory', {'directory': import_dir, 'gui': not options.no_gui}) | 350 | + Publisher.sendMessage('Import directory', directory=import_dir, use_gui=not options.no_gui) |
351 | 351 | ||
352 | if options.save: | 352 | if options.save: |
353 | - Publisher.sendMessage('Save project', os.path.abspath(options.save)) | 353 | + Publisher.sendMessage('Save project', filepath=os.path.abspath(options.save)) |
354 | exit(0) | 354 | exit(0) |
355 | 355 | ||
356 | check_for_export(options) | 356 | check_for_export(options) |
@@ -360,9 +360,11 @@ def use_cmd_optargs(options, args): | @@ -360,9 +360,11 @@ def use_cmd_optargs(options, args): | ||
360 | import invesalius.reader.dicom_reader as dcm | 360 | import invesalius.reader.dicom_reader as dcm |
361 | for patient in dcm.GetDicomGroups(options.import_all): | 361 | for patient in dcm.GetDicomGroups(options.import_all): |
362 | for group in patient.GetGroups(): | 362 | for group in patient.GetGroups(): |
363 | - Publisher.sendMessage('Import group', {'group': group, 'gui': not options.no_gui}) | 363 | + Publisher.sendMessage('Import group', |
364 | + group=group, | ||
365 | + use_gui=not options.no_gui) | ||
364 | check_for_export(options, suffix=group.title, remove_surfaces=False) | 366 | check_for_export(options, suffix=group.title, remove_surfaces=False) |
365 | - Publisher.sendMessage('Remove masks', [0]) | 367 | + Publisher.sendMessage('Remove masks', mask_indexes=(0,)) |
366 | return True | 368 | return True |
367 | 369 | ||
368 | # Check if there is a file path somewhere in what the user wrote | 370 | # Check if there is a file path somewhere in what the user wrote |
@@ -373,14 +375,14 @@ def use_cmd_optargs(options, args): | @@ -373,14 +375,14 @@ def use_cmd_optargs(options, args): | ||
373 | file = utils.decode(arg, FS_ENCODE) | 375 | file = utils.decode(arg, FS_ENCODE) |
374 | if os.path.isfile(file): | 376 | if os.path.isfile(file): |
375 | path = os.path.abspath(file) | 377 | path = os.path.abspath(file) |
376 | - Publisher.sendMessage('Open project', path) | 378 | + Publisher.sendMessage('Open project', filepath=path) |
377 | check_for_export(options) | 379 | check_for_export(options) |
378 | return True | 380 | return True |
379 | - | 381 | + |
380 | file = utils.decode(arg, sys.stdin.encoding) | 382 | file = utils.decode(arg, sys.stdin.encoding) |
381 | if os.path.isfile(file): | 383 | if os.path.isfile(file): |
382 | path = os.path.abspath(file) | 384 | path = os.path.abspath(file) |
383 | - Publisher.sendMessage('Open project', path) | 385 | + Publisher.sendMessage('Open project', filepath=path) |
384 | check_for_export(options) | 386 | check_for_export(options) |
385 | return True | 387 | return True |
386 | 388 | ||
@@ -428,7 +430,8 @@ def check_for_export(options, suffix='', remove_surfaces=False): | @@ -428,7 +430,8 @@ def check_for_export(options, suffix='', remove_surfaces=False): | ||
428 | def export(path_, threshold_range, remove_surface=False): | 430 | def export(path_, threshold_range, remove_surface=False): |
429 | import invesalius.constants as const | 431 | import invesalius.constants as const |
430 | 432 | ||
431 | - Publisher.sendMessage('Set threshold values', threshold_range) | 433 | + Publisher.sendMessage('Set threshold values', |
434 | + threshold_range=threshold_range) | ||
432 | 435 | ||
433 | surface_options = { | 436 | surface_options = { |
434 | 'method': { | 437 | 'method': { |
@@ -443,17 +446,20 @@ def export(path_, threshold_range, remove_surface=False): | @@ -443,17 +446,20 @@ def export(path_, threshold_range, remove_surface=False): | ||
443 | 'overwrite': False, | 446 | 'overwrite': False, |
444 | } | 447 | } |
445 | } | 448 | } |
446 | - Publisher.sendMessage('Create surface from index', surface_options) | ||
447 | - Publisher.sendMessage('Export surface to file', (path_, const.FILETYPE_STL)) | 449 | + Publisher.sendMessage('Create surface from index', |
450 | + surface_parameters=surface_options) | ||
451 | + Publisher.sendMessage('Export surface to file', | ||
452 | + filename=path_, filetype=const.FILETYPE_STL) | ||
448 | if remove_surface: | 453 | if remove_surface: |
449 | - Publisher.sendMessage('Remove surfaces', [0]) | 454 | + Publisher.sendMessage('Remove surfaces', |
455 | + surface_indexes=(0,)) | ||
450 | 456 | ||
451 | 457 | ||
452 | -def print_events(data): | 458 | +def print_events(topic=Publisher.AUTO_TOPIC, **msg_data): |
453 | """ | 459 | """ |
454 | Print pubsub messages | 460 | Print pubsub messages |
455 | """ | 461 | """ |
456 | - utils.debug(data.topic) | 462 | + utils.debug("%s\n\tParameters: %s" % (topic, msg_data)) |
457 | 463 | ||
458 | def main(): | 464 | def main(): |
459 | """ | 465 | """ |
invesalius/control.py
@@ -108,40 +108,38 @@ class Controller(): | @@ -108,40 +108,38 @@ class Controller(): | ||
108 | 108 | ||
109 | Publisher.subscribe(self.OnSaveProject, 'Save project') | 109 | Publisher.subscribe(self.OnSaveProject, 'Save project') |
110 | 110 | ||
111 | - def SetBitmapSpacing(self, pubsub_evt): | 111 | + def SetBitmapSpacing(self, spacing): |
112 | proj = prj.Project() | 112 | proj = prj.Project() |
113 | - proj.spacing = pubsub_evt.data | 113 | + proj.spacing = spacing |
114 | 114 | ||
115 | - def OnCancelImport(self, pubsub_evt): | 115 | + def OnCancelImport(self): |
116 | #self.cancel_import = True | 116 | #self.cancel_import = True |
117 | Publisher.sendMessage('Hide import panel') | 117 | Publisher.sendMessage('Hide import panel') |
118 | 118 | ||
119 | 119 | ||
120 | - def OnCancelImportBitmap(self, pubsub_evt): | 120 | + def OnCancelImportBitmap(self): |
121 | #self.cancel_import = True | 121 | #self.cancel_import = True |
122 | Publisher.sendMessage('Hide import bitmap panel') | 122 | Publisher.sendMessage('Hide import bitmap panel') |
123 | 123 | ||
124 | ########################### | 124 | ########################### |
125 | ########################### | 125 | ########################### |
126 | 126 | ||
127 | - def OnShowDialogImportDirectory(self, pubsub_evt): | 127 | + def OnShowDialogImportDirectory(self): |
128 | self.ShowDialogImportDirectory() | 128 | self.ShowDialogImportDirectory() |
129 | 129 | ||
130 | - def OnShowDialogImportOtherFiles(self, pubsub_evt): | ||
131 | - id_type = pubsub_evt.data | 130 | + def OnShowDialogImportOtherFiles(self, id_type): |
132 | self.ShowDialogImportOtherFiles(id_type) | 131 | self.ShowDialogImportOtherFiles(id_type) |
133 | 132 | ||
134 | - def OnShowDialogOpenProject(self, pubsub_evt): | 133 | + def OnShowDialogOpenProject(self): |
135 | self.ShowDialogOpenProject() | 134 | self.ShowDialogOpenProject() |
136 | 135 | ||
137 | - def OnShowDialogSaveProject(self, pubsub_evt): | ||
138 | - saveas = pubsub_evt.data | ||
139 | - self.ShowDialogSaveProject(saveas) | 136 | + def OnShowDialogSaveProject(self, save_as): |
137 | + self.ShowDialogSaveProject(save_as) | ||
140 | 138 | ||
141 | - def OnShowDialogCloseProject(self, pubsub_evt): | 139 | + def OnShowDialogCloseProject(self): |
142 | self.ShowDialogCloseProject() | 140 | self.ShowDialogCloseProject() |
143 | 141 | ||
144 | - def OnShowBitmapFile(self, pubsub_evt): | 142 | + def OnShowBitmapFile(self): |
145 | self.ShowDialogImportBitmapFile() | 143 | self.ShowDialogImportBitmapFile() |
146 | ########################### | 144 | ########################### |
147 | 145 | ||
@@ -155,10 +153,10 @@ class Controller(): | @@ -155,10 +153,10 @@ class Controller(): | ||
155 | if answer: | 153 | if answer: |
156 | self.ShowDialogSaveProject() | 154 | self.ShowDialogSaveProject() |
157 | self.CloseProject() | 155 | self.CloseProject() |
158 | - #Publisher.sendMessage("Enable state project", False) | 156 | + #Publisher.sendMessage("Enable state project", state=False) |
159 | Publisher.sendMessage('Set project name') | 157 | Publisher.sendMessage('Set project name') |
160 | Publisher.sendMessage("Stop Config Recording") | 158 | Publisher.sendMessage("Stop Config Recording") |
161 | - Publisher.sendMessage("Set slice interaction style", const.STATE_DEFAULT) | 159 | + Publisher.sendMessage("Set slice interaction style", style=const.STATE_DEFAULT) |
162 | 160 | ||
163 | # Import TIFF, BMP, JPEG or PNG | 161 | # Import TIFF, BMP, JPEG or PNG |
164 | dirpath = dialog.ShowImportBitmapDirDialog(self.frame) | 162 | dirpath = dialog.ShowImportBitmapDirDialog(self.frame) |
@@ -179,10 +177,10 @@ class Controller(): | @@ -179,10 +177,10 @@ class Controller(): | ||
179 | if answer: | 177 | if answer: |
180 | self.ShowDialogSaveProject() | 178 | self.ShowDialogSaveProject() |
181 | self.CloseProject() | 179 | self.CloseProject() |
182 | - #Publisher.sendMessage("Enable state project", False) | 180 | + #Publisher.sendMessage("Enable state project", state=False) |
183 | Publisher.sendMessage('Set project name') | 181 | Publisher.sendMessage('Set project name') |
184 | Publisher.sendMessage("Stop Config Recording") | 182 | Publisher.sendMessage("Stop Config Recording") |
185 | - Publisher.sendMessage("Set slice interaction style", const.STATE_DEFAULT) | 183 | + Publisher.sendMessage("Set slice interaction style", style=const.STATE_DEFAULT) |
186 | # Import project | 184 | # Import project |
187 | dirpath = dialog.ShowImportDirDialog(self.frame) | 185 | dirpath = dialog.ShowImportDirDialog(self.frame) |
188 | if dirpath and not os.listdir(dirpath): | 186 | if dirpath and not os.listdir(dirpath): |
@@ -200,17 +198,17 @@ class Controller(): | @@ -200,17 +198,17 @@ class Controller(): | ||
200 | if answer: | 198 | if answer: |
201 | self.ShowDialogSaveProject() | 199 | self.ShowDialogSaveProject() |
202 | self.CloseProject() | 200 | self.CloseProject() |
203 | - # Publisher.sendMessage("Enable state project", False) | 201 | + # Publisher.sendMessage("Enable state project", state=False) |
204 | Publisher.sendMessage('Set project name') | 202 | Publisher.sendMessage('Set project name') |
205 | Publisher.sendMessage("Stop Config Recording") | 203 | Publisher.sendMessage("Stop Config Recording") |
206 | - Publisher.sendMessage("Set slice interaction style", const.STATE_DEFAULT) | 204 | + Publisher.sendMessage("Set slice interaction style", style=const.STATE_DEFAULT) |
207 | 205 | ||
208 | # Warning for limited support to Analyze format | 206 | # Warning for limited support to Analyze format |
209 | if id_type == const.ID_ANALYZE_IMPORT: | 207 | if id_type == const.ID_ANALYZE_IMPORT: |
210 | dialog.ImportAnalyzeWarning() | 208 | dialog.ImportAnalyzeWarning() |
211 | 209 | ||
212 | filepath = dialog.ShowImportOtherFilesDialog(id_type) | 210 | filepath = dialog.ShowImportOtherFilesDialog(id_type) |
213 | - Publisher.sendMessage("Open other files", filepath) | 211 | + Publisher.sendMessage("Open other files", filepath=filepath) |
214 | 212 | ||
215 | def ShowDialogOpenProject(self): | 213 | def ShowDialogOpenProject(self): |
216 | # Offer to save current project if necessary | 214 | # Offer to save current project if necessary |
@@ -265,21 +263,21 @@ class Controller(): | @@ -265,21 +263,21 @@ class Controller(): | ||
265 | if not answer: | 263 | if not answer: |
266 | utils.debug("Close without changes") | 264 | utils.debug("Close without changes") |
267 | self.CloseProject() | 265 | self.CloseProject() |
268 | - Publisher.sendMessage("Enable state project", False) | 266 | + Publisher.sendMessage("Enable state project", state=False) |
269 | Publisher.sendMessage('Set project name') | 267 | Publisher.sendMessage('Set project name') |
270 | Publisher.sendMessage("Stop Config Recording") | 268 | Publisher.sendMessage("Stop Config Recording") |
271 | elif answer == 1: | 269 | elif answer == 1: |
272 | self.ShowDialogSaveProject() | 270 | self.ShowDialogSaveProject() |
273 | utils.debug("Save changes and close") | 271 | utils.debug("Save changes and close") |
274 | self.CloseProject() | 272 | self.CloseProject() |
275 | - Publisher.sendMessage("Enable state project", False) | 273 | + Publisher.sendMessage("Enable state project", state=False) |
276 | Publisher.sendMessage('Set project name') | 274 | Publisher.sendMessage('Set project name') |
277 | Publisher.sendMessage("Stop Config Recording") | 275 | Publisher.sendMessage("Stop Config Recording") |
278 | elif answer == -1: | 276 | elif answer == -1: |
279 | utils.debug("Cancel") | 277 | utils.debug("Cancel") |
280 | else: | 278 | else: |
281 | self.CloseProject() | 279 | self.CloseProject() |
282 | - Publisher.sendMessage("Enable state project", False) | 280 | + Publisher.sendMessage("Enable state project", state=False) |
283 | Publisher.sendMessage('Set project name') | 281 | Publisher.sendMessage('Set project name') |
284 | Publisher.sendMessage("Stop Config Recording") | 282 | Publisher.sendMessage("Stop Config Recording") |
285 | 283 | ||
@@ -288,13 +286,10 @@ class Controller(): | @@ -288,13 +286,10 @@ class Controller(): | ||
288 | 286 | ||
289 | 287 | ||
290 | ########################### | 288 | ########################### |
291 | - def OnOpenProject(self, pubsub_evt): | ||
292 | - path = pubsub_evt.data | ||
293 | - self.OpenProject(path) | ||
294 | - | ||
295 | - def OnOpenRecentProject(self, pubsub_evt): | ||
296 | - filepath = pubsub_evt.data | 289 | + def OnOpenProject(self, filepath): |
290 | + self.OpenProject(filepath) | ||
297 | 291 | ||
292 | + def OnOpenRecentProject(self, filepath): | ||
298 | if os.path.exists(filepath): | 293 | if os.path.exists(filepath): |
299 | session = ses.Session() | 294 | session = ses.Session() |
300 | st = session.project_status | 295 | st = session.project_status |
@@ -325,17 +320,16 @@ class Controller(): | @@ -325,17 +320,16 @@ class Controller(): | ||
325 | self.Slice.window_width = proj.window | 320 | self.Slice.window_width = proj.window |
326 | 321 | ||
327 | Publisher.sendMessage('Update threshold limits list', | 322 | Publisher.sendMessage('Update threshold limits list', |
328 | - proj.threshold_range) | 323 | + threshold_range=proj.threshold_range) |
329 | 324 | ||
330 | self.LoadProject() | 325 | self.LoadProject() |
331 | 326 | ||
332 | session = ses.Session() | 327 | session = ses.Session() |
333 | session.OpenProject(filepath) | 328 | session.OpenProject(filepath) |
334 | - Publisher.sendMessage("Enable state project", True) | 329 | + Publisher.sendMessage("Enable state project", state=True) |
335 | 330 | ||
336 | - def OnSaveProject(self, pubsub_evt): | ||
337 | - path = pubsub_evt.data | ||
338 | - self.SaveProject(path) | 331 | + def OnSaveProject(self, filepath): |
332 | + self.SaveProject(filepath) | ||
339 | 333 | ||
340 | def SaveProject(self, path=None, compress=False): | 334 | def SaveProject(self, path=None, compress=False): |
341 | Publisher.sendMessage('Begin busy cursor') | 335 | Publisher.sendMessage('Begin busy cursor') |
@@ -356,7 +350,7 @@ class Controller(): | @@ -356,7 +350,7 @@ class Controller(): | ||
356 | Publisher.sendMessage('End busy cursor') | 350 | Publisher.sendMessage('End busy cursor') |
357 | 351 | ||
358 | def CloseProject(self): | 352 | def CloseProject(self): |
359 | - Publisher.sendMessage('Set slice interaction style', const.STATE_DEFAULT) | 353 | + Publisher.sendMessage('Set slice interaction style', style=const.STATE_DEFAULT) |
360 | Publisher.sendMessage('Hide content panel') | 354 | Publisher.sendMessage('Hide content panel') |
361 | Publisher.sendMessage('Close project data') | 355 | Publisher.sendMessage('Close project data') |
362 | 356 | ||
@@ -390,8 +384,7 @@ class Controller(): | @@ -390,8 +384,7 @@ class Controller(): | ||
390 | reader.SetDirectoryPath(path) | 384 | reader.SetDirectoryPath(path) |
391 | Publisher.sendMessage('End busy cursor') | 385 | Publisher.sendMessage('End busy cursor') |
392 | 386 | ||
393 | - def Progress(self, evt): | ||
394 | - data = evt.data | 387 | + def Progress(self, data): |
395 | if (data): | 388 | if (data): |
396 | message = _("Loading file %d of %d ...")%(data[0],data[1]) | 389 | message = _("Loading file %d of %d ...")%(data[0],data[1]) |
397 | if not(self.progress_dialog): | 390 | if not(self.progress_dialog): |
@@ -408,19 +401,17 @@ class Controller(): | @@ -408,19 +401,17 @@ class Controller(): | ||
408 | self.progress_dialog.Close() | 401 | self.progress_dialog.Close() |
409 | self.progress_dialog = None | 402 | self.progress_dialog = None |
410 | 403 | ||
411 | - def OnLoadImportPanel(self, evt): | ||
412 | - patient_series = evt.data | 404 | + def OnLoadImportPanel(self, patient_series): |
413 | ok = self.LoadImportPanel(patient_series) | 405 | ok = self.LoadImportPanel(patient_series) |
414 | if ok: | 406 | if ok: |
415 | Publisher.sendMessage('Show import panel') | 407 | Publisher.sendMessage('Show import panel') |
416 | Publisher.sendMessage("Show import panel in frame") | 408 | Publisher.sendMessage("Show import panel in frame") |
417 | self.img_type = 1 | 409 | self.img_type = 1 |
418 | 410 | ||
419 | - def OnLoadImportBitmapPanel(self, evt): | ||
420 | - data = evt.data | 411 | + def OnLoadImportBitmapPanel(self, data): |
421 | ok = self.LoadImportBitmapPanel(data) | 412 | ok = self.LoadImportBitmapPanel(data) |
422 | if ok: | 413 | if ok: |
423 | - Publisher.sendMessage('Show import bitmap panel in frame') | 414 | + Publisher.sendMessage('Show import bitmap panel in frame') |
424 | self.img_type = 2 | 415 | self.img_type = 2 |
425 | #Publisher.sendMessage("Show import panel in invesalius.gui.frame") as frame | 416 | #Publisher.sendMessage("Show import panel in invesalius.gui.frame") as frame |
426 | 417 | ||
@@ -430,7 +421,7 @@ class Controller(): | @@ -430,7 +421,7 @@ class Controller(): | ||
430 | #first_patient = patient_series[0] | 421 | #first_patient = patient_series[0] |
431 | #Publisher.sendMessage("Load bitmap preview", first_patient) | 422 | #Publisher.sendMessage("Load bitmap preview", first_patient) |
432 | if data: | 423 | if data: |
433 | - Publisher.sendMessage("Load import bitmap panel", data) | 424 | + Publisher.sendMessage("Load import bitmap panel", data=data) |
434 | return True | 425 | return True |
435 | else: | 426 | else: |
436 | dialog.ImportInvalidFiles("Bitmap") | 427 | dialog.ImportInvalidFiles("Bitmap") |
@@ -439,9 +430,9 @@ class Controller(): | @@ -439,9 +430,9 @@ class Controller(): | ||
439 | 430 | ||
440 | def LoadImportPanel(self, patient_series): | 431 | def LoadImportPanel(self, patient_series): |
441 | if patient_series and isinstance(patient_series, list): | 432 | if patient_series and isinstance(patient_series, list): |
442 | - Publisher.sendMessage("Load import panel", patient_series) | 433 | + Publisher.sendMessage("Load import panel", dicom_groups=patient_series) |
443 | first_patient = patient_series[0] | 434 | first_patient = patient_series[0] |
444 | - Publisher.sendMessage("Load dicom preview", first_patient) | 435 | + Publisher.sendMessage("Load dicom preview", patient=first_patient) |
445 | return True | 436 | return True |
446 | else: | 437 | else: |
447 | dialog.ImportInvalidFiles("DICOM") | 438 | dialog.ImportInvalidFiles("DICOM") |
@@ -450,10 +441,8 @@ class Controller(): | @@ -450,10 +441,8 @@ class Controller(): | ||
450 | 441 | ||
451 | #----------- to import by command line --------------------------------------------------- | 442 | #----------- to import by command line --------------------------------------------------- |
452 | 443 | ||
453 | - def OnImportMedicalImages(self, pubsub_evt): | ||
454 | - directory = pubsub_evt.data['directory'] | ||
455 | - gui = pubsub_evt.data['gui'] | ||
456 | - self.ImportMedicalImages(directory, gui) | 444 | + def OnImportMedicalImages(self, directory, use_gui): |
445 | + self.ImportMedicalImages(directory, use_gui) | ||
457 | 446 | ||
458 | def ImportMedicalImages(self, directory, gui=True): | 447 | def ImportMedicalImages(self, directory, gui=True): |
459 | patients_groups = dcm.GetDicomGroups(directory) | 448 | patients_groups = dcm.GetDicomGroups(directory) |
@@ -484,19 +473,17 @@ class Controller(): | @@ -484,19 +473,17 @@ class Controller(): | ||
484 | # OPTION 4: Nothing... | 473 | # OPTION 4: Nothing... |
485 | 474 | ||
486 | self.LoadProject() | 475 | self.LoadProject() |
487 | - Publisher.sendMessage("Enable state project", True) | 476 | + Publisher.sendMessage("Enable state project", state=True) |
488 | 477 | ||
489 | - def OnImportGroup(self, pubsub_evt): | ||
490 | - group = pubsub_evt.data['group'] | ||
491 | - gui = pubsub_evt.data['gui'] | ||
492 | - self.ImportGroup(group, gui) | 478 | + def OnImportGroup(self, group, use_gui): |
479 | + self.ImportGroup(group, use_gui) | ||
493 | 480 | ||
494 | def ImportGroup(self, group, gui=True): | 481 | def ImportGroup(self, group, gui=True): |
495 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, 0, [0, 0], gui=gui) | 482 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, 0, [0, 0], gui=gui) |
496 | self.CreateDicomProject(dicom, matrix, matrix_filename) | 483 | self.CreateDicomProject(dicom, matrix, matrix_filename) |
497 | 484 | ||
498 | self.LoadProject() | 485 | self.LoadProject() |
499 | - Publisher.sendMessage("Enable state project", True) | 486 | + Publisher.sendMessage("Enable state project", state=True) |
500 | 487 | ||
501 | #------------------------------------------------------------------------------------- | 488 | #------------------------------------------------------------------------------------- |
502 | 489 | ||
@@ -514,21 +501,23 @@ class Controller(): | @@ -514,21 +501,23 @@ class Controller(): | ||
514 | self.Slice.spacing = proj.spacing | 501 | self.Slice.spacing = proj.spacing |
515 | 502 | ||
516 | Publisher.sendMessage('Load slice to viewer', | 503 | Publisher.sendMessage('Load slice to viewer', |
517 | - (proj.mask_dict)) | 504 | + mask_dict=proj.mask_dict) |
518 | 505 | ||
519 | 506 | ||
520 | Publisher.sendMessage('Load slice plane') | 507 | Publisher.sendMessage('Load slice plane') |
521 | 508 | ||
522 | - Publisher.sendMessage('Bright and contrast adjustment image',\ | ||
523 | - (proj.window, proj.level)) | ||
524 | - Publisher.sendMessage('Update window level value',\ | ||
525 | - (proj.window, proj.level)) | 509 | + Publisher.sendMessage('Bright and contrast adjustment image', |
510 | + window=proj.window, | ||
511 | + level=proj.level) | ||
512 | + Publisher.sendMessage('Update window level value', | ||
513 | + window=proj.window, | ||
514 | + level=proj.level) | ||
526 | 515 | ||
527 | - Publisher.sendMessage('Set project name', proj.name) | 516 | + Publisher.sendMessage('Set project name', proj_name=proj.name) |
528 | Publisher.sendMessage('Load surface dict', | 517 | Publisher.sendMessage('Load surface dict', |
529 | - proj.surface_dict) | 518 | + surface_dict=proj.surface_dict) |
530 | Publisher.sendMessage('Hide surface items', | 519 | Publisher.sendMessage('Hide surface items', |
531 | - proj.surface_dict) | 520 | + surface_dict=proj.surface_dict) |
532 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? | 521 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? |
533 | 522 | ||
534 | Publisher.sendMessage('Show content panel') | 523 | Publisher.sendMessage('Show content panel') |
@@ -537,13 +526,11 @@ class Controller(): | @@ -537,13 +526,11 @@ class Controller(): | ||
537 | if len(proj.mask_dict): | 526 | if len(proj.mask_dict): |
538 | mask_index = len(proj.mask_dict) -1 | 527 | mask_index = len(proj.mask_dict) -1 |
539 | for m in proj.mask_dict.values(): | 528 | for m in proj.mask_dict.values(): |
540 | - Publisher.sendMessage('Add mask', | ||
541 | - (m.index, m.name, | ||
542 | - m.threshold_range, m.colour)) | 529 | + Publisher.sendMessage('Add mask', mask=m) |
543 | if m.is_shown: | 530 | if m.is_shown: |
544 | self.Slice.current_mask = proj.mask_dict[mask_index] | 531 | self.Slice.current_mask = proj.mask_dict[mask_index] |
545 | - Publisher.sendMessage('Show mask', (m.index, True)) | ||
546 | - Publisher.sendMessage('Change mask selected', m.index) | 532 | + Publisher.sendMessage('Show mask', index=m.index, value=True) |
533 | + Publisher.sendMessage('Change mask selected', index=m.index) | ||
547 | else: | 534 | else: |
548 | mask_name = const.MASK_NAME_PATTERN % (1,) | 535 | mask_name = const.MASK_NAME_PATTERN % (1,) |
549 | 536 | ||
@@ -554,14 +541,17 @@ class Controller(): | @@ -554,14 +541,17 @@ class Controller(): | ||
554 | 541 | ||
555 | colour = const.MASK_COLOUR[0] | 542 | colour = const.MASK_COLOUR[0] |
556 | Publisher.sendMessage('Create new mask', | 543 | Publisher.sendMessage('Create new mask', |
557 | - (mask_name, thresh, colour)) | 544 | + mask_name=mask_name, |
545 | + thresh=thresh, | ||
546 | + colour=colour) | ||
558 | 547 | ||
559 | Publisher.sendMessage('Load measurement dict', | 548 | Publisher.sendMessage('Load measurement dict', |
560 | - (proj.measurement_dict, self.Slice.spacing)) | 549 | + measurement_dict=proj.measurement_dict, |
550 | + spacing=self.Slice.spacing) | ||
561 | 551 | ||
562 | - Publisher.sendMessage(('Set scroll position', 'AXIAL'),proj.matrix_shape[0]/2) | ||
563 | - Publisher.sendMessage(('Set scroll position', 'SAGITAL'),proj.matrix_shape[1]/2) | ||
564 | - Publisher.sendMessage(('Set scroll position', 'CORONAL'),proj.matrix_shape[2]/2) | 552 | + Publisher.sendMessage(('Set scroll position', 'AXIAL'), index=proj.matrix_shape[0]/2) |
553 | + Publisher.sendMessage(('Set scroll position', 'SAGITAL'),index=proj.matrix_shape[1]/2) | ||
554 | + Publisher.sendMessage(('Set scroll position', 'CORONAL'),index=proj.matrix_shape[2]/2) | ||
565 | 555 | ||
566 | Publisher.sendMessage('End busy cursor') | 556 | Publisher.sendMessage('End busy cursor') |
567 | 557 | ||
@@ -675,8 +665,7 @@ class Controller(): | @@ -675,8 +665,7 @@ class Controller(): | ||
675 | 665 | ||
676 | dirpath = session.CreateProject(filename) | 666 | dirpath = session.CreateProject(filename) |
677 | 667 | ||
678 | - def OnOpenBitmapFiles(self, pubsub_evt): | ||
679 | - rec_data = pubsub_evt.data | 668 | + def OnOpenBitmapFiles(self, rec_data): |
680 | bmp_data = bmp.BitmapData() | 669 | bmp_data = bmp.BitmapData() |
681 | 670 | ||
682 | if bmp_data.IsAllBitmapSameSize(): | 671 | if bmp_data.IsAllBitmapSameSize(): |
@@ -686,12 +675,11 @@ class Controller(): | @@ -686,12 +675,11 @@ class Controller(): | ||
686 | self.CreateBitmapProject(bmp_data, rec_data, matrix, matrix_filename) | 675 | self.CreateBitmapProject(bmp_data, rec_data, matrix, matrix_filename) |
687 | 676 | ||
688 | self.LoadProject() | 677 | self.LoadProject() |
689 | - Publisher.sendMessage("Enable state project", True) | 678 | + Publisher.sendMessage("Enable state project", state=True) |
690 | else: | 679 | else: |
691 | dialogs.BitmapNotSameSize() | 680 | dialogs.BitmapNotSameSize() |
692 | 681 | ||
693 | def OpenBitmapFiles(self, bmp_data, rec_data): | 682 | def OpenBitmapFiles(self, bmp_data, rec_data): |
694 | - | ||
695 | name = rec_data[0] | 683 | name = rec_data[0] |
696 | orientation = rec_data[1] | 684 | orientation = rec_data[1] |
697 | sp_x = float(rec_data[2]) | 685 | sp_x = float(rec_data[2]) |
@@ -747,20 +735,20 @@ class Controller(): | @@ -747,20 +735,20 @@ class Controller(): | ||
747 | self.Slice.window_width = float(self.matrix.max()) | 735 | self.Slice.window_width = float(self.matrix.max()) |
748 | 736 | ||
749 | scalar_range = int(self.matrix.min()), int(self.matrix.max()) | 737 | scalar_range = int(self.matrix.min()), int(self.matrix.max()) |
750 | - Publisher.sendMessage('Update threshold limits list', scalar_range) | 738 | + Publisher.sendMessage('Update threshold limits list', |
739 | + threshold_range=scalar_range) | ||
751 | 740 | ||
752 | return self.matrix, self.filename#, dicom | 741 | return self.matrix, self.filename#, dicom |
753 | 742 | ||
754 | 743 | ||
755 | - def OnOpenDicomGroup(self, pubsub_evt): | ||
756 | - group, interval, file_range = pubsub_evt.data | 744 | + def OnOpenDicomGroup(self, group, interval, file_range): |
757 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, interval, file_range, gui=True) | 745 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, interval, file_range, gui=True) |
758 | self.CreateDicomProject(dicom, matrix, matrix_filename) | 746 | self.CreateDicomProject(dicom, matrix, matrix_filename) |
759 | self.LoadProject() | 747 | self.LoadProject() |
760 | - Publisher.sendMessage("Enable state project", True) | 748 | + Publisher.sendMessage("Enable state project", state=True) |
761 | 749 | ||
762 | - def OnOpenOtherFiles(self, pubsub_evt): | ||
763 | - filepath = utils.decode(pubsub_evt.data, const.FS_ENCODE) | 750 | + def OnOpenOtherFiles(self, filepath): |
751 | + filepath = utils.decode(filepath, const.FS_ENCODE) | ||
764 | if not(filepath) == None: | 752 | if not(filepath) == None: |
765 | name = filepath.rpartition('\\')[-1].split('.') | 753 | name = filepath.rpartition('\\')[-1].split('.') |
766 | 754 | ||
@@ -770,7 +758,7 @@ class Controller(): | @@ -770,7 +758,7 @@ class Controller(): | ||
770 | matrix, matrix_filename = self.OpenOtherFiles(group) | 758 | matrix, matrix_filename = self.OpenOtherFiles(group) |
771 | self.CreateOtherProject(str(name[0]), matrix, matrix_filename) | 759 | self.CreateOtherProject(str(name[0]), matrix, matrix_filename) |
772 | self.LoadProject() | 760 | self.LoadProject() |
773 | - Publisher.sendMessage("Enable state project", True) | 761 | + Publisher.sendMessage("Enable state project", state=True) |
774 | else: | 762 | else: |
775 | dialog.ImportInvalidFiles(ftype="Others") | 763 | dialog.ImportInvalidFiles(ftype="Others") |
776 | 764 | ||
@@ -861,7 +849,8 @@ class Controller(): | @@ -861,7 +849,8 @@ class Controller(): | ||
861 | 849 | ||
862 | scalar_range = int(self.matrix.min()), int(self.matrix.max()) | 850 | scalar_range = int(self.matrix.min()), int(self.matrix.max()) |
863 | 851 | ||
864 | - Publisher.sendMessage('Update threshold limits list', scalar_range) | 852 | + Publisher.sendMessage('Update threshold limits list', |
853 | + threshold_range=scalar_range) | ||
865 | 854 | ||
866 | return self.matrix, self.filename, dicom | 855 | return self.matrix, self.filename, dicom |
867 | 856 | ||
@@ -886,7 +875,8 @@ class Controller(): | @@ -886,7 +875,8 @@ class Controller(): | ||
886 | self.Slice.window_width = ww | 875 | self.Slice.window_width = ww |
887 | 876 | ||
888 | scalar_range = int(scalar_range[0]), int(scalar_range[1]) | 877 | scalar_range = int(scalar_range[0]), int(scalar_range[1]) |
889 | - Publisher.sendMessage('Update threshold limits list', scalar_range) | 878 | + Publisher.sendMessage('Update threshold limits list', |
879 | + threshold_range=scalar_range) | ||
890 | return self.matrix, self.filename | 880 | return self.matrix, self.filename |
891 | 881 | ||
892 | def LoadImagedataInfo(self): | 882 | def LoadImagedataInfo(self): |
@@ -909,24 +899,20 @@ class Controller(): | @@ -909,24 +899,20 @@ class Controller(): | ||
909 | [a,b] = default_threshold | 899 | [a,b] = default_threshold |
910 | default_threshold = (a,b) | 900 | default_threshold = (a,b) |
911 | Publisher.sendMessage('Set threshold modes', | 901 | Publisher.sendMessage('Set threshold modes', |
912 | - (thresh_modes,default_threshold)) | 902 | + thresh_modes_names=thresh_modes, |
903 | + default_thresh=default_threshold) | ||
913 | 904 | ||
914 | - def LoadRaycastingPreset(self, pubsub_evt=None): | ||
915 | - if pubsub_evt: | ||
916 | - label = pubsub_evt.data | ||
917 | - else: | ||
918 | - return | ||
919 | - | ||
920 | - if label != const.RAYCASTING_OFF_LABEL: | ||
921 | - if label in const.RAYCASTING_FILES.keys(): | 905 | + def LoadRaycastingPreset(self, preset_name): |
906 | + if preset_name != const.RAYCASTING_OFF_LABEL: | ||
907 | + if preset_name in const.RAYCASTING_FILES.keys(): | ||
922 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 908 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, |
923 | - const.RAYCASTING_FILES[label]) | 909 | + const.RAYCASTING_FILES[preset_name]) |
924 | else: | 910 | else: |
925 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 911 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, |
926 | - label+".plist") | 912 | + preset_name+".plist") |
927 | if not os.path.isfile(path): | 913 | if not os.path.isfile(path): |
928 | path = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, | 914 | path = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, |
929 | - label+".plist") | 915 | + preset_name+".plist") |
930 | preset = plistlib.readPlist(path) | 916 | preset = plistlib.readPlist(path) |
931 | prj.Project().raycasting_preset = preset | 917 | prj.Project().raycasting_preset = preset |
932 | # Notify volume | 918 | # Notify volume |
@@ -936,17 +922,16 @@ class Controller(): | @@ -936,17 +922,16 @@ class Controller(): | ||
936 | prj.Project().raycasting_preset = 0 | 922 | prj.Project().raycasting_preset = 0 |
937 | Publisher.sendMessage('Update raycasting preset') | 923 | Publisher.sendMessage('Update raycasting preset') |
938 | 924 | ||
939 | - def SaveRaycastingPreset(self, pubsub_evt): | ||
940 | - preset_name = pubsub_evt.data | 925 | + def SaveRaycastingPreset(self, preset_name): |
941 | preset = prj.Project().raycasting_preset | 926 | preset = prj.Project().raycasting_preset |
942 | preset['name'] = preset_name | 927 | preset['name'] = preset_name |
943 | preset_dir = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, | 928 | preset_dir = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, |
944 | preset_name + '.plist') | 929 | preset_name + '.plist') |
945 | plistlib.writePlist(preset, preset_dir) | 930 | plistlib.writePlist(preset, preset_dir) |
946 | 931 | ||
947 | - def ShowBooleanOpDialog(self, pubsub_evt): | 932 | + def ShowBooleanOpDialog(self): |
948 | dlg = dialogs.MaskBooleanDialog(prj.Project().mask_dict) | 933 | dlg = dialogs.MaskBooleanDialog(prj.Project().mask_dict) |
949 | dlg.Show() | 934 | dlg.Show() |
950 | 935 | ||
951 | - def ApplyReorientation(self, pubsub_evt): | 936 | + def ApplyReorientation(self): |
952 | self.Slice.apply_reorientation() | 937 | self.Slice.apply_reorientation() |
invesalius/data/coordinates.py
@@ -86,7 +86,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode): | @@ -86,7 +86,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode): | ||
86 | k += 1 | 86 | k += 1 |
87 | print("wait, collecting coordinates ...") | 87 | print("wait, collecting coordinates ...") |
88 | 88 | ||
89 | - Publisher.sendMessage('Sensors ID', [trck.probeID, trck.refID]) | 89 | + Publisher.sendMessage('Sensors ID', probe_id=trck.probeID, ref_id=trck.refID) |
90 | 90 | ||
91 | return coord | 91 | return coord |
92 | 92 | ||
@@ -225,7 +225,7 @@ def DebugCoord(trk_init, trck_id, ref_mode): | @@ -225,7 +225,7 @@ def DebugCoord(trk_init, trck_id, ref_mode): | ||
225 | coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), | 225 | coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), |
226 | uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) | 226 | uniform(-180.0, 180.0), uniform(-180.0, 180.0), uniform(-180.0, 180.0)]) |
227 | 227 | ||
228 | - Publisher.sendMessage('Sensors ID', [int(uniform(0, 5)), int(uniform(0, 5))]) | 228 | + Publisher.sendMessage('Sensors ID', probe_id=int(uniform(0, 5)), ref_id=int(uniform(0, 5))) |
229 | 229 | ||
230 | return np.vstack([coord1, coord2, coord3]) | 230 | return np.vstack([coord1, coord2, coord3]) |
231 | 231 |
invesalius/data/coregistration.py
@@ -72,7 +72,7 @@ class CoregistrationStatic(threading.Thread): | @@ -72,7 +72,7 @@ class CoregistrationStatic(threading.Thread): | ||
72 | 72 | ||
73 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], psi, theta, phi | 73 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], psi, theta, phi |
74 | 74 | ||
75 | - wx.CallAfter(Publisher.sendMessage, 'Co-registered points', (m_img, coord)) | 75 | + wx.CallAfter(Publisher.sendMessage, 'Co-registered points', arg=m_img, position=coord) |
76 | 76 | ||
77 | # TODO: Optimize the value of sleep for each tracking device. | 77 | # TODO: Optimize the value of sleep for each tracking device. |
78 | sleep(0.175) | 78 | sleep(0.175) |
@@ -127,7 +127,7 @@ class CoregistrationDynamic(threading.Thread): | @@ -127,7 +127,7 @@ class CoregistrationDynamic(threading.Thread): | ||
127 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ | 127 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ |
128 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) | 128 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) |
129 | 129 | ||
130 | - wx.CallAfter(Publisher.sendMessage, 'Co-registered points', (m_img, coord)) | 130 | + wx.CallAfter(Publisher.sendMessage, 'Co-registered points', arg=m_img, position=coord) |
131 | 131 | ||
132 | # TODO: Optimize the value of sleep for each tracking device. | 132 | # TODO: Optimize the value of sleep for each tracking device. |
133 | sleep(0.175) | 133 | sleep(0.175) |
@@ -179,7 +179,7 @@ class CoregistrationDynamic_old(threading.Thread): | @@ -179,7 +179,7 @@ class CoregistrationDynamic_old(threading.Thread): | ||
179 | 179 | ||
180 | # Tried several combinations and different locations to send the messages, | 180 | # Tried several combinations and different locations to send the messages, |
181 | # however only this one does not block the GUI during navigation. | 181 | # however only this one does not block the GUI during navigation. |
182 | - wx.CallAfter(Publisher.sendMessage, 'Co-registered points', coord) | 182 | + wx.CallAfter(Publisher.sendMessage, 'Co-registered points', arg=None, position=coord) |
183 | wx.CallAfter(Publisher.sendMessage, 'Set camera in volume', coord) | 183 | wx.CallAfter(Publisher.sendMessage, 'Set camera in volume', coord) |
184 | wx.CallAfter(Publisher.sendMessage, 'Update tracker angles', angles) | 184 | wx.CallAfter(Publisher.sendMessage, 'Update tracker angles', angles) |
185 | 185 | ||
@@ -253,8 +253,8 @@ class CoregistrationObjectStatic(threading.Thread): | @@ -253,8 +253,8 @@ class CoregistrationObjectStatic(threading.Thread): | ||
253 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ | 253 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ |
254 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) | 254 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) |
255 | 255 | ||
256 | - wx.CallAfter(Publisher.sendMessage, 'Co-registered points', (m_img, coord)) | ||
257 | - wx.CallAfter(Publisher.sendMessage, 'Update object matrix', (m_img, coord)) | 256 | + wx.CallAfter(Publisher.sendMessage, 'Co-registered points', arg=m_img, position=coord) |
257 | + wx.CallAfter(Publisher.sendMessage, 'Update object matrix', m_img=m_img, coord=coord) | ||
258 | 258 | ||
259 | # TODO: Optimize the value of sleep for each tracking device. | 259 | # TODO: Optimize the value of sleep for each tracking device. |
260 | sleep(0.175) | 260 | sleep(0.175) |
@@ -335,8 +335,8 @@ class CoregistrationObjectDynamic(threading.Thread): | @@ -335,8 +335,8 @@ class CoregistrationObjectDynamic(threading.Thread): | ||
335 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1],\ | 335 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1],\ |
336 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) | 336 | degrees(angles[0]), degrees(angles[1]), degrees(angles[2]) |
337 | 337 | ||
338 | - wx.CallAfter(Publisher.sendMessage, 'Co-registered points', (m_img, coord)) | ||
339 | - wx.CallAfter(Publisher.sendMessage, 'Update object matrix', (m_img, coord)) | 338 | + wx.CallAfter(Publisher.sendMessage, 'Co-registered points', arg=m_img, position=coord) |
339 | + wx.CallAfter(Publisher.sendMessage, 'Update object matrix', m_img=m_img, coord=coord) | ||
340 | 340 | ||
341 | # TODO: Optimize the value of sleep for each tracking device. | 341 | # TODO: Optimize the value of sleep for each tracking device. |
342 | sleep(0.175) | 342 | sleep(0.175) |
@@ -360,4 +360,4 @@ class CoregistrationObjectDynamic(threading.Thread): | @@ -360,4 +360,4 @@ class CoregistrationObjectDynamic(threading.Thread): | ||
360 | # R_dyn = M_vtk * M_obj_rot_raw.I * S0_rot_dyn.I * R_reference.I * R_stylus * M_obj_rot_raw | 360 | # R_dyn = M_vtk * M_obj_rot_raw.I * S0_rot_dyn.I * R_reference.I * R_stylus * M_obj_rot_raw |
361 | 361 | ||
362 | if self._pause_: | 362 | if self._pause_: |
363 | - return | ||
364 | \ No newline at end of file | 363 | \ No newline at end of file |
364 | + return |
invesalius/data/geometry.py
@@ -136,7 +136,7 @@ class Box(with_metaclass(utils.Singleton, object)): | @@ -136,7 +136,7 @@ class Box(with_metaclass(utils.Singleton, object)): | ||
136 | self.axial[const.AXIAL_RIGHT] = [[self.xf + (self.xs/2), self.yi, self.zi],\ | 136 | self.axial[const.AXIAL_RIGHT] = [[self.xf + (self.xs/2), self.yi, self.zi],\ |
137 | [self.xf + (self.xs/2), self.yf, self.zf]] | 137 | [self.xf + (self.xs/2), self.yf, self.zf]] |
138 | 138 | ||
139 | - Publisher.sendMessage('Update crop limits into gui', self.GetLimits()) | 139 | + Publisher.sendMessage('Update crop limits into gui', limits=self.GetLimits()) |
140 | 140 | ||
141 | 141 | ||
142 | def GetLimits(self): | 142 | def GetLimits(self): |
invesalius/data/mask.py
@@ -78,8 +78,8 @@ class EditionHistory(object): | @@ -78,8 +78,8 @@ class EditionHistory(object): | ||
78 | self.index = -1 | 78 | self.index = -1 |
79 | self.size = size * 2 | 79 | self.size = size * 2 |
80 | 80 | ||
81 | - Publisher.sendMessage("Enable undo", False) | ||
82 | - Publisher.sendMessage("Enable redo", False) | 81 | + Publisher.sendMessage("Enable undo", value=False) |
82 | + Publisher.sendMessage("Enable redo", value=False) | ||
83 | 83 | ||
84 | def new_node(self, index, orientation, array, p_array, clean): | 84 | def new_node(self, index, orientation, array, p_array, clean): |
85 | # Saving the previous state, used to undo/redo correctly. | 85 | # Saving the previous state, used to undo/redo correctly. |
@@ -100,8 +100,8 @@ class EditionHistory(object): | @@ -100,8 +100,8 @@ class EditionHistory(object): | ||
100 | self.index += 1 | 100 | self.index += 1 |
101 | 101 | ||
102 | print("INDEX", self.index, len(self.history), self.history) | 102 | print("INDEX", self.index, len(self.history), self.history) |
103 | - Publisher.sendMessage("Enable undo", True) | ||
104 | - Publisher.sendMessage("Enable redo", False) | 103 | + Publisher.sendMessage("Enable undo", value=True) |
104 | + Publisher.sendMessage("Enable redo", value=False) | ||
105 | 105 | ||
106 | def undo(self, mvolume, actual_slices=None): | 106 | def undo(self, mvolume, actual_slices=None): |
107 | h = self.history | 107 | h = self.history |
@@ -114,7 +114,7 @@ class EditionHistory(object): | @@ -114,7 +114,7 @@ class EditionHistory(object): | ||
114 | self.index -= 1 | 114 | self.index -= 1 |
115 | h[self.index].commit_history(mvolume) | 115 | h[self.index].commit_history(mvolume) |
116 | self._reload_slice(self.index) | 116 | self._reload_slice(self.index) |
117 | - Publisher.sendMessage("Enable redo", True) | 117 | + Publisher.sendMessage("Enable redo", value=True) |
118 | elif actual_slices and actual_slices[h[self.index - 1].orientation] != h[self.index - 1].index: | 118 | elif actual_slices and actual_slices[h[self.index - 1].orientation] != h[self.index - 1].index: |
119 | self._reload_slice(self.index - 1) | 119 | self._reload_slice(self.index - 1) |
120 | else: | 120 | else: |
@@ -124,10 +124,10 @@ class EditionHistory(object): | @@ -124,10 +124,10 @@ class EditionHistory(object): | ||
124 | self.index -= 1 | 124 | self.index -= 1 |
125 | h[self.index].commit_history(mvolume) | 125 | h[self.index].commit_history(mvolume) |
126 | self._reload_slice(self.index) | 126 | self._reload_slice(self.index) |
127 | - Publisher.sendMessage("Enable redo", True) | 127 | + Publisher.sendMessage("Enable redo", value=True) |
128 | 128 | ||
129 | if self.index == 0: | 129 | if self.index == 0: |
130 | - Publisher.sendMessage("Enable undo", False) | 130 | + Publisher.sendMessage("Enable undo", value=False) |
131 | print("AT", self.index, len(self.history), self.history[self.index].filename) | 131 | print("AT", self.index, len(self.history), self.history[self.index].filename) |
132 | 132 | ||
133 | def redo(self, mvolume, actual_slices=None): | 133 | def redo(self, mvolume, actual_slices=None): |
@@ -142,7 +142,7 @@ class EditionHistory(object): | @@ -142,7 +142,7 @@ class EditionHistory(object): | ||
142 | self.index += 1 | 142 | self.index += 1 |
143 | h[self.index].commit_history(mvolume) | 143 | h[self.index].commit_history(mvolume) |
144 | self._reload_slice(self.index) | 144 | self._reload_slice(self.index) |
145 | - Publisher.sendMessage("Enable undo", True) | 145 | + Publisher.sendMessage("Enable undo", value=True) |
146 | elif actual_slices and actual_slices[h[self.index + 1].orientation] != h[self.index + 1].index: | 146 | elif actual_slices and actual_slices[h[self.index + 1].orientation] != h[self.index + 1].index: |
147 | self._reload_slice(self.index + 1) | 147 | self._reload_slice(self.index + 1) |
148 | else: | 148 | else: |
@@ -152,15 +152,15 @@ class EditionHistory(object): | @@ -152,15 +152,15 @@ class EditionHistory(object): | ||
152 | self.index += 1 | 152 | self.index += 1 |
153 | h[self.index].commit_history(mvolume) | 153 | h[self.index].commit_history(mvolume) |
154 | self._reload_slice(self.index) | 154 | self._reload_slice(self.index) |
155 | - Publisher.sendMessage("Enable undo", True) | 155 | + Publisher.sendMessage("Enable undo", value=True) |
156 | 156 | ||
157 | if self.index == len(h) - 1: | 157 | if self.index == len(h) - 1: |
158 | - Publisher.sendMessage("Enable redo", False) | 158 | + Publisher.sendMessage("Enable redo", value=False) |
159 | print("AT", self.index, len(h), h[self.index].filename) | 159 | print("AT", self.index, len(h), h[self.index].filename) |
160 | 160 | ||
161 | def _reload_slice(self, index): | 161 | def _reload_slice(self, index): |
162 | Publisher.sendMessage(('Set scroll position', self.history[index].orientation), | 162 | Publisher.sendMessage(('Set scroll position', self.history[index].orientation), |
163 | - self.history[index].index) | 163 | + index=self.history[index].index) |
164 | 164 | ||
165 | def _config_undo_redo(self, visible): | 165 | def _config_undo_redo(self, visible): |
166 | v_undo = False | 166 | v_undo = False |
@@ -174,14 +174,14 @@ class EditionHistory(object): | @@ -174,14 +174,14 @@ class EditionHistory(object): | ||
174 | elif self.index == len(self.history) - 1: | 174 | elif self.index == len(self.history) - 1: |
175 | v_redo = False | 175 | v_redo = False |
176 | 176 | ||
177 | - Publisher.sendMessage("Enable undo", v_undo) | ||
178 | - Publisher.sendMessage("Enable redo", v_redo) | 177 | + Publisher.sendMessage("Enable undo", value=v_undo) |
178 | + Publisher.sendMessage("Enable redo", value=v_redo) | ||
179 | 179 | ||
180 | def clear_history(self): | 180 | def clear_history(self): |
181 | self.history = [] | 181 | self.history = [] |
182 | self.index = -1 | 182 | self.index = -1 |
183 | - Publisher.sendMessage("Enable undo", False) | ||
184 | - Publisher.sendMessage("Enable redo", False) | 183 | + Publisher.sendMessage("Enable undo", value=False) |
184 | + Publisher.sendMessage("Enable redo", value=False) | ||
185 | 185 | ||
186 | 186 | ||
187 | class Mask(): | 187 | class Mask(): |
@@ -273,8 +273,7 @@ class Mask(): | @@ -273,8 +273,7 @@ class Mask(): | ||
273 | path = os.path.join(dirpath, mask_file) | 273 | path = os.path.join(dirpath, mask_file) |
274 | self._open_mask(path, tuple(shape)) | 274 | self._open_mask(path, tuple(shape)) |
275 | 275 | ||
276 | - def OnFlipVolume(self, pubsub_evt): | ||
277 | - axis = pubsub_evt.data | 276 | + def OnFlipVolume(self, axis): |
278 | submatrix = self.matrix[1:, 1:, 1:] | 277 | submatrix = self.matrix[1:, 1:, 1:] |
279 | if axis == 0: | 278 | if axis == 0: |
280 | submatrix[:] = submatrix[::-1] | 279 | submatrix[:] = submatrix[::-1] |
@@ -286,8 +285,8 @@ class Mask(): | @@ -286,8 +285,8 @@ class Mask(): | ||
286 | submatrix[:] = submatrix[:, :, ::-1] | 285 | submatrix[:] = submatrix[:, :, ::-1] |
287 | self.matrix[0, 0, 1::] = self.matrix[0, 0, :0:-1] | 286 | self.matrix[0, 0, 1::] = self.matrix[0, 0, :0:-1] |
288 | 287 | ||
289 | - def OnSwapVolumeAxes(self, pubsub_evt): | ||
290 | - axis0, axis1 = pubsub_evt.data | 288 | + def OnSwapVolumeAxes(self, axes): |
289 | + axis0, axis1 = axes | ||
291 | self.matrix = self.matrix.swapaxes(axis0, axis1) | 290 | self.matrix = self.matrix.swapaxes(axis0, axis1) |
292 | 291 | ||
293 | def _save_mask(self, filename): | 292 | def _save_mask(self, filename): |
invesalius/data/measures.py
@@ -120,14 +120,9 @@ class MeasurementManager(object): | @@ -120,14 +120,9 @@ class MeasurementManager(object): | ||
120 | Publisher.subscribe(self._change_measure_point_pos, 'Change measurement point position') | 120 | Publisher.subscribe(self._change_measure_point_pos, 'Change measurement point position') |
121 | Publisher.subscribe(self.OnCloseProject, 'Close project data') | 121 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
122 | 122 | ||
123 | - def _load_measurements(self, pubsub_evt): | ||
124 | - try: | ||
125 | - dict, spacing = pubsub_evt.data | ||
126 | - except ValueError: | ||
127 | - dict = pubsub_evt.data | ||
128 | - spacing = 1.0, 1.0, 1.0 | ||
129 | - for i in dict: | ||
130 | - m = dict[i] | 123 | + def _load_measurements(self, measurement_dict, spacing=(1.0, 1.0, 1.0)): |
124 | + for i in measurement_dict: | ||
125 | + m = measurement_dict[i] | ||
131 | 126 | ||
132 | if m.location == const.AXIAL: | 127 | if m.location == const.AXIAL: |
133 | radius = min(spacing[1], spacing[2]) * const.PROP_MEASURE | 128 | radius = min(spacing[1], spacing[2]) * const.PROP_MEASURE |
@@ -154,7 +149,7 @@ class MeasurementManager(object): | @@ -154,7 +149,7 @@ class MeasurementManager(object): | ||
154 | 149 | ||
155 | if m.location == const.SURFACE: | 150 | if m.location == const.SURFACE: |
156 | Publisher.sendMessage(("Add actors " + str(m.location)), | 151 | Publisher.sendMessage(("Add actors " + str(m.location)), |
157 | - (actors, m.slice_number)) | 152 | + actors=actors) |
158 | self.current = None | 153 | self.current = None |
159 | 154 | ||
160 | if not m.visible: | 155 | if not m.visible: |
@@ -164,28 +159,7 @@ class MeasurementManager(object): | @@ -164,28 +159,7 @@ class MeasurementManager(object): | ||
164 | else: | 159 | else: |
165 | Publisher.sendMessage('Redraw canvas') | 160 | Publisher.sendMessage('Redraw canvas') |
166 | 161 | ||
167 | - def _add_point(self, pubsub_evt): | ||
168 | - position = pubsub_evt.data[0] | ||
169 | - type = pubsub_evt.data[1] # Linear or Angular | ||
170 | - location = pubsub_evt.data[2] # 3D, AXIAL, SAGITAL, CORONAL | ||
171 | - | ||
172 | - if location == const.SURFACE: | ||
173 | - slice_number = 0 | ||
174 | - try: | ||
175 | - radius = pubsub_evt.data[3] | ||
176 | - except IndexError: | ||
177 | - radius = const.PROP_MEASURE | ||
178 | - else: | ||
179 | - try: | ||
180 | - slice_number = pubsub_evt.data[3] | ||
181 | - except IndexError: | ||
182 | - slice_number = 0 | ||
183 | - | ||
184 | - try: | ||
185 | - radius = pubsub_evt.data[4] | ||
186 | - except IndexError: | ||
187 | - radius = const.PROP_MEASURE | ||
188 | - | 162 | + def _add_point(self, position, type, location, slice_number=0, radius=const.PROP_MEASURE): |
189 | to_remove = False | 163 | to_remove = False |
190 | if self.current is None: | 164 | if self.current is None: |
191 | to_create = True | 165 | to_create = True |
@@ -233,8 +207,7 @@ class MeasurementManager(object): | @@ -233,8 +207,7 @@ class MeasurementManager(object): | ||
233 | m.points.append(position) | 207 | m.points.append(position) |
234 | 208 | ||
235 | if m.location == const.SURFACE: | 209 | if m.location == const.SURFACE: |
236 | - Publisher.sendMessage("Add actors " + str(location), | ||
237 | - (actors, m.slice_number)) | 210 | + Publisher.sendMessage("Add actors " + str(location), actors=actors) |
238 | 211 | ||
239 | if self.current not in self.measures: | 212 | if self.current not in self.measures: |
240 | self.measures.append(self.current) | 213 | self.measures.append(self.current) |
@@ -254,14 +227,12 @@ class MeasurementManager(object): | @@ -254,14 +227,12 @@ class MeasurementManager(object): | ||
254 | 227 | ||
255 | msg = 'Update measurement info in GUI', | 228 | msg = 'Update measurement info in GUI', |
256 | Publisher.sendMessage(msg, | 229 | Publisher.sendMessage(msg, |
257 | - (index, name, colour, | ||
258 | - location, | ||
259 | - type_, | ||
260 | - value)) | 230 | + index=index, name=name, |
231 | + colour=colour, location=location, | ||
232 | + type_=type_, value=value) | ||
261 | self.current = None | 233 | self.current = None |
262 | 234 | ||
263 | - def _change_measure_point_pos(self, pubsub_evt): | ||
264 | - index, npoint, pos = pubsub_evt.data | 235 | + def _change_measure_point_pos(self, index, npoint, pos): |
265 | m, mr = self.measures[index] | 236 | m, mr = self.measures[index] |
266 | x, y, z = pos | 237 | x, y, z = pos |
267 | if npoint == 0: | 238 | if npoint == 0: |
@@ -288,17 +259,14 @@ class MeasurementManager(object): | @@ -288,17 +259,14 @@ class MeasurementManager(object): | ||
288 | value = u"%.3f°"% m.value | 259 | value = u"%.3f°"% m.value |
289 | 260 | ||
290 | Publisher.sendMessage('Update measurement info in GUI', | 261 | Publisher.sendMessage('Update measurement info in GUI', |
291 | - (index, name, colour, | ||
292 | - location, | ||
293 | - type_, | ||
294 | - value)) | 262 | + index=index, name=name, colour=colour, |
263 | + location=location, type_=type_, | ||
264 | + value=value) | ||
295 | 265 | ||
296 | - def _change_name(self, pubsub_evt): | ||
297 | - index, new_name = pubsub_evt.data | ||
298 | - self.measures[index].name = new_name | 266 | + def _change_name(self, index, name): |
267 | + self.measures[index][0].name = name | ||
299 | 268 | ||
300 | - def _remove_measurements(self, pubsub_evt): | ||
301 | - indexes = pubsub_evt.data | 269 | + def _remove_measurements(self, indexes): |
302 | for index in indexes: | 270 | for index in indexes: |
303 | m, mr = self.measures.pop(index) | 271 | m, mr = self.measures.pop(index) |
304 | try: | 272 | try: |
@@ -308,16 +276,15 @@ class MeasurementManager(object): | @@ -308,16 +276,15 @@ class MeasurementManager(object): | ||
308 | pass | 276 | pass |
309 | prj.Project().RemoveMeasurement(index) | 277 | prj.Project().RemoveMeasurement(index) |
310 | if m.location == const.SURFACE: | 278 | if m.location == const.SURFACE: |
311 | - Publisher.sendMessage(('Remove actors ' + str(m.location)), | ||
312 | - (mr.GetActors(), m.slice_number)) | 279 | + Publisher.sendMessage('Remove actors ' + str(m.location), |
280 | + actors=mr.GetActors()) | ||
313 | Publisher.sendMessage('Redraw canvas') | 281 | Publisher.sendMessage('Redraw canvas') |
314 | Publisher.sendMessage('Render volume viewer') | 282 | Publisher.sendMessage('Render volume viewer') |
315 | 283 | ||
316 | session = ses.Session() | 284 | session = ses.Session() |
317 | session.ChangeProject() | 285 | session.ChangeProject() |
318 | 286 | ||
319 | - def _set_visibility(self, pubsub_evt): | ||
320 | - index, visibility = pubsub_evt.data | 287 | + def _set_visibility(self, index, visibility): |
321 | m, mr = self.measures[index] | 288 | m, mr = self.measures[index] |
322 | m.visible = visibility | 289 | m.visible = visibility |
323 | mr.SetVisibility(visibility) | 290 | mr.SetVisibility(visibility) |
@@ -326,7 +293,7 @@ class MeasurementManager(object): | @@ -326,7 +293,7 @@ class MeasurementManager(object): | ||
326 | else: | 293 | else: |
327 | Publisher.sendMessage('Redraw canvas') | 294 | Publisher.sendMessage('Redraw canvas') |
328 | 295 | ||
329 | - def _rm_incomplete_measurements(self, pubsub_evt): | 296 | + def _rm_incomplete_measurements(self): |
330 | if self.current is None: | 297 | if self.current is None: |
331 | return | 298 | return |
332 | 299 | ||
@@ -334,12 +301,12 @@ class MeasurementManager(object): | @@ -334,12 +301,12 @@ class MeasurementManager(object): | ||
334 | if not mr.IsComplete(): | 301 | if not mr.IsComplete(): |
335 | idx = self.measures._list_measures.index((m, mr)) | 302 | idx = self.measures._list_measures.index((m, mr)) |
336 | self.measures.remove((m, mr)) | 303 | self.measures.remove((m, mr)) |
337 | - Publisher.sendMessage("Remove GUI measurement", idx) | 304 | + Publisher.sendMessage("Remove GUI measurement", measure_index=idx) |
338 | actors = mr.GetActors() | 305 | actors = mr.GetActors() |
339 | slice_number = self.current[0].slice_number | 306 | slice_number = self.current[0].slice_number |
340 | if m.location == const.SURFACE: | 307 | if m.location == const.SURFACE: |
341 | Publisher.sendMessage(('Remove actors ' + str(self.current[0].location)), | 308 | Publisher.sendMessage(('Remove actors ' + str(self.current[0].location)), |
342 | - (actors, slice_number)) | 309 | + actors=actors) |
343 | if self.current[0].location == const.SURFACE: | 310 | if self.current[0].location == const.SURFACE: |
344 | Publisher.sendMessage('Render volume viewer') | 311 | Publisher.sendMessage('Render volume viewer') |
345 | else: | 312 | else: |
@@ -349,7 +316,7 @@ class MeasurementManager(object): | @@ -349,7 +316,7 @@ class MeasurementManager(object): | ||
349 | # self.measures.pop() | 316 | # self.measures.pop() |
350 | self.current = None | 317 | self.current = None |
351 | 318 | ||
352 | - def OnCloseProject(self, pubsub_evt): | 319 | + def OnCloseProject(self): |
353 | self.measures.clean() | 320 | self.measures.clean() |
354 | 321 | ||
355 | 322 | ||
@@ -650,7 +617,7 @@ class LinearMeasure(object): | @@ -650,7 +617,7 @@ class LinearMeasure(object): | ||
650 | 617 | ||
651 | def Remove(self): | 618 | def Remove(self): |
652 | actors = self.GetActors() | 619 | actors = self.GetActors() |
653 | - Publisher.sendMessage("Remove actors " + str(const.SURFACE), (actors,)) | 620 | + Publisher.sendMessage("Remove actors " + str(const.SURFACE), actors=actors) |
654 | 621 | ||
655 | def __del__(self): | 622 | def __del__(self): |
656 | self.Remove() | 623 | self.Remove() |
@@ -901,7 +868,7 @@ class AngularMeasure(object): | @@ -901,7 +868,7 @@ class AngularMeasure(object): | ||
901 | 868 | ||
902 | def Remove(self): | 869 | def Remove(self): |
903 | actors = self.GetActors() | 870 | actors = self.GetActors() |
904 | - Publisher.sendMessage("Remove actors " + str(const.SURFACE), (actors,)) | 871 | + Publisher.sendMessage("Remove actors " + str(const.SURFACE), actors=actors) |
905 | 872 | ||
906 | def SetRenderer(self, renderer): | 873 | def SetRenderer(self, renderer): |
907 | if self.point_actor1: | 874 | if self.point_actor1: |
invesalius/data/record_coords.py
@@ -44,8 +44,8 @@ class Record(threading.Thread): | @@ -44,8 +44,8 @@ class Record(threading.Thread): | ||
44 | def __bind_events(self): | 44 | def __bind_events(self): |
45 | Publisher.subscribe(self.UpdateCurrentCoords, 'Co-registered points') | 45 | Publisher.subscribe(self.UpdateCurrentCoords, 'Co-registered points') |
46 | 46 | ||
47 | - def UpdateCurrentCoords(self, pubsub_evt): | ||
48 | - self.coord = asarray(pubsub_evt.data[1]) | 47 | + def UpdateCurrentCoords(self, arg, position): |
48 | + self.coord = asarray(position) | ||
49 | 49 | ||
50 | def stop(self): | 50 | def stop(self): |
51 | self._pause_ = True | 51 | self._pause_ = True |
@@ -64,4 +64,4 @@ class Record(threading.Thread): | @@ -64,4 +64,4 @@ class Record(threading.Thread): | ||
64 | else: | 64 | else: |
65 | self.coord_list = vstack((self.coord_list, hstack((relative_time, self.coord)))) | 65 | self.coord_list = vstack((self.coord_list, hstack((relative_time, self.coord)))) |
66 | if self._pause_: | 66 | if self._pause_: |
67 | - return | ||
68 | \ No newline at end of file | 67 | \ No newline at end of file |
68 | + return |
invesalius/data/slice_.py
@@ -219,10 +219,9 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -219,10 +219,9 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
219 | buffer_.discard_vtk_mask() | 219 | buffer_.discard_vtk_mask() |
220 | buffer_.discard_mask() | 220 | buffer_.discard_mask() |
221 | 221 | ||
222 | - def OnRemoveMasks(self, pubsub_evt): | ||
223 | - selected_items = pubsub_evt.data | 222 | + def OnRemoveMasks(self, mask_indexes): |
224 | proj = Project() | 223 | proj = Project() |
225 | - for item in selected_items: | 224 | + for item in mask_indexes: |
226 | proj.RemoveMask(item) | 225 | proj.RemoveMask(item) |
227 | 226 | ||
228 | # if the deleted mask is the current mask, cleans the current mask | 227 | # if the deleted mask is the current mask, cleans the current mask |
@@ -234,14 +233,13 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -234,14 +233,13 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
234 | buffer_.discard_vtk_mask() | 233 | buffer_.discard_vtk_mask() |
235 | buffer_.discard_mask() | 234 | buffer_.discard_mask() |
236 | 235 | ||
237 | - Publisher.sendMessage('Show mask', (item, 0)) | 236 | + Publisher.sendMessage('Show mask', index=item, value=False) |
238 | Publisher.sendMessage('Reload actual slice') | 237 | Publisher.sendMessage('Reload actual slice') |
239 | 238 | ||
240 | - def OnDuplicateMasks(self, pubsub_evt): | ||
241 | - selected_items = pubsub_evt.data | 239 | + def OnDuplicateMasks(self, mask_indexes): |
242 | proj = Project() | 240 | proj = Project() |
243 | mask_dict = proj.mask_dict | 241 | mask_dict = proj.mask_dict |
244 | - for index in selected_items: | 242 | + for index in mask_indexes: |
245 | original_mask = mask_dict[index] | 243 | original_mask = mask_dict[index] |
246 | # compute copy name | 244 | # compute copy name |
247 | name = original_mask.name | 245 | name = original_mask.name |
@@ -251,34 +249,32 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -251,34 +249,32 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
251 | copy_mask = original_mask.copy(new_name) | 249 | copy_mask = original_mask.copy(new_name) |
252 | self._add_mask_into_proj(copy_mask) | 250 | self._add_mask_into_proj(copy_mask) |
253 | 251 | ||
254 | - def OnEnableStyle(self, pubsub_evt): | ||
255 | - state = pubsub_evt.data | ||
256 | - if (state in const.SLICE_STYLES): | ||
257 | - new_state = self.interaction_style.AddState(state) | ||
258 | - Publisher.sendMessage('Set slice interaction style', new_state) | ||
259 | - self.state = state | 252 | + def OnEnableStyle(self, style): |
253 | + if (style in const.SLICE_STYLES): | ||
254 | + new_state = self.interaction_style.AddState(style) | ||
255 | + Publisher.sendMessage('Set slice interaction style', style=new_state) | ||
256 | + self.state = style | ||
260 | 257 | ||
261 | - def OnDisableStyle(self, pubsub_evt): | ||
262 | - state = pubsub_evt.data | ||
263 | - if (state in const.SLICE_STYLES): | ||
264 | - new_state = self.interaction_style.RemoveState(state) | ||
265 | - Publisher.sendMessage('Set slice interaction style', new_state) | 258 | + def OnDisableStyle(self, style): |
259 | + if (style in const.SLICE_STYLES): | ||
260 | + new_state = self.interaction_style.RemoveState(style) | ||
261 | + Publisher.sendMessage('Set slice interaction style', style=new_state) | ||
266 | 262 | ||
267 | - if (state == const.SLICE_STATE_EDITOR): | 263 | + if (style == const.SLICE_STATE_EDITOR): |
268 | Publisher.sendMessage('Set interactor default cursor') | 264 | Publisher.sendMessage('Set interactor default cursor') |
269 | self.state = new_state | 265 | self.state = new_state |
270 | 266 | ||
271 | - def OnDisableActualStyle(self, pubsub_evt): | 267 | + def OnDisableActualStyle(self): |
272 | actual_state = self.interaction_style.GetActualState() | 268 | actual_state = self.interaction_style.GetActualState() |
273 | if actual_state != const.STATE_DEFAULT: | 269 | if actual_state != const.STATE_DEFAULT: |
274 | new_state = self.interaction_style.RemoveState(actual_state) | 270 | new_state = self.interaction_style.RemoveState(actual_state) |
275 | - Publisher.sendMessage('Set slice interaction style', new_state) | 271 | + Publisher.sendMessage('Set slice interaction style', style=new_state) |
276 | 272 | ||
277 | # if (actual_state == const.SLICE_STATE_EDITOR): | 273 | # if (actual_state == const.SLICE_STATE_EDITOR): |
278 | # Publisher.sendMessage('Set interactor default cursor') | 274 | # Publisher.sendMessage('Set interactor default cursor') |
279 | self.state = new_state | 275 | self.state = new_state |
280 | 276 | ||
281 | - def OnCloseProject(self, pubsub_evt): | 277 | + def OnCloseProject(self): |
282 | self.CloseProject() | 278 | self.CloseProject() |
283 | 279 | ||
284 | def CloseProject(self): | 280 | def CloseProject(self): |
@@ -310,39 +306,32 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -310,39 +306,32 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
310 | 306 | ||
311 | Publisher.sendMessage('Select first item from slice menu') | 307 | Publisher.sendMessage('Select first item from slice menu') |
312 | 308 | ||
313 | - def __set_current_mask_threshold_limits(self, pubsub_evt): | ||
314 | - thresh_min = pubsub_evt.data[0] | ||
315 | - thresh_max = pubsub_evt.data[1] | 309 | + def __set_current_mask_threshold_limits(self, threshold_range): |
310 | + thresh_min = threshold_range[0] | ||
311 | + thresh_max = threshold_range[1] | ||
316 | if self.current_mask: | 312 | if self.current_mask: |
317 | index = self.current_mask.index | 313 | index = self.current_mask.index |
318 | self.SetMaskEditionThreshold(index, (thresh_min, thresh_max)) | 314 | self.SetMaskEditionThreshold(index, (thresh_min, thresh_max)) |
319 | 315 | ||
320 | - def __add_mask(self, pubsub_evt): | ||
321 | - mask_name = pubsub_evt.data | 316 | + def __add_mask(self, mask_name): |
322 | self.create_new_mask(name=mask_name) | 317 | self.create_new_mask(name=mask_name) |
323 | self.SetMaskColour(self.current_mask.index, self.current_mask.colour) | 318 | self.SetMaskColour(self.current_mask.index, self.current_mask.colour) |
324 | 319 | ||
325 | - def __add_mask_thresh(self, pubsub_evt): | ||
326 | - mask_name = pubsub_evt.data[0] | ||
327 | - thresh = pubsub_evt.data[1] | ||
328 | - colour = pubsub_evt.data[2] | 320 | + def __add_mask_thresh(self, mask_name, thresh, colour): |
329 | self.create_new_mask(name=mask_name, threshold_range=thresh, colour=colour) | 321 | self.create_new_mask(name=mask_name, threshold_range=thresh, colour=colour) |
330 | self.SetMaskColour(self.current_mask.index, self.current_mask.colour) | 322 | self.SetMaskColour(self.current_mask.index, self.current_mask.colour) |
331 | self.SelectCurrentMask(self.current_mask.index) | 323 | self.SelectCurrentMask(self.current_mask.index) |
332 | Publisher.sendMessage('Reload actual slice') | 324 | Publisher.sendMessage('Reload actual slice') |
333 | 325 | ||
334 | - def __select_current_mask(self, pubsub_evt): | ||
335 | - mask_index = pubsub_evt.data | ||
336 | - self.SelectCurrentMask(mask_index) | 326 | + def __select_current_mask(self, index): |
327 | + self.SelectCurrentMask(index) | ||
337 | 328 | ||
338 | - def __set_current_mask_edition_threshold(self, evt_pubsub): | 329 | + def __set_current_mask_edition_threshold(self, threshold_range): |
339 | if self.current_mask: | 330 | if self.current_mask: |
340 | - threshold_range = evt_pubsub.data | ||
341 | index = self.current_mask.index | 331 | index = self.current_mask.index |
342 | self.SetMaskEditionThreshold(index, threshold_range) | 332 | self.SetMaskEditionThreshold(index, threshold_range) |
343 | 333 | ||
344 | - def __set_current_mask_threshold(self, evt_pubsub): | ||
345 | - threshold_range = evt_pubsub.data | 334 | + def __set_current_mask_threshold(self, threshold_range): |
346 | index = self.current_mask.index | 335 | index = self.current_mask.index |
347 | self.num_gradient += 1 | 336 | self.num_gradient += 1 |
348 | self.current_mask.matrix[:] = 0 | 337 | self.current_mask.matrix[:] = 0 |
@@ -379,8 +368,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -379,8 +368,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
379 | if to_reload: | 368 | if to_reload: |
380 | Publisher.sendMessage('Reload actual slice') | 369 | Publisher.sendMessage('Reload actual slice') |
381 | 370 | ||
382 | - def __set_current_mask_threshold_actual_slice(self, evt_pubsub): | ||
383 | - threshold_range = evt_pubsub.data | 371 | + def __set_current_mask_threshold_actual_slice(self, threshold_range): |
384 | index = self.current_mask.index | 372 | index = self.current_mask.index |
385 | for orientation in self.buffer_slices: | 373 | for orientation in self.buffer_slices: |
386 | self.buffer_slices[orientation].discard_vtk_mask() | 374 | self.buffer_slices[orientation].discard_vtk_mask() |
@@ -391,44 +379,41 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -391,44 +379,41 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
391 | 379 | ||
392 | Publisher.sendMessage('Reload actual slice') | 380 | Publisher.sendMessage('Reload actual slice') |
393 | 381 | ||
394 | - def __set_current_mask_colour(self, pubsub_evt): | 382 | + def __set_current_mask_colour(self, colour): |
395 | # "if" is necessary because wx events are calling this before any mask | 383 | # "if" is necessary because wx events are calling this before any mask |
396 | # has been created | 384 | # has been created |
397 | if self.current_mask: | 385 | if self.current_mask: |
398 | - colour_wx = pubsub_evt.data | ||
399 | - colour_vtk = [c/255.0 for c in colour_wx] | 386 | + colour_vtk = [c/255.0 for c in colour] |
400 | self.SetMaskColour(self.current_mask.index, colour_vtk) | 387 | self.SetMaskColour(self.current_mask.index, colour_vtk) |
401 | 388 | ||
402 | - def __set_mask_name(self, pubsub_evt): | ||
403 | - index, name = pubsub_evt.data | 389 | + def __set_mask_name(self, index, name): |
404 | self.SetMaskName(index, name) | 390 | self.SetMaskName(index, name) |
405 | 391 | ||
406 | - def __show_mask(self, pubsub_evt): | 392 | + def __show_mask(self, index, value): |
407 | # "if" is necessary because wx events are calling this before any mask | 393 | # "if" is necessary because wx events are calling this before any mask |
408 | # has been created | 394 | # has been created |
409 | if self.current_mask: | 395 | if self.current_mask: |
410 | - index, value = pubsub_evt.data | ||
411 | self.ShowMask(index, value) | 396 | self.ShowMask(index, value) |
412 | if not value: | 397 | if not value: |
413 | - Publisher.sendMessage('Select mask name in combo', -1) | 398 | + Publisher.sendMessage('Select mask name in combo', index=-1) |
414 | 399 | ||
415 | if self._type_projection != const.PROJECTION_NORMAL: | 400 | if self._type_projection != const.PROJECTION_NORMAL: |
416 | self.SetTypeProjection(const.PROJECTION_NORMAL) | 401 | self.SetTypeProjection(const.PROJECTION_NORMAL) |
417 | Publisher.sendMessage('Reload actual slice') | 402 | Publisher.sendMessage('Reload actual slice') |
418 | 403 | ||
419 | - def __hide_current_mask(self, pubsub_evt): | 404 | + def __hide_current_mask(self): |
420 | if self.current_mask: | 405 | if self.current_mask: |
421 | index = self.current_mask.index | 406 | index = self.current_mask.index |
422 | value = False | 407 | value = False |
423 | - Publisher.sendMessage('Show mask', (index, value)) | 408 | + Publisher.sendMessage('Show mask', index=index, value=value) |
424 | 409 | ||
425 | - def __show_current_mask(self, pubsub_evt): | 410 | + def __show_current_mask(self): |
426 | if self.current_mask: | 411 | if self.current_mask: |
427 | index = self.current_mask.index | 412 | index = self.current_mask.index |
428 | value = True | 413 | value = True |
429 | - Publisher.sendMessage('Show mask', (index, value)) | 414 | + Publisher.sendMessage('Show mask', index=index, value=value) |
430 | 415 | ||
431 | - def __clean_current_mask(self, pubsub_evt): | 416 | + def __clean_current_mask(self): |
432 | if self.current_mask: | 417 | if self.current_mask: |
433 | self.current_mask.clean() | 418 | self.current_mask.clean() |
434 | for buffer_ in self.buffer_slices.values(): | 419 | for buffer_ in self.buffer_slices.values(): |
@@ -844,8 +829,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -844,8 +829,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
844 | (r,g,b) = colour[:3] | 829 | (r,g,b) = colour[:3] |
845 | colour_wx = [r*255, g*255, b*255] | 830 | colour_wx = [r*255, g*255, b*255] |
846 | Publisher.sendMessage('Change mask colour in notebook', | 831 | Publisher.sendMessage('Change mask colour in notebook', |
847 | - (index, (r,g,b))) | ||
848 | - Publisher.sendMessage('Set GUI items colour', colour_wx) | 832 | + index=index, colour=(r,g,b)) |
833 | + Publisher.sendMessage('Set GUI items colour', colour=colour_wx) | ||
849 | if update: | 834 | if update: |
850 | # Updating mask colour on vtkimagedata. | 835 | # Updating mask colour on vtkimagedata. |
851 | for buffer_ in self.buffer_slices.values(): | 836 | for buffer_ in self.buffer_slices.values(): |
@@ -899,8 +884,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -899,8 +884,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
899 | 884 | ||
900 | # Update data notebook (GUI) | 885 | # Update data notebook (GUI) |
901 | Publisher.sendMessage('Set mask threshold in notebook', | 886 | Publisher.sendMessage('Set mask threshold in notebook', |
902 | - (self.current_mask.index, | ||
903 | - self.current_mask.threshold_range)) | 887 | + index=self.current_mask.index, |
888 | + threshold_range=self.current_mask.threshold_range) | ||
904 | else: | 889 | else: |
905 | proj = Project() | 890 | proj = Project() |
906 | proj.mask_dict[index].threshold_range = threshold_range | 891 | proj.mask_dict[index].threshold_range = threshold_range |
@@ -936,32 +921,30 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -936,32 +921,30 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
936 | "SAGITAL": SliceBuffer()} | 921 | "SAGITAL": SliceBuffer()} |
937 | 922 | ||
938 | Publisher.sendMessage('Set mask threshold in notebook', | 923 | Publisher.sendMessage('Set mask threshold in notebook', |
939 | - (index, | ||
940 | - self.current_mask.threshold_range)) | 924 | + index=index, |
925 | + threshold_range=self.current_mask.threshold_range) | ||
941 | Publisher.sendMessage('Set threshold values in gradient', | 926 | Publisher.sendMessage('Set threshold values in gradient', |
942 | - self.current_mask.threshold_range) | ||
943 | - Publisher.sendMessage('Select mask name in combo', index) | 927 | + threshold_range=self.current_mask.threshold_range) |
928 | + Publisher.sendMessage('Select mask name in combo', index=index) | ||
944 | Publisher.sendMessage('Update slice viewer') | 929 | Publisher.sendMessage('Update slice viewer') |
945 | #--------------------------------------------------------------------------- | 930 | #--------------------------------------------------------------------------- |
946 | 931 | ||
947 | - def CreateSurfaceFromIndex(self, pubsub_evt): | ||
948 | - surface_parameters = pubsub_evt.data | ||
949 | - | 932 | + def CreateSurfaceFromIndex(self, surface_parameters): |
950 | proj = Project() | 933 | proj = Project() |
951 | mask = proj.mask_dict[surface_parameters['options']['index']] | 934 | mask = proj.mask_dict[surface_parameters['options']['index']] |
952 | 935 | ||
953 | self.do_threshold_to_all_slices(mask) | 936 | self.do_threshold_to_all_slices(mask) |
954 | - Publisher.sendMessage('Create surface', (self, mask, surface_parameters)) | 937 | + Publisher.sendMessage('Create surface', |
938 | + slice_=self, mask=mask, | ||
939 | + surface_parameters=surface_parameters) | ||
955 | 940 | ||
956 | def GetOutput(self): | 941 | def GetOutput(self): |
957 | return self.blend_filter.GetOutput() | 942 | return self.blend_filter.GetOutput() |
958 | 943 | ||
959 | - def _set_projection_type(self, pubsub_evt): | ||
960 | - tprojection = pubsub_evt.data | ||
961 | - self.SetTypeProjection(tprojection) | 944 | + def _set_projection_type(self, projection_id): |
945 | + self.SetTypeProjection(projection_id) | ||
962 | 946 | ||
963 | - def _set_interpolation_method(self, pubsub_evt): | ||
964 | - interp_method = pubsub_evt.data | 947 | + def _set_interpolation_method(self, interp_method): |
965 | self.SetInterpolationMethod(interp_method) | 948 | self.SetInterpolationMethod(interp_method) |
966 | 949 | ||
967 | def SetTypeProjection(self, tprojection): | 950 | def SetTypeProjection(self, tprojection): |
@@ -970,15 +953,15 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -970,15 +953,15 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
970 | Publisher.sendMessage('Hide current mask') | 953 | Publisher.sendMessage('Hide current mask') |
971 | 954 | ||
972 | if tprojection == const.PROJECTION_NORMAL: | 955 | if tprojection == const.PROJECTION_NORMAL: |
973 | - Publisher.sendMessage('Show MIP interface', False) | 956 | + Publisher.sendMessage('Show MIP interface', flag=False) |
974 | else: | 957 | else: |
975 | - Publisher.sendMessage('Show MIP interface', True) | 958 | + Publisher.sendMessage('Show MIP interface', flag=True) |
976 | 959 | ||
977 | self._type_projection = tprojection | 960 | self._type_projection = tprojection |
978 | for buffer_ in self.buffer_slices.values(): | 961 | for buffer_ in self.buffer_slices.values(): |
979 | buffer_.discard_buffer() | 962 | buffer_.discard_buffer() |
980 | 963 | ||
981 | - Publisher.sendMessage('Check projection menu', tprojection) | 964 | + Publisher.sendMessage('Check projection menu', projection_id=tprojection) |
982 | 965 | ||
983 | def SetInterpolationMethod(self, interp_method): | 966 | def SetInterpolationMethod(self, interp_method): |
984 | if self.interp_method != interp_method: | 967 | if self.interp_method != interp_method: |
@@ -987,8 +970,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -987,8 +970,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
987 | buffer_.discard_buffer() | 970 | buffer_.discard_buffer() |
988 | Publisher.sendMessage('Reload actual slice') | 971 | Publisher.sendMessage('Reload actual slice') |
989 | 972 | ||
990 | - def UpdateWindowLevelBackground(self, pubsub_evt): | ||
991 | - window, level = pubsub_evt.data | 973 | + def UpdateWindowLevelBackground(self, window, level): |
992 | self.window_width = window | 974 | self.window_width = window |
993 | self.window_level = level | 975 | self.window_level = level |
994 | 976 | ||
@@ -1004,8 +986,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1004,8 +986,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1004 | 986 | ||
1005 | Publisher.sendMessage('Reload actual slice') | 987 | Publisher.sendMessage('Reload actual slice') |
1006 | 988 | ||
1007 | - def UpdateColourTableBackground(self, pubsub_evt): | ||
1008 | - values = pubsub_evt.data | 989 | + def UpdateColourTableBackground(self, values): |
1009 | self.from_= OTHER | 990 | self.from_= OTHER |
1010 | self.number_of_colours= values[0] | 991 | self.number_of_colours= values[0] |
1011 | self.saturation_range = values[1] | 992 | self.saturation_range = values[1] |
@@ -1015,16 +996,16 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1015,16 +996,16 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1015 | buffer_.discard_vtk_image() | 996 | buffer_.discard_vtk_image() |
1016 | Publisher.sendMessage('Reload actual slice') | 997 | Publisher.sendMessage('Reload actual slice') |
1017 | 998 | ||
1018 | - def UpdateColourTableBackgroundPlist(self, pubsub_evt): | ||
1019 | - self.values = pubsub_evt.data | 999 | + def UpdateColourTableBackgroundPlist(self, values): |
1000 | + self.values = values | ||
1020 | self.from_= PLIST | 1001 | self.from_= PLIST |
1021 | for buffer_ in self.buffer_slices.values(): | 1002 | for buffer_ in self.buffer_slices.values(): |
1022 | buffer_.discard_vtk_image() | 1003 | buffer_.discard_vtk_image() |
1023 | 1004 | ||
1024 | Publisher.sendMessage('Reload actual slice') | 1005 | Publisher.sendMessage('Reload actual slice') |
1025 | 1006 | ||
1026 | - def UpdateColourTableBackgroundWidget(self, pubsub_evt): | ||
1027 | - self.nodes = pubsub_evt.data | 1007 | + def UpdateColourTableBackgroundWidget(self, nodes): |
1008 | + self.nodes = nodes | ||
1028 | self.from_= WIDGET | 1009 | self.from_= WIDGET |
1029 | for buffer_ in self.buffer_slices.values(): | 1010 | for buffer_ in self.buffer_slices.values(): |
1030 | if self._type_projection in (const.PROJECTION_NORMAL, | 1011 | if self._type_projection in (const.PROJECTION_NORMAL, |
@@ -1045,8 +1026,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1045,8 +1026,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1045 | 1026 | ||
1046 | Publisher.sendMessage('Reload actual slice') | 1027 | Publisher.sendMessage('Reload actual slice') |
1047 | 1028 | ||
1048 | - def UpdateSlice3D(self, pubsub_evt): | ||
1049 | - widget, orientation = pubsub_evt.data | 1029 | + def UpdateSlice3D(self, widget, orientation): |
1050 | img = self.buffer_slices[orientation].vtk_image | 1030 | img = self.buffer_slices[orientation].vtk_image |
1051 | original_orientation = Project().original_orientation | 1031 | original_orientation = Project().original_orientation |
1052 | cast = vtk.vtkImageCast() | 1032 | cast = vtk.vtkImageCast() |
@@ -1125,15 +1105,12 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1125,15 +1105,12 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1125 | 1105 | ||
1126 | ## update gui related to mask | 1106 | ## update gui related to mask |
1127 | Publisher.sendMessage('Add mask', | 1107 | Publisher.sendMessage('Add mask', |
1128 | - (mask.index, | ||
1129 | - mask.name, | ||
1130 | - mask.threshold_range, | ||
1131 | - mask.colour)) | 1108 | + mask=mask) |
1132 | 1109 | ||
1133 | if show: | 1110 | if show: |
1134 | self.current_mask = mask | 1111 | self.current_mask = mask |
1135 | - Publisher.sendMessage('Show mask', (mask.index, 1)) | ||
1136 | - Publisher.sendMessage('Change mask selected', mask.index) | 1112 | + Publisher.sendMessage('Show mask', index=mask.index, value=True) |
1113 | + Publisher.sendMessage('Change mask selected', index=mask.index) | ||
1137 | Publisher.sendMessage('Update slice viewer') | 1114 | Publisher.sendMessage('Update slice viewer') |
1138 | 1115 | ||
1139 | def do_ww_wl(self, image): | 1116 | def do_ww_wl(self, image): |
@@ -1336,9 +1313,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1336,9 +1313,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1336 | 1313 | ||
1337 | return blend_imagedata.GetOutput() | 1314 | return blend_imagedata.GetOutput() |
1338 | 1315 | ||
1339 | - def _do_boolean_op(self, pubsub_evt): | ||
1340 | - op, m1, m2 = pubsub_evt.data | ||
1341 | - self.do_boolean_op(op, m1, m2) | 1316 | + def _do_boolean_op(self, operation, mask1, mask2): |
1317 | + self.do_boolean_op(operation, mask1, mask2) | ||
1342 | 1318 | ||
1343 | 1319 | ||
1344 | def do_boolean_op(self, op, m1, m2): | 1320 | def do_boolean_op(self, op, m1, m2): |
@@ -1449,7 +1425,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1449,7 +1425,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1449 | self.q_orientation = np.array((1, 0, 0, 0)) | 1425 | self.q_orientation = np.array((1, 0, 0, 0)) |
1450 | self.center = [(s * d/2.0) for (d, s) in zip(self.matrix.shape[::-1], self.spacing)] | 1426 | self.center = [(s * d/2.0) for (d, s) in zip(self.matrix.shape[::-1], self.spacing)] |
1451 | 1427 | ||
1452 | - self.__clean_current_mask(None) | 1428 | + self.__clean_current_mask() |
1453 | if self.current_mask: | 1429 | if self.current_mask: |
1454 | self.current_mask.matrix[:] = 0 | 1430 | self.current_mask.matrix[:] = 0 |
1455 | self.current_mask.was_edited = False | 1431 | self.current_mask.was_edited = False |
@@ -1459,7 +1435,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1459,7 +1435,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1459 | 1435 | ||
1460 | Publisher.sendMessage('Reload actual slice') | 1436 | Publisher.sendMessage('Reload actual slice') |
1461 | 1437 | ||
1462 | - def __undo_edition(self, pub_evt): | 1438 | + def __undo_edition(self): |
1463 | buffer_slices = self.buffer_slices | 1439 | buffer_slices = self.buffer_slices |
1464 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, | 1440 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, |
1465 | "CORONAL": buffer_slices["CORONAL"].index, | 1441 | "CORONAL": buffer_slices["CORONAL"].index, |
@@ -1471,7 +1447,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1471,7 +1447,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1471 | self.buffer_slices[o].discard_vtk_mask() | 1447 | self.buffer_slices[o].discard_vtk_mask() |
1472 | Publisher.sendMessage('Reload actual slice') | 1448 | Publisher.sendMessage('Reload actual slice') |
1473 | 1449 | ||
1474 | - def __redo_edition(self, pub_evt): | 1450 | + def __redo_edition(self): |
1475 | buffer_slices = self.buffer_slices | 1451 | buffer_slices = self.buffer_slices |
1476 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, | 1452 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, |
1477 | "CORONAL": buffer_slices["CORONAL"].index, | 1453 | "CORONAL": buffer_slices["CORONAL"].index, |
@@ -1487,8 +1463,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1487,8 +1463,7 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1487 | self.matrix_filename = filename | 1463 | self.matrix_filename = filename |
1488 | self.matrix = np.memmap(filename, shape=shape, dtype=dtype, mode='r+') | 1464 | self.matrix = np.memmap(filename, shape=shape, dtype=dtype, mode='r+') |
1489 | 1465 | ||
1490 | - def OnFlipVolume(self, pubsub_evt): | ||
1491 | - axis = pubsub_evt.data | 1466 | + def OnFlipVolume(self, axis): |
1492 | if axis == 0: | 1467 | if axis == 0: |
1493 | self.matrix[:] = self.matrix[::-1] | 1468 | self.matrix[:] = self.matrix[::-1] |
1494 | elif axis == 1: | 1469 | elif axis == 1: |
@@ -1499,8 +1474,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1499,8 +1474,8 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1499 | for buffer_ in self.buffer_slices.values(): | 1474 | for buffer_ in self.buffer_slices.values(): |
1500 | buffer_.discard_buffer() | 1475 | buffer_.discard_buffer() |
1501 | 1476 | ||
1502 | - def OnSwapVolumeAxes(self, pubsub_evt): | ||
1503 | - axis0, axis1 = pubsub_evt.data | 1477 | + def OnSwapVolumeAxes(self, axes): |
1478 | + axis0, axis1 = axes | ||
1504 | self.matrix = self.matrix.swapaxes(axis0, axis1) | 1479 | self.matrix = self.matrix.swapaxes(axis0, axis1) |
1505 | if (axis0, axis1) == (2, 1): | 1480 | if (axis0, axis1) == (2, 1): |
1506 | self.spacing = self.spacing[1], self.spacing[0], self.spacing[2] | 1481 | self.spacing = self.spacing[1], self.spacing[0], self.spacing[2] |
@@ -1512,20 +1487,17 @@ class Slice(with_metaclass(utils.Singleton, object)): | @@ -1512,20 +1487,17 @@ class Slice(with_metaclass(utils.Singleton, object)): | ||
1512 | for buffer_ in self.buffer_slices.values(): | 1487 | for buffer_ in self.buffer_slices.values(): |
1513 | buffer_.discard_buffer() | 1488 | buffer_.discard_buffer() |
1514 | 1489 | ||
1515 | - def OnExportMask(self, pubsub_evt): | ||
1516 | - pass | ||
1517 | - ##imagedata = self.current_mask.imagedata | ||
1518 | - #imagedata = self.imagedata | ||
1519 | - #filename, filetype = pubsub_evt.data | ||
1520 | - #if (filetype == const.FILETYPE_IMAGEDATA): | ||
1521 | - #iu.Export(imagedata, filename) | ||
1522 | - | ||
1523 | - def _fill_holes_auto(self, pubsub_evt): | ||
1524 | - data = pubsub_evt.data | ||
1525 | - target = data['target'] | ||
1526 | - conn = data['conn'] | ||
1527 | - orientation = data['orientation'] | ||
1528 | - size = data['size'] | 1490 | + def OnExportMask(self, filename, filetype): |
1491 | + imagedata = self.current_mask.imagedata | ||
1492 | + # imagedata = self.imagedata | ||
1493 | + if (filetype == const.FILETYPE_IMAGEDATA): | ||
1494 | + iu.Export(imagedata, filename) | ||
1495 | + | ||
1496 | + def _fill_holes_auto(self, parameters): | ||
1497 | + target = parameters['target'] | ||
1498 | + conn = parameters['conn'] | ||
1499 | + orientation = parameters['orientation'] | ||
1500 | + size = parameters['size'] | ||
1529 | 1501 | ||
1530 | if target == '2D': | 1502 | if target == '2D': |
1531 | index = self.buffer_slices[orientation].index | 1503 | index = self.buffer_slices[orientation].index |
invesalius/data/styles.py
@@ -214,12 +214,12 @@ class CrossInteractorStyle(DefaultInteractorStyle): | @@ -214,12 +214,12 @@ class CrossInteractorStyle(DefaultInteractorStyle): | ||
214 | def SetUp(self): | 214 | def SetUp(self): |
215 | self.viewer._set_cross_visibility(1) | 215 | self.viewer._set_cross_visibility(1) |
216 | Publisher.sendMessage('Toggle toolbar item', | 216 | Publisher.sendMessage('Toggle toolbar item', |
217 | - (self.state_code, True)) | 217 | + _id=self.state_code, value=True) |
218 | 218 | ||
219 | def CleanUp(self): | 219 | def CleanUp(self): |
220 | self.viewer._set_cross_visibility(0) | 220 | self.viewer._set_cross_visibility(0) |
221 | Publisher.sendMessage('Toggle toolbar item', | 221 | Publisher.sendMessage('Toggle toolbar item', |
222 | - (self.state_code, False)) | 222 | + _id=self.state_code, value=False) |
223 | 223 | ||
224 | def OnCrossMouseClick(self, obj, evt): | 224 | def OnCrossMouseClick(self, obj, evt): |
225 | iren = obj.GetInteractor() | 225 | iren = obj.GetInteractor() |
@@ -237,29 +237,29 @@ class CrossInteractorStyle(DefaultInteractorStyle): | @@ -237,29 +237,29 @@ class CrossInteractorStyle(DefaultInteractorStyle): | ||
237 | wx, wy, wz = self.viewer.get_coordinate_cursor(mouse_x, mouse_y, self.picker) | 237 | wx, wy, wz = self.viewer.get_coordinate_cursor(mouse_x, mouse_y, self.picker) |
238 | px, py = self.viewer.get_slice_pixel_coord_by_world_pos(wx, wy, wz) | 238 | px, py = self.viewer.get_slice_pixel_coord_by_world_pos(wx, wy, wz) |
239 | coord = self.viewer.calcultate_scroll_position(px, py) | 239 | coord = self.viewer.calcultate_scroll_position(px, py) |
240 | - Publisher.sendMessage('Update cross position', (wx, wy, wz)) | 240 | + Publisher.sendMessage('Update cross position', position=(wx, wy, wz)) |
241 | self.ScrollSlice(coord) | 241 | self.ScrollSlice(coord) |
242 | - Publisher.sendMessage('Set ball reference position', (wx, wy, wz)) | ||
243 | - Publisher.sendMessage('Co-registered points', (None, (wx, wy, wz, 0., 0., 0.))) | 242 | + Publisher.sendMessage('Set ball reference position', position=(wx, wy, wz)) |
243 | + Publisher.sendMessage('Co-registered points', arg=None, position=(wx, wy, wz, 0., 0., 0.)) | ||
244 | 244 | ||
245 | iren.Render() | 245 | iren.Render() |
246 | 246 | ||
247 | def ScrollSlice(self, coord): | 247 | def ScrollSlice(self, coord): |
248 | if self.orientation == "AXIAL": | 248 | if self.orientation == "AXIAL": |
249 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), | 249 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
250 | - coord[0]) | 250 | + index=coord[0]) |
251 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), | 251 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
252 | - coord[1]) | 252 | + index=coord[1]) |
253 | elif self.orientation == "SAGITAL": | 253 | elif self.orientation == "SAGITAL": |
254 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), | 254 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
255 | - coord[2]) | 255 | + index=coord[2]) |
256 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), | 256 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
257 | - coord[1]) | 257 | + index=coord[1]) |
258 | elif self.orientation == "CORONAL": | 258 | elif self.orientation == "CORONAL": |
259 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), | 259 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
260 | - coord[2]) | 260 | + index=coord[2]) |
261 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), | 261 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
262 | - coord[0]) | 262 | + index=coord[0]) |
263 | 263 | ||
264 | 264 | ||
265 | class WWWLInteractorStyle(DefaultInteractorStyle): | 265 | class WWWLInteractorStyle(DefaultInteractorStyle): |
@@ -285,14 +285,14 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | @@ -285,14 +285,14 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | ||
285 | def SetUp(self): | 285 | def SetUp(self): |
286 | self.viewer.on_wl = True | 286 | self.viewer.on_wl = True |
287 | Publisher.sendMessage('Toggle toolbar item', | 287 | Publisher.sendMessage('Toggle toolbar item', |
288 | - (self.state_code, True)) | 288 | + _id=self.state_code, value=True) |
289 | self.viewer.canvas.draw_list.append(self.viewer.wl_text) | 289 | self.viewer.canvas.draw_list.append(self.viewer.wl_text) |
290 | self.viewer.UpdateCanvas() | 290 | self.viewer.UpdateCanvas() |
291 | 291 | ||
292 | def CleanUp(self): | 292 | def CleanUp(self): |
293 | self.viewer.on_wl = False | 293 | self.viewer.on_wl = False |
294 | Publisher.sendMessage('Toggle toolbar item', | 294 | Publisher.sendMessage('Toggle toolbar item', |
295 | - (self.state_code, False)) | 295 | + _id=self.state_code, value=False) |
296 | if self.viewer.wl_text is not None: | 296 | if self.viewer.wl_text is not None: |
297 | self.viewer.canvas.draw_list.remove(self.viewer.wl_text) | 297 | self.viewer.canvas.draw_list.remove(self.viewer.wl_text) |
298 | self.viewer.UpdateCanvas() | 298 | self.viewer.UpdateCanvas() |
@@ -306,7 +306,8 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | @@ -306,7 +306,8 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | ||
306 | self.last_x, self.last_y = mouse_x, mouse_y | 306 | self.last_x, self.last_y = mouse_x, mouse_y |
307 | 307 | ||
308 | Publisher.sendMessage('Bright and contrast adjustment image', | 308 | Publisher.sendMessage('Bright and contrast adjustment image', |
309 | - (self.acum_achange_window, self.acum_achange_level)) | 309 | + window=self.acum_achange_window, |
310 | + level=self.acum_achange_level) | ||
310 | 311 | ||
311 | #self.SetWLText(self.acum_achange_level, | 312 | #self.SetWLText(self.acum_achange_level, |
312 | # self.acum_achange_window) | 313 | # self.acum_achange_window) |
@@ -314,8 +315,9 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | @@ -314,8 +315,9 @@ class WWWLInteractorStyle(DefaultInteractorStyle): | ||
314 | const.WINDOW_LEVEL['Manual'] = (self.acum_achange_window,\ | 315 | const.WINDOW_LEVEL['Manual'] = (self.acum_achange_window,\ |
315 | self.acum_achange_level) | 316 | self.acum_achange_level) |
316 | Publisher.sendMessage('Check window and level other') | 317 | Publisher.sendMessage('Check window and level other') |
317 | - Publisher.sendMessage('Update window level value',(self.acum_achange_window, | ||
318 | - self.acum_achange_level)) | 318 | + Publisher.sendMessage('Update window level value', |
319 | + window=self.acum_achange_window, | ||
320 | + level= self.acum_achange_level) | ||
319 | #Necessary update the slice plane in the volume case exists | 321 | #Necessary update the slice plane in the volume case exists |
320 | Publisher.sendMessage('Update slice viewer') | 322 | Publisher.sendMessage('Update slice viewer') |
321 | Publisher.sendMessage('Render volume viewer') | 323 | Publisher.sendMessage('Render volume viewer') |
@@ -374,11 +376,11 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -374,11 +376,11 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
374 | 376 | ||
375 | def SetUp(self): | 377 | def SetUp(self): |
376 | Publisher.sendMessage('Toggle toolbar item', | 378 | Publisher.sendMessage('Toggle toolbar item', |
377 | - (self.state_code, True)) | 379 | + _id=self.state_code, value=True) |
378 | 380 | ||
379 | def CleanUp(self): | 381 | def CleanUp(self): |
380 | Publisher.sendMessage('Toggle toolbar item', | 382 | Publisher.sendMessage('Toggle toolbar item', |
381 | - (self.state_code, False)) | 383 | + _id=self.state_code, value=False) |
382 | self.picker.PickFromListOff() | 384 | self.picker.PickFromListOff() |
383 | Publisher.sendMessage("Remove incomplete measurements") | 385 | Publisher.sendMessage("Remove incomplete measurements") |
384 | 386 | ||
@@ -399,9 +401,9 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -399,9 +401,9 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
399 | self.viewer.scroll_enabled = True | 401 | self.viewer.scroll_enabled = True |
400 | else: | 402 | else: |
401 | Publisher.sendMessage("Add measurement point", | 403 | Publisher.sendMessage("Add measurement point", |
402 | - ((x, y, z), self._type, | ||
403 | - ORIENTATIONS[self.orientation], | ||
404 | - slice_number, self.radius)) | 404 | + position=(x, y, z), type=self._type, |
405 | + location=ORIENTATIONS[self.orientation], | ||
406 | + slice_number=slice_number, radius=self.radius) | ||
405 | n = len(m.points)-1 | 407 | n = len(m.points)-1 |
406 | self.creating = n, m, mr | 408 | self.creating = n, m, mr |
407 | self.viewer.UpdateCanvas() | 409 | self.viewer.UpdateCanvas() |
@@ -416,13 +418,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -416,13 +418,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
416 | if self.picker.GetViewProp(): | 418 | if self.picker.GetViewProp(): |
417 | renderer = self.viewer.slice_data.renderer | 419 | renderer = self.viewer.slice_data.renderer |
418 | Publisher.sendMessage("Add measurement point", | 420 | Publisher.sendMessage("Add measurement point", |
419 | - ((x, y, z), self._type, | ||
420 | - ORIENTATIONS[self.orientation], | ||
421 | - slice_number, self.radius)) | 421 | + position=(x, y, z), type=self._type, |
422 | + location=ORIENTATIONS[self.orientation], | ||
423 | + slice_number=slice_number, | ||
424 | + radius=self.radius) | ||
422 | Publisher.sendMessage("Add measurement point", | 425 | Publisher.sendMessage("Add measurement point", |
423 | - ((x, y, z), self._type, | ||
424 | - ORIENTATIONS[self.orientation], | ||
425 | - slice_number, self.radius)) | 426 | + position=(x, y, z), type=self._type, |
427 | + location=ORIENTATIONS[self.orientation], | ||
428 | + slice_number=slice_number, | ||
429 | + radius=self.radius) | ||
426 | 430 | ||
427 | n, (m, mr) = 1, self.measures.measures[self._ori][slice_number][-1] | 431 | n, (m, mr) = 1, self.measures.measures[self._ori][slice_number][-1] |
428 | self.creating = n, m, mr | 432 | self.creating = n, m, mr |
@@ -434,7 +438,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -434,7 +438,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
434 | n, m, mr = self.selected | 438 | n, m, mr = self.selected |
435 | x, y, z = self._get_pos_clicked() | 439 | x, y, z = self._get_pos_clicked() |
436 | idx = self.measures._list_measures.index((m, mr)) | 440 | idx = self.measures._list_measures.index((m, mr)) |
437 | - Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) | 441 | + Publisher.sendMessage('Change measurement point position', index=idx, npoint=n, pos=(x, y, z)) |
438 | self.viewer.UpdateCanvas() | 442 | self.viewer.UpdateCanvas() |
439 | self.selected = None | 443 | self.selected = None |
440 | self.viewer.scroll_enabled = True | 444 | self.viewer.scroll_enabled = True |
@@ -444,13 +448,13 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | @@ -444,13 +448,13 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): | ||
444 | if self.selected: | 448 | if self.selected: |
445 | n, m, mr = self.selected | 449 | n, m, mr = self.selected |
446 | idx = self.measures._list_measures.index((m, mr)) | 450 | idx = self.measures._list_measures.index((m, mr)) |
447 | - Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) | 451 | + Publisher.sendMessage('Change measurement point position', index=idx, npoint=n, pos=(x, y, z)) |
448 | self.viewer.UpdateCanvas() | 452 | self.viewer.UpdateCanvas() |
449 | 453 | ||
450 | elif self.creating: | 454 | elif self.creating: |
451 | n, m, mr = self.creating | 455 | n, m, mr = self.creating |
452 | idx = self.measures._list_measures.index((m, mr)) | 456 | idx = self.measures._list_measures.index((m, mr)) |
453 | - Publisher.sendMessage('Change measurement point position', (idx, n, (x, y, z))) | 457 | + Publisher.sendMessage('Change measurement point position', index=idx, npoint=n, pos=(x, y, z)) |
454 | self.viewer.UpdateCanvas() | 458 | self.viewer.UpdateCanvas() |
455 | 459 | ||
456 | else: | 460 | else: |
@@ -539,12 +543,12 @@ class PanMoveInteractorStyle(DefaultInteractorStyle): | @@ -539,12 +543,12 @@ class PanMoveInteractorStyle(DefaultInteractorStyle): | ||
539 | 543 | ||
540 | def SetUp(self): | 544 | def SetUp(self): |
541 | Publisher.sendMessage('Toggle toolbar item', | 545 | Publisher.sendMessage('Toggle toolbar item', |
542 | - (self.state_code, True)) | 546 | + _id=self.state_code, value=True) |
543 | 547 | ||
544 | def CleanUp(self): | 548 | def CleanUp(self): |
545 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) | 549 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
546 | Publisher.sendMessage('Toggle toolbar item', | 550 | Publisher.sendMessage('Toggle toolbar item', |
547 | - (self.state_code, False)) | 551 | + _id=self.state_code, value=False) |
548 | 552 | ||
549 | def OnPanMove(self, obj, evt): | 553 | def OnPanMove(self, obj, evt): |
550 | if self.left_pressed: | 554 | if self.left_pressed: |
@@ -575,12 +579,12 @@ class SpinInteractorStyle(DefaultInteractorStyle): | @@ -575,12 +579,12 @@ class SpinInteractorStyle(DefaultInteractorStyle): | ||
575 | 579 | ||
576 | def SetUp(self): | 580 | def SetUp(self): |
577 | Publisher.sendMessage('Toggle toolbar item', | 581 | Publisher.sendMessage('Toggle toolbar item', |
578 | - (self.state_code, True)) | 582 | + _id=self.state_code, value=True) |
579 | 583 | ||
580 | def CleanUp(self): | 584 | def CleanUp(self): |
581 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) | 585 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
582 | Publisher.sendMessage('Toggle toolbar item', | 586 | Publisher.sendMessage('Toggle toolbar item', |
583 | - (self.state_code, False)) | 587 | + _id=self.state_code, value=False) |
584 | 588 | ||
585 | def OnSpinMove(self, obj, evt): | 589 | def OnSpinMove(self, obj, evt): |
586 | iren = obj.GetInteractor() | 590 | iren = obj.GetInteractor() |
@@ -620,12 +624,12 @@ class ZoomInteractorStyle(DefaultInteractorStyle): | @@ -620,12 +624,12 @@ class ZoomInteractorStyle(DefaultInteractorStyle): | ||
620 | 624 | ||
621 | def SetUp(self): | 625 | def SetUp(self): |
622 | Publisher.sendMessage('Toggle toolbar item', | 626 | Publisher.sendMessage('Toggle toolbar item', |
623 | - (self.state_code, True)) | 627 | + _id=self.state_code, value=True) |
624 | 628 | ||
625 | def CleanUp(self): | 629 | def CleanUp(self): |
626 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) | 630 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
627 | Publisher.sendMessage('Toggle toolbar item', | 631 | Publisher.sendMessage('Toggle toolbar item', |
628 | - (self.state_code, False)) | 632 | + _id=self.state_code, value=False) |
629 | 633 | ||
630 | def OnZoomMoveLeft(self, obj, evt): | 634 | def OnZoomMoveLeft(self, obj, evt): |
631 | if self.left_pressed: | 635 | if self.left_pressed: |
@@ -654,12 +658,12 @@ class ZoomSLInteractorStyle(vtk.vtkInteractorStyleRubberBandZoom): | @@ -654,12 +658,12 @@ class ZoomSLInteractorStyle(vtk.vtkInteractorStyleRubberBandZoom): | ||
654 | 658 | ||
655 | def SetUp(self): | 659 | def SetUp(self): |
656 | Publisher.sendMessage('Toggle toolbar item', | 660 | Publisher.sendMessage('Toggle toolbar item', |
657 | - (self.state_code, True)) | 661 | + _id=self.state_code, value=True) |
658 | 662 | ||
659 | def CleanUp(self): | 663 | def CleanUp(self): |
660 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) | 664 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
661 | Publisher.sendMessage('Toggle toolbar item', | 665 | Publisher.sendMessage('Toggle toolbar item', |
662 | - (self.state_code, False)) | 666 | + _id=self.state_code, value=False) |
663 | 667 | ||
664 | def OnUnZoom(self, evt): | 668 | def OnUnZoom(self, evt): |
665 | mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition() | 669 | mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition() |
@@ -687,11 +691,11 @@ class ChangeSliceInteractorStyle(DefaultInteractorStyle): | @@ -687,11 +691,11 @@ class ChangeSliceInteractorStyle(DefaultInteractorStyle): | ||
687 | 691 | ||
688 | def SetUp(self): | 692 | def SetUp(self): |
689 | Publisher.sendMessage('Toggle toolbar item', | 693 | Publisher.sendMessage('Toggle toolbar item', |
690 | - (self.state_code, True)) | 694 | + _id=self.state_code, value=True) |
691 | 695 | ||
692 | def CleanUp(self): | 696 | def CleanUp(self): |
693 | Publisher.sendMessage('Toggle toolbar item', | 697 | Publisher.sendMessage('Toggle toolbar item', |
694 | - (self.state_code, False)) | 698 | + _id=self.state_code, value=False) |
695 | 699 | ||
696 | def OnChangeSliceMove(self, evt, obj): | 700 | def OnChangeSliceMove(self, evt, obj): |
697 | if self.left_pressed: | 701 | if self.left_pressed: |
@@ -779,17 +783,16 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -779,17 +783,16 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
779 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 783 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
780 | self.viewer.interactor.Render() | 784 | self.viewer.interactor.Render() |
781 | 785 | ||
782 | - def set_bsize(self, pubsub_evt): | ||
783 | - size = pubsub_evt.data | 786 | + def set_bsize(self, size): |
784 | self.config.cursor_size = size | 787 | self.config.cursor_size = size |
785 | self.viewer.slice_data.cursor.SetSize(size) | 788 | self.viewer.slice_data.cursor.SetSize(size) |
786 | 789 | ||
787 | - def set_bformat(self, pubsub_evt): | ||
788 | - self.config.cursor_type = pubsub_evt.data | 790 | + def set_bformat(self, cursor_format): |
791 | + self.config.cursor_type = cursor_format | ||
789 | self._set_cursor() | 792 | self._set_cursor() |
790 | 793 | ||
791 | - def set_boperation(self, pubsub_evt): | ||
792 | - self.config.operation = pubsub_evt.data | 794 | + def set_boperation(self, operation): |
795 | + self.config.operation = operation | ||
793 | 796 | ||
794 | def _set_cursor(self): | 797 | def _set_cursor(self): |
795 | if self.config.cursor_type == const.BRUSH_SQUARE: | 798 | if self.config.cursor_type == const.BRUSH_SQUARE: |
@@ -936,7 +939,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -936,7 +939,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
936 | size += 1 | 939 | size += 1 |
937 | 940 | ||
938 | if size <= 100: | 941 | if size <= 100: |
939 | - Publisher.sendMessage('Set edition brush size', size) | 942 | + Publisher.sendMessage('Set edition brush size', size=size) |
940 | cursor.SetPosition(cursor.position) | 943 | cursor.SetPosition(cursor.position) |
941 | self.viewer.interactor.Render() | 944 | self.viewer.interactor.Render() |
942 | else: | 945 | else: |
@@ -954,7 +957,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | @@ -954,7 +957,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): | ||
954 | size -= 1 | 957 | size -= 1 |
955 | 958 | ||
956 | if size > 0: | 959 | if size > 0: |
957 | - Publisher.sendMessage('Set edition brush size', size) | 960 | + Publisher.sendMessage('Set edition brush size', size=size) |
958 | cursor.SetPosition(cursor.position) | 961 | cursor.SetPosition(cursor.position) |
959 | self.viewer.interactor.Render() | 962 | self.viewer.interactor.Render() |
960 | else: | 963 | else: |
@@ -1005,23 +1008,23 @@ class WatershedConfig(with_metaclass(utils.Singleton, object)): | @@ -1005,23 +1008,23 @@ class WatershedConfig(with_metaclass(utils.Singleton, object)): | ||
1005 | Publisher.subscribe(self.set_3dcon, "Set watershed 3d con") | 1008 | Publisher.subscribe(self.set_3dcon, "Set watershed 3d con") |
1006 | Publisher.subscribe(self.set_gaussian_size, "Set watershed gaussian size") | 1009 | Publisher.subscribe(self.set_gaussian_size, "Set watershed gaussian size") |
1007 | 1010 | ||
1008 | - def set_operation(self, pubsub_evt): | ||
1009 | - self.operation = WATERSHED_OPERATIONS[pubsub_evt.data] | 1011 | + def set_operation(self, operation): |
1012 | + self.operation = WATERSHED_OPERATIONS[operation] | ||
1010 | 1013 | ||
1011 | - def set_use_ww_wl(self, pubsub_evt): | ||
1012 | - self.use_ww_wl = pubsub_evt.data | 1014 | + def set_use_ww_wl(self, use_ww_wl): |
1015 | + self.use_ww_wl = use_ww_wl | ||
1013 | 1016 | ||
1014 | - def set_algorithm(self, pubsub_evt): | ||
1015 | - self.algorithm = pubsub_evt.data | 1017 | + def set_algorithm(self, algorithm): |
1018 | + self.algorithm = algorithm | ||
1016 | 1019 | ||
1017 | - def set_2dcon(self, pubsub_evt): | ||
1018 | - self.con_2d = pubsub_evt.data | 1020 | + def set_2dcon(self, con_2d): |
1021 | + self.con_2d = con_2d | ||
1019 | 1022 | ||
1020 | - def set_3dcon(self, pubsub_evt): | ||
1021 | - self.con_3d = pubsub_evt.data | 1023 | + def set_3dcon(self, con_3d): |
1024 | + self.con_3d = con_3d | ||
1022 | 1025 | ||
1023 | - def set_gaussian_size(self, pubsub_evt): | ||
1024 | - self.mg_size = pubsub_evt.data | 1026 | + def set_gaussian_size(self, size): |
1027 | + self.mg_size = size | ||
1025 | 1028 | ||
1026 | WALGORITHM = {"Watershed": watershed, | 1029 | WALGORITHM = {"Watershed": watershed, |
1027 | "Watershed IFT": watershed_ift} | 1030 | "Watershed IFT": watershed_ift} |
@@ -1124,13 +1127,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1124,13 +1127,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1124 | cursor.SetSize(self.config.cursor_size) | 1127 | cursor.SetSize(self.config.cursor_size) |
1125 | self.viewer.slice_data.SetCursor(cursor) | 1128 | self.viewer.slice_data.SetCursor(cursor) |
1126 | 1129 | ||
1127 | - def set_bsize(self, pubsub_evt): | ||
1128 | - size = pubsub_evt.data | 1130 | + def set_bsize(self, size): |
1129 | self.config.cursor_size = size | 1131 | self.config.cursor_size = size |
1130 | self.viewer.slice_data.cursor.SetSize(size) | 1132 | self.viewer.slice_data.cursor.SetSize(size) |
1131 | 1133 | ||
1132 | - def set_bformat(self, pubsub_evt): | ||
1133 | - self.config.cursor_type = pubsub_evt.data | 1134 | + def set_bformat(self, brush_format): |
1135 | + self.config.cursor_type = brush_format | ||
1134 | self._set_cursor() | 1136 | self._set_cursor() |
1135 | 1137 | ||
1136 | def OnEnterInteractor(self, obj, evt): | 1138 | def OnEnterInteractor(self, obj, evt): |
@@ -1157,7 +1159,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1157,7 +1159,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1157 | size -= 1 | 1159 | size -= 1 |
1158 | 1160 | ||
1159 | if size > 0: | 1161 | if size > 0: |
1160 | - Publisher.sendMessage('Set watershed brush size', size) | 1162 | + Publisher.sendMessage('Set watershed brush size', size=size) |
1161 | cursor.SetPosition(cursor.position) | 1163 | cursor.SetPosition(cursor.position) |
1162 | self.viewer.interactor.Render() | 1164 | self.viewer.interactor.Render() |
1163 | else: | 1165 | else: |
@@ -1175,7 +1177,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1175,7 +1177,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1175 | size += 1 | 1177 | size += 1 |
1176 | 1178 | ||
1177 | if size <= 100: | 1179 | if size <= 100: |
1178 | - Publisher.sendMessage('Set watershed brush size', size) | 1180 | + Publisher.sendMessage('Set watershed brush size', size=size) |
1179 | cursor.SetPosition(cursor.position) | 1181 | cursor.SetPosition(cursor.position) |
1180 | self.viewer.interactor.Render() | 1182 | self.viewer.interactor.Render() |
1181 | else: | 1183 | else: |
@@ -1423,7 +1425,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | @@ -1423,7 +1425,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): | ||
1423 | if roi_m.size: | 1425 | if roi_m.size: |
1424 | roi_m[index] = operation | 1426 | roi_m[index] = operation |
1425 | 1427 | ||
1426 | - def expand_watershed(self, pubsub_evt): | 1428 | + def expand_watershed(self): |
1427 | markers = self.matrix | 1429 | markers = self.matrix |
1428 | image = self.viewer.slice_.matrix | 1430 | image = self.viewer.slice_.matrix |
1429 | self.viewer.slice_.do_threshold_to_all_slices() | 1431 | self.viewer.slice_.do_threshold_to_all_slices() |
@@ -1631,7 +1633,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | @@ -1631,7 +1633,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | ||
1631 | self.viewer.slice_.rotations = [0, 0, 0] | 1633 | self.viewer.slice_.rotations = [0, 0, 0] |
1632 | self.viewer.slice_.q_orientation = np.array((1, 0, 0, 0)) | 1634 | self.viewer.slice_.q_orientation = np.array((1, 0, 0, 0)) |
1633 | 1635 | ||
1634 | - Publisher.sendMessage('Update reorient angles', (0, 0, 0)) | 1636 | + Publisher.sendMessage('Update reorient angles', angles=(0, 0, 0)) |
1635 | 1637 | ||
1636 | self._discard_buffers() | 1638 | self._discard_buffers() |
1637 | self.viewer.slice_.current_mask.clear_history() | 1639 | self.viewer.slice_.current_mask.clear_history() |
@@ -1687,7 +1689,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | @@ -1687,7 +1689,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | ||
1687 | self.viewer.slice_.q_orientation = transformations.quaternion_multiply(self.viewer.slice_.q_orientation, transformations.quaternion_about_axis(angle, axis)) | 1689 | self.viewer.slice_.q_orientation = transformations.quaternion_multiply(self.viewer.slice_.q_orientation, transformations.quaternion_about_axis(angle, axis)) |
1688 | 1690 | ||
1689 | az, ay, ax = transformations.euler_from_quaternion(self.viewer.slice_.q_orientation) | 1691 | az, ay, ax = transformations.euler_from_quaternion(self.viewer.slice_.q_orientation) |
1690 | - Publisher.sendMessage('Update reorient angles', (ax, ay, az)) | 1692 | + Publisher.sendMessage('Update reorient angles', angles=(ax, ay, az)) |
1691 | 1693 | ||
1692 | self._discard_buffers() | 1694 | self._discard_buffers() |
1693 | if self.viewer.slice_.current_mask: | 1695 | if self.viewer.slice_.current_mask: |
@@ -1713,8 +1715,8 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | @@ -1713,8 +1715,8 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): | ||
1713 | # print (z, y, x), tcoord | 1715 | # print (z, y, x), tcoord |
1714 | return tcoord | 1716 | return tcoord |
1715 | 1717 | ||
1716 | - def _set_reorientation_angles(self, pubsub_evt): | ||
1717 | - ax, ay, az = pubsub_evt.data | 1718 | + def _set_reorientation_angles(self, angles): |
1719 | + ax, ay, az = angles | ||
1718 | q = transformations.quaternion_from_euler(az, ay, ax) | 1720 | q = transformations.quaternion_from_euler(az, ay, ax) |
1719 | self.viewer.slice_.q_orientation = q | 1721 | self.viewer.slice_.q_orientation = q |
1720 | 1722 | ||
@@ -1968,9 +1970,8 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | @@ -1968,9 +1970,8 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | ||
1968 | self.viewer.canvas.draw_list.remove(self.draw_retangle) | 1970 | self.viewer.canvas.draw_list.remove(self.draw_retangle) |
1969 | Publisher.sendMessage('Redraw canvas') | 1971 | Publisher.sendMessage('Redraw canvas') |
1970 | 1972 | ||
1971 | - def CropMask(self, pubsub_evt): | 1973 | + def CropMask(self): |
1972 | if self.viewer.orientation == "AXIAL": | 1974 | if self.viewer.orientation == "AXIAL": |
1973 | - | ||
1974 | xi, xf, yi, yf, zi, zf = self.draw_retangle.box.GetLimits() | 1975 | xi, xf, yi, yf, zi, zf = self.draw_retangle.box.GetLimits() |
1975 | 1976 | ||
1976 | xi += 1 | 1977 | xi += 1 |
@@ -1978,7 +1979,7 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | @@ -1978,7 +1979,7 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | ||
1978 | 1979 | ||
1979 | yi += 1 | 1980 | yi += 1 |
1980 | yf += 1 | 1981 | yf += 1 |
1981 | - | 1982 | + |
1982 | zi += 1 | 1983 | zi += 1 |
1983 | zf += 1 | 1984 | zf += 1 |
1984 | 1985 | ||
@@ -1986,13 +1987,13 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | @@ -1986,13 +1987,13 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | ||
1986 | cp_mask = self.viewer.slice_.current_mask.matrix.copy() | 1987 | cp_mask = self.viewer.slice_.current_mask.matrix.copy() |
1987 | 1988 | ||
1988 | tmp_mask = self.viewer.slice_.current_mask.matrix[zi-1:zf+1, yi-1:yf+1, xi-1:xf+1].copy() | 1989 | tmp_mask = self.viewer.slice_.current_mask.matrix[zi-1:zf+1, yi-1:yf+1, xi-1:xf+1].copy() |
1989 | - | 1990 | + |
1990 | self.viewer.slice_.current_mask.matrix[:] = 1 | 1991 | self.viewer.slice_.current_mask.matrix[:] = 1 |
1991 | 1992 | ||
1992 | self.viewer.slice_.current_mask.matrix[zi-1:zf+1, yi-1:yf+1, xi-1:xf+1] = tmp_mask | 1993 | self.viewer.slice_.current_mask.matrix[zi-1:zf+1, yi-1:yf+1, xi-1:xf+1] = tmp_mask |
1993 | 1994 | ||
1994 | self.viewer.slice_.current_mask.save_history(0, 'VOLUME', self.viewer.slice_.current_mask.matrix.copy(), cp_mask) | 1995 | self.viewer.slice_.current_mask.save_history(0, 'VOLUME', self.viewer.slice_.current_mask.matrix.copy(), cp_mask) |
1995 | - | 1996 | + |
1996 | self.viewer.slice_.buffer_slices['AXIAL'].discard_mask() | 1997 | self.viewer.slice_.buffer_slices['AXIAL'].discard_mask() |
1997 | self.viewer.slice_.buffer_slices['CORONAL'].discard_mask() | 1998 | self.viewer.slice_.buffer_slices['CORONAL'].discard_mask() |
1998 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_mask() | 1999 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_mask() |
@@ -2002,9 +2003,9 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | @@ -2002,9 +2003,9 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): | ||
2002 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_vtk_mask() | 2003 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_vtk_mask() |
2003 | 2004 | ||
2004 | self.viewer.slice_.current_mask.was_edited = True | 2005 | self.viewer.slice_.current_mask.was_edited = True |
2005 | - Publisher.sendMessage('Reload actual slice') | 2006 | + Publisher.sendMessage('Reload actual slice') |
2007 | + | ||
2006 | 2008 | ||
2007 | - | ||
2008 | class SelectPartConfig(with_metaclass(utils.Singleton, object)): | 2009 | class SelectPartConfig(with_metaclass(utils.Singleton, object)): |
2009 | def __init__(self): | 2010 | def __init__(self): |
2010 | self.mask = None | 2011 | self.mask = None |
@@ -2066,7 +2067,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | @@ -2066,7 +2067,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): | ||
2066 | self.config.mask.name = self.config.mask_name | 2067 | self.config.mask.name = self.config.mask_name |
2067 | self.viewer.slice_._add_mask_into_proj(self.config.mask) | 2068 | self.viewer.slice_._add_mask_into_proj(self.config.mask) |
2068 | self.viewer.slice_.SelectCurrentMask(self.config.mask.index) | 2069 | self.viewer.slice_.SelectCurrentMask(self.config.mask.index) |
2069 | - Publisher.sendMessage('Change mask selected', self.config.mask.index) | 2070 | + Publisher.sendMessage('Change mask selected', index=self.config.mask.index) |
2070 | 2071 | ||
2071 | del self.viewer.slice_.aux_matrices['SELECT'] | 2072 | del self.viewer.slice_.aux_matrices['SELECT'] |
2072 | self.viewer.slice_.to_show_aux = '' | 2073 | self.viewer.slice_.to_show_aux = '' |
invesalius/data/surface.py
@@ -171,11 +171,10 @@ class SurfaceManager(): | @@ -171,11 +171,10 @@ class SurfaceManager(): | ||
171 | 171 | ||
172 | Publisher.subscribe(self.OnImportSurfaceFile, 'Import surface file') | 172 | Publisher.subscribe(self.OnImportSurfaceFile, 'Import surface file') |
173 | 173 | ||
174 | - def OnDuplicate(self, pubsub_evt): | ||
175 | - selected_items = pubsub_evt.data | 174 | + def OnDuplicate(self, surface_indexes): |
176 | proj = prj.Project() | 175 | proj = prj.Project() |
177 | surface_dict = proj.surface_dict | 176 | surface_dict = proj.surface_dict |
178 | - for index in selected_items: | 177 | + for index in surface_indexes: |
179 | original_surface = surface_dict[index] | 178 | original_surface = surface_dict[index] |
180 | # compute copy name | 179 | # compute copy name |
181 | name = original_surface.name | 180 | name = original_surface.name |
@@ -190,14 +189,13 @@ class SurfaceManager(): | @@ -190,14 +189,13 @@ class SurfaceManager(): | ||
190 | volume = original_surface.volume, | 189 | volume = original_surface.volume, |
191 | area = original_surface.area) | 190 | area = original_surface.area) |
192 | 191 | ||
193 | - def OnRemove(self, pubsub_evt): | ||
194 | - selected_items = pubsub_evt.data | 192 | + def OnRemove(self, surface_indexes): |
195 | proj = prj.Project() | 193 | proj = prj.Project() |
196 | 194 | ||
197 | old_dict = self.actors_dict | 195 | old_dict = self.actors_dict |
198 | new_dict = {} | 196 | new_dict = {} |
199 | - if selected_items: | ||
200 | - for index in selected_items: | 197 | + if surface_indexes: |
198 | + for index in surface_indexes: | ||
201 | proj.RemoveSurface(index) | 199 | proj.RemoveSurface(index) |
202 | if index in old_dict: | 200 | if index in old_dict: |
203 | actor = old_dict[index] | 201 | actor = old_dict[index] |
@@ -207,21 +205,21 @@ class SurfaceManager(): | @@ -207,21 +205,21 @@ class SurfaceManager(): | ||
207 | if i > index: | 205 | if i > index: |
208 | new_dict[i-1] = old_dict[i] | 206 | new_dict[i-1] = old_dict[i] |
209 | old_dict = new_dict | 207 | old_dict = new_dict |
210 | - Publisher.sendMessage('Remove surface actor from viewer', actor) | 208 | + Publisher.sendMessage('Remove surface actor from viewer', actor=actor) |
211 | self.actors_dict = new_dict | 209 | self.actors_dict = new_dict |
212 | 210 | ||
213 | - if self.last_surface_index in selected_items: | 211 | + if self.last_surface_index in surface_indexes: |
214 | if self.actors_dict: | 212 | if self.actors_dict: |
215 | self.last_surface_index = 0 | 213 | self.last_surface_index = 0 |
216 | else: | 214 | else: |
217 | self.last_surface_index = None | 215 | self.last_surface_index = None |
218 | 216 | ||
219 | - def OnSeedSurface(self, pubsub_evt): | 217 | + def OnSeedSurface(self, seeds): |
220 | """ | 218 | """ |
221 | Create a new surface, based on the last selected surface, | 219 | Create a new surface, based on the last selected surface, |
222 | using as reference seeds user add to surface of reference. | 220 | using as reference seeds user add to surface of reference. |
223 | """ | 221 | """ |
224 | - points_id_list = pubsub_evt.data | 222 | + points_id_list = seeds |
225 | index = self.last_surface_index | 223 | index = self.last_surface_index |
226 | proj = prj.Project() | 224 | proj = prj.Project() |
227 | surface = proj.surface_dict[index] | 225 | surface = proj.surface_dict[index] |
@@ -229,10 +227,10 @@ class SurfaceManager(): | @@ -229,10 +227,10 @@ class SurfaceManager(): | ||
229 | new_polydata = pu.JoinSeedsParts(surface.polydata, | 227 | new_polydata = pu.JoinSeedsParts(surface.polydata, |
230 | points_id_list) | 228 | points_id_list) |
231 | index = self.CreateSurfaceFromPolydata(new_polydata) | 229 | index = self.CreateSurfaceFromPolydata(new_polydata) |
232 | - Publisher.sendMessage('Show single surface', (index, True)) | 230 | + Publisher.sendMessage('Show single surface', index=index, visibility=True) |
233 | #self.ShowActor(index, True) | 231 | #self.ShowActor(index, True) |
234 | 232 | ||
235 | - def OnSplitSurface(self, pubsub_evt): | 233 | + def OnSplitSurface(self): |
236 | """ | 234 | """ |
237 | Create n new surfaces, based on the last selected surface, | 235 | Create n new surfaces, based on the last selected surface, |
238 | according to their connectivity. | 236 | according to their connectivity. |
@@ -248,9 +246,9 @@ class SurfaceManager(): | @@ -248,9 +246,9 @@ class SurfaceManager(): | ||
248 | index_list.append(index) | 246 | index_list.append(index) |
249 | #self.ShowActor(index, True) | 247 | #self.ShowActor(index, True) |
250 | 248 | ||
251 | - Publisher.sendMessage('Show multiple surfaces', (index_list, True)) | 249 | + Publisher.sendMessage('Show multiple surfaces', index_list=index_list, visibility=True) |
252 | 250 | ||
253 | - def OnLargestSurface(self, pubsub_evt): | 251 | + def OnLargestSurface(self): |
254 | """ | 252 | """ |
255 | Create a new surface, based on largest part of the last | 253 | Create a new surface, based on largest part of the last |
256 | selected surface. | 254 | selected surface. |
@@ -261,13 +259,12 @@ class SurfaceManager(): | @@ -261,13 +259,12 @@ class SurfaceManager(): | ||
261 | 259 | ||
262 | new_polydata = pu.SelectLargestPart(surface.polydata) | 260 | new_polydata = pu.SelectLargestPart(surface.polydata) |
263 | new_index = self.CreateSurfaceFromPolydata(new_polydata) | 261 | new_index = self.CreateSurfaceFromPolydata(new_polydata) |
264 | - Publisher.sendMessage('Show single surface', (new_index, True)) | 262 | + Publisher.sendMessage('Show single surface', index=new_index, visibility=True) |
265 | 263 | ||
266 | - def OnImportSurfaceFile(self, pubsub_evt): | 264 | + def OnImportSurfaceFile(self, filename): |
267 | """ | 265 | """ |
268 | Creates a new surface from a surface file (STL, PLY, OBJ or VTP) | 266 | Creates a new surface from a surface file (STL, PLY, OBJ or VTP) |
269 | """ | 267 | """ |
270 | - filename = pubsub_evt.data | ||
271 | self.CreateSurfaceFromFile(filename) | 268 | self.CreateSurfaceFromFile(filename) |
272 | 269 | ||
273 | def CreateSurfaceFromFile(self, filename): | 270 | def CreateSurfaceFromFile(self, filename): |
@@ -368,42 +365,34 @@ class SurfaceManager(): | @@ -368,42 +365,34 @@ class SurfaceManager(): | ||
368 | 365 | ||
369 | self.last_surface_index = surface.index | 366 | self.last_surface_index = surface.index |
370 | 367 | ||
371 | - Publisher.sendMessage('Load surface actor into viewer', actor) | 368 | + Publisher.sendMessage('Load surface actor into viewer', actor=actor) |
372 | 369 | ||
373 | - Publisher.sendMessage('Update surface info in GUI', | ||
374 | - (surface.index, surface.name, | ||
375 | - surface.colour, surface.volume, | ||
376 | - surface.area, surface.transparency)) | 370 | + Publisher.sendMessage('Update surface info in GUI', surface=surface) |
377 | return surface.index | 371 | return surface.index |
378 | 372 | ||
379 | - def OnCloseProject(self, pubsub_evt): | 373 | + def OnCloseProject(self): |
380 | self.CloseProject() | 374 | self.CloseProject() |
381 | 375 | ||
382 | def CloseProject(self): | 376 | def CloseProject(self): |
383 | for index in self.actors_dict: | 377 | for index in self.actors_dict: |
384 | - Publisher.sendMessage('Remove surface actor from viewer', self.actors_dict[index]) | 378 | + Publisher.sendMessage('Remove surface actor from viewer', actor=self.actors_dict[index]) |
385 | del self.actors_dict | 379 | del self.actors_dict |
386 | self.actors_dict = {} | 380 | self.actors_dict = {} |
387 | 381 | ||
388 | # restarting the surface index | 382 | # restarting the surface index |
389 | Surface.general_index = -1 | 383 | Surface.general_index = -1 |
390 | 384 | ||
391 | - def OnSelectSurface(self, pubsub_evt): | ||
392 | - index = pubsub_evt.data | ||
393 | - #self.last_surface_index = index | 385 | + def OnSelectSurface(self, surface_index): |
386 | + #self.last_surface_index = surface_index | ||
394 | # self.actors_dict. | 387 | # self.actors_dict. |
395 | proj = prj.Project() | 388 | proj = prj.Project() |
396 | - surface = proj.surface_dict[index] | ||
397 | - Publisher.sendMessage('Update surface info in GUI', | ||
398 | - (index, surface.name, | ||
399 | - surface.colour, surface.volume, | ||
400 | - surface.area, surface.transparency)) | ||
401 | - self.last_surface_index = index | 389 | + surface = proj.surface_dict[surface_index] |
390 | + Publisher.sendMessage('Update surface info in GUI', surface=surface) | ||
391 | + self.last_surface_index = surface_index | ||
402 | # if surface.is_shown: | 392 | # if surface.is_shown: |
403 | - self.ShowActor(index, True) | 393 | + self.ShowActor(surface_index, True) |
404 | 394 | ||
405 | - def OnLoadSurfaceDict(self, pubsub_evt): | ||
406 | - surface_dict = pubsub_evt.data | 395 | + def OnLoadSurfaceDict(self, surface_dict): |
407 | for key in surface_dict: | 396 | for key in surface_dict: |
408 | surface = surface_dict[key] | 397 | surface = surface_dict[key] |
409 | 398 | ||
@@ -436,27 +425,23 @@ class SurfaceManager(): | @@ -436,27 +425,23 @@ class SurfaceManager(): | ||
436 | self.actors_dict[surface.index] = actor | 425 | self.actors_dict[surface.index] = actor |
437 | 426 | ||
438 | # Send actor by pubsub to viewer's render | 427 | # Send actor by pubsub to viewer's render |
439 | - Publisher.sendMessage('Load surface actor into viewer', (actor)) | 428 | + Publisher.sendMessage('Load surface actor into viewer', actor=actor) |
440 | 429 | ||
441 | Publisher.sendMessage('Update status text in GUI', | 430 | Publisher.sendMessage('Update status text in GUI', |
442 | - _("Ready")) | 431 | + label=_("Ready")) |
443 | 432 | ||
444 | # The following lines have to be here, otherwise all volumes disappear | 433 | # The following lines have to be here, otherwise all volumes disappear |
445 | - Publisher.sendMessage('Update surface info in GUI', | ||
446 | - (surface.index, surface.name, | ||
447 | - surface.colour, surface.volume, | ||
448 | - surface.area, surface.transparency)) | 434 | + Publisher.sendMessage('Update surface info in GUI', surface=surface) |
449 | if not surface.is_shown: | 435 | if not surface.is_shown: |
450 | self.ShowActor(key, False) | 436 | self.ShowActor(key, False) |
451 | 437 | ||
452 | #### | 438 | #### |
453 | #(mask_index, surface_name, quality, fill_holes, keep_largest) | 439 | #(mask_index, surface_name, quality, fill_holes, keep_largest) |
454 | 440 | ||
455 | - def AddNewActor(self, pubsub_evt): | 441 | + def AddNewActor(self, slice_, mask, surface_parameters): |
456 | """ | 442 | """ |
457 | Create surface actor, save into project and send it to viewer. | 443 | Create surface actor, save into project and send it to viewer. |
458 | """ | 444 | """ |
459 | - slice_, mask, surface_parameters = pubsub_evt.data | ||
460 | matrix = slice_.matrix | 445 | matrix = slice_.matrix |
461 | filename_img = slice_.matrix_filename | 446 | filename_img = slice_.matrix_filename |
462 | spacing = slice_.spacing | 447 | spacing = slice_.spacing |
@@ -825,31 +810,27 @@ class SurfaceManager(): | @@ -825,31 +810,27 @@ class SurfaceManager(): | ||
825 | del measured_polydata | 810 | del measured_polydata |
826 | del to_measure | 811 | del to_measure |
827 | 812 | ||
828 | - Publisher.sendMessage('Load surface actor into viewer', actor) | 813 | + Publisher.sendMessage('Load surface actor into viewer', actor=actor) |
829 | 814 | ||
830 | # Send actor by pubsub to viewer's render | 815 | # Send actor by pubsub to viewer's render |
831 | if overwrite and self.actors_dict.keys(): | 816 | if overwrite and self.actors_dict.keys(): |
832 | old_actor = self.actors_dict[self.last_surface_index] | 817 | old_actor = self.actors_dict[self.last_surface_index] |
833 | - Publisher.sendMessage('Remove surface actor from viewer', old_actor) | 818 | + Publisher.sendMessage('Remove surface actor from viewer', actor=old_actor) |
834 | 819 | ||
835 | # Save actor for future management tasks | 820 | # Save actor for future management tasks |
836 | self.actors_dict[surface.index] = actor | 821 | self.actors_dict[surface.index] = actor |
837 | 822 | ||
838 | - Publisher.sendMessage('Update surface info in GUI', | ||
839 | - (surface.index, surface.name, | ||
840 | - surface.colour, surface.volume, | ||
841 | - surface.area, | ||
842 | - surface.transparency)) | 823 | + Publisher.sendMessage('Update surface info in GUI', surface=surface) |
843 | 824 | ||
844 | #When you finalize the progress. The bar is cleaned. | 825 | #When you finalize the progress. The bar is cleaned. |
845 | UpdateProgress = vu.ShowProgress(1) | 826 | UpdateProgress = vu.ShowProgress(1) |
846 | UpdateProgress(0, _("Ready")) | 827 | UpdateProgress(0, _("Ready")) |
847 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | 828 | + Publisher.sendMessage('Update status text in GUI', label=_("Ready")) |
848 | 829 | ||
849 | Publisher.sendMessage('End busy cursor') | 830 | Publisher.sendMessage('End busy cursor') |
850 | del actor | 831 | del actor |
851 | 832 | ||
852 | - def UpdateSurfaceInterpolation(self, pub_evt): | 833 | + def UpdateSurfaceInterpolation(self): |
853 | interpolation = int(ses.Session().surface_interpolation) | 834 | interpolation = int(ses.Session().surface_interpolation) |
854 | key_actors = self.actors_dict.keys() | 835 | key_actors = self.actors_dict.keys() |
855 | 836 | ||
@@ -861,20 +842,18 @@ class SurfaceManager(): | @@ -861,20 +842,18 @@ class SurfaceManager(): | ||
861 | """ | 842 | """ |
862 | Remove actor, according to given actor index. | 843 | Remove actor, according to given actor index. |
863 | """ | 844 | """ |
864 | - Publisher.sendMessage('Remove surface actor from viewer', (index)) | 845 | + Publisher.sendMessage('Remove surface actor from viewer', actor=index) |
865 | self.actors_dict.pop(index) | 846 | self.actors_dict.pop(index) |
866 | # Remove surface from project's surface_dict | 847 | # Remove surface from project's surface_dict |
867 | proj = prj.Project() | 848 | proj = prj.Project() |
868 | proj.surface_dict.pop(index) | 849 | proj.surface_dict.pop(index) |
869 | 850 | ||
870 | - def OnChangeSurfaceName(self, pubsub_evt): | ||
871 | - index, name = pubsub_evt.data | 851 | + def OnChangeSurfaceName(self, index, name): |
872 | proj = prj.Project() | 852 | proj = prj.Project() |
873 | proj.surface_dict[index].name = name | 853 | proj.surface_dict[index].name = name |
874 | 854 | ||
875 | - def OnShowSurface(self, pubsub_evt): | ||
876 | - index, value = pubsub_evt.data | ||
877 | - self.ShowActor(index, value) | 855 | + def OnShowSurface(self, index, visibility): |
856 | + self.ShowActor(index, visibility) | ||
878 | 857 | ||
879 | def ShowActor(self, index, value): | 858 | def ShowActor(self, index, value): |
880 | """ | 859 | """ |
@@ -886,30 +865,27 @@ class SurfaceManager(): | @@ -886,30 +865,27 @@ class SurfaceManager(): | ||
886 | proj.surface_dict[index].is_shown = value | 865 | proj.surface_dict[index].is_shown = value |
887 | Publisher.sendMessage('Render volume viewer') | 866 | Publisher.sendMessage('Render volume viewer') |
888 | 867 | ||
889 | - def SetActorTransparency(self, pubsub_evt): | 868 | + def SetActorTransparency(self, surface_index, transparency): |
890 | """ | 869 | """ |
891 | Set actor transparency (oposite to opacity) according to given actor | 870 | Set actor transparency (oposite to opacity) according to given actor |
892 | index and value. | 871 | index and value. |
893 | """ | 872 | """ |
894 | - index, value = pubsub_evt.data | ||
895 | - self.actors_dict[index].GetProperty().SetOpacity(1-value) | 873 | + self.actors_dict[surface_index].GetProperty().SetOpacity(1-transparency) |
896 | # Update value in project's surface_dict | 874 | # Update value in project's surface_dict |
897 | proj = prj.Project() | 875 | proj = prj.Project() |
898 | - proj.surface_dict[index].transparency = value | 876 | + proj.surface_dict[surface_index].transparency = transparency |
899 | Publisher.sendMessage('Render volume viewer') | 877 | Publisher.sendMessage('Render volume viewer') |
900 | 878 | ||
901 | - def SetActorColour(self, pubsub_evt): | 879 | + def SetActorColour(self, surface_index, colour): |
902 | """ | 880 | """ |
903 | """ | 881 | """ |
904 | - index, colour = pubsub_evt.data | ||
905 | - self.actors_dict[index].GetProperty().SetColor(colour[:3]) | 882 | + self.actors_dict[surface_index].GetProperty().SetColor(colour[:3]) |
906 | # Update value in project's surface_dict | 883 | # Update value in project's surface_dict |
907 | proj = prj.Project() | 884 | proj = prj.Project() |
908 | - proj.surface_dict[index].colour = colour | 885 | + proj.surface_dict[surface_index].colour = colour |
909 | Publisher.sendMessage('Render volume viewer') | 886 | Publisher.sendMessage('Render volume viewer') |
910 | 887 | ||
911 | - def OnExportSurface(self, pubsub_evt): | ||
912 | - filename, filetype = pubsub_evt.data | 888 | + def OnExportSurface(self, filename, filetype): |
913 | ftype_prefix = { | 889 | ftype_prefix = { |
914 | const.FILETYPE_STL: '.stl', | 890 | const.FILETYPE_STL: '.stl', |
915 | const.FILETYPE_VTP: '.vtp', | 891 | const.FILETYPE_VTP: '.vtp', |
invesalius/data/viewer_slice.py
@@ -132,29 +132,27 @@ class ContourMIPConfig(wx.Panel): | @@ -132,29 +132,27 @@ class ContourMIPConfig(wx.Panel): | ||
132 | 132 | ||
133 | Publisher.subscribe(self._set_projection_type, 'Set projection type') | 133 | Publisher.subscribe(self._set_projection_type, 'Set projection type') |
134 | 134 | ||
135 | - def OnSetMIPSize(self, evt): | 135 | + def OnSetMIPSize(self, number_slices): |
136 | val = self.mip_size_spin.GetValue() | 136 | val = self.mip_size_spin.GetValue() |
137 | - Publisher.sendMessage('Set MIP size %s' % self.orientation, val) | 137 | + Publisher.sendMessage('Set MIP size %s' % self.orientation, number_slices=val) |
138 | 138 | ||
139 | def OnSetMIPBorder(self, evt): | 139 | def OnSetMIPBorder(self, evt): |
140 | val = self.border_spin.GetValue() | 140 | val = self.border_spin.GetValue() |
141 | - Publisher.sendMessage('Set MIP border %s' % self.orientation, val) | 141 | + Publisher.sendMessage('Set MIP border %s' % self.orientation, border_size=val) |
142 | 142 | ||
143 | def OnCheckInverted(self, evt): | 143 | def OnCheckInverted(self, evt): |
144 | val = self.inverted.GetValue() | 144 | val = self.inverted.GetValue() |
145 | - Publisher.sendMessage('Set MIP Invert %s' % self.orientation, val) | 145 | + Publisher.sendMessage('Set MIP Invert %s' % self.orientation, invert=val) |
146 | 146 | ||
147 | - def _set_projection_type(self, pubsub_evt): | ||
148 | - tprojection = pubsub_evt.data | ||
149 | - | ||
150 | - if tprojection in (const.PROJECTION_MIDA, | ||
151 | - const.PROJECTION_CONTOUR_MIDA): | 147 | + def _set_projection_type(self, projection_id): |
148 | + if projection_id in (const.PROJECTION_MIDA, | ||
149 | + const.PROJECTION_CONTOUR_MIDA): | ||
152 | self.inverted.Enable() | 150 | self.inverted.Enable() |
153 | else: | 151 | else: |
154 | self.inverted.Disable() | 152 | self.inverted.Disable() |
155 | 153 | ||
156 | - if tprojection in (const.PROJECTION_CONTOUR_MIP, | ||
157 | - const.PROJECTION_CONTOUR_MIDA): | 154 | + if projection_id in (const.PROJECTION_CONTOUR_MIP, |
155 | + const.PROJECTION_CONTOUR_MIDA): | ||
158 | self.border_spin.Enable() | 156 | self.border_spin.Enable() |
159 | self.txt_mip_border.Enable() | 157 | self.txt_mip_border.Enable() |
160 | else: | 158 | else: |
@@ -664,8 +662,7 @@ class Viewer(wx.Panel): | @@ -664,8 +662,7 @@ class Viewer(wx.Panel): | ||
664 | self.UpdateCanvas() | 662 | self.UpdateCanvas() |
665 | self.on_text = True | 663 | self.on_text = True |
666 | 664 | ||
667 | - def __set_layout(self, pubsub_evt): | ||
668 | - layout = pubsub_evt.data | 665 | + def __set_layout(self, layout): |
669 | self.SetLayout(layout) | 666 | self.SetLayout(layout) |
670 | 667 | ||
671 | def __config_interactor(self): | 668 | def __config_interactor(self): |
@@ -693,8 +690,7 @@ class Viewer(wx.Panel): | @@ -693,8 +690,7 @@ class Viewer(wx.Panel): | ||
693 | 690 | ||
694 | self.state = state | 691 | self.state = state |
695 | 692 | ||
696 | - def UpdateWindowLevelValue(self, pubsub_evt): | ||
697 | - window, level = pubsub_evt.data | 693 | + def UpdateWindowLevelValue(self, window, level): |
698 | self.acum_achange_window, self.acum_achange_level = (window, level) | 694 | self.acum_achange_window, self.acum_achange_level = (window, level) |
699 | self.SetWLText(window, level) | 695 | self.SetWLText(window, level) |
700 | 696 | ||
@@ -704,18 +700,18 @@ class Viewer(wx.Panel): | @@ -704,18 +700,18 @@ class Viewer(wx.Panel): | ||
704 | Publisher.sendMessage('Update all slice') | 700 | Publisher.sendMessage('Update all slice') |
705 | Publisher.sendMessage('Update clut imagedata widget') | 701 | Publisher.sendMessage('Update clut imagedata widget') |
706 | 702 | ||
707 | - def UpdateWindowLevelText(self, pubsub_evt): | ||
708 | - window, level = pubsub_evt.data | ||
709 | - self.acum_achange_window, self.acum_achange_level = (window, level) | 703 | + def UpdateWindowLevelText(self, window, level): |
704 | + self.acum_achange_window, self.acum_achange_level = window, level | ||
710 | self.SetWLText(window, level) | 705 | self.SetWLText(window, level) |
711 | self.interactor.Render() | 706 | self.interactor.Render() |
712 | 707 | ||
713 | def OnClutChange(self, evt): | 708 | def OnClutChange(self, evt): |
714 | Publisher.sendMessage('Change colour table from background image from widget', | 709 | Publisher.sendMessage('Change colour table from background image from widget', |
715 | - evt.GetNodes()) | 710 | + nodes=evt.GetNodes()) |
716 | slc = sl.Slice() | 711 | slc = sl.Slice() |
717 | Publisher.sendMessage('Update window level value', | 712 | Publisher.sendMessage('Update window level value', |
718 | - (slc.window_width, slc.window_level)) | 713 | + window=slc.window_width, |
714 | + level=slc.window_level) | ||
719 | 715 | ||
720 | def SetWLText(self, window_width, window_level): | 716 | def SetWLText(self, window_width, window_level): |
721 | value = STR_WL%(window_level, window_width) | 717 | value = STR_WL%(window_level, window_width) |
@@ -930,46 +926,45 @@ class Viewer(wx.Panel): | @@ -930,46 +926,45 @@ class Viewer(wx.Panel): | ||
930 | ren.GetActiveCamera().Zoom(1.0) | 926 | ren.GetActiveCamera().Zoom(1.0) |
931 | self.interactor.Render() | 927 | self.interactor.Render() |
932 | 928 | ||
933 | - def ChangeBrushColour(self, pubsub_evt): | ||
934 | - vtk_colour = pubsub_evt.data[3] | 929 | + def ChangeBrushColour(self, colour): |
930 | + vtk_colour = colour | ||
935 | self._brush_cursor_colour = vtk_colour | 931 | self._brush_cursor_colour = vtk_colour |
936 | if (self.cursor): | 932 | if (self.cursor): |
937 | for slice_data in self.slice_data_list: | 933 | for slice_data in self.slice_data_list: |
938 | slice_data.cursor.SetColour(vtk_colour) | 934 | slice_data.cursor.SetColour(vtk_colour) |
939 | 935 | ||
940 | - def SetBrushColour(self, pubsub_evt): | ||
941 | - colour_wx = pubsub_evt.data | ||
942 | - colour_vtk = [colour/float(255) for colour in colour_wx] | 936 | + def SetBrushColour(self, colour): |
937 | + colour_vtk = [colour/float(255) for colour in colour] | ||
943 | self._brush_cursor_colour = colour_vtk | 938 | self._brush_cursor_colour = colour_vtk |
944 | if self.slice_data.cursor: | 939 | if self.slice_data.cursor: |
945 | self.slice_data.cursor.SetColour(colour_vtk) | 940 | self.slice_data.cursor.SetColour(colour_vtk) |
946 | 941 | ||
947 | - def UpdateSlicesNavigation(self, pubsub_evt): | 942 | + def UpdateSlicesNavigation(self, arg, position): |
948 | # Get point from base change | 943 | # Get point from base change |
949 | - ux, uy, uz = pubsub_evt.data[1][:3] | 944 | + ux, uy, uz = position[:3] |
950 | px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz) | 945 | px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz) |
951 | coord = self.calcultate_scroll_position(px, py) | 946 | coord = self.calcultate_scroll_position(px, py) |
952 | 947 | ||
953 | self.cross.SetFocalPoint((ux, uy, uz)) | 948 | self.cross.SetFocalPoint((ux, uy, uz)) |
954 | self.ScrollSlice(coord) | 949 | self.ScrollSlice(coord) |
955 | - Publisher.sendMessage('Set ball reference position', (ux, uy, uz)) | 950 | + Publisher.sendMessage('Set ball reference position', position=(ux, uy, uz)) |
956 | 951 | ||
957 | def ScrollSlice(self, coord): | 952 | def ScrollSlice(self, coord): |
958 | if self.orientation == "AXIAL": | 953 | if self.orientation == "AXIAL": |
959 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), | 954 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
960 | - coord[0]) | 955 | + index=coord[0]) |
961 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), | 956 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
962 | - coord[1]) | 957 | + index=coord[1]) |
963 | elif self.orientation == "SAGITAL": | 958 | elif self.orientation == "SAGITAL": |
964 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), | 959 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
965 | - coord[2]) | 960 | + index=coord[2]) |
966 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), | 961 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
967 | - coord[1]) | 962 | + index=coord[1]) |
968 | elif self.orientation == "CORONAL": | 963 | elif self.orientation == "CORONAL": |
969 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), | 964 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
970 | - coord[2]) | 965 | + index=coord[2]) |
971 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), | 966 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
972 | - coord[0]) | 967 | + index=coord[0]) |
973 | 968 | ||
974 | def get_slice_data(self, render): | 969 | def get_slice_data(self, render): |
975 | #for slice_data in self.slice_data_list: | 970 | #for slice_data in self.slice_data_list: |
@@ -1251,39 +1246,37 @@ class Viewer(wx.Panel): | @@ -1251,39 +1246,37 @@ class Viewer(wx.Panel): | ||
1251 | Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation") | 1246 | Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation") |
1252 | 1247 | ||
1253 | 1248 | ||
1254 | - def RefreshViewer(self, pubsub_evt): | 1249 | + def RefreshViewer(self): |
1255 | self.Refresh() | 1250 | self.Refresh() |
1256 | 1251 | ||
1257 | - def SetDefaultCursor(self, pusub_evt): | 1252 | + def SetDefaultCursor(self): |
1258 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) | 1253 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
1259 | 1254 | ||
1260 | - def SetSizeNSCursor(self, pusub_evt): | 1255 | + def SetSizeNSCursor(self): |
1261 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) | 1256 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) |
1262 | 1257 | ||
1263 | - def SetSizeWECursor(self, pusub_evt): | 1258 | + def SetSizeWECursor(self): |
1264 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) | 1259 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) |
1265 | 1260 | ||
1266 | - def SetSizeNWSECursor(self, pubsub_evt): | 1261 | + def SetSizeNWSECursor(self): |
1267 | if sys.platform.startswith('linux'): | 1262 | if sys.platform.startswith('linux'): |
1268 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE)) | 1263 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE)) |
1269 | else: | 1264 | else: |
1270 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | 1265 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) |
1271 | 1266 | ||
1272 | - def OnExportPicture(self, pubsub_evt): | ||
1273 | - id, filename, filetype = pubsub_evt.data | ||
1274 | - | 1267 | + def OnExportPicture(self, orientation, filename, filetype): |
1275 | dict = {"AXIAL": const.AXIAL, | 1268 | dict = {"AXIAL": const.AXIAL, |
1276 | "CORONAL": const.CORONAL, | 1269 | "CORONAL": const.CORONAL, |
1277 | "SAGITAL": const.SAGITAL} | 1270 | "SAGITAL": const.SAGITAL} |
1278 | 1271 | ||
1279 | - if id == dict[self.orientation]: | 1272 | + if orientation == dict[self.orientation]: |
1280 | Publisher.sendMessage('Begin busy cursor') | 1273 | Publisher.sendMessage('Begin busy cursor') |
1281 | if _has_win32api: | 1274 | if _has_win32api: |
1282 | utils.touch(filename) | 1275 | utils.touch(filename) |
1283 | win_filename = win32api.GetShortPathName(filename) | 1276 | win_filename = win32api.GetShortPathName(filename) |
1284 | - self._export_picture(id, win_filename, filetype) | 1277 | + self._export_picture(orientation, win_filename, filetype) |
1285 | else: | 1278 | else: |
1286 | - self._export_picture(id, filename, filetype) | 1279 | + self._export_picture(orientation, filename, filetype) |
1287 | Publisher.sendMessage('End busy cursor') | 1280 | Publisher.sendMessage('End busy cursor') |
1288 | 1281 | ||
1289 | def _export_picture(self, id, filename, filetype): | 1282 | def _export_picture(self, id, filename, filetype): |
@@ -1340,13 +1333,13 @@ class Viewer(wx.Panel): | @@ -1340,13 +1333,13 @@ class Viewer(wx.Panel): | ||
1340 | 1333 | ||
1341 | Publisher.sendMessage('End busy cursor') | 1334 | Publisher.sendMessage('End busy cursor') |
1342 | 1335 | ||
1343 | - def OnShowText(self, pubsub_evt): | 1336 | + def OnShowText(self): |
1344 | self.ShowTextActors() | 1337 | self.ShowTextActors() |
1345 | 1338 | ||
1346 | - def OnHideText(self, pubsub_evt): | 1339 | + def OnHideText(self): |
1347 | self.HideTextActors() | 1340 | self.HideTextActors() |
1348 | 1341 | ||
1349 | - def OnCloseProject(self, pubsub_evt): | 1342 | + def OnCloseProject(self): |
1350 | self.CloseProject() | 1343 | self.CloseProject() |
1351 | 1344 | ||
1352 | def CloseProject(self): | 1345 | def CloseProject(self): |
@@ -1371,11 +1364,10 @@ class Viewer(wx.Panel): | @@ -1371,11 +1364,10 @@ class Viewer(wx.Panel): | ||
1371 | self.wl_text = None | 1364 | self.wl_text = None |
1372 | self.pick = vtk.vtkWorldPointPicker() | 1365 | self.pick = vtk.vtkWorldPointPicker() |
1373 | 1366 | ||
1374 | - def OnSetInteractorStyle(self, pubsub_evt): | ||
1375 | - state = pubsub_evt.data | ||
1376 | - self.SetInteractorStyle(state) | 1367 | + def OnSetInteractorStyle(self, style): |
1368 | + self.SetInteractorStyle(style) | ||
1377 | 1369 | ||
1378 | - if (state not in [const.SLICE_STATE_EDITOR, const.SLICE_STATE_WATERSHED]): | 1370 | + if (style not in [const.SLICE_STATE_EDITOR, const.SLICE_STATE_WATERSHED]): |
1379 | Publisher.sendMessage('Set interactor default cursor') | 1371 | Publisher.sendMessage('Set interactor default cursor') |
1380 | 1372 | ||
1381 | def __bind_events_wx(self): | 1373 | def __bind_events_wx(self): |
@@ -1386,8 +1378,7 @@ class Viewer(wx.Panel): | @@ -1386,8 +1378,7 @@ class Viewer(wx.Panel): | ||
1386 | self.interactor.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) | 1378 | self.interactor.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) |
1387 | self.interactor.Bind(wx.EVT_SIZE, self.OnSize) | 1379 | self.interactor.Bind(wx.EVT_SIZE, self.OnSize) |
1388 | 1380 | ||
1389 | - def LoadImagedata(self, pubsub_evt): | ||
1390 | - mask_dict = pubsub_evt.data | 1381 | + def LoadImagedata(self, mask_dict): |
1391 | self.SetInput(mask_dict) | 1382 | self.SetInput(mask_dict) |
1392 | 1383 | ||
1393 | def LoadRenderers(self, imagedata): | 1384 | def LoadRenderers(self, imagedata): |
@@ -1509,9 +1500,8 @@ class Viewer(wx.Panel): | @@ -1509,9 +1500,8 @@ class Viewer(wx.Panel): | ||
1509 | 1500 | ||
1510 | renderer.AddActor(cross_actor) | 1501 | renderer.AddActor(cross_actor) |
1511 | 1502 | ||
1512 | - def __update_cross_position(self, pubsub_evt): | ||
1513 | - pos = pubsub_evt.data | ||
1514 | - self.cross.SetFocalPoint(pos) | 1503 | + def __update_cross_position(self, position): |
1504 | + self.cross.SetFocalPoint(position) | ||
1515 | 1505 | ||
1516 | def _set_cross_visibility(self, visibility): | 1506 | def _set_cross_visibility(self, visibility): |
1517 | self.cross_actor.SetVisibility(visibility) | 1507 | self.cross_actor.SetVisibility(visibility) |
@@ -1569,8 +1559,8 @@ class Viewer(wx.Panel): | @@ -1569,8 +1559,8 @@ class Viewer(wx.Panel): | ||
1569 | 1559 | ||
1570 | return slice_data | 1560 | return slice_data |
1571 | 1561 | ||
1572 | - def UpdateInterpolatedSlice(self, pub_sub): | ||
1573 | - if self.slice_actor != None: | 1562 | + def UpdateInterpolatedSlice(self): |
1563 | + if self.slice_actor != None: | ||
1574 | if ses.Session().slice_interpolation: | 1564 | if ses.Session().slice_interpolation: |
1575 | self.slice_actor.InterpolateOff() | 1565 | self.slice_actor.InterpolateOff() |
1576 | else: | 1566 | else: |
@@ -1578,15 +1568,13 @@ class Viewer(wx.Panel): | @@ -1578,15 +1568,13 @@ class Viewer(wx.Panel): | ||
1578 | self.interactor.Render() | 1568 | self.interactor.Render() |
1579 | 1569 | ||
1580 | 1570 | ||
1581 | - def SetInterpolatedSlices(self, pub_sub): | ||
1582 | - self.interpolation_slice_status = status = pub_sub.data | ||
1583 | - | 1571 | + def SetInterpolatedSlices(self, flag): |
1572 | + self.interpolation_slice_status = flag | ||
1584 | if self.slice_actor != None: | 1573 | if self.slice_actor != None: |
1585 | - if status == True: | 1574 | + if self.interpolation_slice_status == True: |
1586 | self.slice_actor.InterpolateOn() | 1575 | self.slice_actor.InterpolateOn() |
1587 | else: | 1576 | else: |
1588 | self.slice_actor.InterpolateOff() | 1577 | self.slice_actor.InterpolateOff() |
1589 | - | ||
1590 | self.interactor.Render() | 1578 | self.interactor.Render() |
1591 | 1579 | ||
1592 | def __update_camera(self): | 1580 | def __update_camera(self): |
@@ -1605,7 +1593,7 @@ class Viewer(wx.Panel): | @@ -1605,7 +1593,7 @@ class Viewer(wx.Panel): | ||
1605 | self.slice_data.actor.SetDisplayExtent(image.GetExtent()) | 1593 | self.slice_data.actor.SetDisplayExtent(image.GetExtent()) |
1606 | self.slice_data.renderer.ResetCameraClippingRange() | 1594 | self.slice_data.renderer.ResetCameraClippingRange() |
1607 | 1595 | ||
1608 | - def UpdateRender(self, evt): | 1596 | + def UpdateRender(self): |
1609 | self.interactor.Render() | 1597 | self.interactor.Render() |
1610 | 1598 | ||
1611 | def UpdateCanvas(self, evt=None): | 1599 | def UpdateCanvas(self, evt=None): |
@@ -1655,8 +1643,8 @@ class Viewer(wx.Panel): | @@ -1655,8 +1643,8 @@ class Viewer(wx.Panel): | ||
1655 | def UpdateSlice3D(self, pos): | 1643 | def UpdateSlice3D(self, pos): |
1656 | original_orientation = project.Project().original_orientation | 1644 | original_orientation = project.Project().original_orientation |
1657 | pos = self.scroll.GetThumbPosition() | 1645 | pos = self.scroll.GetThumbPosition() |
1658 | - Publisher.sendMessage('Change slice from slice plane',\ | ||
1659 | - (self.orientation, pos)) | 1646 | + Publisher.sendMessage('Change slice from slice plane', |
1647 | + orientation=self.orientation, index=pos) | ||
1660 | 1648 | ||
1661 | def OnScrollBar(self, evt=None, update3D=True): | 1649 | def OnScrollBar(self, evt=None, update3D=True): |
1662 | pos = self.scroll.GetThumbPosition() | 1650 | pos = self.scroll.GetThumbPosition() |
@@ -1667,7 +1655,7 @@ class Viewer(wx.Panel): | @@ -1667,7 +1655,7 @@ class Viewer(wx.Panel): | ||
1667 | # Update other slice's cross according to the new focal point from | 1655 | # Update other slice's cross according to the new focal point from |
1668 | # the actual orientation. | 1656 | # the actual orientation. |
1669 | focal_point = self.cross.GetFocalPoint() | 1657 | focal_point = self.cross.GetFocalPoint() |
1670 | - Publisher.sendMessage('Update cross position', focal_point) | 1658 | + Publisher.sendMessage('Update cross position', position=focal_point) |
1671 | Publisher.sendMessage('Update slice viewer') | 1659 | Publisher.sendMessage('Update slice viewer') |
1672 | else: | 1660 | else: |
1673 | self.interactor.Render() | 1661 | self.interactor.Render() |
@@ -1722,7 +1710,7 @@ class Viewer(wx.Panel): | @@ -1722,7 +1710,7 @@ class Viewer(wx.Panel): | ||
1722 | 1710 | ||
1723 | elif evt.GetKeyCode() in projections: | 1711 | elif evt.GetKeyCode() in projections: |
1724 | self.slice_.SetTypeProjection(projections[evt.GetKeyCode()]) | 1712 | self.slice_.SetTypeProjection(projections[evt.GetKeyCode()]) |
1725 | - Publisher.sendMessage('Set projection type', projections[evt.GetKeyCode()]) | 1713 | + Publisher.sendMessage('Set projection type', projection_id=projections[evt.GetKeyCode()]) |
1726 | Publisher.sendMessage('Reload actual slice') | 1714 | Publisher.sendMessage('Reload actual slice') |
1727 | skip = False | 1715 | skip = False |
1728 | 1716 | ||
@@ -1766,28 +1754,24 @@ class Viewer(wx.Panel): | @@ -1766,28 +1754,24 @@ class Viewer(wx.Panel): | ||
1766 | self.slice_data.SetSize((w, h)) | 1754 | self.slice_data.SetSize((w, h)) |
1767 | evt.Skip() | 1755 | evt.Skip() |
1768 | 1756 | ||
1769 | - def OnSetMIPSize(self, pubsub_evt): | ||
1770 | - val = pubsub_evt.data | ||
1771 | - self.number_slices = val | 1757 | + def OnSetMIPSize(self, number_slices): |
1758 | + self.number_slices = number_slices | ||
1772 | self.ReloadActualSlice() | 1759 | self.ReloadActualSlice() |
1773 | 1760 | ||
1774 | - def OnSetMIPBorder(self, pubsub_evt): | ||
1775 | - val = pubsub_evt.data | ||
1776 | - self.slice_.n_border = val | 1761 | + def OnSetMIPBorder(self, border_size): |
1762 | + self.slice_.n_border = border_size | ||
1777 | buffer_ = self.slice_.buffer_slices[self.orientation] | 1763 | buffer_ = self.slice_.buffer_slices[self.orientation] |
1778 | buffer_.discard_buffer() | 1764 | buffer_.discard_buffer() |
1779 | self.ReloadActualSlice() | 1765 | self.ReloadActualSlice() |
1780 | 1766 | ||
1781 | - def OnSetMIPInvert(self, pubsub_evt): | ||
1782 | - val = pubsub_evt.data | ||
1783 | - self._mip_inverted = val | 1767 | + def OnSetMIPInvert(self, invert): |
1768 | + self._mip_inverted = invert | ||
1784 | buffer_ = self.slice_.buffer_slices[self.orientation] | 1769 | buffer_ = self.slice_.buffer_slices[self.orientation] |
1785 | buffer_.discard_buffer() | 1770 | buffer_.discard_buffer() |
1786 | self.ReloadActualSlice() | 1771 | self.ReloadActualSlice() |
1787 | 1772 | ||
1788 | - def OnShowMIPInterface(self, pubsub_evt): | ||
1789 | - value = pubsub_evt.data | ||
1790 | - if value: | 1773 | + def OnShowMIPInterface(self, flag): |
1774 | + if flag: | ||
1791 | if not self.mip_ctrls.Shown: | 1775 | if not self.mip_ctrls.Shown: |
1792 | self.mip_ctrls.Show() | 1776 | self.mip_ctrls.Show() |
1793 | self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) | 1777 | self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) |
@@ -1797,9 +1781,8 @@ class Viewer(wx.Panel): | @@ -1797,9 +1781,8 @@ class Viewer(wx.Panel): | ||
1797 | self.GetSizer().Detach(self.mip_ctrls) | 1781 | self.GetSizer().Detach(self.mip_ctrls) |
1798 | self.Layout() | 1782 | self.Layout() |
1799 | 1783 | ||
1800 | - def OnSetOverwriteMask(self, pubsub_evt): | ||
1801 | - value = pubsub_evt.data | ||
1802 | - self.overwrite_mask = value | 1784 | + def OnSetOverwriteMask(self, flag): |
1785 | + self.overwrite_mask = flag | ||
1803 | 1786 | ||
1804 | def set_slice_number(self, index): | 1787 | def set_slice_number(self, index): |
1805 | inverted = self.mip_ctrls.inverted.GetValue() | 1788 | inverted = self.mip_ctrls.inverted.GetValue() |
@@ -1831,28 +1814,27 @@ class Viewer(wx.Panel): | @@ -1831,28 +1814,27 @@ class Viewer(wx.Panel): | ||
1831 | self.__update_display_extent(image) | 1814 | self.__update_display_extent(image) |
1832 | self.cross.SetModelBounds(self.slice_data.actor.GetBounds()) | 1815 | self.cross.SetModelBounds(self.slice_data.actor.GetBounds()) |
1833 | 1816 | ||
1834 | - def ChangeSliceNumber(self, pubsub_evt): | ||
1835 | - index = pubsub_evt.data | 1817 | + def ChangeSliceNumber(self, index): |
1836 | #self.set_slice_number(index) | 1818 | #self.set_slice_number(index) |
1837 | self.scroll.SetThumbPosition(index) | 1819 | self.scroll.SetThumbPosition(index) |
1838 | pos = self.scroll.GetThumbPosition() | 1820 | pos = self.scroll.GetThumbPosition() |
1839 | self.set_slice_number(pos) | 1821 | self.set_slice_number(pos) |
1840 | self.interactor.Render() | 1822 | self.interactor.Render() |
1841 | 1823 | ||
1842 | - def ReloadActualSlice(self, pubsub_evt=None): | 1824 | + def ReloadActualSlice(self): |
1843 | pos = self.scroll.GetThumbPosition() | 1825 | pos = self.scroll.GetThumbPosition() |
1844 | self.set_slice_number(pos) | 1826 | self.set_slice_number(pos) |
1845 | self.interactor.Render() | 1827 | self.interactor.Render() |
1846 | 1828 | ||
1847 | - def OnUpdateScroll(self, pubsub_evt): | 1829 | + def OnUpdateScroll(self): |
1848 | max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation) | 1830 | max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation) |
1849 | self.scroll.SetScrollbar(wx.SB_VERTICAL, 1, max_slice_number, | 1831 | self.scroll.SetScrollbar(wx.SB_VERTICAL, 1, max_slice_number, |
1850 | max_slice_number) | 1832 | max_slice_number) |
1851 | 1833 | ||
1852 | - def OnSwapVolumeAxes(self, pubsub_evt): | 1834 | + def OnSwapVolumeAxes(self, axes): |
1853 | # Adjusting cursor spacing to match the spacing from the actual slice | 1835 | # Adjusting cursor spacing to match the spacing from the actual slice |
1854 | # orientation | 1836 | # orientation |
1855 | - axis0, axis1 = pubsub_evt.data | 1837 | + axis0, axis1 = axes |
1856 | cursor = self.slice_data.cursor | 1838 | cursor = self.slice_data.cursor |
1857 | spacing = cursor.spacing | 1839 | spacing = cursor.spacing |
1858 | if (axis0, axis1) == (2, 1): | 1840 | if (axis0, axis1) == (2, 1): |
@@ -1864,34 +1846,32 @@ class Viewer(wx.Panel): | @@ -1864,34 +1846,32 @@ class Viewer(wx.Panel): | ||
1864 | 1846 | ||
1865 | self.slice_data.renderer.ResetCamera() | 1847 | self.slice_data.renderer.ResetCamera() |
1866 | 1848 | ||
1867 | - def AddActors(self, pubsub_evt): | 1849 | + def AddActors(self, actors, slice_number): |
1868 | "Inserting actors" | 1850 | "Inserting actors" |
1869 | - actors, n = pubsub_evt.data | ||
1870 | pos = self.scroll.GetThumbPosition() | 1851 | pos = self.scroll.GetThumbPosition() |
1871 | #try: | 1852 | #try: |
1872 | - #renderer = self.renderers_by_slice_number[n] | 1853 | + #renderer = self.renderers_by_slice_number[slice_number] |
1873 | #for actor in actors: | 1854 | #for actor in actors: |
1874 | #renderer.AddActor(actor) | 1855 | #renderer.AddActor(actor) |
1875 | #except KeyError: | 1856 | #except KeyError: |
1876 | #pass | 1857 | #pass |
1877 | - if pos == n: | 1858 | + if pos == slice_number: |
1878 | for actor in actors: | 1859 | for actor in actors: |
1879 | self.slice_data.renderer.AddActor(actor) | 1860 | self.slice_data.renderer.AddActor(actor) |
1880 | 1861 | ||
1881 | - self.actors_by_slice_number[n].extend(actors) | 1862 | + self.actors_by_slice_number[slice_number].extend(actors) |
1882 | 1863 | ||
1883 | - def RemoveActors(self, pubsub_evt): | 1864 | + def RemoveActors(self, actors, slice_number): |
1884 | "Remove a list of actors" | 1865 | "Remove a list of actors" |
1885 | - actors, n = pubsub_evt.data | ||
1886 | try: | 1866 | try: |
1887 | - renderer = self.renderers_by_slice_number[n] | 1867 | + renderer = self.renderers_by_slice_number[slice_number] |
1888 | except KeyError: | 1868 | except KeyError: |
1889 | for actor in actors: | 1869 | for actor in actors: |
1890 | - self.actors_by_slice_number[n].remove(actor) | 1870 | + self.actors_by_slice_number[slice_number].remove(actor) |
1891 | self.slice_data.renderer.RemoveActor(actor) | 1871 | self.slice_data.renderer.RemoveActor(actor) |
1892 | else: | 1872 | else: |
1893 | for actor in actors: | 1873 | for actor in actors: |
1894 | # Remove the actor from the renderer | 1874 | # Remove the actor from the renderer |
1895 | renderer.RemoveActor(actor) | 1875 | renderer.RemoveActor(actor) |
1896 | # and remove the actor from the actor's list | 1876 | # and remove the actor from the actor's list |
1897 | - self.actors_by_slice_number[n].remove(actor) | 1877 | + self.actors_by_slice_number[slice_number].remove(actor) |
invesalius/data/viewer_volume.py
@@ -264,8 +264,7 @@ class Viewer(wx.Panel): | @@ -264,8 +264,7 @@ class Viewer(wx.Panel): | ||
264 | Publisher.subscribe(self.OnUpdateAngleThreshold, 'Update angle threshold') | 264 | Publisher.subscribe(self.OnUpdateAngleThreshold, 'Update angle threshold') |
265 | Publisher.subscribe(self.OnUpdateDistThreshold, 'Update dist threshold') | 265 | Publisher.subscribe(self.OnUpdateDistThreshold, 'Update dist threshold') |
266 | 266 | ||
267 | - def SetStereoMode(self, pubsub_evt): | ||
268 | - mode = pubsub_evt.data | 267 | + def SetStereoMode(self, mode): |
269 | ren_win = self.interactor.GetRenderWindow() | 268 | ren_win = self.interactor.GetRenderWindow() |
270 | 269 | ||
271 | if mode == const.STEREO_OFF: | 270 | if mode == const.STEREO_OFF: |
@@ -293,23 +292,19 @@ class Viewer(wx.Panel): | @@ -293,23 +292,19 @@ class Viewer(wx.Panel): | ||
293 | 292 | ||
294 | self.interactor.Render() | 293 | self.interactor.Render() |
295 | 294 | ||
296 | - def _check_ball_reference(self, pubsub_evt): | ||
297 | - st = pubsub_evt.data | ||
298 | - if st == const.SLICE_STATE_CROSS: | 295 | + def _check_ball_reference(self, style): |
296 | + if style == const.SLICE_STATE_CROSS: | ||
299 | self._mode_cross = True | 297 | self._mode_cross = True |
300 | self._check_and_set_ball_visibility() | 298 | self._check_and_set_ball_visibility() |
301 | self.interactor.Render() | 299 | self.interactor.Render() |
302 | 300 | ||
303 | - def _uncheck_ball_reference(self, pubsub_evt): | ||
304 | - st = pubsub_evt.data | ||
305 | - if st == const.SLICE_STATE_CROSS: | 301 | + def _uncheck_ball_reference(self, style): |
302 | + if style == const.SLICE_STATE_CROSS: | ||
306 | self._mode_cross = False | 303 | self._mode_cross = False |
307 | self.RemoveBallReference() | 304 | self.RemoveBallReference() |
308 | self.interactor.Render() | 305 | self.interactor.Render() |
309 | 306 | ||
310 | - def OnSensors(self, pubsub_evt): | ||
311 | - probe_id = pubsub_evt.data[0] | ||
312 | - ref_id = pubsub_evt.data[1] | 307 | + def OnSensors(self, probe_id, ref_id): |
313 | if not self.sen1: | 308 | if not self.sen1: |
314 | self.CreateSensorID() | 309 | self.CreateSensorID() |
315 | 310 | ||
@@ -345,39 +340,36 @@ class Viewer(wx.Panel): | @@ -345,39 +340,36 @@ class Viewer(wx.Panel): | ||
345 | 340 | ||
346 | self.interactor.Render() | 341 | self.interactor.Render() |
347 | 342 | ||
348 | - def OnRemoveSensorsID(self, pubsub_evt): | 343 | + def OnRemoveSensorsID(self): |
349 | if self.sen1: | 344 | if self.sen1: |
350 | self.ren.RemoveActor(self.sen1.actor) | 345 | self.ren.RemoveActor(self.sen1.actor) |
351 | self.ren.RemoveActor(self.sen2.actor) | 346 | self.ren.RemoveActor(self.sen2.actor) |
352 | self.sen1 = self.sen2 = False | 347 | self.sen1 = self.sen2 = False |
353 | self.interactor.Render() | 348 | self.interactor.Render() |
354 | 349 | ||
355 | - def OnShowSurface(self, pubsub_evt): | ||
356 | - index, value = pubsub_evt.data | ||
357 | - if value: | 350 | + def OnShowSurface(self, index, visibility): |
351 | + if visibility: | ||
358 | self._to_show_ball += 1 | 352 | self._to_show_ball += 1 |
359 | else: | 353 | else: |
360 | self._to_show_ball -= 1 | 354 | self._to_show_ball -= 1 |
361 | self._check_and_set_ball_visibility() | 355 | self._check_and_set_ball_visibility() |
362 | 356 | ||
363 | - def OnStartSeed(self, pubsub_evt): | ||
364 | - index = pubsub_evt.data | 357 | + def OnStartSeed(self): |
365 | self.seed_points = [] | 358 | self.seed_points = [] |
366 | 359 | ||
367 | - def OnEndSeed(self, pubsub_evt): | 360 | + def OnEndSeed(self): |
368 | Publisher.sendMessage("Create surface from seeds", | 361 | Publisher.sendMessage("Create surface from seeds", |
369 | - self.seed_points) | 362 | + seeds=self.seed_points) |
370 | 363 | ||
371 | - def OnExportPicture(self, pubsub_evt): | ||
372 | - id, filename, filetype = pubsub_evt.data | ||
373 | - if id == const.VOLUME: | 364 | + def OnExportPicture(self, orientation, filename, filetype): |
365 | + if orientation == const.VOLUME: | ||
374 | Publisher.sendMessage('Begin busy cursor') | 366 | Publisher.sendMessage('Begin busy cursor') |
375 | if _has_win32api: | 367 | if _has_win32api: |
376 | utils.touch(filename) | 368 | utils.touch(filename) |
377 | win_filename = win32api.GetShortPathName(filename) | 369 | win_filename = win32api.GetShortPathName(filename) |
378 | - self._export_picture(id, win_filename, filetype) | 370 | + self._export_picture(orientation, win_filename, filetype) |
379 | else: | 371 | else: |
380 | - self._export_picture(id, filename, filetype) | 372 | + self._export_picture(orientation, filename, filetype) |
381 | Publisher.sendMessage('End busy cursor') | 373 | Publisher.sendMessage('End busy cursor') |
382 | 374 | ||
383 | def _export_picture(self, id, filename, filetype): | 375 | def _export_picture(self, id, filename, filetype): |
@@ -419,7 +411,7 @@ class Viewer(wx.Panel): | @@ -419,7 +411,7 @@ class Viewer(wx.Panel): | ||
419 | wx.MessageBox(_("InVesalius was not able to export this picture"), _("Export picture error")) | 411 | wx.MessageBox(_("InVesalius was not able to export this picture"), _("Export picture error")) |
420 | 412 | ||
421 | 413 | ||
422 | - def OnCloseProject(self, pubsub_evt): | 414 | + def OnCloseProject(self): |
423 | if self.raycasting_volume: | 415 | if self.raycasting_volume: |
424 | self.raycasting_volume = False | 416 | self.raycasting_volume = False |
425 | 417 | ||
@@ -436,22 +428,21 @@ class Viewer(wx.Panel): | @@ -436,22 +428,21 @@ class Viewer(wx.Panel): | ||
436 | self.SetInteractorStyle(const.STATE_DEFAULT) | 428 | self.SetInteractorStyle(const.STATE_DEFAULT) |
437 | self._last_state = const.STATE_DEFAULT | 429 | self._last_state = const.STATE_DEFAULT |
438 | 430 | ||
439 | - def OnHideText(self, pubsub_evt): | 431 | + def OnHideText(self): |
440 | self.text.Hide() | 432 | self.text.Hide() |
441 | self.interactor.Render() | 433 | self.interactor.Render() |
442 | 434 | ||
443 | - def OnShowText(self, pubsub_evt): | 435 | + def OnShowText(self): |
444 | if self.on_wl: | 436 | if self.on_wl: |
445 | self.text.Show() | 437 | self.text.Show() |
446 | self.interactor.Render() | 438 | self.interactor.Render() |
447 | 439 | ||
448 | - def AddActors(self, pubsub_evt): | 440 | + def AddActors(self, actors): |
449 | "Inserting actors" | 441 | "Inserting actors" |
450 | - actors = pubsub_evt.data[0] | ||
451 | for actor in actors: | 442 | for actor in actors: |
452 | self.ren.AddActor(actor) | 443 | self.ren.AddActor(actor) |
453 | 444 | ||
454 | - def RemoveVolume(self, pub_evt): | 445 | + def RemoveVolume(self): |
455 | volumes = self.ren.GetVolumes() | 446 | volumes = self.ren.GetVolumes() |
456 | if (volumes.GetNumberOfItems()): | 447 | if (volumes.GetNumberOfItems()): |
457 | self.ren.RemoveVolume(volumes.GetLastProp()) | 448 | self.ren.RemoveVolume(volumes.GetLastProp()) |
@@ -459,9 +450,8 @@ class Viewer(wx.Panel): | @@ -459,9 +450,8 @@ class Viewer(wx.Panel): | ||
459 | self._to_show_ball -= 1 | 450 | self._to_show_ball -= 1 |
460 | self._check_and_set_ball_visibility() | 451 | self._check_and_set_ball_visibility() |
461 | 452 | ||
462 | - def RemoveActors(self, pubsub_evt): | 453 | + def RemoveActors(self, actors): |
463 | "Remove a list of actors" | 454 | "Remove a list of actors" |
464 | - actors = pubsub_evt.data[0] | ||
465 | for actor in actors: | 455 | for actor in actors: |
466 | self.ren.RemoveActor(actor) | 456 | self.ren.RemoveActor(actor) |
467 | 457 | ||
@@ -501,25 +491,22 @@ class Viewer(wx.Panel): | @@ -501,25 +491,22 @@ class Viewer(wx.Panel): | ||
501 | actor = self.points_reference.pop(point) | 491 | actor = self.points_reference.pop(point) |
502 | self.ren.RemoveActor(actor) | 492 | self.ren.RemoveActor(actor) |
503 | 493 | ||
504 | - def AddMarker(self, pubsub_evt): | 494 | + def AddMarker(self, ball_id, size, colour, coord): |
505 | """ | 495 | """ |
506 | Markers created by navigation tools and rendered in volume viewer. | 496 | Markers created by navigation tools and rendered in volume viewer. |
507 | """ | 497 | """ |
508 | - self.ball_id = pubsub_evt.data[0] | ||
509 | - ballsize = pubsub_evt.data[1] | ||
510 | - ballcolour = pubsub_evt.data[2][:3] | ||
511 | - coord = pubsub_evt.data[3] | 498 | + self.ball_id = ball_id |
512 | x, y, z = bases.flip_x(coord) | 499 | x, y, z = bases.flip_x(coord) |
513 | 500 | ||
514 | ball_ref = vtk.vtkSphereSource() | 501 | ball_ref = vtk.vtkSphereSource() |
515 | - ball_ref.SetRadius(ballsize) | 502 | + ball_ref.SetRadius(size) |
516 | ball_ref.SetCenter(x, y, z) | 503 | ball_ref.SetCenter(x, y, z) |
517 | 504 | ||
518 | mapper = vtk.vtkPolyDataMapper() | 505 | mapper = vtk.vtkPolyDataMapper() |
519 | mapper.SetInputConnection(ball_ref.GetOutputPort()) | 506 | mapper.SetInputConnection(ball_ref.GetOutputPort()) |
520 | 507 | ||
521 | prop = vtk.vtkProperty() | 508 | prop = vtk.vtkProperty() |
522 | - prop.SetColor(ballcolour) | 509 | + prop.SetColor(colour) |
523 | 510 | ||
524 | #adding a new actor for the present ball | 511 | #adding a new actor for the present ball |
525 | self.staticballs.append(vtk.vtkActor()) | 512 | self.staticballs.append(vtk.vtkActor()) |
@@ -532,38 +519,37 @@ class Viewer(wx.Panel): | @@ -532,38 +519,37 @@ class Viewer(wx.Panel): | ||
532 | #self.UpdateRender() | 519 | #self.UpdateRender() |
533 | self.Refresh() | 520 | self.Refresh() |
534 | 521 | ||
535 | - def HideAllMarkers(self, pubsub_evt): | ||
536 | - ballid = pubsub_evt.data | 522 | + def HideAllMarkers(self, indexes): |
523 | + ballid = indexes | ||
537 | for i in range(0, ballid): | 524 | for i in range(0, ballid): |
538 | self.staticballs[i].SetVisibility(0) | 525 | self.staticballs[i].SetVisibility(0) |
539 | self.UpdateRender() | 526 | self.UpdateRender() |
540 | 527 | ||
541 | - def ShowAllMarkers(self, pubsub_evt): | ||
542 | - ballid = pubsub_evt.data | 528 | + def ShowAllMarkers(self, indexes): |
529 | + ballid = indexes | ||
543 | for i in range(0, ballid): | 530 | for i in range(0, ballid): |
544 | self.staticballs[i].SetVisibility(1) | 531 | self.staticballs[i].SetVisibility(1) |
545 | self.UpdateRender() | 532 | self.UpdateRender() |
546 | 533 | ||
547 | - def RemoveAllMarkers(self, pubsub_evt): | ||
548 | - ballid = pubsub_evt.data | 534 | + def RemoveAllMarkers(self, indexes): |
535 | + ballid = indexes | ||
549 | for i in range(0, ballid): | 536 | for i in range(0, ballid): |
550 | self.ren.RemoveActor(self.staticballs[i]) | 537 | self.ren.RemoveActor(self.staticballs[i]) |
551 | self.staticballs = [] | 538 | self.staticballs = [] |
552 | self.UpdateRender() | 539 | self.UpdateRender() |
553 | 540 | ||
554 | - def RemoveMarker(self, pubsub_evt): | ||
555 | - index = pubsub_evt.data | 541 | + def RemoveMarker(self, index): |
556 | for i in reversed(index): | 542 | for i in reversed(index): |
557 | self.ren.RemoveActor(self.staticballs[i]) | 543 | self.ren.RemoveActor(self.staticballs[i]) |
558 | del self.staticballs[i] | 544 | del self.staticballs[i] |
559 | self.ball_id = self.ball_id - 1 | 545 | self.ball_id = self.ball_id - 1 |
560 | self.UpdateRender() | 546 | self.UpdateRender() |
561 | 547 | ||
562 | - def BlinkMarker(self, pubsub_evt): | 548 | + def BlinkMarker(self, index): |
563 | if self.timer: | 549 | if self.timer: |
564 | self.timer.Stop() | 550 | self.timer.Stop() |
565 | self.staticballs[self.index].SetVisibility(1) | 551 | self.staticballs[self.index].SetVisibility(1) |
566 | - self.index = pubsub_evt.data | 552 | + self.index = index |
567 | self.timer = wx.Timer(self) | 553 | self.timer = wx.Timer(self) |
568 | self.Bind(wx.EVT_TIMER, self.OnBlinkMarker, self.timer) | 554 | self.Bind(wx.EVT_TIMER, self.OnBlinkMarker, self.timer) |
569 | self.timer.Start(500) | 555 | self.timer.Start(500) |
@@ -574,31 +560,29 @@ class Viewer(wx.Panel): | @@ -574,31 +560,29 @@ class Viewer(wx.Panel): | ||
574 | self.Refresh() | 560 | self.Refresh() |
575 | self.timer_count += 1 | 561 | self.timer_count += 1 |
576 | 562 | ||
577 | - def StopBlinkMarker(self, pubsub_evt): | 563 | + def StopBlinkMarker(self, index=None): |
578 | if self.timer: | 564 | if self.timer: |
579 | self.timer.Stop() | 565 | self.timer.Stop() |
580 | - if pubsub_evt.data is None: | 566 | + if index is None: |
581 | self.staticballs[self.index].SetVisibility(1) | 567 | self.staticballs[self.index].SetVisibility(1) |
582 | self.Refresh() | 568 | self.Refresh() |
583 | self.index = False | 569 | self.index = False |
584 | 570 | ||
585 | - def OnTargetMarkerTransparency(self, pubsub_evt): | ||
586 | - status = pubsub_evt.data[0] | ||
587 | - index = pubsub_evt.data[1] | 571 | + def OnTargetMarkerTransparency(self, status, index): |
588 | if status: | 572 | if status: |
589 | self.staticballs[index].GetProperty().SetOpacity(1) | 573 | self.staticballs[index].GetProperty().SetOpacity(1) |
590 | # self.staticballs[index].GetProperty().SetOpacity(0.4) | 574 | # self.staticballs[index].GetProperty().SetOpacity(0.4) |
591 | else: | 575 | else: |
592 | self.staticballs[index].GetProperty().SetOpacity(1) | 576 | self.staticballs[index].GetProperty().SetOpacity(1) |
593 | 577 | ||
594 | - def OnUpdateAngleThreshold(self, pubsub_evt): | ||
595 | - self.anglethreshold = pubsub_evt.data | 578 | + def OnUpdateAngleThreshold(self, angle): |
579 | + self.anglethreshold = angle | ||
596 | 580 | ||
597 | - def OnUpdateDistThreshold(self, pubsub_evt): | ||
598 | - self.distthreshold = pubsub_evt.data | 581 | + def OnUpdateDistThreshold(self, dist_threshold): |
582 | + self.distthreshold = dist_threshold | ||
599 | 583 | ||
600 | - def ActivateTargetMode(self, pubsub_evt): | ||
601 | - self.target_mode = pubsub_evt.data | 584 | + def ActivateTargetMode(self, evt=None, target_mode=None): |
585 | + self.target_mode = target_mode | ||
602 | if self.target_coord and self.target_mode: | 586 | if self.target_coord and self.target_mode: |
603 | self.CreateTargetAim() | 587 | self.CreateTargetAim() |
604 | 588 | ||
@@ -691,8 +675,7 @@ class Viewer(wx.Panel): | @@ -691,8 +675,7 @@ class Viewer(wx.Panel): | ||
691 | else: | 675 | else: |
692 | self.DisableCoilTracker() | 676 | self.DisableCoilTracker() |
693 | 677 | ||
694 | - def OnUpdateObjectTargetGuide(self, pubsub_evt): | ||
695 | - coord = pubsub_evt.data[1] | 678 | + def OnUpdateObjectTargetGuide(self, m_img, coord): |
696 | if self.target_coord and self.target_mode: | 679 | if self.target_coord and self.target_mode: |
697 | 680 | ||
698 | target_dist = distance.euclidean(coord[0:3], | 681 | target_dist = distance.euclidean(coord[0:3], |
@@ -811,13 +794,12 @@ class Viewer(wx.Panel): | @@ -811,13 +794,12 @@ class Viewer(wx.Panel): | ||
811 | 794 | ||
812 | self.Refresh() | 795 | self.Refresh() |
813 | 796 | ||
814 | - def OnUpdateTargetCoordinates(self, pubsub_evt): | ||
815 | - self.target_coord = pubsub_evt.data[0:6] | 797 | + def OnUpdateTargetCoordinates(self, coord): |
798 | + self.target_coord = coord | ||
816 | self.target_coord[1] = -self.target_coord[1] | 799 | self.target_coord[1] = -self.target_coord[1] |
817 | self.CreateTargetAim() | 800 | self.CreateTargetAim() |
818 | 801 | ||
819 | - def OnRemoveTarget(self, pubsub_evt): | ||
820 | - status = pubsub_evt.data | 802 | + def OnRemoveTarget(self, status): |
821 | if not status: | 803 | if not status: |
822 | self.target_mode = None | 804 | self.target_mode = None |
823 | self.target_coord = None | 805 | self.target_coord = None |
@@ -1108,12 +1090,12 @@ class Viewer(wx.Panel): | @@ -1108,12 +1090,12 @@ class Viewer(wx.Panel): | ||
1108 | self.ren.RemoveActor(self.ball_actor) | 1090 | self.ren.RemoveActor(self.ball_actor) |
1109 | self.ball_actor = None | 1091 | self.ball_actor = None |
1110 | 1092 | ||
1111 | - def SetBallReferencePosition(self, pubsub_evt): | 1093 | + def SetBallReferencePosition(self, position): |
1112 | if self._to_show_ball: | 1094 | if self._to_show_ball: |
1113 | if not self.ball_actor: | 1095 | if not self.ball_actor: |
1114 | self.ActivateBallReference() | 1096 | self.ActivateBallReference() |
1115 | 1097 | ||
1116 | - coord = pubsub_evt.data | 1098 | + coord = position |
1117 | x, y, z = bases.flip_x(coord) | 1099 | x, y, z = bases.flip_x(coord) |
1118 | self.ball_actor.SetPosition(x, y, z) | 1100 | self.ball_actor.SetPosition(x, y, z) |
1119 | 1101 | ||
@@ -1198,18 +1180,15 @@ class Viewer(wx.Panel): | @@ -1198,18 +1180,15 @@ class Viewer(wx.Panel): | ||
1198 | 1180 | ||
1199 | # self.ren.AddActor(self.obj_axes) | 1181 | # self.ren.AddActor(self.obj_axes) |
1200 | 1182 | ||
1201 | - def OnNavigationStatus(self, pubsub_evt): | ||
1202 | - self.nav_status = pubsub_evt.data | 1183 | + def OnNavigationStatus(self, status): |
1184 | + self.nav_status = status | ||
1203 | self.pTarget = self.CenterOfMass() | 1185 | self.pTarget = self.CenterOfMass() |
1204 | if self.obj_actor and self.nav_status: | 1186 | if self.obj_actor and self.nav_status: |
1205 | self.obj_actor.SetVisibility(self.obj_state) | 1187 | self.obj_actor.SetVisibility(self.obj_state) |
1206 | if not self.obj_state: | 1188 | if not self.obj_state: |
1207 | self.Refresh() | 1189 | self.Refresh() |
1208 | 1190 | ||
1209 | - def UpdateObjectOrientation(self, pubsub_evt): | ||
1210 | - | ||
1211 | - m_img = pubsub_evt.data[0] | ||
1212 | - | 1191 | + def UpdateObjectOrientation(self, m_img, coord): |
1213 | m_img[:3, -1] = np.asmatrix(bases.flip_x_m((m_img[0, -1], m_img[1, -1], m_img[2, -1]))).reshape([3, 1]) | 1192 | m_img[:3, -1] = np.asmatrix(bases.flip_x_m((m_img[0, -1], m_img[1, -1], m_img[2, -1]))).reshape([3, 1]) |
1214 | 1193 | ||
1215 | m_img_vtk = vtk.vtkMatrix4x4() | 1194 | m_img_vtk = vtk.vtkMatrix4x4() |
@@ -1223,22 +1202,19 @@ class Viewer(wx.Panel): | @@ -1223,22 +1202,19 @@ class Viewer(wx.Panel): | ||
1223 | 1202 | ||
1224 | self.Refresh() | 1203 | self.Refresh() |
1225 | 1204 | ||
1226 | - def UpdateTrackObjectState(self, pubsub_evt): | ||
1227 | - if pubsub_evt.data[0]: | ||
1228 | - self.obj_name = pubsub_evt.data[1] | ||
1229 | - | 1205 | + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): |
1206 | + if flag: | ||
1207 | + self.obj_name = obj_name | ||
1230 | if not self.obj_actor: | 1208 | if not self.obj_actor: |
1231 | self.AddObjectActor(self.obj_name) | 1209 | self.AddObjectActor(self.obj_name) |
1232 | - | ||
1233 | else: | 1210 | else: |
1234 | if self.obj_actor: | 1211 | if self.obj_actor: |
1235 | self.ren.RemoveActor(self.obj_actor) | 1212 | self.ren.RemoveActor(self.obj_actor) |
1236 | self.obj_actor = None | 1213 | self.obj_actor = None |
1237 | - | ||
1238 | self.Refresh() | 1214 | self.Refresh() |
1239 | 1215 | ||
1240 | - def UpdateShowObjectState(self, pubsub_evt): | ||
1241 | - self.obj_state = pubsub_evt.data | 1216 | + def UpdateShowObjectState(self, state): |
1217 | + self.obj_state = state | ||
1242 | if self.obj_actor and not self.obj_state: | 1218 | if self.obj_actor and not self.obj_state: |
1243 | self.obj_actor.SetVisibility(self.obj_state) | 1219 | self.obj_actor.SetVisibility(self.obj_state) |
1244 | self.Refresh() | 1220 | self.Refresh() |
@@ -1371,8 +1347,8 @@ class Viewer(wx.Panel): | @@ -1371,8 +1347,8 @@ class Viewer(wx.Panel): | ||
1371 | diff_y = mouse_y - self.last_y | 1347 | diff_y = mouse_y - self.last_y |
1372 | self.last_x, self.last_y = mouse_x, mouse_y | 1348 | self.last_x, self.last_y = mouse_x, mouse_y |
1373 | Publisher.sendMessage('Set raycasting relative window and level', | 1349 | Publisher.sendMessage('Set raycasting relative window and level', |
1374 | - (diff_x, diff_y)) | ||
1375 | - Publisher.sendMessage('Refresh raycasting widget points', None) | 1350 | + diff_wl=diff_x, diff_ww=diff_y) |
1351 | + Publisher.sendMessage('Refresh raycasting widget points') | ||
1376 | self.interactor.Render() | 1352 | self.interactor.Render() |
1377 | 1353 | ||
1378 | def OnWindowLevelClick(self, obj, evt): | 1354 | def OnWindowLevelClick(self, obj, evt): |
@@ -1387,31 +1363,29 @@ class Viewer(wx.Panel): | @@ -1387,31 +1363,29 @@ class Viewer(wx.Panel): | ||
1387 | if const.RAYCASTING_WWWL_BLUR: | 1363 | if const.RAYCASTING_WWWL_BLUR: |
1388 | self.style.EndZoom() | 1364 | self.style.EndZoom() |
1389 | 1365 | ||
1390 | - def OnEnableStyle(self, pubsub_evt): | ||
1391 | - state = pubsub_evt.data | ||
1392 | - if (state in const.VOLUME_STYLES): | ||
1393 | - new_state = self.interaction_style.AddState(state) | 1366 | + def OnEnableStyle(self, style): |
1367 | + if (style in const.VOLUME_STYLES): | ||
1368 | + new_state = self.interaction_style.AddState(style) | ||
1394 | self.SetInteractorStyle(new_state) | 1369 | self.SetInteractorStyle(new_state) |
1395 | else: | 1370 | else: |
1396 | - new_state = self.interaction_style.RemoveState(state) | 1371 | + new_state = self.interaction_style.RemoveState(style) |
1397 | self.SetInteractorStyle(new_state) | 1372 | self.SetInteractorStyle(new_state) |
1398 | 1373 | ||
1399 | - def OnDisableStyle(self, pubsub_evt): | ||
1400 | - state = pubsub_evt.data | ||
1401 | - new_state = self.interaction_style.RemoveState(state) | 1374 | + def OnDisableStyle(self, style): |
1375 | + new_state = self.interaction_style.RemoveState(style) | ||
1402 | self.SetInteractorStyle(new_state) | 1376 | self.SetInteractorStyle(new_state) |
1403 | 1377 | ||
1404 | - def ResetCamClippingRange(self, pubsub_evt): | 1378 | + def ResetCamClippingRange(self): |
1405 | self.ren.ResetCamera() | 1379 | self.ren.ResetCamera() |
1406 | self.ren.ResetCameraClippingRange() | 1380 | self.ren.ResetCameraClippingRange() |
1407 | 1381 | ||
1408 | - def SetVolumeCameraState(self, pubsub_evt): | ||
1409 | - self.camera_state = pubsub_evt.data | 1382 | + def SetVolumeCameraState(self, camera_state): |
1383 | + self.camera_state = camera_state | ||
1410 | 1384 | ||
1411 | - def SetVolumeCamera(self, pubsub_evt): | 1385 | + def SetVolumeCamera(self, arg, position): |
1412 | if self.camera_state: | 1386 | if self.camera_state: |
1413 | # TODO: exclude dependency on initial focus | 1387 | # TODO: exclude dependency on initial focus |
1414 | - cam_focus = np.array(bases.flip_x(pubsub_evt.data[1][:3])) | 1388 | + cam_focus = np.array(bases.flip_x(position[:3])) |
1415 | cam = self.ren.GetActiveCamera() | 1389 | cam = self.ren.GetActiveCamera() |
1416 | 1390 | ||
1417 | if self.initial_focus is None: | 1391 | if self.initial_focus is None: |
@@ -1442,8 +1416,7 @@ class Viewer(wx.Panel): | @@ -1442,8 +1416,7 @@ class Viewer(wx.Panel): | ||
1442 | #self.interactor.Render() | 1416 | #self.interactor.Render() |
1443 | self.Refresh() | 1417 | self.Refresh() |
1444 | 1418 | ||
1445 | - def OnExportSurface(self, pubsub_evt): | ||
1446 | - filename, filetype = pubsub_evt.data | 1419 | + def OnExportSurface(self, filename, filetype): |
1447 | if filetype not in (const.FILETYPE_STL, | 1420 | if filetype not in (const.FILETYPE_STL, |
1448 | const.FILETYPE_VTP, | 1421 | const.FILETYPE_VTP, |
1449 | const.FILETYPE_PLY, | 1422 | const.FILETYPE_PLY, |
@@ -1487,23 +1460,22 @@ class Viewer(wx.Panel): | @@ -1487,23 +1460,22 @@ class Viewer(wx.Panel): | ||
1487 | writer.SetInput(renwin) | 1460 | writer.SetInput(renwin) |
1488 | writer.Write() | 1461 | writer.Write() |
1489 | 1462 | ||
1490 | - def OnEnableBrightContrast(self, pubsub_evt): | 1463 | + def OnEnableBrightContrast(self): |
1491 | style = self.style | 1464 | style = self.style |
1492 | style.AddObserver("MouseMoveEvent", self.OnMove) | 1465 | style.AddObserver("MouseMoveEvent", self.OnMove) |
1493 | style.AddObserver("LeftButtonPressEvent", self.OnClick) | 1466 | style.AddObserver("LeftButtonPressEvent", self.OnClick) |
1494 | style.AddObserver("LeftButtonReleaseEvent", self.OnRelease) | 1467 | style.AddObserver("LeftButtonReleaseEvent", self.OnRelease) |
1495 | 1468 | ||
1496 | - def OnDisableBrightContrast(self, pubsub_evt): | 1469 | + def OnDisableBrightContrast(self): |
1497 | style = vtk.vtkInteractorStyleTrackballCamera() | 1470 | style = vtk.vtkInteractorStyleTrackballCamera() |
1498 | self.interactor.SetInteractorStyle(style) | 1471 | self.interactor.SetInteractorStyle(style) |
1499 | self.style = style | 1472 | self.style = style |
1500 | 1473 | ||
1501 | - def OnSetWindowLevelText(self, pubsub_evt): | 1474 | + def OnSetWindowLevelText(self, ww, wl): |
1502 | if self.raycasting_volume: | 1475 | if self.raycasting_volume: |
1503 | - ww, wl = pubsub_evt.data | ||
1504 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) | 1476 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) |
1505 | 1477 | ||
1506 | - def OnShowRaycasting(self, pubsub_evt): | 1478 | + def OnShowRaycasting(self): |
1507 | if not self.raycasting_volume: | 1479 | if not self.raycasting_volume: |
1508 | self.raycasting_volume = True | 1480 | self.raycasting_volume = True |
1509 | self._to_show_ball += 1 | 1481 | self._to_show_ball += 1 |
@@ -1511,7 +1483,7 @@ class Viewer(wx.Panel): | @@ -1511,7 +1483,7 @@ class Viewer(wx.Panel): | ||
1511 | if self.on_wl: | 1483 | if self.on_wl: |
1512 | self.text.Show() | 1484 | self.text.Show() |
1513 | 1485 | ||
1514 | - def OnHideRaycasting(self, pubsub_evt): | 1486 | + def OnHideRaycasting(self): |
1515 | self.raycasting_volume = False | 1487 | self.raycasting_volume = False |
1516 | self.text.Hide() | 1488 | self.text.Hide() |
1517 | self._to_show_ball -= 1 | 1489 | self._to_show_ball -= 1 |
@@ -1524,13 +1496,11 @@ class Viewer(wx.Panel): | @@ -1524,13 +1496,11 @@ class Viewer(wx.Panel): | ||
1524 | self.interactor.Update() | 1496 | self.interactor.Update() |
1525 | evt.Skip() | 1497 | evt.Skip() |
1526 | 1498 | ||
1527 | - def ChangeBackgroundColour(self, pubsub_evt): | ||
1528 | - colour = pubsub_evt.data | 1499 | + def ChangeBackgroundColour(self, colour): |
1529 | self.ren.SetBackground(colour[:3]) | 1500 | self.ren.SetBackground(colour[:3]) |
1530 | self.UpdateRender() | 1501 | self.UpdateRender() |
1531 | 1502 | ||
1532 | - def LoadActor(self, pubsub_evt): | ||
1533 | - actor = pubsub_evt.data | 1503 | + def LoadActor(self, actor): |
1534 | self.added_actor = 1 | 1504 | self.added_actor = 1 |
1535 | ren = self.ren | 1505 | ren = self.ren |
1536 | ren.AddActor(actor) | 1506 | ren.AddActor(actor) |
@@ -1547,31 +1517,26 @@ class Viewer(wx.Panel): | @@ -1547,31 +1517,26 @@ class Viewer(wx.Panel): | ||
1547 | self._to_show_ball += 1 | 1517 | self._to_show_ball += 1 |
1548 | self._check_and_set_ball_visibility() | 1518 | self._check_and_set_ball_visibility() |
1549 | 1519 | ||
1550 | - def RemoveActor(self, pubsub_evt): | 1520 | + def RemoveActor(self, actor): |
1551 | utils.debug("RemoveActor") | 1521 | utils.debug("RemoveActor") |
1552 | - actor = pubsub_evt.data | ||
1553 | ren = self.ren | 1522 | ren = self.ren |
1554 | ren.RemoveActor(actor) | 1523 | ren.RemoveActor(actor) |
1555 | self.interactor.Render() | 1524 | self.interactor.Render() |
1556 | self._to_show_ball -= 1 | 1525 | self._to_show_ball -= 1 |
1557 | self._check_and_set_ball_visibility() | 1526 | self._check_and_set_ball_visibility() |
1558 | 1527 | ||
1559 | - def RemoveAllActor(self, pubsub_evt): | 1528 | + def RemoveAllActor(self): |
1560 | utils.debug("RemoveAllActor") | 1529 | utils.debug("RemoveAllActor") |
1561 | self.ren.RemoveAllProps() | 1530 | self.ren.RemoveAllProps() |
1562 | Publisher.sendMessage('Render volume viewer') | 1531 | Publisher.sendMessage('Render volume viewer') |
1563 | 1532 | ||
1564 | - def LoadSlicePlane(self, pubsub_evt): | 1533 | + def LoadSlicePlane(self): |
1565 | self.slice_plane = SlicePlane() | 1534 | self.slice_plane = SlicePlane() |
1566 | 1535 | ||
1567 | - def LoadVolume(self, pubsub_evt): | 1536 | + def LoadVolume(self, volume, colour, ww, wl): |
1568 | self.raycasting_volume = True | 1537 | self.raycasting_volume = True |
1569 | self._to_show_ball += 1 | 1538 | self._to_show_ball += 1 |
1570 | 1539 | ||
1571 | - volume = pubsub_evt.data[0] | ||
1572 | - colour = pubsub_evt.data[1] | ||
1573 | - ww, wl = pubsub_evt.data[2] | ||
1574 | - | ||
1575 | self.light = self.ren.GetLights().GetNextItem() | 1540 | self.light = self.ren.GetLights().GetNextItem() |
1576 | 1541 | ||
1577 | self.ren.AddVolume(volume) | 1542 | self.ren.AddVolume(volume) |
@@ -1593,16 +1558,14 @@ class Viewer(wx.Panel): | @@ -1593,16 +1558,14 @@ class Viewer(wx.Panel): | ||
1593 | self._check_and_set_ball_visibility() | 1558 | self._check_and_set_ball_visibility() |
1594 | self.UpdateRender() | 1559 | self.UpdateRender() |
1595 | 1560 | ||
1596 | - def UnloadVolume(self, pubsub_evt): | ||
1597 | - volume = pubsub_evt.data | 1561 | + def UnloadVolume(self, volume): |
1598 | self.ren.RemoveVolume(volume) | 1562 | self.ren.RemoveVolume(volume) |
1599 | del volume | 1563 | del volume |
1600 | self.raycasting_volume = False | 1564 | self.raycasting_volume = False |
1601 | self._to_show_ball -= 1 | 1565 | self._to_show_ball -= 1 |
1602 | self._check_and_set_ball_visibility() | 1566 | self._check_and_set_ball_visibility() |
1603 | 1567 | ||
1604 | - def OnSetViewAngle(self, evt_pubsub): | ||
1605 | - view = evt_pubsub.data | 1568 | + def OnSetViewAngle(self, view): |
1606 | self.SetViewAngle(view) | 1569 | self.SetViewAngle(view) |
1607 | 1570 | ||
1608 | def SetViewAngle(self, view): | 1571 | def SetViewAngle(self, view): |
@@ -1657,14 +1620,14 @@ class Viewer(wx.Panel): | @@ -1657,14 +1620,14 @@ class Viewer(wx.Panel): | ||
1657 | orientation_widget.On() | 1620 | orientation_widget.On() |
1658 | orientation_widget.InteractiveOff() | 1621 | orientation_widget.InteractiveOff() |
1659 | 1622 | ||
1660 | - def UpdateRender(self, evt_pubsub=None): | 1623 | + def UpdateRender(self): |
1661 | self.interactor.Render() | 1624 | self.interactor.Render() |
1662 | 1625 | ||
1663 | - def SetWidgetInteractor(self, evt_pubsub=None): | ||
1664 | - evt_pubsub.data.SetInteractor(self.interactor._Iren) | 1626 | + def SetWidgetInteractor(self, widget=None): |
1627 | + widget.SetInteractor(self.interactor._Iren) | ||
1665 | 1628 | ||
1666 | - def AppendActor(self, evt_pubsub=None): | ||
1667 | - self.ren.AddActor(evt_pubsub.data) | 1629 | + def AppendActor(self, actor): |
1630 | + self.ren.AddActor(actor) | ||
1668 | 1631 | ||
1669 | def OnInsertSeed(self, obj, evt): | 1632 | def OnInsertSeed(self, obj, evt): |
1670 | x,y = self.interactor.GetEventPosition() | 1633 | x,y = self.interactor.GetEventPosition() |
@@ -1693,7 +1656,10 @@ class Viewer(wx.Panel): | @@ -1693,7 +1656,10 @@ class Viewer(wx.Panel): | ||
1693 | # Publisher.sendMessage("Add measure to list", | 1656 | # Publisher.sendMessage("Add measure to list", |
1694 | # (u"3D", _(u"%.3f mm" % m.GetValue()))) | 1657 | # (u"3D", _(u"%.3f mm" % m.GetValue()))) |
1695 | Publisher.sendMessage("Add measurement point", | 1658 | Publisher.sendMessage("Add measurement point", |
1696 | - ((x, y,z), const.LINEAR, const.SURFACE, radius)) | 1659 | + position=(x, y,z), |
1660 | + type=const.LINEAR, | ||
1661 | + location=const.SURFACE, | ||
1662 | + radius=radius) | ||
1697 | self.interactor.Render() | 1663 | self.interactor.Render() |
1698 | 1664 | ||
1699 | def OnInsertAngularMeasurePoint(self, obj, evt): | 1665 | def OnInsertAngularMeasurePoint(self, obj, evt): |
@@ -1724,21 +1690,23 @@ class Viewer(wx.Panel): | @@ -1724,21 +1690,23 @@ class Viewer(wx.Panel): | ||
1724 | # type_, location, | 1690 | # type_, location, |
1725 | # value)) | 1691 | # value)) |
1726 | Publisher.sendMessage("Add measurement point", | 1692 | Publisher.sendMessage("Add measurement point", |
1727 | - ((x, y,z), const.ANGULAR, const.SURFACE, radius)) | 1693 | + position=(x, y,z), |
1694 | + type=const.ANGULAR, | ||
1695 | + location=const.SURFACE, | ||
1696 | + radius=radius) | ||
1728 | self.interactor.Render() | 1697 | self.interactor.Render() |
1729 | 1698 | ||
1730 | - def Reposition3DPlane(self, evt_pubsub): | ||
1731 | - position = evt_pubsub.data | 1699 | + def Reposition3DPlane(self, plane_label): |
1732 | if not(self.added_actor) and not(self.raycasting_volume): | 1700 | if not(self.added_actor) and not(self.raycasting_volume): |
1733 | - if not(self.repositioned_axial_plan) and (position == 'Axial'): | 1701 | + if not(self.repositioned_axial_plan) and (plane_label == 'Axial'): |
1734 | self.SetViewAngle(const.VOL_ISO) | 1702 | self.SetViewAngle(const.VOL_ISO) |
1735 | self.repositioned_axial_plan = 1 | 1703 | self.repositioned_axial_plan = 1 |
1736 | 1704 | ||
1737 | - elif not(self.repositioned_sagital_plan) and (position == 'Sagital'): | 1705 | + elif not(self.repositioned_sagital_plan) and (plane_label == 'Sagital'): |
1738 | self.SetViewAngle(const.VOL_ISO) | 1706 | self.SetViewAngle(const.VOL_ISO) |
1739 | self.repositioned_sagital_plan = 1 | 1707 | self.repositioned_sagital_plan = 1 |
1740 | 1708 | ||
1741 | - elif not(self.repositioned_coronal_plan) and (position == 'Coronal'): | 1709 | + elif not(self.repositioned_coronal_plan) and (plane_label == 'Coronal'): |
1742 | self.SetViewAngle(const.VOL_ISO) | 1710 | self.SetViewAngle(const.VOL_ISO) |
1743 | self.repositioned_coronal_plan = 1 | 1711 | self.repositioned_coronal_plan = 1 |
1744 | 1712 | ||
@@ -1825,39 +1793,36 @@ class SlicePlane: | @@ -1825,39 +1793,36 @@ class SlicePlane: | ||
1825 | selected_prop2 = plane_y.GetSelectedPlaneProperty() | 1793 | selected_prop2 = plane_y.GetSelectedPlaneProperty() |
1826 | selected_prop2.SetColor(0, 1, 0) | 1794 | selected_prop2.SetColor(0, 1, 0) |
1827 | 1795 | ||
1828 | - Publisher.sendMessage('Set Widget Interactor', plane_x) | ||
1829 | - Publisher.sendMessage('Set Widget Interactor', plane_y) | ||
1830 | - Publisher.sendMessage('Set Widget Interactor', plane_z) | 1796 | + Publisher.sendMessage('Set Widget Interactor', widget=plane_x) |
1797 | + Publisher.sendMessage('Set Widget Interactor', widget=plane_y) | ||
1798 | + Publisher.sendMessage('Set Widget Interactor', widget=plane_z) | ||
1831 | 1799 | ||
1832 | self.Render() | 1800 | self.Render() |
1833 | 1801 | ||
1834 | - def Enable(self, evt_pubsub=None): | ||
1835 | - if (evt_pubsub): | ||
1836 | - label = evt_pubsub.data | ||
1837 | - if(label == "Axial"): | 1802 | + def Enable(self, plane_label=None): |
1803 | + if plane_label: | ||
1804 | + if(plane_label == "Axial"): | ||
1838 | self.plane_z.On() | 1805 | self.plane_z.On() |
1839 | - elif(label == "Coronal"): | 1806 | + elif(plane_label == "Coronal"): |
1840 | self.plane_y.On() | 1807 | self.plane_y.On() |
1841 | - elif(label == "Sagital"): | 1808 | + elif(plane_label == "Sagital"): |
1842 | self.plane_x.On() | 1809 | self.plane_x.On() |
1843 | - | ||
1844 | - Publisher.sendMessage('Reposition 3D Plane', label) | ||
1845 | - | 1810 | + Publisher.sendMessage('Reposition 3D Plane', plane_label=plane_label) |
1846 | else: | 1811 | else: |
1847 | self.plane_z.On() | 1812 | self.plane_z.On() |
1848 | self.plane_x.On() | 1813 | self.plane_x.On() |
1849 | self.plane_y.On() | 1814 | self.plane_y.On() |
1850 | - Publisher.sendMessage('Set volume view angle', const.VOL_ISO) | 1815 | + Publisher.sendMessage('Set volume view angle', |
1816 | + view=const.VOL_ISO) | ||
1851 | self.Render() | 1817 | self.Render() |
1852 | 1818 | ||
1853 | - def Disable(self, evt_pubsub=None): | ||
1854 | - if (evt_pubsub): | ||
1855 | - label = evt_pubsub.data | ||
1856 | - if(label == "Axial"): | 1819 | + def Disable(self, plane_label=None): |
1820 | + if plane_label: | ||
1821 | + if(plane_label == "Axial"): | ||
1857 | self.plane_z.Off() | 1822 | self.plane_z.Off() |
1858 | - elif(label == "Coronal"): | 1823 | + elif(plane_label == "Coronal"): |
1859 | self.plane_y.Off() | 1824 | self.plane_y.Off() |
1860 | - elif(label == "Sagital"): | 1825 | + elif(plane_label == "Sagital"): |
1861 | self.plane_x.Off() | 1826 | self.plane_x.Off() |
1862 | else: | 1827 | else: |
1863 | self.plane_z.Off() | 1828 | self.plane_z.Off() |
@@ -1869,23 +1834,33 @@ class SlicePlane: | @@ -1869,23 +1834,33 @@ class SlicePlane: | ||
1869 | def Render(self): | 1834 | def Render(self): |
1870 | Publisher.sendMessage('Render volume viewer') | 1835 | Publisher.sendMessage('Render volume viewer') |
1871 | 1836 | ||
1872 | - def ChangeSlice(self, pubsub_evt = None): | ||
1873 | - orientation, number = pubsub_evt.data | ||
1874 | - | 1837 | + def ChangeSlice(self, orientation, index): |
1875 | if orientation == "CORONAL" and self.plane_y.GetEnabled(): | 1838 | if orientation == "CORONAL" and self.plane_y.GetEnabled(): |
1876 | - Publisher.sendMessage('Update slice 3D', (self.plane_y,orientation)) | 1839 | + Publisher.sendMessage('Update slice 3D', |
1840 | + widget=self.plane_y, | ||
1841 | + orientation=orientation) | ||
1877 | self.Render() | 1842 | self.Render() |
1878 | elif orientation == "SAGITAL" and self.plane_x.GetEnabled(): | 1843 | elif orientation == "SAGITAL" and self.plane_x.GetEnabled(): |
1879 | - Publisher.sendMessage('Update slice 3D', (self.plane_x,orientation)) | 1844 | + Publisher.sendMessage('Update slice 3D', |
1845 | + widget=self.plane_x, | ||
1846 | + orientation=orientation) | ||
1880 | self.Render() | 1847 | self.Render() |
1881 | elif orientation == 'AXIAL' and self.plane_z.GetEnabled() : | 1848 | elif orientation == 'AXIAL' and self.plane_z.GetEnabled() : |
1882 | - Publisher.sendMessage('Update slice 3D', (self.plane_z,orientation)) | 1849 | + Publisher.sendMessage('Update slice 3D', |
1850 | + widget=self.plane_z, | ||
1851 | + orientation=orientation) | ||
1883 | self.Render() | 1852 | self.Render() |
1884 | 1853 | ||
1885 | - def UpdateAllSlice(self, pubsub_evt): | ||
1886 | - Publisher.sendMessage('Update slice 3D', (self.plane_y,"CORONAL")) | ||
1887 | - Publisher.sendMessage('Update slice 3D', (self.plane_x,"SAGITAL")) | ||
1888 | - Publisher.sendMessage('Update slice 3D', (self.plane_z,"AXIAL")) | 1854 | + def UpdateAllSlice(self): |
1855 | + Publisher.sendMessage('Update slice 3D', | ||
1856 | + widget=self.plane_y, | ||
1857 | + orientation="CORONAL") | ||
1858 | + Publisher.sendMessage('Update slice 3D', | ||
1859 | + widget=self.plane_x, | ||
1860 | + orientation="SAGITAL") | ||
1861 | + Publisher.sendMessage('Update slice 3D', | ||
1862 | + widget=self.plane_z, | ||
1863 | + orientation="AXIAL") | ||
1889 | 1864 | ||
1890 | 1865 | ||
1891 | def DeletePlanes(self): | 1866 | def DeletePlanes(self): |
invesalius/data/volume.py
@@ -110,17 +110,17 @@ class Volume(): | @@ -110,17 +110,17 @@ class Volume(): | ||
110 | Publisher.subscribe(self.ChangeBackgroundColour, | 110 | Publisher.subscribe(self.ChangeBackgroundColour, |
111 | 'Change volume viewer background colour') | 111 | 'Change volume viewer background colour') |
112 | 112 | ||
113 | - Publisher.subscribe(self.ResetRayCasting, 'Reset Reaycasting') | 113 | + Publisher.subscribe(self.ResetRayCasting, 'Reset Raycasting') |
114 | 114 | ||
115 | Publisher.subscribe(self.OnFlipVolume, 'Flip volume') | 115 | Publisher.subscribe(self.OnFlipVolume, 'Flip volume') |
116 | 116 | ||
117 | - def ResetRayCasting(self, pub_evt): | 117 | + def ResetRayCasting(self): |
118 | if self.exist: | 118 | if self.exist: |
119 | self.exist = None | 119 | self.exist = None |
120 | self.LoadVolume() | 120 | self.LoadVolume() |
121 | 121 | ||
122 | 122 | ||
123 | - def OnCloseProject(self, pubsub_evt): | 123 | + def OnCloseProject(self): |
124 | self.CloseProject() | 124 | self.CloseProject() |
125 | 125 | ||
126 | def CloseProject(self): | 126 | def CloseProject(self): |
@@ -134,9 +134,9 @@ class Volume(): | @@ -134,9 +134,9 @@ class Volume(): | ||
134 | 134 | ||
135 | if self.exist: | 135 | if self.exist: |
136 | self.exist = None | 136 | self.exist = None |
137 | - Publisher.sendMessage('Remove surface actor from viewer', self.volume) | 137 | + Publisher.sendMessage('Remove surface actor from viewer', actor=self.volume) |
138 | Publisher.sendMessage('Disable volume cut menu') | 138 | Publisher.sendMessage('Disable volume cut menu') |
139 | - Publisher.sendMessage('Unload volume', self.volume) | 139 | + Publisher.sendMessage('Unload volume', volume=self.volume) |
140 | 140 | ||
141 | del self.image | 141 | del self.image |
142 | del self.imagedata | 142 | del self.imagedata |
@@ -155,19 +155,19 @@ class Volume(): | @@ -155,19 +155,19 @@ class Volume(): | ||
155 | self.color_transfer = None | 155 | self.color_transfer = None |
156 | Publisher.sendMessage('Render volume viewer') | 156 | Publisher.sendMessage('Render volume viewer') |
157 | 157 | ||
158 | - def OnLoadVolume(self, pubsub_evt): | ||
159 | - label = pubsub_evt.data | 158 | + def OnLoadVolume(self, label): |
159 | + label = label | ||
160 | #self.LoadConfig(label) | 160 | #self.LoadConfig(label) |
161 | self.LoadVolume() | 161 | self.LoadVolume() |
162 | 162 | ||
163 | - def OnHideVolume(self, pubsub_evt): | 163 | + def OnHideVolume(self): |
164 | print('Hide Volume') | 164 | print('Hide Volume') |
165 | self.volume.SetVisibility(0) | 165 | self.volume.SetVisibility(0) |
166 | if (self.plane and self.plane_on): | 166 | if (self.plane and self.plane_on): |
167 | self.plane.Disable() | 167 | self.plane.Disable() |
168 | Publisher.sendMessage('Render volume viewer') | 168 | Publisher.sendMessage('Render volume viewer') |
169 | 169 | ||
170 | - def OnShowVolume(self, pubsub_evt = None): | 170 | + def OnShowVolume(self): |
171 | print('Show volume') | 171 | print('Show volume') |
172 | if self.exist: | 172 | if self.exist: |
173 | print('Volume exists') | 173 | print('Volume exists') |
@@ -177,18 +177,19 @@ class Volume(): | @@ -177,18 +177,19 @@ class Volume(): | ||
177 | Publisher.sendMessage('Render volume viewer') | 177 | Publisher.sendMessage('Render volume viewer') |
178 | else: | 178 | else: |
179 | print('Volume doesnt exit') | 179 | print('Volume doesnt exit') |
180 | - Publisher.sendMessage('Load raycasting preset', const.RAYCASTING_LABEL) | 180 | + Publisher.sendMessage('Load raycasting preset', |
181 | + preset_name=const.RAYCASTING_LABEL) | ||
181 | self.LoadConfig() | 182 | self.LoadConfig() |
182 | self.LoadVolume() | 183 | self.LoadVolume() |
183 | self.exist = 1 | 184 | self.exist = 1 |
184 | 185 | ||
185 | - def OnUpdatePreset(self, pubsub_evt): | 186 | + def OnUpdatePreset(self): |
186 | self.__load_preset_config() | 187 | self.__load_preset_config() |
187 | 188 | ||
188 | if self.config: | 189 | if self.config: |
189 | if self.to_reload: | 190 | if self.to_reload: |
190 | self.exist = False | 191 | self.exist = False |
191 | - Publisher.sendMessage('Unload volume', self.volume) | 192 | + Publisher.sendMessage('Unload volume', volume=self.volume) |
192 | 193 | ||
193 | if self.exist: | 194 | if self.exist: |
194 | self.__load_preset() | 195 | self.__load_preset() |
@@ -200,10 +201,10 @@ class Volume(): | @@ -200,10 +201,10 @@ class Volume(): | ||
200 | self.exist = 1 | 201 | self.exist = 1 |
201 | 202 | ||
202 | colour = self.GetBackgroundColour() | 203 | colour = self.GetBackgroundColour() |
203 | - Publisher.sendMessage('Change volume viewer background colour', colour) | ||
204 | - Publisher.sendMessage('Change volume viewer gui colour', colour) | 204 | + Publisher.sendMessage('Change volume viewer background colour', colour=colour) |
205 | + Publisher.sendMessage('Change volume viewer gui colour', colour=colour) | ||
205 | else: | 206 | else: |
206 | - Publisher.sendMessage('Unload volume', self.volume) | 207 | + Publisher.sendMessage('Unload volume', volume=self.volume) |
207 | del self.image | 208 | del self.image |
208 | del self.imagedata | 209 | del self.imagedata |
209 | del self.final_imagedata | 210 | del self.final_imagedata |
@@ -221,7 +222,7 @@ class Volume(): | @@ -221,7 +222,7 @@ class Volume(): | ||
221 | self.color_transfer = None | 222 | self.color_transfer = None |
222 | Publisher.sendMessage('Render volume viewer') | 223 | Publisher.sendMessage('Render volume viewer') |
223 | 224 | ||
224 | - def OnFlipVolume(self, pubsub_evt): | 225 | + def OnFlipVolume(self, axis): |
225 | print("Flipping Volume") | 226 | print("Flipping Volume") |
226 | self.loaded_image = False | 227 | self.loaded_image = False |
227 | del self.image | 228 | del self.image |
@@ -252,28 +253,24 @@ class Volume(): | @@ -252,28 +253,24 @@ class Volume(): | ||
252 | self.SetShading() | 253 | self.SetShading() |
253 | self.SetTypeRaycasting() | 254 | self.SetTypeRaycasting() |
254 | 255 | ||
255 | - def OnSetCurve(self, pubsub_evt): | ||
256 | - self.curve = pubsub_evt.data | 256 | + def OnSetCurve(self, curve): |
257 | + self.curve = curve | ||
257 | self.CalculateWWWL() | 258 | self.CalculateWWWL() |
258 | ww = self.ww | 259 | ww = self.ww |
259 | wl = self.wl | 260 | wl = self.wl |
260 | - Publisher.sendMessage('Set volume window and level text', | ||
261 | - (ww, wl)) | 261 | + Publisher.sendMessage('Set volume window and level text', ww=ww, wl=wl) |
262 | 262 | ||
263 | - def OnSetRelativeWindowLevel(self, pubsub_evt): | ||
264 | - diff_wl, diff_ww = pubsub_evt.data | 263 | + def OnSetRelativeWindowLevel(self, diff_wl, diff_ww): |
265 | ww = self.ww + diff_ww | 264 | ww = self.ww + diff_ww |
266 | wl = self.wl + diff_wl | 265 | wl = self.wl + diff_wl |
267 | - Publisher.sendMessage('Set volume window and level text', | ||
268 | - (ww, wl)) | 266 | + Publisher.sendMessage('Set volume window and level text', ww=ww, wl=wl) |
269 | self.SetWWWL(ww, wl) | 267 | self.SetWWWL(ww, wl) |
270 | self.ww = ww | 268 | self.ww = ww |
271 | self.wl = wl | 269 | self.wl = wl |
272 | 270 | ||
273 | - def OnSetWindowLevel(self, pubsub_evt): | ||
274 | - ww, wl, n = pubsub_evt.data | ||
275 | - self.curve = n | ||
276 | - self.SetWWWL(ww,wl) | 271 | + def OnSetWindowLevel(self, ww, wl, curve): |
272 | + self.curve = curve | ||
273 | + self.SetWWWL(ww, wl) | ||
277 | 274 | ||
278 | def SetWWWL(self, ww, wl): | 275 | def SetWWWL(self, ww, wl): |
279 | if self.config['advancedCLUT']: | 276 | if self.config['advancedCLUT']: |
@@ -321,7 +318,7 @@ class Volume(): | @@ -321,7 +318,7 @@ class Volume(): | ||
321 | self.ww = last_point - first_point | 318 | self.ww = last_point - first_point |
322 | self.wl = first_point + self.ww / 2.0 | 319 | self.wl = first_point + self.ww / 2.0 |
323 | 320 | ||
324 | - def Refresh(self, pubsub_evt): | 321 | + def Refresh(self): |
325 | self.__update_colour_table() | 322 | self.__update_colour_table() |
326 | 323 | ||
327 | def Create16bColorTable(self, scale): | 324 | def Create16bColorTable(self, scale): |
@@ -445,11 +442,11 @@ class Volume(): | @@ -445,11 +442,11 @@ class Volume(): | ||
445 | self.config['backgroundColorBlueComponent']) | 442 | self.config['backgroundColorBlueComponent']) |
446 | return colour | 443 | return colour |
447 | 444 | ||
448 | - def ChangeBackgroundColour(self, pubsub_evt): | 445 | + def ChangeBackgroundColour(self, colour): |
449 | if (self.config): | 446 | if (self.config): |
450 | - self.config['backgroundColorRedComponent'] = pubsub_evt.data[0] * 255 | ||
451 | - self.config['backgroundColorGreenComponent'] = pubsub_evt.data[1] * 255 | ||
452 | - self.config['backgroundColorBlueComponent'] = pubsub_evt.data[2] * 255 | 447 | + self.config['backgroundColorRedComponent'] = colour[0] * 255 |
448 | + self.config['backgroundColorGreenComponent'] = colour[1] * 255 | ||
449 | + self.config['backgroundColorBlueComponent'] = colour[2] * 255 | ||
453 | 450 | ||
454 | def BuildTable(): | 451 | def BuildTable(): |
455 | curve_table = p['16bitClutCurves'] | 452 | curve_table = p['16bitClutCurves'] |
@@ -663,16 +660,16 @@ class Volume(): | @@ -663,16 +660,16 @@ class Volume(): | ||
663 | self.plane.SetVolumeMapper(volume_mapper) | 660 | self.plane.SetVolumeMapper(volume_mapper) |
664 | 661 | ||
665 | Publisher.sendMessage('Load volume into viewer', | 662 | Publisher.sendMessage('Load volume into viewer', |
666 | - (volume, colour, (self.ww, self.wl))) | 663 | + volume=volume, colour=colour, |
664 | + ww=self.ww, wl=self.wl) | ||
667 | 665 | ||
668 | del flip | 666 | del flip |
669 | del cast | 667 | del cast |
670 | 668 | ||
671 | - def OnEnableTool(self, pubsub_evt): | ||
672 | - tool_name, enable = pubsub_evt.data | 669 | + def OnEnableTool(self, tool_name, flag): |
673 | if tool_name == _("Cut plane"): | 670 | if tool_name == _("Cut plane"): |
674 | if self.plane: | 671 | if self.plane: |
675 | - if enable: | 672 | + if flag: |
676 | self.plane_on = True | 673 | self.plane_on = True |
677 | self.plane.Enable() | 674 | self.plane.Enable() |
678 | else: | 675 | else: |
@@ -695,8 +692,10 @@ class Volume(): | @@ -695,8 +692,10 @@ class Volume(): | ||
695 | accumulate.Update() | 692 | accumulate.Update() |
696 | n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars()) | 693 | n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars()) |
697 | del accumulate | 694 | del accumulate |
698 | - Publisher.sendMessage('Load histogram', (n_image, | ||
699 | - image.GetScalarRange())) | 695 | + init, end = image.GetScalarRange() |
696 | + Publisher.sendMessage('Load histogram', histogram=n_image, init=init, end=end) | ||
697 | + | ||
698 | + | ||
700 | 699 | ||
701 | def TranslateScale(self, scale, value): | 700 | def TranslateScale(self, scale, value): |
702 | #if value < 0: | 701 | #if value < 0: |
@@ -747,8 +746,8 @@ class CutPlane: | @@ -747,8 +746,8 @@ class CutPlane: | ||
747 | plane_actor.GetProperty().BackfaceCullingOn() | 746 | plane_actor.GetProperty().BackfaceCullingOn() |
748 | plane_actor.GetProperty().SetOpacity(0) | 747 | plane_actor.GetProperty().SetOpacity(0) |
749 | plane_widget.AddObserver("InteractionEvent", self.Update) | 748 | plane_widget.AddObserver("InteractionEvent", self.Update) |
750 | - Publisher.sendMessage('AppendActor', self.plane_actor) | ||
751 | - Publisher.sendMessage('Set Widget Interactor', self.plane_widget) | 749 | + Publisher.sendMessage('AppendActor', actor=self.plane_actor) |
750 | + Publisher.sendMessage('Set Widget Interactor', widget=self.plane_widget) | ||
752 | plane_actor.SetVisibility(1) | 751 | plane_actor.SetVisibility(1) |
753 | plane_widget.On() | 752 | plane_widget.On() |
754 | self.plane = plane = vtk.vtkPlane() | 753 | self.plane = plane = vtk.vtkPlane() |
@@ -775,21 +774,21 @@ class CutPlane: | @@ -775,21 +774,21 @@ class CutPlane: | ||
775 | self.plane_actor.VisibilityOn() | 774 | self.plane_actor.VisibilityOn() |
776 | self.plane.SetNormal(plane_source.GetNormal()) | 775 | self.plane.SetNormal(plane_source.GetNormal()) |
777 | self.plane.SetOrigin(plane_source.GetOrigin()) | 776 | self.plane.SetOrigin(plane_source.GetOrigin()) |
778 | - Publisher.sendMessage('Render volume viewer', None) | 777 | + Publisher.sendMessage('Render volume viewer') |
779 | 778 | ||
780 | - def Enable(self, evt_pubsub=None): | 779 | + def Enable(self): |
781 | self.plane_widget.On() | 780 | self.plane_widget.On() |
782 | self.plane_actor.VisibilityOn() | 781 | self.plane_actor.VisibilityOn() |
783 | self.volume_mapper.AddClippingPlane(self.plane) | 782 | self.volume_mapper.AddClippingPlane(self.plane) |
784 | - Publisher.sendMessage('Render volume viewer', None) | 783 | + Publisher.sendMessage('Render volume viewer') |
785 | 784 | ||
786 | - def Disable(self,evt_pubsub=None): | 785 | + def Disable(self): |
787 | self.plane_widget.Off() | 786 | self.plane_widget.Off() |
788 | self.plane_actor.VisibilityOff() | 787 | self.plane_actor.VisibilityOff() |
789 | self.volume_mapper.RemoveClippingPlane(self.plane) | 788 | self.volume_mapper.RemoveClippingPlane(self.plane) |
790 | - Publisher.sendMessage('Render volume viewer', None) | 789 | + Publisher.sendMessage('Render volume viewer') |
791 | 790 | ||
792 | - def Reset(self, evt_pubsub=None): | 791 | + def Reset(self): |
793 | plane_source = self.plane_source | 792 | plane_source = self.plane_source |
794 | plane_widget = self.plane_widget | 793 | plane_widget = self.plane_widget |
795 | plane_source.SetOrigin(self.origin) | 794 | plane_source.SetOrigin(self.origin) |
@@ -799,10 +798,10 @@ class CutPlane: | @@ -799,10 +798,10 @@ class CutPlane: | ||
799 | self.plane_actor.VisibilityOn() | 798 | self.plane_actor.VisibilityOn() |
800 | self.plane.SetNormal(self.normal) | 799 | self.plane.SetNormal(self.normal) |
801 | self.plane.SetOrigin(self.origin) | 800 | self.plane.SetOrigin(self.origin) |
802 | - Publisher.sendMessage('Render volume viewer', None) | 801 | + Publisher.sendMessage('Render volume viewer') |
803 | 802 | ||
804 | def DestroyObjs(self): | 803 | def DestroyObjs(self): |
805 | - Publisher.sendMessage('Remove surface actor from viewer', self.plane_actor) | 804 | + Publisher.sendMessage('Remove surface actor from viewer', actor=self.plane_actor) |
806 | self.Disable() | 805 | self.Disable() |
807 | del self.plane_widget | 806 | del self.plane_widget |
808 | del self.plane_source | 807 | del self.plane_source |
invesalius/data/vtk_utils.py
@@ -81,8 +81,7 @@ def ShowProgress(number_of_filters = 1, | @@ -81,8 +81,7 @@ def ShowProgress(number_of_filters = 1, | ||
81 | progress[0] = progress[0] + ratio*difference | 81 | progress[0] = progress[0] + ratio*difference |
82 | # Tell GUI to update progress status value | 82 | # Tell GUI to update progress status value |
83 | if (dialog_type == "GaugeProgress"): | 83 | if (dialog_type == "GaugeProgress"): |
84 | - Publisher.sendMessage('Update status in GUI', | ||
85 | - (progress[0], label)) | 84 | + Publisher.sendMessage('Update status in GUI', value=progress[0], label=label) |
86 | else: | 85 | else: |
87 | if (progress[0] >= 99.999): | 86 | if (progress[0] >= 99.999): |
88 | progress[0] = 100 | 87 | progress[0] = 100 |
invesalius/gui/bitmap_preview_panel.py
@@ -249,7 +249,7 @@ class Preview(wx.Panel): | @@ -249,7 +249,7 @@ class Preview(wx.Panel): | ||
249 | my_evt.SetEventObject(self) | 249 | my_evt.SetEventObject(self) |
250 | self.GetEventHandler().ProcessEvent(my_evt) | 250 | self.GetEventHandler().ProcessEvent(my_evt) |
251 | 251 | ||
252 | - Publisher.sendMessage('Set bitmap in preview panel', self.bitmap_info.pos) | 252 | + Publisher.sendMessage('Set bitmap in preview panel', pos=self.bitmap_info.pos) |
253 | 253 | ||
254 | evt.Skip() | 254 | evt.Skip() |
255 | 255 | ||
@@ -369,15 +369,14 @@ class BitmapPreviewSeries(wx.Panel): | @@ -369,15 +369,14 @@ class BitmapPreviewSeries(wx.Panel): | ||
369 | self._display_previews() | 369 | self._display_previews() |
370 | 370 | ||
371 | 371 | ||
372 | - def RemovePanel(self, pub_sub): | ||
373 | - data = pub_sub.data | 372 | + def RemovePanel(self, data): |
374 | for p, f in zip(self.previews, self.files): | 373 | for p, f in zip(self.previews, self.files): |
375 | if p.bitmap_info != None: | 374 | if p.bitmap_info != None: |
376 | if data.encode('utf-8') in p.bitmap_info.data: | 375 | if data.encode('utf-8') in p.bitmap_info.data: |
377 | self.files.remove(f) | 376 | self.files.remove(f) |
378 | p.Hide() | 377 | p.Hide() |
379 | self._display_previews() | 378 | self._display_previews() |
380 | - Publisher.sendMessage('Update max of slidebar in single preview image', len(self.files)) | 379 | + Publisher.sendMessage('Update max of slidebar in single preview image', max_value=len(self.files)) |
381 | 380 | ||
382 | self.Update() | 381 | self.Update() |
383 | self.Layout() | 382 | self.Layout() |
@@ -539,8 +538,7 @@ class SingleImagePreview(wx.Panel): | @@ -539,8 +538,7 @@ class SingleImagePreview(wx.Panel): | ||
539 | Publisher.subscribe(self.UpdateMaxValueSliderBar, 'Update max of slidebar in single preview image') | 538 | Publisher.subscribe(self.UpdateMaxValueSliderBar, 'Update max of slidebar in single preview image') |
540 | Publisher.subscribe(self.ShowBlackSlice, 'Show black slice in single preview image') | 539 | Publisher.subscribe(self.ShowBlackSlice, 'Show black slice in single preview image') |
541 | 540 | ||
542 | - def ShowBitmapByPosition(self, evt): | ||
543 | - pos = evt.data | 541 | + def ShowBitmapByPosition(self, pos): |
544 | if pos != None: | 542 | if pos != None: |
545 | self.ShowSlice(int(pos)) | 543 | self.ShowSlice(int(pos)) |
546 | 544 | ||
@@ -584,8 +582,8 @@ class SingleImagePreview(wx.Panel): | @@ -584,8 +582,8 @@ class SingleImagePreview(wx.Panel): | ||
584 | self.slider.SetValue(0) | 582 | self.slider.SetValue(0) |
585 | self.ShowSlice() | 583 | self.ShowSlice() |
586 | 584 | ||
587 | - def UpdateMaxValueSliderBar(self, pub_sub): | ||
588 | - self.slider.SetMax(pub_sub.data - 1) | 585 | + def UpdateMaxValueSliderBar(self, max_value): |
586 | + self.slider.SetMax(max_value - 1) | ||
589 | self.slider.Refresh() | 587 | self.slider.Refresh() |
590 | self.slider.Update() | 588 | self.slider.Update() |
591 | 589 |
invesalius/gui/data_notebook.py
@@ -98,20 +98,20 @@ class NotebookPanel(wx.Panel): | @@ -98,20 +98,20 @@ class NotebookPanel(wx.Panel): | ||
98 | 'Fold mask page') | 98 | 'Fold mask page') |
99 | 99 | ||
100 | 100 | ||
101 | - def _FoldSurface(self, pubusb_evt): | 101 | + def _FoldSurface(self): |
102 | """ | 102 | """ |
103 | Fold surface notebook page. | 103 | Fold surface notebook page. |
104 | """ | 104 | """ |
105 | self.book.SetSelection(1) | 105 | self.book.SetSelection(1) |
106 | 106 | ||
107 | - def _FoldMeasure(self, pubsub_evt): | 107 | + def _FoldMeasure(self): |
108 | """ | 108 | """ |
109 | Fold measure notebook page. | 109 | Fold measure notebook page. |
110 | """ | 110 | """ |
111 | self.book.SetSelection(2) | 111 | self.book.SetSelection(2) |
112 | 112 | ||
113 | 113 | ||
114 | - def _FoldMask(self, pubsub_evt): | 114 | + def _FoldMask(self): |
115 | """ | 115 | """ |
116 | Fold mask notebook page. | 116 | Fold mask notebook page. |
117 | """ | 117 | """ |
@@ -334,7 +334,8 @@ class ButtonControlPanel(wx.Panel): | @@ -334,7 +334,8 @@ class ButtonControlPanel(wx.Panel): | ||
334 | mask_name, thresh, colour = dialog.GetValue() | 334 | mask_name, thresh, colour = dialog.GetValue() |
335 | if mask_name: | 335 | if mask_name: |
336 | Publisher.sendMessage('Create new mask', | 336 | Publisher.sendMessage('Create new mask', |
337 | - (mask_name, thresh, colour)) | 337 | + mask_name=mask_name, |
338 | + thresh=thresh, colour=colour) | ||
338 | dialog.Destroy() | 339 | dialog.Destroy() |
339 | 340 | ||
340 | def OnRemove(self): | 341 | def OnRemove(self): |
@@ -343,7 +344,7 @@ class ButtonControlPanel(wx.Panel): | @@ -343,7 +344,7 @@ class ButtonControlPanel(wx.Panel): | ||
343 | def OnDuplicate(self): | 344 | def OnDuplicate(self): |
344 | selected_items = self.parent.listctrl.GetSelected() | 345 | selected_items = self.parent.listctrl.GetSelected() |
345 | if selected_items: | 346 | if selected_items: |
346 | - Publisher.sendMessage('Duplicate masks', selected_items) | 347 | + Publisher.sendMessage('Duplicate masks', mask_indexes=selected_items) |
347 | else: | 348 | else: |
348 | dlg.MaskSelectionRequiredForDuplication() | 349 | dlg.MaskSelectionRequiredForDuplication() |
349 | 350 | ||
@@ -398,7 +399,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -398,7 +399,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
398 | selected_items = self.GetSelected() | 399 | selected_items = self.GetSelected() |
399 | 400 | ||
400 | if selected_items: | 401 | if selected_items: |
401 | - Publisher.sendMessage('Remove masks', selected_items) | 402 | + Publisher.sendMessage('Remove masks', mask_indexes=selected_items) |
402 | else: | 403 | else: |
403 | dlg.MaskSelectionRequiredForRemoval() | 404 | dlg.MaskSelectionRequiredForRemoval() |
404 | return | 405 | return |
@@ -421,8 +422,8 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -421,8 +422,8 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
421 | if new_dict: | 422 | if new_dict: |
422 | if index == self.current_index: | 423 | if index == self.current_index: |
423 | self.SetItemImage(0, 1) | 424 | self.SetItemImage(0, 1) |
424 | - Publisher.sendMessage('Change mask selected', 0) | ||
425 | - Publisher.sendMessage('Show mask', (0, 1)) | 425 | + Publisher.sendMessage('Change mask selected', index=0) |
426 | + Publisher.sendMessage('Show mask', index=0, value=1) | ||
426 | Publisher.sendMessage('Refresh viewer') | 427 | Publisher.sendMessage('Refresh viewer') |
427 | for key in new_dict: | 428 | for key in new_dict: |
428 | if key: | 429 | if key: |
@@ -433,27 +434,26 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -433,27 +434,26 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
433 | self.SetItemImage(self.current_index, 1) | 434 | self.SetItemImage(self.current_index, 1) |
434 | 435 | ||
435 | 436 | ||
436 | - def OnCloseProject(self, pubsub_evt): | 437 | + def OnCloseProject(self): |
437 | self.DeleteAllItems() | 438 | self.DeleteAllItems() |
438 | self.mask_list_index = {} | 439 | self.mask_list_index = {} |
439 | 440 | ||
440 | - def OnChangeCurrentMask(self, pubsub_evt): | ||
441 | - mask_index = pubsub_evt.data | 441 | + def OnChangeCurrentMask(self, index): |
442 | try: | 442 | try: |
443 | - self.SetItemImage(mask_index, 1) | ||
444 | - self.current_index = mask_index | 443 | + self.SetItemImage(index, 1) |
444 | + self.current_index = index | ||
445 | except wx._core.PyAssertionError: | 445 | except wx._core.PyAssertionError: |
446 | #in SetItem(): invalid item index in SetItem | 446 | #in SetItem(): invalid item index in SetItem |
447 | pass | 447 | pass |
448 | for key in self.mask_list_index.keys(): | 448 | for key in self.mask_list_index.keys(): |
449 | - if key != mask_index: | 449 | + if key != index: |
450 | self.SetItemImage(key, 0) | 450 | self.SetItemImage(key, 0) |
451 | 451 | ||
452 | - def __hide_current_mask(self, pubsub_evt): | 452 | + def __hide_current_mask(self): |
453 | if self.mask_list_index: | 453 | if self.mask_list_index: |
454 | self.SetItemImage(self.current_index, 0) | 454 | self.SetItemImage(self.current_index, 0) |
455 | 455 | ||
456 | - def __show_current_mask(self, pubsub_evt): | 456 | + def __show_current_mask(self): |
457 | if self.mask_list_index: | 457 | if self.mask_list_index: |
458 | self.SetItemImage(self.current_index, 1) | 458 | self.SetItemImage(self.current_index, 1) |
459 | 459 | ||
@@ -488,7 +488,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -488,7 +488,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
488 | 488 | ||
489 | def OnEditLabel(self, evt): | 489 | def OnEditLabel(self, evt): |
490 | Publisher.sendMessage('Change mask name', | 490 | Publisher.sendMessage('Change mask name', |
491 | - (evt.GetIndex(), evt.GetLabel())) | 491 | + index=evt.GetIndex(), name=evt.GetLabel()) |
492 | evt.Skip() | 492 | evt.Skip() |
493 | 493 | ||
494 | def OnItemActivated(self, evt): | 494 | def OnItemActivated(self, evt): |
@@ -499,9 +499,9 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -499,9 +499,9 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
499 | for key in self.mask_list_index.keys(): | 499 | for key in self.mask_list_index.keys(): |
500 | if key != index: | 500 | if key != index: |
501 | self.SetItemImage(key, 0) | 501 | self.SetItemImage(key, 0) |
502 | - Publisher.sendMessage('Change mask selected',index) | 502 | + Publisher.sendMessage('Change mask selected', index=index) |
503 | self.current_index = index | 503 | self.current_index = index |
504 | - Publisher.sendMessage('Show mask', (index, flag)) | 504 | + Publisher.sendMessage('Show mask', index=index, value=flag) |
505 | 505 | ||
506 | def CreateColourBitmap(self, colour): | 506 | def CreateColourBitmap(self, colour): |
507 | """ | 507 | """ |
@@ -536,19 +536,16 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -536,19 +536,16 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
536 | # self.SetItemImage(key, 0) | 536 | # self.SetItemImage(key, 0) |
537 | # self.current_index = index | 537 | # self.current_index = index |
538 | 538 | ||
539 | - def AddMask(self, pubsub_evt): | ||
540 | - index, mask_name, threshold_range, colour = pubsub_evt.data | ||
541 | - image = self.CreateColourBitmap(colour) | 539 | + def AddMask(self, mask): |
540 | + image = self.CreateColourBitmap(mask.colour) | ||
542 | image_index = self.imagelist.Add(image) | 541 | image_index = self.imagelist.Add(image) |
543 | - self.mask_list_index[index] = image_index | ||
544 | - self.InsertNewItem(index, mask_name, str(threshold_range)) | 542 | + self.mask_list_index[mask.index] = image_index |
543 | + self.InsertNewItem(mask.index, mask.name, str(mask.threshold_range)) | ||
545 | 544 | ||
546 | - def EditMaskThreshold(self, pubsub_evt): | ||
547 | - index, threshold_range = pubsub_evt.data | 545 | + def EditMaskThreshold(self, index, threshold_range): |
548 | self.SetStringItem(index, 2, str(threshold_range)) | 546 | self.SetStringItem(index, 2, str(threshold_range)) |
549 | 547 | ||
550 | - def EditMaskColour(self, pubsub_evt): | ||
551 | - index, colour = pubsub_evt.data | 548 | + def EditMaskColour(self, index, colour): |
552 | image = self.CreateColourBitmap(colour) | 549 | image = self.CreateColourBitmap(colour) |
553 | image_index = self.mask_list_index[index] | 550 | image_index = self.mask_list_index[index] |
554 | self.imagelist.Replace(image_index, image) | 551 | self.imagelist.Replace(image_index, image) |
@@ -678,7 +675,8 @@ class SurfaceButtonControlPanel(wx.Panel): | @@ -678,7 +675,8 @@ class SurfaceButtonControlPanel(wx.Panel): | ||
678 | if ok: | 675 | if ok: |
679 | surface_options = dialog.GetValue() | 676 | surface_options = dialog.GetValue() |
680 | 677 | ||
681 | - Publisher.sendMessage('Create surface from index', surface_options) | 678 | + Publisher.sendMessage('Create surface from index', |
679 | + surface_parameters=surface_options) | ||
682 | dialog.Destroy() | 680 | dialog.Destroy() |
683 | 681 | ||
684 | def OnRemove(self): | 682 | def OnRemove(self): |
@@ -688,14 +686,14 @@ class SurfaceButtonControlPanel(wx.Panel): | @@ -688,14 +686,14 @@ class SurfaceButtonControlPanel(wx.Panel): | ||
688 | def OnDuplicate(self): | 686 | def OnDuplicate(self): |
689 | selected_items = self.parent.listctrl.GetSelected() | 687 | selected_items = self.parent.listctrl.GetSelected() |
690 | if selected_items: | 688 | if selected_items: |
691 | - Publisher.sendMessage('Duplicate surfaces', selected_items) | 689 | + Publisher.sendMessage('Duplicate surfaces', surface_indexes=selected_items) |
692 | else: | 690 | else: |
693 | dlg.SurfaceSelectionRequiredForDuplication() | 691 | dlg.SurfaceSelectionRequiredForDuplication() |
694 | 692 | ||
695 | def OnOpenMesh(self): | 693 | def OnOpenMesh(self): |
696 | filename = dlg.ShowImportMeshFilesDialog() | 694 | filename = dlg.ShowImportMeshFilesDialog() |
697 | if filename: | 695 | if filename: |
698 | - Publisher.sendMessage('Import surface file', filename) | 696 | + Publisher.sendMessage('Import surface file', filename=filename) |
699 | 697 | ||
700 | 698 | ||
701 | class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | 699 | class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
@@ -744,8 +742,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -744,8 +742,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
744 | elif (keycode == wx.WXK_DELETE): | 742 | elif (keycode == wx.WXK_DELETE): |
745 | self.RemoveSurfaces() | 743 | self.RemoveSurfaces() |
746 | 744 | ||
747 | - def OnHideSurface(self, pubsub_evt): | ||
748 | - surface_dict = pubsub_evt.data | 745 | + def OnHideSurface(self, surface_dict): |
749 | for key in surface_dict: | 746 | for key in surface_dict: |
750 | if not surface_dict[key].is_shown: | 747 | if not surface_dict[key].is_shown: |
751 | self.SetItemImage(key, False) | 748 | self.SetItemImage(key, False) |
@@ -770,11 +767,11 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -770,11 +767,11 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
770 | old_dict = new_dict | 767 | old_dict = new_dict |
771 | self.surface_list_index = new_dict | 768 | self.surface_list_index = new_dict |
772 | 769 | ||
773 | - Publisher.sendMessage('Remove surfaces', selected_items) | 770 | + Publisher.sendMessage('Remove surfaces', surface_indexes=selected_items) |
774 | else: | 771 | else: |
775 | dlg.SurfaceSelectionRequiredForRemoval() | 772 | dlg.SurfaceSelectionRequiredForRemoval() |
776 | 773 | ||
777 | - def OnCloseProject(self, pubsub_evt): | 774 | + def OnCloseProject(self): |
778 | self.DeleteAllItems() | 775 | self.DeleteAllItems() |
779 | self.surface_list_index = {} | 776 | self.surface_list_index = {} |
780 | self.surface_bmp_idx_to_name = {} | 777 | self.surface_bmp_idx_to_name = {} |
@@ -786,7 +783,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -786,7 +783,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
786 | 783 | ||
787 | last_surface_index = evt.Index | 784 | last_surface_index = evt.Index |
788 | Publisher.sendMessage('Change surface selected', | 785 | Publisher.sendMessage('Change surface selected', |
789 | - last_surface_index) | 786 | + surface_index=last_surface_index) |
790 | evt.Skip() | 787 | evt.Skip() |
791 | 788 | ||
792 | def GetSelected(self): | 789 | def GetSelected(self): |
@@ -837,7 +834,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -837,7 +834,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
837 | self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | 834 | self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) |
838 | 835 | ||
839 | def OnEditLabel(self, evt): | 836 | def OnEditLabel(self, evt): |
840 | - Publisher.sendMessage('Change surface name', (evt.GetIndex(), evt.GetLabel())) | 837 | + Publisher.sendMessage('Change surface name', index=evt.GetIndex(), name=evt.GetLabel()) |
841 | evt.Skip() | 838 | evt.Skip() |
842 | 839 | ||
843 | def OnItemActivated(self, evt): | 840 | def OnItemActivated(self, evt): |
@@ -845,38 +842,36 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -845,38 +842,36 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
845 | evt.Skip() | 842 | evt.Skip() |
846 | 843 | ||
847 | def OnCheckItem(self, index, flag): | 844 | def OnCheckItem(self, index, flag): |
848 | - Publisher.sendMessage('Show surface', (index, flag)) | 845 | + Publisher.sendMessage('Show surface', index=index, visibility=flag) |
849 | 846 | ||
850 | - def OnShowSingle(self, pubsub_evt): | ||
851 | - index, visibility = pubsub_evt.data | 847 | + def OnShowSingle(self, index, visibility): |
852 | for key in self.surface_list_index.keys(): | 848 | for key in self.surface_list_index.keys(): |
853 | if key != index: | 849 | if key != index: |
854 | self.SetItemImage(key, not visibility) | 850 | self.SetItemImage(key, not visibility) |
855 | Publisher.sendMessage('Show surface', | 851 | Publisher.sendMessage('Show surface', |
856 | - (key, not visibility)) | 852 | + index=key, visibility=not visibility) |
857 | self.SetItemImage(index, visibility) | 853 | self.SetItemImage(index, visibility) |
858 | Publisher.sendMessage('Show surface', | 854 | Publisher.sendMessage('Show surface', |
859 | - (index, visibility)) | 855 | + index=index, visibility=visibility) |
860 | 856 | ||
861 | - def OnShowMultiple(self, pubsub_evt): | ||
862 | - index_list, visibility = pubsub_evt.data | 857 | + def OnShowMultiple(self, index_list, visibility): |
863 | for key in self.surface_list_index.keys(): | 858 | for key in self.surface_list_index.keys(): |
864 | if key not in index_list: | 859 | if key not in index_list: |
865 | self.SetItemImage(key, not visibility) | 860 | self.SetItemImage(key, not visibility) |
866 | Publisher.sendMessage('Show surface', | 861 | Publisher.sendMessage('Show surface', |
867 | - (key, not visibility)) | 862 | + index=key, visibility=not visibility) |
868 | for index in index_list: | 863 | for index in index_list: |
869 | self.SetItemImage(index, visibility) | 864 | self.SetItemImage(index, visibility) |
870 | Publisher.sendMessage('Show surface', | 865 | Publisher.sendMessage('Show surface', |
871 | - (index, visibility)) | 866 | + index=index, visibility=visibility) |
872 | 867 | ||
873 | - def AddSurface(self, pubsub_evt): | ||
874 | - index = pubsub_evt.data[0] | ||
875 | - name = pubsub_evt.data[1] | ||
876 | - colour = pubsub_evt.data[2] | ||
877 | - volume = "%.3f"%pubsub_evt.data[3] | ||
878 | - area = "%.3f"%pubsub_evt.data[4] | ||
879 | - transparency = "%d%%"%(int(100*pubsub_evt.data[5])) | 868 | + def AddSurface(self, surface): |
869 | + index = surface.index | ||
870 | + name = surface.name | ||
871 | + colour = surface.colour | ||
872 | + volume = "%.3f" % surface.volume | ||
873 | + area = "%.3f" % surface.area | ||
874 | + transparency = "%d%%" % (int(100*surface.transparency)) | ||
880 | 875 | ||
881 | if index not in self.surface_list_index: | 876 | if index not in self.surface_list_index: |
882 | image = self.CreateColourBitmap(colour) | 877 | image = self.CreateColourBitmap(colour) |
@@ -941,20 +936,18 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -941,20 +936,18 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
941 | 936 | ||
942 | return wx.BitmapFromImage(wx_image.Scale(16, 16)) | 937 | return wx.BitmapFromImage(wx_image.Scale(16, 16)) |
943 | 938 | ||
944 | - def EditSurfaceTransparency(self, pubsub_evt): | 939 | + def EditSurfaceTransparency(self, surface_index, transparency): |
945 | """ | 940 | """ |
946 | Set actor transparency (oposite to opacity) according to given actor | 941 | Set actor transparency (oposite to opacity) according to given actor |
947 | index and value. | 942 | index and value. |
948 | """ | 943 | """ |
949 | - index, value = pubsub_evt.data | ||
950 | - self.SetStringItem(index, 4, "%d%%"%(int(value*100))) | 944 | + self.SetStringItem(surface_index, 4, "%d%%"%(int(transparency*100))) |
951 | 945 | ||
952 | - def EditSurfaceColour(self, pubsub_evt): | 946 | + def EditSurfaceColour(self, surface_index, colour): |
953 | """ | 947 | """ |
954 | """ | 948 | """ |
955 | - index, colour = pubsub_evt.data | ||
956 | image = self.CreateColourBitmap(colour) | 949 | image = self.CreateColourBitmap(colour) |
957 | - image_index = self.surface_list_index[index] | 950 | + image_index = self.surface_list_index[surface_index] |
958 | self.imagelist.Replace(image_index, image) | 951 | self.imagelist.Replace(image_index, image) |
959 | self.Refresh() | 952 | self.Refresh() |
960 | 953 | ||
@@ -1007,15 +1000,14 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1007,15 +1000,14 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1007 | elif (keycode == wx.WXK_DELETE): | 1000 | elif (keycode == wx.WXK_DELETE): |
1008 | self.RemoveMeasurements() | 1001 | self.RemoveMeasurements() |
1009 | 1002 | ||
1010 | - def OnRemoveGUIMeasure(self, pubsub_evt): | ||
1011 | - idx = pubsub_evt.data | ||
1012 | - self.DeleteItem(idx) | 1003 | + def OnRemoveGUIMeasure(self, measure_index): |
1004 | + self.DeleteItem(measure_index) | ||
1013 | 1005 | ||
1014 | old_dict = self._list_index | 1006 | old_dict = self._list_index |
1015 | new_dict = {} | 1007 | new_dict = {} |
1016 | j = 0 | 1008 | j = 0 |
1017 | for i in old_dict: | 1009 | for i in old_dict: |
1018 | - if i != idx: | 1010 | + if i != measure_index: |
1019 | new_dict[j] = old_dict[i] | 1011 | new_dict[j] = old_dict[i] |
1020 | j+=1 | 1012 | j+=1 |
1021 | self._list_index = new_dict | 1013 | self._list_index = new_dict |
@@ -1041,12 +1033,12 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1041,12 +1033,12 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1041 | new_dict[i-1] = old_dict[i] | 1033 | new_dict[i-1] = old_dict[i] |
1042 | old_dict = new_dict | 1034 | old_dict = new_dict |
1043 | self._list_index = new_dict | 1035 | self._list_index = new_dict |
1044 | - Publisher.sendMessage('Remove measurements', selected_items) | 1036 | + Publisher.sendMessage('Remove measurements', indexes=selected_items) |
1045 | else: | 1037 | else: |
1046 | dlg.MeasureSelectionRequiredForRemoval() | 1038 | dlg.MeasureSelectionRequiredForRemoval() |
1047 | 1039 | ||
1048 | 1040 | ||
1049 | - def OnCloseProject(self, pubsub_evt): | 1041 | + def OnCloseProject(self): |
1050 | self.DeleteAllItems() | 1042 | self.DeleteAllItems() |
1051 | self._list_index = {} | 1043 | self._list_index = {} |
1052 | self._bmp_idx_to_name = {} | 1044 | self._bmp_idx_to_name = {} |
@@ -1057,8 +1049,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1057,8 +1049,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1057 | # things will stop working, e.g.: OnCheckItem | 1049 | # things will stop working, e.g.: OnCheckItem |
1058 | 1050 | ||
1059 | last_index = evt.Index | 1051 | last_index = evt.Index |
1060 | - Publisher.sendMessage('Change measurement selected', | ||
1061 | - last_index) | 1052 | + # Publisher.sendMessage('Change measurement selected', |
1053 | + # last_index) | ||
1062 | evt.Skip() | 1054 | evt.Skip() |
1063 | 1055 | ||
1064 | def GetSelected(self): | 1056 | def GetSelected(self): |
@@ -1110,7 +1102,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1110,7 +1102,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1110 | 1102 | ||
1111 | 1103 | ||
1112 | def OnEditLabel(self, evt): | 1104 | def OnEditLabel(self, evt): |
1113 | - Publisher.sendMessage('Change measurement name', (evt.GetIndex(), evt.GetLabel())) | 1105 | + Publisher.sendMessage('Change measurement name', index=evt.GetIndex(), name=evt.GetLabel()) |
1114 | evt.Skip() | 1106 | evt.Skip() |
1115 | 1107 | ||
1116 | def OnItemActivated(self, evt): | 1108 | def OnItemActivated(self, evt): |
@@ -1119,38 +1111,32 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1119,38 +1111,32 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1119 | 1111 | ||
1120 | 1112 | ||
1121 | def OnCheckItem(self, index, flag): | 1113 | def OnCheckItem(self, index, flag): |
1122 | - Publisher.sendMessage('Show measurement', (index, flag)) | 1114 | + Publisher.sendMessage('Show measurement', index=index, visibility=flag) |
1123 | 1115 | ||
1124 | - def OnShowSingle(self, pubsub_evt): | ||
1125 | - index, visibility = pubsub_evt.data | 1116 | + def OnShowSingle(self, index, visibility): |
1126 | for key in self._list_index.keys(): | 1117 | for key in self._list_index.keys(): |
1127 | if key != index: | 1118 | if key != index: |
1128 | self.SetItemImage(key, not visibility) | 1119 | self.SetItemImage(key, not visibility) |
1129 | Publisher.sendMessage('Show measurement', | 1120 | Publisher.sendMessage('Show measurement', |
1130 | - (key, not visibility)) | 1121 | + index=key, visibility=not visibility) |
1131 | self.SetItemImage(index, visibility) | 1122 | self.SetItemImage(index, visibility) |
1132 | Publisher.sendMessage('Show measurement', | 1123 | Publisher.sendMessage('Show measurement', |
1133 | - (index, visibility)) | 1124 | + index=index, visibility=visibility) |
1134 | 1125 | ||
1135 | - def OnShowMultiple(self, pubsub_evt): | ||
1136 | - index_list, visibility = pubsub_evt.data | 1126 | + def OnShowMultiple(self, index_list, visibility): |
1137 | for key in self._list_index.keys(): | 1127 | for key in self._list_index.keys(): |
1138 | if key not in index_list: | 1128 | if key not in index_list: |
1139 | self.SetItemImage(key, not visibility) | 1129 | self.SetItemImage(key, not visibility) |
1140 | Publisher.sendMessage('Show measurement', | 1130 | Publisher.sendMessage('Show measurement', |
1141 | - (key, not visibility)) | 1131 | + index=key, visibility=not visibility) |
1142 | for index in index_list: | 1132 | for index in index_list: |
1143 | self.SetItemImage(index, visibility) | 1133 | self.SetItemImage(index, visibility) |
1144 | Publisher.sendMessage('Show measurement', | 1134 | Publisher.sendMessage('Show measurement', |
1145 | - (index, visibility)) | 1135 | + index=index, visibility=visibility) |
1146 | 1136 | ||
1147 | - def OnLoadData(self, pubsub_evt): | ||
1148 | - try: | ||
1149 | - items_dict, spacing = pubsub_evt.data | ||
1150 | - except ValueError: | ||
1151 | - items_dict = pubsub_evt.data | ||
1152 | - for i in items_dict: | ||
1153 | - m = items_dict[i] | 1137 | + def OnLoadData(self, measurement_dict, spacing=(1.0, 1.0, 1.0)): |
1138 | + for i in measurement_dict: | ||
1139 | + m = measurement_dict[i] | ||
1154 | image = self.CreateColourBitmap(m.colour) | 1140 | image = self.CreateColourBitmap(m.colour) |
1155 | image_index = self.imagelist.Add(image) | 1141 | image_index = self.imagelist.Add(image) |
1156 | 1142 | ||
@@ -1169,14 +1155,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1169,14 +1155,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1169 | if not m.visible: | 1155 | if not m.visible: |
1170 | self.SetItemImage(i, False) | 1156 | self.SetItemImage(i, False) |
1171 | 1157 | ||
1172 | - def AddItem_(self, pubsub_evt): | ||
1173 | - index = pubsub_evt.data[0] | ||
1174 | - name = pubsub_evt.data[1] | ||
1175 | - colour = pubsub_evt.data[2] | ||
1176 | - location = pubsub_evt.data[3] | ||
1177 | - type_ = pubsub_evt.data[4] | ||
1178 | - value = pubsub_evt.data[5] | ||
1179 | - | 1158 | + def AddItem_(self, index, name, colour, location, type_, value): |
1180 | if index not in self._list_index: | 1159 | if index not in self._list_index: |
1181 | image = self.CreateColourBitmap(colour) | 1160 | image = self.CreateColourBitmap(colour) |
1182 | image_index = self.imagelist.Add(image) | 1161 | image_index = self.imagelist.Add(image) |
@@ -1241,12 +1220,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -1241,12 +1220,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
1241 | wx_image.SetData(new_image.tobytes()) | 1220 | wx_image.SetData(new_image.tobytes()) |
1242 | return wx.BitmapFromImage(wx_image.Scale(16, 16)) | 1221 | return wx.BitmapFromImage(wx_image.Scale(16, 16)) |
1243 | 1222 | ||
1244 | - def EditItemColour(self, pubsub_evt): | 1223 | + def EditItemColour(self, measure_index, colour): |
1245 | """ | 1224 | """ |
1246 | """ | 1225 | """ |
1247 | - index, colour = pubsub_evt.data | ||
1248 | image = self.CreateColourBitmap(colour) | 1226 | image = self.CreateColourBitmap(colour) |
1249 | - image_index = self._list_index[index] | 1227 | + image_index = self._list_index[measure_index] |
1250 | self.imagelist.Replace(image_index, image) | 1228 | self.imagelist.Replace(image_index, image) |
1251 | self.Refresh() | 1229 | self.Refresh() |
1252 | 1230 |
invesalius/gui/default_tasks.py
@@ -204,8 +204,7 @@ class LowerTaskPanel(wx.Panel): | @@ -204,8 +204,7 @@ class LowerTaskPanel(wx.Panel): | ||
204 | def __bind_events(self): | 204 | def __bind_events(self): |
205 | Publisher.subscribe(self.OnEnableState, "Enable state project") | 205 | Publisher.subscribe(self.OnEnableState, "Enable state project") |
206 | 206 | ||
207 | - def OnEnableState(self, pubsub_evt): | ||
208 | - state = pubsub_evt.data | 207 | + def OnEnableState(self, state): |
209 | if state: | 208 | if state: |
210 | self.SetStateProjectOpen() | 209 | self.SetStateProjectOpen() |
211 | else: | 210 | else: |
@@ -305,25 +304,24 @@ class UpperTaskPanel(wx.Panel): | @@ -305,25 +304,24 @@ class UpperTaskPanel(wx.Panel): | ||
305 | Publisher.subscribe(self.OnFoldExport, 'Fold export task') | 304 | Publisher.subscribe(self.OnFoldExport, 'Fold export task') |
306 | Publisher.subscribe(self.SetNavigationMode, "Set navigation mode") | 305 | Publisher.subscribe(self.SetNavigationMode, "Set navigation mode") |
307 | 306 | ||
308 | - def OnOverwrite(self, pubsub_evt): | ||
309 | - self.overwrite = pubsub_evt.data['options']['overwrite'] | 307 | + def OnOverwrite(self, surface_parameters): |
308 | + self.overwrite = surface_parameters['options']['overwrite'] | ||
310 | 309 | ||
311 | - def OnFoldSurface(self, pubsub_evt): | 310 | + def OnFoldSurface(self): |
312 | if not self.overwrite: | 311 | if not self.overwrite: |
313 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(2)) | 312 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(2)) |
314 | 313 | ||
315 | - def OnFoldExport(self, pubsub_evt): | 314 | + def OnFoldExport(self): |
316 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(3)) | 315 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(3)) |
317 | 316 | ||
318 | - def OnEnableState(self, pubsub_evt): | ||
319 | - state = pubsub_evt.data | 317 | + def OnEnableState(self, state): |
320 | if state: | 318 | if state: |
321 | self.SetStateProjectOpen() | 319 | self.SetStateProjectOpen() |
322 | else: | 320 | else: |
323 | self.SetStateProjectClose() | 321 | self.SetStateProjectClose() |
324 | 322 | ||
325 | - def SetNavigationMode(self, pubsub_evt): | ||
326 | - self.navigation_mode_status = status = pubsub_evt.data | 323 | + def SetNavigationMode(self, status): |
324 | + self.navigation_mode_status = status | ||
327 | name = _("Navigation system") | 325 | name = _("Navigation system") |
328 | panel = navigator.TaskPanel | 326 | panel = navigator.TaskPanel |
329 | if status and (self.fold_panel.GetCount()<=4): | 327 | if status and (self.fold_panel.GetCount()<=4): |
invesalius/gui/default_viewers.py
@@ -130,11 +130,11 @@ class Panel(wx.Panel): | @@ -130,11 +130,11 @@ class Panel(wx.Panel): | ||
130 | 130 | ||
131 | def OnMaximize(self, evt): | 131 | def OnMaximize(self, evt): |
132 | if evt.GetPane().name == self.s4.name: | 132 | if evt.GetPane().name == self.s4.name: |
133 | - Publisher.sendMessage('Show raycasting widget', None) | 133 | + Publisher.sendMessage('Show raycasting widget') |
134 | 134 | ||
135 | def OnRestore(self, evt): | 135 | def OnRestore(self, evt): |
136 | if evt.GetPane().name == self.s4.name: | 136 | if evt.GetPane().name == self.s4.name: |
137 | - Publisher.sendMessage('Hide raycasting widget', None) | 137 | + Publisher.sendMessage('Hide raycasting widget') |
138 | 138 | ||
139 | def __init_four_way_splitter(self): | 139 | def __init_four_way_splitter(self): |
140 | 140 | ||
@@ -156,7 +156,7 @@ class Panel(wx.Panel): | @@ -156,7 +156,7 @@ class Panel(wx.Panel): | ||
156 | p4 = volume_viewer.Viewer(self) | 156 | p4 = volume_viewer.Viewer(self) |
157 | splitter.AppendWindow(p4) | 157 | splitter.AppendWindow(p4) |
158 | 158 | ||
159 | - def _Exit(self, pubsub_evt): | 159 | + def _Exit(self): |
160 | self.aui_manager.UnInit() | 160 | self.aui_manager.UnInit() |
161 | 161 | ||
162 | def __init_mix(self): | 162 | def __init_mix(self): |
@@ -256,28 +256,28 @@ class VolumeInteraction(wx.Panel): | @@ -256,28 +256,28 @@ class VolumeInteraction(wx.Panel): | ||
256 | 256 | ||
257 | def __update_curve_wwwl_text(self, curve): | 257 | def __update_curve_wwwl_text(self, curve): |
258 | ww, wl = self.clut_raycasting.GetCurveWWWl(curve) | 258 | ww, wl = self.clut_raycasting.GetCurveWWWl(curve) |
259 | - Publisher.sendMessage('Set raycasting wwwl', (ww, wl, curve)) | 259 | + Publisher.sendMessage('Set raycasting wwwl', ww=ww, wl=wl, curve=curve) |
260 | 260 | ||
261 | - def ShowRaycastingWidget(self, evt_pubsub=None): | 261 | + def ShowRaycastingWidget(self): |
262 | self.can_show_raycasting_widget = 1 | 262 | self.can_show_raycasting_widget = 1 |
263 | if self.clut_raycasting.to_draw_points: | 263 | if self.clut_raycasting.to_draw_points: |
264 | p = self.aui_manager.GetPane(self.clut_raycasting) | 264 | p = self.aui_manager.GetPane(self.clut_raycasting) |
265 | p.Show() | 265 | p.Show() |
266 | self.aui_manager.Update() | 266 | self.aui_manager.Update() |
267 | 267 | ||
268 | - def HideRaycastingWidget(self, evt_pubsub=None): | 268 | + def HideRaycastingWidget(self): |
269 | self.can_show_raycasting_widget = 0 | 269 | self.can_show_raycasting_widget = 0 |
270 | p = self.aui_manager.GetPane(self.clut_raycasting) | 270 | p = self.aui_manager.GetPane(self.clut_raycasting) |
271 | p.Hide() | 271 | p.Hide() |
272 | self.aui_manager.Update() | 272 | self.aui_manager.Update() |
273 | 273 | ||
274 | def OnPointChanged(self, evt): | 274 | def OnPointChanged(self, evt): |
275 | - Publisher.sendMessage('Set raycasting refresh', None) | ||
276 | - Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | 275 | + Publisher.sendMessage('Set raycasting refresh') |
276 | + Publisher.sendMessage('Set raycasting curve', curve=evt.GetCurve()) | ||
277 | Publisher.sendMessage('Render volume viewer') | 277 | Publisher.sendMessage('Render volume viewer') |
278 | 278 | ||
279 | def OnCurveSelected(self, evt): | 279 | def OnCurveSelected(self, evt): |
280 | - Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | 280 | + Publisher.sendMessage('Set raycasting curve', curve=evt.GetCurve()) |
281 | Publisher.sendMessage('Render volume viewer') | 281 | Publisher.sendMessage('Render volume viewer') |
282 | 282 | ||
283 | def OnChangeCurveWL(self, evt): | 283 | def OnChangeCurveWL(self, evt): |
@@ -285,7 +285,7 @@ class VolumeInteraction(wx.Panel): | @@ -285,7 +285,7 @@ class VolumeInteraction(wx.Panel): | ||
285 | self.__update_curve_wwwl_text(curve) | 285 | self.__update_curve_wwwl_text(curve) |
286 | Publisher.sendMessage('Render volume viewer') | 286 | Publisher.sendMessage('Render volume viewer') |
287 | 287 | ||
288 | - def OnSetRaycastPreset(self, evt_pubsub): | 288 | + def OnSetRaycastPreset(self): |
289 | preset = project.Project().raycasting_preset | 289 | preset = project.Project().raycasting_preset |
290 | p = self.aui_manager.GetPane(self.clut_raycasting) | 290 | p = self.aui_manager.GetPane(self.clut_raycasting) |
291 | self.clut_raycasting.SetRaycastPreset(preset) | 291 | self.clut_raycasting.SetRaycastPreset(preset) |
@@ -296,17 +296,15 @@ class VolumeInteraction(wx.Panel): | @@ -296,17 +296,15 @@ class VolumeInteraction(wx.Panel): | ||
296 | p.Hide() | 296 | p.Hide() |
297 | self.aui_manager.Update() | 297 | self.aui_manager.Update() |
298 | 298 | ||
299 | - def LoadHistogram(self, pubsub_evt): | ||
300 | - histogram = pubsub_evt.data[0] | ||
301 | - init, end = pubsub_evt.data[1] | 299 | + def LoadHistogram(self, histogram, init, end): |
302 | self.clut_raycasting.SetRange((init, end)) | 300 | self.clut_raycasting.SetRange((init, end)) |
303 | self.clut_raycasting.SetHistogramArray(histogram, (init, end)) | 301 | self.clut_raycasting.SetHistogramArray(histogram, (init, end)) |
304 | 302 | ||
305 | - def RefreshPoints(self, pubsub_evt): | 303 | + def RefreshPoints(self): |
306 | self.clut_raycasting.CalculatePixelPoints() | 304 | self.clut_raycasting.CalculatePixelPoints() |
307 | self.clut_raycasting.Refresh() | 305 | self.clut_raycasting.Refresh() |
308 | 306 | ||
309 | - def _Exit(self, pubsub_evt): | 307 | + def _Exit(self): |
310 | self.aui_manager.UnInit() | 308 | self.aui_manager.UnInit() |
311 | 309 | ||
312 | 310 | ||
@@ -434,7 +432,7 @@ class VolumeToolPanel(wx.Panel): | @@ -434,7 +432,7 @@ class VolumeToolPanel(wx.Panel): | ||
434 | Publisher.subscribe(self.StatusTargetSelect, 'Disable or enable coil tracker') | 432 | Publisher.subscribe(self.StatusTargetSelect, 'Disable or enable coil tracker') |
435 | Publisher.subscribe(self.StatusObjTracker, 'Status target button') | 433 | Publisher.subscribe(self.StatusObjTracker, 'Status target button') |
436 | 434 | ||
437 | - def DisablePreset(self, pubsub_evt): | 435 | + def DisablePreset(self): |
438 | self.off_item.Check(1) | 436 | self.off_item.Check(1) |
439 | 437 | ||
440 | 438 | ||
@@ -459,12 +457,12 @@ class VolumeToolPanel(wx.Panel): | @@ -459,12 +457,12 @@ class VolumeToolPanel(wx.Panel): | ||
459 | def OnButtonSlicePlane(self, evt): | 457 | def OnButtonSlicePlane(self, evt): |
460 | self.button_slice_plane.PopupMenu(self.slice_plane_menu) | 458 | self.button_slice_plane.PopupMenu(self.slice_plane_menu) |
461 | 459 | ||
462 | - def StatusObjTracker(self, pubsub_evt): | ||
463 | - self.status_obj_tracker = pubsub_evt.data | 460 | + def StatusObjTracker(self, status): |
461 | + self.status_obj_tracker = status | ||
464 | self.StatusNavigation() | 462 | self.StatusNavigation() |
465 | 463 | ||
466 | - def StatusTargetSelect(self, pubsub_evt): | ||
467 | - self.status_target_select = pubsub_evt.data | 464 | + def StatusTargetSelect(self, status): |
465 | + self.status_target_select = status | ||
468 | self.StatusNavigation() | 466 | self.StatusNavigation() |
469 | 467 | ||
470 | def StatusNavigation(self): | 468 | def StatusNavigation(self): |
@@ -477,19 +475,18 @@ class VolumeToolPanel(wx.Panel): | @@ -477,19 +475,18 @@ class VolumeToolPanel(wx.Panel): | ||
477 | def OnButtonTarget(self, evt): | 475 | def OnButtonTarget(self, evt): |
478 | if not self.button_target.IsPressed() and evt is not False: | 476 | if not self.button_target.IsPressed() and evt is not False: |
479 | self.button_target._pressed = True | 477 | self.button_target._pressed = True |
480 | - Publisher.sendMessage('Target navigation mode', self.button_target._pressed) | 478 | + Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) |
481 | elif self.button_target.IsPressed() or evt is False: | 479 | elif self.button_target.IsPressed() or evt is False: |
482 | self.button_target._pressed = False | 480 | self.button_target._pressed = False |
483 | - Publisher.sendMessage('Target navigation mode', self.button_target._pressed) | 481 | + Publisher.sendMessage('Target navigation mode', target_mode=self.button_target._pressed) |
484 | 482 | ||
485 | def OnSavePreset(self, evt): | 483 | def OnSavePreset(self, evt): |
486 | d = wx.TextEntryDialog(self, _("Preset name")) | 484 | d = wx.TextEntryDialog(self, _("Preset name")) |
487 | if d.ShowModal() == wx.ID_OK: | 485 | if d.ShowModal() == wx.ID_OK: |
488 | preset_name = d.GetValue() | 486 | preset_name = d.GetValue() |
489 | - Publisher.sendMessage(_("Save raycasting preset"), | ||
490 | - preset_name) | 487 | + Publisher.sendMessage("Save raycasting preset", preset_name=preset_name) |
491 | 488 | ||
492 | - def __init_menus(self, pubsub_evt=None): | 489 | + def __init_menus(self): |
493 | # MENU RELATED TO RAYCASTING TYPES | 490 | # MENU RELATED TO RAYCASTING TYPES |
494 | menu = self.menu = wx.Menu() | 491 | menu = self.menu = wx.Menu() |
495 | #print "\n\n" | 492 | #print "\n\n" |
@@ -576,7 +573,7 @@ class VolumeToolPanel(wx.Panel): | @@ -576,7 +573,7 @@ class VolumeToolPanel(wx.Panel): | ||
576 | self.Fit() | 573 | self.Fit() |
577 | self.Update() | 574 | self.Update() |
578 | 575 | ||
579 | - def DisableVolumeCutMenu(self, pusub_evt): | 576 | + def DisableVolumeCutMenu(self): |
580 | self.menu.Enable(RAYCASTING_TOOLS, 0) | 577 | self.menu.Enable(RAYCASTING_TOOLS, 0) |
581 | item = ID_TO_TOOL_ITEM[self.id_cutplane] | 578 | item = ID_TO_TOOL_ITEM[self.id_cutplane] |
582 | item.Check(0) | 579 | item.Check(0) |
@@ -596,23 +593,23 @@ class VolumeToolPanel(wx.Panel): | @@ -596,23 +593,23 @@ class VolumeToolPanel(wx.Panel): | ||
596 | label = item.GetLabel() | 593 | label = item.GetLabel() |
597 | 594 | ||
598 | if not (checked): | 595 | if not (checked): |
599 | - Publisher.sendMessage('Disable plane', label) | 596 | + Publisher.sendMessage('Disable plane', plane_label=label) |
600 | else: | 597 | else: |
601 | - Publisher.sendMessage('Enable plane', label) | 598 | + Publisher.sendMessage('Enable plane', plane_label=label) |
602 | 599 | ||
603 | def OnMenuStereo(self, evt): | 600 | def OnMenuStereo(self, evt): |
604 | id = evt.GetId() | 601 | id = evt.GetId() |
605 | mode = ID_TO_STEREO_NAME[id] | 602 | mode = ID_TO_STEREO_NAME[id] |
606 | - Publisher.sendMessage('Set stereo mode', mode) | 603 | + Publisher.sendMessage('Set stereo mode', mode=mode) |
607 | 604 | ||
608 | 605 | ||
609 | - def Uncheck(self, pubsub_evt): | 606 | + def Uncheck(self): |
610 | for item in self.slice_plane_menu.GetMenuItems(): | 607 | for item in self.slice_plane_menu.GetMenuItems(): |
611 | if (item.IsChecked()): | 608 | if (item.IsChecked()): |
612 | item.Check(0) | 609 | item.Check(0) |
613 | 610 | ||
614 | - def ChangeButtonColour(self, pubsub_evt): | ||
615 | - colour = [i*255 for i in pubsub_evt.data] | 611 | + def ChangeButtonColour(self, colour): |
612 | + colour = [i*255 for i in colour] | ||
616 | self.button_colour.SetColour(colour) | 613 | self.button_colour.SetColour(colour) |
617 | 614 | ||
618 | def OnMenuRaycasting(self, evt): | 615 | def OnMenuRaycasting(self, evt): |
@@ -622,7 +619,7 @@ class VolumeToolPanel(wx.Panel): | @@ -622,7 +619,7 @@ class VolumeToolPanel(wx.Panel): | ||
622 | # Raycassting type was selected | 619 | # Raycassting type was selected |
623 | name = ID_TO_NAME[id] | 620 | name = ID_TO_NAME[id] |
624 | Publisher.sendMessage('Load raycasting preset', | 621 | Publisher.sendMessage('Load raycasting preset', |
625 | - ID_TO_NAME[id]) | 622 | + preset_name=ID_TO_NAME[id]) |
626 | # Enable or disable tools | 623 | # Enable or disable tools |
627 | if name != const.RAYCASTING_OFF_LABEL: | 624 | if name != const.RAYCASTING_OFF_LABEL: |
628 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) | 625 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) |
@@ -639,12 +636,12 @@ class VolumeToolPanel(wx.Panel): | @@ -639,12 +636,12 @@ class VolumeToolPanel(wx.Panel): | ||
639 | # i.Check(0) | 636 | # i.Check(0) |
640 | if not TOOL_STATE[id]: | 637 | if not TOOL_STATE[id]: |
641 | Publisher.sendMessage('Enable raycasting tool', | 638 | Publisher.sendMessage('Enable raycasting tool', |
642 | - [ID_TO_TOOL[id],1]) | 639 | + tool_name=ID_TO_TOOL[id], flag=1) |
643 | TOOL_STATE[id] = True | 640 | TOOL_STATE[id] = True |
644 | item.Check(1) | 641 | item.Check(1) |
645 | else: | 642 | else: |
646 | Publisher.sendMessage('Enable raycasting tool', | 643 | Publisher.sendMessage('Enable raycasting tool', |
647 | - [ID_TO_TOOL[id],0]) | 644 | + tool_name=ID_TO_TOOL[id], flag=0) |
648 | TOOL_STATE[id] = False | 645 | TOOL_STATE[id] = False |
649 | item.Check(0) | 646 | item.Check(0) |
650 | 647 | ||
@@ -655,10 +652,10 @@ class VolumeToolPanel(wx.Panel): | @@ -655,10 +652,10 @@ class VolumeToolPanel(wx.Panel): | ||
655 | self.button_view.SetBitmapSelected(bmp) | 652 | self.button_view.SetBitmapSelected(bmp) |
656 | 653 | ||
657 | Publisher.sendMessage('Set volume view angle', | 654 | Publisher.sendMessage('Set volume view angle', |
658 | - evt.GetId()) | 655 | + view=evt.GetId()) |
659 | self.Refresh() | 656 | self.Refresh() |
660 | 657 | ||
661 | def OnSelectColour(self, evt): | 658 | def OnSelectColour(self, evt): |
662 | colour = c = [i/255.0 for i in evt.GetValue()] | 659 | colour = c = [i/255.0 for i in evt.GetValue()] |
663 | - Publisher.sendMessage('Change volume viewer background colour', colour) | 660 | + Publisher.sendMessage('Change volume viewer background colour', colour=colour) |
664 | 661 |
invesalius/gui/dialogs.py
@@ -726,7 +726,7 @@ class UpdateMessageDialog(wx.Dialog): | @@ -726,7 +726,7 @@ class UpdateMessageDialog(wx.Dialog): | ||
726 | self.Close() | 726 | self.Close() |
727 | self.Destroy() | 727 | self.Destroy() |
728 | 728 | ||
729 | - def _OnCloseInV(self, pubsub_evt): | 729 | + def _OnCloseInV(self): |
730 | # Closes and destroy this dialog. | 730 | # Closes and destroy this dialog. |
731 | self.Close() | 731 | self.Close() |
732 | self.Destroy() | 732 | self.Destroy() |
@@ -1880,12 +1880,12 @@ class ClutImagedataDialog(wx.Dialog): | @@ -1880,12 +1880,12 @@ class ClutImagedataDialog(wx.Dialog): | ||
1880 | 1880 | ||
1881 | def OnClutChange(self, evt): | 1881 | def OnClutChange(self, evt): |
1882 | Publisher.sendMessage('Change colour table from background image from widget', | 1882 | Publisher.sendMessage('Change colour table from background image from widget', |
1883 | - evt.GetNodes()) | 1883 | + nodes=evt.GetNodes()) |
1884 | Publisher.sendMessage('Update window level text', | 1884 | Publisher.sendMessage('Update window level text', |
1885 | - (self.clut_widget.window_width, | ||
1886 | - self.clut_widget.window_level)) | 1885 | + window=self.clut_widget.window_width, |
1886 | + level=self.clut_widget.window_level) | ||
1887 | 1887 | ||
1888 | - def _refresh_widget(self, pubsub_evt): | 1888 | + def _refresh_widget(self): |
1889 | self.clut_widget.Refresh() | 1889 | self.clut_widget.Refresh() |
1890 | 1890 | ||
1891 | def Show(self, gen_evt=True, show=True): | 1891 | def Show(self, gen_evt=True, show=True): |
@@ -2068,7 +2068,8 @@ class MaskBooleanDialog(wx.Dialog): | @@ -2068,7 +2068,8 @@ class MaskBooleanDialog(wx.Dialog): | ||
2068 | m1 = self.mask1.GetClientData(self.mask1.GetSelection()) | 2068 | m1 = self.mask1.GetClientData(self.mask1.GetSelection()) |
2069 | m2 = self.mask2.GetClientData(self.mask2.GetSelection()) | 2069 | m2 = self.mask2.GetClientData(self.mask2.GetSelection()) |
2070 | 2070 | ||
2071 | - Publisher.sendMessage('Do boolean operation', (op, m1, m2)) | 2071 | + Publisher.sendMessage('Do boolean operation', |
2072 | + operation=op, mask1=m1, mask2=m2) | ||
2072 | Publisher.sendMessage('Reload actual slice') | 2073 | Publisher.sendMessage('Reload actual slice') |
2073 | Publisher.sendMessage('Refresh viewer') | 2074 | Publisher.sendMessage('Refresh viewer') |
2074 | 2075 | ||
@@ -2152,13 +2153,13 @@ class ReorientImageDialog(wx.Dialog): | @@ -2152,13 +2153,13 @@ class ReorientImageDialog(wx.Dialog): | ||
2152 | self.btnapply.Bind(wx.EVT_BUTTON, self.apply_reorientation) | 2153 | self.btnapply.Bind(wx.EVT_BUTTON, self.apply_reorientation) |
2153 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 2154 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
2154 | 2155 | ||
2155 | - def _update_angles(self, pubsub_evt): | ||
2156 | - anglex, angley, anglez = pubsub_evt.data | 2156 | + def _update_angles(self, angles): |
2157 | + anglex, angley, anglez = angles | ||
2157 | self.anglex.SetValue("%.3f" % np.rad2deg(anglex)) | 2158 | self.anglex.SetValue("%.3f" % np.rad2deg(anglex)) |
2158 | self.angley.SetValue("%.3f" % np.rad2deg(angley)) | 2159 | self.angley.SetValue("%.3f" % np.rad2deg(angley)) |
2159 | self.anglez.SetValue("%.3f" % np.rad2deg(anglez)) | 2160 | self.anglez.SetValue("%.3f" % np.rad2deg(anglez)) |
2160 | 2161 | ||
2161 | - def _close_dialog(self, pubsub_evt): | 2162 | + def _close_dialog(self): |
2162 | self.Destroy() | 2163 | self.Destroy() |
2163 | 2164 | ||
2164 | def apply_reorientation(self, evt): | 2165 | def apply_reorientation(self, evt): |
@@ -2167,13 +2168,13 @@ class ReorientImageDialog(wx.Dialog): | @@ -2167,13 +2168,13 @@ class ReorientImageDialog(wx.Dialog): | ||
2167 | 2168 | ||
2168 | def OnClose(self, evt): | 2169 | def OnClose(self, evt): |
2169 | self._closed = True | 2170 | self._closed = True |
2170 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_REORIENT) | ||
2171 | - Publisher.sendMessage('Enable style', const.STATE_DEFAULT) | 2171 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_REORIENT) |
2172 | + Publisher.sendMessage('Enable style', style=const.STATE_DEFAULT) | ||
2172 | self.Destroy() | 2173 | self.Destroy() |
2173 | 2174 | ||
2174 | def OnSelect(self, evt): | 2175 | def OnSelect(self, evt): |
2175 | im_code = self.interp_method.GetClientData(self.interp_method.GetSelection()) | 2176 | im_code = self.interp_method.GetClientData(self.interp_method.GetSelection()) |
2176 | - Publisher.sendMessage('Set interpolation method', im_code) | 2177 | + Publisher.sendMessage('Set interpolation method', interp_method=im_code) |
2177 | 2178 | ||
2178 | def OnSetFocus(self, evt): | 2179 | def OnSetFocus(self, evt): |
2179 | self._last_ax = self.anglex.GetValue() | 2180 | self._last_ax = self.anglex.GetValue() |
@@ -2191,7 +2192,7 @@ class ReorientImageDialog(wx.Dialog): | @@ -2191,7 +2192,7 @@ class ReorientImageDialog(wx.Dialog): | ||
2191 | self.angley.SetValue(self._last_ay) | 2192 | self.angley.SetValue(self._last_ay) |
2192 | self.anglez.SetValue(self._last_az) | 2193 | self.anglez.SetValue(self._last_az) |
2193 | return | 2194 | return |
2194 | - Publisher.sendMessage('Set reorientation angles', (ax, ay, az)) | 2195 | + Publisher.sendMessage('Set reorientation angles', angles=(ax, ay, az)) |
2195 | 2196 | ||
2196 | 2197 | ||
2197 | class ImportBitmapParameters(wx.Dialog): | 2198 | class ImportBitmapParameters(wx.Dialog): |
@@ -2350,7 +2351,7 @@ class ImportBitmapParameters(wx.Dialog): | @@ -2350,7 +2351,7 @@ class ImportBitmapParameters(wx.Dialog): | ||
2350 | values = [self.tx_name.GetValue(), orientation,\ | 2351 | values = [self.tx_name.GetValue(), orientation,\ |
2351 | self.fsp_spacing_x.GetValue(), self.fsp_spacing_y.GetValue(),\ | 2352 | self.fsp_spacing_x.GetValue(), self.fsp_spacing_y.GetValue(),\ |
2352 | self.fsp_spacing_z.GetValue(), self.interval] | 2353 | self.fsp_spacing_z.GetValue(), self.interval] |
2353 | - Publisher.sendMessage('Open bitmap files', values) | 2354 | + Publisher.sendMessage('Open bitmap files', rec_data=values) |
2354 | 2355 | ||
2355 | self.Close() | 2356 | self.Close() |
2356 | self.Destroy() | 2357 | self.Destroy() |
@@ -2759,7 +2760,7 @@ class FFillOptionsDialog(wx.Dialog): | @@ -2759,7 +2760,7 @@ class FFillOptionsDialog(wx.Dialog): | ||
2759 | def OnClose(self, evt): | 2760 | def OnClose(self, evt): |
2760 | print("ONCLOSE") | 2761 | print("ONCLOSE") |
2761 | if self.config.dlg_visible: | 2762 | if self.config.dlg_visible: |
2762 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) | 2763 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_MASK_FFILL) |
2763 | evt.Skip() | 2764 | evt.Skip() |
2764 | self.Destroy() | 2765 | self.Destroy() |
2765 | 2766 | ||
@@ -2845,7 +2846,7 @@ class SelectPartsOptionsDialog(wx.Dialog): | @@ -2845,7 +2846,7 @@ class SelectPartsOptionsDialog(wx.Dialog): | ||
2845 | 2846 | ||
2846 | def OnClose(self, evt): | 2847 | def OnClose(self, evt): |
2847 | if self.config.dlg_visible: | 2848 | if self.config.dlg_visible: |
2848 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_SELECT_MASK_PARTS) | 2849 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_SELECT_MASK_PARTS) |
2849 | evt.Skip() | 2850 | evt.Skip() |
2850 | self.Destroy() | 2851 | self.Destroy() |
2851 | 2852 | ||
@@ -3048,7 +3049,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): | @@ -3048,7 +3049,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): | ||
3048 | 3049 | ||
3049 | def OnClose(self, evt): | 3050 | def OnClose(self, evt): |
3050 | if self.config.dlg_visible: | 3051 | if self.config.dlg_visible: |
3051 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) | 3052 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_MASK_FFILL) |
3052 | evt.Skip() | 3053 | evt.Skip() |
3053 | self.Destroy() | 3054 | self.Destroy() |
3054 | 3055 | ||
@@ -3068,14 +3069,8 @@ class CropOptionsDialog(wx.Dialog): | @@ -3068,14 +3069,8 @@ class CropOptionsDialog(wx.Dialog): | ||
3068 | 3069 | ||
3069 | self._init_gui() | 3070 | self._init_gui() |
3070 | 3071 | ||
3071 | - def UpdateValues(self, pubsub_evt): | ||
3072 | - | ||
3073 | - if type(pubsub_evt) == list: | ||
3074 | - data = pubsub_evt | ||
3075 | - else: | ||
3076 | - data = pubsub_evt.data | ||
3077 | - | ||
3078 | - xi, xf, yi, yf, zi, zf = data | 3072 | + def UpdateValues(self, limits): |
3073 | + xi, xf, yi, yf, zi, zf = limits | ||
3079 | 3074 | ||
3080 | self.tx_axial_i.SetValue(str(zi)) | 3075 | self.tx_axial_i.SetValue(str(zi)) |
3081 | self.tx_axial_f.SetValue(str(zf)) | 3076 | self.tx_axial_f.SetValue(str(zf)) |
@@ -3170,12 +3165,12 @@ class CropOptionsDialog(wx.Dialog): | @@ -3170,12 +3165,12 @@ class CropOptionsDialog(wx.Dialog): | ||
3170 | def OnOk(self, evt): | 3165 | def OnOk(self, evt): |
3171 | self.config.dlg_visible = False | 3166 | self.config.dlg_visible = False |
3172 | Publisher.sendMessage('Crop mask') | 3167 | Publisher.sendMessage('Crop mask') |
3173 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_CROP_MASK) | 3168 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_CROP_MASK) |
3174 | evt.Skip() | 3169 | evt.Skip() |
3175 | 3170 | ||
3176 | def OnClose(self, evt): | 3171 | def OnClose(self, evt): |
3177 | self.config.dlg_visible = False | 3172 | self.config.dlg_visible = False |
3178 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_CROP_MASK) | 3173 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_CROP_MASK) |
3179 | evt.Skip() | 3174 | evt.Skip() |
3180 | self.Destroy() | 3175 | self.Destroy() |
3181 | 3176 | ||
@@ -3260,14 +3255,14 @@ class FillHolesAutoDialog(wx.Dialog): | @@ -3260,14 +3255,14 @@ class FillHolesAutoDialog(wx.Dialog): | ||
3260 | conn = self.panel3dcon.GetConnSelected() | 3255 | conn = self.panel3dcon.GetConnSelected() |
3261 | orientation = 'VOLUME' | 3256 | orientation = 'VOLUME' |
3262 | 3257 | ||
3263 | - data = { | 3258 | + parameters = { |
3264 | 'target': target, | 3259 | 'target': target, |
3265 | 'conn': conn, | 3260 | 'conn': conn, |
3266 | 'orientation': orientation, | 3261 | 'orientation': orientation, |
3267 | 'size': self.spin_size.GetValue(), | 3262 | 'size': self.spin_size.GetValue(), |
3268 | } | 3263 | } |
3269 | 3264 | ||
3270 | - Publisher.sendMessage("Fill holes automatically", data) | 3265 | + Publisher.sendMessage("Fill holes automatically", parameters=parameters) |
3271 | 3266 | ||
3272 | 3267 | ||
3273 | def OnBtnClose(self, evt): | 3268 | def OnBtnClose(self, evt): |
invesalius/gui/dicom_preview_panel.py
@@ -686,8 +686,8 @@ class DicomPreviewSlice(wx.Panel): | @@ -686,8 +686,8 @@ class DicomPreviewSlice(wx.Panel): | ||
686 | self.selected_dicom = self.selected_panel.dicom_info | 686 | self.selected_dicom = self.selected_panel.dicom_info |
687 | self.GetEventHandler().ProcessEvent(my_evt) | 687 | self.GetEventHandler().ProcessEvent(my_evt) |
688 | 688 | ||
689 | - Publisher.sendMessage("Selected Import Images", [self.first_selection, \ | ||
690 | - self.last_selection]) | 689 | + Publisher.sendMessage("Selected Import Images", |
690 | + selection=(self.first_selection, self.last_selection)) | ||
691 | 691 | ||
692 | def OnScroll(self, evt=None): | 692 | def OnScroll(self, evt=None): |
693 | if evt: | 693 | if evt: |
invesalius/gui/frame.py
@@ -248,14 +248,14 @@ class Frame(wx.Frame): | @@ -248,14 +248,14 @@ class Frame(wx.Frame): | ||
248 | # TODO: Allow saving and restoring perspectives | 248 | # TODO: Allow saving and restoring perspectives |
249 | self.perspective_all = aui_manager.SavePerspective() | 249 | self.perspective_all = aui_manager.SavePerspective() |
250 | 250 | ||
251 | - def _BeginBusyCursor(self, pubsub_evt): | 251 | + def _BeginBusyCursor(self): |
252 | """ | 252 | """ |
253 | Start busy cursor. | 253 | Start busy cursor. |
254 | Note: _EndBusyCursor should be called after. | 254 | Note: _EndBusyCursor should be called after. |
255 | """ | 255 | """ |
256 | wx.BeginBusyCursor() | 256 | wx.BeginBusyCursor() |
257 | 257 | ||
258 | - def _EndBusyCursor(self, pubsub_evt): | 258 | + def _EndBusyCursor(self): |
259 | """ | 259 | """ |
260 | End busy cursor. | 260 | End busy cursor. |
261 | Note: _BeginBusyCursor should have been called previously. | 261 | Note: _BeginBusyCursor should have been called previously. |
@@ -266,7 +266,7 @@ class Frame(wx.Frame): | @@ -266,7 +266,7 @@ class Frame(wx.Frame): | ||
266 | #no matching wxBeginBusyCursor() for wxEndBusyCursor() | 266 | #no matching wxBeginBusyCursor() for wxEndBusyCursor() |
267 | pass | 267 | pass |
268 | 268 | ||
269 | - def _Exit(self, pubsub_evt): | 269 | + def _Exit(self): |
270 | """ | 270 | """ |
271 | Exit InVesalius. | 271 | Exit InVesalius. |
272 | """ | 272 | """ |
@@ -275,7 +275,7 @@ class Frame(wx.Frame): | @@ -275,7 +275,7 @@ class Frame(wx.Frame): | ||
275 | if hasattr(sys,"frozen") and sys.platform == 'darwin': | 275 | if hasattr(sys,"frozen") and sys.platform == 'darwin': |
276 | sys.exit(0) | 276 | sys.exit(0) |
277 | 277 | ||
278 | - def _HideContentPanel(self, pubsub_evt): | 278 | + def _HideContentPanel(self): |
279 | """ | 279 | """ |
280 | Hide data and tasks panels. | 280 | Hide data and tasks panels. |
281 | """ | 281 | """ |
@@ -284,7 +284,7 @@ class Frame(wx.Frame): | @@ -284,7 +284,7 @@ class Frame(wx.Frame): | ||
284 | aui_manager.GetPane("Tasks").Show(1) | 284 | aui_manager.GetPane("Tasks").Show(1) |
285 | aui_manager.Update() | 285 | aui_manager.Update() |
286 | 286 | ||
287 | - def _HideImportPanel(self, evt_pubsub): | 287 | + def _HideImportPanel(self): |
288 | """ | 288 | """ |
289 | Hide import panel and show tasks. | 289 | Hide import panel and show tasks. |
290 | """ | 290 | """ |
@@ -294,39 +294,37 @@ class Frame(wx.Frame): | @@ -294,39 +294,37 @@ class Frame(wx.Frame): | ||
294 | aui_manager.GetPane("Tasks").Show(1) | 294 | aui_manager.GetPane("Tasks").Show(1) |
295 | aui_manager.Update() | 295 | aui_manager.Update() |
296 | 296 | ||
297 | - def _HideTask(self, pubsub_evt): | 297 | + def _HideTask(self): |
298 | """ | 298 | """ |
299 | Hide task panel. | 299 | Hide task panel. |
300 | """ | 300 | """ |
301 | self.aui_manager.GetPane("Tasks").Hide() | 301 | self.aui_manager.GetPane("Tasks").Hide() |
302 | self.aui_manager.Update() | 302 | self.aui_manager.Update() |
303 | 303 | ||
304 | - def _SetProjectName(self, pubsub_evt): | 304 | + def _SetProjectName(self, proj_name=""): |
305 | """ | 305 | """ |
306 | Set project name into frame's title. | 306 | Set project name into frame's title. |
307 | """ | 307 | """ |
308 | - proj_name = pubsub_evt.data | ||
309 | - | ||
310 | if not(proj_name): | 308 | if not(proj_name): |
311 | self.SetTitle("InVesalius 3") | 309 | self.SetTitle("InVesalius 3") |
312 | else: | 310 | else: |
313 | self.SetTitle("%s - InVesalius 3"%(proj_name)) | 311 | self.SetTitle("%s - InVesalius 3"%(proj_name)) |
314 | 312 | ||
315 | - def _ShowContentPanel(self, evt_pubsub): | 313 | + def _ShowContentPanel(self): |
316 | """ | 314 | """ |
317 | Show viewers and task, hide import panel. | 315 | Show viewers and task, hide import panel. |
318 | """ | 316 | """ |
319 | Publisher.sendMessage("Set layout button full") | 317 | Publisher.sendMessage("Set layout button full") |
320 | aui_manager = self.aui_manager | 318 | aui_manager = self.aui_manager |
321 | aui_manager.GetPane("Import").Show(0) | 319 | aui_manager.GetPane("Import").Show(0) |
322 | - | 320 | + |
323 | aui_manager.GetPane("ImportBMP").Show(0) | 321 | aui_manager.GetPane("ImportBMP").Show(0) |
324 | 322 | ||
325 | aui_manager.GetPane("Data").Show(1) | 323 | aui_manager.GetPane("Data").Show(1) |
326 | aui_manager.GetPane("Tasks").Show(1) | 324 | aui_manager.GetPane("Tasks").Show(1) |
327 | aui_manager.Update() | 325 | aui_manager.Update() |
328 | 326 | ||
329 | - def _ShowImportNetwork(self, evt_pubsub): | 327 | + def _ShowImportNetwork(self): |
330 | """ | 328 | """ |
331 | Show viewers and task, hide import panel. | 329 | Show viewers and task, hide import panel. |
332 | """ | 330 | """ |
@@ -338,7 +336,7 @@ class Frame(wx.Frame): | @@ -338,7 +336,7 @@ class Frame(wx.Frame): | ||
338 | aui_manager.GetPane("Import").Show(0) | 336 | aui_manager.GetPane("Import").Show(0) |
339 | aui_manager.Update() | 337 | aui_manager.Update() |
340 | 338 | ||
341 | - def _ShowImportBitmap(self, evt_pubsub): | 339 | + def _ShowImportBitmap(self): |
342 | """ | 340 | """ |
343 | Show viewers and task, hide import panel. | 341 | Show viewers and task, hide import panel. |
344 | """ | 342 | """ |
@@ -350,15 +348,14 @@ class Frame(wx.Frame): | @@ -350,15 +348,14 @@ class Frame(wx.Frame): | ||
350 | aui_manager.GetPane("Import").Show(0) | 348 | aui_manager.GetPane("Import").Show(0) |
351 | aui_manager.Update() | 349 | aui_manager.Update() |
352 | 350 | ||
353 | - def _ShowHelpMessage(self, evt_pubsub): | 351 | + def _ShowHelpMessage(self, message): |
354 | aui_manager = self.aui_manager | 352 | aui_manager = self.aui_manager |
355 | pos = aui_manager.GetPane("Data").window.GetScreenPosition() | 353 | pos = aui_manager.GetPane("Data").window.GetScreenPosition() |
356 | - msg = evt_pubsub.data | ||
357 | - self.mw = MessageWatershed(self, msg) | 354 | + self.mw = MessageWatershed(self, message) |
358 | self.mw.SetPosition(pos) | 355 | self.mw.SetPosition(pos) |
359 | self.mw.Show() | 356 | self.mw.Show() |
360 | 357 | ||
361 | - def _ShowImportPanel(self, evt_pubsub): | 358 | + def _ShowImportPanel(self): |
362 | """ | 359 | """ |
363 | Show only DICOM import panel. as dicom """ | 360 | Show only DICOM import panel. as dicom """ |
364 | Publisher.sendMessage("Set layout button data only") | 361 | Publisher.sendMessage("Set layout button data only") |
@@ -368,14 +365,14 @@ class Frame(wx.Frame): | @@ -368,14 +365,14 @@ class Frame(wx.Frame): | ||
368 | aui_manager.GetPane("Tasks").Show(0) | 365 | aui_manager.GetPane("Tasks").Show(0) |
369 | aui_manager.Update() | 366 | aui_manager.Update() |
370 | 367 | ||
371 | - def _ShowTask(self, pubsub_evt): | 368 | + def _ShowTask(self): |
372 | """ | 369 | """ |
373 | Show task panel. | 370 | Show task panel. |
374 | """ | 371 | """ |
375 | self.aui_manager.GetPane("Tasks").Show() | 372 | self.aui_manager.GetPane("Tasks").Show() |
376 | self.aui_manager.Update() | 373 | self.aui_manager.Update() |
377 | 374 | ||
378 | - def _UpdateAUI(self, pubsub_evt): | 375 | + def _UpdateAUI(self): |
379 | """ | 376 | """ |
380 | Refresh AUI panels/data. | 377 | Refresh AUI panels/data. |
381 | """ | 378 | """ |
@@ -457,19 +454,19 @@ class Frame(wx.Frame): | @@ -457,19 +454,19 @@ class Frame(wx.Frame): | ||
457 | self.OnReorientImg() | 454 | self.OnReorientImg() |
458 | 455 | ||
459 | elif id == const.ID_THRESHOLD_SEGMENTATION: | 456 | elif id == const.ID_THRESHOLD_SEGMENTATION: |
460 | - Publisher.sendMessage("Show panel", const.ID_THRESHOLD_SEGMENTATION) | 457 | + Publisher.sendMessage("Show panel", panel_id=const.ID_THRESHOLD_SEGMENTATION) |
461 | Publisher.sendMessage('Disable actual style') | 458 | Publisher.sendMessage('Disable actual style') |
462 | - Publisher.sendMessage('Enable style', const.STATE_DEFAULT) | 459 | + Publisher.sendMessage('Enable style', style=const.STATE_DEFAULT) |
463 | 460 | ||
464 | elif id == const.ID_MANUAL_SEGMENTATION: | 461 | elif id == const.ID_MANUAL_SEGMENTATION: |
465 | - Publisher.sendMessage("Show panel", const.ID_MANUAL_SEGMENTATION) | 462 | + Publisher.sendMessage("Show panel", panel_id=const.ID_MANUAL_SEGMENTATION) |
466 | Publisher.sendMessage('Disable actual style') | 463 | Publisher.sendMessage('Disable actual style') |
467 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_EDITOR) | 464 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_EDITOR) |
468 | 465 | ||
469 | elif id == const.ID_WATERSHED_SEGMENTATION: | 466 | elif id == const.ID_WATERSHED_SEGMENTATION: |
470 | - Publisher.sendMessage("Show panel", const.ID_WATERSHED_SEGMENTATION) | 467 | + Publisher.sendMessage("Show panel", panel_id=const.ID_WATERSHED_SEGMENTATION) |
471 | Publisher.sendMessage('Disable actual style') | 468 | Publisher.sendMessage('Disable actual style') |
472 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_WATERSHED) | 469 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_WATERSHED) |
473 | 470 | ||
474 | elif id == const.ID_FLOODFILL_MASK: | 471 | elif id == const.ID_FLOODFILL_MASK: |
475 | self.OnFillHolesManually() | 472 | self.OnFillHolesManually() |
@@ -507,13 +504,13 @@ class Frame(wx.Frame): | @@ -507,13 +504,13 @@ class Frame(wx.Frame): | ||
507 | Publisher.sendMessage('New mask from shortcut') | 504 | Publisher.sendMessage('New mask from shortcut') |
508 | 505 | ||
509 | def OnInterpolatedSlices(self, status): | 506 | def OnInterpolatedSlices(self, status): |
510 | - Publisher.sendMessage('Set interpolated slices', status) | 507 | + Publisher.sendMessage('Set interpolated slices', flag=status) |
511 | 508 | ||
512 | def OnNavigationMode(self, status): | 509 | def OnNavigationMode(self, status): |
513 | if status and self._show_navigator_message and sys.platform != 'win32': | 510 | if status and self._show_navigator_message and sys.platform != 'win32': |
514 | wx.MessageBox(_('Currently the Navigation mode is only working on Windows'), 'Info', wx.OK | wx.ICON_INFORMATION) | 511 | wx.MessageBox(_('Currently the Navigation mode is only working on Windows'), 'Info', wx.OK | wx.ICON_INFORMATION) |
515 | self._show_navigator_message = False | 512 | self._show_navigator_message = False |
516 | - Publisher.sendMessage('Set navigation mode', status) | 513 | + Publisher.sendMessage('Set navigation mode', status=status) |
517 | if not status: | 514 | if not status: |
518 | Publisher.sendMessage('Remove sensors ID') | 515 | Publisher.sendMessage('Remove sensors ID') |
519 | 516 | ||
@@ -554,7 +551,7 @@ class Frame(wx.Frame): | @@ -554,7 +551,7 @@ class Frame(wx.Frame): | ||
554 | ses.Session().WriteSessionFile() | 551 | ses.Session().WriteSessionFile() |
555 | 552 | ||
556 | Publisher.sendMessage('Remove Volume') | 553 | Publisher.sendMessage('Remove Volume') |
557 | - Publisher.sendMessage('Reset Reaycasting') | 554 | + Publisher.sendMessage('Reset Raycasting') |
558 | Publisher.sendMessage('Update Slice Interpolation') | 555 | Publisher.sendMessage('Update Slice Interpolation') |
559 | Publisher.sendMessage('Update Slice Interpolation MenuBar') | 556 | Publisher.sendMessage('Update Slice Interpolation MenuBar') |
560 | Publisher.sendMessage('Update Navigation Mode MenuBar') | 557 | Publisher.sendMessage('Update Navigation Mode MenuBar') |
@@ -570,7 +567,7 @@ class Frame(wx.Frame): | @@ -570,7 +567,7 @@ class Frame(wx.Frame): | ||
570 | """ | 567 | """ |
571 | Save project. | 568 | Save project. |
572 | """ | 569 | """ |
573 | - Publisher.sendMessage('Show save dialog', False) | 570 | + Publisher.sendMessage('Show save dialog', save_as=False) |
574 | 571 | ||
575 | def ShowGettingStarted(self): | 572 | def ShowGettingStarted(self): |
576 | """ | 573 | """ |
@@ -596,7 +593,7 @@ class Frame(wx.Frame): | @@ -596,7 +593,7 @@ class Frame(wx.Frame): | ||
596 | """ | 593 | """ |
597 | Show import Analyze, NiFTI1 or PAR/REC dialog. | 594 | Show import Analyze, NiFTI1 or PAR/REC dialog. |
598 | """ | 595 | """ |
599 | - Publisher.sendMessage('Show import other files dialog', id_file) | 596 | + Publisher.sendMessage('Show import other files dialog', id_type=id_file) |
600 | 597 | ||
601 | def ShowRetrieveDicomPanel(self): | 598 | def ShowRetrieveDicomPanel(self): |
602 | Publisher.sendMessage('Show retrieve dicom panel') | 599 | Publisher.sendMessage('Show retrieve dicom panel') |
@@ -611,20 +608,20 @@ class Frame(wx.Frame): | @@ -611,20 +608,20 @@ class Frame(wx.Frame): | ||
611 | """ | 608 | """ |
612 | Show save as dialog. | 609 | Show save as dialog. |
613 | """ | 610 | """ |
614 | - Publisher.sendMessage('Show save dialog', True) | 611 | + Publisher.sendMessage('Show save dialog', save_as=True) |
615 | 612 | ||
616 | def ShowBitmapImporter(self): | 613 | def ShowBitmapImporter(self): |
617 | """ | 614 | """ |
618 | Tiff, BMP, JPEG and PNG | 615 | Tiff, BMP, JPEG and PNG |
619 | """ | 616 | """ |
620 | - Publisher.sendMessage('Show bitmap dialog', True) | 617 | + Publisher.sendMessage('Show bitmap dialog') |
621 | 618 | ||
622 | def FlipVolume(self, axis): | 619 | def FlipVolume(self, axis): |
623 | - Publisher.sendMessage('Flip volume', axis) | 620 | + Publisher.sendMessage('Flip volume', axis=axis) |
624 | Publisher.sendMessage('Reload actual slice') | 621 | Publisher.sendMessage('Reload actual slice') |
625 | 622 | ||
626 | def SwapAxes(self, axes): | 623 | def SwapAxes(self, axes): |
627 | - Publisher.sendMessage('Swap volume axes', axes) | 624 | + Publisher.sendMessage('Swap volume axes', axes=axes) |
628 | Publisher.sendMessage('Update scroll') | 625 | Publisher.sendMessage('Update scroll') |
629 | Publisher.sendMessage('Reload actual slice') | 626 | Publisher.sendMessage('Reload actual slice') |
630 | 627 | ||
@@ -642,31 +639,31 @@ class Frame(wx.Frame): | @@ -642,31 +639,31 @@ class Frame(wx.Frame): | ||
642 | Publisher.sendMessage('Reload actual slice') | 639 | Publisher.sendMessage('Reload actual slice') |
643 | 640 | ||
644 | def OnReorientImg(self): | 641 | def OnReorientImg(self): |
645 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_REORIENT) | 642 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_REORIENT) |
646 | rdlg = dlg.ReorientImageDialog() | 643 | rdlg = dlg.ReorientImageDialog() |
647 | rdlg.Show() | 644 | rdlg.Show() |
648 | 645 | ||
649 | def OnFillHolesManually(self): | 646 | def OnFillHolesManually(self): |
650 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_MASK_FFILL) | 647 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_MASK_FFILL) |
651 | 648 | ||
652 | def OnFillHolesAutomatically(self): | 649 | def OnFillHolesAutomatically(self): |
653 | fdlg = dlg.FillHolesAutoDialog(_(u"Fill holes automatically")) | 650 | fdlg = dlg.FillHolesAutoDialog(_(u"Fill holes automatically")) |
654 | fdlg.Show() | 651 | fdlg.Show() |
655 | 652 | ||
656 | def OnRemoveMaskParts(self): | 653 | def OnRemoveMaskParts(self): |
657 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_REMOVE_MASK_PARTS) | 654 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_REMOVE_MASK_PARTS) |
658 | 655 | ||
659 | def OnSelectMaskParts(self): | 656 | def OnSelectMaskParts(self): |
660 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_SELECT_MASK_PARTS) | 657 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_SELECT_MASK_PARTS) |
661 | 658 | ||
662 | def OnFFillSegmentation(self): | 659 | def OnFFillSegmentation(self): |
663 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_FFILL_SEGMENTATION) | 660 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_FFILL_SEGMENTATION) |
664 | 661 | ||
665 | def OnInterpolatedSlices(self, status): | 662 | def OnInterpolatedSlices(self, status): |
666 | - Publisher.sendMessage('Set interpolated slices', status) | ||
667 | - | 663 | + Publisher.sendMessage('Set interpolated slices', flag=status) |
664 | + | ||
668 | def OnCropMask(self): | 665 | def OnCropMask(self): |
669 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_CROP_MASK) | 666 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_CROP_MASK) |
670 | 667 | ||
671 | # ------------------------------------------------------------------ | 668 | # ------------------------------------------------------------------ |
672 | # ------------------------------------------------------------------ | 669 | # ------------------------------------------------------------------ |
@@ -959,20 +956,19 @@ class MenuBar(wx.MenuBar): | @@ -959,20 +956,19 @@ class MenuBar(wx.MenuBar): | ||
959 | else: | 956 | else: |
960 | return False | 957 | return False |
961 | 958 | ||
962 | - def OnUpdateSliceInterpolation(self, pubsub_evt): | 959 | + def OnUpdateSliceInterpolation(self): |
963 | v = self.SliceInterpolationStatus() | 960 | v = self.SliceInterpolationStatus() |
964 | self.view_menu.Check(const.ID_VIEW_INTERPOLATED, v) | 961 | self.view_menu.Check(const.ID_VIEW_INTERPOLATED, v) |
965 | 962 | ||
966 | - def OnUpdateNavigationMode(self, pubsub_evt): | 963 | + def OnUpdateNavigationMode(self): |
967 | v = self.NavigationModeStatus() | 964 | v = self.NavigationModeStatus() |
968 | self.mode_menu.Check(const.ID_MODE_NAVIGATION, v) | 965 | self.mode_menu.Check(const.ID_MODE_NAVIGATION, v) |
969 | 966 | ||
970 | - def OnEnableState(self, pubsub_evt): | 967 | + def OnEnableState(self, state): |
971 | """ | 968 | """ |
972 | Based on given state, enables or disables menu items which | 969 | Based on given state, enables or disables menu items which |
973 | depend if project is open or not. | 970 | depend if project is open or not. |
974 | """ | 971 | """ |
975 | - state = pubsub_evt.data | ||
976 | if state: | 972 | if state: |
977 | self.SetStateProjectOpen() | 973 | self.SetStateProjectOpen() |
978 | else: | 974 | else: |
@@ -992,41 +988,38 @@ class MenuBar(wx.MenuBar): | @@ -992,41 +988,38 @@ class MenuBar(wx.MenuBar): | ||
992 | for item in self.enable_items: | 988 | for item in self.enable_items: |
993 | self.Enable(item, True) | 989 | self.Enable(item, True) |
994 | 990 | ||
995 | - def OnEnableUndo(self, pubsub_evt): | ||
996 | - value = pubsub_evt.data | 991 | + def OnEnableUndo(self, value): |
997 | if value: | 992 | if value: |
998 | self.FindItemById(wx.ID_UNDO).Enable(True) | 993 | self.FindItemById(wx.ID_UNDO).Enable(True) |
999 | else: | 994 | else: |
1000 | self.FindItemById(wx.ID_UNDO).Enable(False) | 995 | self.FindItemById(wx.ID_UNDO).Enable(False) |
1001 | 996 | ||
1002 | - def OnEnableRedo(self, pubsub_evt): | ||
1003 | - value = pubsub_evt.data | 997 | + def OnEnableRedo(self, value): |
1004 | if value: | 998 | if value: |
1005 | self.FindItemById(wx.ID_REDO).Enable(True) | 999 | self.FindItemById(wx.ID_REDO).Enable(True) |
1006 | else: | 1000 | else: |
1007 | self.FindItemById(wx.ID_REDO).Enable(False) | 1001 | self.FindItemById(wx.ID_REDO).Enable(False) |
1008 | 1002 | ||
1009 | - def OnEnableNavigation(self, pubsub_evt): | 1003 | + def OnEnableNavigation(self, status): |
1010 | """ | 1004 | """ |
1011 | Disable mode menu when navigation is on. | 1005 | Disable mode menu when navigation is on. |
1012 | - :param pubsub_evt: Navigation status | 1006 | + :param status: Navigation status |
1013 | """ | 1007 | """ |
1014 | - value = pubsub_evt.data | 1008 | + value = status |
1015 | if value: | 1009 | if value: |
1016 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(False) | 1010 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(False) |
1017 | else: | 1011 | else: |
1018 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(True) | 1012 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(True) |
1019 | 1013 | ||
1020 | - def OnAddMask(self, pubsub_evt): | 1014 | + def OnAddMask(self, mask): |
1021 | self.num_masks += 1 | 1015 | self.num_masks += 1 |
1022 | self.bool_op_menu.Enable(self.num_masks >= 2) | 1016 | self.bool_op_menu.Enable(self.num_masks >= 2) |
1023 | 1017 | ||
1024 | - def OnRemoveMasks(self, pubsub_evt): | ||
1025 | - self.num_masks -= len(pubsub_evt.data) | 1018 | + def OnRemoveMasks(self, mask_indexes): |
1019 | + self.num_masks -= len(mask_indexes) | ||
1026 | self.bool_op_menu.Enable(self.num_masks >= 2) | 1020 | self.bool_op_menu.Enable(self.num_masks >= 2) |
1027 | 1021 | ||
1028 | - def OnShowMask(self, pubsub_evt): | ||
1029 | - index, value = pubsub_evt.data | 1022 | + def OnShowMask(self, index, value): |
1030 | self.clean_mask_menu.Enable(value) | 1023 | self.clean_mask_menu.Enable(value) |
1031 | self.crop_mask_menu.Enable(value) | 1024 | self.crop_mask_menu.Enable(value) |
1032 | 1025 | ||
@@ -1054,7 +1047,7 @@ class ProgressBar(wx.Gauge): | @@ -1054,7 +1047,7 @@ class ProgressBar(wx.Gauge): | ||
1054 | sub = Publisher.subscribe | 1047 | sub = Publisher.subscribe |
1055 | sub(self._Layout, 'ProgressBar Reposition') | 1048 | sub(self._Layout, 'ProgressBar Reposition') |
1056 | 1049 | ||
1057 | - def _Layout(self, evt_pubsub=None): | 1050 | + def _Layout(self): |
1058 | """ | 1051 | """ |
1059 | Compute new size and position, according to parent resize | 1052 | Compute new size and position, according to parent resize |
1060 | """ | 1053 | """ |
@@ -1104,12 +1097,11 @@ class StatusBar(wx.StatusBar): | @@ -1104,12 +1097,11 @@ class StatusBar(wx.StatusBar): | ||
1104 | sub(self._SetProgressValue, 'Update status in GUI') | 1097 | sub(self._SetProgressValue, 'Update status in GUI') |
1105 | sub(self._SetProgressLabel, 'Update status text in GUI') | 1098 | sub(self._SetProgressLabel, 'Update status text in GUI') |
1106 | 1099 | ||
1107 | - def _SetProgressValue(self, pubsub_evt): | 1100 | + def _SetProgressValue(self, value, label): |
1108 | """ | 1101 | """ |
1109 | Set both percentage value in gauge and text progress label in | 1102 | Set both percentage value in gauge and text progress label in |
1110 | status. | 1103 | status. |
1111 | """ | 1104 | """ |
1112 | - value, label = pubsub_evt.data | ||
1113 | self.progress_bar.SetPercentage(value) | 1105 | self.progress_bar.SetPercentage(value) |
1114 | self.SetStatusText(label, 0) | 1106 | self.SetStatusText(label, 0) |
1115 | if (int(value) >= 99): | 1107 | if (int(value) >= 99): |
@@ -1123,11 +1115,10 @@ class StatusBar(wx.StatusBar): | @@ -1123,11 +1115,10 @@ class StatusBar(wx.StatusBar): | ||
1123 | except(wx._core.PyAssertionError): | 1115 | except(wx._core.PyAssertionError): |
1124 | utils.debug("wx._core.PyAssertionError") | 1116 | utils.debug("wx._core.PyAssertionError") |
1125 | 1117 | ||
1126 | - def _SetProgressLabel(self, pubsub_evt): | 1118 | + def _SetProgressLabel(self, label): |
1127 | """ | 1119 | """ |
1128 | Set text progress label. | 1120 | Set text progress label. |
1129 | """ | 1121 | """ |
1130 | - label = pubsub_evt.data | ||
1131 | self.SetStatusText(label, 0) | 1122 | self.SetStatusText(label, 0) |
1132 | 1123 | ||
1133 | # ------------------------------------------------------------------ | 1124 | # ------------------------------------------------------------------ |
@@ -1262,12 +1253,11 @@ class ProjectToolBar(AuiToolBar): | @@ -1262,12 +1253,11 @@ class ProjectToolBar(AuiToolBar): | ||
1262 | # "Print medical image...", | 1253 | # "Print medical image...", |
1263 | # BMP_PRINT) | 1254 | # BMP_PRINT) |
1264 | 1255 | ||
1265 | - def _EnableState(self, pubsub_evt): | 1256 | + def _EnableState(self, state): |
1266 | """ | 1257 | """ |
1267 | Based on given state, enable or disable menu items which | 1258 | Based on given state, enable or disable menu items which |
1268 | depend if project is open or not. | 1259 | depend if project is open or not. |
1269 | """ | 1260 | """ |
1270 | - state = pubsub_evt.data | ||
1271 | if state: | 1261 | if state: |
1272 | self.SetStateProjectOpen() | 1262 | self.SetStateProjectOpen() |
1273 | else: | 1263 | else: |
@@ -1445,19 +1435,18 @@ class ObjectToolBar(AuiToolBar): | @@ -1445,19 +1435,18 @@ class ObjectToolBar(AuiToolBar): | ||
1445 | # bitmap = BMP_ANNOTATE, | 1435 | # bitmap = BMP_ANNOTATE, |
1446 | # kind = wx.ITEM_CHECK) | 1436 | # kind = wx.ITEM_CHECK) |
1447 | 1437 | ||
1448 | - def _EnableState(self, pubsub_evt): | 1438 | + def _EnableState(self, state): |
1449 | """ | 1439 | """ |
1450 | Based on given state, enable or disable menu items which | 1440 | Based on given state, enable or disable menu items which |
1451 | depend if project is open or not. | 1441 | depend if project is open or not. |
1452 | """ | 1442 | """ |
1453 | - state = pubsub_evt.data | ||
1454 | if state: | 1443 | if state: |
1455 | self.SetStateProjectOpen() | 1444 | self.SetStateProjectOpen() |
1456 | else: | 1445 | else: |
1457 | self.SetStateProjectClose() | 1446 | self.SetStateProjectClose() |
1458 | self.Refresh() | 1447 | self.Refresh() |
1459 | 1448 | ||
1460 | - def _UntoggleAllItems(self, pubsub_evt=None): | 1449 | + def _UntoggleAllItems(self): |
1461 | """ | 1450 | """ |
1462 | Untoggle all items on toolbar. | 1451 | Untoggle all items on toolbar. |
1463 | """ | 1452 | """ |
@@ -1467,14 +1456,14 @@ class ObjectToolBar(AuiToolBar): | @@ -1467,14 +1456,14 @@ class ObjectToolBar(AuiToolBar): | ||
1467 | self.ToggleTool(id, False) | 1456 | self.ToggleTool(id, False) |
1468 | self.Refresh() | 1457 | self.Refresh() |
1469 | 1458 | ||
1470 | - def _ToggleLinearMeasure(self, pubsub_evt): | 1459 | + def _ToggleLinearMeasure(self): |
1471 | """ | 1460 | """ |
1472 | Force measure distance tool to be toggled and bind pubsub | 1461 | Force measure distance tool to be toggled and bind pubsub |
1473 | events to other classes whici are interested on this. | 1462 | events to other classes whici are interested on this. |
1474 | """ | 1463 | """ |
1475 | id = const.STATE_MEASURE_DISTANCE | 1464 | id = const.STATE_MEASURE_DISTANCE |
1476 | self.ToggleTool(id, True) | 1465 | self.ToggleTool(id, True) |
1477 | - Publisher.sendMessage('Enable style', id) | 1466 | + Publisher.sendMessage('Enable style', style=id) |
1478 | Publisher.sendMessage('Untoggle slice toolbar items') | 1467 | Publisher.sendMessage('Untoggle slice toolbar items') |
1479 | for item in const.TOOL_STATES: | 1468 | for item in const.TOOL_STATES: |
1480 | state = self.GetToolToggled(item) | 1469 | state = self.GetToolToggled(item) |
@@ -1482,14 +1471,14 @@ class ObjectToolBar(AuiToolBar): | @@ -1482,14 +1471,14 @@ class ObjectToolBar(AuiToolBar): | ||
1482 | self.ToggleTool(item, False) | 1471 | self.ToggleTool(item, False) |
1483 | 1472 | ||
1484 | 1473 | ||
1485 | - def _ToggleAngularMeasure(self, pubsub_evt): | 1474 | + def _ToggleAngularMeasure(self): |
1486 | """ | 1475 | """ |
1487 | Force measure angle tool to be toggled and bind pubsub | 1476 | Force measure angle tool to be toggled and bind pubsub |
1488 | events to other classes which are interested on this. | 1477 | events to other classes which are interested on this. |
1489 | """ | 1478 | """ |
1490 | id = const.STATE_MEASURE_ANGLE | 1479 | id = const.STATE_MEASURE_ANGLE |
1491 | self.ToggleTool(id, True) | 1480 | self.ToggleTool(id, True) |
1492 | - Publisher.sendMessage('Enable style', id) | 1481 | + Publisher.sendMessage('Enable style', style=id) |
1493 | Publisher.sendMessage('Untoggle slice toolbar items') | 1482 | Publisher.sendMessage('Untoggle slice toolbar items') |
1494 | for item in const.TOOL_STATES: | 1483 | for item in const.TOOL_STATES: |
1495 | state = self.GetToolToggled(item) | 1484 | state = self.GetToolToggled(item) |
@@ -1508,10 +1497,10 @@ class ObjectToolBar(AuiToolBar): | @@ -1508,10 +1497,10 @@ class ObjectToolBar(AuiToolBar): | ||
1508 | Publisher.sendMessage('Fold measure task') | 1497 | Publisher.sendMessage('Fold measure task') |
1509 | 1498 | ||
1510 | if state: | 1499 | if state: |
1511 | - Publisher.sendMessage('Enable style', id) | 1500 | + Publisher.sendMessage('Enable style', style=id) |
1512 | Publisher.sendMessage('Untoggle slice toolbar items') | 1501 | Publisher.sendMessage('Untoggle slice toolbar items') |
1513 | else: | 1502 | else: |
1514 | - Publisher.sendMessage('Disable style', id) | 1503 | + Publisher.sendMessage('Disable style', style=id) |
1515 | 1504 | ||
1516 | for item in const.TOOL_STATES: | 1505 | for item in const.TOOL_STATES: |
1517 | state = self.GetToolToggled(item) | 1506 | state = self.GetToolToggled(item) |
@@ -1519,8 +1508,7 @@ class ObjectToolBar(AuiToolBar): | @@ -1519,8 +1508,7 @@ class ObjectToolBar(AuiToolBar): | ||
1519 | self.ToggleTool(item, False) | 1508 | self.ToggleTool(item, False) |
1520 | evt.Skip() | 1509 | evt.Skip() |
1521 | 1510 | ||
1522 | - def ToggleItem(self, evt): | ||
1523 | - _id, value = evt.data | 1511 | + def ToggleItem(self, _id, value): |
1524 | if _id in self.enable_items: | 1512 | if _id in self.enable_items: |
1525 | self.ToggleTool(_id, value) | 1513 | self.ToggleTool(_id, value) |
1526 | self.Refresh() | 1514 | self.Refresh() |
@@ -1613,12 +1601,11 @@ class SliceToolBar(AuiToolBar): | @@ -1613,12 +1601,11 @@ class SliceToolBar(AuiToolBar): | ||
1613 | """ | 1601 | """ |
1614 | self.Bind(wx.EVT_TOOL, self.OnToggle) | 1602 | self.Bind(wx.EVT_TOOL, self.OnToggle) |
1615 | 1603 | ||
1616 | - def _EnableState(self, pubsub_evt): | 1604 | + def _EnableState(self, state): |
1617 | """ | 1605 | """ |
1618 | Based on given state, enable or disable menu items which | 1606 | Based on given state, enable or disable menu items which |
1619 | depend if project is open or not. | 1607 | depend if project is open or not. |
1620 | """ | 1608 | """ |
1621 | - state = pubsub_evt.data | ||
1622 | if state: | 1609 | if state: |
1623 | self.SetStateProjectOpen() | 1610 | self.SetStateProjectOpen() |
1624 | else: | 1611 | else: |
@@ -1626,7 +1613,7 @@ class SliceToolBar(AuiToolBar): | @@ -1626,7 +1613,7 @@ class SliceToolBar(AuiToolBar): | ||
1626 | self._UntoggleAllItems() | 1613 | self._UntoggleAllItems() |
1627 | self.Refresh() | 1614 | self.Refresh() |
1628 | 1615 | ||
1629 | - def _UntoggleAllItems(self, pubsub_evt=None): | 1616 | + def _UntoggleAllItems(self): |
1630 | """ | 1617 | """ |
1631 | Untoggle all items on toolbar. | 1618 | Untoggle all items on toolbar. |
1632 | """ | 1619 | """ |
@@ -1636,16 +1623,15 @@ class SliceToolBar(AuiToolBar): | @@ -1636,16 +1623,15 @@ class SliceToolBar(AuiToolBar): | ||
1636 | self.ToggleTool(id, False) | 1623 | self.ToggleTool(id, False) |
1637 | if id == const.SLICE_STATE_CROSS: | 1624 | if id == const.SLICE_STATE_CROSS: |
1638 | msg = 'Set cross visibility' | 1625 | msg = 'Set cross visibility' |
1639 | - Publisher.sendMessage(msg, 0) | 1626 | + Publisher.sendMessage(msg, visibility=0) |
1640 | self.Refresh() | 1627 | self.Refresh() |
1641 | 1628 | ||
1642 | - def OnToggle(self, evt): | 1629 | + def OnToggle(self, evt=None, id=None): |
1643 | """ | 1630 | """ |
1644 | Update status of other items on toolbar (only one item | 1631 | Update status of other items on toolbar (only one item |
1645 | should be toggle each time). | 1632 | should be toggle each time). |
1646 | """ | 1633 | """ |
1647 | - if hasattr(evt, 'data'): | ||
1648 | - id = evt.data | 1634 | + if id is not None: |
1649 | if not self.GetToolToggled(id): | 1635 | if not self.GetToolToggled(id): |
1650 | self.ToggleTool(id, True) | 1636 | self.ToggleTool(id, True) |
1651 | self.Refresh() | 1637 | self.Refresh() |
@@ -1656,10 +1642,10 @@ class SliceToolBar(AuiToolBar): | @@ -1656,10 +1642,10 @@ class SliceToolBar(AuiToolBar): | ||
1656 | state = self.GetToolToggled(id) | 1642 | state = self.GetToolToggled(id) |
1657 | 1643 | ||
1658 | if state: | 1644 | if state: |
1659 | - Publisher.sendMessage('Enable style', id) | 1645 | + Publisher.sendMessage('Enable style', style=id) |
1660 | Publisher.sendMessage('Untoggle object toolbar items') | 1646 | Publisher.sendMessage('Untoggle object toolbar items') |
1661 | else: | 1647 | else: |
1662 | - Publisher.sendMessage('Disable style', id) | 1648 | + Publisher.sendMessage('Disable style', style=id) |
1663 | 1649 | ||
1664 | for item in self.enable_items: | 1650 | for item in self.enable_items: |
1665 | state = self.GetToolToggled(item) | 1651 | state = self.GetToolToggled(item) |
@@ -1671,8 +1657,7 @@ class SliceToolBar(AuiToolBar): | @@ -1671,8 +1657,7 @@ class SliceToolBar(AuiToolBar): | ||
1671 | ##print ">>>", self.sst.IsToggled() | 1657 | ##print ">>>", self.sst.IsToggled() |
1672 | #print ">>>", self.sst.GetState() | 1658 | #print ">>>", self.sst.GetState() |
1673 | 1659 | ||
1674 | - def ToggleItem(self, evt): | ||
1675 | - _id, value = evt.data | 1660 | + def ToggleItem(self, _id, value): |
1676 | if _id in self.enable_items: | 1661 | if _id in self.enable_items: |
1677 | self.ToggleTool(_id, value) | 1662 | self.ToggleTool(_id, value) |
1678 | self.Refresh() | 1663 | self.Refresh() |
@@ -1785,25 +1770,24 @@ class LayoutToolBar(AuiToolBar): | @@ -1785,25 +1770,24 @@ class LayoutToolBar(AuiToolBar): | ||
1785 | wx.ITEM_NORMAL, | 1770 | wx.ITEM_NORMAL, |
1786 | short_help_string= _("Hide text")) | 1771 | short_help_string= _("Hide text")) |
1787 | 1772 | ||
1788 | - def _EnableState(self, pubsub_evt): | 1773 | + def _EnableState(self, state): |
1789 | """ | 1774 | """ |
1790 | Based on given state, enable or disable menu items which | 1775 | Based on given state, enable or disable menu items which |
1791 | depend if project is open or not. | 1776 | depend if project is open or not. |
1792 | """ | 1777 | """ |
1793 | - state = pubsub_evt.data | ||
1794 | if state: | 1778 | if state: |
1795 | self.SetStateProjectOpen() | 1779 | self.SetStateProjectOpen() |
1796 | else: | 1780 | else: |
1797 | self.SetStateProjectClose() | 1781 | self.SetStateProjectClose() |
1798 | self.Refresh() | 1782 | self.Refresh() |
1799 | 1783 | ||
1800 | - def _SetLayoutWithoutTask(self, pubsub_evt): | 1784 | + def _SetLayoutWithoutTask(self): |
1801 | """ | 1785 | """ |
1802 | Set item bitmap to task panel hiden. | 1786 | Set item bitmap to task panel hiden. |
1803 | """ | 1787 | """ |
1804 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) | 1788 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |
1805 | 1789 | ||
1806 | - def _SetLayoutWithTask(self, pubsub_evt): | 1790 | + def _SetLayoutWithTask(self): |
1807 | """ | 1791 | """ |
1808 | Set item bitmap to task panel shown. | 1792 | Set item bitmap to task panel shown. |
1809 | """ | 1793 | """ |
@@ -1958,25 +1942,24 @@ class HistoryToolBar(AuiToolBar): | @@ -1958,25 +1942,24 @@ class HistoryToolBar(AuiToolBar): | ||
1958 | self.EnableTool(wx.ID_UNDO, False) | 1942 | self.EnableTool(wx.ID_UNDO, False) |
1959 | self.EnableTool(wx.ID_REDO, False) | 1943 | self.EnableTool(wx.ID_REDO, False) |
1960 | 1944 | ||
1961 | - def _EnableState(self, pubsub_evt): | 1945 | + def _EnableState(self, state): |
1962 | """ | 1946 | """ |
1963 | Based on given state, enable or disable menu items which | 1947 | Based on given state, enable or disable menu items which |
1964 | depend if project is open or not. | 1948 | depend if project is open or not. |
1965 | """ | 1949 | """ |
1966 | - state = pubsub_evt.data | ||
1967 | if state: | 1950 | if state: |
1968 | self.SetStateProjectOpen() | 1951 | self.SetStateProjectOpen() |
1969 | else: | 1952 | else: |
1970 | self.SetStateProjectClose() | 1953 | self.SetStateProjectClose() |
1971 | self.Refresh() | 1954 | self.Refresh() |
1972 | 1955 | ||
1973 | - def _SetLayoutWithoutTask(self, pubsub_evt): | 1956 | + def _SetLayoutWithoutTask(self): |
1974 | """ | 1957 | """ |
1975 | Set item bitmap to task panel hiden. | 1958 | Set item bitmap to task panel hiden. |
1976 | """ | 1959 | """ |
1977 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) | 1960 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |
1978 | 1961 | ||
1979 | - def _SetLayoutWithTask(self, pubsub_evt): | 1962 | + def _SetLayoutWithTask(self): |
1980 | """ | 1963 | """ |
1981 | Set item bitmap to task panel shown. | 1964 | Set item bitmap to task panel shown. |
1982 | """ | 1965 | """ |
@@ -2054,16 +2037,14 @@ class HistoryToolBar(AuiToolBar): | @@ -2054,16 +2037,14 @@ class HistoryToolBar(AuiToolBar): | ||
2054 | Publisher.sendMessage('Update AUI') | 2037 | Publisher.sendMessage('Update AUI') |
2055 | self.ontool_text = True | 2038 | self.ontool_text = True |
2056 | 2039 | ||
2057 | - def OnEnableUndo(self, pubsub_evt): | ||
2058 | - value = pubsub_evt.data | 2040 | + def OnEnableUndo(self, value): |
2059 | if value: | 2041 | if value: |
2060 | self.EnableTool(wx.ID_UNDO, True) | 2042 | self.EnableTool(wx.ID_UNDO, True) |
2061 | else: | 2043 | else: |
2062 | self.EnableTool(wx.ID_UNDO, False) | 2044 | self.EnableTool(wx.ID_UNDO, False) |
2063 | self.Refresh() | 2045 | self.Refresh() |
2064 | 2046 | ||
2065 | - def OnEnableRedo(self, pubsub_evt): | ||
2066 | - value = pubsub_evt.data | 2047 | + def OnEnableRedo(self, value): |
2067 | if value: | 2048 | if value: |
2068 | self.EnableTool(wx.ID_REDO, True) | 2049 | self.EnableTool(wx.ID_REDO, True) |
2069 | else: | 2050 | else: |
invesalius/gui/import_bitmap_panel.py
@@ -127,14 +127,13 @@ class InnerPanel(wx.Panel): | @@ -127,14 +127,13 @@ class InnerPanel(wx.Panel): | ||
127 | Publisher.subscribe(self.ShowBitmapPreview, "Load import bitmap panel") | 127 | Publisher.subscribe(self.ShowBitmapPreview, "Load import bitmap panel") |
128 | Publisher.subscribe(self.GetSelectedImages ,"Selected Import Images") | 128 | Publisher.subscribe(self.GetSelectedImages ,"Selected Import Images") |
129 | 129 | ||
130 | - def ShowBitmapPreview(self, pubsub_evt): | ||
131 | - data = pubsub_evt.data | 130 | + def ShowBitmapPreview(self, data): |
132 | #self.patients.extend(dicom_groups) | 131 | #self.patients.extend(dicom_groups) |
133 | self.text_panel.Populate(data) | 132 | self.text_panel.Populate(data) |
134 | 133 | ||
135 | - def GetSelectedImages(self, pubsub_evt): | ||
136 | - self.first_image_selection = pubsub_evt.data[0] | ||
137 | - self.last_image_selection = pubsub_evt.data[1] | 134 | + def GetSelectedImages(self, selection): |
135 | + self.first_image_selection = selection[0] | ||
136 | + self.last_image_selection = selection[1] | ||
138 | 137 | ||
139 | def _bind_events(self): | 138 | def _bind_events(self): |
140 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) | 139 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
@@ -230,23 +229,23 @@ class TextPanel(wx.Panel): | @@ -230,23 +229,23 @@ class TextPanel(wx.Panel): | ||
230 | data_size = len(bpr.BitmapData().GetData()) | 229 | data_size = len(bpr.BitmapData().GetData()) |
231 | 230 | ||
232 | if index >= 0 and index < data_size: | 231 | if index >= 0 and index < data_size: |
233 | - Publisher.sendMessage('Set bitmap in preview panel', index) | 232 | + Publisher.sendMessage('Set bitmap in preview panel', pos=index) |
234 | elif index == data_size and data_size > 0: | 233 | elif index == data_size and data_size > 0: |
235 | - Publisher.sendMessage('Set bitmap in preview panel', index - 1) | 234 | + Publisher.sendMessage('Set bitmap in preview panel', pos=index - 1) |
236 | elif data_size == 1: | 235 | elif data_size == 1: |
237 | - Publisher.sendMessage('Set bitmap in preview panel', 0) | 236 | + Publisher.sendMessage('Set bitmap in preview panel', pos=0) |
238 | else: | 237 | else: |
239 | Publisher.sendMessage('Show black slice in single preview image') | 238 | Publisher.sendMessage('Show black slice in single preview image') |
240 | 239 | ||
241 | self.tree.Delete(selected_item) | 240 | self.tree.Delete(selected_item) |
242 | self.tree.Update() | 241 | self.tree.Update() |
243 | self.tree.Refresh() | 242 | self.tree.Refresh() |
244 | - Publisher.sendMessage('Remove preview panel', text_item) | 243 | + Publisher.sendMessage('Remove preview panel', data=text_item) |
245 | 244 | ||
246 | evt.Skip() | 245 | evt.Skip() |
247 | 246 | ||
248 | - def SelectSeries(self, pubsub_evt): | ||
249 | - group_index = pubsub_evt.data | 247 | + def SelectSeries(self, group_index): |
248 | + pass | ||
250 | 249 | ||
251 | def Populate(self, data): | 250 | def Populate(self, data): |
252 | tree = self.tree | 251 | tree = self.tree |
@@ -259,7 +258,7 @@ class TextPanel(wx.Panel): | @@ -259,7 +258,7 @@ class TextPanel(wx.Panel): | ||
259 | tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) | 258 | tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) |
260 | tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged) | 259 | tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged) |
261 | 260 | ||
262 | - Publisher.sendMessage('Load bitmap into import panel', data) | 261 | + Publisher.sendMessage('Load bitmap into import panel', data=data) |
263 | 262 | ||
264 | def OnSelChanged(self, evt): | 263 | def OnSelChanged(self, evt): |
265 | self.selected_items = self.tree.GetSelections() | 264 | self.selected_items = self.tree.GetSelections() |
@@ -269,7 +268,7 @@ class TextPanel(wx.Panel): | @@ -269,7 +268,7 @@ class TextPanel(wx.Panel): | ||
269 | 268 | ||
270 | text_item = self.tree.GetItemText(item) | 269 | text_item = self.tree.GetItemText(item) |
271 | index = bpr.BitmapData().GetIndexByPath(text_item) | 270 | index = bpr.BitmapData().GetIndexByPath(text_item) |
272 | - Publisher.sendMessage('Set bitmap in preview panel', index) | 271 | + Publisher.sendMessage('Set bitmap in preview panel', pos=index) |
273 | 272 | ||
274 | evt.Skip() | 273 | evt.Skip() |
275 | 274 | ||
@@ -369,14 +368,10 @@ class SeriesPanel(wx.Panel): | @@ -369,14 +368,10 @@ class SeriesPanel(wx.Panel): | ||
369 | def GetSelectedImagesRange(self): | 368 | def GetSelectedImagesRange(self): |
370 | return [self.bitmap_preview.first_selected, self.dicom_preview_last_selection] | 369 | return [self.bitmap_preview.first_selected, self.dicom_preview_last_selection] |
371 | 370 | ||
372 | - def SetBitmapFiles(self, pubsub_evt): | ||
373 | - | ||
374 | - | ||
375 | - bitmap = pubsub_evt.data | 371 | + def SetBitmapFiles(self, data): |
372 | + bitmap = data | ||
376 | self.thumbnail_preview.Show(1) | 373 | self.thumbnail_preview.Show(1) |
377 | - | ||
378 | self.thumbnail_preview.SetBitmapFiles(bitmap) | 374 | self.thumbnail_preview.SetBitmapFiles(bitmap) |
379 | - | ||
380 | self.Update() | 375 | self.Update() |
381 | 376 | ||
382 | def OnSelectSerie(self, evt): | 377 | def OnSelectSerie(self, evt): |
@@ -420,8 +415,7 @@ class SlicePanel(wx.Panel): | @@ -420,8 +415,7 @@ class SlicePanel(wx.Panel): | ||
420 | self.SetAutoLayout(1) | 415 | self.SetAutoLayout(1) |
421 | self.sizer = sizer | 416 | self.sizer = sizer |
422 | 417 | ||
423 | - def SetBitmapFiles(self, pubsub_evt): | ||
424 | - data = pubsub_evt.data | 418 | + def SetBitmapFiles(self, data): |
425 | self.bitmap_preview.SetBitmapFiles(data) | 419 | self.bitmap_preview.SetBitmapFiles(data) |
426 | self.sizer.Layout() | 420 | self.sizer.Layout() |
427 | self.Update() | 421 | self.Update() |
invesalius/gui/import_network_panel.py
@@ -266,8 +266,8 @@ class TextPanel(wx.Panel): | @@ -266,8 +266,8 @@ class TextPanel(wx.Panel): | ||
266 | self.root = tree.AddRoot(_("InVesalius Database")) | 266 | self.root = tree.AddRoot(_("InVesalius Database")) |
267 | self.tree = tree | 267 | self.tree = tree |
268 | 268 | ||
269 | - def SelectSeries(self, pubsub_evt): | ||
270 | - group_index = pubsub_evt.data | 269 | + def SelectSeries(self, group_index): |
270 | + pass | ||
271 | 271 | ||
272 | def Populate(self, pubsub_evt): | 272 | def Populate(self, pubsub_evt): |
273 | tree = self.tree | 273 | tree = self.tree |
invesalius/gui/import_panel.py
@@ -129,9 +129,9 @@ class InnerPanel(wx.Panel): | @@ -129,9 +129,9 @@ class InnerPanel(wx.Panel): | ||
129 | Publisher.subscribe(self.ShowDicomPreview, "Load import panel") | 129 | Publisher.subscribe(self.ShowDicomPreview, "Load import panel") |
130 | Publisher.subscribe(self.GetSelectedImages ,"Selected Import Images") | 130 | Publisher.subscribe(self.GetSelectedImages ,"Selected Import Images") |
131 | 131 | ||
132 | - def GetSelectedImages(self, pubsub_evt): | ||
133 | - self.first_image_selection = pubsub_evt.data[0] | ||
134 | - self.last_image_selection = pubsub_evt.data[1] | 132 | + def GetSelectedImages(self, selection): |
133 | + self.first_image_selection = selection[0] | ||
134 | + self.last_image_selection = selection[1] | ||
135 | 135 | ||
136 | def _bind_events(self): | 136 | def _bind_events(self): |
137 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) | 137 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) |
@@ -141,8 +141,7 @@ class InnerPanel(wx.Panel): | @@ -141,8 +141,7 @@ class InnerPanel(wx.Panel): | ||
141 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) | 141 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) |
142 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) | 142 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) |
143 | 143 | ||
144 | - def ShowDicomPreview(self, pubsub_evt): | ||
145 | - dicom_groups = pubsub_evt.data | 144 | + def ShowDicomPreview(self, dicom_groups): |
146 | self.patients.extend(dicom_groups) | 145 | self.patients.extend(dicom_groups) |
147 | self.text_panel.Populate(dicom_groups) | 146 | self.text_panel.Populate(dicom_groups) |
148 | 147 | ||
@@ -187,8 +186,9 @@ class InnerPanel(wx.Panel): | @@ -187,8 +186,9 @@ class InnerPanel(wx.Panel): | ||
187 | 186 | ||
188 | nslices_result = slice_amont / (interval + 1) | 187 | nslices_result = slice_amont / (interval + 1) |
189 | if (nslices_result > 1): | 188 | if (nslices_result > 1): |
190 | - Publisher.sendMessage('Open DICOM group', (group, interval, | ||
191 | - [self.first_image_selection, self.last_image_selection])) | 189 | + Publisher.sendMessage('Open DICOM group', group=group, |
190 | + interval=interval, | ||
191 | + file_range=(self.first_image_selection, self.last_image_selection)) | ||
192 | else: | 192 | else: |
193 | dlg.MissingFilesForReconstruction() | 193 | dlg.MissingFilesForReconstruction() |
194 | 194 | ||
@@ -251,8 +251,8 @@ class TextPanel(wx.Panel): | @@ -251,8 +251,8 @@ class TextPanel(wx.Panel): | ||
251 | self.root = tree.AddRoot(_("InVesalius Database")) | 251 | self.root = tree.AddRoot(_("InVesalius Database")) |
252 | self.tree = tree | 252 | self.tree = tree |
253 | 253 | ||
254 | - def SelectSeries(self, pubsub_evt): | ||
255 | - group_index = pubsub_evt.data | 254 | + def SelectSeries(self, group_index): |
255 | + pass | ||
256 | 256 | ||
257 | def Populate(self, patient_list): | 257 | def Populate(self, patient_list): |
258 | tree = self.tree | 258 | tree = self.tree |
@@ -313,7 +313,7 @@ class TextPanel(wx.Panel): | @@ -313,7 +313,7 @@ class TextPanel(wx.Panel): | ||
313 | group = self.tree.GetItemPyData(item) | 313 | group = self.tree.GetItemPyData(item) |
314 | if isinstance(group, dcm.DicomGroup): | 314 | if isinstance(group, dcm.DicomGroup): |
315 | Publisher.sendMessage('Load group into import panel', | 315 | Publisher.sendMessage('Load group into import panel', |
316 | - group) | 316 | + group=group) |
317 | 317 | ||
318 | elif isinstance(group, dcm.PatientGroup): | 318 | elif isinstance(group, dcm.PatientGroup): |
319 | id = group.GetDicomSample().patient.id | 319 | id = group.GetDicomSample().patient.id |
@@ -322,7 +322,7 @@ class TextPanel(wx.Panel): | @@ -322,7 +322,7 @@ class TextPanel(wx.Panel): | ||
322 | self.GetEventHandler().ProcessEvent(my_evt) | 322 | self.GetEventHandler().ProcessEvent(my_evt) |
323 | 323 | ||
324 | Publisher.sendMessage('Load patient into import panel', | 324 | Publisher.sendMessage('Load patient into import panel', |
325 | - group) | 325 | + patient=group) |
326 | else: | 326 | else: |
327 | parent_id = self.tree.GetItemParent(item) | 327 | parent_id = self.tree.GetItemParent(item) |
328 | self.tree.Expand(parent_id) | 328 | self.tree.Expand(parent_id) |
@@ -430,8 +430,7 @@ class SeriesPanel(wx.Panel): | @@ -430,8 +430,7 @@ class SeriesPanel(wx.Panel): | ||
430 | self.serie_preview.Bind(dpp.EVT_CLICK_SERIE, self.OnSelectSerie) | 430 | self.serie_preview.Bind(dpp.EVT_CLICK_SERIE, self.OnSelectSerie) |
431 | self.dicom_preview.Bind(dpp.EVT_CLICK_SLICE, self.OnSelectSlice) | 431 | self.dicom_preview.Bind(dpp.EVT_CLICK_SLICE, self.OnSelectSlice) |
432 | 432 | ||
433 | - def SetDicomSeries(self, pubsub_evt): | ||
434 | - group = pubsub_evt.data | 433 | + def SetDicomSeries(self, group): |
435 | self.dicom_preview.SetDicomGroup(group) | 434 | self.dicom_preview.SetDicomGroup(group) |
436 | self.dicom_preview.Show(1) | 435 | self.dicom_preview.Show(1) |
437 | self.serie_preview.Show(0) | 436 | self.serie_preview.Show(0) |
@@ -441,9 +440,7 @@ class SeriesPanel(wx.Panel): | @@ -441,9 +440,7 @@ class SeriesPanel(wx.Panel): | ||
441 | def GetSelectedImagesRange(self): | 440 | def GetSelectedImagesRange(self): |
442 | return [self.dicom_preview.first_selected, self.dicom_preview_last_selection] | 441 | return [self.dicom_preview.first_selected, self.dicom_preview_last_selection] |
443 | 442 | ||
444 | - def SetPatientSeries(self, pubsub_evt): | ||
445 | - patient = pubsub_evt.data | ||
446 | - | 443 | + def SetPatientSeries(self, patient): |
447 | self.dicom_preview.Show(0) | 444 | self.dicom_preview.Show(0) |
448 | self.serie_preview.Show(1) | 445 | self.serie_preview.Show(1) |
449 | 446 | ||
@@ -474,8 +471,7 @@ class SeriesPanel(wx.Panel): | @@ -474,8 +471,7 @@ class SeriesPanel(wx.Panel): | ||
474 | my_evt.SetItemData(evt.GetItemData()) | 471 | my_evt.SetItemData(evt.GetItemData()) |
475 | self.GetEventHandler().ProcessEvent(my_evt) | 472 | self.GetEventHandler().ProcessEvent(my_evt) |
476 | 473 | ||
477 | - def ShowDicomSeries(self, pubsub_evt): | ||
478 | - patient = pubsub_evt.data | 474 | + def ShowDicomSeries(self, patient): |
479 | if isinstance(patient, dcm.PatientGroup): | 475 | if isinstance(patient, dcm.PatientGroup): |
480 | self.serie_preview.SetPatientGroups(patient) | 476 | self.serie_preview.SetPatientGroups(patient) |
481 | self.dicom_preview.SetPatientGroups(patient) | 477 | self.dicom_preview.SetPatientGroups(patient) |
@@ -505,21 +501,18 @@ class SlicePanel(wx.Panel): | @@ -505,21 +501,18 @@ class SlicePanel(wx.Panel): | ||
505 | self.SetAutoLayout(1) | 501 | self.SetAutoLayout(1) |
506 | self.sizer = sizer | 502 | self.sizer = sizer |
507 | 503 | ||
508 | - def SetPatientSeries(self, pubsub_evt): | ||
509 | - patient = pubsub_evt.data | 504 | + def SetPatientSeries(self, patient): |
510 | group = patient.GetGroups()[0] | 505 | group = patient.GetGroups()[0] |
511 | self.dicom_preview.SetDicomGroup(group) | 506 | self.dicom_preview.SetDicomGroup(group) |
512 | self.sizer.Layout() | 507 | self.sizer.Layout() |
513 | self.Update() | 508 | self.Update() |
514 | 509 | ||
515 | - def SetDicomSeries(self, evt): | ||
516 | - group = evt.data | 510 | + def SetDicomSeries(self, group): |
517 | self.dicom_preview.SetDicomGroup(group) | 511 | self.dicom_preview.SetDicomGroup(group) |
518 | self.sizer.Layout() | 512 | self.sizer.Layout() |
519 | self.Update() | 513 | self.Update() |
520 | 514 | ||
521 | - def ShowDicomSeries(self, pubsub_evt): | ||
522 | - patient = pubsub_evt.data | 515 | + def ShowDicomSeries(self, patient): |
523 | group = patient.GetGroups()[0] | 516 | group = patient.GetGroups()[0] |
524 | self.dicom_preview.SetDicomGroup(group) | 517 | self.dicom_preview.SetDicomGroup(group) |
525 | self.sizer.Layout() | 518 | self.sizer.Layout() |
invesalius/gui/preferences.py
@@ -81,7 +81,7 @@ class Preferences(wx.Dialog): | @@ -81,7 +81,7 @@ class Preferences(wx.Dialog): | ||
81 | 81 | ||
82 | return values | 82 | return values |
83 | 83 | ||
84 | - def LoadPreferences(self, pub_evt): | 84 | + def LoadPreferences(self): |
85 | se = ses.Session() | 85 | se = ses.Session() |
86 | 86 | ||
87 | values = {const.RENDERING:se.rendering, | 87 | values = {const.RENDERING:se.rendering, |
invesalius/gui/task_exporter.py
@@ -267,7 +267,7 @@ class InnerTaskPanel(wx.Panel): | @@ -267,7 +267,7 @@ class InnerTaskPanel(wx.Panel): | ||
267 | if value: | 267 | if value: |
268 | filename, filetype = value | 268 | filename, filetype = value |
269 | Publisher.sendMessage('Export picture to file', | 269 | Publisher.sendMessage('Export picture to file', |
270 | - (id, filename, filetype)) | 270 | + orientation=id, filename=filename, filetype=filetype) |
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
@@ -299,7 +299,8 @@ class InnerTaskPanel(wx.Panel): | @@ -299,7 +299,8 @@ class InnerTaskPanel(wx.Panel): | ||
299 | filename = filename + "."+ extension | 299 | filename = filename + "."+ extension |
300 | filetype = const.FILETYPE_IMAGEDATA | 300 | filetype = const.FILETYPE_IMAGEDATA |
301 | Publisher.sendMessage('Export mask to file', | 301 | Publisher.sendMessage('Export mask to file', |
302 | - (filename, filetype)) | 302 | + filename=filename, |
303 | + filetype=filetype) | ||
303 | 304 | ||
304 | 305 | ||
305 | def OnLinkExportSurface(self, evt=None): | 306 | def OnLinkExportSurface(self, evt=None): |
@@ -335,7 +336,7 @@ class InnerTaskPanel(wx.Panel): | @@ -335,7 +336,7 @@ class InnerTaskPanel(wx.Panel): | ||
335 | if filename.split(".")[-1] != extension: | 336 | if filename.split(".")[-1] != extension: |
336 | filename = filename + "."+ extension | 337 | filename = filename + "."+ extension |
337 | Publisher.sendMessage('Export surface to file', | 338 | Publisher.sendMessage('Export surface to file', |
338 | - (filename, filetype)) | 339 | + filename=filename, filetype=filetype) |
339 | if not os.path.exists(filename): | 340 | if not os.path.exists(filename): |
340 | dlg = wx.MessageDialog(None, | 341 | dlg = wx.MessageDialog(None, |
341 | _("It was not possible to save the surface."), | 342 | _("It was not possible to save the surface."), |
invesalius/gui/task_importer.py
@@ -235,15 +235,15 @@ class InnerTaskPanel(wx.Panel): | @@ -235,15 +235,15 @@ class InnerTaskPanel(wx.Panel): | ||
235 | 235 | ||
236 | def OpenProject(self, path=None): | 236 | def OpenProject(self, path=None): |
237 | if path: | 237 | if path: |
238 | - Publisher.sendMessage('Open recent project', path) | 238 | + Publisher.sendMessage('Open recent project', filepath=path) |
239 | else: | 239 | else: |
240 | Publisher.sendMessage('Show open project dialog') | 240 | Publisher.sendMessage('Show open project dialog') |
241 | 241 | ||
242 | def SaveAsProject(self): | 242 | def SaveAsProject(self): |
243 | - Publisher.sendMessage('Show save dialog', True) | 243 | + Publisher.sendMessage('Show save dialog', save_as=True) |
244 | 244 | ||
245 | def SaveProject(self): | 245 | def SaveProject(self): |
246 | - Publisher.sendMessage('Show save dialog', False) | 246 | + Publisher.sendMessage('Show save dialog', save_as=False) |
247 | 247 | ||
248 | def CloseProject(self): | 248 | def CloseProject(self): |
249 | Publisher.sendMessage('Close Project') | 249 | Publisher.sendMessage('Close Project') |
invesalius/gui/task_navigator.py
@@ -220,14 +220,13 @@ class InnerFoldPanel(wx.Panel): | @@ -220,14 +220,13 @@ class InnerFoldPanel(wx.Panel): | ||
220 | self.SetSizer(sizer) | 220 | self.SetSizer(sizer) |
221 | self.Update() | 221 | self.Update() |
222 | self.SetAutoLayout(1) | 222 | self.SetAutoLayout(1) |
223 | - | 223 | + |
224 | def __bind_events(self): | 224 | def __bind_events(self): |
225 | Publisher.subscribe(self.OnCheckStatus, 'Navigation status') | 225 | Publisher.subscribe(self.OnCheckStatus, 'Navigation status') |
226 | Publisher.subscribe(self.OnShowObject, 'Update track object state') | 226 | Publisher.subscribe(self.OnShowObject, 'Update track object state') |
227 | Publisher.subscribe(self.OnVolumeCamera, 'Target navigation mode') | 227 | Publisher.subscribe(self.OnVolumeCamera, 'Target navigation mode') |
228 | 228 | ||
229 | - def OnCheckStatus(self, pubsub_evt): | ||
230 | - status = pubsub_evt.data | 229 | + def OnCheckStatus(self, status): |
231 | if status: | 230 | if status: |
232 | self.checktrigger.Enable(False) | 231 | self.checktrigger.Enable(False) |
233 | self.checkobj.Enable(False) | 232 | self.checkobj.Enable(False) |
@@ -237,27 +236,25 @@ class InnerFoldPanel(wx.Panel): | @@ -237,27 +236,25 @@ class InnerFoldPanel(wx.Panel): | ||
237 | self.checkobj.Enable(True) | 236 | self.checkobj.Enable(True) |
238 | 237 | ||
239 | def OnExternalTrigger(self, evt, ctrl): | 238 | def OnExternalTrigger(self, evt, ctrl): |
240 | - Publisher.sendMessage('Update trigger state', ctrl.GetValue()) | 239 | + Publisher.sendMessage('Update trigger state', trigger_state=ctrl.GetValue()) |
241 | 240 | ||
242 | - def OnShowObject(self, evt): | ||
243 | - if hasattr(evt, 'data'): | ||
244 | - if evt.data[0]: | ||
245 | - self.checkobj.Enable(True) | ||
246 | - self.track_obj = True | ||
247 | - Publisher.sendMessage('Status target button', True) | ||
248 | - else: | ||
249 | - self.checkobj.Enable(False) | ||
250 | - self.checkobj.SetValue(False) | ||
251 | - self.track_obj = False | ||
252 | - Publisher.sendMessage('Status target button', False) | 241 | + def OnShowObject(self, evt=None, flag=None, obj_name=None): |
242 | + if flag: | ||
243 | + self.checkobj.Enable(True) | ||
244 | + self.track_obj = True | ||
245 | + Publisher.sendMessage('Status target button', status=True) | ||
246 | + else: | ||
247 | + self.checkobj.Enable(False) | ||
248 | + self.checkobj.SetValue(False) | ||
249 | + self.track_obj = False | ||
250 | + Publisher.sendMessage('Status target button', status=False) | ||
253 | 251 | ||
254 | - Publisher.sendMessage('Update show object state', self.checkobj.GetValue()) | 252 | + Publisher.sendMessage('Update show object state', state=self.checkobj.GetValue()) |
255 | 253 | ||
256 | - def OnVolumeCamera(self, evt): | ||
257 | - if hasattr(evt, 'data'): | ||
258 | - if evt.data is True: | ||
259 | - self.checkcamera.SetValue(0) | ||
260 | - Publisher.sendMessage('Update volume camera state', self.checkcamera.GetValue()) | 254 | + def OnVolumeCamera(self, evt=None, target_mode=None): |
255 | + if target_mode is True: | ||
256 | + self.checkcamera.SetValue(0) | ||
257 | + Publisher.sendMessage('Update volume camera state', camera_state=self.checkcamera.GetValue()) | ||
261 | 258 | ||
262 | 259 | ||
263 | class NeuronavigationPanel(wx.Panel): | 260 | class NeuronavigationPanel(wx.Panel): |
@@ -402,9 +399,7 @@ class NeuronavigationPanel(wx.Panel): | @@ -402,9 +399,7 @@ class NeuronavigationPanel(wx.Panel): | ||
402 | Publisher.subscribe(self.UpdateObjectRegistration, 'Update object registration') | 399 | Publisher.subscribe(self.UpdateObjectRegistration, 'Update object registration') |
403 | Publisher.subscribe(self.OnCloseProject, 'Close project data') | 400 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
404 | 401 | ||
405 | - def LoadImageFiducials(self, pubsub_evt): | ||
406 | - marker_id = pubsub_evt.data[0] | ||
407 | - coord = pubsub_evt.data[1] | 402 | + def LoadImageFiducials(self, marker_id, coord): |
408 | for n in const.BTNS_IMG_MKS: | 403 | for n in const.BTNS_IMG_MKS: |
409 | btn_id = list(const.BTNS_IMG_MKS[n].keys())[0] | 404 | btn_id = list(const.BTNS_IMG_MKS[n].keys())[0] |
410 | fid_id = list(const.BTNS_IMG_MKS[n].values())[0] | 405 | fid_id = list(const.BTNS_IMG_MKS[n].values())[0] |
@@ -414,9 +409,9 @@ class NeuronavigationPanel(wx.Panel): | @@ -414,9 +409,9 @@ class NeuronavigationPanel(wx.Panel): | ||
414 | for m in [0, 1, 2]: | 409 | for m in [0, 1, 2]: |
415 | self.numctrls_coord[btn_id][m].SetValue(coord[m]) | 410 | self.numctrls_coord[btn_id][m].SetValue(coord[m]) |
416 | 411 | ||
417 | - def UpdateImageCoordinates(self, pubsub_evt): | 412 | + def UpdateImageCoordinates(self, position): |
418 | # TODO: Change from world coordinates to matrix coordinates. They are better for multi software communication. | 413 | # TODO: Change from world coordinates to matrix coordinates. They are better for multi software communication. |
419 | - self.current_coord = pubsub_evt.data | 414 | + self.current_coord = position |
420 | for m in [0, 1, 2, 6]: | 415 | for m in [0, 1, 2, 6]: |
421 | if m == 6 and self.btns_coord[m].IsEnabled(): | 416 | if m == 6 and self.btns_coord[m].IsEnabled(): |
422 | for n in [0, 1, 2]: | 417 | for n in [0, 1, 2]: |
@@ -427,29 +422,27 @@ class NeuronavigationPanel(wx.Panel): | @@ -427,29 +422,27 @@ class NeuronavigationPanel(wx.Panel): | ||
427 | for n in [0, 1, 2]: | 422 | for n in [0, 1, 2]: |
428 | self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) | 423 | self.numctrls_coord[m][n].SetValue(float(self.current_coord[n])) |
429 | 424 | ||
430 | - def UpdateObjectRegistration(self, pubsub_evt): | ||
431 | - if pubsub_evt.data: | ||
432 | - self.obj_reg = pubsub_evt.data | 425 | + def UpdateObjectRegistration(self, data=None): |
426 | + if data: | ||
427 | + self.obj_reg = data | ||
433 | self.obj_reg_status = True | 428 | self.obj_reg_status = True |
434 | else: | 429 | else: |
435 | self.obj_reg = None | 430 | self.obj_reg = None |
436 | self.obj_reg_status = False | 431 | self.obj_reg_status = False |
437 | 432 | ||
438 | - def UpdateTrackObjectState(self, pubsub_evt): | ||
439 | - if pubsub_evt.data[0]: | ||
440 | - self.track_obj = pubsub_evt.data[0] | ||
441 | - else: | ||
442 | - self.track_obj = False | 433 | + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): |
434 | + self.track_obj = flag | ||
443 | 435 | ||
444 | - def UpdateTriggerState(self, pubsub_evt): | ||
445 | - self.trigger_state = pubsub_evt.data | 436 | + def UpdateTriggerState(self, trigger_state): |
437 | + self.trigger_state = trigger_state | ||
446 | 438 | ||
447 | - def OnDisconnectTracker(self, pubsub_evt): | 439 | + def OnDisconnectTracker(self): |
448 | if self.tracker_id: | 440 | if self.tracker_id: |
449 | dt.TrackerConnection(self.tracker_id, self.trk_init[0], 'disconnect') | 441 | dt.TrackerConnection(self.tracker_id, self.trk_init[0], 'disconnect') |
450 | 442 | ||
451 | def OnChoiceTracker(self, evt, ctrl): | 443 | def OnChoiceTracker(self, evt, ctrl): |
452 | - Publisher.sendMessage('Update status text in GUI', _("Configuring tracker ...")) | 444 | + Publisher.sendMessage('Update status text in GUI', |
445 | + label=_("Configuring tracker ...")) | ||
453 | if hasattr(evt, 'GetSelection'): | 446 | if hasattr(evt, 'GetSelection'): |
454 | choice = evt.GetSelection() | 447 | choice = evt.GetSelection() |
455 | else: | 448 | else: |
@@ -464,24 +457,28 @@ class NeuronavigationPanel(wx.Panel): | @@ -464,24 +457,28 @@ class NeuronavigationPanel(wx.Panel): | ||
464 | # has been initialized before | 457 | # has been initialized before |
465 | if trck and choice != 6: | 458 | if trck and choice != 6: |
466 | self.ResetTrackerFiducials() | 459 | self.ResetTrackerFiducials() |
467 | - Publisher.sendMessage('Update status text in GUI', _("Disconnecting tracker...")) | 460 | + Publisher.sendMessage('Update status text in GUI', |
461 | + label=_("Disconnecting tracker...")) | ||
468 | Publisher.sendMessage('Remove sensors ID') | 462 | Publisher.sendMessage('Remove sensors ID') |
469 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') | 463 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') |
470 | self.tracker_id = choice | 464 | self.tracker_id = choice |
471 | if not self.trk_init[0] and choice: | 465 | if not self.trk_init[0] and choice: |
472 | - Publisher.sendMessage('Update status text in GUI', _("Tracker disconnected successfully")) | 466 | + Publisher.sendMessage('Update status text in GUI', |
467 | + label=_("Tracker disconnected successfully")) | ||
473 | self.trk_init = dt.TrackerConnection(self.tracker_id, None, 'connect') | 468 | self.trk_init = dt.TrackerConnection(self.tracker_id, None, 'connect') |
474 | if not self.trk_init[0]: | 469 | if not self.trk_init[0]: |
475 | dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) | 470 | dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) |
476 | ctrl.SetSelection(0) | 471 | ctrl.SetSelection(0) |
477 | print("Tracker not connected!") | 472 | print("Tracker not connected!") |
478 | else: | 473 | else: |
479 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | 474 | + Publisher.sendMessage('Update status text in GUI', |
475 | + label=_("Ready")) | ||
480 | ctrl.SetSelection(self.tracker_id) | 476 | ctrl.SetSelection(self.tracker_id) |
481 | print("Tracker connected!") | 477 | print("Tracker connected!") |
482 | elif choice == 6: | 478 | elif choice == 6: |
483 | if trck: | 479 | if trck: |
484 | - Publisher.sendMessage('Update status text in GUI', _("Disconnecting tracker ...")) | 480 | + Publisher.sendMessage('Update status text in GUI', |
481 | + label=_("Disconnecting tracker ...")) | ||
485 | Publisher.sendMessage('Remove sensors ID') | 482 | Publisher.sendMessage('Remove sensors ID') |
486 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') | 483 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') |
487 | if not self.trk_init[0]: | 484 | if not self.trk_init[0]: |
@@ -489,10 +486,12 @@ class NeuronavigationPanel(wx.Panel): | @@ -489,10 +486,12 @@ class NeuronavigationPanel(wx.Panel): | ||
489 | dlg.NavigationTrackerWarning(self.tracker_id, 'disconnect') | 486 | dlg.NavigationTrackerWarning(self.tracker_id, 'disconnect') |
490 | self.tracker_id = 0 | 487 | self.tracker_id = 0 |
491 | ctrl.SetSelection(self.tracker_id) | 488 | ctrl.SetSelection(self.tracker_id) |
492 | - Publisher.sendMessage('Update status text in GUI', _("Tracker disconnected")) | 489 | + Publisher.sendMessage('Update status text in GUI', |
490 | + label=_("Tracker disconnected")) | ||
493 | print("Tracker disconnected!") | 491 | print("Tracker disconnected!") |
494 | else: | 492 | else: |
495 | - Publisher.sendMessage('Update status text in GUI', _("Tracker still connected")) | 493 | + Publisher.sendMessage('Update status text in GUI', |
494 | + label=_("Tracker still connected")) | ||
496 | print("Tracker still connected!") | 495 | print("Tracker still connected!") |
497 | else: | 496 | else: |
498 | ctrl.SetSelection(self.tracker_id) | 497 | ctrl.SetSelection(self.tracker_id) |
@@ -507,9 +506,11 @@ class NeuronavigationPanel(wx.Panel): | @@ -507,9 +506,11 @@ class NeuronavigationPanel(wx.Panel): | ||
507 | self.tracker_id = 0 | 506 | self.tracker_id = 0 |
508 | ctrl.SetSelection(self.tracker_id) | 507 | ctrl.SetSelection(self.tracker_id) |
509 | else: | 508 | else: |
510 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | 509 | + Publisher.sendMessage('Update status text in GUI', |
510 | + label=_("Ready")) | ||
511 | 511 | ||
512 | - Publisher.sendMessage('Update tracker initializer', (self.tracker_id, self.trk_init, self.ref_mode_id)) | 512 | + Publisher.sendMessage('Update tracker initializer', |
513 | + nav_prop=(self.tracker_id, self.trk_init, self.ref_mode_id)) | ||
513 | 514 | ||
514 | def OnChoiceRefMode(self, evt, ctrl): | 515 | def OnChoiceRefMode(self, evt, ctrl): |
515 | # When ref mode is changed the tracker coordinates are set to zero | 516 | # When ref mode is changed the tracker coordinates are set to zero |
@@ -518,7 +519,8 @@ class NeuronavigationPanel(wx.Panel): | @@ -518,7 +519,8 @@ class NeuronavigationPanel(wx.Panel): | ||
518 | # Some trackers do not accept restarting within this time window | 519 | # Some trackers do not accept restarting within this time window |
519 | # TODO: Improve the restarting of trackers after changing reference mode | 520 | # TODO: Improve the restarting of trackers after changing reference mode |
520 | # self.OnChoiceTracker(None, ctrl) | 521 | # self.OnChoiceTracker(None, ctrl) |
521 | - Publisher.sendMessage('Update tracker initializer', (self.tracker_id, self.trk_init, self.ref_mode_id)) | 522 | + Publisher.sendMessage('Update tracker initializer', |
523 | + nav_prop=(self.tracker_id, self.trk_init, self.ref_mode_id)) | ||
522 | print("Reference mode changed!") | 524 | print("Reference mode changed!") |
523 | 525 | ||
524 | def OnSetImageCoordinates(self, evt): | 526 | def OnSetImageCoordinates(self, evt): |
@@ -529,10 +531,10 @@ class NeuronavigationPanel(wx.Panel): | @@ -529,10 +531,10 @@ class NeuronavigationPanel(wx.Panel): | ||
529 | self.numctrls_coord[btn_id][1].GetValue(),\ | 531 | self.numctrls_coord[btn_id][1].GetValue(),\ |
530 | self.numctrls_coord[btn_id][2].GetValue() | 532 | self.numctrls_coord[btn_id][2].GetValue() |
531 | 533 | ||
532 | - Publisher.sendMessage('Set ball reference position', (ux, uy, uz)) | 534 | + Publisher.sendMessage('Set ball reference position', position=(ux, uy, uz)) |
533 | # Publisher.sendMessage('Set camera in volume', (ux, uy, uz)) | 535 | # Publisher.sendMessage('Set camera in volume', (ux, uy, uz)) |
534 | - Publisher.sendMessage('Co-registered points', ((ux, uy, uz), (0., 0., 0.))) | ||
535 | - Publisher.sendMessage('Update cross position', (ux, uy, uz)) | 536 | + Publisher.sendMessage('Co-registered points', arg=(ux, uy, uz), position=(0., 0., 0.)) |
537 | + Publisher.sendMessage('Update cross position', position=(ux, uy, uz)) | ||
536 | 538 | ||
537 | def OnImageFiducials(self, evt): | 539 | def OnImageFiducials(self, evt): |
538 | btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] | 540 | btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] |
@@ -544,13 +546,13 @@ class NeuronavigationPanel(wx.Panel): | @@ -544,13 +546,13 @@ class NeuronavigationPanel(wx.Panel): | ||
544 | self.numctrls_coord[btn_id][2].GetValue(), 0, 0, 0 | 546 | self.numctrls_coord[btn_id][2].GetValue(), 0, 0, 0 |
545 | 547 | ||
546 | self.fiducials[btn_id, :] = coord[0:3] | 548 | self.fiducials[btn_id, :] = coord[0:3] |
547 | - Publisher.sendMessage('Create marker', (coord, marker_id)) | 549 | + Publisher.sendMessage('Create marker', coord=coord, marker_id=marker_id) |
548 | else: | 550 | else: |
549 | for n in [0, 1, 2]: | 551 | for n in [0, 1, 2]: |
550 | self.numctrls_coord[btn_id][n].SetValue(float(self.current_coord[n])) | 552 | self.numctrls_coord[btn_id][n].SetValue(float(self.current_coord[n])) |
551 | 553 | ||
552 | self.fiducials[btn_id, :] = np.nan | 554 | self.fiducials[btn_id, :] = np.nan |
553 | - Publisher.sendMessage('Delete fiducial marker', marker_id) | 555 | + Publisher.sendMessage('Delete fiducial marker', marker_id=marker_id) |
554 | 556 | ||
555 | def OnTrackerFiducials(self, evt): | 557 | def OnTrackerFiducials(self, evt): |
556 | btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0] | 558 | btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0] |
@@ -627,8 +629,8 @@ class NeuronavigationPanel(wx.Panel): | @@ -627,8 +629,8 @@ class NeuronavigationPanel(wx.Panel): | ||
627 | if self.trigger_state: | 629 | if self.trigger_state: |
628 | self.trigger = trig.Trigger(nav_id) | 630 | self.trigger = trig.Trigger(nav_id) |
629 | 631 | ||
630 | - Publisher.sendMessage("Navigation status", True) | ||
631 | - Publisher.sendMessage("Toggle Cross", const.SLICE_STATE_CROSS) | 632 | + Publisher.sendMessage("Navigation status", status=True) |
633 | + Publisher.sendMessage("Toggle Cross", id=const.SLICE_STATE_CROSS) | ||
632 | Publisher.sendMessage("Hide current mask") | 634 | Publisher.sendMessage("Hide current mask") |
633 | 635 | ||
634 | if self.track_obj: | 636 | if self.track_obj: |
@@ -682,7 +684,7 @@ class NeuronavigationPanel(wx.Panel): | @@ -682,7 +684,7 @@ class NeuronavigationPanel(wx.Panel): | ||
682 | 684 | ||
683 | self.correg.stop() | 685 | self.correg.stop() |
684 | 686 | ||
685 | - Publisher.sendMessage("Navigation status", False) | 687 | + Publisher.sendMessage("Navigation status", status=False) |
686 | 688 | ||
687 | def ResetImageFiducials(self): | 689 | def ResetImageFiducials(self): |
688 | for m in range(0, 3): | 690 | for m in range(0, 3): |
@@ -703,13 +705,13 @@ class NeuronavigationPanel(wx.Panel): | @@ -703,13 +705,13 @@ class NeuronavigationPanel(wx.Panel): | ||
703 | self.txtctrl_fre.SetValue('') | 705 | self.txtctrl_fre.SetValue('') |
704 | self.txtctrl_fre.SetBackgroundColour('WHITE') | 706 | self.txtctrl_fre.SetBackgroundColour('WHITE') |
705 | 707 | ||
706 | - def OnCloseProject(self, pubsub_evt): | 708 | + def OnCloseProject(self): |
707 | self.ResetTrackerFiducials() | 709 | self.ResetTrackerFiducials() |
708 | self.ResetImageFiducials() | 710 | self.ResetImageFiducials() |
709 | self.OnChoiceTracker(False, self.choice_trck) | 711 | self.OnChoiceTracker(False, self.choice_trck) |
710 | - Publisher.sendMessage('Update object registration', False) | ||
711 | - Publisher.sendMessage('Update track object state', (False, False)) | ||
712 | - Publisher.sendMessage('Delete all markers', 'close') | 712 | + Publisher.sendMessage('Update object registration') |
713 | + Publisher.sendMessage('Update track object state', flag=False, obj_name=False) | ||
714 | + Publisher.sendMessage('Delete all markers') | ||
713 | # TODO: Reset camera initial focus | 715 | # TODO: Reset camera initial focus |
714 | Publisher.sendMessage('Reset cam clipping range') | 716 | Publisher.sendMessage('Reset cam clipping range') |
715 | 717 | ||
@@ -838,11 +840,11 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -838,11 +840,11 @@ class ObjectRegistrationPanel(wx.Panel): | ||
838 | Publisher.subscribe(self.UpdateNavigationStatus, 'Navigation status') | 840 | Publisher.subscribe(self.UpdateNavigationStatus, 'Navigation status') |
839 | Publisher.subscribe(self.OnCloseProject, 'Close project data') | 841 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
840 | 842 | ||
841 | - def UpdateTrackerInit(self, pubsub_evt): | ||
842 | - self.nav_prop = pubsub_evt.data | 843 | + def UpdateTrackerInit(self, nav_prop): |
844 | + self.nav_prop = nav_prop | ||
843 | 845 | ||
844 | - def UpdateNavigationStatus(self, pubsub_evt): | ||
845 | - nav_status = pubsub_evt.data | 846 | + def UpdateNavigationStatus(self, status): |
847 | + nav_status = status | ||
846 | if nav_status: | 848 | if nav_status: |
847 | self.checkrecordcoords.Enable(1) | 849 | self.checkrecordcoords.Enable(1) |
848 | self.checktrack.Enable(0) | 850 | self.checktrack.Enable(0) |
@@ -861,10 +863,10 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -861,10 +863,10 @@ class ObjectRegistrationPanel(wx.Panel): | ||
861 | Publisher.sendMessage('Enable target button', True) | 863 | Publisher.sendMessage('Enable target button', True) |
862 | 864 | ||
863 | def OnSelectAngleThreshold(self, evt, ctrl): | 865 | def OnSelectAngleThreshold(self, evt, ctrl): |
864 | - Publisher.sendMessage('Update angle threshold', ctrl.GetValue()) | 866 | + Publisher.sendMessage('Update angle threshold', angle=ctrl.GetValue()) |
865 | 867 | ||
866 | def OnSelectDistThreshold(self, evt, ctrl): | 868 | def OnSelectDistThreshold(self, evt, ctrl): |
867 | - Publisher.sendMessage('Update dist threshold', ctrl.GetValue()) | 869 | + Publisher.sendMessage('Update dist threshold', dist_threshold=ctrl.GetValue()) |
868 | 870 | ||
869 | def OnSelectTimestamp(self, evt, ctrl): | 871 | def OnSelectTimestamp(self, evt, ctrl): |
870 | self.timestamp = ctrl.GetValue() | 872 | self.timestamp = ctrl.GetValue() |
@@ -880,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -880,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): | ||
880 | None | 882 | None |
881 | 883 | ||
882 | def OnTrackObject(self, evt, ctrl): | 884 | def OnTrackObject(self, evt, ctrl): |
883 | - Publisher.sendMessage('Update track object state', (evt.GetSelection(), self.obj_name)) | 885 | + Publisher.sendMessage('Update track object state', flag=evt.GetSelection(), obj_name=self.obj_name) |
884 | 886 | ||
885 | def OnComboCoil(self, evt): | 887 | def OnComboCoil(self, evt): |
886 | # coil_name = evt.GetString() | 888 | # coil_name = evt.GetString() |
@@ -897,8 +899,9 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -897,8 +899,9 @@ class ObjectRegistrationPanel(wx.Panel): | ||
897 | if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): | 899 | if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): |
898 | self.checktrack.Enable(1) | 900 | self.checktrack.Enable(1) |
899 | Publisher.sendMessage('Update object registration', | 901 | Publisher.sendMessage('Update object registration', |
900 | - (self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) | ||
901 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | 902 | + data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) |
903 | + Publisher.sendMessage('Update status text in GUI', | ||
904 | + label=_("Ready")) | ||
902 | 905 | ||
903 | except wx._core.PyAssertionError: # TODO FIX: win64 | 906 | except wx._core.PyAssertionError: # TODO FIX: win64 |
904 | pass | 907 | pass |
@@ -923,8 +926,8 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -923,8 +926,8 @@ class ObjectRegistrationPanel(wx.Panel): | ||
923 | 926 | ||
924 | self.checktrack.Enable(1) | 927 | self.checktrack.Enable(1) |
925 | Publisher.sendMessage('Update object registration', | 928 | Publisher.sendMessage('Update object registration', |
926 | - (self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) | ||
927 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | 929 | + data=(self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name)) |
930 | + Publisher.sendMessage('Update status text in GUI', label=_("Ready")) | ||
928 | wx.MessageBox(_("Object file successfully loaded"), _("Load")) | 931 | wx.MessageBox(_("Object file successfully loaded"), _("Load")) |
929 | 932 | ||
930 | def ShowSaveObjectDialog(self, evt): | 933 | def ShowSaveObjectDialog(self, evt): |
@@ -938,7 +941,7 @@ class ObjectRegistrationPanel(wx.Panel): | @@ -938,7 +941,7 @@ class ObjectRegistrationPanel(wx.Panel): | ||
938 | np.savetxt(filename, data, fmt='%.4f', delimiter='\t', newline='\n', header=hdr) | 941 | np.savetxt(filename, data, fmt='%.4f', delimiter='\t', newline='\n', header=hdr) |
939 | wx.MessageBox(_("Object file successfully saved"), _("Save")) | 942 | wx.MessageBox(_("Object file successfully saved"), _("Save")) |
940 | 943 | ||
941 | - def OnCloseProject(self, pubsub_evt): | 944 | + def OnCloseProject(self): |
942 | self.checkrecordcoords.SetValue(False) | 945 | self.checkrecordcoords.SetValue(False) |
943 | self.checkrecordcoords.Enable(0) | 946 | self.checkrecordcoords.Enable(0) |
944 | self.checktrack.SetValue(False) | 947 | self.checktrack.SetValue(False) |
@@ -1054,12 +1057,12 @@ class MarkersPanel(wx.Panel): | @@ -1054,12 +1057,12 @@ class MarkersPanel(wx.Panel): | ||
1054 | Publisher.subscribe(self.OnCreateMarker, 'Create marker') | 1057 | Publisher.subscribe(self.OnCreateMarker, 'Create marker') |
1055 | Publisher.subscribe(self.UpdateNavigationStatus, 'Navigation status') | 1058 | Publisher.subscribe(self.UpdateNavigationStatus, 'Navigation status') |
1056 | 1059 | ||
1057 | - def UpdateCurrentCoord(self, pubsub_evt): | ||
1058 | - self.current_coord = pubsub_evt.data[1][:] | 1060 | + def UpdateCurrentCoord(self, arg, position): |
1061 | + self.current_coord = position[:] | ||
1059 | #self.current_angle = pubsub_evt.data[1][3:] | 1062 | #self.current_angle = pubsub_evt.data[1][3:] |
1060 | 1063 | ||
1061 | - def UpdateNavigationStatus(self, pubsub_evt): | ||
1062 | - if pubsub_evt.data is False: | 1064 | + def UpdateNavigationStatus(self, status): |
1065 | + if not status: | ||
1063 | sleep(0.5) | 1066 | sleep(0.5) |
1064 | #self.current_coord[3:] = 0, 0, 0 | 1067 | #self.current_coord[3:] = 0, 0, 0 |
1065 | self.nav_status = False | 1068 | self.nav_status = False |
@@ -1080,7 +1083,7 @@ class MarkersPanel(wx.Panel): | @@ -1080,7 +1083,7 @@ class MarkersPanel(wx.Panel): | ||
1080 | menu_id.Destroy() | 1083 | menu_id.Destroy() |
1081 | 1084 | ||
1082 | def OnItemBlink(self, evt): | 1085 | def OnItemBlink(self, evt): |
1083 | - Publisher.sendMessage('Blink Marker', self.lc.GetFocusedItem()) | 1086 | + Publisher.sendMessage('Blink Marker', index=self.lc.GetFocusedItem()) |
1084 | 1087 | ||
1085 | def OnStopItemBlink(self, evt): | 1088 | def OnStopItemBlink(self, evt): |
1086 | Publisher.sendMessage('Stop Blink Marker') | 1089 | Publisher.sendMessage('Stop Blink Marker') |
@@ -1107,7 +1110,7 @@ class MarkersPanel(wx.Panel): | @@ -1107,7 +1110,7 @@ class MarkersPanel(wx.Panel): | ||
1107 | 1110 | ||
1108 | if self.tgt_flag: | 1111 | if self.tgt_flag: |
1109 | self.lc.SetItemBackgroundColour(self.tgt_index, 'white') | 1112 | self.lc.SetItemBackgroundColour(self.tgt_index, 'white') |
1110 | - Publisher.sendMessage('Set target transparency', [False, self.tgt_index]) | 1113 | + Publisher.sendMessage('Set target transparency', status=False, index=self.tgt_index) |
1111 | self.lc.SetStringItem(self.tgt_index, 4, '') | 1114 | self.lc.SetStringItem(self.tgt_index, 4, '') |
1112 | # Add the new ID to exported list | 1115 | # Add the new ID to exported list |
1113 | if len(self.list_coord[self.tgt_index]) > 8: | 1116 | if len(self.list_coord[self.tgt_index]) > 8: |
@@ -1118,16 +1121,16 @@ class MarkersPanel(wx.Panel): | @@ -1118,16 +1121,16 @@ class MarkersPanel(wx.Panel): | ||
1118 | self.tgt_index = self.lc.GetFocusedItem() | 1121 | self.tgt_index = self.lc.GetFocusedItem() |
1119 | self.lc.SetItemBackgroundColour(self.tgt_index, 'RED') | 1122 | self.lc.SetItemBackgroundColour(self.tgt_index, 'RED') |
1120 | 1123 | ||
1121 | - Publisher.sendMessage('Update target', self.list_coord[self.tgt_index]) | ||
1122 | - Publisher.sendMessage('Set target transparency', [True, self.tgt_index]) | ||
1123 | - Publisher.sendMessage('Disable or enable coil tracker', True) | 1124 | + Publisher.sendMessage('Update target', coord=self.list_coord[self.tgt_index]) |
1125 | + Publisher.sendMessage('Set target transparency', status=True, index=self.tgt_index) | ||
1126 | + Publisher.sendMessage('Disable or enable coil tracker', status=True) | ||
1124 | self.OnMenuEditMarkerId('TARGET') | 1127 | self.OnMenuEditMarkerId('TARGET') |
1125 | self.tgt_flag = True | 1128 | self.tgt_flag = True |
1126 | dlg.NewTarget() | 1129 | dlg.NewTarget() |
1127 | 1130 | ||
1128 | - def OnDeleteAllMarkers(self, evt): | 1131 | + def OnDeleteAllMarkers(self, evt=None): |
1129 | if self.list_coord: | 1132 | if self.list_coord: |
1130 | - if hasattr(evt, 'data'): | 1133 | + if evt is None: |
1131 | result = wx.ID_OK | 1134 | result = wx.ID_OK |
1132 | else: | 1135 | else: |
1133 | result = dlg.DeleteAllMarkers() | 1136 | result = dlg.DeleteAllMarkers() |
@@ -1135,22 +1138,21 @@ class MarkersPanel(wx.Panel): | @@ -1135,22 +1138,21 @@ class MarkersPanel(wx.Panel): | ||
1135 | if result == wx.ID_OK: | 1138 | if result == wx.ID_OK: |
1136 | self.list_coord = [] | 1139 | self.list_coord = [] |
1137 | self.marker_ind = 0 | 1140 | self.marker_ind = 0 |
1138 | - Publisher.sendMessage('Remove all markers', self.lc.GetItemCount()) | 1141 | + Publisher.sendMessage('Remove all markers', indexes=self.lc.GetItemCount()) |
1139 | self.lc.DeleteAllItems() | 1142 | self.lc.DeleteAllItems() |
1140 | - Publisher.sendMessage('Stop Blink Marker', 'DeleteAll') | 1143 | + Publisher.sendMessage('Stop Blink Marker', index='DeleteAll') |
1141 | 1144 | ||
1142 | if self.tgt_flag: | 1145 | if self.tgt_flag: |
1143 | self.tgt_flag = self.tgt_index = None | 1146 | self.tgt_flag = self.tgt_index = None |
1144 | - Publisher.sendMessage('Disable or enable coil tracker', False) | 1147 | + Publisher.sendMessage('Disable or enable coil tracker', status=False) |
1145 | if not hasattr(evt, 'data'): | 1148 | if not hasattr(evt, 'data'): |
1146 | dlg.DeleteTarget() | 1149 | dlg.DeleteTarget() |
1147 | 1150 | ||
1148 | - def OnDeleteSingleMarker(self, evt): | 1151 | + def OnDeleteSingleMarker(self, evt=None, marker_id=None): |
1149 | # OnDeleteSingleMarker is used for both pubsub and button click events | 1152 | # OnDeleteSingleMarker is used for both pubsub and button click events |
1150 | # Pubsub is used for fiducial handle and button click for all others | 1153 | # Pubsub is used for fiducial handle and button click for all others |
1151 | 1154 | ||
1152 | - if hasattr(evt, 'data'): | ||
1153 | - marker_id = evt.data | 1155 | + if marker_id is not None: |
1154 | if self.lc.GetItemCount(): | 1156 | if self.lc.GetItemCount(): |
1155 | for id_n in range(self.lc.GetItemCount()): | 1157 | for id_n in range(self.lc.GetItemCount()): |
1156 | item = self.lc.GetItem(id_n, 4) | 1158 | item = self.lc.GetItem(id_n, 4) |
@@ -1168,7 +1170,7 @@ class MarkersPanel(wx.Panel): | @@ -1168,7 +1170,7 @@ class MarkersPanel(wx.Panel): | ||
1168 | if index: | 1170 | if index: |
1169 | if self.tgt_flag and self.tgt_index == index[0]: | 1171 | if self.tgt_flag and self.tgt_index == index[0]: |
1170 | self.tgt_flag = self.tgt_index = None | 1172 | self.tgt_flag = self.tgt_index = None |
1171 | - Publisher.sendMessage('Disable or enable coil tracker', False) | 1173 | + Publisher.sendMessage('Disable or enable coil tracker', status=False) |
1172 | dlg.DeleteTarget() | 1174 | dlg.DeleteTarget() |
1173 | self.DeleteMarker(index) | 1175 | self.DeleteMarker(index) |
1174 | else: | 1176 | else: |
@@ -1181,14 +1183,14 @@ class MarkersPanel(wx.Panel): | @@ -1181,14 +1183,14 @@ class MarkersPanel(wx.Panel): | ||
1181 | for n in range(0, self.lc.GetItemCount()): | 1183 | for n in range(0, self.lc.GetItemCount()): |
1182 | self.lc.SetStringItem(n, 0, str(n+1)) | 1184 | self.lc.SetStringItem(n, 0, str(n+1)) |
1183 | self.marker_ind -= 1 | 1185 | self.marker_ind -= 1 |
1184 | - Publisher.sendMessage('Remove marker', index) | 1186 | + Publisher.sendMessage('Remove marker', index=index) |
1185 | 1187 | ||
1186 | - def OnCreateMarker(self, evt): | 1188 | + def OnCreateMarker(self, evt=None, coord=None, marker_id=None): |
1187 | # OnCreateMarker is used for both pubsub and button click events | 1189 | # OnCreateMarker is used for both pubsub and button click events |
1188 | # Pubsub is used for markers created with fiducial buttons, trigger and create marker button | 1190 | # Pubsub is used for markers created with fiducial buttons, trigger and create marker button |
1189 | - if hasattr(evt, 'data'): | ||
1190 | - if evt.data is not None: | ||
1191 | - self.CreateMarker(evt.data[0], (0.0, 1.0, 0.0), self.marker_size, evt.data[1]) | 1191 | + if evt is None: |
1192 | + if coord: | ||
1193 | + self.CreateMarker(coord, (0.0, 1.0, 0.0), self.marker_size, marker_id) | ||
1192 | else: | 1194 | else: |
1193 | self.CreateMarker(self.current_coord, self.marker_colour, self.marker_size) | 1195 | self.CreateMarker(self.current_coord, self.marker_colour, self.marker_size) |
1194 | else: | 1196 | else: |
@@ -1212,7 +1214,7 @@ class MarkersPanel(wx.Panel): | @@ -1212,7 +1214,7 @@ class MarkersPanel(wx.Panel): | ||
1212 | if len(line) == 11: | 1214 | if len(line) == 11: |
1213 | for i in const.BTNS_IMG_MKS: | 1215 | for i in const.BTNS_IMG_MKS: |
1214 | if line[10] in list(const.BTNS_IMG_MKS[i].values())[0]: | 1216 | if line[10] in list(const.BTNS_IMG_MKS[i].values())[0]: |
1215 | - Publisher.sendMessage('Load image fiducials', (line[10], coord)) | 1217 | + Publisher.sendMessage('Load image fiducials', marker_id=line[10], coord=coord) |
1216 | elif line[10] == 'TARGET': | 1218 | elif line[10] == 'TARGET': |
1217 | target = count_line | 1219 | target = count_line |
1218 | else: | 1220 | else: |
@@ -1230,7 +1232,7 @@ class MarkersPanel(wx.Panel): | @@ -1230,7 +1232,7 @@ class MarkersPanel(wx.Panel): | ||
1230 | if len(line) == 8: | 1232 | if len(line) == 8: |
1231 | for i in const.BTNS_IMG_MKS: | 1233 | for i in const.BTNS_IMG_MKS: |
1232 | if line[7] in list(const.BTNS_IMG_MKS[i].values())[0]: | 1234 | if line[7] in list(const.BTNS_IMG_MKS[i].values())[0]: |
1233 | - Publisher.sendMessage('Load image fiducials', (line[7], coord)) | 1235 | + Publisher.sendMessage('Load image fiducials', marker_id=line[7], coord=coord) |
1234 | else: | 1236 | else: |
1235 | line.append("") | 1237 | line.append("") |
1236 | self.CreateMarker(coord, colour, size, line[7]) | 1238 | self.CreateMarker(coord, colour, size, line[7]) |
@@ -1241,10 +1243,10 @@ class MarkersPanel(wx.Panel): | @@ -1241,10 +1243,10 @@ class MarkersPanel(wx.Panel): | ||
1241 | def OnMarkersVisibility(self, evt, ctrl): | 1243 | def OnMarkersVisibility(self, evt, ctrl): |
1242 | 1244 | ||
1243 | if ctrl.GetValue(): | 1245 | if ctrl.GetValue(): |
1244 | - Publisher.sendMessage('Hide all markers', self.lc.GetItemCount()) | 1246 | + Publisher.sendMessage('Hide all markers', indexes=self.lc.GetItemCount()) |
1245 | ctrl.SetLabel('Show') | 1247 | ctrl.SetLabel('Show') |
1246 | else: | 1248 | else: |
1247 | - Publisher.sendMessage('Show all markers', self.lc.GetItemCount()) | 1249 | + Publisher.sendMessage('Show all markers', indexes=self.lc.GetItemCount()) |
1248 | ctrl.SetLabel('Hide') | 1250 | ctrl.SetLabel('Hide') |
1249 | 1251 | ||
1250 | def OnSaveMarkers(self, evt): | 1252 | def OnSaveMarkers(self, evt): |
@@ -1278,7 +1280,7 @@ class MarkersPanel(wx.Panel): | @@ -1278,7 +1280,7 @@ class MarkersPanel(wx.Panel): | ||
1278 | # TODO: Use matrix coordinates and not world coordinates as current method. | 1280 | # TODO: Use matrix coordinates and not world coordinates as current method. |
1279 | # This makes easier for inter-software comprehension. | 1281 | # This makes easier for inter-software comprehension. |
1280 | 1282 | ||
1281 | - Publisher.sendMessage('Add marker', (self.marker_ind, size, colour, coord[0:3])) | 1283 | + Publisher.sendMessage('Add marker', ball_id=self.marker_ind, size=size, colour=colour, coord=coord[0:3]) |
1282 | 1284 | ||
1283 | self.marker_ind += 1 | 1285 | self.marker_ind += 1 |
1284 | 1286 |
invesalius/gui/task_slice.py
@@ -190,7 +190,7 @@ class InnerTaskPanel(wx.Panel): | @@ -190,7 +190,7 @@ class InnerTaskPanel(wx.Panel): | ||
190 | "overwrite": overwrite} | 190 | "overwrite": overwrite} |
191 | 191 | ||
192 | Publisher.sendMessage('Create surface from index', | 192 | Publisher.sendMessage('Create surface from index', |
193 | - {'method': method, 'options': srf_options}) | 193 | + surface_parameters={'method': method, 'options': srf_options}) |
194 | Publisher.sendMessage('Fold surface task') | 194 | Publisher.sendMessage('Fold surface task') |
195 | 195 | ||
196 | else: | 196 | else: |
@@ -218,7 +218,9 @@ class InnerTaskPanel(wx.Panel): | @@ -218,7 +218,9 @@ class InnerTaskPanel(wx.Panel): | ||
218 | mask_name, thresh, colour = dialog.GetValue() | 218 | mask_name, thresh, colour = dialog.GetValue() |
219 | if mask_name: | 219 | if mask_name: |
220 | Publisher.sendMessage('Create new mask', | 220 | Publisher.sendMessage('Create new mask', |
221 | - (mask_name, thresh, colour)) | 221 | + mask_name=mask_name, |
222 | + thresh=thresh, | ||
223 | + colour=colour) | ||
222 | dialog.Destroy() | 224 | dialog.Destroy() |
223 | 225 | ||
224 | def GetMaskSelected(self): | 226 | def GetMaskSelected(self): |
@@ -371,23 +373,21 @@ class InnerFoldPanel(wx.Panel): | @@ -371,23 +373,21 @@ class InnerFoldPanel(wx.Panel): | ||
371 | 373 | ||
372 | if self.__id_editor == id: | 374 | if self.__id_editor == id: |
373 | if closed: | 375 | if closed: |
374 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_EDITOR) | 376 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_EDITOR) |
375 | self.last_style = None | 377 | self.last_style = None |
376 | else: | 378 | else: |
377 | - Publisher.sendMessage('Enable style', | ||
378 | - const.SLICE_STATE_EDITOR) | 379 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_EDITOR) |
379 | self.last_style = const.SLICE_STATE_EDITOR | 380 | self.last_style = const.SLICE_STATE_EDITOR |
380 | elif self.__id_watershed == id: | 381 | elif self.__id_watershed == id: |
381 | if closed: | 382 | if closed: |
382 | - Publisher.sendMessage('Disable style', | ||
383 | - const.SLICE_STATE_WATERSHED) | 383 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_WATERSHED) |
384 | self.last_style = None | 384 | self.last_style = None |
385 | else: | 385 | else: |
386 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_WATERSHED) | ||
387 | - Publisher.sendMessage('Show help message', 'Mark the object and the background') | 386 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_WATERSHED) |
387 | + # Publisher.sendMessage('Show help message', 'Mark the object and the background') | ||
388 | self.last_style = const.SLICE_STATE_WATERSHED | 388 | self.last_style = const.SLICE_STATE_WATERSHED |
389 | else: | 389 | else: |
390 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_EDITOR) | 390 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_EDITOR) |
391 | self.last_style = None | 391 | self.last_style = None |
392 | 392 | ||
393 | evt.Skip() | 393 | evt.Skip() |
@@ -399,18 +399,18 @@ class InnerFoldPanel(wx.Panel): | @@ -399,18 +399,18 @@ class InnerFoldPanel(wx.Panel): | ||
399 | self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) | 399 | self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) |
400 | self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) | 400 | self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) |
401 | 401 | ||
402 | - def OnRetrieveStyle(self, pubsub_evt): | 402 | + def OnRetrieveStyle(self): |
403 | if (self.last_style == const.SLICE_STATE_EDITOR): | 403 | if (self.last_style == const.SLICE_STATE_EDITOR): |
404 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_EDITOR) | 404 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_EDITOR) |
405 | 405 | ||
406 | - def OnDisableStyle(self, pubsub_evt): | 406 | + def OnDisableStyle(self): |
407 | if (self.last_style == const.SLICE_STATE_EDITOR): | 407 | if (self.last_style == const.SLICE_STATE_EDITOR): |
408 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_EDITOR) | 408 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_EDITOR) |
409 | 409 | ||
410 | - def OnCloseProject(self, pubsub_evt): | 410 | + def OnCloseProject(self): |
411 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0)) | 411 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(0)) |
412 | 412 | ||
413 | - def OnColapsePanel(self, pubsub_evt): | 413 | + def OnColapsePanel(self, panel_id): |
414 | panel_seg_id = { | 414 | panel_seg_id = { |
415 | const.ID_THRESHOLD_SEGMENTATION: 0, | 415 | const.ID_THRESHOLD_SEGMENTATION: 0, |
416 | const.ID_MANUAL_SEGMENTATION: 1, | 416 | const.ID_MANUAL_SEGMENTATION: 1, |
@@ -418,7 +418,7 @@ class InnerFoldPanel(wx.Panel): | @@ -418,7 +418,7 @@ class InnerFoldPanel(wx.Panel): | ||
418 | } | 418 | } |
419 | 419 | ||
420 | try: | 420 | try: |
421 | - _id = panel_seg_id[pubsub_evt.data] | 421 | + _id = panel_seg_id[panel_id] |
422 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(_id)) | 422 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(_id)) |
423 | except KeyError: | 423 | except KeyError: |
424 | pass | 424 | pass |
@@ -515,7 +515,7 @@ class MaskProperties(wx.Panel): | @@ -515,7 +515,7 @@ class MaskProperties(wx.Panel): | ||
515 | Publisher.subscribe(self.OnCloseProject, 'Close project data') | 515 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
516 | Publisher.subscribe(self.SetThresholdValues2, 'Set threshold values') | 516 | Publisher.subscribe(self.SetThresholdValues2, 'Set threshold values') |
517 | 517 | ||
518 | - def OnCloseProject(self, pubsub_evt): | 518 | + def OnCloseProject(self): |
519 | self.CloseProject() | 519 | self.CloseProject() |
520 | 520 | ||
521 | def CloseProject(self): | 521 | def CloseProject(self): |
@@ -526,9 +526,8 @@ class MaskProperties(wx.Panel): | @@ -526,9 +526,8 @@ class MaskProperties(wx.Panel): | ||
526 | for i in range(n-1, -1, -1): | 526 | for i in range(n-1, -1, -1): |
527 | self.combo_thresh.Delete(i) | 527 | self.combo_thresh.Delete(i) |
528 | 528 | ||
529 | - def OnRemoveMasks(self, pubsub_evt): | ||
530 | - list_index = pubsub_evt.data | ||
531 | - for i in list_index: | 529 | + def OnRemoveMasks(self, mask_indexes): |
530 | + for i in mask_indexes: | ||
532 | self.combo_mask_name.Delete(i) | 531 | self.combo_mask_name.Delete(i) |
533 | 532 | ||
534 | if self.combo_mask_name.IsEmpty(): | 533 | if self.combo_mask_name.IsEmpty(): |
@@ -543,20 +542,18 @@ class MaskProperties(wx.Panel): | @@ -543,20 +542,18 @@ class MaskProperties(wx.Panel): | ||
543 | self.combo_mask_name.Bind(wx.EVT_COMBOBOX, self.OnComboName) | 542 | self.combo_mask_name.Bind(wx.EVT_COMBOBOX, self.OnComboName) |
544 | self.button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) | 543 | self.button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour) |
545 | 544 | ||
546 | - def SelectMaskName(self, pubsub_evt): | ||
547 | - index = pubsub_evt.data | 545 | + def SelectMaskName(self, index): |
548 | if index >= 0: | 546 | if index >= 0: |
549 | self.combo_mask_name.SetSelection(index) | 547 | self.combo_mask_name.SetSelection(index) |
550 | else: | 548 | else: |
551 | self.combo_mask_name.SetValue('') | 549 | self.combo_mask_name.SetValue('') |
552 | 550 | ||
553 | - def ChangeMaskName(self, pubsub_evt): | ||
554 | - index, name = pubsub_evt.data | 551 | + def ChangeMaskName(self, index, name): |
555 | self.combo_mask_name.SetString(index, name) | 552 | self.combo_mask_name.SetString(index, name) |
556 | self.combo_mask_name.Refresh() | 553 | self.combo_mask_name.Refresh() |
557 | 554 | ||
558 | - def SetThresholdValues(self, pubsub_evt): | ||
559 | - thresh_min, thresh_max = pubsub_evt.data | 555 | + def SetThresholdValues(self, threshold_range): |
556 | + thresh_min, thresh_max = threshold_range | ||
560 | self.bind_evt_gradient = False | 557 | self.bind_evt_gradient = False |
561 | self.gradient.SetMinValue(thresh_min) | 558 | self.gradient.SetMinValue(thresh_min) |
562 | self.gradient.SetMaxValue(thresh_max) | 559 | self.gradient.SetMaxValue(thresh_max) |
@@ -572,8 +569,8 @@ class MaskProperties(wx.Panel): | @@ -572,8 +569,8 @@ class MaskProperties(wx.Panel): | ||
572 | self.combo_thresh.SetSelection(index) | 569 | self.combo_thresh.SetSelection(index) |
573 | Project().threshold_modes[_("Custom")] = (thresh_min, thresh_max) | 570 | Project().threshold_modes[_("Custom")] = (thresh_min, thresh_max) |
574 | 571 | ||
575 | - def SetThresholdValues2(self, pubsub_evt): | ||
576 | - thresh_min, thresh_max = pubsub_evt.data | 572 | + def SetThresholdValues2(self, threshold_range): |
573 | + thresh_min, thresh_max = threshold_range | ||
577 | self.gradient.SetMinValue(thresh_min) | 574 | self.gradient.SetMinValue(thresh_min) |
578 | self.gradient.SetMaxValue(thresh_max) | 575 | self.gradient.SetMaxValue(thresh_max) |
579 | thresh = (thresh_min, thresh_max) | 576 | thresh = (thresh_min, thresh_max) |
@@ -586,17 +583,16 @@ class MaskProperties(wx.Panel): | @@ -586,17 +583,16 @@ class MaskProperties(wx.Panel): | ||
586 | self.combo_thresh.SetSelection(index) | 583 | self.combo_thresh.SetSelection(index) |
587 | Project().threshold_modes[_("Custom")] = (thresh_min, thresh_max) | 584 | Project().threshold_modes[_("Custom")] = (thresh_min, thresh_max) |
588 | 585 | ||
589 | - def SetItemsColour(self, evt_pubsub): | ||
590 | - colour = evt_pubsub.data | 586 | + def SetItemsColour(self, colour): |
591 | self.gradient.SetColour(colour) | 587 | self.gradient.SetColour(colour) |
592 | self.button_colour.SetColour(colour) | 588 | self.button_colour.SetColour(colour) |
593 | 589 | ||
594 | - def AddMask(self, evt_pubsub): | 590 | + def AddMask(self, mask): |
595 | if self.combo_mask_name.IsEmpty(): | 591 | if self.combo_mask_name.IsEmpty(): |
596 | self.Enable() | 592 | self.Enable() |
597 | - mask_name = evt_pubsub.data[1] | ||
598 | - mask_thresh = evt_pubsub.data[2] | ||
599 | - mask_colour = [int(c*255) for c in evt_pubsub.data[3]] | 593 | + mask_name = mask.name |
594 | + mask_thresh = mask.threshold_range | ||
595 | + mask_colour = [int(c*255) for c in mask.colour] | ||
600 | index = self.combo_mask_name.Append(mask_name) | 596 | index = self.combo_mask_name.Append(mask_name) |
601 | # self.combo_mask_name.SetSelection(index) | 597 | # self.combo_mask_name.SetSelection(index) |
602 | # self.button_colour.SetColour(mask_colour) | 598 | # self.button_colour.SetColour(mask_colour) |
@@ -607,8 +603,7 @@ class MaskProperties(wx.Panel): | @@ -607,8 +603,7 @@ class MaskProperties(wx.Panel): | ||
607 | x = self.combo_mask_name.GetSelection() | 603 | x = self.combo_mask_name.GetSelection() |
608 | return self.combo_mask_name.GetSelection() | 604 | return self.combo_mask_name.GetSelection() |
609 | 605 | ||
610 | - def SetThresholdModes(self, pubsub_evt): | ||
611 | - (thresh_modes_names, default_thresh) = pubsub_evt.data | 606 | + def SetThresholdModes(self, thresh_modes_names, default_thresh): |
612 | self.combo_thresh.SetItems(thresh_modes_names) | 607 | self.combo_thresh.SetItems(thresh_modes_names) |
613 | self.threshold_modes_names = thresh_modes_names | 608 | self.threshold_modes_names = thresh_modes_names |
614 | proj = Project() | 609 | proj = Project() |
@@ -635,17 +630,17 @@ class MaskProperties(wx.Panel): | @@ -635,17 +630,17 @@ class MaskProperties(wx.Panel): | ||
635 | self.gradient.SetMinValue(thresh_min) | 630 | self.gradient.SetMinValue(thresh_min) |
636 | self.gradient.SetMaxValue(thresh_max) | 631 | self.gradient.SetMaxValue(thresh_max) |
637 | 632 | ||
638 | - def SetThresholdBounds(self, pubsub_evt): | ||
639 | - thresh_min = pubsub_evt.data[0] | ||
640 | - thresh_max = pubsub_evt.data[1] | 633 | + def SetThresholdBounds(self, threshold_range): |
634 | + thresh_min = threshold_range[0] | ||
635 | + thresh_max = threshold_range[1] | ||
641 | self.gradient.SetMinRange(thresh_min) | 636 | self.gradient.SetMinRange(thresh_min) |
642 | self.gradient.SetMaxRange(thresh_max) | 637 | self.gradient.SetMaxRange(thresh_max) |
643 | 638 | ||
644 | def OnComboName(self, evt): | 639 | def OnComboName(self, evt): |
645 | mask_name = evt.GetString() | 640 | mask_name = evt.GetString() |
646 | mask_index = evt.GetSelection() | 641 | mask_index = evt.GetSelection() |
647 | - Publisher.sendMessage('Change mask selected', mask_index) | ||
648 | - Publisher.sendMessage('Show mask', (mask_index, True)) | 642 | + Publisher.sendMessage('Change mask selected', index=mask_index) |
643 | + Publisher.sendMessage('Show mask', index=mask_index, value=True) | ||
649 | 644 | ||
650 | def OnComboThresh(self, evt): | 645 | def OnComboThresh(self, evt): |
651 | (thresh_min, thresh_max) = Project().threshold_modes[evt.GetString()] | 646 | (thresh_min, thresh_max) = Project().threshold_modes[evt.GetString()] |
@@ -658,7 +653,7 @@ class MaskProperties(wx.Panel): | @@ -658,7 +653,7 @@ class MaskProperties(wx.Panel): | ||
658 | thresh_min = self.gradient.GetMinValue() | 653 | thresh_min = self.gradient.GetMinValue() |
659 | thresh_max = self.gradient.GetMaxValue() | 654 | thresh_max = self.gradient.GetMaxValue() |
660 | Publisher.sendMessage('Set threshold values', | 655 | Publisher.sendMessage('Set threshold values', |
661 | - (thresh_min, thresh_max)) | 656 | + threshold_range=(thresh_min, thresh_max)) |
662 | session = ses.Session() | 657 | session = ses.Session() |
663 | session.ChangeProject() | 658 | session.ChangeProject() |
664 | 659 | ||
@@ -666,14 +661,14 @@ class MaskProperties(wx.Panel): | @@ -666,14 +661,14 @@ class MaskProperties(wx.Panel): | ||
666 | thresh_min = self.gradient.GetMinValue() | 661 | thresh_min = self.gradient.GetMinValue() |
667 | thresh_max = self.gradient.GetMaxValue() | 662 | thresh_max = self.gradient.GetMaxValue() |
668 | Publisher.sendMessage('Changing threshold values', | 663 | Publisher.sendMessage('Changing threshold values', |
669 | - (thresh_min, thresh_max)) | 664 | + threshold_range=(thresh_min, thresh_max)) |
670 | session = ses.Session() | 665 | session = ses.Session() |
671 | session.ChangeProject() | 666 | session.ChangeProject() |
672 | 667 | ||
673 | def OnSelectColour(self, evt): | 668 | def OnSelectColour(self, evt): |
674 | colour = evt.GetValue()[:3] | 669 | colour = evt.GetValue()[:3] |
675 | self.gradient.SetColour(colour) | 670 | self.gradient.SetColour(colour) |
676 | - Publisher.sendMessage('Change mask colour', colour) | 671 | + Publisher.sendMessage('Change mask colour', colour=colour) |
677 | 672 | ||
678 | class EditionTools(wx.Panel): | 673 | class EditionTools(wx.Panel): |
679 | def __init__(self, parent): | 674 | def __init__(self, parent): |
@@ -778,25 +773,23 @@ class EditionTools(wx.Panel): | @@ -778,25 +773,23 @@ class EditionTools(wx.Panel): | ||
778 | Publisher.subscribe(self.SetGradientColour, 'Add mask') | 773 | Publisher.subscribe(self.SetGradientColour, 'Add mask') |
779 | Publisher.subscribe(self._set_brush_size, 'Set edition brush size') | 774 | Publisher.subscribe(self._set_brush_size, 'Set edition brush size') |
780 | 775 | ||
781 | - def ChangeMaskColour(self, pubsub_evt): | ||
782 | - colour = pubsub_evt.data | 776 | + def ChangeMaskColour(self, colour): |
783 | self.gradient_thresh.SetColour(colour) | 777 | self.gradient_thresh.SetColour(colour) |
784 | 778 | ||
785 | - def SetGradientColour(self, pubsub_evt): | ||
786 | - vtk_colour = pubsub_evt.data[3] | ||
787 | - wx_colour = [c*255 for c in vtk_colour] | 779 | + def SetGradientColour(self, mask): |
780 | + wx_colour = [c*255 for c in mask.colour] | ||
788 | self.gradient_thresh.SetColour(wx_colour) | 781 | self.gradient_thresh.SetColour(wx_colour) |
789 | 782 | ||
790 | - def SetThresholdValues(self, pubsub_evt): | ||
791 | - thresh_min, thresh_max = pubsub_evt.data | 783 | + def SetThresholdValues(self, threshold_range): |
784 | + thresh_min, thresh_max = threshold_range | ||
792 | self.bind_evt_gradient = False | 785 | self.bind_evt_gradient = False |
793 | self.gradient_thresh.SetMinValue(thresh_min) | 786 | self.gradient_thresh.SetMinValue(thresh_min) |
794 | self.gradient_thresh.SetMaxValue(thresh_max) | 787 | self.gradient_thresh.SetMaxValue(thresh_max) |
795 | self.bind_evt_gradient = True | 788 | self.bind_evt_gradient = True |
796 | 789 | ||
797 | - def SetThresholdBounds(self, pubsub_evt): | ||
798 | - thresh_min = pubsub_evt.data[0] | ||
799 | - thresh_max = pubsub_evt.data[1] | 790 | + def SetThresholdBounds(self, threshold_range): |
791 | + thresh_min = threshold_range[0] | ||
792 | + thresh_max = threshold_range[1] | ||
800 | self.gradient_thresh.SetMinRange(thresh_min) | 793 | self.gradient_thresh.SetMinRange(thresh_min) |
801 | self.gradient_thresh.SetMaxRange(thresh_max) | 794 | self.gradient_thresh.SetMaxRange(thresh_max) |
802 | self.gradient_thresh.SetMinValue(thresh_min) | 795 | self.gradient_thresh.SetMinValue(thresh_min) |
@@ -807,7 +800,7 @@ class EditionTools(wx.Panel): | @@ -807,7 +800,7 @@ class EditionTools(wx.Panel): | ||
807 | thresh_max = self.gradient_thresh.GetMaxValue() | 800 | thresh_max = self.gradient_thresh.GetMaxValue() |
808 | if self.bind_evt_gradient: | 801 | if self.bind_evt_gradient: |
809 | Publisher.sendMessage('Set edition threshold values', | 802 | Publisher.sendMessage('Set edition threshold values', |
810 | - (thresh_min, thresh_max)) | 803 | + threshold_range=(thresh_min, thresh_max)) |
811 | 804 | ||
812 | def OnMenu(self, evt): | 805 | def OnMenu(self, evt): |
813 | SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | 806 | SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) |
@@ -820,22 +813,21 @@ class EditionTools(wx.Panel): | @@ -820,22 +813,21 @@ class EditionTools(wx.Panel): | ||
820 | 813 | ||
821 | self.btn_brush_format.SetBitmap(bitmap[evt.GetId()]) | 814 | self.btn_brush_format.SetBitmap(bitmap[evt.GetId()]) |
822 | 815 | ||
823 | - Publisher.sendMessage('Set brush format', brush[evt.GetId()]) | 816 | + Publisher.sendMessage('Set brush format', cursor_format=brush[evt.GetId()]) |
824 | 817 | ||
825 | def OnBrushSize(self, evt): | 818 | def OnBrushSize(self, evt): |
826 | """ """ | 819 | """ """ |
827 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only | 820 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
828 | # in the text ctrl - so we are capturing only changes on text | 821 | # in the text ctrl - so we are capturing only changes on text |
829 | # Strangelly this is being called twice | 822 | # Strangelly this is being called twice |
830 | - Publisher.sendMessage('Set edition brush size',self.spin.GetValue()) | 823 | + Publisher.sendMessage('Set edition brush size', size=self.spin.GetValue()) |
831 | 824 | ||
832 | - def _set_brush_size(self, pubsub_evt): | ||
833 | - size = pubsub_evt.data | 825 | + def _set_brush_size(self, size): |
834 | self.spin.SetValue(size) | 826 | self.spin.SetValue(size) |
835 | 827 | ||
836 | def OnComboBrushOp(self, evt): | 828 | def OnComboBrushOp(self, evt): |
837 | brush_op_id = evt.GetSelection() | 829 | brush_op_id = evt.GetSelection() |
838 | - Publisher.sendMessage('Set edition operation', brush_op_id) | 830 | + Publisher.sendMessage('Set edition operation', operation=brush_op_id) |
839 | if brush_op_id == const.BRUSH_THRESH: | 831 | if brush_op_id == const.BRUSH_THRESH: |
840 | self.gradient_thresh.Enable() | 832 | self.gradient_thresh.Enable() |
841 | else: | 833 | else: |
@@ -959,25 +951,24 @@ class WatershedTool(EditionTools): | @@ -959,25 +951,24 @@ class WatershedTool(EditionTools): | ||
959 | def __bind_pubsub_evt(self): | 951 | def __bind_pubsub_evt(self): |
960 | Publisher.subscribe(self._set_brush_size, 'Set watershed brush size') | 952 | Publisher.subscribe(self._set_brush_size, 'Set watershed brush size') |
961 | 953 | ||
962 | - def ChangeMaskColour(self, pubsub_evt): | ||
963 | - colour = pubsub_evt.data | 954 | + def ChangeMaskColour(self, colour): |
964 | self.gradient_thresh.SetColour(colour) | 955 | self.gradient_thresh.SetColour(colour) |
965 | 956 | ||
966 | - def SetGradientColour(self, pubsub_evt): | ||
967 | - vtk_colour = pubsub_evt.data[3] | 957 | + def SetGradientColour(self, mask): |
958 | + vtk_colour = mask.colour | ||
968 | wx_colour = [c*255 for c in vtk_colour] | 959 | wx_colour = [c*255 for c in vtk_colour] |
969 | self.gradient_thresh.SetColour(wx_colour) | 960 | self.gradient_thresh.SetColour(wx_colour) |
970 | 961 | ||
971 | - def SetThresholdValues(self, pubsub_evt): | ||
972 | - thresh_min, thresh_max = pubsub_evt.data | 962 | + def SetThresholdValues(self, threshold_range): |
963 | + thresh_min, thresh_max = threshold_range | ||
973 | self.bind_evt_gradient = False | 964 | self.bind_evt_gradient = False |
974 | self.gradient_thresh.SetMinValue(thresh_min) | 965 | self.gradient_thresh.SetMinValue(thresh_min) |
975 | self.gradient_thresh.SetMaxValue(thresh_max) | 966 | self.gradient_thresh.SetMaxValue(thresh_max) |
976 | self.bind_evt_gradient = True | 967 | self.bind_evt_gradient = True |
977 | 968 | ||
978 | - def SetThresholdBounds(self, pubsub_evt): | ||
979 | - thresh_min = pubsub_evt.data[0] | ||
980 | - thresh_max = pubsub_evt.data[1] | 969 | + def SetThresholdBounds(self, threshold_range): |
970 | + thresh_min = threshold_range[0] | ||
971 | + thresh_max = threshold_range[1] | ||
981 | self.gradient_thresh.SetMinRange(thresh_min) | 972 | self.gradient_thresh.SetMinRange(thresh_min) |
982 | self.gradient_thresh.SetMaxRange(thresh_max) | 973 | self.gradient_thresh.SetMaxRange(thresh_max) |
983 | self.gradient_thresh.SetMinValue(thresh_min) | 974 | self.gradient_thresh.SetMinValue(thresh_min) |
@@ -994,30 +985,29 @@ class WatershedTool(EditionTools): | @@ -994,30 +985,29 @@ class WatershedTool(EditionTools): | ||
994 | 985 | ||
995 | self.btn_brush_format.SetBitmap(bitmap[evt.GetId()]) | 986 | self.btn_brush_format.SetBitmap(bitmap[evt.GetId()]) |
996 | 987 | ||
997 | - Publisher.sendMessage('Set watershed brush format', brush[evt.GetId()]) | 988 | + Publisher.sendMessage('Set watershed brush format', brush_format=brush[evt.GetId()]) |
998 | 989 | ||
999 | def OnBrushSize(self, evt): | 990 | def OnBrushSize(self, evt): |
1000 | """ """ | 991 | """ """ |
1001 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only | 992 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
1002 | # in the text ctrl - so we are capturing only changes on text | 993 | # in the text ctrl - so we are capturing only changes on text |
1003 | # Strangelly this is being called twice | 994 | # Strangelly this is being called twice |
1004 | - Publisher.sendMessage('Set watershed brush size',self.spin.GetValue()) | 995 | + Publisher.sendMessage('Set watershed brush size', size=self.spin.GetValue()) |
1005 | 996 | ||
1006 | - def _set_brush_size(self, pubsub_evt): | ||
1007 | - size = pubsub_evt.data | 997 | + def _set_brush_size(self, size): |
1008 | self.spin.SetValue(size) | 998 | self.spin.SetValue(size) |
1009 | 999 | ||
1010 | def OnComboBrushOp(self, evt): | 1000 | def OnComboBrushOp(self, evt): |
1011 | brush_op = self.combo_brush_op.GetValue() | 1001 | brush_op = self.combo_brush_op.GetValue() |
1012 | - Publisher.sendMessage('Set watershed operation', brush_op) | 1002 | + Publisher.sendMessage('Set watershed operation', operation=brush_op) |
1013 | 1003 | ||
1014 | def OnCheckOverwriteMask(self, evt): | 1004 | def OnCheckOverwriteMask(self, evt): |
1015 | value = self.check_box.GetValue() | 1005 | value = self.check_box.GetValue() |
1016 | - Publisher.sendMessage('Set overwrite mask', value) | 1006 | + Publisher.sendMessage('Set overwrite mask', flag=value) |
1017 | 1007 | ||
1018 | def OnCheckWWWL(self, evt): | 1008 | def OnCheckWWWL(self, evt): |
1019 | value = self.ww_wl_cbox.GetValue() | 1009 | value = self.ww_wl_cbox.GetValue() |
1020 | - Publisher.sendMessage('Set use ww wl', value) | 1010 | + Publisher.sendMessage('Set use ww wl', use_ww_wl=value) |
1021 | 1011 | ||
1022 | def OnConfig(self, evt): | 1012 | def OnConfig(self, evt): |
1023 | from invesalius.data.styles import WatershedConfig | 1013 | from invesalius.data.styles import WatershedConfig |
invesalius/gui/task_surface.py
@@ -193,9 +193,9 @@ class InnerTaskPanel(wx.Panel): | @@ -193,9 +193,9 @@ class InnerTaskPanel(wx.Panel): | ||
193 | 193 | ||
194 | surface_options = dialog.GetValue() | 194 | surface_options = dialog.GetValue() |
195 | 195 | ||
196 | - Publisher.sendMessage('Create surface from index', surface_options) | 196 | + Publisher.sendMessage('Create surface from index', |
197 | + surface_parameters=surface_options) | ||
197 | dialog.Destroy() | 198 | dialog.Destroy() |
198 | - | ||
199 | if evt: | 199 | if evt: |
200 | evt.Skip() | 200 | evt.Skip() |
201 | 201 | ||
@@ -424,12 +424,12 @@ class SurfaceTools(wx.Panel): | @@ -424,12 +424,12 @@ class SurfaceTools(wx.Panel): | ||
424 | 424 | ||
425 | def StartSeeding(self): | 425 | def StartSeeding(self): |
426 | print("Start Seeding") | 426 | print("Start Seeding") |
427 | - Publisher.sendMessage('Enable style', const.VOLUME_STATE_SEED) | 427 | + Publisher.sendMessage('Enable style', style=const.VOLUME_STATE_SEED) |
428 | Publisher.sendMessage('Create surface by seeding - start') | 428 | Publisher.sendMessage('Create surface by seeding - start') |
429 | 429 | ||
430 | def EndSeeding(self): | 430 | def EndSeeding(self): |
431 | print("End Seeding") | 431 | print("End Seeding") |
432 | - Publisher.sendMessage('Disable style', const.VOLUME_STATE_SEED) | 432 | + Publisher.sendMessage('Disable style', style=const.VOLUME_STATE_SEED) |
433 | Publisher.sendMessage('Create surface by seeding - end') | 433 | Publisher.sendMessage('Create surface by seeding - end') |
434 | 434 | ||
435 | 435 | ||
@@ -515,8 +515,7 @@ class SurfaceProperties(wx.Panel): | @@ -515,8 +515,7 @@ class SurfaceProperties(wx.Panel): | ||
515 | Publisher.subscribe(self.OnRemoveSurfaces, 'Remove surfaces') | 515 | Publisher.subscribe(self.OnRemoveSurfaces, 'Remove surfaces') |
516 | 516 | ||
517 | 517 | ||
518 | - def OnRemoveSurfaces(self, pubsub_evt): | ||
519 | - list_index = pubsub_evt.data | 518 | + def OnRemoveSurfaces(self, surface_indexes): |
520 | s = self.combo_surface_name.GetSelection() | 519 | s = self.combo_surface_name.GetSelection() |
521 | ns = 0 | 520 | ns = 0 |
522 | 521 | ||
@@ -524,7 +523,7 @@ class SurfaceProperties(wx.Panel): | @@ -524,7 +523,7 @@ class SurfaceProperties(wx.Panel): | ||
524 | new_dict = [] | 523 | new_dict = [] |
525 | i = 0 | 524 | i = 0 |
526 | for n, (name, index) in enumerate(old_dict): | 525 | for n, (name, index) in enumerate(old_dict): |
527 | - if n not in list_index: | 526 | + if n not in surface_indexes: |
528 | new_dict.append([name, i]) | 527 | new_dict.append([name, i]) |
529 | if s == n: | 528 | if s == n: |
530 | ns = i | 529 | ns = i |
@@ -536,7 +535,7 @@ class SurfaceProperties(wx.Panel): | @@ -536,7 +535,7 @@ class SurfaceProperties(wx.Panel): | ||
536 | if self.surface_list: | 535 | if self.surface_list: |
537 | self.combo_surface_name.SetSelection(ns) | 536 | self.combo_surface_name.SetSelection(ns) |
538 | 537 | ||
539 | - def OnCloseProject(self, pubsub_evt): | 538 | + def OnCloseProject(self): |
540 | self.CloseProject() | 539 | self.CloseProject() |
541 | 540 | ||
542 | def CloseProject(self): | 541 | def CloseProject(self): |
@@ -545,16 +544,14 @@ class SurfaceProperties(wx.Panel): | @@ -545,16 +544,14 @@ class SurfaceProperties(wx.Panel): | ||
545 | self.combo_surface_name.Delete(i) | 544 | self.combo_surface_name.Delete(i) |
546 | self.surface_list = [] | 545 | self.surface_list = [] |
547 | 546 | ||
548 | - def ChangeSurfaceName(self, pubsub_evt): | ||
549 | - index, name = pubsub_evt.data | 547 | + def ChangeSurfaceName(self, index, name): |
550 | self.surface_list[index][0] = name | 548 | self.surface_list[index][0] = name |
551 | self.combo_surface_name.SetString(index, name) | 549 | self.combo_surface_name.SetString(index, name) |
552 | 550 | ||
553 | - def InsertNewSurface(self, pubsub_evt): | ||
554 | - #not_update = len(pubsub_evt.data) == 5 | ||
555 | - index = pubsub_evt.data[0] | ||
556 | - name = pubsub_evt.data[1] | ||
557 | - colour = [value*255 for value in pubsub_evt.data[2]] | 551 | + def InsertNewSurface(self, surface): |
552 | + index = surface.index | ||
553 | + name = surface.name | ||
554 | + colour = [value*255 for value in surface.colour] | ||
558 | i = 0 | 555 | i = 0 |
559 | try: | 556 | try: |
560 | i = self.surface_list.index([name, index]) | 557 | i = self.surface_list.index([name, index]) |
@@ -570,21 +567,21 @@ class SurfaceProperties(wx.Panel): | @@ -570,21 +567,21 @@ class SurfaceProperties(wx.Panel): | ||
570 | 567 | ||
571 | self.combo_surface_name.SetItems([n[0] for n in self.surface_list]) | 568 | self.combo_surface_name.SetItems([n[0] for n in self.surface_list]) |
572 | self.combo_surface_name.SetSelection(i) | 569 | self.combo_surface_name.SetSelection(i) |
573 | - transparency = 100*pubsub_evt.data[5] | 570 | + transparency = 100*surface.transparency |
574 | self.button_colour.SetColour(colour) | 571 | self.button_colour.SetColour(colour) |
575 | self.slider_transparency.SetValue(transparency) | 572 | self.slider_transparency.SetValue(transparency) |
576 | - Publisher.sendMessage('Update surface data', (index)) | 573 | + # Publisher.sendMessage('Update surface data', (index)) |
577 | 574 | ||
578 | def OnComboName(self, evt): | 575 | def OnComboName(self, evt): |
579 | surface_name = evt.GetString() | 576 | surface_name = evt.GetString() |
580 | surface_index = evt.GetSelection() | 577 | surface_index = evt.GetSelection() |
581 | - Publisher.sendMessage('Change surface selected', self.surface_list[surface_index][1]) | 578 | + Publisher.sendMessage('Change surface selected', surface_index=self.surface_list[surface_index][1]) |
582 | 579 | ||
583 | def OnSelectColour(self, evt): | 580 | def OnSelectColour(self, evt): |
584 | colour = [value/255.0 for value in evt.GetValue()] | 581 | colour = [value/255.0 for value in evt.GetValue()] |
585 | Publisher.sendMessage('Set surface colour', | 582 | Publisher.sendMessage('Set surface colour', |
586 | - (self.combo_surface_name.GetSelection(), | ||
587 | - colour)) | 583 | + surface_index=self.combo_surface_name.GetSelection(), |
584 | + colour=colour) | ||
588 | 585 | ||
589 | def OnTransparency(self, evt): | 586 | def OnTransparency(self, evt): |
590 | transparency = evt.GetInt()/float(MAX_TRANSPARENCY) | 587 | transparency = evt.GetInt()/float(MAX_TRANSPARENCY) |
@@ -594,8 +591,8 @@ class SurfaceProperties(wx.Panel): | @@ -594,8 +591,8 @@ class SurfaceProperties(wx.Panel): | ||
594 | if (wx.Platform == "__WXMAC__"): | 591 | if (wx.Platform == "__WXMAC__"): |
595 | transparency = evt.GetInt()/(0.96*float(MAX_TRANSPARENCY)) | 592 | transparency = evt.GetInt()/(0.96*float(MAX_TRANSPARENCY)) |
596 | Publisher.sendMessage('Set surface transparency', | 593 | Publisher.sendMessage('Set surface transparency', |
597 | - (self.combo_surface_name.GetSelection(), | ||
598 | - transparency)) | 594 | + surface_index=self.combo_surface_name.GetSelection(), |
595 | + transparency=transparency) | ||
599 | 596 | ||
600 | 597 | ||
601 | class QualityAdjustment(wx.Panel): | 598 | class QualityAdjustment(wx.Panel): |
invesalius/gui/task_tools.py
@@ -128,12 +128,10 @@ class InnerTaskPanel(wx.Panel): | @@ -128,12 +128,10 @@ class InnerTaskPanel(wx.Panel): | ||
128 | print("TODO: Send Signal - Add text annotation (both 2d and 3d)") | 128 | print("TODO: Send Signal - Add text annotation (both 2d and 3d)") |
129 | 129 | ||
130 | def OnLinkLinearMeasure(self): | 130 | def OnLinkLinearMeasure(self): |
131 | - Publisher.sendMessage('Enable style', | ||
132 | - constants.STATE_MEASURE_DISTANCE) | 131 | + Publisher.sendMessage('Enable style', style=constants.STATE_MEASURE_DISTANCE) |
133 | 132 | ||
134 | def OnLinkAngularMeasure(self): | 133 | def OnLinkAngularMeasure(self): |
135 | - Publisher.sendMessage('Enable style', | ||
136 | - constants.STATE_MEASURE_ANGLE) | 134 | + Publisher.sendMessage('Enable style', style=constants.STATE_MEASURE_ANGLE) |
137 | 135 | ||
138 | def OnButton(self, evt): | 136 | def OnButton(self, evt): |
139 | id = evt.GetId() | 137 | id = evt.GetId() |
invesalius/gui/widgets/clut_raycasting.py
@@ -174,7 +174,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -174,7 +174,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
174 | print("Salvando") | 174 | print("Salvando") |
175 | filename = dialog.ShowSavePresetDialog() | 175 | filename = dialog.ShowSavePresetDialog() |
176 | if filename: | 176 | if filename: |
177 | - Publisher.sendMessage('Save raycasting preset', filename) | 177 | + Publisher.sendMessage('Save raycasting preset', preset_name=filename) |
178 | point = self._has_clicked_in_a_point((x, y)) | 178 | point = self._has_clicked_in_a_point((x, y)) |
179 | # A point has been selected. It can be dragged. | 179 | # A point has been selected. It can be dragged. |
180 | if point: | 180 | if point: |
invesalius/gui/widgets/slice_menu.py
@@ -181,7 +181,7 @@ class SliceMenu(wx.Menu): | @@ -181,7 +181,7 @@ class SliceMenu(wx.Menu): | ||
181 | 181 | ||
182 | Publisher.subscribe(self._check_projection_menu, 'Check projection menu') | 182 | Publisher.subscribe(self._check_projection_menu, 'Check projection menu') |
183 | 183 | ||
184 | - def FirstItemSelect(self, pusub_evt): | 184 | + def FirstItemSelect(self): |
185 | item = self.ID_TO_TOOL_ITEM[self.id_wl_first] | 185 | item = self.ID_TO_TOOL_ITEM[self.id_wl_first] |
186 | item.Check(True) | 186 | item.Check(True) |
187 | 187 | ||
@@ -195,13 +195,12 @@ class SliceMenu(wx.Menu): | @@ -195,13 +195,12 @@ class SliceMenu(wx.Menu): | ||
195 | # item = self.ID_TO_TOOL_ITEM[self.id_tiling_first] | 195 | # item = self.ID_TO_TOOL_ITEM[self.id_tiling_first] |
196 | # item.Check(True) | 196 | # item.Check(True) |
197 | 197 | ||
198 | - def CheckWindowLevelOther(self, pubsub_evt): | 198 | + def CheckWindowLevelOther(self): |
199 | item = self.ID_TO_TOOL_ITEM[self.other_wl_id] | 199 | item = self.ID_TO_TOOL_ITEM[self.other_wl_id] |
200 | item.Check() | 200 | item.Check() |
201 | 201 | ||
202 | - def _check_projection_menu(self, pubsub_evt): | ||
203 | - p_id = pubsub_evt.data | ||
204 | - item = self.projection_items[p_id] | 202 | + def _check_projection_menu(self, projection_id): |
203 | + item = self.projection_items[projection_id] | ||
205 | item.Check() | 204 | item.Check() |
206 | 205 | ||
207 | def OnPopup(self, evt): | 206 | def OnPopup(self, evt): |
@@ -211,11 +210,12 @@ class SliceMenu(wx.Menu): | @@ -211,11 +210,12 @@ class SliceMenu(wx.Menu): | ||
211 | if(key in const.WINDOW_LEVEL.keys()): | 210 | if(key in const.WINDOW_LEVEL.keys()): |
212 | window, level = const.WINDOW_LEVEL[key] | 211 | window, level = const.WINDOW_LEVEL[key] |
213 | Publisher.sendMessage('Bright and contrast adjustment image', | 212 | Publisher.sendMessage('Bright and contrast adjustment image', |
214 | - (window, level)) | ||
215 | - Publisher.sendMessage('Update window level value',\ | ||
216 | - (window, level)) | ||
217 | - Publisher.sendMessage('Update window and level text',\ | ||
218 | - "WL: %d WW: %d"%(level, window)) | 213 | + window=window, level=level) |
214 | + Publisher.sendMessage('Update window level value', | ||
215 | + window=window, | ||
216 | + level=level) | ||
217 | + # Publisher.sendMessage('Update window and level text', | ||
218 | + # "WL: %d WW: %d"%(level, window)) | ||
219 | Publisher.sendMessage('Update slice viewer') | 219 | Publisher.sendMessage('Update slice viewer') |
220 | 220 | ||
221 | #Necessary update the slice plane in the volume case exists | 221 | #Necessary update the slice plane in the volume case exists |
@@ -223,7 +223,7 @@ class SliceMenu(wx.Menu): | @@ -223,7 +223,7 @@ class SliceMenu(wx.Menu): | ||
223 | 223 | ||
224 | elif(key in const.SLICE_COLOR_TABLE.keys()): | 224 | elif(key in const.SLICE_COLOR_TABLE.keys()): |
225 | values = const.SLICE_COLOR_TABLE[key] | 225 | values = const.SLICE_COLOR_TABLE[key] |
226 | - Publisher.sendMessage('Change colour table from background image', values) | 226 | + Publisher.sendMessage('Change colour table from background image', values=values) |
227 | Publisher.sendMessage('Update slice viewer') | 227 | Publisher.sendMessage('Update slice viewer') |
228 | 228 | ||
229 | if sys.platform.startswith('linux'): | 229 | if sys.platform.startswith('linux'): |
@@ -238,7 +238,7 @@ class SliceMenu(wx.Menu): | @@ -238,7 +238,7 @@ class SliceMenu(wx.Menu): | ||
238 | 238 | ||
239 | elif key in self.plist_presets: | 239 | elif key in self.plist_presets: |
240 | values = presets.get_wwwl_preset_colours(self.plist_presets[key]) | 240 | values = presets.get_wwwl_preset_colours(self.plist_presets[key]) |
241 | - Publisher.sendMessage('Change colour table from background image from plist', values) | 241 | + Publisher.sendMessage('Change colour table from background image from plist', values=values) |
242 | Publisher.sendMessage('Update slice viewer') | 242 | Publisher.sendMessage('Update slice viewer') |
243 | 243 | ||
244 | if sys.platform.startswith('linux'): | 244 | if sys.platform.startswith('linux'): |
@@ -253,12 +253,12 @@ class SliceMenu(wx.Menu): | @@ -253,12 +253,12 @@ class SliceMenu(wx.Menu): | ||
253 | 253 | ||
254 | elif(key in const.IMAGE_TILING.keys()): | 254 | elif(key in const.IMAGE_TILING.keys()): |
255 | values = const.IMAGE_TILING[key] | 255 | values = const.IMAGE_TILING[key] |
256 | - Publisher.sendMessage('Set slice viewer layout', values) | 256 | + Publisher.sendMessage('Set slice viewer layout', layout=values) |
257 | Publisher.sendMessage('Update slice viewer') | 257 | Publisher.sendMessage('Update slice viewer') |
258 | 258 | ||
259 | elif key in PROJECTIONS_ID: | 259 | elif key in PROJECTIONS_ID: |
260 | pid = PROJECTIONS_ID[key] | 260 | pid = PROJECTIONS_ID[key] |
261 | - Publisher.sendMessage('Set projection type', pid) | 261 | + Publisher.sendMessage('Set projection type', projection_id=pid) |
262 | Publisher.sendMessage('Reload actual slice') | 262 | Publisher.sendMessage('Reload actual slice') |
263 | 263 | ||
264 | elif key == _('Custom'): | 264 | elif key == _('Custom'): |
@@ -290,7 +290,7 @@ class SliceMenu(wx.Menu): | @@ -290,7 +290,7 @@ class SliceMenu(wx.Menu): | ||
290 | if self.cdialog: | 290 | if self.cdialog: |
291 | self.cdialog.Hide() | 291 | self.cdialog.Hide() |
292 | 292 | ||
293 | - def _close(self, pubsub_evt): | 293 | + def _close(self): |
294 | if self.cdialog: | 294 | if self.cdialog: |
295 | self.cdialog.Destroy() | 295 | self.cdialog.Destroy() |
296 | self.cdialog = None | 296 | self.cdialog = None |
invesalius/presets.py
@@ -64,14 +64,13 @@ class Presets(): | @@ -64,14 +64,13 @@ class Presets(): | ||
64 | _("Custom"):(0, 0) | 64 | _("Custom"):(0, 0) |
65 | }) | 65 | }) |
66 | self.__bind_events() | 66 | self.__bind_events() |
67 | - | 67 | + |
68 | def __bind_events(self): | 68 | def __bind_events(self): |
69 | Publisher.subscribe(self.UpdateThresholdModes, | 69 | Publisher.subscribe(self.UpdateThresholdModes, |
70 | - 'Update threshold limits list') | ||
71 | - | ||
72 | - def UpdateThresholdModes(self, evt): | ||
73 | - | ||
74 | - thresh_min, thresh_max = evt.data | 70 | + 'Update threshold limits list') |
71 | + | ||
72 | + def UpdateThresholdModes(self, threshold_range): | ||
73 | + thresh_min, thresh_max = threshold_range | ||
75 | presets_list = (self.thresh_ct, self.thresh_mri) | 74 | presets_list = (self.thresh_ct, self.thresh_mri) |
76 | 75 | ||
77 | for presets in presets_list: | 76 | for presets in presets_list: |
@@ -87,7 +86,7 @@ class Presets(): | @@ -87,7 +86,7 @@ class Presets(): | ||
87 | t_min = thresh_min | 86 | t_min = thresh_min |
88 | if (t_max > thresh_max): | 87 | if (t_max > thresh_max): |
89 | t_max = thresh_max | 88 | t_max = thresh_max |
90 | - | 89 | + |
91 | # This has happened in Analyze files | 90 | # This has happened in Analyze files |
92 | # TODO: find a good solution for presets in Analyze files | 91 | # TODO: find a good solution for presets in Analyze files |
93 | if (t_min > thresh_max): | 92 | if (t_min > thresh_max): |
@@ -96,9 +95,9 @@ class Presets(): | @@ -96,9 +95,9 @@ class Presets(): | ||
96 | t_max = thresh_max | 95 | t_max = thresh_max |
97 | 96 | ||
98 | presets[key] = (t_min, t_max) | 97 | presets[key] = (t_min, t_max) |
99 | - | ||
100 | - Publisher.sendMessage('Update threshold limits', (thresh_min, | ||
101 | - thresh_max)) | 98 | + |
99 | + Publisher.sendMessage('Update threshold limits', | ||
100 | + threshold_range=(thresh_min, thresh_max)) | ||
102 | 101 | ||
103 | def SavePlist(self, filename): | 102 | def SavePlist(self, filename): |
104 | filename = "%s$%s" % (filename, 'presets.plist') | 103 | filename = "%s$%s" % (filename, 'presets.plist') |
invesalius/reader/bitmap_reader.py
@@ -242,12 +242,12 @@ class ProgressBitmapReader: | @@ -242,12 +242,12 @@ class ProgressBitmapReader: | ||
242 | def __init__(self): | 242 | def __init__(self): |
243 | Publisher.subscribe(self.CancelLoad, "Cancel bitmap load") | 243 | Publisher.subscribe(self.CancelLoad, "Cancel bitmap load") |
244 | 244 | ||
245 | - def CancelLoad(self, evt_pubsub): | 245 | + def CancelLoad(self): |
246 | self.running = False | 246 | self.running = False |
247 | self.stoped = True | 247 | self.stoped = True |
248 | 248 | ||
249 | def SetWindowEvent(self, frame): | 249 | def SetWindowEvent(self, frame): |
250 | - self.frame = frame | 250 | + self.frame = frame |
251 | 251 | ||
252 | def SetDirectoryPath(self, path,recursive=True): | 252 | def SetDirectoryPath(self, path,recursive=True): |
253 | self.running = True | 253 | self.running = True |
@@ -255,10 +255,10 @@ class ProgressBitmapReader: | @@ -255,10 +255,10 @@ class ProgressBitmapReader: | ||
255 | self.GetBitmaps(path,recursive) | 255 | self.GetBitmaps(path,recursive) |
256 | 256 | ||
257 | def UpdateLoadFileProgress(self,cont_progress): | 257 | def UpdateLoadFileProgress(self,cont_progress): |
258 | - Publisher.sendMessage("Update bitmap load", cont_progress) | 258 | + Publisher.sendMessage("Update bitmap load", data=cont_progress) |
259 | 259 | ||
260 | def EndLoadFile(self, bitmap_list): | 260 | def EndLoadFile(self, bitmap_list): |
261 | - Publisher.sendMessage("End bitmap load", bitmap_list) | 261 | + Publisher.sendMessage("End bitmap load", data=bitmap_list) |
262 | 262 | ||
263 | def GetBitmaps(self, path, recursive): | 263 | def GetBitmaps(self, path, recursive): |
264 | 264 | ||
@@ -359,7 +359,7 @@ def ReadBitmap(filepath): | @@ -359,7 +359,7 @@ def ReadBitmap(filepath): | ||
359 | except UnicodeDecodeError: | 359 | except UnicodeDecodeError: |
360 | measures_info = False | 360 | measures_info = False |
361 | if measures_info: | 361 | if measures_info: |
362 | - Publisher.sendMessage('Set bitmap spacing', measures_info) | 362 | + Publisher.sendMessage('Set bitmap spacing', spacing=measures_info) |
363 | 363 | ||
364 | return False | 364 | return False |
365 | 365 |
invesalius/reader/dicom_reader.py
@@ -313,7 +313,7 @@ class ProgressDicomReader: | @@ -313,7 +313,7 @@ class ProgressDicomReader: | ||
313 | def __init__(self): | 313 | def __init__(self): |
314 | Publisher.subscribe(self.CancelLoad, "Cancel DICOM load") | 314 | Publisher.subscribe(self.CancelLoad, "Cancel DICOM load") |
315 | 315 | ||
316 | - def CancelLoad(self, evt_pubsub): | 316 | + def CancelLoad(self): |
317 | self.running = False | 317 | self.running = False |
318 | self.stoped = True | 318 | self.stoped = True |
319 | 319 | ||
@@ -326,10 +326,10 @@ class ProgressDicomReader: | @@ -326,10 +326,10 @@ class ProgressDicomReader: | ||
326 | self.GetDicomGroups(path,recursive) | 326 | self.GetDicomGroups(path,recursive) |
327 | 327 | ||
328 | def UpdateLoadFileProgress(self,cont_progress): | 328 | def UpdateLoadFileProgress(self,cont_progress): |
329 | - Publisher.sendMessage("Update dicom load", cont_progress) | 329 | + Publisher.sendMessage("Update dicom load", data=cont_progress) |
330 | 330 | ||
331 | def EndLoadFile(self, patient_list): | 331 | def EndLoadFile(self, patient_list): |
332 | - Publisher.sendMessage("End dicom load", patient_list) | 332 | + Publisher.sendMessage("End dicom load", patient_series=patient_list) |
333 | 333 | ||
334 | def GetDicomGroups(self, path, recursive): | 334 | def GetDicomGroups(self, path, recursive): |
335 | 335 |