Commit 4e26411d23c552318b94e754bb547236d67b8a13

Authored by Thiago Franco de Moraes
1 parent 90e1222d

Created a method to draw line

invesalius/data/measures.py
@@ -582,12 +582,8 @@ class LinearMeasure(object): @@ -582,12 +582,8 @@ class LinearMeasure(object):
582 gc.FillPath(path) 582 gc.FillPath(path)
583 583
584 if len(lines) > 1: 584 if len(lines) > 1:
585 - path = gc.CreatePath()  
586 -  
587 - path.MoveToPoint(*lines[0])  
588 - for p in lines[1::]:  
589 - path.AddLineToPoint(*p)  
590 - gc.StrokePath(path) 585 + for (p0, p1) in zip(lines[:-1:], lines[1::]):
  586 + canvas.draw_line(p0, p1)
591 587
592 txt = u"%.3f mm" % self.GetValue() 588 txt = u"%.3f mm" % self.GetValue()
593 # gc.DrawText(txt, *lines[0]) 589 # gc.DrawText(txt, *lines[0])
@@ -852,10 +848,8 @@ class AngularMeasure(object): @@ -852,10 +848,8 @@ class AngularMeasure(object):
852 if len(lines) > 1: 848 if len(lines) > 1:
853 path = gc.CreatePath() 849 path = gc.CreatePath()
854 850
855 - path.MoveToPoint(*lines[0])  
856 - for p in lines[1::]:  
857 - path.AddLineToPoint(*p)  
858 - gc.StrokePath(path) 851 + for (p0, p1) in zip(lines[:-1:], lines[1::]):
  852 + canvas.draw_line(p0, p1)
859 853
860 if len(lines) == 3: 854 if len(lines) == 3:
861 txt = u"%.3f° / %.3f°" % (self.GetValue(), 360.0 - self.GetValue()) 855 txt = u"%.3f° / %.3f°" % (self.GetValue(), 360.0 - self.GetValue())
invesalius/data/viewer_slice.py
@@ -89,7 +89,7 @@ class ContourMIPConfig(wx.Panel): @@ -89,7 +89,7 @@ class ContourMIPConfig(wx.Panel):
89 " order to compound the" 89 " order to compound the"
90 " visualization instead of" 90 " visualization instead of"
91 " ascending order."))) 91 " ascending order.")))
92 - 92 +
93 txt_mip_size = wx.StaticText(self, -1, _("Number of slices"), style=wx.ALIGN_CENTER_HORIZONTAL) 93 txt_mip_size = wx.StaticText(self, -1, _("Number of slices"), style=wx.ALIGN_CENTER_HORIZONTAL)
94 self.txt_mip_border = wx.StaticText(self, -1, _("Sharpness")) 94 self.txt_mip_border = wx.StaticText(self, -1, _("Sharpness"))
95 95
@@ -113,7 +113,7 @@ class ContourMIPConfig(wx.Panel): @@ -113,7 +113,7 @@ class ContourMIPConfig(wx.Panel):
113 self.mip_size_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPSize) 113 self.mip_size_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPSize)
114 self.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder) 114 self.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder)
115 self.inverted.Bind(wx.EVT_CHECKBOX, self.OnCheckInverted) 115 self.inverted.Bind(wx.EVT_CHECKBOX, self.OnCheckInverted)
116 - 116 +
117 Publisher.subscribe(self._set_projection_type, 'Set projection type') 117 Publisher.subscribe(self._set_projection_type, 'Set projection type')
118 118
119 def OnSetMIPSize(self, evt): 119 def OnSetMIPSize(self, evt):
@@ -136,7 +136,7 @@ class ContourMIPConfig(wx.Panel): @@ -136,7 +136,7 @@ class ContourMIPConfig(wx.Panel):
136 self.inverted.Enable() 136 self.inverted.Enable()
137 else: 137 else:
138 self.inverted.Disable() 138 self.inverted.Disable()
139 - 139 +
140 if tprojection in (const.PROJECTION_CONTOUR_MIP, 140 if tprojection in (const.PROJECTION_CONTOUR_MIP,
141 const.PROJECTION_CONTOUR_MIDA): 141 const.PROJECTION_CONTOUR_MIDA):
142 self.border_spin.Enable() 142 self.border_spin.Enable()
@@ -233,7 +233,24 @@ class CanvasRendererCTX: @@ -233,7 +233,24 @@ class CanvasRendererCTX:
233 233
234 self._cv_image.Modified() 234 self._cv_image.Modified()
235 235
236 - def draw_text_box(self, text, pos, font=None, txt_colour=(0.0, 0.0, 0.0), bg_colour=(128, 0, 0, 128), border=5): 236 + def draw_line(self, pos0, pos1, colour=(255, 0, 0, 128), width=2, style=wx.SOLID):
  237 + """
  238 + Draw a line from pos0 to pos1
  239 + """
  240 + if self.gc is None:
  241 + return None
  242 + gc = self.gc
  243 +
  244 + pen = wx.Pen(wx.Colour(*colour), width, wx.SOLID)
  245 + gc.SetPen(pen)
  246 +
  247 + path = gc.CreatePath()
  248 + path.MoveToPoint(*pos0)
  249 + path.AddLineToPoint(*pos1)
  250 + gc.StrokePath(path)
  251 +
  252 +
  253 + def draw_text_box(self, text, pos, font=None, txt_colour=(255, 255, 255), bg_colour=(128, 128, 128, 128), border=5):
237 """ 254 """
238 Draw text inside a text box. 255 Draw text inside a text box.
239 256
@@ -281,7 +298,7 @@ class Viewer(wx.Panel): @@ -281,7 +298,7 @@ class Viewer(wx.Panel):
281 298
282 self._number_slices = const.PROJECTION_MIP_SIZE 299 self._number_slices = const.PROJECTION_MIP_SIZE
283 self._mip_inverted = False 300 self._mip_inverted = False
284 - 301 +
285 self.style = None 302 self.style = None
286 self.last_position_mouse_move = () 303 self.last_position_mouse_move = ()
287 self.state = const.STATE_DEFAULT 304 self.state = const.STATE_DEFAULT
@@ -354,7 +371,7 @@ class Viewer(wx.Panel): @@ -354,7 +371,7 @@ class Viewer(wx.Panel):
354 self.menu.caller = self 371 self.menu.caller = self
355 self.PopupMenu(self.menu) 372 self.PopupMenu(self.menu)
356 evt.Skip() 373 evt.Skip()
357 - 374 +
358 def SetPopupMenu(self, menu): 375 def SetPopupMenu(self, menu):
359 self.menu = menu 376 self.menu = menu
360 377
@@ -440,14 +457,14 @@ class Viewer(wx.Panel): @@ -440,14 +457,14 @@ class Viewer(wx.Panel):
440 (slc.window_width, slc.window_level)) 457 (slc.window_width, slc.window_level))
441 458
442 def SetWLText(self, window_width, window_level): 459 def SetWLText(self, window_width, window_level):
443 - value = STR_WL%(window_level, window_width) 460 + value = STR_WL%(window_level, window_width)
444 if (self.wl_text): 461 if (self.wl_text):
445 self.wl_text.SetValue(value) 462 self.wl_text.SetValue(value)
446 #self.interactor.Render() 463 #self.interactor.Render()
447 464
448 def EnableText(self): 465 def EnableText(self):
449 if not (self.wl_text): 466 if not (self.wl_text):
450 - proj = project.Project() 467 + proj = project.Project()
451 colour = const.ORIENTATION_COLOUR[self.orientation] 468 colour = const.ORIENTATION_COLOUR[self.orientation]
452 469
453 # Window & Level text 470 # Window & Level text
@@ -460,7 +477,7 @@ class Viewer(wx.Panel): @@ -460,7 +477,7 @@ class Viewer(wx.Panel):
460 values = [_('P'), _('A'), _('T'), _('B')] 477 values = [_('P'), _('A'), _('T'), _('B')]
461 else: 478 else:
462 values = [_('R'), _('L'), _('T'), _('B')] 479 values = [_('R'), _('L'), _('T'), _('B')]
463 - 480 +
464 left_text = self.left_text = vtku.TextZero() 481 left_text = self.left_text = vtku.TextZero()
465 left_text.ShadowOff() 482 left_text.ShadowOff()
466 left_text.SetColour(colour) 483 left_text.SetColour(colour)
@@ -539,30 +556,30 @@ class Viewer(wx.Panel): @@ -539,30 +556,30 @@ class Viewer(wx.Panel):
539 556
540 elif(croll > 91 and croll <= 135): 557 elif(croll > 91 and croll <= 135):
541 self.RenderTextDirection([_("LP"), _("AL"), _("RA"), _("PR")]) 558 self.RenderTextDirection([_("LP"), _("AL"), _("RA"), _("PR")])
542 - 559 +
543 elif(croll > 135 and croll <= 177): 560 elif(croll > 135 and croll <= 177):
544 self.RenderTextDirection([_("PL"), _("LA"), _("AR"), _("RP")]) 561 self.RenderTextDirection([_("PL"), _("LA"), _("AR"), _("RP")])
545 - 562 +
546 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): 563 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177):
547 self.RenderTextDirection([_("P"), _("L"), _("A"), _("R")]) 564 self.RenderTextDirection([_("P"), _("L"), _("A"), _("R")])
548 - 565 +
549 elif(croll >= -177 and croll <= -133): 566 elif(croll >= -177 and croll <= -133):
550 self.RenderTextDirection([_("PR"), _("LP"), _("AL"), _("RA")]) 567 self.RenderTextDirection([_("PR"), _("LP"), _("AL"), _("RA")])
551 - 568 +
552 elif(croll >= -132 and croll <= -101): 569 elif(croll >= -132 and croll <= -101):
553 self.RenderTextDirection([_("RP"), _("PL"), _("LA"), _("AR")]) 570 self.RenderTextDirection([_("RP"), _("PL"), _("LA"), _("AR")])
554 571
555 elif(croll >= -101 and croll <= -87): 572 elif(croll >= -101 and croll <= -87):
556 self.RenderTextDirection([_("R"), _("P"), _("L"), _("A")]) 573 self.RenderTextDirection([_("R"), _("P"), _("L"), _("A")])
557 - 574 +
558 elif(croll >= -86 and croll <= -42): 575 elif(croll >= -86 and croll <= -42):
559 self.RenderTextDirection([_("RA"), _("PR"), _("LP"), _("AL")]) 576 self.RenderTextDirection([_("RA"), _("PR"), _("LP"), _("AL")])
560 - 577 +
561 elif(croll >= -41 and croll <= -2): 578 elif(croll >= -41 and croll <= -2):
562 self.RenderTextDirection([_("AR"), _("RP"), _("PL"), _("LA")]) 579 self.RenderTextDirection([_("AR"), _("RP"), _("PL"), _("LA")])
563 580
564 elif(self.orientation == "CORONAL"): 581 elif(self.orientation == "CORONAL"):
565 - 582 +
566 if (croll >= -2 and croll <= 1): 583 if (croll >= -2 and croll <= 1):
567 self.RenderTextDirection([_("T"), _("R"), _("B"), _("L")]) 584 self.RenderTextDirection([_("T"), _("R"), _("B"), _("L")])
568 585
@@ -577,25 +594,25 @@ class Viewer(wx.Panel): @@ -577,25 +594,25 @@ class Viewer(wx.Panel):
577 594
578 elif(croll > 91 and croll <= 135): 595 elif(croll > 91 and croll <= 135):
579 self.RenderTextDirection([_("LB"), _("TL"), _("RT"), _("BR")]) 596 self.RenderTextDirection([_("LB"), _("TL"), _("RT"), _("BR")])
580 - 597 +
581 elif(croll > 135 and croll <= 177): 598 elif(croll > 135 and croll <= 177):
582 self.RenderTextDirection([_("BL"), _("LT"), _("TR"), _("RB")]) 599 self.RenderTextDirection([_("BL"), _("LT"), _("TR"), _("RB")])
583 - 600 +
584 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): 601 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177):
585 self.RenderTextDirection([_("B"), _("L"), _("T"), _("R")]) 602 self.RenderTextDirection([_("B"), _("L"), _("T"), _("R")])
586 - 603 +
587 elif(croll >= -177 and croll <= -133): 604 elif(croll >= -177 and croll <= -133):
588 self.RenderTextDirection([_("BR"), _("LB"), _("TL"), _("RT")]) 605 self.RenderTextDirection([_("BR"), _("LB"), _("TL"), _("RT")])
589 - 606 +
590 elif(croll >= -132 and croll <= -101): 607 elif(croll >= -132 and croll <= -101):
591 self.RenderTextDirection([_("RB"), _("BL"), _("LT"), _("TR")]) 608 self.RenderTextDirection([_("RB"), _("BL"), _("LT"), _("TR")])
592 609
593 elif(croll >= -101 and croll <= -87): 610 elif(croll >= -101 and croll <= -87):
594 self.RenderTextDirection([_("R"), _("B"), _("L"), _("T")]) 611 self.RenderTextDirection([_("R"), _("B"), _("L"), _("T")])
595 - 612 +
596 elif(croll >= -86 and croll <= -42): 613 elif(croll >= -86 and croll <= -42):
597 self.RenderTextDirection([_("RT"), _("BR"), _("LB"), _("TL")]) 614 self.RenderTextDirection([_("RT"), _("BR"), _("LB"), _("TL")])
598 - 615 +
599 elif(croll >= -41 and croll <= -2): 616 elif(croll >= -41 and croll <= -2):
600 self.RenderTextDirection([_("TR"), _("RB"), _("BL"), _("LT")]) 617 self.RenderTextDirection([_("TR"), _("RB"), _("BL"), _("LT")])
601 618
@@ -603,13 +620,13 @@ class Viewer(wx.Panel): @@ -603,13 +620,13 @@ class Viewer(wx.Panel):
603 620
604 if(croll >= -101 and croll <= -87): 621 if(croll >= -101 and croll <= -87):
605 self.RenderTextDirection([_("T"), _("P"), _("B"), _("A")]) 622 self.RenderTextDirection([_("T"), _("P"), _("B"), _("A")])
606 - 623 +
607 elif(croll >= -86 and croll <= -42): 624 elif(croll >= -86 and croll <= -42):
608 self.RenderTextDirection([_("TA"), _("PT"), _("BP"), _("AB")]) 625 self.RenderTextDirection([_("TA"), _("PT"), _("BP"), _("AB")])
609 - 626 +
610 elif(croll >= -41 and croll <= -2): 627 elif(croll >= -41 and croll <= -2):
611 self.RenderTextDirection([_("AT"), _("TP"), _("PB"), _("BA")]) 628 self.RenderTextDirection([_("AT"), _("TP"), _("PB"), _("BA")])
612 - 629 +
613 elif (croll >= -2 and croll <= 1): 630 elif (croll >= -2 and croll <= 1):
614 self.RenderTextDirection([_("A"), _("T"), _("P"), _("B")]) 631 self.RenderTextDirection([_("A"), _("T"), _("P"), _("B")])
615 632
@@ -624,16 +641,16 @@ class Viewer(wx.Panel): @@ -624,16 +641,16 @@ class Viewer(wx.Panel):
624 641
625 elif(croll > 91 and croll <= 135): 642 elif(croll > 91 and croll <= 135):
626 self.RenderTextDirection([_("BP"), _("AB"), _("TA"), _("PT")]) 643 self.RenderTextDirection([_("BP"), _("AB"), _("TA"), _("PT")])
627 - 644 +
628 elif(croll > 135 and croll <= 177): 645 elif(croll > 135 and croll <= 177):
629 self.RenderTextDirection([_("PB"), _("BA"), _("AT"), _("TP")]) 646 self.RenderTextDirection([_("PB"), _("BA"), _("AT"), _("TP")])
630 - 647 +
631 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177): 648 elif(croll >= -180 and croll <= -178) or (croll < 180 and croll > 177):
632 self.RenderTextDirection([_("P"), _("B"), _("A"), _("T")]) 649 self.RenderTextDirection([_("P"), _("B"), _("A"), _("T")])
633 - 650 +
634 elif(croll >= -177 and croll <= -133): 651 elif(croll >= -177 and croll <= -133):
635 self.RenderTextDirection([_("PT"), _("BP"), _("AB"), _("TA")]) 652 self.RenderTextDirection([_("PT"), _("BP"), _("AB"), _("TA")])
636 - 653 +
637 elif(croll >= -132 and croll <= -101): 654 elif(croll >= -132 and croll <= -101):
638 self.RenderTextDirection([_("TP"), _("PB"), _("BA"), _("AT")]) 655 self.RenderTextDirection([_("TP"), _("PB"), _("BA"), _("AT")])
639 656
@@ -668,12 +685,12 @@ class Viewer(wx.Panel): @@ -668,12 +685,12 @@ class Viewer(wx.Panel):
668 def Navigation(self, pubsub_evt): 685 def Navigation(self, pubsub_evt):
669 # Get point from base change 686 # Get point from base change
670 x, y, z = pubsub_evt.data 687 x, y, z = pubsub_evt.data
671 - coord_cross = x, y, z 688 + coord_cross = x, y, z
672 position = self.slice_data.actor.GetInput().FindPoint(x, y, z) 689 position = self.slice_data.actor.GetInput().FindPoint(x, y, z)
673 coord_cross = self.slice_data.actor.GetInput().GetPoint(position) 690 coord_cross = self.slice_data.actor.GetInput().GetPoint(position)
674 - coord = self.calcultate_scroll_position(position) 691 + coord = self.calcultate_scroll_position(position)
675 Publisher.sendMessage('Update cross position', coord_cross) 692 Publisher.sendMessage('Update cross position', coord_cross)
676 - 693 +
677 self.ScrollSlice(coord) 694 self.ScrollSlice(coord)
678 self.interactor.Render() 695 self.interactor.Render()
679 696
@@ -698,7 +715,7 @@ class Viewer(wx.Panel): @@ -698,7 +715,7 @@ class Viewer(wx.Panel):
698 #for slice_data in self.slice_data_list: 715 #for slice_data in self.slice_data_list:
699 #if slice_data.renderer is render: 716 #if slice_data.renderer is render:
700 #return slice_data 717 #return slice_data
701 - # WARN: Return the only slice_data used in this slice_viewer. 718 + # WARN: Return the only slice_data used in this slice_viewer.
702 return self.slice_data 719 return self.slice_data
703 720
704 def calcultate_scroll_position(self, position): 721 def calcultate_scroll_position(self, position):
@@ -825,7 +842,7 @@ class Viewer(wx.Panel): @@ -825,7 +842,7 @@ class Viewer(wx.Panel):
825 'Hide text actors on viewers') 842 'Hide text actors on viewers')
826 Publisher.subscribe(self.OnExportPicture,'Export picture to file') 843 Publisher.subscribe(self.OnExportPicture,'Export picture to file')
827 Publisher.subscribe(self.SetDefaultCursor, 'Set interactor default cursor') 844 Publisher.subscribe(self.SetDefaultCursor, 'Set interactor default cursor')
828 - 845 +
829 Publisher.subscribe(self.AddActors, 'Add actors ' + str(ORIENTATIONS[self.orientation])) 846 Publisher.subscribe(self.AddActors, 'Add actors ' + str(ORIENTATIONS[self.orientation]))
830 Publisher.subscribe(self.RemoveActors, 'Remove actors ' + str(ORIENTATIONS[self.orientation])) 847 Publisher.subscribe(self.RemoveActors, 'Remove actors ' + str(ORIENTATIONS[self.orientation]))
831 Publisher.subscribe(self.OnSwapVolumeAxes, 'Swap volume axes') 848 Publisher.subscribe(self.OnSwapVolumeAxes, 'Swap volume axes')
@@ -851,11 +868,11 @@ class Viewer(wx.Panel): @@ -851,11 +868,11 @@ class Viewer(wx.Panel):
851 868
852 def SetDefaultCursor(self, pusub_evt): 869 def SetDefaultCursor(self, pusub_evt):
853 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 870 self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
854 - 871 +
855 def OnExportPicture(self, pubsub_evt): 872 def OnExportPicture(self, pubsub_evt):
856 Publisher.sendMessage('Begin busy cursor') 873 Publisher.sendMessage('Begin busy cursor')
857 view_prop_list = [] 874 view_prop_list = []
858 - view_prop_list.append(self.slice_data.box_actor) 875 + view_prop_list.append(self.slice_data.box_actor)
859 self.slice_data.renderer.RemoveViewProp(self.slice_data.box_actor) 876 self.slice_data.renderer.RemoveViewProp(self.slice_data.box_actor)
860 877
861 id, filename, filetype = pubsub_evt.data 878 id, filename, filetype = pubsub_evt.data
@@ -917,7 +934,7 @@ class Viewer(wx.Panel): @@ -917,7 +934,7 @@ class Viewer(wx.Panel):
917 def CloseProject(self): 934 def CloseProject(self):
918 for slice_data in self.slice_data_list: 935 for slice_data in self.slice_data_list:
919 del slice_data 936 del slice_data
920 - 937 +
921 self.slice_data_list = [] 938 self.slice_data_list = []
922 self.layout = (1, 1) 939 self.layout = (1, 1)
923 self.orientation_texts = [] 940 self.orientation_texts = []
@@ -929,10 +946,10 @@ class Viewer(wx.Panel): @@ -929,10 +946,10 @@ class Viewer(wx.Panel):
929 def OnSetInteractorStyle(self, pubsub_evt): 946 def OnSetInteractorStyle(self, pubsub_evt):
930 state = pubsub_evt.data 947 state = pubsub_evt.data
931 self.SetInteractorStyle(state) 948 self.SetInteractorStyle(state)
932 - 949 +
933 if (state != const.SLICE_STATE_EDITOR): 950 if (state != const.SLICE_STATE_EDITOR):
934 Publisher.sendMessage('Set interactor default cursor') 951 Publisher.sendMessage('Set interactor default cursor')
935 - 952 +
936 def __bind_events_wx(self): 953 def __bind_events_wx(self):
937 self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar) 954 self.scroll.Bind(wx.EVT_SCROLL, self.OnScrollBar)
938 self.scroll.Bind(wx.EVT_SCROLL_THUMBTRACK, self.OnScrollBarRelease) 955 self.scroll.Bind(wx.EVT_SCROLL_THUMBTRACK, self.OnScrollBarRelease)
@@ -1162,15 +1179,15 @@ class Viewer(wx.Panel): @@ -1162,15 +1179,15 @@ class Viewer(wx.Panel):
1162 def set_scroll_position(self, position): 1179 def set_scroll_position(self, position):
1163 self.scroll.SetThumbPosition(position) 1180 self.scroll.SetThumbPosition(position)
1164 self.OnScrollBar() 1181 self.OnScrollBar()
1165 - 1182 +
1166 def UpdateSlice3D(self, pos): 1183 def UpdateSlice3D(self, pos):
1167 original_orientation = project.Project().original_orientation 1184 original_orientation = project.Project().original_orientation
1168 pos = self.scroll.GetThumbPosition() 1185 pos = self.scroll.GetThumbPosition()
1169 Publisher.sendMessage('Change slice from slice plane',\ 1186 Publisher.sendMessage('Change slice from slice plane',\
1170 (self.orientation, pos)) 1187 (self.orientation, pos))
1171 - 1188 +
1172 def OnScrollBar(self, evt=None, update3D=True): 1189 def OnScrollBar(self, evt=None, update3D=True):
1173 - pos = self.scroll.GetThumbPosition() 1190 + pos = self.scroll.GetThumbPosition()
1174 self.set_slice_number(pos) 1191 self.set_slice_number(pos)
1175 if update3D: 1192 if update3D:
1176 self.UpdateSlice3D(pos) 1193 self.UpdateSlice3D(pos)
@@ -1179,14 +1196,14 @@ class Viewer(wx.Panel): @@ -1179,14 +1196,14 @@ class Viewer(wx.Panel):
1179 # the actual orientation. 1196 # the actual orientation.
1180 focal_point = self.cross.GetFocalPoint() 1197 focal_point = self.cross.GetFocalPoint()
1181 Publisher.sendMessage('Update cross position', focal_point) 1198 Publisher.sendMessage('Update cross position', focal_point)
1182 - Publisher.sendMessage('Update slice viewer') 1199 + Publisher.sendMessage('Update slice viewer')
1183 else: 1200 else:
1184 - self.interactor.Render() 1201 + self.interactor.Render()
1185 if evt: 1202 if evt:
1186 if self._flush_buffer: 1203 if self._flush_buffer:
1187 self.slice_.apply_slice_buffer_to_mask(self.orientation) 1204 self.slice_.apply_slice_buffer_to_mask(self.orientation)
1188 evt.Skip() 1205 evt.Skip()
1189 - 1206 +
1190 def OnScrollBarRelease(self, evt): 1207 def OnScrollBarRelease(self, evt):
1191 pos = self.scroll.GetThumbPosition() 1208 pos = self.scroll.GetThumbPosition()
1192 evt.Skip() 1209 evt.Skip()
@@ -1212,7 +1229,7 @@ class Viewer(wx.Panel): @@ -1212,7 +1229,7 @@ class Viewer(wx.Panel):
1212 if (evt.GetKeyCode() == wx.WXK_UP and pos > min): 1229 if (evt.GetKeyCode() == wx.WXK_UP and pos > min):
1213 self.OnScrollForward() 1230 self.OnScrollForward()
1214 self.OnScrollBar() 1231 self.OnScrollBar()
1215 - 1232 +
1216 elif (evt.GetKeyCode() == wx.WXK_DOWN and pos < max): 1233 elif (evt.GetKeyCode() == wx.WXK_DOWN and pos < max):
1217 self.OnScrollBackward() 1234 self.OnScrollBackward()
1218 self.OnScrollBar() 1235 self.OnScrollBar()
@@ -1236,7 +1253,7 @@ class Viewer(wx.Panel): @@ -1236,7 +1253,7 @@ class Viewer(wx.Panel):
1236 Publisher.sendMessage('Set projection type', projections[evt.GetKeyCode()]) 1253 Publisher.sendMessage('Set projection type', projections[evt.GetKeyCode()])
1237 Publisher.sendMessage('Reload actual slice') 1254 Publisher.sendMessage('Reload actual slice')
1238 skip = False 1255 skip = False
1239 - 1256 +
1240 self.UpdateSlice3D(pos) 1257 self.UpdateSlice3D(pos)
1241 self.interactor.Render() 1258 self.interactor.Render()
1242 1259
@@ -1246,18 +1263,18 @@ class Viewer(wx.Panel): @@ -1246,18 +1263,18 @@ class Viewer(wx.Panel):
1246 def OnScrollForward(self, evt=None, obj=None): 1263 def OnScrollForward(self, evt=None, obj=None):
1247 pos = self.scroll.GetThumbPosition() 1264 pos = self.scroll.GetThumbPosition()
1248 min = 0 1265 min = 0
1249 - 1266 +
1250 if(pos > min): 1267 if(pos > min):
1251 if self._flush_buffer: 1268 if self._flush_buffer:
1252 self.slice_.apply_slice_buffer_to_mask(self.orientation) 1269 self.slice_.apply_slice_buffer_to_mask(self.orientation)
1253 pos = pos - 1 1270 pos = pos - 1
1254 self.scroll.SetThumbPosition(pos) 1271 self.scroll.SetThumbPosition(pos)
1255 self.OnScrollBar() 1272 self.OnScrollBar()
1256 - 1273 +
1257 def OnScrollBackward(self, evt=None, obj=None): 1274 def OnScrollBackward(self, evt=None, obj=None):
1258 pos = self.scroll.GetThumbPosition() 1275 pos = self.scroll.GetThumbPosition()
1259 max = self.slice_.GetMaxSliceNumber(self.orientation) 1276 max = self.slice_.GetMaxSliceNumber(self.orientation)
1260 - 1277 +
1261 if(pos < max): 1278 if(pos < max):
1262 if self._flush_buffer: 1279 if self._flush_buffer:
1263 self.slice_.apply_slice_buffer_to_mask(self.orientation) 1280 self.slice_.apply_slice_buffer_to_mask(self.orientation)
@@ -1266,7 +1283,7 @@ class Viewer(wx.Panel): @@ -1266,7 +1283,7 @@ class Viewer(wx.Panel):
1266 self.OnScrollBar() 1283 self.OnScrollBar()
1267 1284
1268 def OnSize(self, evt): 1285 def OnSize(self, evt):
1269 - w, h = evt.GetSize() 1286 + w, h = evt.GetSize()
1270 w = float(w) 1287 w = float(w)
1271 h = float(h) 1288 h = float(h)
1272 if self.slice_data: 1289 if self.slice_data:
@@ -1303,7 +1320,7 @@ class Viewer(wx.Panel): @@ -1303,7 +1320,7 @@ class Viewer(wx.Panel):
1303 self.mip_ctrls.Hide() 1320 self.mip_ctrls.Hide()
1304 self.GetSizer().Remove(self.mip_ctrls) 1321 self.GetSizer().Remove(self.mip_ctrls)
1305 self.Layout() 1322 self.Layout()
1306 - 1323 +
1307 def OnSetOverwriteMask(self, pubsub_evt): 1324 def OnSetOverwriteMask(self, pubsub_evt):
1308 value = pubsub_evt.data 1325 value = pubsub_evt.data
1309 self.overwrite_mask = value 1326 self.overwrite_mask = value
@@ -1360,7 +1377,7 @@ class Viewer(wx.Panel): @@ -1360,7 +1377,7 @@ class Viewer(wx.Panel):
1360 # orientation 1377 # orientation
1361 axis0, axis1 = pubsub_evt.data 1378 axis0, axis1 = pubsub_evt.data
1362 cursor = self.slice_data.cursor 1379 cursor = self.slice_data.cursor
1363 - spacing = cursor.spacing 1380 + spacing = cursor.spacing
1364 if (axis0, axis1) == (2, 1): 1381 if (axis0, axis1) == (2, 1):
1365 cursor.SetSpacing((spacing[1], spacing[0], spacing[2])) 1382 cursor.SetSpacing((spacing[1], spacing[0], spacing[2]))
1366 elif (axis0, axis1) == (2, 0): 1383 elif (axis0, axis1) == (2, 0):