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 | 161 | "Vasculature - Hard":(240,80), |
162 | 162 | "Vasculature - Soft":(650,160)} |
163 | 163 | |
164 | -REDUCE_IMAGEDATA_QUALITY = 1 | |
164 | +REDUCE_IMAGEDATA_QUALITY = 0 | |
165 | 165 | |
166 | 166 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
167 | 167 | TYPE_RAYCASTING_MAPPER = 0 | ... | ... |
invesalius/data/viewer_slice.py
invesalius/data/volume.py
... | ... | @@ -140,11 +140,6 @@ class Volume(): |
140 | 140 | if self.config['advancedCLUT']: |
141 | 141 | self.Create16bColorTable(self.scale) |
142 | 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 | 143 | else: |
149 | 144 | self.Create8bColorTable(self.scale) |
150 | 145 | self.Create8bOpacityTable(self.scale) |
... | ... | @@ -225,7 +220,11 @@ class Volume(): |
225 | 220 | """ |
226 | 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 | 228 | first_point = curve[0]['x'] |
230 | 229 | last_point = curve[-1]['x'] |
231 | 230 | self.ww = last_point - first_point | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -240,6 +240,10 @@ class VolumeInteraction(wx.Panel): |
240 | 240 | ps.Publisher().subscribe( self.RefreshPoints, |
241 | 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 | 247 | def ShowRaycastingWidget(self, evt_pubsub=None): |
244 | 248 | self.can_show_raycasting_widget = 1 |
245 | 249 | if self.clut_raycasting.to_draw_points: |
... | ... | @@ -254,9 +258,10 @@ class VolumeInteraction(wx.Panel): |
254 | 258 | self.aui_manager.Update() |
255 | 259 | |
256 | 260 | def OnPointChanged(self, evt): |
261 | + print "Removed" | |
257 | 262 | ps.Publisher.sendMessage('Set raycasting refresh', None) |
258 | 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 | 266 | def OnCurveSelected(self, evt): |
262 | 267 | ps.Publisher.sendMessage('Set raycasting curve', evt.GetCurve()) |
... | ... | @@ -264,8 +269,7 @@ class VolumeInteraction(wx.Panel): |
264 | 269 | |
265 | 270 | def OnChangeCurveWL(self, evt): |
266 | 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 | 273 | ps.Publisher().sendMessage('Render volume viewer') |
270 | 274 | |
271 | 275 | def OnSetRaycastPreset(self, evt_pubsub): | ... | ... |
invesalius/gui/widgets/clut_raycasting.py
... | ... | @@ -176,6 +176,13 @@ class CLUTRaycastingWidget(wx.Panel): |
176 | 176 | nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i) |
177 | 177 | self.GetEventHandler().ProcessEvent(nevt) |
178 | 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 | 186 | evt.Skip() |
180 | 187 | |
181 | 188 | def OnRelease(self, evt): |
... | ... | @@ -339,11 +346,20 @@ class CLUTRaycastingWidget(wx.Panel): |
339 | 346 | self.point_dragged = (new_i, new_j) |
340 | 347 | # Can't have only one point in the curve |
341 | 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 | 364 | def _draw_gradient(self, ctx, height): |
349 | 365 | #The gradient | ... | ... |