Commit 133f8acf39eff8461cd2ff8b29cc964719e48eb8
1 parent
ebda1724
Exists in
master
and in
5 other branches
FIX: Fixed window and level in 3D slice
Showing
4 changed files
with
32 additions
and
25 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -353,7 +353,7 @@ class Controller(): |
353 | 353 | ps.Publisher().sendMessage('Load slice to viewer', |
354 | 354 | (proj.imagedata, |
355 | 355 | proj.mask_dict)) |
356 | - #ps.Publisher().sendMessage('Load slice plane') | |
356 | + ps.Publisher().sendMessage('Load slice plane') | |
357 | 357 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
358 | 358 | (proj.window, proj.level)) |
359 | 359 | ps.Publisher().sendMessage('Update window level value',\ | ... | ... |
invesalius/data/slice_.py
... | ... | @@ -675,29 +675,37 @@ class Slice(object): |
675 | 675 | cast.ClampOverflowOn() |
676 | 676 | cast.Update() |
677 | 677 | |
678 | - flip = vtk.vtkImageFlip() | |
679 | - flip.SetInput(cast.GetOutput()) | |
680 | - flip.SetFilteredAxis(1) | |
681 | - flip.FlipAboutOriginOn() | |
682 | - flip.Update() | |
683 | - widget.SetInput(flip.GetOutput()) | |
678 | + if (original_orientation == const.AXIAL): | |
679 | + flip = vtk.vtkImageFlip() | |
680 | + flip.SetInput(cast.GetOutput()) | |
681 | + flip.SetFilteredAxis(1) | |
682 | + flip.FlipAboutOriginOn() | |
683 | + flip.Update() | |
684 | + widget.SetInput(flip.GetOutput()) | |
685 | + else: | |
686 | + widget.SetInput(cast.GetOutput()) | |
684 | 687 | |
685 | 688 | def UpdateSlice3D(self, pubsub_evt): |
686 | 689 | widget, orientation = pubsub_evt.data |
687 | 690 | img = self.buffer_slices[orientation].vtk_image |
688 | - | |
691 | + original_orientation = Project().original_orientation | |
689 | 692 | cast = vtk.vtkImageCast() |
690 | 693 | cast.SetInput(img) |
691 | 694 | cast.SetOutputScalarTypeToDouble() |
692 | 695 | cast.ClampOverflowOn() |
693 | 696 | cast.Update() |
694 | 697 | |
695 | - flip = vtk.vtkImageFlip() | |
696 | - flip.SetInput(cast.GetOutput()) | |
697 | - flip.SetFilteredAxis(1) | |
698 | - flip.FlipAboutOriginOn() | |
699 | - flip.Update() | |
700 | - widget.SetInput(flip.GetOutput()) | |
698 | + if (original_orientation == const.AXIAL): | |
699 | + flip = vtk.vtkImageFlip() | |
700 | + flip.SetInput(cast.GetOutput()) | |
701 | + flip.SetFilteredAxis(1) | |
702 | + flip.FlipAboutOriginOn() | |
703 | + flip.Update() | |
704 | + widget.SetInput(flip.GetOutput()) | |
705 | + else: | |
706 | + widget.SetInput(cast.GetOutput()) | |
707 | + | |
708 | + | |
701 | 709 | |
702 | 710 | def CreateMask(self, imagedata=None, name=None, colour=None, |
703 | 711 | opacity=None, threshold_range=None, | ... | ... |
invesalius/data/viewer_slice.py
... | ... | @@ -351,6 +351,8 @@ class Viewer(wx.Panel): |
351 | 351 | window, level = pubsub_evt.data |
352 | 352 | self.acum_achange_window, self.acum_achange_level = (window, level) |
353 | 353 | self.SetWLText(window, level) |
354 | + ps.Publisher().sendMessage('Update all slice') | |
355 | + | |
354 | 356 | |
355 | 357 | def OnChangeSliceMove(self, evt, obj): |
356 | 358 | if (self.left_pressed): |
... | ... | @@ -821,7 +823,7 @@ class Viewer(wx.Panel): |
821 | 823 | ps.Publisher().subscribe(self.RemoveActors, ('Remove actors', ORIENTATIONS[self.orientation])) |
822 | 824 | |
823 | 825 | ps.Publisher().subscribe(self.ReloadActualSlice, 'Reload actual slice') |
824 | - | |
826 | + | |
825 | 827 | |
826 | 828 | def SetDefaultCursor(self, pusub_evt): |
827 | 829 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) |
... | ... | @@ -1150,15 +1152,6 @@ class Viewer(wx.Panel): |
1150 | 1152 | def UpdateSlice3D(self, pos): |
1151 | 1153 | original_orientation = project.Project().original_orientation |
1152 | 1154 | pos = self.scroll.GetThumbPosition() |
1153 | - #if (self.orientation == "CORONAL") and \ | |
1154 | - # (original_orientation == const.AXIAL): | |
1155 | - # pos = abs(self.scroll.GetRange() - pos) | |
1156 | - #elif(self.orientation == "AXIAL") and \ | |
1157 | - # (original_orientation == const.CORONAL): | |
1158 | - # pos = abs(self.scroll.GetRange() - pos) | |
1159 | - #elif(self.orientation == "AXIAL") and \ | |
1160 | - # (original_orientation == const.SAGITAL): | |
1161 | - # pos = abs(self.scroll.GetRange() - pos) | |
1162 | 1155 | ps.Publisher().sendMessage('Change slice from slice plane',\ |
1163 | 1156 | (self.orientation, pos)) |
1164 | 1157 | |
... | ... | @@ -1179,7 +1172,6 @@ class Viewer(wx.Panel): |
1179 | 1172 | |
1180 | 1173 | def OnScrollBarRelease(self, evt): |
1181 | 1174 | pos = self.scroll.GetThumbPosition() |
1182 | - #self.UpdateSlice3D(pos) | |
1183 | 1175 | evt.Skip() |
1184 | 1176 | |
1185 | 1177 | def OnKeyDown(self, evt=None, obj=None): | ... | ... |
invesalius/data/viewer_volume.py
... | ... | @@ -806,6 +806,7 @@ class SlicePlane: |
806 | 806 | ps.Publisher().subscribe(self.Enable, 'Enable plane') |
807 | 807 | ps.Publisher().subscribe(self.Disable, 'Disable plane') |
808 | 808 | ps.Publisher().subscribe(self.ChangeSlice, 'Change slice from slice plane') |
809 | + ps.Publisher().subscribe(self.UpdateAllSlice, 'Update all slice') | |
809 | 810 | |
810 | 811 | def Create(self): |
811 | 812 | plane_x = self.plane_x = vtk.vtkImagePlaneWidget() |
... | ... | @@ -918,6 +919,12 @@ class SlicePlane: |
918 | 919 | |
919 | 920 | self.Render() |
920 | 921 | |
922 | + def UpdateAllSlice(self, pubsub_evt): | |
923 | + ps.Publisher().sendMessage('Update slice 3D', (self.plane_y,"CORONAL")) | |
924 | + ps.Publisher().sendMessage('Update slice 3D', (self.plane_x,"SAGITAL")) | |
925 | + ps.Publisher().sendMessage('Update slice 3D', (self.plane_z,"AXIAL")) | |
926 | + | |
927 | + | |
921 | 928 | def DeletePlanes(self): |
922 | 929 | del self.plane_x |
923 | 930 | del self.plane_y | ... | ... |