Commit 39171fc5d0cfe0f0955d44d823bbe0be9651fe7c

Authored by tfmoraes
1 parent b0529683

ENH: Plotting histogram in the clut widget

Showing 1 changed file with 10 additions and 8 deletions   Show diff stats
invesalius/gui/widgets/clut_raycasting.py
... ... @@ -34,7 +34,7 @@ class CLUTRaycastingWidget(wx.Panel):
34 34 self.padding = 10
35 35 self.to_render = False
36 36 self.histogram_pixel_points = [[0,0]]
37   - self.histogram_array = [[100,100],[100,100]]
  37 + self.histogram_array = [100,100]
38 38 self.CreatePixelArray()
39 39 #self.sizer = wx.BoxSizer(wx.HORIZONTAL)
40 40 #self.SetSizer(self.sizer)
... ... @@ -293,6 +293,7 @@ class CLUTRaycastingWidget(wx.Panel):
293 293 x,y = self.histogram_pixel_points[0]
294 294 print "=>", x,y
295 295 ctx.move_to(x,y)
  296 + ctx.set_line_width(0.5)
296 297 for x,y in self.histogram_pixel_points:
297 298 ctx.line_to(x,y)
298 299 ctx.stroke()
... ... @@ -313,6 +314,7 @@ class CLUTRaycastingWidget(wx.Panel):
313 314 height -= self.padding
314 315 width -= self.padding
315 316  
  317 + self._draw_histogram(ctx)
316 318 self._draw_gradient(ctx, height)
317 319 self._draw_curves(ctx)
318 320 self._draw_points(ctx)
... ... @@ -326,17 +328,17 @@ class CLUTRaycastingWidget(wx.Panel):
326 328 width -= self.padding
327 329 height -= self.padding
328 330 y_init = 0
329   - y_end = max(self.histogram_array[0])
  331 + y_end = max(self.histogram_array)
  332 + print y_end
330 333 proportion_x = width * 1.0 / (self.end - self.init)
331 334 proportion_y = height * 1.0 / (y_end - y_init)
332 335 print ":) ", y_end, proportion_y
333 336 self.histogram_pixel_points = []
334   - for i in xrange(len(self.histogram_array[0])):
335   - x = self.histogram_array[1][i]
336   - y = self.histogram_array[0][i]
337   - print x, y
  337 + for i in xrange(len(self.histogram_array)):
  338 + y = self.histogram_array[i]
  339 + x = self.init+ i
338 340 x = (x + abs(self.init)) * proportion_x
339   - y = height - (y + abs(y_init)) * proportion_y
  341 + y = height - y * proportion_y
340 342 self.histogram_pixel_points.append((x, y))
341 343  
342 344  
... ... @@ -344,7 +346,7 @@ class CLUTRaycastingWidget(wx.Panel):
344 346 self.pixels_points = []
345 347 for curve in self.points:
346 348 self.pixels_points.append([self.HounsfieldToPixel(i) for i in curve])
347   - #self._build_histogram()
  349 + self._build_histogram()
348 350  
349 351 def HounsfieldToPixel(self, h_pt):
350 352 """
... ...