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,6 +1013,8 @@ class Viewer(wx.Panel): | ||
1013 | def OnScrollBar(self, evt=None): | 1013 | def OnScrollBar(self, evt=None): |
1014 | pos = self.scroll.GetThumbPosition() | 1014 | pos = self.scroll.GetThumbPosition() |
1015 | self.set_slice_number(pos) | 1015 | self.set_slice_number(pos) |
1016 | + ps.Publisher().sendMessage('Change slice from slice plane',\ | ||
1017 | + (self.orientation, pos)) | ||
1016 | self.cursor_.Show(1) | 1018 | self.cursor_.Show(1) |
1017 | self.interactor.Render() | 1019 | self.interactor.Render() |
1018 | if evt: | 1020 | if evt: |
invesalius/data/viewer_volume.py
@@ -325,7 +325,8 @@ class SlicePlane: | @@ -325,7 +325,8 @@ class SlicePlane: | ||
325 | def __bind_evt(self): | 325 | def __bind_evt(self): |
326 | ps.Publisher().subscribe(self.Enable, 'Enable plane') | 326 | ps.Publisher().subscribe(self.Enable, 'Enable plane') |
327 | ps.Publisher().subscribe(self.Disable, 'Disable plane') | 327 | ps.Publisher().subscribe(self.Disable, 'Disable plane') |
328 | - | 328 | + ps.Publisher().subscribe(self.ChangeSlice, 'Change slice from slice plane') |
329 | + | ||
329 | def Create(self): | 330 | def Create(self): |
330 | 331 | ||
331 | plane_x = self.plane_x = vtk.vtkImagePlaneWidget() | 332 | plane_x = self.plane_x = vtk.vtkImagePlaneWidget() |
@@ -335,6 +336,8 @@ class SlicePlane: | @@ -335,6 +336,8 @@ class SlicePlane: | ||
335 | plane_x.TextureVisibilityOn() | 336 | plane_x.TextureVisibilityOn() |
336 | plane_x.SetLeftButtonAction(1) | 337 | plane_x.SetLeftButtonAction(1) |
337 | plane_x.SetRightButtonAction(0) | 338 | plane_x.SetRightButtonAction(0) |
339 | + prop1 = plane_x.GetPlaneProperty() | ||
340 | + prop1.SetColor(0, 0, 1) | ||
338 | cursor_property = plane_x.GetCursorProperty() | 341 | cursor_property = plane_x.GetCursorProperty() |
339 | cursor_property.SetOpacity(0) | 342 | cursor_property.SetOpacity(0) |
340 | 343 | ||
@@ -345,6 +348,8 @@ class SlicePlane: | @@ -345,6 +348,8 @@ class SlicePlane: | ||
345 | plane_y.TextureVisibilityOn() | 348 | plane_y.TextureVisibilityOn() |
346 | plane_y.SetLeftButtonAction(1) | 349 | plane_y.SetLeftButtonAction(1) |
347 | plane_y.SetRightButtonAction(0) | 350 | plane_y.SetRightButtonAction(0) |
351 | + prop1 = plane_y.GetPlaneProperty() | ||
352 | + prop1.SetColor(0, 1, 0) | ||
348 | cursor_property = plane_y.GetCursorProperty() | 353 | cursor_property = plane_y.GetCursorProperty() |
349 | cursor_property.SetOpacity(0) | 354 | cursor_property.SetOpacity(0) |
350 | 355 | ||
@@ -355,9 +360,11 @@ class SlicePlane: | @@ -355,9 +360,11 @@ class SlicePlane: | ||
355 | plane_z.TextureVisibilityOn() | 360 | plane_z.TextureVisibilityOn() |
356 | plane_z.SetLeftButtonAction(1) | 361 | plane_z.SetLeftButtonAction(1) |
357 | plane_z.SetRightButtonAction(0) | 362 | plane_z.SetRightButtonAction(0) |
363 | + prop1 = plane_z.GetPlaneProperty() | ||
364 | + prop1.SetColor(1, 0, 0) | ||
358 | cursor_property = plane_z.GetCursorProperty() | 365 | cursor_property = plane_z.GetCursorProperty() |
359 | cursor_property.SetOpacity(0) | 366 | cursor_property.SetOpacity(0) |
360 | - | 367 | + |
361 | if(self.original_orientation == const.AXIAL): | 368 | if(self.original_orientation == const.AXIAL): |
362 | prop3 = plane_z.GetPlaneProperty() | 369 | prop3 = plane_z.GetPlaneProperty() |
363 | prop3.SetColor(1, 0, 0) | 370 | prop3.SetColor(1, 0, 0) |
@@ -391,10 +398,9 @@ class SlicePlane: | @@ -391,10 +398,9 @@ class SlicePlane: | ||
391 | ps.Publisher().sendMessage('Set Widget Interactor', plane_x) | 398 | ps.Publisher().sendMessage('Set Widget Interactor', plane_x) |
392 | ps.Publisher().sendMessage('Set Widget Interactor', plane_y) | 399 | ps.Publisher().sendMessage('Set Widget Interactor', plane_y) |
393 | ps.Publisher().sendMessage('Set Widget Interactor', plane_z) | 400 | ps.Publisher().sendMessage('Set Widget Interactor', plane_z) |
394 | - | 401 | + |
395 | self.Enable() | 402 | self.Enable() |
396 | self.Disable() | 403 | self.Disable() |
397 | - | ||
398 | self.Render() | 404 | self.Render() |
399 | 405 | ||
400 | def Enable(self, evt_pubsub=None): | 406 | def Enable(self, evt_pubsub=None): |
@@ -422,6 +428,7 @@ class SlicePlane: | @@ -422,6 +428,7 @@ class SlicePlane: | ||
422 | self.plane_z.On() | 428 | self.plane_z.On() |
423 | elif(label == "Sagital"): | 429 | elif(label == "Sagital"): |
424 | self.plane_x.On() | 430 | self.plane_x.On() |
431 | + | ||
425 | else: | 432 | else: |
426 | self.plane_z.On() | 433 | self.plane_z.On() |
427 | self.plane_x.On() | 434 | self.plane_x.On() |
@@ -455,7 +462,6 @@ class SlicePlane: | @@ -455,7 +462,6 @@ class SlicePlane: | ||
455 | self.plane_z.Off() | 462 | self.plane_z.Off() |
456 | elif(label == "Sagital"): | 463 | elif(label == "Sagital"): |
457 | self.plane_x.Off() | 464 | self.plane_x.Off() |
458 | - | ||
459 | else: | 465 | else: |
460 | self.plane_z.Off() | 466 | self.plane_z.Off() |
461 | self.plane_x.Off() | 467 | self.plane_x.Off() |
@@ -466,4 +472,43 @@ class SlicePlane: | @@ -466,4 +472,43 @@ class SlicePlane: | ||
466 | 472 | ||
467 | def Render(self): | 473 | def Render(self): |
468 | ps.Publisher().sendMessage('Render volume viewer') | 474 | ps.Publisher().sendMessage('Render volume viewer') |
469 | - | ||
470 | \ No newline at end of file | 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 | \ No newline at end of file | 516 | \ No newline at end of file |