Commit aad0e7dae7087c9336195db585bc34d31aff1883

Authored by Thiago Franco de Moraes
1 parent 0b283dbe
Exists in phoenix

graphs

invesalius/data/viewer_slice.py
@@ -196,7 +196,10 @@ class CanvasRendererCTX: @@ -196,7 +196,10 @@ class CanvasRendererCTX:
196 self.rgb = np.zeros((h, w, 3), dtype=np.uint8) 196 self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
197 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 197 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
198 198
199 - self.bitmap = wx.EmptyBitmapRGBA(w, h) 199 + try:
  200 + self.bitmap = wx.Bitmap.FromRGBA(w, h)
  201 + except AttributeError:
  202 + self.bitmap = wx.EmptyBitmapRGBA(w, h)
200 self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha.data) 203 self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha.data)
201 204
202 def _resize_canvas(self, w, h): 205 def _resize_canvas(self, w, h):
@@ -208,7 +211,10 @@ class CanvasRendererCTX: @@ -208,7 +211,10 @@ class CanvasRendererCTX:
208 self.rgb = np.zeros((h, w, 3), dtype=np.uint8) 211 self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
209 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 212 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
210 213
211 - self.bitmap = wx.EmptyBitmapRGBA(w, h) 214 + try:
  215 + self.bitmap = wx.Bitmap.FromRGBA(w, h)
  216 + except AttributeError:
  217 + self.bitmap = wx.EmptyBitmapRGBA(w, h)
212 self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha.data) 218 self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha.data)
213 219
214 self.modified = True 220 self.modified = True
@@ -288,7 +294,7 @@ class CanvasRendererCTX: @@ -288,7 +294,7 @@ class CanvasRendererCTX:
288 w, h = gc.GetTextExtent(text) 294 w, h = gc.GetTextExtent(text)
289 return w, h 295 return w, h
290 296
291 - def draw_line(self, pos0, pos1, arrow_start=False, arrow_end=False, colour=(255, 0, 0, 128), width=2, style=wx.SOLID): 297 + def draw_line(self, pos0, pos1, arrow_start=False, arrow_end=False, colour=(255, 0, 0, 0.5), width=2, style=wx.SOLID):
292 """ 298 """
293 Draw a line from pos0 to pos1 299 Draw a line from pos0 to pos1
294 300
@@ -311,7 +317,7 @@ class CanvasRendererCTX: @@ -311,7 +317,7 @@ class CanvasRendererCTX:
311 p0y = -p0y 317 p0y = -p0y
312 p1y = -p1y 318 p1y = -p1y
313 319
314 - pen = wx.Pen(wx.Colour(*colour), width, wx.SOLID) 320 + pen = wx.Pen(wx.Colour(int(colour[0]), int(colour[1]), int(colour[2]), alpha=colour[3]), width, wx.SOLID)
315 pen.SetCap(wx.CAP_BUTT) 321 pen.SetCap(wx.CAP_BUTT)
316 gc.SetPen(pen) 322 gc.SetPen(pen)
317 323
@@ -372,7 +378,7 @@ class CanvasRendererCTX: @@ -372,7 +378,7 @@ class CanvasRendererCTX:
372 return None 378 return None
373 gc = self.gc 379 gc = self.gc
374 380
375 - pen = wx.Pen(wx.Colour(*line_colour), width, wx.SOLID) 381 + pen = wx.Pen(wx.Colour(int(line_colour[0]), int(line_colour[1]), int(line_colour[2]), alpha=line_colour[3]), width, wx.SOLID)
376 gc.SetPen(pen) 382 gc.SetPen(pen)
377 383
378 brush = wx.Brush(wx.Colour(*fill_colour)) 384 brush = wx.Brush(wx.Colour(*fill_colour))
@@ -403,7 +409,8 @@ class CanvasRendererCTX: @@ -403,7 +409,8 @@ class CanvasRendererCTX:
403 gc = self.gc 409 gc = self.gc
404 410
405 px, py = pos 411 px, py = pos
406 - gc.SetPen(wx.Pen(line_colour)) 412 + pen = wx.Pen(wx.Colour(int(line_colour[0]), int(line_colour[1]), int(line_colour[2]), alpha=line_colour[3]))
  413 + gc.SetPen(pen)
407 gc.SetBrush(wx.Brush(fill_colour)) 414 gc.SetBrush(wx.Brush(fill_colour))
408 gc.DrawRectangle(px, py, width, height) 415 gc.DrawRectangle(px, py, width, height)
409 self._drawn = True 416 self._drawn = True
@@ -481,7 +488,7 @@ class CanvasRendererCTX: @@ -481,7 +488,7 @@ class CanvasRendererCTX:
481 if self.gc is None: 488 if self.gc is None:
482 return None 489 return None
483 gc = self.gc 490 gc = self.gc
484 - pen = wx.Pen(wx.Colour(*line_colour), width, wx.SOLID) 491 + pen = wx.Pen(wx.Colour(int(line_colour[0]), int(line_colour[1]), int(line_colour[2]), alpha=line_colour[3]), width, wx.SOLID)
485 gc.SetPen(pen) 492 gc.SetPen(pen)
486 493
487 c = np.array(center) 494 c = np.array(center)
@@ -506,7 +513,7 @@ class CanvasRendererCTX: @@ -506,7 +513,7 @@ class CanvasRendererCTX:
506 ea = a0 513 ea = a0
507 514
508 path = gc.CreatePath() 515 path = gc.CreatePath()
509 - path.AddArc((c[0], c[1]), min(s0, s1), sa, ea) 516 + path.AddArc(float(c[0]), float(c[1]), float(min(s0, s1)), sa, ea, True)
510 gc.StrokePath(path) 517 gc.StrokePath(path)
511 self._drawn = True 518 self._drawn = True
512 519
invesalius/gui/task_navigator.py
@@ -29,6 +29,11 @@ except ImportError: @@ -29,6 +29,11 @@ except ImportError:
29 import wx.lib.masked.numctrl 29 import wx.lib.masked.numctrl
30 from wx.lib.pubsub import pub as Publisher 30 from wx.lib.pubsub import pub as Publisher
31 31
  32 +try:
  33 + from wx.lib.agw import foldpanelbar as fpb
  34 +except ImportError:
  35 + import wx.lib.foldpanelbar as fpb
  36 +
32 import invesalius.constants as const 37 import invesalius.constants as const
33 import invesalius.data.bases as db 38 import invesalius.data.bases as db
34 import invesalius.data.coordinates as dco 39 import invesalius.data.coordinates as dco
@@ -36,7 +41,6 @@ import invesalius.data.coregistration as dcr @@ -36,7 +41,6 @@ import invesalius.data.coregistration as dcr
36 import invesalius.data.trackers as dt 41 import invesalius.data.trackers as dt
37 import invesalius.data.trigger as trig 42 import invesalius.data.trigger as trig
38 import invesalius.gui.dialogs as dlg 43 import invesalius.gui.dialogs as dlg
39 -import invesalius.gui.widgets.foldpanelbar as fpb  
40 import invesalius.gui.widgets.colourselect as csel 44 import invesalius.gui.widgets.colourselect as csel
41 45
42 class TaskPanel(wx.Panel): 46 class TaskPanel(wx.Panel):
invesalius/gui/task_slice.py
@@ -29,6 +29,11 @@ import wx.lib.platebtn as pbtn @@ -29,6 +29,11 @@ import wx.lib.platebtn as pbtn
29 from wx.lib.pubsub import pub as Publisher 29 from wx.lib.pubsub import pub as Publisher
30 30
31 try: 31 try:
  32 + from wx.lib.agw import foldpanelbar as fpb
  33 +except ImportError:
  34 + import wx.lib.foldpanelbar as fpb
  35 +
  36 +try:
32 SystemSettings_GetColour = wx.SystemSettings.GetColour 37 SystemSettings_GetColour = wx.SystemSettings.GetColour
33 except AttributeError: 38 except AttributeError:
34 SystemSettings_GetColour = wx.SystemSettings_GetColour 39 SystemSettings_GetColour = wx.SystemSettings_GetColour
@@ -38,7 +43,6 @@ import invesalius.data.slice_ as slice_ @@ -38,7 +43,6 @@ import invesalius.data.slice_ as slice_
38 import invesalius.constants as const 43 import invesalius.constants as const
39 import invesalius.gui.dialogs as dlg 44 import invesalius.gui.dialogs as dlg
40 import invesalius.gui.widgets.gradient as grad 45 import invesalius.gui.widgets.gradient as grad
41 -import invesalius.gui.widgets.foldpanelbar as fpb  
42 import invesalius.gui.widgets.colourselect as csel 46 import invesalius.gui.widgets.colourselect as csel
43 47
44 from invesalius.project import Project 48 from invesalius.project import Project
@@ -276,7 +280,7 @@ class InnerFoldPanel(wx.Panel): @@ -276,7 +280,7 @@ class InnerFoldPanel(wx.Panel):
276 self.mask_prop_panel = MaskProperties(item) 280 self.mask_prop_panel = MaskProperties(item)
277 281
278 fold_panel.ApplyCaptionStyle(item, style) 282 fold_panel.ApplyCaptionStyle(item, style)
279 - fold_panel.AddFoldPanelWindow(item, self.mask_prop_panel, Spacing= 0, 283 + fold_panel.AddFoldPanelWindow(item, self.mask_prop_panel, spacing=0,
280 leftSpacing=0, rightSpacing=0) 284 leftSpacing=0, rightSpacing=0)
281 285
282 # Fold 2 - Advanced edition tools 286 # Fold 2 - Advanced edition tools
@@ -284,7 +288,7 @@ class InnerFoldPanel(wx.Panel): @@ -284,7 +288,7 @@ class InnerFoldPanel(wx.Panel):
284 etw = EditionTools(item) 288 etw = EditionTools(item)
285 289
286 fold_panel.ApplyCaptionStyle(item, style) 290 fold_panel.ApplyCaptionStyle(item, style)
287 - fold_panel.AddFoldPanelWindow(item, etw, Spacing= 0, 291 + fold_panel.AddFoldPanelWindow(item, etw, spacing=0,
288 leftSpacing=0, rightSpacing=0) 292 leftSpacing=0, rightSpacing=0)
289 self.__id_editor = item.GetId() 293 self.__id_editor = item.GetId()
290 self.last_panel_opened = None 294 self.last_panel_opened = None
@@ -294,7 +298,7 @@ class InnerFoldPanel(wx.Panel): @@ -294,7 +298,7 @@ class InnerFoldPanel(wx.Panel):
294 wtw = WatershedTool(item) 298 wtw = WatershedTool(item)
295 299
296 fold_panel.ApplyCaptionStyle(item, style) 300 fold_panel.ApplyCaptionStyle(item, style)
297 - fold_panel.AddFoldPanelWindow(item, wtw, Spacing= 0, 301 + fold_panel.AddFoldPanelWindow(item, wtw, spacing=0,
298 leftSpacing=0, rightSpacing=0) 302 leftSpacing=0, rightSpacing=0)
299 self.__id_watershed = item.GetId() 303 self.__id_watershed = item.GetId()
300 304
invesalius/gui/task_surface.py
@@ -25,6 +25,17 @@ try: @@ -25,6 +25,17 @@ try:
25 except ImportError: 25 except ImportError:
26 import wx.lib.hyperlink as hl 26 import wx.lib.hyperlink as hl
27 from wx.lib.pubsub import pub as Publisher 27 from wx.lib.pubsub import pub as Publisher
  28 +import wx.lib.platebtn as pbtn
  29 +
  30 +try:
  31 + from wx.lib.agw import foldpanelbar as fpb
  32 +except ImportError:
  33 + import wx.lib.foldpanelbar as fpb
  34 +
  35 +try:
  36 + from wx.lib.agw import foldpanelbar as fpb
  37 +except ImportError:
  38 + import wx.lib.foldpanelbar as fpb
28 39
29 try: 40 try:
30 SystemSettings_GetColour = wx.SystemSettings.GetColour 41 SystemSettings_GetColour = wx.SystemSettings.GetColour
@@ -34,9 +45,7 @@ except AttributeError: @@ -34,9 +45,7 @@ except AttributeError:
34 import invesalius.constants as const 45 import invesalius.constants as const
35 import invesalius.data.slice_ as slice_ 46 import invesalius.data.slice_ as slice_
36 import invesalius.gui.dialogs as dlg 47 import invesalius.gui.dialogs as dlg
37 -import invesalius.gui.widgets.foldpanelbar as fpb  
38 import invesalius.gui.widgets.colourselect as csel 48 import invesalius.gui.widgets.colourselect as csel
39 -import invesalius.gui.widgets.platebtn as pbtn  
40 import invesalius.project as prj 49 import invesalius.project as prj
41 import invesalius.utils as utl 50 import invesalius.utils as utl
42 51
@@ -224,13 +233,13 @@ class InnerFoldPanel(wx.Panel): @@ -224,13 +233,13 @@ class InnerFoldPanel(wx.Panel):
224 # Fold 1 - Surface properties 233 # Fold 1 - Surface properties
225 item = fold_panel.AddFoldPanel(_("Surface properties"), collapsed=True) 234 item = fold_panel.AddFoldPanel(_("Surface properties"), collapsed=True)
226 fold_panel.ApplyCaptionStyle(item, style) 235 fold_panel.ApplyCaptionStyle(item, style)
227 - fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), Spacing= 0, 236 + fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), spacing=0,
228 leftSpacing=0, rightSpacing=0) 237 leftSpacing=0, rightSpacing=0)
229 238
230 # Fold 2 - Surface tools 239 # Fold 2 - Surface tools
231 item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True) 240 item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True)
232 fold_panel.ApplyCaptionStyle(item, style) 241 fold_panel.ApplyCaptionStyle(item, style)
233 - fold_panel.AddFoldPanelWindow(item, SurfaceTools(item), Spacing= 0, 242 + fold_panel.AddFoldPanelWindow(item, SurfaceTools(item), spacing=0,
234 leftSpacing=0, rightSpacing=0) 243 leftSpacing=0, rightSpacing=0)
235 244
236 #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0, 245 #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0,
invesalius/gui/widgets/clut_raycasting.py
@@ -169,8 +169,8 @@ class CLUTRaycastingWidget(wx.Panel): @@ -169,8 +169,8 @@ class CLUTRaycastingWidget(wx.Panel):
169 pass 169 pass
170 170
171 def OnClick(self, evt): 171 def OnClick(self, evt):
172 - x, y = evt.GetPositionTuple()  
173 - if self.save_button.HasClicked(evt.GetPositionTuple()): 172 + x, y = evt.GetPosition()
  173 + if self.save_button.HasClicked(evt.GetPosition()):
174 print "Salvando" 174 print "Salvando"
175 filename = dialog.ShowSavePresetDialog() 175 filename = dialog.ShowSavePresetDialog()
176 if filename: 176 if filename:
@@ -218,7 +218,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -218,7 +218,7 @@ class CLUTRaycastingWidget(wx.Panel):
218 """ 218 """
219 Used to change the colour of a point 219 Used to change the colour of a point
220 """ 220 """
221 - point = self._has_clicked_in_a_point(evt.GetPositionTuple()) 221 + point = self._has_clicked_in_a_point(evt.GetPosition())
222 if point: 222 if point:
223 i, j = point 223 i, j = point
224 actual_colour = self.curves[i].nodes[j].colour 224 actual_colour = self.curves[i].nodes[j].colour
@@ -240,7 +240,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -240,7 +240,7 @@ class CLUTRaycastingWidget(wx.Panel):
240 """ 240 """
241 Used to remove a point 241 Used to remove a point
242 """ 242 """
243 - point = self._has_clicked_in_a_point(evt.GetPositionTuple()) 243 + point = self._has_clicked_in_a_point(evt.GetPosition())
244 if point: 244 if point:
245 i, j = point 245 i, j = point
246 print "RightClick", i, j 246 print "RightClick", i, j
@@ -249,7 +249,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -249,7 +249,7 @@ class CLUTRaycastingWidget(wx.Panel):
249 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i) 249 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i)
250 self.GetEventHandler().ProcessEvent(nevt) 250 self.GetEventHandler().ProcessEvent(nevt)
251 return 251 return
252 - n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple()) 252 + n_curve = self._has_clicked_in_selection_curve(evt.GetPosition())
253 if n_curve is not None: 253 if n_curve is not None:
254 print "Removing a curve" 254 print "Removing a curve"
255 self.RemoveCurve(n_curve) 255 self.RemoveCurve(n_curve)
@@ -383,7 +383,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -383,7 +383,7 @@ class CLUTRaycastingWidget(wx.Panel):
383 self.to_render = True 383 self.to_render = True
384 i,j = self.point_dragged 384 i,j = self.point_dragged
385 385
386 - width, height= self.GetVirtualSizeTuple() 386 + width, height= self.GetVirtualSize()
387 387
388 if y >= height - self.padding: 388 if y >= height - self.padding:
389 y = height - self.padding 389 y = height - self.padding
@@ -525,7 +525,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -525,7 +525,7 @@ class CLUTRaycastingWidget(wx.Panel):
525 x,y = node.x, node.y 525 x,y = node.x, node.y
526 value = node.graylevel 526 value = node.graylevel
527 alpha = node.opacity 527 alpha = node.opacity
528 - widget_width, widget_height = self.GetVirtualSizeTuple() 528 + widget_width, widget_height = self.GetVirtualSize()
529 529
530 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) 530 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
531 font.SetWeight(wx.BOLD) 531 font.SetWeight(wx.BOLD)
@@ -600,7 +600,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -600,7 +600,7 @@ class CLUTRaycastingWidget(wx.Panel):
600 600
601 def Render(self, dc): 601 def Render(self, dc):
602 ctx = wx.GraphicsContext.Create(dc) 602 ctx = wx.GraphicsContext.Create(dc)
603 - width, height= self.GetVirtualSizeTuple() 603 + width, height= self.GetVirtualSize()
604 height -= (self.padding * 2) 604 height -= (self.padding * 2)
605 width -= self.padding 605 width -= self.padding
606 606
@@ -614,7 +614,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -614,7 +614,7 @@ class CLUTRaycastingWidget(wx.Panel):
614 self._draw_selected_point_text(ctx) 614 self._draw_selected_point_text(ctx)
615 615
616 def _build_histogram(self): 616 def _build_histogram(self):
617 - width, height = self.GetVirtualSizeTuple() 617 + width, height = self.GetVirtualSize()
618 width -= self.padding 618 width -= self.padding
619 height -= (self.padding * 2) 619 height -= (self.padding * 2)
620 x_init = self.Histogram.init 620 x_init = self.Histogram.init
@@ -684,7 +684,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -684,7 +684,7 @@ class CLUTRaycastingWidget(wx.Panel):
684 """ 684 """
685 Given a Hounsfield point returns a pixel point in the canvas. 685 Given a Hounsfield point returns a pixel point in the canvas.
686 """ 686 """
687 - width,height = self.GetVirtualSizeTuple() 687 + width,height = self.GetVirtualSize()
688 width -= (TOOLBAR_SIZE) 688 width -= (TOOLBAR_SIZE)
689 proportion = width * 1.0 / (self.end - self.init) 689 proportion = width * 1.0 / (self.end - self.init)
690 x = (graylevel - self.init) * proportion + TOOLBAR_SIZE 690 x = (graylevel - self.init) * proportion + TOOLBAR_SIZE
@@ -694,7 +694,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -694,7 +694,7 @@ class CLUTRaycastingWidget(wx.Panel):
694 """ 694 """
695 Given a Opacity point returns a pixel point in the canvas. 695 Given a Opacity point returns a pixel point in the canvas.
696 """ 696 """
697 - width,height = self.GetVirtualSizeTuple() 697 + width,height = self.GetVirtualSize()
698 height -= (self.padding * 2) 698 height -= (self.padding * 2)
699 y = height - (opacity * height) + self.padding 699 y = height - (opacity * height) + self.padding
700 return y 700 return y
@@ -703,7 +703,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -703,7 +703,7 @@ class CLUTRaycastingWidget(wx.Panel):
703 """ 703 """
704 Translate from pixel point to Hounsfield scale. 704 Translate from pixel point to Hounsfield scale.
705 """ 705 """
706 - width, height= self.GetVirtualSizeTuple() 706 + width, height= self.GetVirtualSize()
707 width -= (TOOLBAR_SIZE) 707 width -= (TOOLBAR_SIZE)
708 proportion = width * 1.0 / (self.end - self.init) 708 proportion = width * 1.0 / (self.end - self.init)
709 graylevel = (x - TOOLBAR_SIZE) / proportion - abs(self.init) 709 graylevel = (x - TOOLBAR_SIZE) / proportion - abs(self.init)
@@ -713,7 +713,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -713,7 +713,7 @@ class CLUTRaycastingWidget(wx.Panel):
713 """ 713 """
714 Translate from pixel point to opacity. 714 Translate from pixel point to opacity.
715 """ 715 """
716 - width, height= self.GetVirtualSizeTuple() 716 + width, height= self.GetVirtualSize()
717 height -= (self.padding * 2) 717 height -= (self.padding * 2)
718 opacity = (height - y + self.padding) * 1.0 / height 718 opacity = (height - y + self.padding) * 1.0 / height
719 return opacity 719 return opacity
invesalius/gui/widgets/gradient.py
@@ -134,10 +134,10 @@ class GradientSlider(wx.Panel): @@ -134,10 +134,10 @@ class GradientSlider(wx.Panel):
134 # Drawing the transparent slider. 134 # Drawing the transparent slider.
135 bytes = numpy.array(self.colour * width_transparency * h, 'B') 135 bytes = numpy.array(self.colour * width_transparency * h, 'B')
136 try: 136 try:
  137 + slider = wx.Bitmap.FromBufferRGBA(width_transparency, h, bytes)
  138 + dc.DrawBitmap(slider, self.min_position, 0, True)
  139 + except AttributeError:
137 slider = wx.BitmapFromBufferRGBA(width_transparency, h, bytes) 140 slider = wx.BitmapFromBufferRGBA(width_transparency, h, bytes)
138 - except:  
139 - pass  
140 - else:  
141 dc.DrawBitmap(slider, self.min_position, 0, True) 141 dc.DrawBitmap(slider, self.min_position, 0, True)
142 142
143 def OnEraseBackGround(self, evt): 143 def OnEraseBackGround(self, evt):