Commit 5e9fa61d5c072e6009e39303a3e5cc7855e78dea
1 parent
d7c4240e
Exists in
master
and in
6 other branches
ENH: Synchronize 2D plane with 3D plane
Showing
2 changed files
with
53 additions
and
6 deletions
Show diff stats
invesalius/data/viewer_slice.py
... | ... | @@ -1013,6 +1013,8 @@ class Viewer(wx.Panel): |
1013 | 1013 | def OnScrollBar(self, evt=None): |
1014 | 1014 | pos = self.scroll.GetThumbPosition() |
1015 | 1015 | self.set_slice_number(pos) |
1016 | + ps.Publisher().sendMessage('Change slice from slice plane',\ | |
1017 | + (self.orientation, pos)) | |
1016 | 1018 | self.cursor_.Show(1) |
1017 | 1019 | self.interactor.Render() |
1018 | 1020 | if evt: | ... | ... |
invesalius/data/viewer_volume.py
... | ... | @@ -325,7 +325,8 @@ class SlicePlane: |
325 | 325 | def __bind_evt(self): |
326 | 326 | ps.Publisher().subscribe(self.Enable, 'Enable plane') |
327 | 327 | ps.Publisher().subscribe(self.Disable, 'Disable plane') |
328 | - | |
328 | + ps.Publisher().subscribe(self.ChangeSlice, 'Change slice from slice plane') | |
329 | + | |
329 | 330 | def Create(self): |
330 | 331 | |
331 | 332 | plane_x = self.plane_x = vtk.vtkImagePlaneWidget() |
... | ... | @@ -335,6 +336,8 @@ class SlicePlane: |
335 | 336 | plane_x.TextureVisibilityOn() |
336 | 337 | plane_x.SetLeftButtonAction(1) |
337 | 338 | plane_x.SetRightButtonAction(0) |
339 | + prop1 = plane_x.GetPlaneProperty() | |
340 | + prop1.SetColor(0, 0, 1) | |
338 | 341 | cursor_property = plane_x.GetCursorProperty() |
339 | 342 | cursor_property.SetOpacity(0) |
340 | 343 | |
... | ... | @@ -345,6 +348,8 @@ class SlicePlane: |
345 | 348 | plane_y.TextureVisibilityOn() |
346 | 349 | plane_y.SetLeftButtonAction(1) |
347 | 350 | plane_y.SetRightButtonAction(0) |
351 | + prop1 = plane_y.GetPlaneProperty() | |
352 | + prop1.SetColor(0, 1, 0) | |
348 | 353 | cursor_property = plane_y.GetCursorProperty() |
349 | 354 | cursor_property.SetOpacity(0) |
350 | 355 | |
... | ... | @@ -355,9 +360,11 @@ class SlicePlane: |
355 | 360 | plane_z.TextureVisibilityOn() |
356 | 361 | plane_z.SetLeftButtonAction(1) |
357 | 362 | plane_z.SetRightButtonAction(0) |
363 | + prop1 = plane_z.GetPlaneProperty() | |
364 | + prop1.SetColor(1, 0, 0) | |
358 | 365 | cursor_property = plane_z.GetCursorProperty() |
359 | 366 | cursor_property.SetOpacity(0) |
360 | - | |
367 | + | |
361 | 368 | if(self.original_orientation == const.AXIAL): |
362 | 369 | prop3 = plane_z.GetPlaneProperty() |
363 | 370 | prop3.SetColor(1, 0, 0) |
... | ... | @@ -391,10 +398,9 @@ class SlicePlane: |
391 | 398 | ps.Publisher().sendMessage('Set Widget Interactor', plane_x) |
392 | 399 | ps.Publisher().sendMessage('Set Widget Interactor', plane_y) |
393 | 400 | ps.Publisher().sendMessage('Set Widget Interactor', plane_z) |
394 | - | |
401 | + | |
395 | 402 | self.Enable() |
396 | 403 | self.Disable() |
397 | - | |
398 | 404 | self.Render() |
399 | 405 | |
400 | 406 | def Enable(self, evt_pubsub=None): |
... | ... | @@ -422,6 +428,7 @@ class SlicePlane: |
422 | 428 | self.plane_z.On() |
423 | 429 | elif(label == "Sagital"): |
424 | 430 | self.plane_x.On() |
431 | + | |
425 | 432 | else: |
426 | 433 | self.plane_z.On() |
427 | 434 | self.plane_x.On() |
... | ... | @@ -455,7 +462,6 @@ class SlicePlane: |
455 | 462 | self.plane_z.Off() |
456 | 463 | elif(label == "Sagital"): |
457 | 464 | self.plane_x.Off() |
458 | - | |
459 | 465 | else: |
460 | 466 | self.plane_z.Off() |
461 | 467 | self.plane_x.Off() |
... | ... | @@ -466,4 +472,43 @@ class SlicePlane: |
466 | 472 | |
467 | 473 | def Render(self): |
468 | 474 | ps.Publisher().sendMessage('Render volume viewer') |
469 | - | |
470 | 475 | \ No newline at end of file |
476 | + | |
477 | + def ChangeSlice(self, pubsub_evt = None): | |
478 | + orientation, number = pubsub_evt.data | |
479 | + | |
480 | + if (self.original_orientation == const.AXIAL): | |
481 | + if (orientation == "CORONAL"): | |
482 | + self.SetSliceNumber(number, "Y") | |
483 | + elif(orientation == "SAGITAL"): | |
484 | + self.SetSliceNumber(number, "X") | |
485 | + else: | |
486 | + self.SetSliceNumber(number, "Z") | |
487 | + | |
488 | + elif(self.original_orientation == const.SAGITAL): | |
489 | + if (orientation == "CORONAL"): | |
490 | + self.SetSliceNumber(number, "X") | |
491 | + elif(orientation == "SAGITAL"): | |
492 | + self.SetSliceNumber(number, "Z") | |
493 | + else: | |
494 | + self.SetSliceNumber(number, "Y") | |
495 | + | |
496 | + else: | |
497 | + if (orientation == "CORONAL"): | |
498 | + self.SetSliceNumber(number, "Z") | |
499 | + elif(orientation == "SAGITAL"): | |
500 | + self.SetSliceNumber(number, "X") | |
501 | + else: | |
502 | + self.SetSliceNumber(number, "Y") | |
503 | + | |
504 | + self.Render() | |
505 | + | |
506 | + def SetSliceNumber(self, number, axis): | |
507 | + if (axis == "X"): | |
508 | + self.plane_x.SetPlaneOrientationToXAxes() | |
509 | + self.plane_x.SetSliceIndex(number) | |
510 | + elif(axis == "Y"): | |
511 | + self.plane_y.SetPlaneOrientationToYAxes() | |
512 | + self.plane_y.SetSliceIndex(number) | |
513 | + else: | |
514 | + self.plane_z.SetPlaneOrientationToZAxes() | |
515 | + self.plane_z.SetSliceIndex(number) | |
471 | 516 | \ No newline at end of file | ... | ... |