Commit 6d6bf3025d6d26cc7194b355a8e8ea7ba42dac7c
1 parent
8dd10d55
Exists in
master
and in
68 other branches
ENH: Close project (raycasting), still needs work
Showing
3 changed files
with
34 additions
and
4 deletions
Show diff stats
invesalius/control.py
@@ -240,7 +240,6 @@ class Controller(): | @@ -240,7 +240,6 @@ class Controller(): | ||
240 | 240 | ||
241 | ps.Publisher().sendMessage('Hide content panel') | 241 | ps.Publisher().sendMessage('Hide content panel') |
242 | ps.Publisher().sendMessage('Close project data') | 242 | ps.Publisher().sendMessage('Close project data') |
243 | - | ||
244 | session = ses.Session() | 243 | session = ses.Session() |
245 | session.CloseProject() | 244 | session.CloseProject() |
246 | 245 | ||
@@ -432,8 +431,12 @@ class Controller(): | @@ -432,8 +431,12 @@ class Controller(): | ||
432 | ps.Publisher().sendMessage('Set threshold modes', | 431 | ps.Publisher().sendMessage('Set threshold modes', |
433 | (thresh_modes,default_threshold)) | 432 | (thresh_modes,default_threshold)) |
434 | 433 | ||
435 | - def LoadRaycastingPreset(self, pubsub_evt): | ||
436 | - label = pubsub_evt.data | 434 | + def LoadRaycastingPreset(self, pubsub_evt=None): |
435 | + if pubsub_evt: | ||
436 | + label = pubsub_evt.data | ||
437 | + else: | ||
438 | + return | ||
439 | + | ||
437 | if label != const.RAYCASTING_OFF_LABEL: | 440 | if label != const.RAYCASTING_OFF_LABEL: |
438 | if label in const.RAYCASTING_FILES.keys(): | 441 | if label in const.RAYCASTING_FILES.keys(): |
439 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 442 | path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, |
invesalius/data/viewer_volume.py
@@ -72,6 +72,9 @@ class Viewer(wx.Panel): | @@ -72,6 +72,9 @@ class Viewer(wx.Panel): | ||
72 | self.text.SetValue("") | 72 | self.text.SetValue("") |
73 | self.ren.AddActor(self.text.actor) | 73 | self.ren.AddActor(self.text.actor) |
74 | 74 | ||
75 | + | ||
76 | + self.slice_plane = None | ||
77 | + | ||
75 | self.view_angle = None | 78 | self.view_angle = None |
76 | 79 | ||
77 | self.__bind_events() | 80 | self.__bind_events() |
@@ -123,7 +126,16 @@ class Viewer(wx.Panel): | @@ -123,7 +126,16 @@ class Viewer(wx.Panel): | ||
123 | 126 | ||
124 | ps.Publisher().subscribe(self.OnShowText, | 127 | ps.Publisher().subscribe(self.OnShowText, |
125 | 'Show text actors on viewers') | 128 | 'Show text actors on viewers') |
129 | + ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') | ||
126 | 130 | ||
131 | + def OnCloseProject(self, pubsub_evt): | ||
132 | + if self.raycasting_volume: | ||
133 | + self.raycasting_volume = False | ||
134 | + if self.slice_plane: | ||
135 | + self.Disable() | ||
136 | + self.mouse_pressed = 0 | ||
137 | + self.on_wl = False | ||
138 | + | ||
127 | 139 | ||
128 | def OnHideText(self, pubsub_evt): | 140 | def OnHideText(self, pubsub_evt): |
129 | self.text.Hide() | 141 | self.text.Hide() |
invesalius/data/volume.py
@@ -81,7 +81,7 @@ class Volume(): | @@ -81,7 +81,7 @@ class Volume(): | ||
81 | self.curve = 0 | 81 | self.curve = 0 |
82 | self.plane = None | 82 | self.plane = None |
83 | self.plane_on = False | 83 | self.plane_on = False |
84 | - | 84 | + self.volume = None |
85 | self.__bind_events() | 85 | self.__bind_events() |
86 | 86 | ||
87 | def __bind_events(self): | 87 | def __bind_events(self): |
@@ -99,6 +99,21 @@ class Volume(): | @@ -99,6 +99,21 @@ class Volume(): | ||
99 | 'Set raycasting relative window and level') | 99 | 'Set raycasting relative window and level') |
100 | ps.Publisher().subscribe(self.OnEnableTool, | 100 | ps.Publisher().subscribe(self.OnEnableTool, |
101 | 'Enable raycasting tool') | 101 | 'Enable raycasting tool') |
102 | + ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') | ||
103 | + | ||
104 | + def OnCloseProject(self, pubsub_evt): | ||
105 | + self.CloseProject() | ||
106 | + | ||
107 | + | ||
108 | + def CloseProject(self): | ||
109 | + | ||
110 | + if self.plane: | ||
111 | + self.plane = None | ||
112 | + ps.Publisher().sendMessage('Remove surface actor from viewer', self.plane_actor) | ||
113 | + if self.exist: | ||
114 | + self.exist = None | ||
115 | + ps.Publisher().sendMessage('Remove surface actor from viewer', self.volume) | ||
116 | + | ||
102 | 117 | ||
103 | def OnLoadVolume(self, pubsub_evt): | 118 | def OnLoadVolume(self, pubsub_evt): |
104 | label = pubsub_evt.data | 119 | label = pubsub_evt.data |