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