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 | 47 | except ImportError: |
48 | 48 | from wx import SplashScreen |
49 | 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 | 51 | #from wx.lib.pubsub import Publisher |
52 | 52 | #import wx.lib.pubsub as ps |
53 | 53 | from wx.lib.pubsub import pub as Publisher |
... | ... | @@ -117,7 +117,7 @@ class InVesalius(wx.App): |
117 | 117 | Open drag & drop files under darwin |
118 | 118 | """ |
119 | 119 | path = os.path.abspath(filename) |
120 | - Publisher.sendMessage('Open project', path) | |
120 | + Publisher.sendMessage('Open project', filepath=path) | |
121 | 121 | |
122 | 122 | def Startup2(self): |
123 | 123 | self.control = self.splash.control |
... | ... | @@ -347,10 +347,10 @@ def use_cmd_optargs(options, args): |
347 | 347 | # If import DICOM argument... |
348 | 348 | if options.dicom_dir: |
349 | 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 | 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 | 354 | exit(0) |
355 | 355 | |
356 | 356 | check_for_export(options) |
... | ... | @@ -360,9 +360,11 @@ def use_cmd_optargs(options, args): |
360 | 360 | import invesalius.reader.dicom_reader as dcm |
361 | 361 | for patient in dcm.GetDicomGroups(options.import_all): |
362 | 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 | 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 | 368 | return True |
367 | 369 | |
368 | 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 | 375 | file = utils.decode(arg, FS_ENCODE) |
374 | 376 | if os.path.isfile(file): |
375 | 377 | path = os.path.abspath(file) |
376 | - Publisher.sendMessage('Open project', path) | |
378 | + Publisher.sendMessage('Open project', filepath=path) | |
377 | 379 | check_for_export(options) |
378 | 380 | return True |
379 | - | |
381 | + | |
380 | 382 | file = utils.decode(arg, sys.stdin.encoding) |
381 | 383 | if os.path.isfile(file): |
382 | 384 | path = os.path.abspath(file) |
383 | - Publisher.sendMessage('Open project', path) | |
385 | + Publisher.sendMessage('Open project', filepath=path) | |
384 | 386 | check_for_export(options) |
385 | 387 | return True |
386 | 388 | |
... | ... | @@ -428,7 +430,8 @@ def check_for_export(options, suffix='', remove_surfaces=False): |
428 | 430 | def export(path_, threshold_range, remove_surface=False): |
429 | 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 | 436 | surface_options = { |
434 | 437 | 'method': { |
... | ... | @@ -443,17 +446,20 @@ def export(path_, threshold_range, remove_surface=False): |
443 | 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 | 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 | 460 | Print pubsub messages |
455 | 461 | """ |
456 | - utils.debug(data.topic) | |
462 | + utils.debug("%s\n\tParameters: %s" % (topic, msg_data)) | |
457 | 463 | |
458 | 464 | def main(): |
459 | 465 | """ | ... | ... |
invesalius/control.py
... | ... | @@ -108,40 +108,38 @@ class Controller(): |
108 | 108 | |
109 | 109 | Publisher.subscribe(self.OnSaveProject, 'Save project') |
110 | 110 | |
111 | - def SetBitmapSpacing(self, pubsub_evt): | |
111 | + def SetBitmapSpacing(self, spacing): | |
112 | 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 | 116 | #self.cancel_import = True |
117 | 117 | Publisher.sendMessage('Hide import panel') |
118 | 118 | |
119 | 119 | |
120 | - def OnCancelImportBitmap(self, pubsub_evt): | |
120 | + def OnCancelImportBitmap(self): | |
121 | 121 | #self.cancel_import = True |
122 | 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 | 128 | self.ShowDialogImportDirectory() |
129 | 129 | |
130 | - def OnShowDialogImportOtherFiles(self, pubsub_evt): | |
131 | - id_type = pubsub_evt.data | |
130 | + def OnShowDialogImportOtherFiles(self, id_type): | |
132 | 131 | self.ShowDialogImportOtherFiles(id_type) |
133 | 132 | |
134 | - def OnShowDialogOpenProject(self, pubsub_evt): | |
133 | + def OnShowDialogOpenProject(self): | |
135 | 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 | 140 | self.ShowDialogCloseProject() |
143 | 141 | |
144 | - def OnShowBitmapFile(self, pubsub_evt): | |
142 | + def OnShowBitmapFile(self): | |
145 | 143 | self.ShowDialogImportBitmapFile() |
146 | 144 | ########################### |
147 | 145 | |
... | ... | @@ -155,10 +153,10 @@ class Controller(): |
155 | 153 | if answer: |
156 | 154 | self.ShowDialogSaveProject() |
157 | 155 | self.CloseProject() |
158 | - #Publisher.sendMessage("Enable state project", False) | |
156 | + #Publisher.sendMessage("Enable state project", state=False) | |
159 | 157 | Publisher.sendMessage('Set project name') |
160 | 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 | 161 | # Import TIFF, BMP, JPEG or PNG |
164 | 162 | dirpath = dialog.ShowImportBitmapDirDialog(self.frame) |
... | ... | @@ -179,10 +177,10 @@ class Controller(): |
179 | 177 | if answer: |
180 | 178 | self.ShowDialogSaveProject() |
181 | 179 | self.CloseProject() |
182 | - #Publisher.sendMessage("Enable state project", False) | |
180 | + #Publisher.sendMessage("Enable state project", state=False) | |
183 | 181 | Publisher.sendMessage('Set project name') |
184 | 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 | 184 | # Import project |
187 | 185 | dirpath = dialog.ShowImportDirDialog(self.frame) |
188 | 186 | if dirpath and not os.listdir(dirpath): |
... | ... | @@ -200,17 +198,17 @@ class Controller(): |
200 | 198 | if answer: |
201 | 199 | self.ShowDialogSaveProject() |
202 | 200 | self.CloseProject() |
203 | - # Publisher.sendMessage("Enable state project", False) | |
201 | + # Publisher.sendMessage("Enable state project", state=False) | |
204 | 202 | Publisher.sendMessage('Set project name') |
205 | 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 | 206 | # Warning for limited support to Analyze format |
209 | 207 | if id_type == const.ID_ANALYZE_IMPORT: |
210 | 208 | dialog.ImportAnalyzeWarning() |
211 | 209 | |
212 | 210 | filepath = dialog.ShowImportOtherFilesDialog(id_type) |
213 | - Publisher.sendMessage("Open other files", filepath) | |
211 | + Publisher.sendMessage("Open other files", filepath=filepath) | |
214 | 212 | |
215 | 213 | def ShowDialogOpenProject(self): |
216 | 214 | # Offer to save current project if necessary |
... | ... | @@ -265,21 +263,21 @@ class Controller(): |
265 | 263 | if not answer: |
266 | 264 | utils.debug("Close without changes") |
267 | 265 | self.CloseProject() |
268 | - Publisher.sendMessage("Enable state project", False) | |
266 | + Publisher.sendMessage("Enable state project", state=False) | |
269 | 267 | Publisher.sendMessage('Set project name') |
270 | 268 | Publisher.sendMessage("Stop Config Recording") |
271 | 269 | elif answer == 1: |
272 | 270 | self.ShowDialogSaveProject() |
273 | 271 | utils.debug("Save changes and close") |
274 | 272 | self.CloseProject() |
275 | - Publisher.sendMessage("Enable state project", False) | |
273 | + Publisher.sendMessage("Enable state project", state=False) | |
276 | 274 | Publisher.sendMessage('Set project name') |
277 | 275 | Publisher.sendMessage("Stop Config Recording") |
278 | 276 | elif answer == -1: |
279 | 277 | utils.debug("Cancel") |
280 | 278 | else: |
281 | 279 | self.CloseProject() |
282 | - Publisher.sendMessage("Enable state project", False) | |
280 | + Publisher.sendMessage("Enable state project", state=False) | |
283 | 281 | Publisher.sendMessage('Set project name') |
284 | 282 | Publisher.sendMessage("Stop Config Recording") |
285 | 283 | |
... | ... | @@ -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 | 293 | if os.path.exists(filepath): |
299 | 294 | session = ses.Session() |
300 | 295 | st = session.project_status |
... | ... | @@ -325,17 +320,16 @@ class Controller(): |
325 | 320 | self.Slice.window_width = proj.window |
326 | 321 | |
327 | 322 | Publisher.sendMessage('Update threshold limits list', |
328 | - proj.threshold_range) | |
323 | + threshold_range=proj.threshold_range) | |
329 | 324 | |
330 | 325 | self.LoadProject() |
331 | 326 | |
332 | 327 | session = ses.Session() |
333 | 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 | 334 | def SaveProject(self, path=None, compress=False): |
341 | 335 | Publisher.sendMessage('Begin busy cursor') |
... | ... | @@ -356,7 +350,7 @@ class Controller(): |
356 | 350 | Publisher.sendMessage('End busy cursor') |
357 | 351 | |
358 | 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 | 354 | Publisher.sendMessage('Hide content panel') |
361 | 355 | Publisher.sendMessage('Close project data') |
362 | 356 | |
... | ... | @@ -390,8 +384,7 @@ class Controller(): |
390 | 384 | reader.SetDirectoryPath(path) |
391 | 385 | Publisher.sendMessage('End busy cursor') |
392 | 386 | |
393 | - def Progress(self, evt): | |
394 | - data = evt.data | |
387 | + def Progress(self, data): | |
395 | 388 | if (data): |
396 | 389 | message = _("Loading file %d of %d ...")%(data[0],data[1]) |
397 | 390 | if not(self.progress_dialog): |
... | ... | @@ -408,19 +401,17 @@ class Controller(): |
408 | 401 | self.progress_dialog.Close() |
409 | 402 | self.progress_dialog = None |
410 | 403 | |
411 | - def OnLoadImportPanel(self, evt): | |
412 | - patient_series = evt.data | |
404 | + def OnLoadImportPanel(self, patient_series): | |
413 | 405 | ok = self.LoadImportPanel(patient_series) |
414 | 406 | if ok: |
415 | 407 | Publisher.sendMessage('Show import panel') |
416 | 408 | Publisher.sendMessage("Show import panel in frame") |
417 | 409 | self.img_type = 1 |
418 | 410 | |
419 | - def OnLoadImportBitmapPanel(self, evt): | |
420 | - data = evt.data | |
411 | + def OnLoadImportBitmapPanel(self, data): | |
421 | 412 | ok = self.LoadImportBitmapPanel(data) |
422 | 413 | if ok: |
423 | - Publisher.sendMessage('Show import bitmap panel in frame') | |
414 | + Publisher.sendMessage('Show import bitmap panel in frame') | |
424 | 415 | self.img_type = 2 |
425 | 416 | #Publisher.sendMessage("Show import panel in invesalius.gui.frame") as frame |
426 | 417 | |
... | ... | @@ -430,7 +421,7 @@ class Controller(): |
430 | 421 | #first_patient = patient_series[0] |
431 | 422 | #Publisher.sendMessage("Load bitmap preview", first_patient) |
432 | 423 | if data: |
433 | - Publisher.sendMessage("Load import bitmap panel", data) | |
424 | + Publisher.sendMessage("Load import bitmap panel", data=data) | |
434 | 425 | return True |
435 | 426 | else: |
436 | 427 | dialog.ImportInvalidFiles("Bitmap") |
... | ... | @@ -439,9 +430,9 @@ class Controller(): |
439 | 430 | |
440 | 431 | def LoadImportPanel(self, patient_series): |
441 | 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 | 434 | first_patient = patient_series[0] |
444 | - Publisher.sendMessage("Load dicom preview", first_patient) | |
435 | + Publisher.sendMessage("Load dicom preview", patient=first_patient) | |
445 | 436 | return True |
446 | 437 | else: |
447 | 438 | dialog.ImportInvalidFiles("DICOM") |
... | ... | @@ -450,10 +441,8 @@ class Controller(): |
450 | 441 | |
451 | 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 | 447 | def ImportMedicalImages(self, directory, gui=True): |
459 | 448 | patients_groups = dcm.GetDicomGroups(directory) |
... | ... | @@ -484,19 +473,17 @@ class Controller(): |
484 | 473 | # OPTION 4: Nothing... |
485 | 474 | |
486 | 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 | 481 | def ImportGroup(self, group, gui=True): |
495 | 482 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, 0, [0, 0], gui=gui) |
496 | 483 | self.CreateDicomProject(dicom, matrix, matrix_filename) |
497 | 484 | |
498 | 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 | 501 | self.Slice.spacing = proj.spacing |
515 | 502 | |
516 | 503 | Publisher.sendMessage('Load slice to viewer', |
517 | - (proj.mask_dict)) | |
504 | + mask_dict=proj.mask_dict) | |
518 | 505 | |
519 | 506 | |
520 | 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 | 517 | Publisher.sendMessage('Load surface dict', |
529 | - proj.surface_dict) | |
518 | + surface_dict=proj.surface_dict) | |
530 | 519 | Publisher.sendMessage('Hide surface items', |
531 | - proj.surface_dict) | |
520 | + surface_dict=proj.surface_dict) | |
532 | 521 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? |
533 | 522 | |
534 | 523 | Publisher.sendMessage('Show content panel') |
... | ... | @@ -537,13 +526,11 @@ class Controller(): |
537 | 526 | if len(proj.mask_dict): |
538 | 527 | mask_index = len(proj.mask_dict) -1 |
539 | 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 | 530 | if m.is_shown: |
544 | 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 | 534 | else: |
548 | 535 | mask_name = const.MASK_NAME_PATTERN % (1,) |
549 | 536 | |
... | ... | @@ -554,14 +541,17 @@ class Controller(): |
554 | 541 | |
555 | 542 | colour = const.MASK_COLOUR[0] |
556 | 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 | 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 | 556 | Publisher.sendMessage('End busy cursor') |
567 | 557 | |
... | ... | @@ -675,8 +665,7 @@ class Controller(): |
675 | 665 | |
676 | 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 | 669 | bmp_data = bmp.BitmapData() |
681 | 670 | |
682 | 671 | if bmp_data.IsAllBitmapSameSize(): |
... | ... | @@ -686,12 +675,11 @@ class Controller(): |
686 | 675 | self.CreateBitmapProject(bmp_data, rec_data, matrix, matrix_filename) |
687 | 676 | |
688 | 677 | self.LoadProject() |
689 | - Publisher.sendMessage("Enable state project", True) | |
678 | + Publisher.sendMessage("Enable state project", state=True) | |
690 | 679 | else: |
691 | 680 | dialogs.BitmapNotSameSize() |
692 | 681 | |
693 | 682 | def OpenBitmapFiles(self, bmp_data, rec_data): |
694 | - | |
695 | 683 | name = rec_data[0] |
696 | 684 | orientation = rec_data[1] |
697 | 685 | sp_x = float(rec_data[2]) |
... | ... | @@ -747,20 +735,20 @@ class Controller(): |
747 | 735 | self.Slice.window_width = float(self.matrix.max()) |
748 | 736 | |
749 | 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 | 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 | 745 | matrix, matrix_filename, dicom = self.OpenDicomGroup(group, interval, file_range, gui=True) |
758 | 746 | self.CreateDicomProject(dicom, matrix, matrix_filename) |
759 | 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 | 752 | if not(filepath) == None: |
765 | 753 | name = filepath.rpartition('\\')[-1].split('.') |
766 | 754 | |
... | ... | @@ -770,7 +758,7 @@ class Controller(): |
770 | 758 | matrix, matrix_filename = self.OpenOtherFiles(group) |
771 | 759 | self.CreateOtherProject(str(name[0]), matrix, matrix_filename) |
772 | 760 | self.LoadProject() |
773 | - Publisher.sendMessage("Enable state project", True) | |
761 | + Publisher.sendMessage("Enable state project", state=True) | |
774 | 762 | else: |
775 | 763 | dialog.ImportInvalidFiles(ftype="Others") |
776 | 764 | |
... | ... | @@ -861,7 +849,8 @@ class Controller(): |
861 | 849 | |
862 | 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 | 855 | return self.matrix, self.filename, dicom |
867 | 856 | |
... | ... | @@ -886,7 +875,8 @@ class Controller(): |
886 | 875 | self.Slice.window_width = ww |
887 | 876 | |
888 | 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 | 880 | return self.matrix, self.filename |
891 | 881 | |
892 | 882 | def LoadImagedataInfo(self): |
... | ... | @@ -909,24 +899,20 @@ class Controller(): |
909 | 899 | [a,b] = default_threshold |
910 | 900 | default_threshold = (a,b) |
911 | 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 | 908 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, |
923 | - const.RAYCASTING_FILES[label]) | |
909 | + const.RAYCASTING_FILES[preset_name]) | |
924 | 910 | else: |
925 | 911 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, |
926 | - label+".plist") | |
912 | + preset_name+".plist") | |
927 | 913 | if not os.path.isfile(path): |
928 | 914 | path = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, |
929 | - label+".plist") | |
915 | + preset_name+".plist") | |
930 | 916 | preset = plistlib.readPlist(path) |
931 | 917 | prj.Project().raycasting_preset = preset |
932 | 918 | # Notify volume |
... | ... | @@ -936,17 +922,16 @@ class Controller(): |
936 | 922 | prj.Project().raycasting_preset = 0 |
937 | 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 | 926 | preset = prj.Project().raycasting_preset |
942 | 927 | preset['name'] = preset_name |
943 | 928 | preset_dir = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, |
944 | 929 | preset_name + '.plist') |
945 | 930 | plistlib.writePlist(preset, preset_dir) |
946 | 931 | |
947 | - def ShowBooleanOpDialog(self, pubsub_evt): | |
932 | + def ShowBooleanOpDialog(self): | |
948 | 933 | dlg = dialogs.MaskBooleanDialog(prj.Project().mask_dict) |
949 | 934 | dlg.Show() |
950 | 935 | |
951 | - def ApplyReorientation(self, pubsub_evt): | |
936 | + def ApplyReorientation(self): | |
952 | 937 | self.Slice.apply_reorientation() | ... | ... |
invesalius/data/coordinates.py
... | ... | @@ -86,7 +86,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode): |
86 | 86 | k += 1 |
87 | 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 | 91 | return coord |
92 | 92 | |
... | ... | @@ -225,7 +225,7 @@ def DebugCoord(trk_init, trck_id, ref_mode): |
225 | 225 | coord3 = np.array([uniform(1, 200), uniform(1, 200), uniform(1, 200), |
226 | 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 | 230 | return np.vstack([coord1, coord2, coord3]) |
231 | 231 | ... | ... |
invesalius/data/coregistration.py
... | ... | @@ -72,7 +72,7 @@ class CoregistrationStatic(threading.Thread): |
72 | 72 | |
73 | 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 | 77 | # TODO: Optimize the value of sleep for each tracking device. |
78 | 78 | sleep(0.175) |
... | ... | @@ -127,7 +127,7 @@ class CoregistrationDynamic(threading.Thread): |
127 | 127 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ |
128 | 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 | 132 | # TODO: Optimize the value of sleep for each tracking device. |
133 | 133 | sleep(0.175) |
... | ... | @@ -179,7 +179,7 @@ class CoregistrationDynamic_old(threading.Thread): |
179 | 179 | |
180 | 180 | # Tried several combinations and different locations to send the messages, |
181 | 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 | 183 | wx.CallAfter(Publisher.sendMessage, 'Set camera in volume', coord) |
184 | 184 | wx.CallAfter(Publisher.sendMessage, 'Update tracker angles', angles) |
185 | 185 | |
... | ... | @@ -253,8 +253,8 @@ class CoregistrationObjectStatic(threading.Thread): |
253 | 253 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1], \ |
254 | 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 | 259 | # TODO: Optimize the value of sleep for each tracking device. |
260 | 260 | sleep(0.175) |
... | ... | @@ -335,8 +335,8 @@ class CoregistrationObjectDynamic(threading.Thread): |
335 | 335 | coord = m_img[0, -1], m_img[1, -1], m_img[2, -1],\ |
336 | 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 | 341 | # TODO: Optimize the value of sleep for each tracking device. |
342 | 342 | sleep(0.175) |
... | ... | @@ -360,4 +360,4 @@ class CoregistrationObjectDynamic(threading.Thread): |
360 | 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 | 362 | if self._pause_: |
363 | - return | |
364 | 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 | 136 | self.axial[const.AXIAL_RIGHT] = [[self.xf + (self.xs/2), self.yi, self.zi],\ |
137 | 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 | 142 | def GetLimits(self): | ... | ... |
invesalius/data/mask.py
... | ... | @@ -78,8 +78,8 @@ class EditionHistory(object): |
78 | 78 | self.index = -1 |
79 | 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 | 84 | def new_node(self, index, orientation, array, p_array, clean): |
85 | 85 | # Saving the previous state, used to undo/redo correctly. |
... | ... | @@ -100,8 +100,8 @@ class EditionHistory(object): |
100 | 100 | self.index += 1 |
101 | 101 | |
102 | 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 | 106 | def undo(self, mvolume, actual_slices=None): |
107 | 107 | h = self.history |
... | ... | @@ -114,7 +114,7 @@ class EditionHistory(object): |
114 | 114 | self.index -= 1 |
115 | 115 | h[self.index].commit_history(mvolume) |
116 | 116 | self._reload_slice(self.index) |
117 | - Publisher.sendMessage("Enable redo", True) | |
117 | + Publisher.sendMessage("Enable redo", value=True) | |
118 | 118 | elif actual_slices and actual_slices[h[self.index - 1].orientation] != h[self.index - 1].index: |
119 | 119 | self._reload_slice(self.index - 1) |
120 | 120 | else: |
... | ... | @@ -124,10 +124,10 @@ class EditionHistory(object): |
124 | 124 | self.index -= 1 |
125 | 125 | h[self.index].commit_history(mvolume) |
126 | 126 | self._reload_slice(self.index) |
127 | - Publisher.sendMessage("Enable redo", True) | |
127 | + Publisher.sendMessage("Enable redo", value=True) | |
128 | 128 | |
129 | 129 | if self.index == 0: |
130 | - Publisher.sendMessage("Enable undo", False) | |
130 | + Publisher.sendMessage("Enable undo", value=False) | |
131 | 131 | print("AT", self.index, len(self.history), self.history[self.index].filename) |
132 | 132 | |
133 | 133 | def redo(self, mvolume, actual_slices=None): |
... | ... | @@ -142,7 +142,7 @@ class EditionHistory(object): |
142 | 142 | self.index += 1 |
143 | 143 | h[self.index].commit_history(mvolume) |
144 | 144 | self._reload_slice(self.index) |
145 | - Publisher.sendMessage("Enable undo", True) | |
145 | + Publisher.sendMessage("Enable undo", value=True) | |
146 | 146 | elif actual_slices and actual_slices[h[self.index + 1].orientation] != h[self.index + 1].index: |
147 | 147 | self._reload_slice(self.index + 1) |
148 | 148 | else: |
... | ... | @@ -152,15 +152,15 @@ class EditionHistory(object): |
152 | 152 | self.index += 1 |
153 | 153 | h[self.index].commit_history(mvolume) |
154 | 154 | self._reload_slice(self.index) |
155 | - Publisher.sendMessage("Enable undo", True) | |
155 | + Publisher.sendMessage("Enable undo", value=True) | |
156 | 156 | |
157 | 157 | if self.index == len(h) - 1: |
158 | - Publisher.sendMessage("Enable redo", False) | |
158 | + Publisher.sendMessage("Enable redo", value=False) | |
159 | 159 | print("AT", self.index, len(h), h[self.index].filename) |
160 | 160 | |
161 | 161 | def _reload_slice(self, index): |
162 | 162 | Publisher.sendMessage(('Set scroll position', self.history[index].orientation), |
163 | - self.history[index].index) | |
163 | + index=self.history[index].index) | |
164 | 164 | |
165 | 165 | def _config_undo_redo(self, visible): |
166 | 166 | v_undo = False |
... | ... | @@ -174,14 +174,14 @@ class EditionHistory(object): |
174 | 174 | elif self.index == len(self.history) - 1: |
175 | 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 | 180 | def clear_history(self): |
181 | 181 | self.history = [] |
182 | 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 | 187 | class Mask(): |
... | ... | @@ -273,8 +273,7 @@ class Mask(): |
273 | 273 | path = os.path.join(dirpath, mask_file) |
274 | 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 | 277 | submatrix = self.matrix[1:, 1:, 1:] |
279 | 278 | if axis == 0: |
280 | 279 | submatrix[:] = submatrix[::-1] |
... | ... | @@ -286,8 +285,8 @@ class Mask(): |
286 | 285 | submatrix[:] = submatrix[:, :, ::-1] |
287 | 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 | 290 | self.matrix = self.matrix.swapaxes(axis0, axis1) |
292 | 291 | |
293 | 292 | def _save_mask(self, filename): | ... | ... |
invesalius/data/measures.py
... | ... | @@ -120,14 +120,9 @@ class MeasurementManager(object): |
120 | 120 | Publisher.subscribe(self._change_measure_point_pos, 'Change measurement point position') |
121 | 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 | 127 | if m.location == const.AXIAL: |
133 | 128 | radius = min(spacing[1], spacing[2]) * const.PROP_MEASURE |
... | ... | @@ -154,7 +149,7 @@ class MeasurementManager(object): |
154 | 149 | |
155 | 150 | if m.location == const.SURFACE: |
156 | 151 | Publisher.sendMessage(("Add actors " + str(m.location)), |
157 | - (actors, m.slice_number)) | |
152 | + actors=actors) | |
158 | 153 | self.current = None |
159 | 154 | |
160 | 155 | if not m.visible: |
... | ... | @@ -164,28 +159,7 @@ class MeasurementManager(object): |
164 | 159 | else: |
165 | 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 | 163 | to_remove = False |
190 | 164 | if self.current is None: |
191 | 165 | to_create = True |
... | ... | @@ -233,8 +207,7 @@ class MeasurementManager(object): |
233 | 207 | m.points.append(position) |
234 | 208 | |
235 | 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 | 212 | if self.current not in self.measures: |
240 | 213 | self.measures.append(self.current) |
... | ... | @@ -254,14 +227,12 @@ class MeasurementManager(object): |
254 | 227 | |
255 | 228 | msg = 'Update measurement info in GUI', |
256 | 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 | 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 | 236 | m, mr = self.measures[index] |
266 | 237 | x, y, z = pos |
267 | 238 | if npoint == 0: |
... | ... | @@ -288,17 +259,14 @@ class MeasurementManager(object): |
288 | 259 | value = u"%.3f°"% m.value |
289 | 260 | |
290 | 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 | 270 | for index in indexes: |
303 | 271 | m, mr = self.measures.pop(index) |
304 | 272 | try: |
... | ... | @@ -308,16 +276,15 @@ class MeasurementManager(object): |
308 | 276 | pass |
309 | 277 | prj.Project().RemoveMeasurement(index) |
310 | 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 | 281 | Publisher.sendMessage('Redraw canvas') |
314 | 282 | Publisher.sendMessage('Render volume viewer') |
315 | 283 | |
316 | 284 | session = ses.Session() |
317 | 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 | 288 | m, mr = self.measures[index] |
322 | 289 | m.visible = visibility |
323 | 290 | mr.SetVisibility(visibility) |
... | ... | @@ -326,7 +293,7 @@ class MeasurementManager(object): |
326 | 293 | else: |
327 | 294 | Publisher.sendMessage('Redraw canvas') |
328 | 295 | |
329 | - def _rm_incomplete_measurements(self, pubsub_evt): | |
296 | + def _rm_incomplete_measurements(self): | |
330 | 297 | if self.current is None: |
331 | 298 | return |
332 | 299 | |
... | ... | @@ -334,12 +301,12 @@ class MeasurementManager(object): |
334 | 301 | if not mr.IsComplete(): |
335 | 302 | idx = self.measures._list_measures.index((m, mr)) |
336 | 303 | self.measures.remove((m, mr)) |
337 | - Publisher.sendMessage("Remove GUI measurement", idx) | |
304 | + Publisher.sendMessage("Remove GUI measurement", measure_index=idx) | |
338 | 305 | actors = mr.GetActors() |
339 | 306 | slice_number = self.current[0].slice_number |
340 | 307 | if m.location == const.SURFACE: |
341 | 308 | Publisher.sendMessage(('Remove actors ' + str(self.current[0].location)), |
342 | - (actors, slice_number)) | |
309 | + actors=actors) | |
343 | 310 | if self.current[0].location == const.SURFACE: |
344 | 311 | Publisher.sendMessage('Render volume viewer') |
345 | 312 | else: |
... | ... | @@ -349,7 +316,7 @@ class MeasurementManager(object): |
349 | 316 | # self.measures.pop() |
350 | 317 | self.current = None |
351 | 318 | |
352 | - def OnCloseProject(self, pubsub_evt): | |
319 | + def OnCloseProject(self): | |
353 | 320 | self.measures.clean() |
354 | 321 | |
355 | 322 | |
... | ... | @@ -650,7 +617,7 @@ class LinearMeasure(object): |
650 | 617 | |
651 | 618 | def Remove(self): |
652 | 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 | 622 | def __del__(self): |
656 | 623 | self.Remove() |
... | ... | @@ -901,7 +868,7 @@ class AngularMeasure(object): |
901 | 868 | |
902 | 869 | def Remove(self): |
903 | 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 | 873 | def SetRenderer(self, renderer): |
907 | 874 | if self.point_actor1: | ... | ... |
invesalius/data/record_coords.py
... | ... | @@ -44,8 +44,8 @@ class Record(threading.Thread): |
44 | 44 | def __bind_events(self): |
45 | 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 | 50 | def stop(self): |
51 | 51 | self._pause_ = True |
... | ... | @@ -64,4 +64,4 @@ class Record(threading.Thread): |
64 | 64 | else: |
65 | 65 | self.coord_list = vstack((self.coord_list, hstack((relative_time, self.coord)))) |
66 | 66 | if self._pause_: |
67 | - return | |
68 | 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 | 219 | buffer_.discard_vtk_mask() |
220 | 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 | 223 | proj = Project() |
225 | - for item in selected_items: | |
224 | + for item in mask_indexes: | |
226 | 225 | proj.RemoveMask(item) |
227 | 226 | |
228 | 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 | 233 | buffer_.discard_vtk_mask() |
235 | 234 | buffer_.discard_mask() |
236 | 235 | |
237 | - Publisher.sendMessage('Show mask', (item, 0)) | |
236 | + Publisher.sendMessage('Show mask', index=item, value=False) | |
238 | 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 | 240 | proj = Project() |
243 | 241 | mask_dict = proj.mask_dict |
244 | - for index in selected_items: | |
242 | + for index in mask_indexes: | |
245 | 243 | original_mask = mask_dict[index] |
246 | 244 | # compute copy name |
247 | 245 | name = original_mask.name |
... | ... | @@ -251,34 +249,32 @@ class Slice(with_metaclass(utils.Singleton, object)): |
251 | 249 | copy_mask = original_mask.copy(new_name) |
252 | 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 | 264 | Publisher.sendMessage('Set interactor default cursor') |
269 | 265 | self.state = new_state |
270 | 266 | |
271 | - def OnDisableActualStyle(self, pubsub_evt): | |
267 | + def OnDisableActualStyle(self): | |
272 | 268 | actual_state = self.interaction_style.GetActualState() |
273 | 269 | if actual_state != const.STATE_DEFAULT: |
274 | 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 | 273 | # if (actual_state == const.SLICE_STATE_EDITOR): |
278 | 274 | # Publisher.sendMessage('Set interactor default cursor') |
279 | 275 | self.state = new_state |
280 | 276 | |
281 | - def OnCloseProject(self, pubsub_evt): | |
277 | + def OnCloseProject(self): | |
282 | 278 | self.CloseProject() |
283 | 279 | |
284 | 280 | def CloseProject(self): |
... | ... | @@ -310,39 +306,32 @@ class Slice(with_metaclass(utils.Singleton, object)): |
310 | 306 | |
311 | 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 | 312 | if self.current_mask: |
317 | 313 | index = self.current_mask.index |
318 | 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 | 317 | self.create_new_mask(name=mask_name) |
323 | 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 | 321 | self.create_new_mask(name=mask_name, threshold_range=thresh, colour=colour) |
330 | 322 | self.SetMaskColour(self.current_mask.index, self.current_mask.colour) |
331 | 323 | self.SelectCurrentMask(self.current_mask.index) |
332 | 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 | 330 | if self.current_mask: |
340 | - threshold_range = evt_pubsub.data | |
341 | 331 | index = self.current_mask.index |
342 | 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 | 335 | index = self.current_mask.index |
347 | 336 | self.num_gradient += 1 |
348 | 337 | self.current_mask.matrix[:] = 0 |
... | ... | @@ -379,8 +368,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
379 | 368 | if to_reload: |
380 | 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 | 372 | index = self.current_mask.index |
385 | 373 | for orientation in self.buffer_slices: |
386 | 374 | self.buffer_slices[orientation].discard_vtk_mask() |
... | ... | @@ -391,44 +379,41 @@ class Slice(with_metaclass(utils.Singleton, object)): |
391 | 379 | |
392 | 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 | 383 | # "if" is necessary because wx events are calling this before any mask |
396 | 384 | # has been created |
397 | 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 | 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 | 390 | self.SetMaskName(index, name) |
405 | 391 | |
406 | - def __show_mask(self, pubsub_evt): | |
392 | + def __show_mask(self, index, value): | |
407 | 393 | # "if" is necessary because wx events are calling this before any mask |
408 | 394 | # has been created |
409 | 395 | if self.current_mask: |
410 | - index, value = pubsub_evt.data | |
411 | 396 | self.ShowMask(index, value) |
412 | 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 | 400 | if self._type_projection != const.PROJECTION_NORMAL: |
416 | 401 | self.SetTypeProjection(const.PROJECTION_NORMAL) |
417 | 402 | Publisher.sendMessage('Reload actual slice') |
418 | 403 | |
419 | - def __hide_current_mask(self, pubsub_evt): | |
404 | + def __hide_current_mask(self): | |
420 | 405 | if self.current_mask: |
421 | 406 | index = self.current_mask.index |
422 | 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 | 411 | if self.current_mask: |
427 | 412 | index = self.current_mask.index |
428 | 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 | 417 | if self.current_mask: |
433 | 418 | self.current_mask.clean() |
434 | 419 | for buffer_ in self.buffer_slices.values(): |
... | ... | @@ -844,8 +829,8 @@ class Slice(with_metaclass(utils.Singleton, object)): |
844 | 829 | (r,g,b) = colour[:3] |
845 | 830 | colour_wx = [r*255, g*255, b*255] |
846 | 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 | 834 | if update: |
850 | 835 | # Updating mask colour on vtkimagedata. |
851 | 836 | for buffer_ in self.buffer_slices.values(): |
... | ... | @@ -899,8 +884,8 @@ class Slice(with_metaclass(utils.Singleton, object)): |
899 | 884 | |
900 | 885 | # Update data notebook (GUI) |
901 | 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 | 889 | else: |
905 | 890 | proj = Project() |
906 | 891 | proj.mask_dict[index].threshold_range = threshold_range |
... | ... | @@ -936,32 +921,30 @@ class Slice(with_metaclass(utils.Singleton, object)): |
936 | 921 | "SAGITAL": SliceBuffer()} |
937 | 922 | |
938 | 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 | 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 | 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 | 933 | proj = Project() |
951 | 934 | mask = proj.mask_dict[surface_parameters['options']['index']] |
952 | 935 | |
953 | 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 | 941 | def GetOutput(self): |
957 | 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 | 948 | self.SetInterpolationMethod(interp_method) |
966 | 949 | |
967 | 950 | def SetTypeProjection(self, tprojection): |
... | ... | @@ -970,15 +953,15 @@ class Slice(with_metaclass(utils.Singleton, object)): |
970 | 953 | Publisher.sendMessage('Hide current mask') |
971 | 954 | |
972 | 955 | if tprojection == const.PROJECTION_NORMAL: |
973 | - Publisher.sendMessage('Show MIP interface', False) | |
956 | + Publisher.sendMessage('Show MIP interface', flag=False) | |
974 | 957 | else: |
975 | - Publisher.sendMessage('Show MIP interface', True) | |
958 | + Publisher.sendMessage('Show MIP interface', flag=True) | |
976 | 959 | |
977 | 960 | self._type_projection = tprojection |
978 | 961 | for buffer_ in self.buffer_slices.values(): |
979 | 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 | 966 | def SetInterpolationMethod(self, interp_method): |
984 | 967 | if self.interp_method != interp_method: |
... | ... | @@ -987,8 +970,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
987 | 970 | buffer_.discard_buffer() |
988 | 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 | 974 | self.window_width = window |
993 | 975 | self.window_level = level |
994 | 976 | |
... | ... | @@ -1004,8 +986,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1004 | 986 | |
1005 | 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 | 990 | self.from_= OTHER |
1010 | 991 | self.number_of_colours= values[0] |
1011 | 992 | self.saturation_range = values[1] |
... | ... | @@ -1015,16 +996,16 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1015 | 996 | buffer_.discard_vtk_image() |
1016 | 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 | 1001 | self.from_= PLIST |
1021 | 1002 | for buffer_ in self.buffer_slices.values(): |
1022 | 1003 | buffer_.discard_vtk_image() |
1023 | 1004 | |
1024 | 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 | 1009 | self.from_= WIDGET |
1029 | 1010 | for buffer_ in self.buffer_slices.values(): |
1030 | 1011 | if self._type_projection in (const.PROJECTION_NORMAL, |
... | ... | @@ -1045,8 +1026,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1045 | 1026 | |
1046 | 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 | 1030 | img = self.buffer_slices[orientation].vtk_image |
1051 | 1031 | original_orientation = Project().original_orientation |
1052 | 1032 | cast = vtk.vtkImageCast() |
... | ... | @@ -1125,15 +1105,12 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1125 | 1105 | |
1126 | 1106 | ## update gui related to mask |
1127 | 1107 | Publisher.sendMessage('Add mask', |
1128 | - (mask.index, | |
1129 | - mask.name, | |
1130 | - mask.threshold_range, | |
1131 | - mask.colour)) | |
1108 | + mask=mask) | |
1132 | 1109 | |
1133 | 1110 | if show: |
1134 | 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 | 1114 | Publisher.sendMessage('Update slice viewer') |
1138 | 1115 | |
1139 | 1116 | def do_ww_wl(self, image): |
... | ... | @@ -1336,9 +1313,8 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1336 | 1313 | |
1337 | 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 | 1320 | def do_boolean_op(self, op, m1, m2): |
... | ... | @@ -1449,7 +1425,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1449 | 1425 | self.q_orientation = np.array((1, 0, 0, 0)) |
1450 | 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 | 1429 | if self.current_mask: |
1454 | 1430 | self.current_mask.matrix[:] = 0 |
1455 | 1431 | self.current_mask.was_edited = False |
... | ... | @@ -1459,7 +1435,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1459 | 1435 | |
1460 | 1436 | Publisher.sendMessage('Reload actual slice') |
1461 | 1437 | |
1462 | - def __undo_edition(self, pub_evt): | |
1438 | + def __undo_edition(self): | |
1463 | 1439 | buffer_slices = self.buffer_slices |
1464 | 1440 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, |
1465 | 1441 | "CORONAL": buffer_slices["CORONAL"].index, |
... | ... | @@ -1471,7 +1447,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1471 | 1447 | self.buffer_slices[o].discard_vtk_mask() |
1472 | 1448 | Publisher.sendMessage('Reload actual slice') |
1473 | 1449 | |
1474 | - def __redo_edition(self, pub_evt): | |
1450 | + def __redo_edition(self): | |
1475 | 1451 | buffer_slices = self.buffer_slices |
1476 | 1452 | actual_slices = {"AXIAL": buffer_slices["AXIAL"].index, |
1477 | 1453 | "CORONAL": buffer_slices["CORONAL"].index, |
... | ... | @@ -1487,8 +1463,7 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1487 | 1463 | self.matrix_filename = filename |
1488 | 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 | 1467 | if axis == 0: |
1493 | 1468 | self.matrix[:] = self.matrix[::-1] |
1494 | 1469 | elif axis == 1: |
... | ... | @@ -1499,8 +1474,8 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1499 | 1474 | for buffer_ in self.buffer_slices.values(): |
1500 | 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 | 1479 | self.matrix = self.matrix.swapaxes(axis0, axis1) |
1505 | 1480 | if (axis0, axis1) == (2, 1): |
1506 | 1481 | self.spacing = self.spacing[1], self.spacing[0], self.spacing[2] |
... | ... | @@ -1512,20 +1487,17 @@ class Slice(with_metaclass(utils.Singleton, object)): |
1512 | 1487 | for buffer_ in self.buffer_slices.values(): |
1513 | 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 | 1502 | if target == '2D': |
1531 | 1503 | index = self.buffer_slices[orientation].index | ... | ... |
invesalius/data/styles.py
... | ... | @@ -214,12 +214,12 @@ class CrossInteractorStyle(DefaultInteractorStyle): |
214 | 214 | def SetUp(self): |
215 | 215 | self.viewer._set_cross_visibility(1) |
216 | 216 | Publisher.sendMessage('Toggle toolbar item', |
217 | - (self.state_code, True)) | |
217 | + _id=self.state_code, value=True) | |
218 | 218 | |
219 | 219 | def CleanUp(self): |
220 | 220 | self.viewer._set_cross_visibility(0) |
221 | 221 | Publisher.sendMessage('Toggle toolbar item', |
222 | - (self.state_code, False)) | |
222 | + _id=self.state_code, value=False) | |
223 | 223 | |
224 | 224 | def OnCrossMouseClick(self, obj, evt): |
225 | 225 | iren = obj.GetInteractor() |
... | ... | @@ -237,29 +237,29 @@ class CrossInteractorStyle(DefaultInteractorStyle): |
237 | 237 | wx, wy, wz = self.viewer.get_coordinate_cursor(mouse_x, mouse_y, self.picker) |
238 | 238 | px, py = self.viewer.get_slice_pixel_coord_by_world_pos(wx, wy, wz) |
239 | 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 | 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 | 245 | iren.Render() |
246 | 246 | |
247 | 247 | def ScrollSlice(self, coord): |
248 | 248 | if self.orientation == "AXIAL": |
249 | 249 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
250 | - coord[0]) | |
250 | + index=coord[0]) | |
251 | 251 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
252 | - coord[1]) | |
252 | + index=coord[1]) | |
253 | 253 | elif self.orientation == "SAGITAL": |
254 | 254 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
255 | - coord[2]) | |
255 | + index=coord[2]) | |
256 | 256 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
257 | - coord[1]) | |
257 | + index=coord[1]) | |
258 | 258 | elif self.orientation == "CORONAL": |
259 | 259 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
260 | - coord[2]) | |
260 | + index=coord[2]) | |
261 | 261 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
262 | - coord[0]) | |
262 | + index=coord[0]) | |
263 | 263 | |
264 | 264 | |
265 | 265 | class WWWLInteractorStyle(DefaultInteractorStyle): |
... | ... | @@ -285,14 +285,14 @@ class WWWLInteractorStyle(DefaultInteractorStyle): |
285 | 285 | def SetUp(self): |
286 | 286 | self.viewer.on_wl = True |
287 | 287 | Publisher.sendMessage('Toggle toolbar item', |
288 | - (self.state_code, True)) | |
288 | + _id=self.state_code, value=True) | |
289 | 289 | self.viewer.canvas.draw_list.append(self.viewer.wl_text) |
290 | 290 | self.viewer.UpdateCanvas() |
291 | 291 | |
292 | 292 | def CleanUp(self): |
293 | 293 | self.viewer.on_wl = False |
294 | 294 | Publisher.sendMessage('Toggle toolbar item', |
295 | - (self.state_code, False)) | |
295 | + _id=self.state_code, value=False) | |
296 | 296 | if self.viewer.wl_text is not None: |
297 | 297 | self.viewer.canvas.draw_list.remove(self.viewer.wl_text) |
298 | 298 | self.viewer.UpdateCanvas() |
... | ... | @@ -306,7 +306,8 @@ class WWWLInteractorStyle(DefaultInteractorStyle): |
306 | 306 | self.last_x, self.last_y = mouse_x, mouse_y |
307 | 307 | |
308 | 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 | 312 | #self.SetWLText(self.acum_achange_level, |
312 | 313 | # self.acum_achange_window) |
... | ... | @@ -314,8 +315,9 @@ class WWWLInteractorStyle(DefaultInteractorStyle): |
314 | 315 | const.WINDOW_LEVEL['Manual'] = (self.acum_achange_window,\ |
315 | 316 | self.acum_achange_level) |
316 | 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 | 321 | #Necessary update the slice plane in the volume case exists |
320 | 322 | Publisher.sendMessage('Update slice viewer') |
321 | 323 | Publisher.sendMessage('Render volume viewer') |
... | ... | @@ -374,11 +376,11 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
374 | 376 | |
375 | 377 | def SetUp(self): |
376 | 378 | Publisher.sendMessage('Toggle toolbar item', |
377 | - (self.state_code, True)) | |
379 | + _id=self.state_code, value=True) | |
378 | 380 | |
379 | 381 | def CleanUp(self): |
380 | 382 | Publisher.sendMessage('Toggle toolbar item', |
381 | - (self.state_code, False)) | |
383 | + _id=self.state_code, value=False) | |
382 | 384 | self.picker.PickFromListOff() |
383 | 385 | Publisher.sendMessage("Remove incomplete measurements") |
384 | 386 | |
... | ... | @@ -399,9 +401,9 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
399 | 401 | self.viewer.scroll_enabled = True |
400 | 402 | else: |
401 | 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 | 407 | n = len(m.points)-1 |
406 | 408 | self.creating = n, m, mr |
407 | 409 | self.viewer.UpdateCanvas() |
... | ... | @@ -416,13 +418,15 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
416 | 418 | if self.picker.GetViewProp(): |
417 | 419 | renderer = self.viewer.slice_data.renderer |
418 | 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 | 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 | 431 | n, (m, mr) = 1, self.measures.measures[self._ori][slice_number][-1] |
428 | 432 | self.creating = n, m, mr |
... | ... | @@ -434,7 +438,7 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
434 | 438 | n, m, mr = self.selected |
435 | 439 | x, y, z = self._get_pos_clicked() |
436 | 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 | 442 | self.viewer.UpdateCanvas() |
439 | 443 | self.selected = None |
440 | 444 | self.viewer.scroll_enabled = True |
... | ... | @@ -444,13 +448,13 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): |
444 | 448 | if self.selected: |
445 | 449 | n, m, mr = self.selected |
446 | 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 | 452 | self.viewer.UpdateCanvas() |
449 | 453 | |
450 | 454 | elif self.creating: |
451 | 455 | n, m, mr = self.creating |
452 | 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 | 458 | self.viewer.UpdateCanvas() |
455 | 459 | |
456 | 460 | else: |
... | ... | @@ -539,12 +543,12 @@ class PanMoveInteractorStyle(DefaultInteractorStyle): |
539 | 543 | |
540 | 544 | def SetUp(self): |
541 | 545 | Publisher.sendMessage('Toggle toolbar item', |
542 | - (self.state_code, True)) | |
546 | + _id=self.state_code, value=True) | |
543 | 547 | |
544 | 548 | def CleanUp(self): |
545 | 549 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
546 | 550 | Publisher.sendMessage('Toggle toolbar item', |
547 | - (self.state_code, False)) | |
551 | + _id=self.state_code, value=False) | |
548 | 552 | |
549 | 553 | def OnPanMove(self, obj, evt): |
550 | 554 | if self.left_pressed: |
... | ... | @@ -575,12 +579,12 @@ class SpinInteractorStyle(DefaultInteractorStyle): |
575 | 579 | |
576 | 580 | def SetUp(self): |
577 | 581 | Publisher.sendMessage('Toggle toolbar item', |
578 | - (self.state_code, True)) | |
582 | + _id=self.state_code, value=True) | |
579 | 583 | |
580 | 584 | def CleanUp(self): |
581 | 585 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
582 | 586 | Publisher.sendMessage('Toggle toolbar item', |
583 | - (self.state_code, False)) | |
587 | + _id=self.state_code, value=False) | |
584 | 588 | |
585 | 589 | def OnSpinMove(self, obj, evt): |
586 | 590 | iren = obj.GetInteractor() |
... | ... | @@ -620,12 +624,12 @@ class ZoomInteractorStyle(DefaultInteractorStyle): |
620 | 624 | |
621 | 625 | def SetUp(self): |
622 | 626 | Publisher.sendMessage('Toggle toolbar item', |
623 | - (self.state_code, True)) | |
627 | + _id=self.state_code, value=True) | |
624 | 628 | |
625 | 629 | def CleanUp(self): |
626 | 630 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
627 | 631 | Publisher.sendMessage('Toggle toolbar item', |
628 | - (self.state_code, False)) | |
632 | + _id=self.state_code, value=False) | |
629 | 633 | |
630 | 634 | def OnZoomMoveLeft(self, obj, evt): |
631 | 635 | if self.left_pressed: |
... | ... | @@ -654,12 +658,12 @@ class ZoomSLInteractorStyle(vtk.vtkInteractorStyleRubberBandZoom): |
654 | 658 | |
655 | 659 | def SetUp(self): |
656 | 660 | Publisher.sendMessage('Toggle toolbar item', |
657 | - (self.state_code, True)) | |
661 | + _id=self.state_code, value=True) | |
658 | 662 | |
659 | 663 | def CleanUp(self): |
660 | 664 | self.viewer.interactor.Unbind(wx.EVT_LEFT_DCLICK) |
661 | 665 | Publisher.sendMessage('Toggle toolbar item', |
662 | - (self.state_code, False)) | |
666 | + _id=self.state_code, value=False) | |
663 | 667 | |
664 | 668 | def OnUnZoom(self, evt): |
665 | 669 | mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition() |
... | ... | @@ -687,11 +691,11 @@ class ChangeSliceInteractorStyle(DefaultInteractorStyle): |
687 | 691 | |
688 | 692 | def SetUp(self): |
689 | 693 | Publisher.sendMessage('Toggle toolbar item', |
690 | - (self.state_code, True)) | |
694 | + _id=self.state_code, value=True) | |
691 | 695 | |
692 | 696 | def CleanUp(self): |
693 | 697 | Publisher.sendMessage('Toggle toolbar item', |
694 | - (self.state_code, False)) | |
698 | + _id=self.state_code, value=False) | |
695 | 699 | |
696 | 700 | def OnChangeSliceMove(self, evt, obj): |
697 | 701 | if self.left_pressed: |
... | ... | @@ -779,17 +783,16 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
779 | 783 | self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
780 | 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 | 787 | self.config.cursor_size = size |
785 | 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 | 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 | 797 | def _set_cursor(self): |
795 | 798 | if self.config.cursor_type == const.BRUSH_SQUARE: |
... | ... | @@ -936,7 +939,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
936 | 939 | size += 1 |
937 | 940 | |
938 | 941 | if size <= 100: |
939 | - Publisher.sendMessage('Set edition brush size', size) | |
942 | + Publisher.sendMessage('Set edition brush size', size=size) | |
940 | 943 | cursor.SetPosition(cursor.position) |
941 | 944 | self.viewer.interactor.Render() |
942 | 945 | else: |
... | ... | @@ -954,7 +957,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
954 | 957 | size -= 1 |
955 | 958 | |
956 | 959 | if size > 0: |
957 | - Publisher.sendMessage('Set edition brush size', size) | |
960 | + Publisher.sendMessage('Set edition brush size', size=size) | |
958 | 961 | cursor.SetPosition(cursor.position) |
959 | 962 | self.viewer.interactor.Render() |
960 | 963 | else: |
... | ... | @@ -1005,23 +1008,23 @@ class WatershedConfig(with_metaclass(utils.Singleton, object)): |
1005 | 1008 | Publisher.subscribe(self.set_3dcon, "Set watershed 3d con") |
1006 | 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 | 1029 | WALGORITHM = {"Watershed": watershed, |
1027 | 1030 | "Watershed IFT": watershed_ift} |
... | ... | @@ -1124,13 +1127,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
1124 | 1127 | cursor.SetSize(self.config.cursor_size) |
1125 | 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 | 1131 | self.config.cursor_size = size |
1130 | 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 | 1136 | self._set_cursor() |
1135 | 1137 | |
1136 | 1138 | def OnEnterInteractor(self, obj, evt): |
... | ... | @@ -1157,7 +1159,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
1157 | 1159 | size -= 1 |
1158 | 1160 | |
1159 | 1161 | if size > 0: |
1160 | - Publisher.sendMessage('Set watershed brush size', size) | |
1162 | + Publisher.sendMessage('Set watershed brush size', size=size) | |
1161 | 1163 | cursor.SetPosition(cursor.position) |
1162 | 1164 | self.viewer.interactor.Render() |
1163 | 1165 | else: |
... | ... | @@ -1175,7 +1177,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
1175 | 1177 | size += 1 |
1176 | 1178 | |
1177 | 1179 | if size <= 100: |
1178 | - Publisher.sendMessage('Set watershed brush size', size) | |
1180 | + Publisher.sendMessage('Set watershed brush size', size=size) | |
1179 | 1181 | cursor.SetPosition(cursor.position) |
1180 | 1182 | self.viewer.interactor.Render() |
1181 | 1183 | else: |
... | ... | @@ -1423,7 +1425,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
1423 | 1425 | if roi_m.size: |
1424 | 1426 | roi_m[index] = operation |
1425 | 1427 | |
1426 | - def expand_watershed(self, pubsub_evt): | |
1428 | + def expand_watershed(self): | |
1427 | 1429 | markers = self.matrix |
1428 | 1430 | image = self.viewer.slice_.matrix |
1429 | 1431 | self.viewer.slice_.do_threshold_to_all_slices() |
... | ... | @@ -1631,7 +1633,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1631 | 1633 | self.viewer.slice_.rotations = [0, 0, 0] |
1632 | 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 | 1638 | self._discard_buffers() |
1637 | 1639 | self.viewer.slice_.current_mask.clear_history() |
... | ... | @@ -1687,7 +1689,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1687 | 1689 | self.viewer.slice_.q_orientation = transformations.quaternion_multiply(self.viewer.slice_.q_orientation, transformations.quaternion_about_axis(angle, axis)) |
1688 | 1690 | |
1689 | 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 | 1694 | self._discard_buffers() |
1693 | 1695 | if self.viewer.slice_.current_mask: |
... | ... | @@ -1713,8 +1715,8 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1713 | 1715 | # print (z, y, x), tcoord |
1714 | 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 | 1720 | q = transformations.quaternion_from_euler(az, ay, ax) |
1719 | 1721 | self.viewer.slice_.q_orientation = q |
1720 | 1722 | |
... | ... | @@ -1968,9 +1970,8 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): |
1968 | 1970 | self.viewer.canvas.draw_list.remove(self.draw_retangle) |
1969 | 1971 | Publisher.sendMessage('Redraw canvas') |
1970 | 1972 | |
1971 | - def CropMask(self, pubsub_evt): | |
1973 | + def CropMask(self): | |
1972 | 1974 | if self.viewer.orientation == "AXIAL": |
1973 | - | |
1974 | 1975 | xi, xf, yi, yf, zi, zf = self.draw_retangle.box.GetLimits() |
1975 | 1976 | |
1976 | 1977 | xi += 1 |
... | ... | @@ -1978,7 +1979,7 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): |
1978 | 1979 | |
1979 | 1980 | yi += 1 |
1980 | 1981 | yf += 1 |
1981 | - | |
1982 | + | |
1982 | 1983 | zi += 1 |
1983 | 1984 | zf += 1 |
1984 | 1985 | |
... | ... | @@ -1986,13 +1987,13 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): |
1986 | 1987 | cp_mask = self.viewer.slice_.current_mask.matrix.copy() |
1987 | 1988 | |
1988 | 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 | 1991 | self.viewer.slice_.current_mask.matrix[:] = 1 |
1991 | 1992 | |
1992 | 1993 | self.viewer.slice_.current_mask.matrix[zi-1:zf+1, yi-1:yf+1, xi-1:xf+1] = tmp_mask |
1993 | 1994 | |
1994 | 1995 | self.viewer.slice_.current_mask.save_history(0, 'VOLUME', self.viewer.slice_.current_mask.matrix.copy(), cp_mask) |
1995 | - | |
1996 | + | |
1996 | 1997 | self.viewer.slice_.buffer_slices['AXIAL'].discard_mask() |
1997 | 1998 | self.viewer.slice_.buffer_slices['CORONAL'].discard_mask() |
1998 | 1999 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_mask() |
... | ... | @@ -2002,9 +2003,9 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): |
2002 | 2003 | self.viewer.slice_.buffer_slices['SAGITAL'].discard_vtk_mask() |
2003 | 2004 | |
2004 | 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 | 2009 | class SelectPartConfig(with_metaclass(utils.Singleton, object)): |
2009 | 2010 | def __init__(self): |
2010 | 2011 | self.mask = None |
... | ... | @@ -2066,7 +2067,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
2066 | 2067 | self.config.mask.name = self.config.mask_name |
2067 | 2068 | self.viewer.slice_._add_mask_into_proj(self.config.mask) |
2068 | 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 | 2072 | del self.viewer.slice_.aux_matrices['SELECT'] |
2072 | 2073 | self.viewer.slice_.to_show_aux = '' | ... | ... |
invesalius/data/surface.py
... | ... | @@ -171,11 +171,10 @@ class SurfaceManager(): |
171 | 171 | |
172 | 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 | 175 | proj = prj.Project() |
177 | 176 | surface_dict = proj.surface_dict |
178 | - for index in selected_items: | |
177 | + for index in surface_indexes: | |
179 | 178 | original_surface = surface_dict[index] |
180 | 179 | # compute copy name |
181 | 180 | name = original_surface.name |
... | ... | @@ -190,14 +189,13 @@ class SurfaceManager(): |
190 | 189 | volume = original_surface.volume, |
191 | 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 | 193 | proj = prj.Project() |
196 | 194 | |
197 | 195 | old_dict = self.actors_dict |
198 | 196 | new_dict = {} |
199 | - if selected_items: | |
200 | - for index in selected_items: | |
197 | + if surface_indexes: | |
198 | + for index in surface_indexes: | |
201 | 199 | proj.RemoveSurface(index) |
202 | 200 | if index in old_dict: |
203 | 201 | actor = old_dict[index] |
... | ... | @@ -207,21 +205,21 @@ class SurfaceManager(): |
207 | 205 | if i > index: |
208 | 206 | new_dict[i-1] = old_dict[i] |
209 | 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 | 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 | 212 | if self.actors_dict: |
215 | 213 | self.last_surface_index = 0 |
216 | 214 | else: |
217 | 215 | self.last_surface_index = None |
218 | 216 | |
219 | - def OnSeedSurface(self, pubsub_evt): | |
217 | + def OnSeedSurface(self, seeds): | |
220 | 218 | """ |
221 | 219 | Create a new surface, based on the last selected surface, |
222 | 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 | 223 | index = self.last_surface_index |
226 | 224 | proj = prj.Project() |
227 | 225 | surface = proj.surface_dict[index] |
... | ... | @@ -229,10 +227,10 @@ class SurfaceManager(): |
229 | 227 | new_polydata = pu.JoinSeedsParts(surface.polydata, |
230 | 228 | points_id_list) |
231 | 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 | 231 | #self.ShowActor(index, True) |
234 | 232 | |
235 | - def OnSplitSurface(self, pubsub_evt): | |
233 | + def OnSplitSurface(self): | |
236 | 234 | """ |
237 | 235 | Create n new surfaces, based on the last selected surface, |
238 | 236 | according to their connectivity. |
... | ... | @@ -248,9 +246,9 @@ class SurfaceManager(): |
248 | 246 | index_list.append(index) |
249 | 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 | 253 | Create a new surface, based on largest part of the last |
256 | 254 | selected surface. |
... | ... | @@ -261,13 +259,12 @@ class SurfaceManager(): |
261 | 259 | |
262 | 260 | new_polydata = pu.SelectLargestPart(surface.polydata) |
263 | 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 | 266 | Creates a new surface from a surface file (STL, PLY, OBJ or VTP) |
269 | 267 | """ |
270 | - filename = pubsub_evt.data | |
271 | 268 | self.CreateSurfaceFromFile(filename) |
272 | 269 | |
273 | 270 | def CreateSurfaceFromFile(self, filename): |
... | ... | @@ -368,42 +365,34 @@ class SurfaceManager(): |
368 | 365 | |
369 | 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 | 371 | return surface.index |
378 | 372 | |
379 | - def OnCloseProject(self, pubsub_evt): | |
373 | + def OnCloseProject(self): | |
380 | 374 | self.CloseProject() |
381 | 375 | |
382 | 376 | def CloseProject(self): |
383 | 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 | 379 | del self.actors_dict |
386 | 380 | self.actors_dict = {} |
387 | 381 | |
388 | 382 | # restarting the surface index |
389 | 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 | 387 | # self.actors_dict. |
395 | 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 | 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 | 396 | for key in surface_dict: |
408 | 397 | surface = surface_dict[key] |
409 | 398 | |
... | ... | @@ -436,27 +425,23 @@ class SurfaceManager(): |
436 | 425 | self.actors_dict[surface.index] = actor |
437 | 426 | |
438 | 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 | 430 | Publisher.sendMessage('Update status text in GUI', |
442 | - _("Ready")) | |
431 | + label=_("Ready")) | |
443 | 432 | |
444 | 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 | 435 | if not surface.is_shown: |
450 | 436 | self.ShowActor(key, False) |
451 | 437 | |
452 | 438 | #### |
453 | 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 | 443 | Create surface actor, save into project and send it to viewer. |
458 | 444 | """ |
459 | - slice_, mask, surface_parameters = pubsub_evt.data | |
460 | 445 | matrix = slice_.matrix |
461 | 446 | filename_img = slice_.matrix_filename |
462 | 447 | spacing = slice_.spacing |
... | ... | @@ -825,31 +810,27 @@ class SurfaceManager(): |
825 | 810 | del measured_polydata |
826 | 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 | 815 | # Send actor by pubsub to viewer's render |
831 | 816 | if overwrite and self.actors_dict.keys(): |
832 | 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 | 820 | # Save actor for future management tasks |
836 | 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 | 825 | #When you finalize the progress. The bar is cleaned. |
845 | 826 | UpdateProgress = vu.ShowProgress(1) |
846 | 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 | 830 | Publisher.sendMessage('End busy cursor') |
850 | 831 | del actor |
851 | 832 | |
852 | - def UpdateSurfaceInterpolation(self, pub_evt): | |
833 | + def UpdateSurfaceInterpolation(self): | |
853 | 834 | interpolation = int(ses.Session().surface_interpolation) |
854 | 835 | key_actors = self.actors_dict.keys() |
855 | 836 | |
... | ... | @@ -861,20 +842,18 @@ class SurfaceManager(): |
861 | 842 | """ |
862 | 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 | 846 | self.actors_dict.pop(index) |
866 | 847 | # Remove surface from project's surface_dict |
867 | 848 | proj = prj.Project() |
868 | 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 | 852 | proj = prj.Project() |
873 | 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 | 858 | def ShowActor(self, index, value): |
880 | 859 | """ |
... | ... | @@ -886,30 +865,27 @@ class SurfaceManager(): |
886 | 865 | proj.surface_dict[index].is_shown = value |
887 | 866 | Publisher.sendMessage('Render volume viewer') |
888 | 867 | |
889 | - def SetActorTransparency(self, pubsub_evt): | |
868 | + def SetActorTransparency(self, surface_index, transparency): | |
890 | 869 | """ |
891 | 870 | Set actor transparency (oposite to opacity) according to given actor |
892 | 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 | 874 | # Update value in project's surface_dict |
897 | 875 | proj = prj.Project() |
898 | - proj.surface_dict[index].transparency = value | |
876 | + proj.surface_dict[surface_index].transparency = transparency | |
899 | 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 | 883 | # Update value in project's surface_dict |
907 | 884 | proj = prj.Project() |
908 | - proj.surface_dict[index].colour = colour | |
885 | + proj.surface_dict[surface_index].colour = colour | |
909 | 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 | 889 | ftype_prefix = { |
914 | 890 | const.FILETYPE_STL: '.stl', |
915 | 891 | const.FILETYPE_VTP: '.vtp', | ... | ... |
invesalius/data/viewer_slice.py
... | ... | @@ -132,29 +132,27 @@ class ContourMIPConfig(wx.Panel): |
132 | 132 | |
133 | 133 | Publisher.subscribe(self._set_projection_type, 'Set projection type') |
134 | 134 | |
135 | - def OnSetMIPSize(self, evt): | |
135 | + def OnSetMIPSize(self, number_slices): | |
136 | 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 | 139 | def OnSetMIPBorder(self, evt): |
140 | 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 | 143 | def OnCheckInverted(self, evt): |
144 | 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 | 150 | self.inverted.Enable() |
153 | 151 | else: |
154 | 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 | 156 | self.border_spin.Enable() |
159 | 157 | self.txt_mip_border.Enable() |
160 | 158 | else: |
... | ... | @@ -664,8 +662,7 @@ class Viewer(wx.Panel): |
664 | 662 | self.UpdateCanvas() |
665 | 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 | 666 | self.SetLayout(layout) |
670 | 667 | |
671 | 668 | def __config_interactor(self): |
... | ... | @@ -693,8 +690,7 @@ class Viewer(wx.Panel): |
693 | 690 | |
694 | 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 | 694 | self.acum_achange_window, self.acum_achange_level = (window, level) |
699 | 695 | self.SetWLText(window, level) |
700 | 696 | |
... | ... | @@ -704,18 +700,18 @@ class Viewer(wx.Panel): |
704 | 700 | Publisher.sendMessage('Update all slice') |
705 | 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 | 705 | self.SetWLText(window, level) |
711 | 706 | self.interactor.Render() |
712 | 707 | |
713 | 708 | def OnClutChange(self, evt): |
714 | 709 | Publisher.sendMessage('Change colour table from background image from widget', |
715 | - evt.GetNodes()) | |
710 | + nodes=evt.GetNodes()) | |
716 | 711 | slc = sl.Slice() |
717 | 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 | 716 | def SetWLText(self, window_width, window_level): |
721 | 717 | value = STR_WL%(window_level, window_width) |
... | ... | @@ -930,46 +926,45 @@ class Viewer(wx.Panel): |
930 | 926 | ren.GetActiveCamera().Zoom(1.0) |
931 | 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 | 931 | self._brush_cursor_colour = vtk_colour |
936 | 932 | if (self.cursor): |
937 | 933 | for slice_data in self.slice_data_list: |
938 | 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 | 938 | self._brush_cursor_colour = colour_vtk |
944 | 939 | if self.slice_data.cursor: |
945 | 940 | self.slice_data.cursor.SetColour(colour_vtk) |
946 | 941 | |
947 | - def UpdateSlicesNavigation(self, pubsub_evt): | |
942 | + def UpdateSlicesNavigation(self, arg, position): | |
948 | 943 | # Get point from base change |
949 | - ux, uy, uz = pubsub_evt.data[1][:3] | |
944 | + ux, uy, uz = position[:3] | |
950 | 945 | px, py = self.get_slice_pixel_coord_by_world_pos(ux, uy, uz) |
951 | 946 | coord = self.calcultate_scroll_position(px, py) |
952 | 947 | |
953 | 948 | self.cross.SetFocalPoint((ux, uy, uz)) |
954 | 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 | 952 | def ScrollSlice(self, coord): |
958 | 953 | if self.orientation == "AXIAL": |
959 | 954 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
960 | - coord[0]) | |
955 | + index=coord[0]) | |
961 | 956 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
962 | - coord[1]) | |
957 | + index=coord[1]) | |
963 | 958 | elif self.orientation == "SAGITAL": |
964 | 959 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
965 | - coord[2]) | |
960 | + index=coord[2]) | |
966 | 961 | Publisher.sendMessage(('Set scroll position', 'CORONAL'), |
967 | - coord[1]) | |
962 | + index=coord[1]) | |
968 | 963 | elif self.orientation == "CORONAL": |
969 | 964 | Publisher.sendMessage(('Set scroll position', 'AXIAL'), |
970 | - coord[2]) | |
965 | + index=coord[2]) | |
971 | 966 | Publisher.sendMessage(('Set scroll position', 'SAGITAL'), |
972 | - coord[0]) | |
967 | + index=coord[0]) | |
973 | 968 | |
974 | 969 | def get_slice_data(self, render): |
975 | 970 | #for slice_data in self.slice_data_list: |
... | ... | @@ -1251,39 +1246,37 @@ class Viewer(wx.Panel): |
1251 | 1246 | Publisher.subscribe(self.UpdateInterpolatedSlice, "Update Slice Interpolation") |
1252 | 1247 | |
1253 | 1248 | |
1254 | - def RefreshViewer(self, pubsub_evt): | |
1249 | + def RefreshViewer(self): | |
1255 | 1250 | self.Refresh() |
1256 | 1251 | |
1257 | - def SetDefaultCursor(self, pusub_evt): | |
1252 | + def SetDefaultCursor(self): | |
1258 | 1253 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
1259 | 1254 | |
1260 | - def SetSizeNSCursor(self, pusub_evt): | |
1255 | + def SetSizeNSCursor(self): | |
1261 | 1256 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) |
1262 | 1257 | |
1263 | - def SetSizeWECursor(self, pusub_evt): | |
1258 | + def SetSizeWECursor(self): | |
1264 | 1259 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) |
1265 | 1260 | |
1266 | - def SetSizeNWSECursor(self, pubsub_evt): | |
1261 | + def SetSizeNWSECursor(self): | |
1267 | 1262 | if sys.platform.startswith('linux'): |
1268 | 1263 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE)) |
1269 | 1264 | else: |
1270 | 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 | 1268 | dict = {"AXIAL": const.AXIAL, |
1276 | 1269 | "CORONAL": const.CORONAL, |
1277 | 1270 | "SAGITAL": const.SAGITAL} |
1278 | 1271 | |
1279 | - if id == dict[self.orientation]: | |
1272 | + if orientation == dict[self.orientation]: | |
1280 | 1273 | Publisher.sendMessage('Begin busy cursor') |
1281 | 1274 | if _has_win32api: |
1282 | 1275 | utils.touch(filename) |
1283 | 1276 | win_filename = win32api.GetShortPathName(filename) |
1284 | - self._export_picture(id, win_filename, filetype) | |
1277 | + self._export_picture(orientation, win_filename, filetype) | |
1285 | 1278 | else: |
1286 | - self._export_picture(id, filename, filetype) | |
1279 | + self._export_picture(orientation, filename, filetype) | |
1287 | 1280 | Publisher.sendMessage('End busy cursor') |
1288 | 1281 | |
1289 | 1282 | def _export_picture(self, id, filename, filetype): |
... | ... | @@ -1340,13 +1333,13 @@ class Viewer(wx.Panel): |
1340 | 1333 | |
1341 | 1334 | Publisher.sendMessage('End busy cursor') |
1342 | 1335 | |
1343 | - def OnShowText(self, pubsub_evt): | |
1336 | + def OnShowText(self): | |
1344 | 1337 | self.ShowTextActors() |
1345 | 1338 | |
1346 | - def OnHideText(self, pubsub_evt): | |
1339 | + def OnHideText(self): | |
1347 | 1340 | self.HideTextActors() |
1348 | 1341 | |
1349 | - def OnCloseProject(self, pubsub_evt): | |
1342 | + def OnCloseProject(self): | |
1350 | 1343 | self.CloseProject() |
1351 | 1344 | |
1352 | 1345 | def CloseProject(self): |
... | ... | @@ -1371,11 +1364,10 @@ class Viewer(wx.Panel): |
1371 | 1364 | self.wl_text = None |
1372 | 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 | 1371 | Publisher.sendMessage('Set interactor default cursor') |
1380 | 1372 | |
1381 | 1373 | def __bind_events_wx(self): |
... | ... | @@ -1386,8 +1378,7 @@ class Viewer(wx.Panel): |
1386 | 1378 | self.interactor.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) |
1387 | 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 | 1382 | self.SetInput(mask_dict) |
1392 | 1383 | |
1393 | 1384 | def LoadRenderers(self, imagedata): |
... | ... | @@ -1509,9 +1500,8 @@ class Viewer(wx.Panel): |
1509 | 1500 | |
1510 | 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 | 1506 | def _set_cross_visibility(self, visibility): |
1517 | 1507 | self.cross_actor.SetVisibility(visibility) |
... | ... | @@ -1569,8 +1559,8 @@ class Viewer(wx.Panel): |
1569 | 1559 | |
1570 | 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 | 1564 | if ses.Session().slice_interpolation: |
1575 | 1565 | self.slice_actor.InterpolateOff() |
1576 | 1566 | else: |
... | ... | @@ -1578,15 +1568,13 @@ class Viewer(wx.Panel): |
1578 | 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 | 1573 | if self.slice_actor != None: |
1585 | - if status == True: | |
1574 | + if self.interpolation_slice_status == True: | |
1586 | 1575 | self.slice_actor.InterpolateOn() |
1587 | 1576 | else: |
1588 | 1577 | self.slice_actor.InterpolateOff() |
1589 | - | |
1590 | 1578 | self.interactor.Render() |
1591 | 1579 | |
1592 | 1580 | def __update_camera(self): |
... | ... | @@ -1605,7 +1593,7 @@ class Viewer(wx.Panel): |
1605 | 1593 | self.slice_data.actor.SetDisplayExtent(image.GetExtent()) |
1606 | 1594 | self.slice_data.renderer.ResetCameraClippingRange() |
1607 | 1595 | |
1608 | - def UpdateRender(self, evt): | |
1596 | + def UpdateRender(self): | |
1609 | 1597 | self.interactor.Render() |
1610 | 1598 | |
1611 | 1599 | def UpdateCanvas(self, evt=None): |
... | ... | @@ -1655,8 +1643,8 @@ class Viewer(wx.Panel): |
1655 | 1643 | def UpdateSlice3D(self, pos): |
1656 | 1644 | original_orientation = project.Project().original_orientation |
1657 | 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 | 1649 | def OnScrollBar(self, evt=None, update3D=True): |
1662 | 1650 | pos = self.scroll.GetThumbPosition() |
... | ... | @@ -1667,7 +1655,7 @@ class Viewer(wx.Panel): |
1667 | 1655 | # Update other slice's cross according to the new focal point from |
1668 | 1656 | # the actual orientation. |
1669 | 1657 | focal_point = self.cross.GetFocalPoint() |
1670 | - Publisher.sendMessage('Update cross position', focal_point) | |
1658 | + Publisher.sendMessage('Update cross position', position=focal_point) | |
1671 | 1659 | Publisher.sendMessage('Update slice viewer') |
1672 | 1660 | else: |
1673 | 1661 | self.interactor.Render() |
... | ... | @@ -1722,7 +1710,7 @@ class Viewer(wx.Panel): |
1722 | 1710 | |
1723 | 1711 | elif evt.GetKeyCode() in projections: |
1724 | 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 | 1714 | Publisher.sendMessage('Reload actual slice') |
1727 | 1715 | skip = False |
1728 | 1716 | |
... | ... | @@ -1766,28 +1754,24 @@ class Viewer(wx.Panel): |
1766 | 1754 | self.slice_data.SetSize((w, h)) |
1767 | 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 | 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 | 1763 | buffer_ = self.slice_.buffer_slices[self.orientation] |
1778 | 1764 | buffer_.discard_buffer() |
1779 | 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 | 1769 | buffer_ = self.slice_.buffer_slices[self.orientation] |
1785 | 1770 | buffer_.discard_buffer() |
1786 | 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 | 1775 | if not self.mip_ctrls.Shown: |
1792 | 1776 | self.mip_ctrls.Show() |
1793 | 1777 | self.GetSizer().Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) |
... | ... | @@ -1797,9 +1781,8 @@ class Viewer(wx.Panel): |
1797 | 1781 | self.GetSizer().Detach(self.mip_ctrls) |
1798 | 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 | 1787 | def set_slice_number(self, index): |
1805 | 1788 | inverted = self.mip_ctrls.inverted.GetValue() |
... | ... | @@ -1831,28 +1814,27 @@ class Viewer(wx.Panel): |
1831 | 1814 | self.__update_display_extent(image) |
1832 | 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 | 1818 | #self.set_slice_number(index) |
1837 | 1819 | self.scroll.SetThumbPosition(index) |
1838 | 1820 | pos = self.scroll.GetThumbPosition() |
1839 | 1821 | self.set_slice_number(pos) |
1840 | 1822 | self.interactor.Render() |
1841 | 1823 | |
1842 | - def ReloadActualSlice(self, pubsub_evt=None): | |
1824 | + def ReloadActualSlice(self): | |
1843 | 1825 | pos = self.scroll.GetThumbPosition() |
1844 | 1826 | self.set_slice_number(pos) |
1845 | 1827 | self.interactor.Render() |
1846 | 1828 | |
1847 | - def OnUpdateScroll(self, pubsub_evt): | |
1829 | + def OnUpdateScroll(self): | |
1848 | 1830 | max_slice_number = sl.Slice().GetNumberOfSlices(self.orientation) |
1849 | 1831 | self.scroll.SetScrollbar(wx.SB_VERTICAL, 1, max_slice_number, |
1850 | 1832 | max_slice_number) |
1851 | 1833 | |
1852 | - def OnSwapVolumeAxes(self, pubsub_evt): | |
1834 | + def OnSwapVolumeAxes(self, axes): | |
1853 | 1835 | # Adjusting cursor spacing to match the spacing from the actual slice |
1854 | 1836 | # orientation |
1855 | - axis0, axis1 = pubsub_evt.data | |
1837 | + axis0, axis1 = axes | |
1856 | 1838 | cursor = self.slice_data.cursor |
1857 | 1839 | spacing = cursor.spacing |
1858 | 1840 | if (axis0, axis1) == (2, 1): |
... | ... | @@ -1864,34 +1846,32 @@ class Viewer(wx.Panel): |
1864 | 1846 | |
1865 | 1847 | self.slice_data.renderer.ResetCamera() |
1866 | 1848 | |
1867 | - def AddActors(self, pubsub_evt): | |
1849 | + def AddActors(self, actors, slice_number): | |
1868 | 1850 | "Inserting actors" |
1869 | - actors, n = pubsub_evt.data | |
1870 | 1851 | pos = self.scroll.GetThumbPosition() |
1871 | 1852 | #try: |
1872 | - #renderer = self.renderers_by_slice_number[n] | |
1853 | + #renderer = self.renderers_by_slice_number[slice_number] | |
1873 | 1854 | #for actor in actors: |
1874 | 1855 | #renderer.AddActor(actor) |
1875 | 1856 | #except KeyError: |
1876 | 1857 | #pass |
1877 | - if pos == n: | |
1858 | + if pos == slice_number: | |
1878 | 1859 | for actor in actors: |
1879 | 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 | 1865 | "Remove a list of actors" |
1885 | - actors, n = pubsub_evt.data | |
1886 | 1866 | try: |
1887 | - renderer = self.renderers_by_slice_number[n] | |
1867 | + renderer = self.renderers_by_slice_number[slice_number] | |
1888 | 1868 | except KeyError: |
1889 | 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 | 1871 | self.slice_data.renderer.RemoveActor(actor) |
1892 | 1872 | else: |
1893 | 1873 | for actor in actors: |
1894 | 1874 | # Remove the actor from the renderer |
1895 | 1875 | renderer.RemoveActor(actor) |
1896 | 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 | 264 | Publisher.subscribe(self.OnUpdateAngleThreshold, 'Update angle threshold') |
265 | 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 | 268 | ren_win = self.interactor.GetRenderWindow() |
270 | 269 | |
271 | 270 | if mode == const.STEREO_OFF: |
... | ... | @@ -293,23 +292,19 @@ class Viewer(wx.Panel): |
293 | 292 | |
294 | 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 | 297 | self._mode_cross = True |
300 | 298 | self._check_and_set_ball_visibility() |
301 | 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 | 303 | self._mode_cross = False |
307 | 304 | self.RemoveBallReference() |
308 | 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 | 308 | if not self.sen1: |
314 | 309 | self.CreateSensorID() |
315 | 310 | |
... | ... | @@ -345,39 +340,36 @@ class Viewer(wx.Panel): |
345 | 340 | |
346 | 341 | self.interactor.Render() |
347 | 342 | |
348 | - def OnRemoveSensorsID(self, pubsub_evt): | |
343 | + def OnRemoveSensorsID(self): | |
349 | 344 | if self.sen1: |
350 | 345 | self.ren.RemoveActor(self.sen1.actor) |
351 | 346 | self.ren.RemoveActor(self.sen2.actor) |
352 | 347 | self.sen1 = self.sen2 = False |
353 | 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 | 352 | self._to_show_ball += 1 |
359 | 353 | else: |
360 | 354 | self._to_show_ball -= 1 |
361 | 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 | 358 | self.seed_points = [] |
366 | 359 | |
367 | - def OnEndSeed(self, pubsub_evt): | |
360 | + def OnEndSeed(self): | |
368 | 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 | 366 | Publisher.sendMessage('Begin busy cursor') |
375 | 367 | if _has_win32api: |
376 | 368 | utils.touch(filename) |
377 | 369 | win_filename = win32api.GetShortPathName(filename) |
378 | - self._export_picture(id, win_filename, filetype) | |
370 | + self._export_picture(orientation, win_filename, filetype) | |
379 | 371 | else: |
380 | - self._export_picture(id, filename, filetype) | |
372 | + self._export_picture(orientation, filename, filetype) | |
381 | 373 | Publisher.sendMessage('End busy cursor') |
382 | 374 | |
383 | 375 | def _export_picture(self, id, filename, filetype): |
... | ... | @@ -419,7 +411,7 @@ class Viewer(wx.Panel): |
419 | 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 | 415 | if self.raycasting_volume: |
424 | 416 | self.raycasting_volume = False |
425 | 417 | |
... | ... | @@ -436,22 +428,21 @@ class Viewer(wx.Panel): |
436 | 428 | self.SetInteractorStyle(const.STATE_DEFAULT) |
437 | 429 | self._last_state = const.STATE_DEFAULT |
438 | 430 | |
439 | - def OnHideText(self, pubsub_evt): | |
431 | + def OnHideText(self): | |
440 | 432 | self.text.Hide() |
441 | 433 | self.interactor.Render() |
442 | 434 | |
443 | - def OnShowText(self, pubsub_evt): | |
435 | + def OnShowText(self): | |
444 | 436 | if self.on_wl: |
445 | 437 | self.text.Show() |
446 | 438 | self.interactor.Render() |
447 | 439 | |
448 | - def AddActors(self, pubsub_evt): | |
440 | + def AddActors(self, actors): | |
449 | 441 | "Inserting actors" |
450 | - actors = pubsub_evt.data[0] | |
451 | 442 | for actor in actors: |
452 | 443 | self.ren.AddActor(actor) |
453 | 444 | |
454 | - def RemoveVolume(self, pub_evt): | |
445 | + def RemoveVolume(self): | |
455 | 446 | volumes = self.ren.GetVolumes() |
456 | 447 | if (volumes.GetNumberOfItems()): |
457 | 448 | self.ren.RemoveVolume(volumes.GetLastProp()) |
... | ... | @@ -459,9 +450,8 @@ class Viewer(wx.Panel): |
459 | 450 | self._to_show_ball -= 1 |
460 | 451 | self._check_and_set_ball_visibility() |
461 | 452 | |
462 | - def RemoveActors(self, pubsub_evt): | |
453 | + def RemoveActors(self, actors): | |
463 | 454 | "Remove a list of actors" |
464 | - actors = pubsub_evt.data[0] | |
465 | 455 | for actor in actors: |
466 | 456 | self.ren.RemoveActor(actor) |
467 | 457 | |
... | ... | @@ -501,25 +491,22 @@ class Viewer(wx.Panel): |
501 | 491 | actor = self.points_reference.pop(point) |
502 | 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 | 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 | 499 | x, y, z = bases.flip_x(coord) |
513 | 500 | |
514 | 501 | ball_ref = vtk.vtkSphereSource() |
515 | - ball_ref.SetRadius(ballsize) | |
502 | + ball_ref.SetRadius(size) | |
516 | 503 | ball_ref.SetCenter(x, y, z) |
517 | 504 | |
518 | 505 | mapper = vtk.vtkPolyDataMapper() |
519 | 506 | mapper.SetInputConnection(ball_ref.GetOutputPort()) |
520 | 507 | |
521 | 508 | prop = vtk.vtkProperty() |
522 | - prop.SetColor(ballcolour) | |
509 | + prop.SetColor(colour) | |
523 | 510 | |
524 | 511 | #adding a new actor for the present ball |
525 | 512 | self.staticballs.append(vtk.vtkActor()) |
... | ... | @@ -532,38 +519,37 @@ class Viewer(wx.Panel): |
532 | 519 | #self.UpdateRender() |
533 | 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 | 524 | for i in range(0, ballid): |
538 | 525 | self.staticballs[i].SetVisibility(0) |
539 | 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 | 530 | for i in range(0, ballid): |
544 | 531 | self.staticballs[i].SetVisibility(1) |
545 | 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 | 536 | for i in range(0, ballid): |
550 | 537 | self.ren.RemoveActor(self.staticballs[i]) |
551 | 538 | self.staticballs = [] |
552 | 539 | self.UpdateRender() |
553 | 540 | |
554 | - def RemoveMarker(self, pubsub_evt): | |
555 | - index = pubsub_evt.data | |
541 | + def RemoveMarker(self, index): | |
556 | 542 | for i in reversed(index): |
557 | 543 | self.ren.RemoveActor(self.staticballs[i]) |
558 | 544 | del self.staticballs[i] |
559 | 545 | self.ball_id = self.ball_id - 1 |
560 | 546 | self.UpdateRender() |
561 | 547 | |
562 | - def BlinkMarker(self, pubsub_evt): | |
548 | + def BlinkMarker(self, index): | |
563 | 549 | if self.timer: |
564 | 550 | self.timer.Stop() |
565 | 551 | self.staticballs[self.index].SetVisibility(1) |
566 | - self.index = pubsub_evt.data | |
552 | + self.index = index | |
567 | 553 | self.timer = wx.Timer(self) |
568 | 554 | self.Bind(wx.EVT_TIMER, self.OnBlinkMarker, self.timer) |
569 | 555 | self.timer.Start(500) |
... | ... | @@ -574,31 +560,29 @@ class Viewer(wx.Panel): |
574 | 560 | self.Refresh() |
575 | 561 | self.timer_count += 1 |
576 | 562 | |
577 | - def StopBlinkMarker(self, pubsub_evt): | |
563 | + def StopBlinkMarker(self, index=None): | |
578 | 564 | if self.timer: |
579 | 565 | self.timer.Stop() |
580 | - if pubsub_evt.data is None: | |
566 | + if index is None: | |
581 | 567 | self.staticballs[self.index].SetVisibility(1) |
582 | 568 | self.Refresh() |
583 | 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 | 572 | if status: |
589 | 573 | self.staticballs[index].GetProperty().SetOpacity(1) |
590 | 574 | # self.staticballs[index].GetProperty().SetOpacity(0.4) |
591 | 575 | else: |
592 | 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 | 586 | if self.target_coord and self.target_mode: |
603 | 587 | self.CreateTargetAim() |
604 | 588 | |
... | ... | @@ -691,8 +675,7 @@ class Viewer(wx.Panel): |
691 | 675 | else: |
692 | 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 | 679 | if self.target_coord and self.target_mode: |
697 | 680 | |
698 | 681 | target_dist = distance.euclidean(coord[0:3], |
... | ... | @@ -811,13 +794,12 @@ class Viewer(wx.Panel): |
811 | 794 | |
812 | 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 | 799 | self.target_coord[1] = -self.target_coord[1] |
817 | 800 | self.CreateTargetAim() |
818 | 801 | |
819 | - def OnRemoveTarget(self, pubsub_evt): | |
820 | - status = pubsub_evt.data | |
802 | + def OnRemoveTarget(self, status): | |
821 | 803 | if not status: |
822 | 804 | self.target_mode = None |
823 | 805 | self.target_coord = None |
... | ... | @@ -1108,12 +1090,12 @@ class Viewer(wx.Panel): |
1108 | 1090 | self.ren.RemoveActor(self.ball_actor) |
1109 | 1091 | self.ball_actor = None |
1110 | 1092 | |
1111 | - def SetBallReferencePosition(self, pubsub_evt): | |
1093 | + def SetBallReferencePosition(self, position): | |
1112 | 1094 | if self._to_show_ball: |
1113 | 1095 | if not self.ball_actor: |
1114 | 1096 | self.ActivateBallReference() |
1115 | 1097 | |
1116 | - coord = pubsub_evt.data | |
1098 | + coord = position | |
1117 | 1099 | x, y, z = bases.flip_x(coord) |
1118 | 1100 | self.ball_actor.SetPosition(x, y, z) |
1119 | 1101 | |
... | ... | @@ -1198,18 +1180,15 @@ class Viewer(wx.Panel): |
1198 | 1180 | |
1199 | 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 | 1185 | self.pTarget = self.CenterOfMass() |
1204 | 1186 | if self.obj_actor and self.nav_status: |
1205 | 1187 | self.obj_actor.SetVisibility(self.obj_state) |
1206 | 1188 | if not self.obj_state: |
1207 | 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 | 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 | 1194 | m_img_vtk = vtk.vtkMatrix4x4() |
... | ... | @@ -1223,22 +1202,19 @@ class Viewer(wx.Panel): |
1223 | 1202 | |
1224 | 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 | 1208 | if not self.obj_actor: |
1231 | 1209 | self.AddObjectActor(self.obj_name) |
1232 | - | |
1233 | 1210 | else: |
1234 | 1211 | if self.obj_actor: |
1235 | 1212 | self.ren.RemoveActor(self.obj_actor) |
1236 | 1213 | self.obj_actor = None |
1237 | - | |
1238 | 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 | 1218 | if self.obj_actor and not self.obj_state: |
1243 | 1219 | self.obj_actor.SetVisibility(self.obj_state) |
1244 | 1220 | self.Refresh() |
... | ... | @@ -1371,8 +1347,8 @@ class Viewer(wx.Panel): |
1371 | 1347 | diff_y = mouse_y - self.last_y |
1372 | 1348 | self.last_x, self.last_y = mouse_x, mouse_y |
1373 | 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 | 1352 | self.interactor.Render() |
1377 | 1353 | |
1378 | 1354 | def OnWindowLevelClick(self, obj, evt): |
... | ... | @@ -1387,31 +1363,29 @@ class Viewer(wx.Panel): |
1387 | 1363 | if const.RAYCASTING_WWWL_BLUR: |
1388 | 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 | 1369 | self.SetInteractorStyle(new_state) |
1395 | 1370 | else: |
1396 | - new_state = self.interaction_style.RemoveState(state) | |
1371 | + new_state = self.interaction_style.RemoveState(style) | |
1397 | 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 | 1376 | self.SetInteractorStyle(new_state) |
1403 | 1377 | |
1404 | - def ResetCamClippingRange(self, pubsub_evt): | |
1378 | + def ResetCamClippingRange(self): | |
1405 | 1379 | self.ren.ResetCamera() |
1406 | 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 | 1386 | if self.camera_state: |
1413 | 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 | 1389 | cam = self.ren.GetActiveCamera() |
1416 | 1390 | |
1417 | 1391 | if self.initial_focus is None: |
... | ... | @@ -1442,8 +1416,7 @@ class Viewer(wx.Panel): |
1442 | 1416 | #self.interactor.Render() |
1443 | 1417 | self.Refresh() |
1444 | 1418 | |
1445 | - def OnExportSurface(self, pubsub_evt): | |
1446 | - filename, filetype = pubsub_evt.data | |
1419 | + def OnExportSurface(self, filename, filetype): | |
1447 | 1420 | if filetype not in (const.FILETYPE_STL, |
1448 | 1421 | const.FILETYPE_VTP, |
1449 | 1422 | const.FILETYPE_PLY, |
... | ... | @@ -1487,23 +1460,22 @@ class Viewer(wx.Panel): |
1487 | 1460 | writer.SetInput(renwin) |
1488 | 1461 | writer.Write() |
1489 | 1462 | |
1490 | - def OnEnableBrightContrast(self, pubsub_evt): | |
1463 | + def OnEnableBrightContrast(self): | |
1491 | 1464 | style = self.style |
1492 | 1465 | style.AddObserver("MouseMoveEvent", self.OnMove) |
1493 | 1466 | style.AddObserver("LeftButtonPressEvent", self.OnClick) |
1494 | 1467 | style.AddObserver("LeftButtonReleaseEvent", self.OnRelease) |
1495 | 1468 | |
1496 | - def OnDisableBrightContrast(self, pubsub_evt): | |
1469 | + def OnDisableBrightContrast(self): | |
1497 | 1470 | style = vtk.vtkInteractorStyleTrackballCamera() |
1498 | 1471 | self.interactor.SetInteractorStyle(style) |
1499 | 1472 | self.style = style |
1500 | 1473 | |
1501 | - def OnSetWindowLevelText(self, pubsub_evt): | |
1474 | + def OnSetWindowLevelText(self, ww, wl): | |
1502 | 1475 | if self.raycasting_volume: |
1503 | - ww, wl = pubsub_evt.data | |
1504 | 1476 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) |
1505 | 1477 | |
1506 | - def OnShowRaycasting(self, pubsub_evt): | |
1478 | + def OnShowRaycasting(self): | |
1507 | 1479 | if not self.raycasting_volume: |
1508 | 1480 | self.raycasting_volume = True |
1509 | 1481 | self._to_show_ball += 1 |
... | ... | @@ -1511,7 +1483,7 @@ class Viewer(wx.Panel): |
1511 | 1483 | if self.on_wl: |
1512 | 1484 | self.text.Show() |
1513 | 1485 | |
1514 | - def OnHideRaycasting(self, pubsub_evt): | |
1486 | + def OnHideRaycasting(self): | |
1515 | 1487 | self.raycasting_volume = False |
1516 | 1488 | self.text.Hide() |
1517 | 1489 | self._to_show_ball -= 1 |
... | ... | @@ -1524,13 +1496,11 @@ class Viewer(wx.Panel): |
1524 | 1496 | self.interactor.Update() |
1525 | 1497 | evt.Skip() |
1526 | 1498 | |
1527 | - def ChangeBackgroundColour(self, pubsub_evt): | |
1528 | - colour = pubsub_evt.data | |
1499 | + def ChangeBackgroundColour(self, colour): | |
1529 | 1500 | self.ren.SetBackground(colour[:3]) |
1530 | 1501 | self.UpdateRender() |
1531 | 1502 | |
1532 | - def LoadActor(self, pubsub_evt): | |
1533 | - actor = pubsub_evt.data | |
1503 | + def LoadActor(self, actor): | |
1534 | 1504 | self.added_actor = 1 |
1535 | 1505 | ren = self.ren |
1536 | 1506 | ren.AddActor(actor) |
... | ... | @@ -1547,31 +1517,26 @@ class Viewer(wx.Panel): |
1547 | 1517 | self._to_show_ball += 1 |
1548 | 1518 | self._check_and_set_ball_visibility() |
1549 | 1519 | |
1550 | - def RemoveActor(self, pubsub_evt): | |
1520 | + def RemoveActor(self, actor): | |
1551 | 1521 | utils.debug("RemoveActor") |
1552 | - actor = pubsub_evt.data | |
1553 | 1522 | ren = self.ren |
1554 | 1523 | ren.RemoveActor(actor) |
1555 | 1524 | self.interactor.Render() |
1556 | 1525 | self._to_show_ball -= 1 |
1557 | 1526 | self._check_and_set_ball_visibility() |
1558 | 1527 | |
1559 | - def RemoveAllActor(self, pubsub_evt): | |
1528 | + def RemoveAllActor(self): | |
1560 | 1529 | utils.debug("RemoveAllActor") |
1561 | 1530 | self.ren.RemoveAllProps() |
1562 | 1531 | Publisher.sendMessage('Render volume viewer') |
1563 | 1532 | |
1564 | - def LoadSlicePlane(self, pubsub_evt): | |
1533 | + def LoadSlicePlane(self): | |
1565 | 1534 | self.slice_plane = SlicePlane() |
1566 | 1535 | |
1567 | - def LoadVolume(self, pubsub_evt): | |
1536 | + def LoadVolume(self, volume, colour, ww, wl): | |
1568 | 1537 | self.raycasting_volume = True |
1569 | 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 | 1540 | self.light = self.ren.GetLights().GetNextItem() |
1576 | 1541 | |
1577 | 1542 | self.ren.AddVolume(volume) |
... | ... | @@ -1593,16 +1558,14 @@ class Viewer(wx.Panel): |
1593 | 1558 | self._check_and_set_ball_visibility() |
1594 | 1559 | self.UpdateRender() |
1595 | 1560 | |
1596 | - def UnloadVolume(self, pubsub_evt): | |
1597 | - volume = pubsub_evt.data | |
1561 | + def UnloadVolume(self, volume): | |
1598 | 1562 | self.ren.RemoveVolume(volume) |
1599 | 1563 | del volume |
1600 | 1564 | self.raycasting_volume = False |
1601 | 1565 | self._to_show_ball -= 1 |
1602 | 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 | 1569 | self.SetViewAngle(view) |
1607 | 1570 | |
1608 | 1571 | def SetViewAngle(self, view): |
... | ... | @@ -1657,14 +1620,14 @@ class Viewer(wx.Panel): |
1657 | 1620 | orientation_widget.On() |
1658 | 1621 | orientation_widget.InteractiveOff() |
1659 | 1622 | |
1660 | - def UpdateRender(self, evt_pubsub=None): | |
1623 | + def UpdateRender(self): | |
1661 | 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 | 1632 | def OnInsertSeed(self, obj, evt): |
1670 | 1633 | x,y = self.interactor.GetEventPosition() |
... | ... | @@ -1693,7 +1656,10 @@ class Viewer(wx.Panel): |
1693 | 1656 | # Publisher.sendMessage("Add measure to list", |
1694 | 1657 | # (u"3D", _(u"%.3f mm" % m.GetValue()))) |
1695 | 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 | 1663 | self.interactor.Render() |
1698 | 1664 | |
1699 | 1665 | def OnInsertAngularMeasurePoint(self, obj, evt): |
... | ... | @@ -1724,21 +1690,23 @@ class Viewer(wx.Panel): |
1724 | 1690 | # type_, location, |
1725 | 1691 | # value)) |
1726 | 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 | 1697 | self.interactor.Render() |
1729 | 1698 | |
1730 | - def Reposition3DPlane(self, evt_pubsub): | |
1731 | - position = evt_pubsub.data | |
1699 | + def Reposition3DPlane(self, plane_label): | |
1732 | 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 | 1702 | self.SetViewAngle(const.VOL_ISO) |
1735 | 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 | 1706 | self.SetViewAngle(const.VOL_ISO) |
1739 | 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 | 1710 | self.SetViewAngle(const.VOL_ISO) |
1743 | 1711 | self.repositioned_coronal_plan = 1 |
1744 | 1712 | |
... | ... | @@ -1825,39 +1793,36 @@ class SlicePlane: |
1825 | 1793 | selected_prop2 = plane_y.GetSelectedPlaneProperty() |
1826 | 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 | 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 | 1805 | self.plane_z.On() |
1839 | - elif(label == "Coronal"): | |
1806 | + elif(plane_label == "Coronal"): | |
1840 | 1807 | self.plane_y.On() |
1841 | - elif(label == "Sagital"): | |
1808 | + elif(plane_label == "Sagital"): | |
1842 | 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 | 1811 | else: |
1847 | 1812 | self.plane_z.On() |
1848 | 1813 | self.plane_x.On() |
1849 | 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 | 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 | 1822 | self.plane_z.Off() |
1858 | - elif(label == "Coronal"): | |
1823 | + elif(plane_label == "Coronal"): | |
1859 | 1824 | self.plane_y.Off() |
1860 | - elif(label == "Sagital"): | |
1825 | + elif(plane_label == "Sagital"): | |
1861 | 1826 | self.plane_x.Off() |
1862 | 1827 | else: |
1863 | 1828 | self.plane_z.Off() |
... | ... | @@ -1869,23 +1834,33 @@ class SlicePlane: |
1869 | 1834 | def Render(self): |
1870 | 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 | 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 | 1842 | self.Render() |
1878 | 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 | 1847 | self.Render() |
1881 | 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 | 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 | 1866 | def DeletePlanes(self): | ... | ... |
invesalius/data/volume.py
... | ... | @@ -110,17 +110,17 @@ class Volume(): |
110 | 110 | Publisher.subscribe(self.ChangeBackgroundColour, |
111 | 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 | 115 | Publisher.subscribe(self.OnFlipVolume, 'Flip volume') |
116 | 116 | |
117 | - def ResetRayCasting(self, pub_evt): | |
117 | + def ResetRayCasting(self): | |
118 | 118 | if self.exist: |
119 | 119 | self.exist = None |
120 | 120 | self.LoadVolume() |
121 | 121 | |
122 | 122 | |
123 | - def OnCloseProject(self, pubsub_evt): | |
123 | + def OnCloseProject(self): | |
124 | 124 | self.CloseProject() |
125 | 125 | |
126 | 126 | def CloseProject(self): |
... | ... | @@ -134,9 +134,9 @@ class Volume(): |
134 | 134 | |
135 | 135 | if self.exist: |
136 | 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 | 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 | 141 | del self.image |
142 | 142 | del self.imagedata |
... | ... | @@ -155,19 +155,19 @@ class Volume(): |
155 | 155 | self.color_transfer = None |
156 | 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 | 160 | #self.LoadConfig(label) |
161 | 161 | self.LoadVolume() |
162 | 162 | |
163 | - def OnHideVolume(self, pubsub_evt): | |
163 | + def OnHideVolume(self): | |
164 | 164 | print('Hide Volume') |
165 | 165 | self.volume.SetVisibility(0) |
166 | 166 | if (self.plane and self.plane_on): |
167 | 167 | self.plane.Disable() |
168 | 168 | Publisher.sendMessage('Render volume viewer') |
169 | 169 | |
170 | - def OnShowVolume(self, pubsub_evt = None): | |
170 | + def OnShowVolume(self): | |
171 | 171 | print('Show volume') |
172 | 172 | if self.exist: |
173 | 173 | print('Volume exists') |
... | ... | @@ -177,18 +177,19 @@ class Volume(): |
177 | 177 | Publisher.sendMessage('Render volume viewer') |
178 | 178 | else: |
179 | 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 | 182 | self.LoadConfig() |
182 | 183 | self.LoadVolume() |
183 | 184 | self.exist = 1 |
184 | 185 | |
185 | - def OnUpdatePreset(self, pubsub_evt): | |
186 | + def OnUpdatePreset(self): | |
186 | 187 | self.__load_preset_config() |
187 | 188 | |
188 | 189 | if self.config: |
189 | 190 | if self.to_reload: |
190 | 191 | self.exist = False |
191 | - Publisher.sendMessage('Unload volume', self.volume) | |
192 | + Publisher.sendMessage('Unload volume', volume=self.volume) | |
192 | 193 | |
193 | 194 | if self.exist: |
194 | 195 | self.__load_preset() |
... | ... | @@ -200,10 +201,10 @@ class Volume(): |
200 | 201 | self.exist = 1 |
201 | 202 | |
202 | 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 | 206 | else: |
206 | - Publisher.sendMessage('Unload volume', self.volume) | |
207 | + Publisher.sendMessage('Unload volume', volume=self.volume) | |
207 | 208 | del self.image |
208 | 209 | del self.imagedata |
209 | 210 | del self.final_imagedata |
... | ... | @@ -221,7 +222,7 @@ class Volume(): |
221 | 222 | self.color_transfer = None |
222 | 223 | Publisher.sendMessage('Render volume viewer') |
223 | 224 | |
224 | - def OnFlipVolume(self, pubsub_evt): | |
225 | + def OnFlipVolume(self, axis): | |
225 | 226 | print("Flipping Volume") |
226 | 227 | self.loaded_image = False |
227 | 228 | del self.image |
... | ... | @@ -252,28 +253,24 @@ class Volume(): |
252 | 253 | self.SetShading() |
253 | 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 | 258 | self.CalculateWWWL() |
258 | 259 | ww = self.ww |
259 | 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 | 264 | ww = self.ww + diff_ww |
266 | 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 | 267 | self.SetWWWL(ww, wl) |
270 | 268 | self.ww = ww |
271 | 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 | 275 | def SetWWWL(self, ww, wl): |
279 | 276 | if self.config['advancedCLUT']: |
... | ... | @@ -321,7 +318,7 @@ class Volume(): |
321 | 318 | self.ww = last_point - first_point |
322 | 319 | self.wl = first_point + self.ww / 2.0 |
323 | 320 | |
324 | - def Refresh(self, pubsub_evt): | |
321 | + def Refresh(self): | |
325 | 322 | self.__update_colour_table() |
326 | 323 | |
327 | 324 | def Create16bColorTable(self, scale): |
... | ... | @@ -445,11 +442,11 @@ class Volume(): |
445 | 442 | self.config['backgroundColorBlueComponent']) |
446 | 443 | return colour |
447 | 444 | |
448 | - def ChangeBackgroundColour(self, pubsub_evt): | |
445 | + def ChangeBackgroundColour(self, colour): | |
449 | 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 | 451 | def BuildTable(): |
455 | 452 | curve_table = p['16bitClutCurves'] |
... | ... | @@ -663,16 +660,16 @@ class Volume(): |
663 | 660 | self.plane.SetVolumeMapper(volume_mapper) |
664 | 661 | |
665 | 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 | 666 | del flip |
669 | 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 | 670 | if tool_name == _("Cut plane"): |
674 | 671 | if self.plane: |
675 | - if enable: | |
672 | + if flag: | |
676 | 673 | self.plane_on = True |
677 | 674 | self.plane.Enable() |
678 | 675 | else: |
... | ... | @@ -695,8 +692,10 @@ class Volume(): |
695 | 692 | accumulate.Update() |
696 | 693 | n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars()) |
697 | 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 | 700 | def TranslateScale(self, scale, value): |
702 | 701 | #if value < 0: |
... | ... | @@ -747,8 +746,8 @@ class CutPlane: |
747 | 746 | plane_actor.GetProperty().BackfaceCullingOn() |
748 | 747 | plane_actor.GetProperty().SetOpacity(0) |
749 | 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 | 751 | plane_actor.SetVisibility(1) |
753 | 752 | plane_widget.On() |
754 | 753 | self.plane = plane = vtk.vtkPlane() |
... | ... | @@ -775,21 +774,21 @@ class CutPlane: |
775 | 774 | self.plane_actor.VisibilityOn() |
776 | 775 | self.plane.SetNormal(plane_source.GetNormal()) |
777 | 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 | 780 | self.plane_widget.On() |
782 | 781 | self.plane_actor.VisibilityOn() |
783 | 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 | 786 | self.plane_widget.Off() |
788 | 787 | self.plane_actor.VisibilityOff() |
789 | 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 | 792 | plane_source = self.plane_source |
794 | 793 | plane_widget = self.plane_widget |
795 | 794 | plane_source.SetOrigin(self.origin) |
... | ... | @@ -799,10 +798,10 @@ class CutPlane: |
799 | 798 | self.plane_actor.VisibilityOn() |
800 | 799 | self.plane.SetNormal(self.normal) |
801 | 800 | self.plane.SetOrigin(self.origin) |
802 | - Publisher.sendMessage('Render volume viewer', None) | |
801 | + Publisher.sendMessage('Render volume viewer') | |
803 | 802 | |
804 | 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 | 805 | self.Disable() |
807 | 806 | del self.plane_widget |
808 | 807 | del self.plane_source | ... | ... |
invesalius/data/vtk_utils.py
... | ... | @@ -81,8 +81,7 @@ def ShowProgress(number_of_filters = 1, |
81 | 81 | progress[0] = progress[0] + ratio*difference |
82 | 82 | # Tell GUI to update progress status value |
83 | 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 | 85 | else: |
87 | 86 | if (progress[0] >= 99.999): |
88 | 87 | progress[0] = 100 | ... | ... |
invesalius/gui/bitmap_preview_panel.py
... | ... | @@ -249,7 +249,7 @@ class Preview(wx.Panel): |
249 | 249 | my_evt.SetEventObject(self) |
250 | 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 | 254 | evt.Skip() |
255 | 255 | |
... | ... | @@ -369,15 +369,14 @@ class BitmapPreviewSeries(wx.Panel): |
369 | 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 | 373 | for p, f in zip(self.previews, self.files): |
375 | 374 | if p.bitmap_info != None: |
376 | 375 | if data.encode('utf-8') in p.bitmap_info.data: |
377 | 376 | self.files.remove(f) |
378 | 377 | p.Hide() |
379 | 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 | 381 | self.Update() |
383 | 382 | self.Layout() |
... | ... | @@ -539,8 +538,7 @@ class SingleImagePreview(wx.Panel): |
539 | 538 | Publisher.subscribe(self.UpdateMaxValueSliderBar, 'Update max of slidebar in single preview image') |
540 | 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 | 542 | if pos != None: |
545 | 543 | self.ShowSlice(int(pos)) |
546 | 544 | |
... | ... | @@ -584,8 +582,8 @@ class SingleImagePreview(wx.Panel): |
584 | 582 | self.slider.SetValue(0) |
585 | 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 | 587 | self.slider.Refresh() |
590 | 588 | self.slider.Update() |
591 | 589 | ... | ... |
invesalius/gui/data_notebook.py
... | ... | @@ -98,20 +98,20 @@ class NotebookPanel(wx.Panel): |
98 | 98 | 'Fold mask page') |
99 | 99 | |
100 | 100 | |
101 | - def _FoldSurface(self, pubusb_evt): | |
101 | + def _FoldSurface(self): | |
102 | 102 | """ |
103 | 103 | Fold surface notebook page. |
104 | 104 | """ |
105 | 105 | self.book.SetSelection(1) |
106 | 106 | |
107 | - def _FoldMeasure(self, pubsub_evt): | |
107 | + def _FoldMeasure(self): | |
108 | 108 | """ |
109 | 109 | Fold measure notebook page. |
110 | 110 | """ |
111 | 111 | self.book.SetSelection(2) |
112 | 112 | |
113 | 113 | |
114 | - def _FoldMask(self, pubsub_evt): | |
114 | + def _FoldMask(self): | |
115 | 115 | """ |
116 | 116 | Fold mask notebook page. |
117 | 117 | """ |
... | ... | @@ -334,7 +334,8 @@ class ButtonControlPanel(wx.Panel): |
334 | 334 | mask_name, thresh, colour = dialog.GetValue() |
335 | 335 | if mask_name: |
336 | 336 | Publisher.sendMessage('Create new mask', |
337 | - (mask_name, thresh, colour)) | |
337 | + mask_name=mask_name, | |
338 | + thresh=thresh, colour=colour) | |
338 | 339 | dialog.Destroy() |
339 | 340 | |
340 | 341 | def OnRemove(self): |
... | ... | @@ -343,7 +344,7 @@ class ButtonControlPanel(wx.Panel): |
343 | 344 | def OnDuplicate(self): |
344 | 345 | selected_items = self.parent.listctrl.GetSelected() |
345 | 346 | if selected_items: |
346 | - Publisher.sendMessage('Duplicate masks', selected_items) | |
347 | + Publisher.sendMessage('Duplicate masks', mask_indexes=selected_items) | |
347 | 348 | else: |
348 | 349 | dlg.MaskSelectionRequiredForDuplication() |
349 | 350 | |
... | ... | @@ -398,7 +399,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
398 | 399 | selected_items = self.GetSelected() |
399 | 400 | |
400 | 401 | if selected_items: |
401 | - Publisher.sendMessage('Remove masks', selected_items) | |
402 | + Publisher.sendMessage('Remove masks', mask_indexes=selected_items) | |
402 | 403 | else: |
403 | 404 | dlg.MaskSelectionRequiredForRemoval() |
404 | 405 | return |
... | ... | @@ -421,8 +422,8 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
421 | 422 | if new_dict: |
422 | 423 | if index == self.current_index: |
423 | 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 | 427 | Publisher.sendMessage('Refresh viewer') |
427 | 428 | for key in new_dict: |
428 | 429 | if key: |
... | ... | @@ -433,27 +434,26 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
433 | 434 | self.SetItemImage(self.current_index, 1) |
434 | 435 | |
435 | 436 | |
436 | - def OnCloseProject(self, pubsub_evt): | |
437 | + def OnCloseProject(self): | |
437 | 438 | self.DeleteAllItems() |
438 | 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 | 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 | 445 | except wx._core.PyAssertionError: |
446 | 446 | #in SetItem(): invalid item index in SetItem |
447 | 447 | pass |
448 | 448 | for key in self.mask_list_index.keys(): |
449 | - if key != mask_index: | |
449 | + if key != index: | |
450 | 450 | self.SetItemImage(key, 0) |
451 | 451 | |
452 | - def __hide_current_mask(self, pubsub_evt): | |
452 | + def __hide_current_mask(self): | |
453 | 453 | if self.mask_list_index: |
454 | 454 | self.SetItemImage(self.current_index, 0) |
455 | 455 | |
456 | - def __show_current_mask(self, pubsub_evt): | |
456 | + def __show_current_mask(self): | |
457 | 457 | if self.mask_list_index: |
458 | 458 | self.SetItemImage(self.current_index, 1) |
459 | 459 | |
... | ... | @@ -488,7 +488,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
488 | 488 | |
489 | 489 | def OnEditLabel(self, evt): |
490 | 490 | Publisher.sendMessage('Change mask name', |
491 | - (evt.GetIndex(), evt.GetLabel())) | |
491 | + index=evt.GetIndex(), name=evt.GetLabel()) | |
492 | 492 | evt.Skip() |
493 | 493 | |
494 | 494 | def OnItemActivated(self, evt): |
... | ... | @@ -499,9 +499,9 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
499 | 499 | for key in self.mask_list_index.keys(): |
500 | 500 | if key != index: |
501 | 501 | self.SetItemImage(key, 0) |
502 | - Publisher.sendMessage('Change mask selected',index) | |
502 | + Publisher.sendMessage('Change mask selected', index=index) | |
503 | 503 | self.current_index = index |
504 | - Publisher.sendMessage('Show mask', (index, flag)) | |
504 | + Publisher.sendMessage('Show mask', index=index, value=flag) | |
505 | 505 | |
506 | 506 | def CreateColourBitmap(self, colour): |
507 | 507 | """ |
... | ... | @@ -536,19 +536,16 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
536 | 536 | # self.SetItemImage(key, 0) |
537 | 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 | 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 | 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 | 549 | image = self.CreateColourBitmap(colour) |
553 | 550 | image_index = self.mask_list_index[index] |
554 | 551 | self.imagelist.Replace(image_index, image) |
... | ... | @@ -678,7 +675,8 @@ class SurfaceButtonControlPanel(wx.Panel): |
678 | 675 | if ok: |
679 | 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 | 680 | dialog.Destroy() |
683 | 681 | |
684 | 682 | def OnRemove(self): |
... | ... | @@ -688,14 +686,14 @@ class SurfaceButtonControlPanel(wx.Panel): |
688 | 686 | def OnDuplicate(self): |
689 | 687 | selected_items = self.parent.listctrl.GetSelected() |
690 | 688 | if selected_items: |
691 | - Publisher.sendMessage('Duplicate surfaces', selected_items) | |
689 | + Publisher.sendMessage('Duplicate surfaces', surface_indexes=selected_items) | |
692 | 690 | else: |
693 | 691 | dlg.SurfaceSelectionRequiredForDuplication() |
694 | 692 | |
695 | 693 | def OnOpenMesh(self): |
696 | 694 | filename = dlg.ShowImportMeshFilesDialog() |
697 | 695 | if filename: |
698 | - Publisher.sendMessage('Import surface file', filename) | |
696 | + Publisher.sendMessage('Import surface file', filename=filename) | |
699 | 697 | |
700 | 698 | |
701 | 699 | class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
... | ... | @@ -744,8 +742,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
744 | 742 | elif (keycode == wx.WXK_DELETE): |
745 | 743 | self.RemoveSurfaces() |
746 | 744 | |
747 | - def OnHideSurface(self, pubsub_evt): | |
748 | - surface_dict = pubsub_evt.data | |
745 | + def OnHideSurface(self, surface_dict): | |
749 | 746 | for key in surface_dict: |
750 | 747 | if not surface_dict[key].is_shown: |
751 | 748 | self.SetItemImage(key, False) |
... | ... | @@ -770,11 +767,11 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
770 | 767 | old_dict = new_dict |
771 | 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 | 771 | else: |
775 | 772 | dlg.SurfaceSelectionRequiredForRemoval() |
776 | 773 | |
777 | - def OnCloseProject(self, pubsub_evt): | |
774 | + def OnCloseProject(self): | |
778 | 775 | self.DeleteAllItems() |
779 | 776 | self.surface_list_index = {} |
780 | 777 | self.surface_bmp_idx_to_name = {} |
... | ... | @@ -786,7 +783,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
786 | 783 | |
787 | 784 | last_surface_index = evt.Index |
788 | 785 | Publisher.sendMessage('Change surface selected', |
789 | - last_surface_index) | |
786 | + surface_index=last_surface_index) | |
790 | 787 | evt.Skip() |
791 | 788 | |
792 | 789 | def GetSelected(self): |
... | ... | @@ -837,7 +834,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
837 | 834 | self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) |
838 | 835 | |
839 | 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 | 838 | evt.Skip() |
842 | 839 | |
843 | 840 | def OnItemActivated(self, evt): |
... | ... | @@ -845,38 +842,36 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
845 | 842 | evt.Skip() |
846 | 843 | |
847 | 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 | 848 | for key in self.surface_list_index.keys(): |
853 | 849 | if key != index: |
854 | 850 | self.SetItemImage(key, not visibility) |
855 | 851 | Publisher.sendMessage('Show surface', |
856 | - (key, not visibility)) | |
852 | + index=key, visibility=not visibility) | |
857 | 853 | self.SetItemImage(index, visibility) |
858 | 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 | 858 | for key in self.surface_list_index.keys(): |
864 | 859 | if key not in index_list: |
865 | 860 | self.SetItemImage(key, not visibility) |
866 | 861 | Publisher.sendMessage('Show surface', |
867 | - (key, not visibility)) | |
862 | + index=key, visibility=not visibility) | |
868 | 863 | for index in index_list: |
869 | 864 | self.SetItemImage(index, visibility) |
870 | 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 | 876 | if index not in self.surface_list_index: |
882 | 877 | image = self.CreateColourBitmap(colour) |
... | ... | @@ -941,20 +936,18 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
941 | 936 | |
942 | 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 | 941 | Set actor transparency (oposite to opacity) according to given actor |
947 | 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 | 949 | image = self.CreateColourBitmap(colour) |
957 | - image_index = self.surface_list_index[index] | |
950 | + image_index = self.surface_list_index[surface_index] | |
958 | 951 | self.imagelist.Replace(image_index, image) |
959 | 952 | self.Refresh() |
960 | 953 | |
... | ... | @@ -1007,15 +1000,14 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1007 | 1000 | elif (keycode == wx.WXK_DELETE): |
1008 | 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 | 1006 | old_dict = self._list_index |
1015 | 1007 | new_dict = {} |
1016 | 1008 | j = 0 |
1017 | 1009 | for i in old_dict: |
1018 | - if i != idx: | |
1010 | + if i != measure_index: | |
1019 | 1011 | new_dict[j] = old_dict[i] |
1020 | 1012 | j+=1 |
1021 | 1013 | self._list_index = new_dict |
... | ... | @@ -1041,12 +1033,12 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1041 | 1033 | new_dict[i-1] = old_dict[i] |
1042 | 1034 | old_dict = new_dict |
1043 | 1035 | self._list_index = new_dict |
1044 | - Publisher.sendMessage('Remove measurements', selected_items) | |
1036 | + Publisher.sendMessage('Remove measurements', indexes=selected_items) | |
1045 | 1037 | else: |
1046 | 1038 | dlg.MeasureSelectionRequiredForRemoval() |
1047 | 1039 | |
1048 | 1040 | |
1049 | - def OnCloseProject(self, pubsub_evt): | |
1041 | + def OnCloseProject(self): | |
1050 | 1042 | self.DeleteAllItems() |
1051 | 1043 | self._list_index = {} |
1052 | 1044 | self._bmp_idx_to_name = {} |
... | ... | @@ -1057,8 +1049,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1057 | 1049 | # things will stop working, e.g.: OnCheckItem |
1058 | 1050 | |
1059 | 1051 | last_index = evt.Index |
1060 | - Publisher.sendMessage('Change measurement selected', | |
1061 | - last_index) | |
1052 | + # Publisher.sendMessage('Change measurement selected', | |
1053 | + # last_index) | |
1062 | 1054 | evt.Skip() |
1063 | 1055 | |
1064 | 1056 | def GetSelected(self): |
... | ... | @@ -1110,7 +1102,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1110 | 1102 | |
1111 | 1103 | |
1112 | 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 | 1106 | evt.Skip() |
1115 | 1107 | |
1116 | 1108 | def OnItemActivated(self, evt): |
... | ... | @@ -1119,38 +1111,32 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1119 | 1111 | |
1120 | 1112 | |
1121 | 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 | 1117 | for key in self._list_index.keys(): |
1127 | 1118 | if key != index: |
1128 | 1119 | self.SetItemImage(key, not visibility) |
1129 | 1120 | Publisher.sendMessage('Show measurement', |
1130 | - (key, not visibility)) | |
1121 | + index=key, visibility=not visibility) | |
1131 | 1122 | self.SetItemImage(index, visibility) |
1132 | 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 | 1127 | for key in self._list_index.keys(): |
1138 | 1128 | if key not in index_list: |
1139 | 1129 | self.SetItemImage(key, not visibility) |
1140 | 1130 | Publisher.sendMessage('Show measurement', |
1141 | - (key, not visibility)) | |
1131 | + index=key, visibility=not visibility) | |
1142 | 1132 | for index in index_list: |
1143 | 1133 | self.SetItemImage(index, visibility) |
1144 | 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 | 1140 | image = self.CreateColourBitmap(m.colour) |
1155 | 1141 | image_index = self.imagelist.Add(image) |
1156 | 1142 | |
... | ... | @@ -1169,14 +1155,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1169 | 1155 | if not m.visible: |
1170 | 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 | 1159 | if index not in self._list_index: |
1181 | 1160 | image = self.CreateColourBitmap(colour) |
1182 | 1161 | image_index = self.imagelist.Add(image) |
... | ... | @@ -1241,12 +1220,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1241 | 1220 | wx_image.SetData(new_image.tobytes()) |
1242 | 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 | 1226 | image = self.CreateColourBitmap(colour) |
1249 | - image_index = self._list_index[index] | |
1227 | + image_index = self._list_index[measure_index] | |
1250 | 1228 | self.imagelist.Replace(image_index, image) |
1251 | 1229 | self.Refresh() |
1252 | 1230 | ... | ... |
invesalius/gui/default_tasks.py
... | ... | @@ -204,8 +204,7 @@ class LowerTaskPanel(wx.Panel): |
204 | 204 | def __bind_events(self): |
205 | 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 | 208 | if state: |
210 | 209 | self.SetStateProjectOpen() |
211 | 210 | else: |
... | ... | @@ -305,25 +304,24 @@ class UpperTaskPanel(wx.Panel): |
305 | 304 | Publisher.subscribe(self.OnFoldExport, 'Fold export task') |
306 | 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 | 311 | if not self.overwrite: |
313 | 312 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(2)) |
314 | 313 | |
315 | - def OnFoldExport(self, pubsub_evt): | |
314 | + def OnFoldExport(self): | |
316 | 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 | 318 | if state: |
321 | 319 | self.SetStateProjectOpen() |
322 | 320 | else: |
323 | 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 | 325 | name = _("Navigation system") |
328 | 326 | panel = navigator.TaskPanel |
329 | 327 | if status and (self.fold_panel.GetCount()<=4): | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -130,11 +130,11 @@ class Panel(wx.Panel): |
130 | 130 | |
131 | 131 | def OnMaximize(self, evt): |
132 | 132 | if evt.GetPane().name == self.s4.name: |
133 | - Publisher.sendMessage('Show raycasting widget', None) | |
133 | + Publisher.sendMessage('Show raycasting widget') | |
134 | 134 | |
135 | 135 | def OnRestore(self, evt): |
136 | 136 | if evt.GetPane().name == self.s4.name: |
137 | - Publisher.sendMessage('Hide raycasting widget', None) | |
137 | + Publisher.sendMessage('Hide raycasting widget') | |
138 | 138 | |
139 | 139 | def __init_four_way_splitter(self): |
140 | 140 | |
... | ... | @@ -156,7 +156,7 @@ class Panel(wx.Panel): |
156 | 156 | p4 = volume_viewer.Viewer(self) |
157 | 157 | splitter.AppendWindow(p4) |
158 | 158 | |
159 | - def _Exit(self, pubsub_evt): | |
159 | + def _Exit(self): | |
160 | 160 | self.aui_manager.UnInit() |
161 | 161 | |
162 | 162 | def __init_mix(self): |
... | ... | @@ -256,28 +256,28 @@ class VolumeInteraction(wx.Panel): |
256 | 256 | |
257 | 257 | def __update_curve_wwwl_text(self, curve): |
258 | 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 | 262 | self.can_show_raycasting_widget = 1 |
263 | 263 | if self.clut_raycasting.to_draw_points: |
264 | 264 | p = self.aui_manager.GetPane(self.clut_raycasting) |
265 | 265 | p.Show() |
266 | 266 | self.aui_manager.Update() |
267 | 267 | |
268 | - def HideRaycastingWidget(self, evt_pubsub=None): | |
268 | + def HideRaycastingWidget(self): | |
269 | 269 | self.can_show_raycasting_widget = 0 |
270 | 270 | p = self.aui_manager.GetPane(self.clut_raycasting) |
271 | 271 | p.Hide() |
272 | 272 | self.aui_manager.Update() |
273 | 273 | |
274 | 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 | 277 | Publisher.sendMessage('Render volume viewer') |
278 | 278 | |
279 | 279 | def OnCurveSelected(self, evt): |
280 | - Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | |
280 | + Publisher.sendMessage('Set raycasting curve', curve=evt.GetCurve()) | |
281 | 281 | Publisher.sendMessage('Render volume viewer') |
282 | 282 | |
283 | 283 | def OnChangeCurveWL(self, evt): |
... | ... | @@ -285,7 +285,7 @@ class VolumeInteraction(wx.Panel): |
285 | 285 | self.__update_curve_wwwl_text(curve) |
286 | 286 | Publisher.sendMessage('Render volume viewer') |
287 | 287 | |
288 | - def OnSetRaycastPreset(self, evt_pubsub): | |
288 | + def OnSetRaycastPreset(self): | |
289 | 289 | preset = project.Project().raycasting_preset |
290 | 290 | p = self.aui_manager.GetPane(self.clut_raycasting) |
291 | 291 | self.clut_raycasting.SetRaycastPreset(preset) |
... | ... | @@ -296,17 +296,15 @@ class VolumeInteraction(wx.Panel): |
296 | 296 | p.Hide() |
297 | 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 | 300 | self.clut_raycasting.SetRange((init, end)) |
303 | 301 | self.clut_raycasting.SetHistogramArray(histogram, (init, end)) |
304 | 302 | |
305 | - def RefreshPoints(self, pubsub_evt): | |
303 | + def RefreshPoints(self): | |
306 | 304 | self.clut_raycasting.CalculatePixelPoints() |
307 | 305 | self.clut_raycasting.Refresh() |
308 | 306 | |
309 | - def _Exit(self, pubsub_evt): | |
307 | + def _Exit(self): | |
310 | 308 | self.aui_manager.UnInit() |
311 | 309 | |
312 | 310 | |
... | ... | @@ -434,7 +432,7 @@ class VolumeToolPanel(wx.Panel): |
434 | 432 | Publisher.subscribe(self.StatusTargetSelect, 'Disable or enable coil tracker') |
435 | 433 | Publisher.subscribe(self.StatusObjTracker, 'Status target button') |
436 | 434 | |
437 | - def DisablePreset(self, pubsub_evt): | |
435 | + def DisablePreset(self): | |
438 | 436 | self.off_item.Check(1) |
439 | 437 | |
440 | 438 | |
... | ... | @@ -459,12 +457,12 @@ class VolumeToolPanel(wx.Panel): |
459 | 457 | def OnButtonSlicePlane(self, evt): |
460 | 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 | 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 | 466 | self.StatusNavigation() |
469 | 467 | |
470 | 468 | def StatusNavigation(self): |
... | ... | @@ -477,19 +475,18 @@ class VolumeToolPanel(wx.Panel): |
477 | 475 | def OnButtonTarget(self, evt): |
478 | 476 | if not self.button_target.IsPressed() and evt is not False: |
479 | 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 | 479 | elif self.button_target.IsPressed() or evt is False: |
482 | 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 | 483 | def OnSavePreset(self, evt): |
486 | 484 | d = wx.TextEntryDialog(self, _("Preset name")) |
487 | 485 | if d.ShowModal() == wx.ID_OK: |
488 | 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 | 490 | # MENU RELATED TO RAYCASTING TYPES |
494 | 491 | menu = self.menu = wx.Menu() |
495 | 492 | #print "\n\n" |
... | ... | @@ -576,7 +573,7 @@ class VolumeToolPanel(wx.Panel): |
576 | 573 | self.Fit() |
577 | 574 | self.Update() |
578 | 575 | |
579 | - def DisableVolumeCutMenu(self, pusub_evt): | |
576 | + def DisableVolumeCutMenu(self): | |
580 | 577 | self.menu.Enable(RAYCASTING_TOOLS, 0) |
581 | 578 | item = ID_TO_TOOL_ITEM[self.id_cutplane] |
582 | 579 | item.Check(0) |
... | ... | @@ -596,23 +593,23 @@ class VolumeToolPanel(wx.Panel): |
596 | 593 | label = item.GetLabel() |
597 | 594 | |
598 | 595 | if not (checked): |
599 | - Publisher.sendMessage('Disable plane', label) | |
596 | + Publisher.sendMessage('Disable plane', plane_label=label) | |
600 | 597 | else: |
601 | - Publisher.sendMessage('Enable plane', label) | |
598 | + Publisher.sendMessage('Enable plane', plane_label=label) | |
602 | 599 | |
603 | 600 | def OnMenuStereo(self, evt): |
604 | 601 | id = evt.GetId() |
605 | 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 | 607 | for item in self.slice_plane_menu.GetMenuItems(): |
611 | 608 | if (item.IsChecked()): |
612 | 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 | 613 | self.button_colour.SetColour(colour) |
617 | 614 | |
618 | 615 | def OnMenuRaycasting(self, evt): |
... | ... | @@ -622,7 +619,7 @@ class VolumeToolPanel(wx.Panel): |
622 | 619 | # Raycassting type was selected |
623 | 620 | name = ID_TO_NAME[id] |
624 | 621 | Publisher.sendMessage('Load raycasting preset', |
625 | - ID_TO_NAME[id]) | |
622 | + preset_name=ID_TO_NAME[id]) | |
626 | 623 | # Enable or disable tools |
627 | 624 | if name != const.RAYCASTING_OFF_LABEL: |
628 | 625 | self.menu_raycasting.Enable(RAYCASTING_TOOLS, 1) |
... | ... | @@ -639,12 +636,12 @@ class VolumeToolPanel(wx.Panel): |
639 | 636 | # i.Check(0) |
640 | 637 | if not TOOL_STATE[id]: |
641 | 638 | Publisher.sendMessage('Enable raycasting tool', |
642 | - [ID_TO_TOOL[id],1]) | |
639 | + tool_name=ID_TO_TOOL[id], flag=1) | |
643 | 640 | TOOL_STATE[id] = True |
644 | 641 | item.Check(1) |
645 | 642 | else: |
646 | 643 | Publisher.sendMessage('Enable raycasting tool', |
647 | - [ID_TO_TOOL[id],0]) | |
644 | + tool_name=ID_TO_TOOL[id], flag=0) | |
648 | 645 | TOOL_STATE[id] = False |
649 | 646 | item.Check(0) |
650 | 647 | |
... | ... | @@ -655,10 +652,10 @@ class VolumeToolPanel(wx.Panel): |
655 | 652 | self.button_view.SetBitmapSelected(bmp) |
656 | 653 | |
657 | 654 | Publisher.sendMessage('Set volume view angle', |
658 | - evt.GetId()) | |
655 | + view=evt.GetId()) | |
659 | 656 | self.Refresh() |
660 | 657 | |
661 | 658 | def OnSelectColour(self, evt): |
662 | 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 | 726 | self.Close() |
727 | 727 | self.Destroy() |
728 | 728 | |
729 | - def _OnCloseInV(self, pubsub_evt): | |
729 | + def _OnCloseInV(self): | |
730 | 730 | # Closes and destroy this dialog. |
731 | 731 | self.Close() |
732 | 732 | self.Destroy() |
... | ... | @@ -1880,12 +1880,12 @@ class ClutImagedataDialog(wx.Dialog): |
1880 | 1880 | |
1881 | 1881 | def OnClutChange(self, evt): |
1882 | 1882 | Publisher.sendMessage('Change colour table from background image from widget', |
1883 | - evt.GetNodes()) | |
1883 | + nodes=evt.GetNodes()) | |
1884 | 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 | 1889 | self.clut_widget.Refresh() |
1890 | 1890 | |
1891 | 1891 | def Show(self, gen_evt=True, show=True): |
... | ... | @@ -2068,7 +2068,8 @@ class MaskBooleanDialog(wx.Dialog): |
2068 | 2068 | m1 = self.mask1.GetClientData(self.mask1.GetSelection()) |
2069 | 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 | 2073 | Publisher.sendMessage('Reload actual slice') |
2073 | 2074 | Publisher.sendMessage('Refresh viewer') |
2074 | 2075 | |
... | ... | @@ -2152,13 +2153,13 @@ class ReorientImageDialog(wx.Dialog): |
2152 | 2153 | self.btnapply.Bind(wx.EVT_BUTTON, self.apply_reorientation) |
2153 | 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 | 2158 | self.anglex.SetValue("%.3f" % np.rad2deg(anglex)) |
2158 | 2159 | self.angley.SetValue("%.3f" % np.rad2deg(angley)) |
2159 | 2160 | self.anglez.SetValue("%.3f" % np.rad2deg(anglez)) |
2160 | 2161 | |
2161 | - def _close_dialog(self, pubsub_evt): | |
2162 | + def _close_dialog(self): | |
2162 | 2163 | self.Destroy() |
2163 | 2164 | |
2164 | 2165 | def apply_reorientation(self, evt): |
... | ... | @@ -2167,13 +2168,13 @@ class ReorientImageDialog(wx.Dialog): |
2167 | 2168 | |
2168 | 2169 | def OnClose(self, evt): |
2169 | 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 | 2173 | self.Destroy() |
2173 | 2174 | |
2174 | 2175 | def OnSelect(self, evt): |
2175 | 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 | 2179 | def OnSetFocus(self, evt): |
2179 | 2180 | self._last_ax = self.anglex.GetValue() |
... | ... | @@ -2191,7 +2192,7 @@ class ReorientImageDialog(wx.Dialog): |
2191 | 2192 | self.angley.SetValue(self._last_ay) |
2192 | 2193 | self.anglez.SetValue(self._last_az) |
2193 | 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 | 2198 | class ImportBitmapParameters(wx.Dialog): |
... | ... | @@ -2350,7 +2351,7 @@ class ImportBitmapParameters(wx.Dialog): |
2350 | 2351 | values = [self.tx_name.GetValue(), orientation,\ |
2351 | 2352 | self.fsp_spacing_x.GetValue(), self.fsp_spacing_y.GetValue(),\ |
2352 | 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 | 2356 | self.Close() |
2356 | 2357 | self.Destroy() |
... | ... | @@ -2759,7 +2760,7 @@ class FFillOptionsDialog(wx.Dialog): |
2759 | 2760 | def OnClose(self, evt): |
2760 | 2761 | print("ONCLOSE") |
2761 | 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 | 2764 | evt.Skip() |
2764 | 2765 | self.Destroy() |
2765 | 2766 | |
... | ... | @@ -2845,7 +2846,7 @@ class SelectPartsOptionsDialog(wx.Dialog): |
2845 | 2846 | |
2846 | 2847 | def OnClose(self, evt): |
2847 | 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 | 2850 | evt.Skip() |
2850 | 2851 | self.Destroy() |
2851 | 2852 | |
... | ... | @@ -3048,7 +3049,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
3048 | 3049 | |
3049 | 3050 | def OnClose(self, evt): |
3050 | 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 | 3053 | evt.Skip() |
3053 | 3054 | self.Destroy() |
3054 | 3055 | |
... | ... | @@ -3068,14 +3069,8 @@ class CropOptionsDialog(wx.Dialog): |
3068 | 3069 | |
3069 | 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 | 3075 | self.tx_axial_i.SetValue(str(zi)) |
3081 | 3076 | self.tx_axial_f.SetValue(str(zf)) |
... | ... | @@ -3170,12 +3165,12 @@ class CropOptionsDialog(wx.Dialog): |
3170 | 3165 | def OnOk(self, evt): |
3171 | 3166 | self.config.dlg_visible = False |
3172 | 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 | 3169 | evt.Skip() |
3175 | 3170 | |
3176 | 3171 | def OnClose(self, evt): |
3177 | 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 | 3174 | evt.Skip() |
3180 | 3175 | self.Destroy() |
3181 | 3176 | |
... | ... | @@ -3260,14 +3255,14 @@ class FillHolesAutoDialog(wx.Dialog): |
3260 | 3255 | conn = self.panel3dcon.GetConnSelected() |
3261 | 3256 | orientation = 'VOLUME' |
3262 | 3257 | |
3263 | - data = { | |
3258 | + parameters = { | |
3264 | 3259 | 'target': target, |
3265 | 3260 | 'conn': conn, |
3266 | 3261 | 'orientation': orientation, |
3267 | 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 | 3268 | def OnBtnClose(self, evt): | ... | ... |
invesalius/gui/dicom_preview_panel.py
... | ... | @@ -686,8 +686,8 @@ class DicomPreviewSlice(wx.Panel): |
686 | 686 | self.selected_dicom = self.selected_panel.dicom_info |
687 | 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 | 692 | def OnScroll(self, evt=None): |
693 | 693 | if evt: | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -248,14 +248,14 @@ class Frame(wx.Frame): |
248 | 248 | # TODO: Allow saving and restoring perspectives |
249 | 249 | self.perspective_all = aui_manager.SavePerspective() |
250 | 250 | |
251 | - def _BeginBusyCursor(self, pubsub_evt): | |
251 | + def _BeginBusyCursor(self): | |
252 | 252 | """ |
253 | 253 | Start busy cursor. |
254 | 254 | Note: _EndBusyCursor should be called after. |
255 | 255 | """ |
256 | 256 | wx.BeginBusyCursor() |
257 | 257 | |
258 | - def _EndBusyCursor(self, pubsub_evt): | |
258 | + def _EndBusyCursor(self): | |
259 | 259 | """ |
260 | 260 | End busy cursor. |
261 | 261 | Note: _BeginBusyCursor should have been called previously. |
... | ... | @@ -266,7 +266,7 @@ class Frame(wx.Frame): |
266 | 266 | #no matching wxBeginBusyCursor() for wxEndBusyCursor() |
267 | 267 | pass |
268 | 268 | |
269 | - def _Exit(self, pubsub_evt): | |
269 | + def _Exit(self): | |
270 | 270 | """ |
271 | 271 | Exit InVesalius. |
272 | 272 | """ |
... | ... | @@ -275,7 +275,7 @@ class Frame(wx.Frame): |
275 | 275 | if hasattr(sys,"frozen") and sys.platform == 'darwin': |
276 | 276 | sys.exit(0) |
277 | 277 | |
278 | - def _HideContentPanel(self, pubsub_evt): | |
278 | + def _HideContentPanel(self): | |
279 | 279 | """ |
280 | 280 | Hide data and tasks panels. |
281 | 281 | """ |
... | ... | @@ -284,7 +284,7 @@ class Frame(wx.Frame): |
284 | 284 | aui_manager.GetPane("Tasks").Show(1) |
285 | 285 | aui_manager.Update() |
286 | 286 | |
287 | - def _HideImportPanel(self, evt_pubsub): | |
287 | + def _HideImportPanel(self): | |
288 | 288 | """ |
289 | 289 | Hide import panel and show tasks. |
290 | 290 | """ |
... | ... | @@ -294,39 +294,37 @@ class Frame(wx.Frame): |
294 | 294 | aui_manager.GetPane("Tasks").Show(1) |
295 | 295 | aui_manager.Update() |
296 | 296 | |
297 | - def _HideTask(self, pubsub_evt): | |
297 | + def _HideTask(self): | |
298 | 298 | """ |
299 | 299 | Hide task panel. |
300 | 300 | """ |
301 | 301 | self.aui_manager.GetPane("Tasks").Hide() |
302 | 302 | self.aui_manager.Update() |
303 | 303 | |
304 | - def _SetProjectName(self, pubsub_evt): | |
304 | + def _SetProjectName(self, proj_name=""): | |
305 | 305 | """ |
306 | 306 | Set project name into frame's title. |
307 | 307 | """ |
308 | - proj_name = pubsub_evt.data | |
309 | - | |
310 | 308 | if not(proj_name): |
311 | 309 | self.SetTitle("InVesalius 3") |
312 | 310 | else: |
313 | 311 | self.SetTitle("%s - InVesalius 3"%(proj_name)) |
314 | 312 | |
315 | - def _ShowContentPanel(self, evt_pubsub): | |
313 | + def _ShowContentPanel(self): | |
316 | 314 | """ |
317 | 315 | Show viewers and task, hide import panel. |
318 | 316 | """ |
319 | 317 | Publisher.sendMessage("Set layout button full") |
320 | 318 | aui_manager = self.aui_manager |
321 | 319 | aui_manager.GetPane("Import").Show(0) |
322 | - | |
320 | + | |
323 | 321 | aui_manager.GetPane("ImportBMP").Show(0) |
324 | 322 | |
325 | 323 | aui_manager.GetPane("Data").Show(1) |
326 | 324 | aui_manager.GetPane("Tasks").Show(1) |
327 | 325 | aui_manager.Update() |
328 | 326 | |
329 | - def _ShowImportNetwork(self, evt_pubsub): | |
327 | + def _ShowImportNetwork(self): | |
330 | 328 | """ |
331 | 329 | Show viewers and task, hide import panel. |
332 | 330 | """ |
... | ... | @@ -338,7 +336,7 @@ class Frame(wx.Frame): |
338 | 336 | aui_manager.GetPane("Import").Show(0) |
339 | 337 | aui_manager.Update() |
340 | 338 | |
341 | - def _ShowImportBitmap(self, evt_pubsub): | |
339 | + def _ShowImportBitmap(self): | |
342 | 340 | """ |
343 | 341 | Show viewers and task, hide import panel. |
344 | 342 | """ |
... | ... | @@ -350,15 +348,14 @@ class Frame(wx.Frame): |
350 | 348 | aui_manager.GetPane("Import").Show(0) |
351 | 349 | aui_manager.Update() |
352 | 350 | |
353 | - def _ShowHelpMessage(self, evt_pubsub): | |
351 | + def _ShowHelpMessage(self, message): | |
354 | 352 | aui_manager = self.aui_manager |
355 | 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 | 355 | self.mw.SetPosition(pos) |
359 | 356 | self.mw.Show() |
360 | 357 | |
361 | - def _ShowImportPanel(self, evt_pubsub): | |
358 | + def _ShowImportPanel(self): | |
362 | 359 | """ |
363 | 360 | Show only DICOM import panel. as dicom """ |
364 | 361 | Publisher.sendMessage("Set layout button data only") |
... | ... | @@ -368,14 +365,14 @@ class Frame(wx.Frame): |
368 | 365 | aui_manager.GetPane("Tasks").Show(0) |
369 | 366 | aui_manager.Update() |
370 | 367 | |
371 | - def _ShowTask(self, pubsub_evt): | |
368 | + def _ShowTask(self): | |
372 | 369 | """ |
373 | 370 | Show task panel. |
374 | 371 | """ |
375 | 372 | self.aui_manager.GetPane("Tasks").Show() |
376 | 373 | self.aui_manager.Update() |
377 | 374 | |
378 | - def _UpdateAUI(self, pubsub_evt): | |
375 | + def _UpdateAUI(self): | |
379 | 376 | """ |
380 | 377 | Refresh AUI panels/data. |
381 | 378 | """ |
... | ... | @@ -457,19 +454,19 @@ class Frame(wx.Frame): |
457 | 454 | self.OnReorientImg() |
458 | 455 | |
459 | 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 | 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 | 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 | 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 | 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 | 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 | 471 | elif id == const.ID_FLOODFILL_MASK: |
475 | 472 | self.OnFillHolesManually() |
... | ... | @@ -507,13 +504,13 @@ class Frame(wx.Frame): |
507 | 504 | Publisher.sendMessage('New mask from shortcut') |
508 | 505 | |
509 | 506 | def OnInterpolatedSlices(self, status): |
510 | - Publisher.sendMessage('Set interpolated slices', status) | |
507 | + Publisher.sendMessage('Set interpolated slices', flag=status) | |
511 | 508 | |
512 | 509 | def OnNavigationMode(self, status): |
513 | 510 | if status and self._show_navigator_message and sys.platform != 'win32': |
514 | 511 | wx.MessageBox(_('Currently the Navigation mode is only working on Windows'), 'Info', wx.OK | wx.ICON_INFORMATION) |
515 | 512 | self._show_navigator_message = False |
516 | - Publisher.sendMessage('Set navigation mode', status) | |
513 | + Publisher.sendMessage('Set navigation mode', status=status) | |
517 | 514 | if not status: |
518 | 515 | Publisher.sendMessage('Remove sensors ID') |
519 | 516 | |
... | ... | @@ -554,7 +551,7 @@ class Frame(wx.Frame): |
554 | 551 | ses.Session().WriteSessionFile() |
555 | 552 | |
556 | 553 | Publisher.sendMessage('Remove Volume') |
557 | - Publisher.sendMessage('Reset Reaycasting') | |
554 | + Publisher.sendMessage('Reset Raycasting') | |
558 | 555 | Publisher.sendMessage('Update Slice Interpolation') |
559 | 556 | Publisher.sendMessage('Update Slice Interpolation MenuBar') |
560 | 557 | Publisher.sendMessage('Update Navigation Mode MenuBar') |
... | ... | @@ -570,7 +567,7 @@ class Frame(wx.Frame): |
570 | 567 | """ |
571 | 568 | Save project. |
572 | 569 | """ |
573 | - Publisher.sendMessage('Show save dialog', False) | |
570 | + Publisher.sendMessage('Show save dialog', save_as=False) | |
574 | 571 | |
575 | 572 | def ShowGettingStarted(self): |
576 | 573 | """ |
... | ... | @@ -596,7 +593,7 @@ class Frame(wx.Frame): |
596 | 593 | """ |
597 | 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 | 598 | def ShowRetrieveDicomPanel(self): |
602 | 599 | Publisher.sendMessage('Show retrieve dicom panel') |
... | ... | @@ -611,20 +608,20 @@ class Frame(wx.Frame): |
611 | 608 | """ |
612 | 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 | 613 | def ShowBitmapImporter(self): |
617 | 614 | """ |
618 | 615 | Tiff, BMP, JPEG and PNG |
619 | 616 | """ |
620 | - Publisher.sendMessage('Show bitmap dialog', True) | |
617 | + Publisher.sendMessage('Show bitmap dialog') | |
621 | 618 | |
622 | 619 | def FlipVolume(self, axis): |
623 | - Publisher.sendMessage('Flip volume', axis) | |
620 | + Publisher.sendMessage('Flip volume', axis=axis) | |
624 | 621 | Publisher.sendMessage('Reload actual slice') |
625 | 622 | |
626 | 623 | def SwapAxes(self, axes): |
627 | - Publisher.sendMessage('Swap volume axes', axes) | |
624 | + Publisher.sendMessage('Swap volume axes', axes=axes) | |
628 | 625 | Publisher.sendMessage('Update scroll') |
629 | 626 | Publisher.sendMessage('Reload actual slice') |
630 | 627 | |
... | ... | @@ -642,31 +639,31 @@ class Frame(wx.Frame): |
642 | 639 | Publisher.sendMessage('Reload actual slice') |
643 | 640 | |
644 | 641 | def OnReorientImg(self): |
645 | - Publisher.sendMessage('Enable style', const.SLICE_STATE_REORIENT) | |
642 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_REORIENT) | |
646 | 643 | rdlg = dlg.ReorientImageDialog() |
647 | 644 | rdlg.Show() |
648 | 645 | |
649 | 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 | 649 | def OnFillHolesAutomatically(self): |
653 | 650 | fdlg = dlg.FillHolesAutoDialog(_(u"Fill holes automatically")) |
654 | 651 | fdlg.Show() |
655 | 652 | |
656 | 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 | 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 | 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 | 662 | def OnInterpolatedSlices(self, status): |
666 | - Publisher.sendMessage('Set interpolated slices', status) | |
667 | - | |
663 | + Publisher.sendMessage('Set interpolated slices', flag=status) | |
664 | + | |
668 | 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 | 956 | else: |
960 | 957 | return False |
961 | 958 | |
962 | - def OnUpdateSliceInterpolation(self, pubsub_evt): | |
959 | + def OnUpdateSliceInterpolation(self): | |
963 | 960 | v = self.SliceInterpolationStatus() |
964 | 961 | self.view_menu.Check(const.ID_VIEW_INTERPOLATED, v) |
965 | 962 | |
966 | - def OnUpdateNavigationMode(self, pubsub_evt): | |
963 | + def OnUpdateNavigationMode(self): | |
967 | 964 | v = self.NavigationModeStatus() |
968 | 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 | 969 | Based on given state, enables or disables menu items which |
973 | 970 | depend if project is open or not. |
974 | 971 | """ |
975 | - state = pubsub_evt.data | |
976 | 972 | if state: |
977 | 973 | self.SetStateProjectOpen() |
978 | 974 | else: |
... | ... | @@ -992,41 +988,38 @@ class MenuBar(wx.MenuBar): |
992 | 988 | for item in self.enable_items: |
993 | 989 | self.Enable(item, True) |
994 | 990 | |
995 | - def OnEnableUndo(self, pubsub_evt): | |
996 | - value = pubsub_evt.data | |
991 | + def OnEnableUndo(self, value): | |
997 | 992 | if value: |
998 | 993 | self.FindItemById(wx.ID_UNDO).Enable(True) |
999 | 994 | else: |
1000 | 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 | 998 | if value: |
1005 | 999 | self.FindItemById(wx.ID_REDO).Enable(True) |
1006 | 1000 | else: |
1007 | 1001 | self.FindItemById(wx.ID_REDO).Enable(False) |
1008 | 1002 | |
1009 | - def OnEnableNavigation(self, pubsub_evt): | |
1003 | + def OnEnableNavigation(self, status): | |
1010 | 1004 | """ |
1011 | 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 | 1009 | if value: |
1016 | 1010 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(False) |
1017 | 1011 | else: |
1018 | 1012 | self.FindItemById(const.ID_MODE_NAVIGATION).Enable(True) |
1019 | 1013 | |
1020 | - def OnAddMask(self, pubsub_evt): | |
1014 | + def OnAddMask(self, mask): | |
1021 | 1015 | self.num_masks += 1 |
1022 | 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 | 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 | 1023 | self.clean_mask_menu.Enable(value) |
1031 | 1024 | self.crop_mask_menu.Enable(value) |
1032 | 1025 | |
... | ... | @@ -1054,7 +1047,7 @@ class ProgressBar(wx.Gauge): |
1054 | 1047 | sub = Publisher.subscribe |
1055 | 1048 | sub(self._Layout, 'ProgressBar Reposition') |
1056 | 1049 | |
1057 | - def _Layout(self, evt_pubsub=None): | |
1050 | + def _Layout(self): | |
1058 | 1051 | """ |
1059 | 1052 | Compute new size and position, according to parent resize |
1060 | 1053 | """ |
... | ... | @@ -1104,12 +1097,11 @@ class StatusBar(wx.StatusBar): |
1104 | 1097 | sub(self._SetProgressValue, 'Update status in GUI') |
1105 | 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 | 1102 | Set both percentage value in gauge and text progress label in |
1110 | 1103 | status. |
1111 | 1104 | """ |
1112 | - value, label = pubsub_evt.data | |
1113 | 1105 | self.progress_bar.SetPercentage(value) |
1114 | 1106 | self.SetStatusText(label, 0) |
1115 | 1107 | if (int(value) >= 99): |
... | ... | @@ -1123,11 +1115,10 @@ class StatusBar(wx.StatusBar): |
1123 | 1115 | except(wx._core.PyAssertionError): |
1124 | 1116 | utils.debug("wx._core.PyAssertionError") |
1125 | 1117 | |
1126 | - def _SetProgressLabel(self, pubsub_evt): | |
1118 | + def _SetProgressLabel(self, label): | |
1127 | 1119 | """ |
1128 | 1120 | Set text progress label. |
1129 | 1121 | """ |
1130 | - label = pubsub_evt.data | |
1131 | 1122 | self.SetStatusText(label, 0) |
1132 | 1123 | |
1133 | 1124 | # ------------------------------------------------------------------ |
... | ... | @@ -1262,12 +1253,11 @@ class ProjectToolBar(AuiToolBar): |
1262 | 1253 | # "Print medical image...", |
1263 | 1254 | # BMP_PRINT) |
1264 | 1255 | |
1265 | - def _EnableState(self, pubsub_evt): | |
1256 | + def _EnableState(self, state): | |
1266 | 1257 | """ |
1267 | 1258 | Based on given state, enable or disable menu items which |
1268 | 1259 | depend if project is open or not. |
1269 | 1260 | """ |
1270 | - state = pubsub_evt.data | |
1271 | 1261 | if state: |
1272 | 1262 | self.SetStateProjectOpen() |
1273 | 1263 | else: |
... | ... | @@ -1445,19 +1435,18 @@ class ObjectToolBar(AuiToolBar): |
1445 | 1435 | # bitmap = BMP_ANNOTATE, |
1446 | 1436 | # kind = wx.ITEM_CHECK) |
1447 | 1437 | |
1448 | - def _EnableState(self, pubsub_evt): | |
1438 | + def _EnableState(self, state): | |
1449 | 1439 | """ |
1450 | 1440 | Based on given state, enable or disable menu items which |
1451 | 1441 | depend if project is open or not. |
1452 | 1442 | """ |
1453 | - state = pubsub_evt.data | |
1454 | 1443 | if state: |
1455 | 1444 | self.SetStateProjectOpen() |
1456 | 1445 | else: |
1457 | 1446 | self.SetStateProjectClose() |
1458 | 1447 | self.Refresh() |
1459 | 1448 | |
1460 | - def _UntoggleAllItems(self, pubsub_evt=None): | |
1449 | + def _UntoggleAllItems(self): | |
1461 | 1450 | """ |
1462 | 1451 | Untoggle all items on toolbar. |
1463 | 1452 | """ |
... | ... | @@ -1467,14 +1456,14 @@ class ObjectToolBar(AuiToolBar): |
1467 | 1456 | self.ToggleTool(id, False) |
1468 | 1457 | self.Refresh() |
1469 | 1458 | |
1470 | - def _ToggleLinearMeasure(self, pubsub_evt): | |
1459 | + def _ToggleLinearMeasure(self): | |
1471 | 1460 | """ |
1472 | 1461 | Force measure distance tool to be toggled and bind pubsub |
1473 | 1462 | events to other classes whici are interested on this. |
1474 | 1463 | """ |
1475 | 1464 | id = const.STATE_MEASURE_DISTANCE |
1476 | 1465 | self.ToggleTool(id, True) |
1477 | - Publisher.sendMessage('Enable style', id) | |
1466 | + Publisher.sendMessage('Enable style', style=id) | |
1478 | 1467 | Publisher.sendMessage('Untoggle slice toolbar items') |
1479 | 1468 | for item in const.TOOL_STATES: |
1480 | 1469 | state = self.GetToolToggled(item) |
... | ... | @@ -1482,14 +1471,14 @@ class ObjectToolBar(AuiToolBar): |
1482 | 1471 | self.ToggleTool(item, False) |
1483 | 1472 | |
1484 | 1473 | |
1485 | - def _ToggleAngularMeasure(self, pubsub_evt): | |
1474 | + def _ToggleAngularMeasure(self): | |
1486 | 1475 | """ |
1487 | 1476 | Force measure angle tool to be toggled and bind pubsub |
1488 | 1477 | events to other classes which are interested on this. |
1489 | 1478 | """ |
1490 | 1479 | id = const.STATE_MEASURE_ANGLE |
1491 | 1480 | self.ToggleTool(id, True) |
1492 | - Publisher.sendMessage('Enable style', id) | |
1481 | + Publisher.sendMessage('Enable style', style=id) | |
1493 | 1482 | Publisher.sendMessage('Untoggle slice toolbar items') |
1494 | 1483 | for item in const.TOOL_STATES: |
1495 | 1484 | state = self.GetToolToggled(item) |
... | ... | @@ -1508,10 +1497,10 @@ class ObjectToolBar(AuiToolBar): |
1508 | 1497 | Publisher.sendMessage('Fold measure task') |
1509 | 1498 | |
1510 | 1499 | if state: |
1511 | - Publisher.sendMessage('Enable style', id) | |
1500 | + Publisher.sendMessage('Enable style', style=id) | |
1512 | 1501 | Publisher.sendMessage('Untoggle slice toolbar items') |
1513 | 1502 | else: |
1514 | - Publisher.sendMessage('Disable style', id) | |
1503 | + Publisher.sendMessage('Disable style', style=id) | |
1515 | 1504 | |
1516 | 1505 | for item in const.TOOL_STATES: |
1517 | 1506 | state = self.GetToolToggled(item) |
... | ... | @@ -1519,8 +1508,7 @@ class ObjectToolBar(AuiToolBar): |
1519 | 1508 | self.ToggleTool(item, False) |
1520 | 1509 | evt.Skip() |
1521 | 1510 | |
1522 | - def ToggleItem(self, evt): | |
1523 | - _id, value = evt.data | |
1511 | + def ToggleItem(self, _id, value): | |
1524 | 1512 | if _id in self.enable_items: |
1525 | 1513 | self.ToggleTool(_id, value) |
1526 | 1514 | self.Refresh() |
... | ... | @@ -1613,12 +1601,11 @@ class SliceToolBar(AuiToolBar): |
1613 | 1601 | """ |
1614 | 1602 | self.Bind(wx.EVT_TOOL, self.OnToggle) |
1615 | 1603 | |
1616 | - def _EnableState(self, pubsub_evt): | |
1604 | + def _EnableState(self, state): | |
1617 | 1605 | """ |
1618 | 1606 | Based on given state, enable or disable menu items which |
1619 | 1607 | depend if project is open or not. |
1620 | 1608 | """ |
1621 | - state = pubsub_evt.data | |
1622 | 1609 | if state: |
1623 | 1610 | self.SetStateProjectOpen() |
1624 | 1611 | else: |
... | ... | @@ -1626,7 +1613,7 @@ class SliceToolBar(AuiToolBar): |
1626 | 1613 | self._UntoggleAllItems() |
1627 | 1614 | self.Refresh() |
1628 | 1615 | |
1629 | - def _UntoggleAllItems(self, pubsub_evt=None): | |
1616 | + def _UntoggleAllItems(self): | |
1630 | 1617 | """ |
1631 | 1618 | Untoggle all items on toolbar. |
1632 | 1619 | """ |
... | ... | @@ -1636,16 +1623,15 @@ class SliceToolBar(AuiToolBar): |
1636 | 1623 | self.ToggleTool(id, False) |
1637 | 1624 | if id == const.SLICE_STATE_CROSS: |
1638 | 1625 | msg = 'Set cross visibility' |
1639 | - Publisher.sendMessage(msg, 0) | |
1626 | + Publisher.sendMessage(msg, visibility=0) | |
1640 | 1627 | self.Refresh() |
1641 | 1628 | |
1642 | - def OnToggle(self, evt): | |
1629 | + def OnToggle(self, evt=None, id=None): | |
1643 | 1630 | """ |
1644 | 1631 | Update status of other items on toolbar (only one item |
1645 | 1632 | should be toggle each time). |
1646 | 1633 | """ |
1647 | - if hasattr(evt, 'data'): | |
1648 | - id = evt.data | |
1634 | + if id is not None: | |
1649 | 1635 | if not self.GetToolToggled(id): |
1650 | 1636 | self.ToggleTool(id, True) |
1651 | 1637 | self.Refresh() |
... | ... | @@ -1656,10 +1642,10 @@ class SliceToolBar(AuiToolBar): |
1656 | 1642 | state = self.GetToolToggled(id) |
1657 | 1643 | |
1658 | 1644 | if state: |
1659 | - Publisher.sendMessage('Enable style', id) | |
1645 | + Publisher.sendMessage('Enable style', style=id) | |
1660 | 1646 | Publisher.sendMessage('Untoggle object toolbar items') |
1661 | 1647 | else: |
1662 | - Publisher.sendMessage('Disable style', id) | |
1648 | + Publisher.sendMessage('Disable style', style=id) | |
1663 | 1649 | |
1664 | 1650 | for item in self.enable_items: |
1665 | 1651 | state = self.GetToolToggled(item) |
... | ... | @@ -1671,8 +1657,7 @@ class SliceToolBar(AuiToolBar): |
1671 | 1657 | ##print ">>>", self.sst.IsToggled() |
1672 | 1658 | #print ">>>", self.sst.GetState() |
1673 | 1659 | |
1674 | - def ToggleItem(self, evt): | |
1675 | - _id, value = evt.data | |
1660 | + def ToggleItem(self, _id, value): | |
1676 | 1661 | if _id in self.enable_items: |
1677 | 1662 | self.ToggleTool(_id, value) |
1678 | 1663 | self.Refresh() |
... | ... | @@ -1785,25 +1770,24 @@ class LayoutToolBar(AuiToolBar): |
1785 | 1770 | wx.ITEM_NORMAL, |
1786 | 1771 | short_help_string= _("Hide text")) |
1787 | 1772 | |
1788 | - def _EnableState(self, pubsub_evt): | |
1773 | + def _EnableState(self, state): | |
1789 | 1774 | """ |
1790 | 1775 | Based on given state, enable or disable menu items which |
1791 | 1776 | depend if project is open or not. |
1792 | 1777 | """ |
1793 | - state = pubsub_evt.data | |
1794 | 1778 | if state: |
1795 | 1779 | self.SetStateProjectOpen() |
1796 | 1780 | else: |
1797 | 1781 | self.SetStateProjectClose() |
1798 | 1782 | self.Refresh() |
1799 | 1783 | |
1800 | - def _SetLayoutWithoutTask(self, pubsub_evt): | |
1784 | + def _SetLayoutWithoutTask(self): | |
1801 | 1785 | """ |
1802 | 1786 | Set item bitmap to task panel hiden. |
1803 | 1787 | """ |
1804 | 1788 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |
1805 | 1789 | |
1806 | - def _SetLayoutWithTask(self, pubsub_evt): | |
1790 | + def _SetLayoutWithTask(self): | |
1807 | 1791 | """ |
1808 | 1792 | Set item bitmap to task panel shown. |
1809 | 1793 | """ |
... | ... | @@ -1958,25 +1942,24 @@ class HistoryToolBar(AuiToolBar): |
1958 | 1942 | self.EnableTool(wx.ID_UNDO, False) |
1959 | 1943 | self.EnableTool(wx.ID_REDO, False) |
1960 | 1944 | |
1961 | - def _EnableState(self, pubsub_evt): | |
1945 | + def _EnableState(self, state): | |
1962 | 1946 | """ |
1963 | 1947 | Based on given state, enable or disable menu items which |
1964 | 1948 | depend if project is open or not. |
1965 | 1949 | """ |
1966 | - state = pubsub_evt.data | |
1967 | 1950 | if state: |
1968 | 1951 | self.SetStateProjectOpen() |
1969 | 1952 | else: |
1970 | 1953 | self.SetStateProjectClose() |
1971 | 1954 | self.Refresh() |
1972 | 1955 | |
1973 | - def _SetLayoutWithoutTask(self, pubsub_evt): | |
1956 | + def _SetLayoutWithoutTask(self): | |
1974 | 1957 | """ |
1975 | 1958 | Set item bitmap to task panel hiden. |
1976 | 1959 | """ |
1977 | 1960 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU) |
1978 | 1961 | |
1979 | - def _SetLayoutWithTask(self, pubsub_evt): | |
1962 | + def _SetLayoutWithTask(self): | |
1980 | 1963 | """ |
1981 | 1964 | Set item bitmap to task panel shown. |
1982 | 1965 | """ |
... | ... | @@ -2054,16 +2037,14 @@ class HistoryToolBar(AuiToolBar): |
2054 | 2037 | Publisher.sendMessage('Update AUI') |
2055 | 2038 | self.ontool_text = True |
2056 | 2039 | |
2057 | - def OnEnableUndo(self, pubsub_evt): | |
2058 | - value = pubsub_evt.data | |
2040 | + def OnEnableUndo(self, value): | |
2059 | 2041 | if value: |
2060 | 2042 | self.EnableTool(wx.ID_UNDO, True) |
2061 | 2043 | else: |
2062 | 2044 | self.EnableTool(wx.ID_UNDO, False) |
2063 | 2045 | self.Refresh() |
2064 | 2046 | |
2065 | - def OnEnableRedo(self, pubsub_evt): | |
2066 | - value = pubsub_evt.data | |
2047 | + def OnEnableRedo(self, value): | |
2067 | 2048 | if value: |
2068 | 2049 | self.EnableTool(wx.ID_REDO, True) |
2069 | 2050 | else: | ... | ... |
invesalius/gui/import_bitmap_panel.py
... | ... | @@ -127,14 +127,13 @@ class InnerPanel(wx.Panel): |
127 | 127 | Publisher.subscribe(self.ShowBitmapPreview, "Load import bitmap panel") |
128 | 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 | 131 | #self.patients.extend(dicom_groups) |
133 | 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 | 138 | def _bind_events(self): |
140 | 139 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
... | ... | @@ -230,23 +229,23 @@ class TextPanel(wx.Panel): |
230 | 229 | data_size = len(bpr.BitmapData().GetData()) |
231 | 230 | |
232 | 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 | 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 | 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 | 237 | else: |
239 | 238 | Publisher.sendMessage('Show black slice in single preview image') |
240 | 239 | |
241 | 240 | self.tree.Delete(selected_item) |
242 | 241 | self.tree.Update() |
243 | 242 | self.tree.Refresh() |
244 | - Publisher.sendMessage('Remove preview panel', text_item) | |
243 | + Publisher.sendMessage('Remove preview panel', data=text_item) | |
245 | 244 | |
246 | 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 | 250 | def Populate(self, data): |
252 | 251 | tree = self.tree |
... | ... | @@ -259,7 +258,7 @@ class TextPanel(wx.Panel): |
259 | 258 | tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) |
260 | 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 | 263 | def OnSelChanged(self, evt): |
265 | 264 | self.selected_items = self.tree.GetSelections() |
... | ... | @@ -269,7 +268,7 @@ class TextPanel(wx.Panel): |
269 | 268 | |
270 | 269 | text_item = self.tree.GetItemText(item) |
271 | 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 | 273 | evt.Skip() |
275 | 274 | |
... | ... | @@ -369,14 +368,10 @@ class SeriesPanel(wx.Panel): |
369 | 368 | def GetSelectedImagesRange(self): |
370 | 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 | 373 | self.thumbnail_preview.Show(1) |
377 | - | |
378 | 374 | self.thumbnail_preview.SetBitmapFiles(bitmap) |
379 | - | |
380 | 375 | self.Update() |
381 | 376 | |
382 | 377 | def OnSelectSerie(self, evt): |
... | ... | @@ -420,8 +415,7 @@ class SlicePanel(wx.Panel): |
420 | 415 | self.SetAutoLayout(1) |
421 | 416 | self.sizer = sizer |
422 | 417 | |
423 | - def SetBitmapFiles(self, pubsub_evt): | |
424 | - data = pubsub_evt.data | |
418 | + def SetBitmapFiles(self, data): | |
425 | 419 | self.bitmap_preview.SetBitmapFiles(data) |
426 | 420 | self.sizer.Layout() |
427 | 421 | self.Update() | ... | ... |
invesalius/gui/import_network_panel.py
... | ... | @@ -266,8 +266,8 @@ class TextPanel(wx.Panel): |
266 | 266 | self.root = tree.AddRoot(_("InVesalius Database")) |
267 | 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 | 272 | def Populate(self, pubsub_evt): |
273 | 273 | tree = self.tree | ... | ... |
invesalius/gui/import_panel.py
... | ... | @@ -129,9 +129,9 @@ class InnerPanel(wx.Panel): |
129 | 129 | Publisher.subscribe(self.ShowDicomPreview, "Load import panel") |
130 | 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 | 136 | def _bind_events(self): |
137 | 137 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) |
... | ... | @@ -141,8 +141,7 @@ class InnerPanel(wx.Panel): |
141 | 141 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) |
142 | 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 | 145 | self.patients.extend(dicom_groups) |
147 | 146 | self.text_panel.Populate(dicom_groups) |
148 | 147 | |
... | ... | @@ -187,8 +186,9 @@ class InnerPanel(wx.Panel): |
187 | 186 | |
188 | 187 | nslices_result = slice_amont / (interval + 1) |
189 | 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 | 192 | else: |
193 | 193 | dlg.MissingFilesForReconstruction() |
194 | 194 | |
... | ... | @@ -251,8 +251,8 @@ class TextPanel(wx.Panel): |
251 | 251 | self.root = tree.AddRoot(_("InVesalius Database")) |
252 | 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 | 257 | def Populate(self, patient_list): |
258 | 258 | tree = self.tree |
... | ... | @@ -313,7 +313,7 @@ class TextPanel(wx.Panel): |
313 | 313 | group = self.tree.GetItemPyData(item) |
314 | 314 | if isinstance(group, dcm.DicomGroup): |
315 | 315 | Publisher.sendMessage('Load group into import panel', |
316 | - group) | |
316 | + group=group) | |
317 | 317 | |
318 | 318 | elif isinstance(group, dcm.PatientGroup): |
319 | 319 | id = group.GetDicomSample().patient.id |
... | ... | @@ -322,7 +322,7 @@ class TextPanel(wx.Panel): |
322 | 322 | self.GetEventHandler().ProcessEvent(my_evt) |
323 | 323 | |
324 | 324 | Publisher.sendMessage('Load patient into import panel', |
325 | - group) | |
325 | + patient=group) | |
326 | 326 | else: |
327 | 327 | parent_id = self.tree.GetItemParent(item) |
328 | 328 | self.tree.Expand(parent_id) |
... | ... | @@ -430,8 +430,7 @@ class SeriesPanel(wx.Panel): |
430 | 430 | self.serie_preview.Bind(dpp.EVT_CLICK_SERIE, self.OnSelectSerie) |
431 | 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 | 434 | self.dicom_preview.SetDicomGroup(group) |
436 | 435 | self.dicom_preview.Show(1) |
437 | 436 | self.serie_preview.Show(0) |
... | ... | @@ -441,9 +440,7 @@ class SeriesPanel(wx.Panel): |
441 | 440 | def GetSelectedImagesRange(self): |
442 | 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 | 444 | self.dicom_preview.Show(0) |
448 | 445 | self.serie_preview.Show(1) |
449 | 446 | |
... | ... | @@ -474,8 +471,7 @@ class SeriesPanel(wx.Panel): |
474 | 471 | my_evt.SetItemData(evt.GetItemData()) |
475 | 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 | 475 | if isinstance(patient, dcm.PatientGroup): |
480 | 476 | self.serie_preview.SetPatientGroups(patient) |
481 | 477 | self.dicom_preview.SetPatientGroups(patient) |
... | ... | @@ -505,21 +501,18 @@ class SlicePanel(wx.Panel): |
505 | 501 | self.SetAutoLayout(1) |
506 | 502 | self.sizer = sizer |
507 | 503 | |
508 | - def SetPatientSeries(self, pubsub_evt): | |
509 | - patient = pubsub_evt.data | |
504 | + def SetPatientSeries(self, patient): | |
510 | 505 | group = patient.GetGroups()[0] |
511 | 506 | self.dicom_preview.SetDicomGroup(group) |
512 | 507 | self.sizer.Layout() |
513 | 508 | self.Update() |
514 | 509 | |
515 | - def SetDicomSeries(self, evt): | |
516 | - group = evt.data | |
510 | + def SetDicomSeries(self, group): | |
517 | 511 | self.dicom_preview.SetDicomGroup(group) |
518 | 512 | self.sizer.Layout() |
519 | 513 | self.Update() |
520 | 514 | |
521 | - def ShowDicomSeries(self, pubsub_evt): | |
522 | - patient = pubsub_evt.data | |
515 | + def ShowDicomSeries(self, patient): | |
523 | 516 | group = patient.GetGroups()[0] |
524 | 517 | self.dicom_preview.SetDicomGroup(group) |
525 | 518 | self.sizer.Layout() | ... | ... |
invesalius/gui/preferences.py
invesalius/gui/task_exporter.py
... | ... | @@ -267,7 +267,7 @@ class InnerTaskPanel(wx.Panel): |
267 | 267 | if value: |
268 | 268 | filename, filetype = value |
269 | 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 | 299 | filename = filename + "."+ extension |
300 | 300 | filetype = const.FILETYPE_IMAGEDATA |
301 | 301 | Publisher.sendMessage('Export mask to file', |
302 | - (filename, filetype)) | |
302 | + filename=filename, | |
303 | + filetype=filetype) | |
303 | 304 | |
304 | 305 | |
305 | 306 | def OnLinkExportSurface(self, evt=None): |
... | ... | @@ -335,7 +336,7 @@ class InnerTaskPanel(wx.Panel): |
335 | 336 | if filename.split(".")[-1] != extension: |
336 | 337 | filename = filename + "."+ extension |
337 | 338 | Publisher.sendMessage('Export surface to file', |
338 | - (filename, filetype)) | |
339 | + filename=filename, filetype=filetype) | |
339 | 340 | if not os.path.exists(filename): |
340 | 341 | dlg = wx.MessageDialog(None, |
341 | 342 | _("It was not possible to save the surface."), | ... | ... |
invesalius/gui/task_importer.py
... | ... | @@ -235,15 +235,15 @@ class InnerTaskPanel(wx.Panel): |
235 | 235 | |
236 | 236 | def OpenProject(self, path=None): |
237 | 237 | if path: |
238 | - Publisher.sendMessage('Open recent project', path) | |
238 | + Publisher.sendMessage('Open recent project', filepath=path) | |
239 | 239 | else: |
240 | 240 | Publisher.sendMessage('Show open project dialog') |
241 | 241 | |
242 | 242 | def SaveAsProject(self): |
243 | - Publisher.sendMessage('Show save dialog', True) | |
243 | + Publisher.sendMessage('Show save dialog', save_as=True) | |
244 | 244 | |
245 | 245 | def SaveProject(self): |
246 | - Publisher.sendMessage('Show save dialog', False) | |
246 | + Publisher.sendMessage('Show save dialog', save_as=False) | |
247 | 247 | |
248 | 248 | def CloseProject(self): |
249 | 249 | Publisher.sendMessage('Close Project') | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -220,14 +220,13 @@ class InnerFoldPanel(wx.Panel): |
220 | 220 | self.SetSizer(sizer) |
221 | 221 | self.Update() |
222 | 222 | self.SetAutoLayout(1) |
223 | - | |
223 | + | |
224 | 224 | def __bind_events(self): |
225 | 225 | Publisher.subscribe(self.OnCheckStatus, 'Navigation status') |
226 | 226 | Publisher.subscribe(self.OnShowObject, 'Update track object state') |
227 | 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 | 230 | if status: |
232 | 231 | self.checktrigger.Enable(False) |
233 | 232 | self.checkobj.Enable(False) |
... | ... | @@ -237,27 +236,25 @@ class InnerFoldPanel(wx.Panel): |
237 | 236 | self.checkobj.Enable(True) |
238 | 237 | |
239 | 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 | 260 | class NeuronavigationPanel(wx.Panel): |
... | ... | @@ -402,9 +399,7 @@ class NeuronavigationPanel(wx.Panel): |
402 | 399 | Publisher.subscribe(self.UpdateObjectRegistration, 'Update object registration') |
403 | 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 | 403 | for n in const.BTNS_IMG_MKS: |
409 | 404 | btn_id = list(const.BTNS_IMG_MKS[n].keys())[0] |
410 | 405 | fid_id = list(const.BTNS_IMG_MKS[n].values())[0] |
... | ... | @@ -414,9 +409,9 @@ class NeuronavigationPanel(wx.Panel): |
414 | 409 | for m in [0, 1, 2]: |
415 | 410 | self.numctrls_coord[btn_id][m].SetValue(coord[m]) |
416 | 411 | |
417 | - def UpdateImageCoordinates(self, pubsub_evt): | |
412 | + def UpdateImageCoordinates(self, position): | |
418 | 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 | 415 | for m in [0, 1, 2, 6]: |
421 | 416 | if m == 6 and self.btns_coord[m].IsEnabled(): |
422 | 417 | for n in [0, 1, 2]: |
... | ... | @@ -427,29 +422,27 @@ class NeuronavigationPanel(wx.Panel): |
427 | 422 | for n in [0, 1, 2]: |
428 | 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 | 428 | self.obj_reg_status = True |
434 | 429 | else: |
435 | 430 | self.obj_reg = None |
436 | 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 | 440 | if self.tracker_id: |
449 | 441 | dt.TrackerConnection(self.tracker_id, self.trk_init[0], 'disconnect') |
450 | 442 | |
451 | 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 | 446 | if hasattr(evt, 'GetSelection'): |
454 | 447 | choice = evt.GetSelection() |
455 | 448 | else: |
... | ... | @@ -464,24 +457,28 @@ class NeuronavigationPanel(wx.Panel): |
464 | 457 | # has been initialized before |
465 | 458 | if trck and choice != 6: |
466 | 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 | 462 | Publisher.sendMessage('Remove sensors ID') |
469 | 463 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') |
470 | 464 | self.tracker_id = choice |
471 | 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 | 468 | self.trk_init = dt.TrackerConnection(self.tracker_id, None, 'connect') |
474 | 469 | if not self.trk_init[0]: |
475 | 470 | dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) |
476 | 471 | ctrl.SetSelection(0) |
477 | 472 | print("Tracker not connected!") |
478 | 473 | else: |
479 | - Publisher.sendMessage('Update status text in GUI', _("Ready")) | |
474 | + Publisher.sendMessage('Update status text in GUI', | |
475 | + label=_("Ready")) | |
480 | 476 | ctrl.SetSelection(self.tracker_id) |
481 | 477 | print("Tracker connected!") |
482 | 478 | elif choice == 6: |
483 | 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 | 482 | Publisher.sendMessage('Remove sensors ID') |
486 | 483 | self.trk_init = dt.TrackerConnection(self.tracker_id, trck, 'disconnect') |
487 | 484 | if not self.trk_init[0]: |
... | ... | @@ -489,10 +486,12 @@ class NeuronavigationPanel(wx.Panel): |
489 | 486 | dlg.NavigationTrackerWarning(self.tracker_id, 'disconnect') |
490 | 487 | self.tracker_id = 0 |
491 | 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 | 491 | print("Tracker disconnected!") |
494 | 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 | 495 | print("Tracker still connected!") |
497 | 496 | else: |
498 | 497 | ctrl.SetSelection(self.tracker_id) |
... | ... | @@ -507,9 +506,11 @@ class NeuronavigationPanel(wx.Panel): |
507 | 506 | self.tracker_id = 0 |
508 | 507 | ctrl.SetSelection(self.tracker_id) |
509 | 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 | 515 | def OnChoiceRefMode(self, evt, ctrl): |
515 | 516 | # When ref mode is changed the tracker coordinates are set to zero |
... | ... | @@ -518,7 +519,8 @@ class NeuronavigationPanel(wx.Panel): |
518 | 519 | # Some trackers do not accept restarting within this time window |
519 | 520 | # TODO: Improve the restarting of trackers after changing reference mode |
520 | 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 | 524 | print("Reference mode changed!") |
523 | 525 | |
524 | 526 | def OnSetImageCoordinates(self, evt): |
... | ... | @@ -529,10 +531,10 @@ class NeuronavigationPanel(wx.Panel): |
529 | 531 | self.numctrls_coord[btn_id][1].GetValue(),\ |
530 | 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 | 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 | 539 | def OnImageFiducials(self, evt): |
538 | 540 | btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0] |
... | ... | @@ -544,13 +546,13 @@ class NeuronavigationPanel(wx.Panel): |
544 | 546 | self.numctrls_coord[btn_id][2].GetValue(), 0, 0, 0 |
545 | 547 | |
546 | 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 | 550 | else: |
549 | 551 | for n in [0, 1, 2]: |
550 | 552 | self.numctrls_coord[btn_id][n].SetValue(float(self.current_coord[n])) |
551 | 553 | |
552 | 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 | 557 | def OnTrackerFiducials(self, evt): |
556 | 558 | btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0] |
... | ... | @@ -627,8 +629,8 @@ class NeuronavigationPanel(wx.Panel): |
627 | 629 | if self.trigger_state: |
628 | 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 | 634 | Publisher.sendMessage("Hide current mask") |
633 | 635 | |
634 | 636 | if self.track_obj: |
... | ... | @@ -682,7 +684,7 @@ class NeuronavigationPanel(wx.Panel): |
682 | 684 | |
683 | 685 | self.correg.stop() |
684 | 686 | |
685 | - Publisher.sendMessage("Navigation status", False) | |
687 | + Publisher.sendMessage("Navigation status", status=False) | |
686 | 688 | |
687 | 689 | def ResetImageFiducials(self): |
688 | 690 | for m in range(0, 3): |
... | ... | @@ -703,13 +705,13 @@ class NeuronavigationPanel(wx.Panel): |
703 | 705 | self.txtctrl_fre.SetValue('') |
704 | 706 | self.txtctrl_fre.SetBackgroundColour('WHITE') |
705 | 707 | |
706 | - def OnCloseProject(self, pubsub_evt): | |
708 | + def OnCloseProject(self): | |
707 | 709 | self.ResetTrackerFiducials() |
708 | 710 | self.ResetImageFiducials() |
709 | 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 | 715 | # TODO: Reset camera initial focus |
714 | 716 | Publisher.sendMessage('Reset cam clipping range') |
715 | 717 | |
... | ... | @@ -838,11 +840,11 @@ class ObjectRegistrationPanel(wx.Panel): |
838 | 840 | Publisher.subscribe(self.UpdateNavigationStatus, 'Navigation status') |
839 | 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 | 848 | if nav_status: |
847 | 849 | self.checkrecordcoords.Enable(1) |
848 | 850 | self.checktrack.Enable(0) |
... | ... | @@ -861,10 +863,10 @@ class ObjectRegistrationPanel(wx.Panel): |
861 | 863 | Publisher.sendMessage('Enable target button', True) |
862 | 864 | |
863 | 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 | 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 | 871 | def OnSelectTimestamp(self, evt, ctrl): |
870 | 872 | self.timestamp = ctrl.GetValue() |
... | ... | @@ -880,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): |
880 | 882 | None |
881 | 883 | |
882 | 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 | 887 | def OnComboCoil(self, evt): |
886 | 888 | # coil_name = evt.GetString() |
... | ... | @@ -897,8 +899,9 @@ class ObjectRegistrationPanel(wx.Panel): |
897 | 899 | if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): |
898 | 900 | self.checktrack.Enable(1) |
899 | 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 | 906 | except wx._core.PyAssertionError: # TODO FIX: win64 |
904 | 907 | pass |
... | ... | @@ -923,8 +926,8 @@ class ObjectRegistrationPanel(wx.Panel): |
923 | 926 | |
924 | 927 | self.checktrack.Enable(1) |
925 | 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 | 931 | wx.MessageBox(_("Object file successfully loaded"), _("Load")) |
929 | 932 | |
930 | 933 | def ShowSaveObjectDialog(self, evt): |
... | ... | @@ -938,7 +941,7 @@ class ObjectRegistrationPanel(wx.Panel): |
938 | 941 | np.savetxt(filename, data, fmt='%.4f', delimiter='\t', newline='\n', header=hdr) |
939 | 942 | wx.MessageBox(_("Object file successfully saved"), _("Save")) |
940 | 943 | |
941 | - def OnCloseProject(self, pubsub_evt): | |
944 | + def OnCloseProject(self): | |
942 | 945 | self.checkrecordcoords.SetValue(False) |
943 | 946 | self.checkrecordcoords.Enable(0) |
944 | 947 | self.checktrack.SetValue(False) |
... | ... | @@ -1054,12 +1057,12 @@ class MarkersPanel(wx.Panel): |
1054 | 1057 | Publisher.subscribe(self.OnCreateMarker, 'Create marker') |
1055 | 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 | 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 | 1066 | sleep(0.5) |
1064 | 1067 | #self.current_coord[3:] = 0, 0, 0 |
1065 | 1068 | self.nav_status = False |
... | ... | @@ -1080,7 +1083,7 @@ class MarkersPanel(wx.Panel): |
1080 | 1083 | menu_id.Destroy() |
1081 | 1084 | |
1082 | 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 | 1088 | def OnStopItemBlink(self, evt): |
1086 | 1089 | Publisher.sendMessage('Stop Blink Marker') |
... | ... | @@ -1107,7 +1110,7 @@ class MarkersPanel(wx.Panel): |
1107 | 1110 | |
1108 | 1111 | if self.tgt_flag: |
1109 | 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 | 1114 | self.lc.SetStringItem(self.tgt_index, 4, '') |
1112 | 1115 | # Add the new ID to exported list |
1113 | 1116 | if len(self.list_coord[self.tgt_index]) > 8: |
... | ... | @@ -1118,16 +1121,16 @@ class MarkersPanel(wx.Panel): |
1118 | 1121 | self.tgt_index = self.lc.GetFocusedItem() |
1119 | 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 | 1127 | self.OnMenuEditMarkerId('TARGET') |
1125 | 1128 | self.tgt_flag = True |
1126 | 1129 | dlg.NewTarget() |
1127 | 1130 | |
1128 | - def OnDeleteAllMarkers(self, evt): | |
1131 | + def OnDeleteAllMarkers(self, evt=None): | |
1129 | 1132 | if self.list_coord: |
1130 | - if hasattr(evt, 'data'): | |
1133 | + if evt is None: | |
1131 | 1134 | result = wx.ID_OK |
1132 | 1135 | else: |
1133 | 1136 | result = dlg.DeleteAllMarkers() |
... | ... | @@ -1135,22 +1138,21 @@ class MarkersPanel(wx.Panel): |
1135 | 1138 | if result == wx.ID_OK: |
1136 | 1139 | self.list_coord = [] |
1137 | 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 | 1142 | self.lc.DeleteAllItems() |
1140 | - Publisher.sendMessage('Stop Blink Marker', 'DeleteAll') | |
1143 | + Publisher.sendMessage('Stop Blink Marker', index='DeleteAll') | |
1141 | 1144 | |
1142 | 1145 | if self.tgt_flag: |
1143 | 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 | 1148 | if not hasattr(evt, 'data'): |
1146 | 1149 | dlg.DeleteTarget() |
1147 | 1150 | |
1148 | - def OnDeleteSingleMarker(self, evt): | |
1151 | + def OnDeleteSingleMarker(self, evt=None, marker_id=None): | |
1149 | 1152 | # OnDeleteSingleMarker is used for both pubsub and button click events |
1150 | 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 | 1156 | if self.lc.GetItemCount(): |
1155 | 1157 | for id_n in range(self.lc.GetItemCount()): |
1156 | 1158 | item = self.lc.GetItem(id_n, 4) |
... | ... | @@ -1168,7 +1170,7 @@ class MarkersPanel(wx.Panel): |
1168 | 1170 | if index: |
1169 | 1171 | if self.tgt_flag and self.tgt_index == index[0]: |
1170 | 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 | 1174 | dlg.DeleteTarget() |
1173 | 1175 | self.DeleteMarker(index) |
1174 | 1176 | else: |
... | ... | @@ -1181,14 +1183,14 @@ class MarkersPanel(wx.Panel): |
1181 | 1183 | for n in range(0, self.lc.GetItemCount()): |
1182 | 1184 | self.lc.SetStringItem(n, 0, str(n+1)) |
1183 | 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 | 1189 | # OnCreateMarker is used for both pubsub and button click events |
1188 | 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 | 1194 | else: |
1193 | 1195 | self.CreateMarker(self.current_coord, self.marker_colour, self.marker_size) |
1194 | 1196 | else: |
... | ... | @@ -1212,7 +1214,7 @@ class MarkersPanel(wx.Panel): |
1212 | 1214 | if len(line) == 11: |
1213 | 1215 | for i in const.BTNS_IMG_MKS: |
1214 | 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 | 1218 | elif line[10] == 'TARGET': |
1217 | 1219 | target = count_line |
1218 | 1220 | else: |
... | ... | @@ -1230,7 +1232,7 @@ class MarkersPanel(wx.Panel): |
1230 | 1232 | if len(line) == 8: |
1231 | 1233 | for i in const.BTNS_IMG_MKS: |
1232 | 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 | 1236 | else: |
1235 | 1237 | line.append("") |
1236 | 1238 | self.CreateMarker(coord, colour, size, line[7]) |
... | ... | @@ -1241,10 +1243,10 @@ class MarkersPanel(wx.Panel): |
1241 | 1243 | def OnMarkersVisibility(self, evt, ctrl): |
1242 | 1244 | |
1243 | 1245 | if ctrl.GetValue(): |
1244 | - Publisher.sendMessage('Hide all markers', self.lc.GetItemCount()) | |
1246 | + Publisher.sendMessage('Hide all markers', indexes=self.lc.GetItemCount()) | |
1245 | 1247 | ctrl.SetLabel('Show') |
1246 | 1248 | else: |
1247 | - Publisher.sendMessage('Show all markers', self.lc.GetItemCount()) | |
1249 | + Publisher.sendMessage('Show all markers', indexes=self.lc.GetItemCount()) | |
1248 | 1250 | ctrl.SetLabel('Hide') |
1249 | 1251 | |
1250 | 1252 | def OnSaveMarkers(self, evt): |
... | ... | @@ -1278,7 +1280,7 @@ class MarkersPanel(wx.Panel): |
1278 | 1280 | # TODO: Use matrix coordinates and not world coordinates as current method. |
1279 | 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 | 1285 | self.marker_ind += 1 |
1284 | 1286 | ... | ... |
invesalius/gui/task_slice.py
... | ... | @@ -190,7 +190,7 @@ class InnerTaskPanel(wx.Panel): |
190 | 190 | "overwrite": overwrite} |
191 | 191 | |
192 | 192 | Publisher.sendMessage('Create surface from index', |
193 | - {'method': method, 'options': srf_options}) | |
193 | + surface_parameters={'method': method, 'options': srf_options}) | |
194 | 194 | Publisher.sendMessage('Fold surface task') |
195 | 195 | |
196 | 196 | else: |
... | ... | @@ -218,7 +218,9 @@ class InnerTaskPanel(wx.Panel): |
218 | 218 | mask_name, thresh, colour = dialog.GetValue() |
219 | 219 | if mask_name: |
220 | 220 | Publisher.sendMessage('Create new mask', |
221 | - (mask_name, thresh, colour)) | |
221 | + mask_name=mask_name, | |
222 | + thresh=thresh, | |
223 | + colour=colour) | |
222 | 224 | dialog.Destroy() |
223 | 225 | |
224 | 226 | def GetMaskSelected(self): |
... | ... | @@ -371,23 +373,21 @@ class InnerFoldPanel(wx.Panel): |
371 | 373 | |
372 | 374 | if self.__id_editor == id: |
373 | 375 | if closed: |
374 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_EDITOR) | |
376 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_EDITOR) | |
375 | 377 | self.last_style = None |
376 | 378 | else: |
377 | - Publisher.sendMessage('Enable style', | |
378 | - const.SLICE_STATE_EDITOR) | |
379 | + Publisher.sendMessage('Enable style', style=const.SLICE_STATE_EDITOR) | |
379 | 380 | self.last_style = const.SLICE_STATE_EDITOR |
380 | 381 | elif self.__id_watershed == id: |
381 | 382 | if closed: |
382 | - Publisher.sendMessage('Disable style', | |
383 | - const.SLICE_STATE_WATERSHED) | |
383 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_WATERSHED) | |
384 | 384 | self.last_style = None |
385 | 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 | 388 | self.last_style = const.SLICE_STATE_WATERSHED |
389 | 389 | else: |
390 | - Publisher.sendMessage('Disable style', const.SLICE_STATE_EDITOR) | |
390 | + Publisher.sendMessage('Disable style', style=const.SLICE_STATE_EDITOR) | |
391 | 391 | self.last_style = None |
392 | 392 | |
393 | 393 | evt.Skip() |
... | ... | @@ -399,18 +399,18 @@ class InnerFoldPanel(wx.Panel): |
399 | 399 | self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) |
400 | 400 | self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) |
401 | 401 | |
402 | - def OnRetrieveStyle(self, pubsub_evt): | |
402 | + def OnRetrieveStyle(self): | |
403 | 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 | 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 | 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 | 414 | panel_seg_id = { |
415 | 415 | const.ID_THRESHOLD_SEGMENTATION: 0, |
416 | 416 | const.ID_MANUAL_SEGMENTATION: 1, |
... | ... | @@ -418,7 +418,7 @@ class InnerFoldPanel(wx.Panel): |
418 | 418 | } |
419 | 419 | |
420 | 420 | try: |
421 | - _id = panel_seg_id[pubsub_evt.data] | |
421 | + _id = panel_seg_id[panel_id] | |
422 | 422 | self.fold_panel.Expand(self.fold_panel.GetFoldPanel(_id)) |
423 | 423 | except KeyError: |
424 | 424 | pass |
... | ... | @@ -515,7 +515,7 @@ class MaskProperties(wx.Panel): |
515 | 515 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
516 | 516 | Publisher.subscribe(self.SetThresholdValues2, 'Set threshold values') |
517 | 517 | |
518 | - def OnCloseProject(self, pubsub_evt): | |
518 | + def OnCloseProject(self): | |
519 | 519 | self.CloseProject() |
520 | 520 | |
521 | 521 | def CloseProject(self): |
... | ... | @@ -526,9 +526,8 @@ class MaskProperties(wx.Panel): |
526 | 526 | for i in range(n-1, -1, -1): |
527 | 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 | 531 | self.combo_mask_name.Delete(i) |
533 | 532 | |
534 | 533 | if self.combo_mask_name.IsEmpty(): |
... | ... | @@ -543,20 +542,18 @@ class MaskProperties(wx.Panel): |
543 | 542 | self.combo_mask_name.Bind(wx.EVT_COMBOBOX, self.OnComboName) |
544 | 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 | 546 | if index >= 0: |
549 | 547 | self.combo_mask_name.SetSelection(index) |
550 | 548 | else: |
551 | 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 | 552 | self.combo_mask_name.SetString(index, name) |
556 | 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 | 557 | self.bind_evt_gradient = False |
561 | 558 | self.gradient.SetMinValue(thresh_min) |
562 | 559 | self.gradient.SetMaxValue(thresh_max) |
... | ... | @@ -572,8 +569,8 @@ class MaskProperties(wx.Panel): |
572 | 569 | self.combo_thresh.SetSelection(index) |
573 | 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 | 574 | self.gradient.SetMinValue(thresh_min) |
578 | 575 | self.gradient.SetMaxValue(thresh_max) |
579 | 576 | thresh = (thresh_min, thresh_max) |
... | ... | @@ -586,17 +583,16 @@ class MaskProperties(wx.Panel): |
586 | 583 | self.combo_thresh.SetSelection(index) |
587 | 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 | 587 | self.gradient.SetColour(colour) |
592 | 588 | self.button_colour.SetColour(colour) |
593 | 589 | |
594 | - def AddMask(self, evt_pubsub): | |
590 | + def AddMask(self, mask): | |
595 | 591 | if self.combo_mask_name.IsEmpty(): |
596 | 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 | 596 | index = self.combo_mask_name.Append(mask_name) |
601 | 597 | # self.combo_mask_name.SetSelection(index) |
602 | 598 | # self.button_colour.SetColour(mask_colour) |
... | ... | @@ -607,8 +603,7 @@ class MaskProperties(wx.Panel): |
607 | 603 | x = self.combo_mask_name.GetSelection() |
608 | 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 | 607 | self.combo_thresh.SetItems(thresh_modes_names) |
613 | 608 | self.threshold_modes_names = thresh_modes_names |
614 | 609 | proj = Project() |
... | ... | @@ -635,17 +630,17 @@ class MaskProperties(wx.Panel): |
635 | 630 | self.gradient.SetMinValue(thresh_min) |
636 | 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 | 636 | self.gradient.SetMinRange(thresh_min) |
642 | 637 | self.gradient.SetMaxRange(thresh_max) |
643 | 638 | |
644 | 639 | def OnComboName(self, evt): |
645 | 640 | mask_name = evt.GetString() |
646 | 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 | 645 | def OnComboThresh(self, evt): |
651 | 646 | (thresh_min, thresh_max) = Project().threshold_modes[evt.GetString()] |
... | ... | @@ -658,7 +653,7 @@ class MaskProperties(wx.Panel): |
658 | 653 | thresh_min = self.gradient.GetMinValue() |
659 | 654 | thresh_max = self.gradient.GetMaxValue() |
660 | 655 | Publisher.sendMessage('Set threshold values', |
661 | - (thresh_min, thresh_max)) | |
656 | + threshold_range=(thresh_min, thresh_max)) | |
662 | 657 | session = ses.Session() |
663 | 658 | session.ChangeProject() |
664 | 659 | |
... | ... | @@ -666,14 +661,14 @@ class MaskProperties(wx.Panel): |
666 | 661 | thresh_min = self.gradient.GetMinValue() |
667 | 662 | thresh_max = self.gradient.GetMaxValue() |
668 | 663 | Publisher.sendMessage('Changing threshold values', |
669 | - (thresh_min, thresh_max)) | |
664 | + threshold_range=(thresh_min, thresh_max)) | |
670 | 665 | session = ses.Session() |
671 | 666 | session.ChangeProject() |
672 | 667 | |
673 | 668 | def OnSelectColour(self, evt): |
674 | 669 | colour = evt.GetValue()[:3] |
675 | 670 | self.gradient.SetColour(colour) |
676 | - Publisher.sendMessage('Change mask colour', colour) | |
671 | + Publisher.sendMessage('Change mask colour', colour=colour) | |
677 | 672 | |
678 | 673 | class EditionTools(wx.Panel): |
679 | 674 | def __init__(self, parent): |
... | ... | @@ -778,25 +773,23 @@ class EditionTools(wx.Panel): |
778 | 773 | Publisher.subscribe(self.SetGradientColour, 'Add mask') |
779 | 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 | 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 | 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 | 785 | self.bind_evt_gradient = False |
793 | 786 | self.gradient_thresh.SetMinValue(thresh_min) |
794 | 787 | self.gradient_thresh.SetMaxValue(thresh_max) |
795 | 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 | 793 | self.gradient_thresh.SetMinRange(thresh_min) |
801 | 794 | self.gradient_thresh.SetMaxRange(thresh_max) |
802 | 795 | self.gradient_thresh.SetMinValue(thresh_min) |
... | ... | @@ -807,7 +800,7 @@ class EditionTools(wx.Panel): |
807 | 800 | thresh_max = self.gradient_thresh.GetMaxValue() |
808 | 801 | if self.bind_evt_gradient: |
809 | 802 | Publisher.sendMessage('Set edition threshold values', |
810 | - (thresh_min, thresh_max)) | |
803 | + threshold_range=(thresh_min, thresh_max)) | |
811 | 804 | |
812 | 805 | def OnMenu(self, evt): |
813 | 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 | 813 | |
821 | 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 | 818 | def OnBrushSize(self, evt): |
826 | 819 | """ """ |
827 | 820 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
828 | 821 | # in the text ctrl - so we are capturing only changes on text |
829 | 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 | 826 | self.spin.SetValue(size) |
835 | 827 | |
836 | 828 | def OnComboBrushOp(self, evt): |
837 | 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 | 831 | if brush_op_id == const.BRUSH_THRESH: |
840 | 832 | self.gradient_thresh.Enable() |
841 | 833 | else: |
... | ... | @@ -959,25 +951,24 @@ class WatershedTool(EditionTools): |
959 | 951 | def __bind_pubsub_evt(self): |
960 | 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 | 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 | 959 | wx_colour = [c*255 for c in vtk_colour] |
969 | 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 | 964 | self.bind_evt_gradient = False |
974 | 965 | self.gradient_thresh.SetMinValue(thresh_min) |
975 | 966 | self.gradient_thresh.SetMaxValue(thresh_max) |
976 | 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 | 972 | self.gradient_thresh.SetMinRange(thresh_min) |
982 | 973 | self.gradient_thresh.SetMaxRange(thresh_max) |
983 | 974 | self.gradient_thresh.SetMinValue(thresh_min) |
... | ... | @@ -994,30 +985,29 @@ class WatershedTool(EditionTools): |
994 | 985 | |
995 | 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 | 990 | def OnBrushSize(self, evt): |
1000 | 991 | """ """ |
1001 | 992 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
1002 | 993 | # in the text ctrl - so we are capturing only changes on text |
1003 | 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 | 998 | self.spin.SetValue(size) |
1009 | 999 | |
1010 | 1000 | def OnComboBrushOp(self, evt): |
1011 | 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 | 1004 | def OnCheckOverwriteMask(self, evt): |
1015 | 1005 | value = self.check_box.GetValue() |
1016 | - Publisher.sendMessage('Set overwrite mask', value) | |
1006 | + Publisher.sendMessage('Set overwrite mask', flag=value) | |
1017 | 1007 | |
1018 | 1008 | def OnCheckWWWL(self, evt): |
1019 | 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 | 1012 | def OnConfig(self, evt): |
1023 | 1013 | from invesalius.data.styles import WatershedConfig | ... | ... |
invesalius/gui/task_surface.py
... | ... | @@ -193,9 +193,9 @@ class InnerTaskPanel(wx.Panel): |
193 | 193 | |
194 | 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 | 198 | dialog.Destroy() |
198 | - | |
199 | 199 | if evt: |
200 | 200 | evt.Skip() |
201 | 201 | |
... | ... | @@ -424,12 +424,12 @@ class SurfaceTools(wx.Panel): |
424 | 424 | |
425 | 425 | def StartSeeding(self): |
426 | 426 | print("Start Seeding") |
427 | - Publisher.sendMessage('Enable style', const.VOLUME_STATE_SEED) | |
427 | + Publisher.sendMessage('Enable style', style=const.VOLUME_STATE_SEED) | |
428 | 428 | Publisher.sendMessage('Create surface by seeding - start') |
429 | 429 | |
430 | 430 | def EndSeeding(self): |
431 | 431 | print("End Seeding") |
432 | - Publisher.sendMessage('Disable style', const.VOLUME_STATE_SEED) | |
432 | + Publisher.sendMessage('Disable style', style=const.VOLUME_STATE_SEED) | |
433 | 433 | Publisher.sendMessage('Create surface by seeding - end') |
434 | 434 | |
435 | 435 | |
... | ... | @@ -515,8 +515,7 @@ class SurfaceProperties(wx.Panel): |
515 | 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 | 519 | s = self.combo_surface_name.GetSelection() |
521 | 520 | ns = 0 |
522 | 521 | |
... | ... | @@ -524,7 +523,7 @@ class SurfaceProperties(wx.Panel): |
524 | 523 | new_dict = [] |
525 | 524 | i = 0 |
526 | 525 | for n, (name, index) in enumerate(old_dict): |
527 | - if n not in list_index: | |
526 | + if n not in surface_indexes: | |
528 | 527 | new_dict.append([name, i]) |
529 | 528 | if s == n: |
530 | 529 | ns = i |
... | ... | @@ -536,7 +535,7 @@ class SurfaceProperties(wx.Panel): |
536 | 535 | if self.surface_list: |
537 | 536 | self.combo_surface_name.SetSelection(ns) |
538 | 537 | |
539 | - def OnCloseProject(self, pubsub_evt): | |
538 | + def OnCloseProject(self): | |
540 | 539 | self.CloseProject() |
541 | 540 | |
542 | 541 | def CloseProject(self): |
... | ... | @@ -545,16 +544,14 @@ class SurfaceProperties(wx.Panel): |
545 | 544 | self.combo_surface_name.Delete(i) |
546 | 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 | 548 | self.surface_list[index][0] = name |
551 | 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 | 555 | i = 0 |
559 | 556 | try: |
560 | 557 | i = self.surface_list.index([name, index]) |
... | ... | @@ -570,21 +567,21 @@ class SurfaceProperties(wx.Panel): |
570 | 567 | |
571 | 568 | self.combo_surface_name.SetItems([n[0] for n in self.surface_list]) |
572 | 569 | self.combo_surface_name.SetSelection(i) |
573 | - transparency = 100*pubsub_evt.data[5] | |
570 | + transparency = 100*surface.transparency | |
574 | 571 | self.button_colour.SetColour(colour) |
575 | 572 | self.slider_transparency.SetValue(transparency) |
576 | - Publisher.sendMessage('Update surface data', (index)) | |
573 | + # Publisher.sendMessage('Update surface data', (index)) | |
577 | 574 | |
578 | 575 | def OnComboName(self, evt): |
579 | 576 | surface_name = evt.GetString() |
580 | 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 | 580 | def OnSelectColour(self, evt): |
584 | 581 | colour = [value/255.0 for value in evt.GetValue()] |
585 | 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 | 586 | def OnTransparency(self, evt): |
590 | 587 | transparency = evt.GetInt()/float(MAX_TRANSPARENCY) |
... | ... | @@ -594,8 +591,8 @@ class SurfaceProperties(wx.Panel): |
594 | 591 | if (wx.Platform == "__WXMAC__"): |
595 | 592 | transparency = evt.GetInt()/(0.96*float(MAX_TRANSPARENCY)) |
596 | 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 | 598 | class QualityAdjustment(wx.Panel): | ... | ... |
invesalius/gui/task_tools.py
... | ... | @@ -128,12 +128,10 @@ class InnerTaskPanel(wx.Panel): |
128 | 128 | print("TODO: Send Signal - Add text annotation (both 2d and 3d)") |
129 | 129 | |
130 | 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 | 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 | 136 | def OnButton(self, evt): |
139 | 137 | id = evt.GetId() | ... | ... |
invesalius/gui/widgets/clut_raycasting.py
... | ... | @@ -174,7 +174,7 @@ class CLUTRaycastingWidget(wx.Panel): |
174 | 174 | print("Salvando") |
175 | 175 | filename = dialog.ShowSavePresetDialog() |
176 | 176 | if filename: |
177 | - Publisher.sendMessage('Save raycasting preset', filename) | |
177 | + Publisher.sendMessage('Save raycasting preset', preset_name=filename) | |
178 | 178 | point = self._has_clicked_in_a_point((x, y)) |
179 | 179 | # A point has been selected. It can be dragged. |
180 | 180 | if point: | ... | ... |
invesalius/gui/widgets/slice_menu.py
... | ... | @@ -181,7 +181,7 @@ class SliceMenu(wx.Menu): |
181 | 181 | |
182 | 182 | Publisher.subscribe(self._check_projection_menu, 'Check projection menu') |
183 | 183 | |
184 | - def FirstItemSelect(self, pusub_evt): | |
184 | + def FirstItemSelect(self): | |
185 | 185 | item = self.ID_TO_TOOL_ITEM[self.id_wl_first] |
186 | 186 | item.Check(True) |
187 | 187 | |
... | ... | @@ -195,13 +195,12 @@ class SliceMenu(wx.Menu): |
195 | 195 | # item = self.ID_TO_TOOL_ITEM[self.id_tiling_first] |
196 | 196 | # item.Check(True) |
197 | 197 | |
198 | - def CheckWindowLevelOther(self, pubsub_evt): | |
198 | + def CheckWindowLevelOther(self): | |
199 | 199 | item = self.ID_TO_TOOL_ITEM[self.other_wl_id] |
200 | 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 | 204 | item.Check() |
206 | 205 | |
207 | 206 | def OnPopup(self, evt): |
... | ... | @@ -211,11 +210,12 @@ class SliceMenu(wx.Menu): |
211 | 210 | if(key in const.WINDOW_LEVEL.keys()): |
212 | 211 | window, level = const.WINDOW_LEVEL[key] |
213 | 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 | 219 | Publisher.sendMessage('Update slice viewer') |
220 | 220 | |
221 | 221 | #Necessary update the slice plane in the volume case exists |
... | ... | @@ -223,7 +223,7 @@ class SliceMenu(wx.Menu): |
223 | 223 | |
224 | 224 | elif(key in const.SLICE_COLOR_TABLE.keys()): |
225 | 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 | 227 | Publisher.sendMessage('Update slice viewer') |
228 | 228 | |
229 | 229 | if sys.platform.startswith('linux'): |
... | ... | @@ -238,7 +238,7 @@ class SliceMenu(wx.Menu): |
238 | 238 | |
239 | 239 | elif key in self.plist_presets: |
240 | 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 | 242 | Publisher.sendMessage('Update slice viewer') |
243 | 243 | |
244 | 244 | if sys.platform.startswith('linux'): |
... | ... | @@ -253,12 +253,12 @@ class SliceMenu(wx.Menu): |
253 | 253 | |
254 | 254 | elif(key in const.IMAGE_TILING.keys()): |
255 | 255 | values = const.IMAGE_TILING[key] |
256 | - Publisher.sendMessage('Set slice viewer layout', values) | |
256 | + Publisher.sendMessage('Set slice viewer layout', layout=values) | |
257 | 257 | Publisher.sendMessage('Update slice viewer') |
258 | 258 | |
259 | 259 | elif key in PROJECTIONS_ID: |
260 | 260 | pid = PROJECTIONS_ID[key] |
261 | - Publisher.sendMessage('Set projection type', pid) | |
261 | + Publisher.sendMessage('Set projection type', projection_id=pid) | |
262 | 262 | Publisher.sendMessage('Reload actual slice') |
263 | 263 | |
264 | 264 | elif key == _('Custom'): |
... | ... | @@ -290,7 +290,7 @@ class SliceMenu(wx.Menu): |
290 | 290 | if self.cdialog: |
291 | 291 | self.cdialog.Hide() |
292 | 292 | |
293 | - def _close(self, pubsub_evt): | |
293 | + def _close(self): | |
294 | 294 | if self.cdialog: |
295 | 295 | self.cdialog.Destroy() |
296 | 296 | self.cdialog = None | ... | ... |
invesalius/presets.py
... | ... | @@ -64,14 +64,13 @@ class Presets(): |
64 | 64 | _("Custom"):(0, 0) |
65 | 65 | }) |
66 | 66 | self.__bind_events() |
67 | - | |
67 | + | |
68 | 68 | def __bind_events(self): |
69 | 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 | 74 | presets_list = (self.thresh_ct, self.thresh_mri) |
76 | 75 | |
77 | 76 | for presets in presets_list: |
... | ... | @@ -87,7 +86,7 @@ class Presets(): |
87 | 86 | t_min = thresh_min |
88 | 87 | if (t_max > thresh_max): |
89 | 88 | t_max = thresh_max |
90 | - | |
89 | + | |
91 | 90 | # This has happened in Analyze files |
92 | 91 | # TODO: find a good solution for presets in Analyze files |
93 | 92 | if (t_min > thresh_max): |
... | ... | @@ -96,9 +95,9 @@ class Presets(): |
96 | 95 | t_max = thresh_max |
97 | 96 | |
98 | 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 | 102 | def SavePlist(self, filename): |
104 | 103 | filename = "%s$%s" % (filename, 'presets.plist') | ... | ... |
invesalius/reader/bitmap_reader.py
... | ... | @@ -242,12 +242,12 @@ class ProgressBitmapReader: |
242 | 242 | def __init__(self): |
243 | 243 | Publisher.subscribe(self.CancelLoad, "Cancel bitmap load") |
244 | 244 | |
245 | - def CancelLoad(self, evt_pubsub): | |
245 | + def CancelLoad(self): | |
246 | 246 | self.running = False |
247 | 247 | self.stoped = True |
248 | 248 | |
249 | 249 | def SetWindowEvent(self, frame): |
250 | - self.frame = frame | |
250 | + self.frame = frame | |
251 | 251 | |
252 | 252 | def SetDirectoryPath(self, path,recursive=True): |
253 | 253 | self.running = True |
... | ... | @@ -255,10 +255,10 @@ class ProgressBitmapReader: |
255 | 255 | self.GetBitmaps(path,recursive) |
256 | 256 | |
257 | 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 | 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 | 263 | def GetBitmaps(self, path, recursive): |
264 | 264 | |
... | ... | @@ -359,7 +359,7 @@ def ReadBitmap(filepath): |
359 | 359 | except UnicodeDecodeError: |
360 | 360 | measures_info = False |
361 | 361 | if measures_info: |
362 | - Publisher.sendMessage('Set bitmap spacing', measures_info) | |
362 | + Publisher.sendMessage('Set bitmap spacing', spacing=measures_info) | |
363 | 363 | |
364 | 364 | return False |
365 | 365 | ... | ... |
invesalius/reader/dicom_reader.py
... | ... | @@ -313,7 +313,7 @@ class ProgressDicomReader: |
313 | 313 | def __init__(self): |
314 | 314 | Publisher.subscribe(self.CancelLoad, "Cancel DICOM load") |
315 | 315 | |
316 | - def CancelLoad(self, evt_pubsub): | |
316 | + def CancelLoad(self): | |
317 | 317 | self.running = False |
318 | 318 | self.stoped = True |
319 | 319 | |
... | ... | @@ -326,10 +326,10 @@ class ProgressDicomReader: |
326 | 326 | self.GetDicomGroups(path,recursive) |
327 | 327 | |
328 | 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 | 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 | 334 | def GetDicomGroups(self, path, recursive): |
335 | 335 | ... | ... |