Commit 4701ce10df1ca19c7bfa2d483f94e183d89c2726
1 parent
5de709ee
Exists in
master
and in
68 other branches
ENH: Removing curve from clut raycasting widget
Showing
5 changed files
with
34 additions
and
15 deletions
Show diff stats
invesalius/constants.py
@@ -161,7 +161,7 @@ WINDOW_LEVEL = {"Abdomen":(350,50), | @@ -161,7 +161,7 @@ WINDOW_LEVEL = {"Abdomen":(350,50), | ||
161 | "Vasculature - Hard":(240,80), | 161 | "Vasculature - Hard":(240,80), |
162 | "Vasculature - Soft":(650,160)} | 162 | "Vasculature - Soft":(650,160)} |
163 | 163 | ||
164 | -REDUCE_IMAGEDATA_QUALITY = 1 | 164 | +REDUCE_IMAGEDATA_QUALITY = 0 |
165 | 165 | ||
166 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper | 166 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
167 | TYPE_RAYCASTING_MAPPER = 0 | 167 | TYPE_RAYCASTING_MAPPER = 0 |
invesalius/data/viewer_slice.py
@@ -66,7 +66,7 @@ class Viewer(wx.Panel): | @@ -66,7 +66,7 @@ class Viewer(wx.Panel): | ||
66 | self.text = None | 66 | self.text = None |
67 | # VTK pipeline and actors | 67 | # VTK pipeline and actors |
68 | #self.__config_interactor() | 68 | #self.__config_interactor() |
69 | - self.pick = vtk.vtkWorldPointPicker() | 69 | + self.pick = vtk.vtkPropPicker() |
70 | 70 | ||
71 | self.__bind_events() | 71 | self.__bind_events() |
72 | self.__bind_events_wx() | 72 | self.__bind_events_wx() |
invesalius/data/volume.py
@@ -140,11 +140,6 @@ class Volume(): | @@ -140,11 +140,6 @@ class Volume(): | ||
140 | if self.config['advancedCLUT']: | 140 | if self.config['advancedCLUT']: |
141 | self.Create16bColorTable(self.scale) | 141 | self.Create16bColorTable(self.scale) |
142 | self.CreateOpacityTable(self.scale) | 142 | self.CreateOpacityTable(self.scale) |
143 | - self.CalculateWWWL() | ||
144 | - ww = self.ww | ||
145 | - wl = self.wl | ||
146 | - ps.Publisher().sendMessage('Set volume window and level text', | ||
147 | - (ww, wl)) | ||
148 | else: | 143 | else: |
149 | self.Create8bColorTable(self.scale) | 144 | self.Create8bColorTable(self.scale) |
150 | self.Create8bOpacityTable(self.scale) | 145 | self.Create8bOpacityTable(self.scale) |
@@ -225,7 +220,11 @@ class Volume(): | @@ -225,7 +220,11 @@ class Volume(): | ||
225 | """ | 220 | """ |
226 | Get the window width & level from the selected curve | 221 | Get the window width & level from the selected curve |
227 | """ | 222 | """ |
228 | - curve = self.config['16bitClutCurves'][self.curve] | 223 | + try: |
224 | + curve = self.config['16bitClutCurves'][self.curve] | ||
225 | + except IndexError: | ||
226 | + self.curve -= 1 | ||
227 | + curve = self.config['16bitClutCurves'][self.curve] | ||
229 | first_point = curve[0]['x'] | 228 | first_point = curve[0]['x'] |
230 | last_point = curve[-1]['x'] | 229 | last_point = curve[-1]['x'] |
231 | self.ww = last_point - first_point | 230 | self.ww = last_point - first_point |
invesalius/gui/default_viewers.py
@@ -240,6 +240,10 @@ class VolumeInteraction(wx.Panel): | @@ -240,6 +240,10 @@ class VolumeInteraction(wx.Panel): | ||
240 | ps.Publisher().subscribe( self.RefreshPoints, | 240 | ps.Publisher().subscribe( self.RefreshPoints, |
241 | 'Refresh raycasting widget points') | 241 | 'Refresh raycasting widget points') |
242 | 242 | ||
243 | + def __update_curve_wwwl_text(self, curve): | ||
244 | + ww, wl = self.clut_raycasting.GetCurveWWWl(curve) | ||
245 | + ps.Publisher().sendMessage('Set raycasting wwwl', (ww, wl, curve)) | ||
246 | + | ||
243 | def ShowRaycastingWidget(self, evt_pubsub=None): | 247 | def ShowRaycastingWidget(self, evt_pubsub=None): |
244 | self.can_show_raycasting_widget = 1 | 248 | self.can_show_raycasting_widget = 1 |
245 | if self.clut_raycasting.to_draw_points: | 249 | if self.clut_raycasting.to_draw_points: |
@@ -254,9 +258,10 @@ class VolumeInteraction(wx.Panel): | @@ -254,9 +258,10 @@ class VolumeInteraction(wx.Panel): | ||
254 | self.aui_manager.Update() | 258 | self.aui_manager.Update() |
255 | 259 | ||
256 | def OnPointChanged(self, evt): | 260 | def OnPointChanged(self, evt): |
261 | + print "Removed" | ||
257 | ps.Publisher.sendMessage('Set raycasting refresh', None) | 262 | ps.Publisher.sendMessage('Set raycasting refresh', None) |
258 | ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | 263 | ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) |
259 | - ps.Publisher().sendMessage('Render volume viewer', None) | 264 | + ps.Publisher().sendMessage('Render volume viewer') |
260 | 265 | ||
261 | def OnCurveSelected(self, evt): | 266 | def OnCurveSelected(self, evt): |
262 | ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) | 267 | ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) |
@@ -264,8 +269,7 @@ class VolumeInteraction(wx.Panel): | @@ -264,8 +269,7 @@ class VolumeInteraction(wx.Panel): | ||
264 | 269 | ||
265 | def OnChangeCurveWL(self, evt): | 270 | def OnChangeCurveWL(self, evt): |
266 | curve = evt.GetCurve() | 271 | curve = evt.GetCurve() |
267 | - ww, wl = self.clut_raycasting.GetCurveWWWl(curve) | ||
268 | - ps.Publisher().sendMessage('Set raycasting wwwl', (ww, wl, curve)) | 272 | + self.__update_curve_wwwl_text(curve) |
269 | ps.Publisher().sendMessage('Render volume viewer') | 273 | ps.Publisher().sendMessage('Render volume viewer') |
270 | 274 | ||
271 | def OnSetRaycastPreset(self, evt_pubsub): | 275 | def OnSetRaycastPreset(self, evt_pubsub): |
invesalius/gui/widgets/clut_raycasting.py
@@ -176,6 +176,13 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -176,6 +176,13 @@ class CLUTRaycastingWidget(wx.Panel): | ||
176 | nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i) | 176 | nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i) |
177 | self.GetEventHandler().ProcessEvent(nevt) | 177 | self.GetEventHandler().ProcessEvent(nevt) |
178 | return | 178 | return |
179 | + n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple()) | ||
180 | + if n_curve is not None: | ||
181 | + print "Removing a curve" | ||
182 | + self.RemoveCurve(n_curve) | ||
183 | + self.Refresh() | ||
184 | + nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), n_curve) | ||
185 | + self.GetEventHandler().ProcessEvent(nevt) | ||
179 | evt.Skip() | 186 | evt.Skip() |
180 | 187 | ||
181 | def OnRelease(self, evt): | 188 | def OnRelease(self, evt): |
@@ -339,11 +346,20 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -339,11 +346,20 @@ class CLUTRaycastingWidget(wx.Panel): | ||
339 | self.point_dragged = (new_i, new_j) | 346 | self.point_dragged = (new_i, new_j) |
340 | # Can't have only one point in the curve | 347 | # Can't have only one point in the curve |
341 | if len(self.points[i]) == 1: | 348 | if len(self.points[i]) == 1: |
342 | - self.points.pop(i) | ||
343 | - self.colours.pop(i) | ||
344 | - self.point_dragged = None | 349 | + self.RemoveCurve(i) |
350 | + else: | ||
351 | + curve = self.curves[i] | ||
352 | + curve.CalculateWWWl() | ||
353 | + curve.wl_px = (self.HounsfieldToPixel(curve.wl), | ||
354 | + self.OpacityToPixel(0)) | ||
355 | + | ||
356 | + def RemoveCurve(self, n_curve): | ||
357 | + self.points.pop(n_curve) | ||
358 | + self.colours.pop(n_curve) | ||
359 | + self.point_dragged = None | ||
360 | + | ||
361 | + self.curves.pop(n_curve) | ||
345 | 362 | ||
346 | - self.curves.pop(i) | ||
347 | 363 | ||
348 | def _draw_gradient(self, ctx, height): | 364 | def _draw_gradient(self, ctx, height): |
349 | #The gradient | 365 | #The gradient |