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