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 | 178 | ps.Publisher().subscribe(self.SetStereoMode, 'Set stereo mode') |
| 179 | 179 | |
| 180 | 180 | ps.Publisher().subscribe(self.Reposition3DPlane, 'Reposition 3D Plane') |
| 181 | - | |
| 181 | + | |
| 182 | + ps.Publisher().subscribe(self.RemoveVolume, 'Remove Volume') | |
| 182 | 183 | |
| 183 | 184 | def SetStereoMode(self, pubsub_evt): |
| 184 | 185 | mode = pubsub_evt.data |
| ... | ... | @@ -318,6 +319,12 @@ class Viewer(wx.Panel): |
| 318 | 319 | for actor in actors: |
| 319 | 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 | 328 | def RemoveActors(self, pubsub_evt): |
| 322 | 329 | "Remove a list of actors" |
| 323 | 330 | actors = pubsub_evt.data[0] | ... | ... |
invesalius/data/volume.py
| ... | ... | @@ -85,6 +85,7 @@ class Volume(): |
| 85 | 85 | self.plane = None |
| 86 | 86 | self.plane_on = False |
| 87 | 87 | self.volume = None |
| 88 | + self.loaded_image = 0 | |
| 88 | 89 | self.__bind_events() |
| 89 | 90 | |
| 90 | 91 | def __bind_events(self): |
| ... | ... | @@ -106,6 +107,14 @@ class Volume(): |
| 106 | 107 | ps.Publisher().subscribe(self.ChangeBackgroundColour, |
| 107 | 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 | 118 | def OnCloseProject(self, pubsub_evt): |
| 110 | 119 | self.CloseProject() |
| 111 | 120 | |
| ... | ... | @@ -134,7 +143,7 @@ class Volume(): |
| 134 | 143 | self.plane.Disable() |
| 135 | 144 | ps.Publisher().sendMessage('Render volume viewer') |
| 136 | 145 | |
| 137 | - def OnShowVolume(self, pubsub_evt): | |
| 146 | + def OnShowVolume(self, pubsub_evt = None): | |
| 138 | 147 | if self.exist: |
| 139 | 148 | self.volume.SetVisibility(1) |
| 140 | 149 | if (self.plane and self.plane_on): |
| ... | ... | @@ -451,17 +460,30 @@ class Volume(): |
| 451 | 460 | #convolve.GetOutput().ReleaseDataFlagOn() |
| 452 | 461 | return imagedata |
| 453 | 462 | |
| 454 | - def LoadVolume(self): | |
| 455 | - proj = prj.Project() | |
| 463 | + def LoadImage(self): | |
| 464 | + | |
| 465 | + | |
| 456 | 466 | slice_data = slice_.Slice() |
| 457 | 467 | n_array = slice_data.matrix |
| 458 | 468 | spacing = slice_data.spacing |
| 459 | 469 | slice_number = 0 |
| 460 | 470 | orientation = 'AXIAL' |
| 461 | 471 | |
| 472 | + | |
| 462 | 473 | image = imagedata_utils.to_vtk(n_array, spacing, slice_number, orientation) |
| 463 | 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 | 487 | number_filters = len(self.config['convolutionFilters']) |
| 466 | 488 | |
| 467 | 489 | if (prj.Project().original_orientation == const.AXIAL): |
| ... | ... | @@ -517,7 +539,8 @@ class Volume(): |
| 517 | 539 | volume_mapper.IntermixIntersectingGeometryOn() |
| 518 | 540 | self.volume_mapper = volume_mapper |
| 519 | 541 | else: |
| 520 | - if ses.Session().rendering == '0': | |
| 542 | + | |
| 543 | + if int(ses.Session().rendering) == 0: | |
| 521 | 544 | volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper() |
| 522 | 545 | #volume_mapper.AutoAdjustSampleDistancesOff() |
| 523 | 546 | self.volume_mapper = volume_mapper |
| ... | ... | @@ -568,6 +591,8 @@ class Volume(): |
| 568 | 591 | |
| 569 | 592 | colour = self.GetBackgroundColour() |
| 570 | 593 | |
| 594 | + self.exist = 1 | |
| 595 | + | |
| 571 | 596 | ps.Publisher().sendMessage('Load volume into viewer', |
| 572 | 597 | (volume, colour, (self.ww, self.wl))) |
| 573 | 598 | ... | ... |
invesalius/gui/frame.py
| ... | ... | @@ -325,12 +325,18 @@ class Frame(wx.Frame): |
| 325 | 325 | evt.Skip() |
| 326 | 326 | |
| 327 | 327 | def ShowPreferences(self): |
| 328 | - if self.preferences.ShowModal(): | |
| 328 | + | |
| 329 | + if self.preferences.ShowModal() == wx.ID_OK: | |
| 329 | 330 | values = self.preferences.GetPreferences() |
| 330 | 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 | 341 | def ShowAbout(self): |
| 336 | 342 | """ | ... | ... |