Commit 490289b9721102fddd36712b265f1eb4370af2ee
1 parent
56f7a128
Exists in
master
and in
67 other branches
Added a method in viewer_volume to unload a given volume
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
invesalius/data/viewer_volume.py
| ... | ... | @@ -122,6 +122,8 @@ class Viewer(wx.Panel): |
| 122 | 122 | # Raycating - related |
| 123 | 123 | Publisher.subscribe(self.LoadVolume, |
| 124 | 124 | 'Load volume into viewer') |
| 125 | + Publisher.subscribe(self.UnloadVolume, | |
| 126 | + 'Unload volume') | |
| 125 | 127 | Publisher.subscribe(self.OnSetWindowLevelText, |
| 126 | 128 | 'Set volume window and level text') |
| 127 | 129 | Publisher.subscribe(self.OnHideRaycasting, |
| ... | ... | @@ -681,6 +683,10 @@ class Viewer(wx.Panel): |
| 681 | 683 | |
| 682 | 684 | self.UpdateRender() |
| 683 | 685 | |
| 686 | + def UnloadVolume(self, pubsub_evt): | |
| 687 | + volume = pubsub_evt.data | |
| 688 | + self.ren.RemoveVolume(volume) | |
| 689 | + | |
| 684 | 690 | def OnSetViewAngle(self, evt_pubsub): |
| 685 | 691 | view = evt_pubsub.data |
| 686 | 692 | self.SetViewAngle(view) | ... | ... |
invesalius/data/volume.py
| ... | ... | @@ -87,6 +87,7 @@ class Volume(): |
| 87 | 87 | self.volume = None |
| 88 | 88 | self.image = None |
| 89 | 89 | self.loaded_image = 0 |
| 90 | + self.to_reload = False | |
| 90 | 91 | self.__bind_events() |
| 91 | 92 | |
| 92 | 93 | def __bind_events(self): |
| ... | ... | @@ -162,6 +163,10 @@ class Volume(): |
| 162 | 163 | self.__load_preset_config() |
| 163 | 164 | |
| 164 | 165 | if self.config: |
| 166 | + if self.to_reload: | |
| 167 | + self.exist = False | |
| 168 | + Publisher.sendMessage('Unload volume', self.volume) | |
| 169 | + | |
| 165 | 170 | if self.exist: |
| 166 | 171 | self.__load_preset() |
| 167 | 172 | self.volume.SetVisibility(1) |
| ... | ... | @@ -180,7 +185,7 @@ class Volume(): |
| 180 | 185 | self.loaded_image = False |
| 181 | 186 | del self.image |
| 182 | 187 | self.image = None |
| 183 | - self.exist = None | |
| 188 | + self.to_reload = True | |
| 184 | 189 | |
| 185 | 190 | def __load_preset_config(self): |
| 186 | 191 | self.config = prj.Project().raycasting_preset | ... | ... |