Commit 51c65c2f9342d80d727a4781a9e6419f49d5bbd6
1 parent
14de9547
Exists in
master
and in
67 other branches
ENH: Finalization of Add GPU support
Showing
3 changed files
with
47 additions
and
9 deletions
Show diff stats
invesalius/data/viewer_volume.py
| @@ -178,7 +178,8 @@ class Viewer(wx.Panel): | @@ -178,7 +178,8 @@ class Viewer(wx.Panel): | ||
| 178 | ps.Publisher().subscribe(self.SetStereoMode, 'Set stereo mode') | 178 | ps.Publisher().subscribe(self.SetStereoMode, 'Set stereo mode') |
| 179 | 179 | ||
| 180 | ps.Publisher().subscribe(self.Reposition3DPlane, 'Reposition 3D Plane') | 180 | ps.Publisher().subscribe(self.Reposition3DPlane, 'Reposition 3D Plane') |
| 181 | - | 181 | + |
| 182 | + ps.Publisher().subscribe(self.RemoveVolume, 'Remove Volume') | ||
| 182 | 183 | ||
| 183 | def SetStereoMode(self, pubsub_evt): | 184 | def SetStereoMode(self, pubsub_evt): |
| 184 | mode = pubsub_evt.data | 185 | mode = pubsub_evt.data |
| @@ -318,6 +319,12 @@ class Viewer(wx.Panel): | @@ -318,6 +319,12 @@ class Viewer(wx.Panel): | ||
| 318 | for actor in actors: | 319 | for actor in actors: |
| 319 | self.ren.AddActor(actor) | 320 | self.ren.AddActor(actor) |
| 320 | 321 | ||
| 322 | + def RemoveVolume(self, pub_evt): | ||
| 323 | + volumes = self.ren.GetVolumes() | ||
| 324 | + if (volumes.GetNumberOfItems()): | ||
| 325 | + self.ren.RemoveVolume(volumes.GetLastProp()) | ||
| 326 | + self.interactor.Render() | ||
| 327 | + | ||
| 321 | def RemoveActors(self, pubsub_evt): | 328 | def RemoveActors(self, pubsub_evt): |
| 322 | "Remove a list of actors" | 329 | "Remove a list of actors" |
| 323 | actors = pubsub_evt.data[0] | 330 | actors = pubsub_evt.data[0] |
invesalius/data/volume.py
| @@ -85,6 +85,7 @@ class Volume(): | @@ -85,6 +85,7 @@ class Volume(): | ||
| 85 | self.plane = None | 85 | self.plane = None |
| 86 | self.plane_on = False | 86 | self.plane_on = False |
| 87 | self.volume = None | 87 | self.volume = None |
| 88 | + self.loaded_image = 0 | ||
| 88 | self.__bind_events() | 89 | self.__bind_events() |
| 89 | 90 | ||
| 90 | def __bind_events(self): | 91 | def __bind_events(self): |
| @@ -106,6 +107,14 @@ class Volume(): | @@ -106,6 +107,14 @@ class Volume(): | ||
| 106 | ps.Publisher().subscribe(self.ChangeBackgroundColour, | 107 | ps.Publisher().subscribe(self.ChangeBackgroundColour, |
| 107 | 'Change volume viewer background colour') | 108 | 'Change volume viewer background colour') |
| 108 | 109 | ||
| 110 | + ps.Publisher().subscribe(self.ResetRayCasting, 'Reset Reaycasting') | ||
| 111 | + | ||
| 112 | + def ResetRayCasting(self, pub_evt): | ||
| 113 | + if self.exist: | ||
| 114 | + self.exist = None | ||
| 115 | + self.LoadVolume() | ||
| 116 | + | ||
| 117 | + | ||
| 109 | def OnCloseProject(self, pubsub_evt): | 118 | def OnCloseProject(self, pubsub_evt): |
| 110 | self.CloseProject() | 119 | self.CloseProject() |
| 111 | 120 | ||
| @@ -134,7 +143,7 @@ class Volume(): | @@ -134,7 +143,7 @@ class Volume(): | ||
| 134 | self.plane.Disable() | 143 | self.plane.Disable() |
| 135 | ps.Publisher().sendMessage('Render volume viewer') | 144 | ps.Publisher().sendMessage('Render volume viewer') |
| 136 | 145 | ||
| 137 | - def OnShowVolume(self, pubsub_evt): | 146 | + def OnShowVolume(self, pubsub_evt = None): |
| 138 | if self.exist: | 147 | if self.exist: |
| 139 | self.volume.SetVisibility(1) | 148 | self.volume.SetVisibility(1) |
| 140 | if (self.plane and self.plane_on): | 149 | if (self.plane and self.plane_on): |
| @@ -451,17 +460,30 @@ class Volume(): | @@ -451,17 +460,30 @@ class Volume(): | ||
| 451 | #convolve.GetOutput().ReleaseDataFlagOn() | 460 | #convolve.GetOutput().ReleaseDataFlagOn() |
| 452 | return imagedata | 461 | return imagedata |
| 453 | 462 | ||
| 454 | - def LoadVolume(self): | ||
| 455 | - proj = prj.Project() | 463 | + def LoadImage(self): |
| 464 | + | ||
| 465 | + | ||
| 456 | slice_data = slice_.Slice() | 466 | slice_data = slice_.Slice() |
| 457 | n_array = slice_data.matrix | 467 | n_array = slice_data.matrix |
| 458 | spacing = slice_data.spacing | 468 | spacing = slice_data.spacing |
| 459 | slice_number = 0 | 469 | slice_number = 0 |
| 460 | orientation = 'AXIAL' | 470 | orientation = 'AXIAL' |
| 461 | 471 | ||
| 472 | + | ||
| 462 | image = imagedata_utils.to_vtk(n_array, spacing, slice_number, orientation) | 473 | image = imagedata_utils.to_vtk(n_array, spacing, slice_number, orientation) |
| 463 | self.image = image | 474 | self.image = image |
| 464 | 475 | ||
| 476 | + | ||
| 477 | + def LoadVolume(self): | ||
| 478 | + proj = prj.Project() | ||
| 479 | + #image = imagedata_utils.to_vtk(n_array, spacing, slice_number, orientation) | ||
| 480 | + | ||
| 481 | + if not self.loaded_image: | ||
| 482 | + self.LoadImage() | ||
| 483 | + self.loaded_image = 1 | ||
| 484 | + | ||
| 485 | + image = self.image | ||
| 486 | + | ||
| 465 | number_filters = len(self.config['convolutionFilters']) | 487 | number_filters = len(self.config['convolutionFilters']) |
| 466 | 488 | ||
| 467 | if (prj.Project().original_orientation == const.AXIAL): | 489 | if (prj.Project().original_orientation == const.AXIAL): |
| @@ -517,7 +539,8 @@ class Volume(): | @@ -517,7 +539,8 @@ class Volume(): | ||
| 517 | volume_mapper.IntermixIntersectingGeometryOn() | 539 | volume_mapper.IntermixIntersectingGeometryOn() |
| 518 | self.volume_mapper = volume_mapper | 540 | self.volume_mapper = volume_mapper |
| 519 | else: | 541 | else: |
| 520 | - if ses.Session().rendering == '0': | 542 | + |
| 543 | + if int(ses.Session().rendering) == 0: | ||
| 521 | volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper() | 544 | volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper() |
| 522 | #volume_mapper.AutoAdjustSampleDistancesOff() | 545 | #volume_mapper.AutoAdjustSampleDistancesOff() |
| 523 | self.volume_mapper = volume_mapper | 546 | self.volume_mapper = volume_mapper |
| @@ -568,6 +591,8 @@ class Volume(): | @@ -568,6 +591,8 @@ class Volume(): | ||
| 568 | 591 | ||
| 569 | colour = self.GetBackgroundColour() | 592 | colour = self.GetBackgroundColour() |
| 570 | 593 | ||
| 594 | + self.exist = 1 | ||
| 595 | + | ||
| 571 | ps.Publisher().sendMessage('Load volume into viewer', | 596 | ps.Publisher().sendMessage('Load volume into viewer', |
| 572 | (volume, colour, (self.ww, self.wl))) | 597 | (volume, colour, (self.ww, self.wl))) |
| 573 | 598 |
invesalius/gui/frame.py
| @@ -325,12 +325,18 @@ class Frame(wx.Frame): | @@ -325,12 +325,18 @@ class Frame(wx.Frame): | ||
| 325 | evt.Skip() | 325 | evt.Skip() |
| 326 | 326 | ||
| 327 | def ShowPreferences(self): | 327 | def ShowPreferences(self): |
| 328 | - if self.preferences.ShowModal(): | 328 | + |
| 329 | + if self.preferences.ShowModal() == wx.ID_OK: | ||
| 329 | values = self.preferences.GetPreferences() | 330 | values = self.preferences.GetPreferences() |
| 330 | self.preferences.Close() | 331 | self.preferences.Close() |
| 331 | - | ||
| 332 | - ses.Session().rendering = values[const.RENDERING] | ||
| 333 | - ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] | 332 | + |
| 333 | + ses.Session().rendering = values[const.RENDERING] | ||
| 334 | + ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] | ||
| 335 | + | ||
| 336 | + ps.Publisher().sendMessage('Remove Volume') | ||
| 337 | + ps.Publisher().sendMessage('Reset Reaycasting') | ||
| 338 | + | ||
| 339 | + | ||
| 334 | 340 | ||
| 335 | def ShowAbout(self): | 341 | def ShowAbout(self): |
| 336 | """ | 342 | """ |