Commit 78bd360e53ea0bf2894f80101460a9de04fdd746
1 parent
fe5a5962
Exists in
master
and in
6 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,6 +71,8 @@ class Viewer(wx.Panel): | ||
71 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP | 71 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP |
72 | self.cursor = None | 72 | self.cursor = None |
73 | self.wl_text = None | 73 | self.wl_text = None |
74 | + self.on_wl = False | ||
75 | + self.on_text = False | ||
74 | # VTK pipeline and actors | 76 | # VTK pipeline and actors |
75 | #self.__config_interactor() | 77 | #self.__config_interactor() |
76 | self.pick = vtk.vtkPropPicker() | 78 | self.pick = vtk.vtkPropPicker() |
@@ -118,24 +120,30 @@ class Viewer(wx.Panel): | @@ -118,24 +120,30 @@ class Viewer(wx.Panel): | ||
118 | 120 | ||
119 | def SetLayout(self, layout): | 121 | def SetLayout(self, layout): |
120 | self.layout = layout | 122 | self.layout = layout |
121 | - if layout == (1,1): | 123 | + if (layout == (1,1)) and self.on_text: |
122 | self.ShowTextActors() | 124 | self.ShowTextActors() |
123 | else: | 125 | else: |
124 | - self.HideTextActors() | 126 | + self.HideTextActors(change_status=False) |
125 | 127 | ||
126 | slice_ = sl.Slice() | 128 | slice_ = sl.Slice() |
127 | self.LoadRenderers(slice_.GetOutput()) | 129 | self.LoadRenderers(slice_.GetOutput()) |
128 | self.__configure_renderers() | 130 | self.__configure_renderers() |
129 | self.__configure_scroll() | 131 | self.__configure_scroll() |
130 | 132 | ||
131 | - def HideTextActors(self): | 133 | + def HideTextActors(self, change_status=True): |
132 | self.wl_text.Hide() | 134 | self.wl_text.Hide() |
133 | [t.Hide() for t in self.orientation_texts] | 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 | def ShowTextActors(self): | 140 | def ShowTextActors(self): |
136 | - self.wl_text.Show() | 141 | + if self.on_wl: |
142 | + self.wl_text.Show() | ||
137 | [t.Show() for t in self.orientation_texts] | 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 | def __set_layout(self, pubsub_evt): | 149 | def __set_layout(self, pubsub_evt): |
@@ -204,6 +212,13 @@ class Viewer(wx.Panel): | @@ -204,6 +212,13 @@ class Viewer(wx.Panel): | ||
204 | else: | 212 | else: |
205 | self.__set_cross_visibility(0) | 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 | self.__set_editor_cursor_visibility(0) | 222 | self.__set_editor_cursor_visibility(0) |
208 | 223 | ||
209 | 224 | ||
@@ -807,6 +822,21 @@ class Viewer(wx.Panel): | @@ -807,6 +822,21 @@ class Viewer(wx.Panel): | ||
807 | 'Set slice interaction style') | 822 | 'Set slice interaction style') |
808 | ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') | 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 | def OnCloseProject(self, pubsub_evt): | 840 | def OnCloseProject(self, pubsub_evt): |
811 | self.CloseProject() | 841 | self.CloseProject() |
812 | 842 |
invesalius/data/viewer_volume.py
@@ -69,6 +69,8 @@ class Viewer(wx.Panel): | @@ -69,6 +69,8 @@ class Viewer(wx.Panel): | ||
69 | self.onclick = False | 69 | self.onclick = False |
70 | 70 | ||
71 | self.text = vtku.Text() | 71 | self.text = vtku.Text() |
72 | + self.text.SetValue("") | ||
73 | + self.ren.AddActor(self.text.actor) | ||
72 | 74 | ||
73 | self.view_angle = None | 75 | self.view_angle = None |
74 | 76 | ||
@@ -76,6 +78,7 @@ class Viewer(wx.Panel): | @@ -76,6 +78,7 @@ class Viewer(wx.Panel): | ||
76 | self.__bind_events_wx() | 78 | self.__bind_events_wx() |
77 | 79 | ||
78 | self.mouse_pressed = 0 | 80 | self.mouse_pressed = 0 |
81 | + self.on_wl = False | ||
79 | 82 | ||
80 | def __bind_events(self): | 83 | def __bind_events(self): |
81 | ps.Publisher().subscribe(self.LoadActor, | 84 | ps.Publisher().subscribe(self.LoadActor, |
@@ -153,6 +156,15 @@ class Viewer(wx.Panel): | @@ -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 | if (state == const.STATE_ZOOM_SL): | 168 | if (state == const.STATE_ZOOM_SL): |
157 | style = vtk.vtkInteractorStyleRubberBandZoom() | 169 | style = vtk.vtkInteractorStyleRubberBandZoom() |
158 | self.interactor.SetInteractorStyle(style) | 170 | self.interactor.SetInteractorStyle(style) |
@@ -322,7 +334,8 @@ class Viewer(wx.Panel): | @@ -322,7 +334,8 @@ class Viewer(wx.Panel): | ||
322 | 334 | ||
323 | def OnShowRaycasting(self, pubsub_evt): | 335 | def OnShowRaycasting(self, pubsub_evt): |
324 | self.raycasting_volume = True | 336 | self.raycasting_volume = True |
325 | - self.text.Show() | 337 | + if self.on_wl: |
338 | + self.text.Show() | ||
326 | 339 | ||
327 | def OnHideRaycasting(self, pubsub_evt): | 340 | def OnHideRaycasting(self, pubsub_evt): |
328 | self.raycasting_volume = False | 341 | self.raycasting_volume = False |
@@ -370,7 +383,7 @@ class Viewer(wx.Panel): | @@ -370,7 +383,7 @@ class Viewer(wx.Panel): | ||
370 | 383 | ||
371 | self.ren.AddVolume(volume) | 384 | self.ren.AddVolume(volume) |
372 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) | 385 | self.text.SetValue("WL: %d WW: %d"%(wl, ww)) |
373 | - self.ren.AddActor(self.text.actor) | 386 | + |
374 | self.ren.SetBackground(colour) | 387 | self.ren.SetBackground(colour) |
375 | 388 | ||
376 | if not (self.view_angle): | 389 | if not (self.view_angle): |
invesalius/gui/frame.py
@@ -825,9 +825,9 @@ class LayoutToolBar(wx.ToolBar): | @@ -825,9 +825,9 @@ class LayoutToolBar(wx.ToolBar): | ||
825 | 825 | ||
826 | def OnText(self, event): | 826 | def OnText(self, event): |
827 | if event.IsChecked(): | 827 | if event.IsChecked(): |
828 | - print "TODO: Send message so all textactors are shown" | 828 | + ps.Publisher().sendMessage('Show text actors on viewers') |
829 | else: | 829 | else: |
830 | - print "TODO: Send message so all textactors are hiden" | 830 | + ps.Publisher().sendMessage('Hide text actors on viewers') |
831 | 831 | ||
832 | def SetLayoutButtonOnlyData(self, pubsub_evt): | 832 | def SetLayoutButtonOnlyData(self, pubsub_evt): |
833 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) | 833 | self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) |