Commit 78bd360e53ea0bf2894f80101460a9de04fdd746
1 parent
fe5a5962
Exists in
master
and in
68 other branches
EHN: #53 - show/hide text according to toolbar, except WL - based on other tool
Showing
3 changed files
with
52 additions
and
9 deletions
Show diff stats
invesalius/data/viewer_slice.py
... | ... | @@ -71,6 +71,8 @@ class Viewer(wx.Panel): |
71 | 71 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP |
72 | 72 | self.cursor = None |
73 | 73 | self.wl_text = None |
74 | + self.on_wl = False | |
75 | + self.on_text = False | |
74 | 76 | # VTK pipeline and actors |
75 | 77 | #self.__config_interactor() |
76 | 78 | self.pick = vtk.vtkPropPicker() |
... | ... | @@ -118,24 +120,30 @@ class Viewer(wx.Panel): |
118 | 120 | |
119 | 121 | def SetLayout(self, layout): |
120 | 122 | self.layout = layout |
121 | - if layout == (1,1): | |
123 | + if (layout == (1,1)) and self.on_text: | |
122 | 124 | self.ShowTextActors() |
123 | 125 | else: |
124 | - self.HideTextActors() | |
126 | + self.HideTextActors(change_status=False) | |
125 | 127 | |
126 | 128 | slice_ = sl.Slice() |
127 | 129 | self.LoadRenderers(slice_.GetOutput()) |
128 | 130 | self.__configure_renderers() |
129 | 131 | self.__configure_scroll() |
130 | 132 | |
131 | - def HideTextActors(self): | |
133 | + def HideTextActors(self, change_status=True): | |
132 | 134 | self.wl_text.Hide() |
133 | 135 | [t.Hide() for t in self.orientation_texts] |
136 | + self.interactor.Render() | |
137 | + if change_status: | |
138 | + self.on_text = False | |
134 | 139 | |
135 | 140 | def ShowTextActors(self): |
136 | - self.wl_text.Show() | |
141 | + if self.on_wl: | |
142 | + self.wl_text.Show() | |
137 | 143 | [t.Show() for t in self.orientation_texts] |
138 | - | |
144 | + self.Update() | |
145 | + self.interactor.Render() | |
146 | + self.on_text = True | |
139 | 147 | |
140 | 148 | |
141 | 149 | def __set_layout(self, pubsub_evt): |
... | ... | @@ -204,6 +212,13 @@ class Viewer(wx.Panel): |
204 | 212 | else: |
205 | 213 | self.__set_cross_visibility(0) |
206 | 214 | |
215 | + if state == const.STATE_WL: | |
216 | + self.on_wl = True | |
217 | + self.wl_text.Show() | |
218 | + else: | |
219 | + self.on_wl = False | |
220 | + self.wl_text.Hide() | |
221 | + | |
207 | 222 | self.__set_editor_cursor_visibility(0) |
208 | 223 | |
209 | 224 | |
... | ... | @@ -807,6 +822,21 @@ class Viewer(wx.Panel): |
807 | 822 | 'Set slice interaction style') |
808 | 823 | ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') |
809 | 824 | |
825 | + ##### | |
826 | + ps.Publisher().subscribe(self.OnShowText, | |
827 | + 'Show text actors on viewers') | |
828 | + ps.Publisher().subscribe(self.OnHideText, | |
829 | + 'Hide text actors on viewers') | |
830 | + | |
831 | + def OnShowText(self, pubsub_evt): | |
832 | + print "OnShowText" | |
833 | + self.ShowTextActors() | |
834 | + | |
835 | + def OnHideText(self, pubsub_evt): | |
836 | + print "OnHideText" | |
837 | + self.HideTextActors() | |
838 | + | |
839 | + | |
810 | 840 | def OnCloseProject(self, pubsub_evt): |
811 | 841 | self.CloseProject() |
812 | 842 | ... | ... |
invesalius/data/viewer_volume.py
... | ... | @@ -69,6 +69,8 @@ class Viewer(wx.Panel): |
69 | 69 | self.onclick = False |
70 | 70 | |
71 | 71 | self.text = vtku.Text() |
72 | + self.text.SetValue("") | |
73 | + self.ren.AddActor(self.text.actor) | |
72 | 74 | |
73 | 75 | self.view_angle = None |
74 | 76 | |
... | ... | @@ -76,6 +78,7 @@ class Viewer(wx.Panel): |
76 | 78 | self.__bind_events_wx() |
77 | 79 | |
78 | 80 | self.mouse_pressed = 0 |
81 | + self.on_wl = False | |
79 | 82 | |
80 | 83 | def __bind_events(self): |
81 | 84 | ps.Publisher().subscribe(self.LoadActor, |
... | ... | @@ -153,6 +156,15 @@ class Viewer(wx.Panel): |
153 | 156 | } |
154 | 157 | } |
155 | 158 | |
159 | + if state == const.STATE_WL: | |
160 | + self.on_wl = True | |
161 | + self.text.Show() | |
162 | + self.interactor.Render() | |
163 | + else: | |
164 | + self.on_wl = False | |
165 | + self.text.Hide() | |
166 | + self.interactor.Render() | |
167 | + | |
156 | 168 | if (state == const.STATE_ZOOM_SL): |
157 | 169 | style = vtk.vtkInteractorStyleRubberBandZoom() |
158 | 170 | self.interactor.SetInteractorStyle(style) |
... | ... | @@ -322,7 +334,8 @@ class Viewer(wx.Panel): |
322 | 334 | |
323 | 335 | def OnShowRaycasting(self, pubsub_evt): |
324 | 336 | self.raycasting_volume = True |
325 | - self.text.Show() | |
337 | + if self.on_wl: | |
338 | + self.text.Show() | |
326 | 339 | |
327 | 340 | def OnHideRaycasting(self, pubsub_evt): |
328 | 341 | self.raycasting_volume = False |
... | ... | @@ -370,7 +383,7 @@ class Viewer(wx.Panel): |
370 | 383 | |
371 | 384 | self.ren.AddVolume(volume) |
372 | 385 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) |
373 | - self.ren.AddActor(self.text.actor) | |
386 | + | |
374 | 387 | self.ren.SetBackground(colour) |
375 | 388 | |
376 | 389 | if not (self.view_angle): | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -825,9 +825,9 @@ class LayoutToolBar(wx.ToolBar): |
825 | 825 | |
826 | 826 | def OnText(self, event): |
827 | 827 | if event.IsChecked(): |
828 | - print "TODO: Send message so all textactors are shown" | |
828 | + ps.Publisher().sendMessage('Show text actors on viewers') | |
829 | 829 | else: |
830 | - print "TODO: Send message so all textactors are hiden" | |
830 | + ps.Publisher().sendMessage('Hide text actors on viewers') | |
831 | 831 | |
832 | 832 | def SetLayoutButtonOnlyData(self, pubsub_evt): |
833 | 833 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) | ... | ... |