Commit 494bb5b0f8509484ecc8ac70a5eb845abe71731e

Authored by Paulo Henrique Junqueira Amorim
1 parent 19abbab5

FIX: Fixed problem in resize box (Windows)

Showing 1 changed file with 15 additions and 4 deletions   Show diff stats
invesalius/data/viewer_slice.py
... ... @@ -31,6 +31,7 @@ from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
31 31 import styles
32 32  
33 33 import wx
  34 +import sys
34 35 from wx.lib.pubsub import pub as Publisher
35 36  
36 37 try:
... ... @@ -171,6 +172,7 @@ class CanvasRendererCTX:
171 172 self.gc = None
172 173 self.last_cam_modif_time = -1
173 174 self.modified = True
  175 + self._drawn = False
174 176 self._init_canvas()
175 177 evt_renderer.AddObserver("StartEvent", self.OnPaint)
176 178  
... ... @@ -248,21 +250,20 @@ class CanvasRendererCTX:
248 250 gc.SetBrush(brush)
249 251 gc.Scale(1, -1)
250 252  
251   - modified = False
252 253 for d in self.draw_list:
253 254 d.draw_to_canvas(gc, self)
254   - modified = True
255 255  
256 256 gc.Destroy()
257 257  
258 258 self.gc = None
259 259  
260   - if modified:
  260 + if self._drawn:
261 261 self.bitmap = self.image.ConvertToBitmap()
262 262 self.bitmap.CopyToBuffer(self._array, wx.BitmapBufferFormat_RGBA)
263 263  
264 264 self._cv_image.Modified()
265 265 self.modified = False
  266 + self._drawn = False
266 267  
267 268 def calc_text_size(self, text, font=None):
268 269 """
... ... @@ -355,6 +356,8 @@ class CanvasRendererCTX:
355 356 path.AddLineToPoint(p2)
356 357 gc.StrokePath(path)
357 358  
  359 + self._drawn = True
  360 +
358 361 def draw_circle(self, center, radius, width=2, line_colour=(255, 0, 0, 128), fill_colour=(0, 0, 0, 0)):
359 362 """
360 363 Draw a circle centered at center with the given radius.
... ... @@ -383,6 +386,7 @@ class CanvasRendererCTX:
383 386 path.AddCircle(cx, cy, 2.5)
384 387 gc.StrokePath(path)
385 388 gc.FillPath(path)
  389 + self._drawn = True
386 390  
387 391 def draw_rectangle(self, pos, width, height, line_colour=(255, 0, 0, 128), fill_colour=(0, 0, 0, 0)):
388 392 """
... ... @@ -403,6 +407,7 @@ class CanvasRendererCTX:
403 407 gc.SetPen(wx.Pen(line_colour))
404 408 gc.SetBrush(wx.Brush(fill_colour))
405 409 gc.DrawRectangle(px, py, width, height)
  410 + self._drawn = True
406 411  
407 412 def draw_text(self, text, pos, font=None, txt_colour=(255, 255, 255)):
408 413 """
... ... @@ -426,6 +431,7 @@ class CanvasRendererCTX:
426 431  
427 432 px, py = pos
428 433 gc.DrawText(text, px, py)
  434 + self._drawn = True
429 435  
430 436 def draw_text_box(self, text, pos, font=None, txt_colour=(255, 255, 255), bg_colour=(128, 128, 128, 128), border=5):
431 437 """
... ... @@ -460,6 +466,7 @@ class CanvasRendererCTX:
460 466 # Drawing the text
461 467 tpx, tpy = px + border, py + border
462 468 self.draw_text(text, (tpx, tpy), font, txt_colour)
  469 + self._drawn = True
463 470  
464 471 def draw_arc(self, center, p0, p1, line_colour=(255, 0, 0, 128), width=2):
465 472 """
... ... @@ -502,6 +509,7 @@ class CanvasRendererCTX:
502 509 path = gc.CreatePath()
503 510 path.AddArc((c[0], c[1]), min(s0, s1), sa, ea)
504 511 gc.StrokePath(path)
  512 + self._drawn = True
505 513  
506 514  
507 515 class Viewer(wx.Panel):
... ... @@ -1228,7 +1236,10 @@ class Viewer(wx.Panel):
1228 1236 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE))
1229 1237  
1230 1238 def SetSizeNWSECursor(self, pubsub_evt):
1231   - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE))
  1239 + if sys.platform == 'win32':
  1240 + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
  1241 + else:
  1242 + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE))
1232 1243  
1233 1244 def OnExportPicture(self, pubsub_evt):
1234 1245 Publisher.sendMessage('Begin busy cursor')
... ...