Commit 6b5eb748d9d12f61ffe3f7007b3bac3d6675333a
1 parent
e02c9d5b
Exists in
master
Changing mask being previewd on volume when changing mask
Showing
4 changed files
with
14 additions
and
2 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -1115,7 +1115,7 @@ class Controller(): |
1115 | 1115 | pass |
1116 | 1116 | |
1117 | 1117 | if err_msg: |
1118 | - dialog.MessageBox(None, "It was not possible to launch new instance of InVesalius3 dsfa dfdsfa sdfas fdsaf asdfasf dsaa", err_msg) | |
1118 | + dialog.MessageBox(None, "It was not possible to launch new instance of InVesalius3", err_msg) | |
1119 | 1119 | |
1120 | 1120 | def show_mask_preview(self, index, flag=True): |
1121 | 1121 | proj = prj.Project() |
... | ... | @@ -1126,6 +1126,7 @@ class Controller(): |
1126 | 1126 | Publisher.sendMessage("Reload actual slice") |
1127 | 1127 | |
1128 | 1128 | def enable_mask_preview(self): |
1129 | + ses.Session().mask_3d_preview = True | |
1129 | 1130 | mask = self.Slice.current_mask |
1130 | 1131 | if mask is not None: |
1131 | 1132 | self.Slice.do_threshold_to_all_slices(mask) |
... | ... | @@ -1134,6 +1135,7 @@ class Controller(): |
1134 | 1135 | Publisher.sendMessage("Render volume viewer") |
1135 | 1136 | |
1136 | 1137 | def disable_mask_preview(self): |
1138 | + ses.Session().mask_3d_preview = False | |
1137 | 1139 | mask = self.Slice.current_mask |
1138 | 1140 | if mask is not None: |
1139 | 1141 | Publisher.sendMessage("Remove mask preview", mask_3d_actor=mask.volume._actor) | ... | ... |
invesalius/data/mask.py
... | ... | @@ -248,6 +248,9 @@ class Mask(): |
248 | 248 | |
249 | 249 | def on_show(self): |
250 | 250 | self.history._config_undo_redo(self.is_shown) |
251 | + if ses.Session().mask_3d_preview: | |
252 | + Publisher.sendMessage('Show mask preview', index=self.index, flag=bool(self.is_shown)) | |
253 | + Publisher.sendMessage("Render volume viewer") | |
251 | 254 | |
252 | 255 | def create_3d_preview(self): |
253 | 256 | if self.volume is None: | ... | ... |
invesalius/data/slice_.py
... | ... | @@ -1178,6 +1178,10 @@ class Slice(metaclass=utils.Singleton): |
1178 | 1178 | |
1179 | 1179 | def SelectCurrentMask(self, index): |
1180 | 1180 | "Insert mask data, based on given index, into pipeline." |
1181 | + if self.current_mask: | |
1182 | + self.current_mask.is_shown = False | |
1183 | + self.current_mask.on_show() | |
1184 | + | |
1181 | 1185 | proj = Project() |
1182 | 1186 | future_mask = proj.GetMask(index) |
1183 | 1187 | future_mask.is_shown = True |
... | ... | @@ -1394,6 +1398,8 @@ class Slice(metaclass=utils.Singleton): |
1394 | 1398 | Publisher.sendMessage("Add mask", mask=mask) |
1395 | 1399 | |
1396 | 1400 | if show: |
1401 | + if self.current_mask: | |
1402 | + self.current_mask.is_shown = False | |
1397 | 1403 | self.current_mask = mask |
1398 | 1404 | Publisher.sendMessage("Show mask", index=mask.index, value=True) |
1399 | 1405 | Publisher.sendMessage("Change mask selected", index=mask.index) | ... | ... |
invesalius/session.py
... | ... | @@ -54,6 +54,7 @@ class Session(metaclass=Singleton): |
54 | 54 | def __init__(self): |
55 | 55 | self.project_path = () |
56 | 56 | self.temp_item = False |
57 | + self.mask_3d_preview = False | |
57 | 58 | |
58 | 59 | self._values = collections.defaultdict(dict, { |
59 | 60 | 'session': { |
... | ... | @@ -128,7 +129,7 @@ class Session(metaclass=Singleton): |
128 | 129 | return object.__getattribute__(self, '_values')[session][key] |
129 | 130 | |
130 | 131 | def __setattr__(self, name, value): |
131 | - if name in ("temp_item", "_map_attrs", "_values", "project_path"): | |
132 | + if name in ("temp_item", "_map_attrs", "_values", "project_path", "mask_3d_preview"): | |
132 | 133 | return object.__setattr__(self, name, value) |
133 | 134 | else: |
134 | 135 | session, key = self._map_attrs[name] | ... | ... |