Commit 0a4c0482be2a5744b82753d74beed844afaa4573
1 parent
22aa7bb1
Exists in
brush_pix
Initing the option to set the unity of the size of brush
Showing
3 changed files
with
34 additions
and
17 deletions
Show diff stats
invesalius/data/cursor_actors.py
@@ -78,6 +78,7 @@ class CursorBase(object): | @@ -78,6 +78,7 @@ class CursorBase(object): | ||
78 | self.size = 15.0 | 78 | self.size = 15.0 |
79 | self.orientation = "AXIAL" | 79 | self.orientation = "AXIAL" |
80 | self.spacing = (1, 1, 1) | 80 | self.spacing = (1, 1, 1) |
81 | + self.unity = 'mm' | ||
81 | if vtk.vtkVersion().GetVTKVersion() > '5.8.0': | 82 | if vtk.vtkVersion().GetVTKVersion() > '5.8.0': |
82 | self.mapper = vtk.vtkImageSliceMapper() | 83 | self.mapper = vtk.vtkImageSliceMapper() |
83 | cursor_property = vtk.vtkImageProperty() | 84 | cursor_property = vtk.vtkImageProperty() |
@@ -91,8 +92,9 @@ class CursorBase(object): | @@ -91,8 +92,9 @@ class CursorBase(object): | ||
91 | self._build_actor() | 92 | self._build_actor() |
92 | self._calculate_area_pixels() | 93 | self._calculate_area_pixels() |
93 | 94 | ||
94 | - def SetSize(self, diameter): | 95 | + def SetSize(self, diameter, unity): |
95 | self.radius = diameter/2.0 | 96 | self.radius = diameter/2.0 |
97 | + self.unity = unity | ||
96 | self._build_actor() | 98 | self._build_actor() |
97 | self._calculate_area_pixels() | 99 | self._calculate_area_pixels() |
98 | 100 | ||
@@ -241,7 +243,10 @@ class CursorCircle(CursorBase): | @@ -241,7 +243,10 @@ class CursorCircle(CursorBase): | ||
241 | """ | 243 | """ |
242 | print "Building circle cursor", self.orientation | 244 | print "Building circle cursor", self.orientation |
243 | r = self.radius | 245 | r = self.radius |
244 | - sx, sy, sz = self.spacing | 246 | + if self.unity == 'mm': |
247 | + sx, sy, sz = self.spacing | ||
248 | + else: | ||
249 | + sx, sy, sz = 1.0, 1.0, 1.0 | ||
245 | if self.orientation == 'AXIAL': | 250 | if self.orientation == 'AXIAL': |
246 | xi = math.floor(-r/sx) | 251 | xi = math.floor(-r/sx) |
247 | xf = math.ceil(r/sx) + 1 | 252 | xf = math.ceil(r/sx) + 1 |
@@ -293,15 +298,18 @@ class CursorCircle(CursorBase): | @@ -293,15 +298,18 @@ class CursorCircle(CursorBase): | ||
293 | Return the cursor's pixels. | 298 | Return the cursor's pixels. |
294 | """ | 299 | """ |
295 | r = self.radius | 300 | r = self.radius |
296 | - if self.orientation == 'AXIAL': | ||
297 | - sx = self.spacing[0] | ||
298 | - sy = self.spacing[1] | ||
299 | - elif self.orientation == 'CORONAL': | ||
300 | - sx = self.spacing[0] | ||
301 | - sy = self.spacing[2] | ||
302 | - elif self.orientation == 'SAGITAL': | ||
303 | - sx = self.spacing[1] | ||
304 | - sy = self.spacing[2] | 301 | + if self.unity == 'mm': |
302 | + if self.orientation == 'AXIAL': | ||
303 | + sx = self.spacing[0] | ||
304 | + sy = self.spacing[1] | ||
305 | + elif self.orientation == 'CORONAL': | ||
306 | + sx = self.spacing[0] | ||
307 | + sy = self.spacing[2] | ||
308 | + elif self.orientation == 'SAGITAL': | ||
309 | + sx = self.spacing[1] | ||
310 | + sy = self.spacing[2] | ||
311 | + else: | ||
312 | + sx, sy = 1.0, 1.0 | ||
305 | 313 | ||
306 | xi = math.floor(-r/sx) | 314 | xi = math.floor(-r/sx) |
307 | xf = math.ceil(r/sx) + 1 | 315 | xf = math.ceil(r/sx) + 1 |
invesalius/data/viewer_slice.py
@@ -534,10 +534,11 @@ class Viewer(wx.Panel): | @@ -534,10 +534,11 @@ class Viewer(wx.Panel): | ||
534 | self.interactor.Render() | 534 | self.interactor.Render() |
535 | 535 | ||
536 | def ChangeBrushSize(self, pubsub_evt): | 536 | def ChangeBrushSize(self, pubsub_evt): |
537 | - size = pubsub_evt.data | 537 | + size = pubsub_evt.data[0] |
538 | + unity = pubsub_evt.data[1] | ||
538 | self._brush_cursor_size = size | 539 | self._brush_cursor_size = size |
539 | #for slice_data in self.slice_data_list: | 540 | #for slice_data in self.slice_data_list: |
540 | - self.slice_data.cursor.SetSize(size) | 541 | + self.slice_data.cursor.SetSize(size, unity) |
541 | 542 | ||
542 | def ChangeBrushColour(self, pubsub_evt): | 543 | def ChangeBrushColour(self, pubsub_evt): |
543 | vtk_colour = pubsub_evt.data[3] | 544 | vtk_colour = pubsub_evt.data[3] |
@@ -570,7 +571,7 @@ class Viewer(wx.Panel): | @@ -570,7 +571,7 @@ class Viewer(wx.Panel): | ||
570 | cursor.SetPosition(coordinates[self.orientation]) | 571 | cursor.SetPosition(coordinates[self.orientation]) |
571 | cursor.SetSpacing(self.slice_.spacing) | 572 | cursor.SetSpacing(self.slice_.spacing) |
572 | cursor.SetColour(self._brush_cursor_colour) | 573 | cursor.SetColour(self._brush_cursor_colour) |
573 | - cursor.SetSize(self._brush_cursor_size) | 574 | + cursor.SetSize(self._brush_cursor_size, 'mm') |
574 | slice_data.SetCursor(cursor) | 575 | slice_data.SetCursor(cursor) |
575 | self.interactor.Render() | 576 | self.interactor.Render() |
576 | 577 |
invesalius/gui/task_slice.py
@@ -599,24 +599,31 @@ class EditionTools(wx.Panel): | @@ -599,24 +599,31 @@ class EditionTools(wx.Panel): | ||
599 | btn_brush_format.SetMenu(menu) | 599 | btn_brush_format.SetMenu(menu) |
600 | self.btn_brush_format = btn_brush_format | 600 | self.btn_brush_format = btn_brush_format |
601 | 601 | ||
602 | - spin_brush_size = wx.SpinCtrl(self, -1, "", (20, 50)) | 602 | + spin_brush_size = wx.SpinCtrl(self, -1, "", (20, -1)) |
603 | spin_brush_size.SetRange(1,100) | 603 | spin_brush_size.SetRange(1,100) |
604 | spin_brush_size.SetValue(const.BRUSH_SIZE) | 604 | spin_brush_size.SetValue(const.BRUSH_SIZE) |
605 | spin_brush_size.Bind(wx.EVT_TEXT, self.OnBrushSize) | 605 | spin_brush_size.Bind(wx.EVT_TEXT, self.OnBrushSize) |
606 | self.spin = spin_brush_size | 606 | self.spin = spin_brush_size |
607 | 607 | ||
608 | + unities = ("mm", "px") | ||
609 | + self.combo_brush_unity = wx.ComboBox(self, -1, unities[0], | ||
610 | + size=(15, -1), choices=unities, | ||
611 | + style=wx.CB_DROPDOWN | wx.CB_READONLY) | ||
612 | + | ||
608 | combo_brush_op = wx.ComboBox(self, -1, "", size=(15,-1), | 613 | combo_brush_op = wx.ComboBox(self, -1, "", size=(15,-1), |
609 | choices = const.BRUSH_OP_NAME, | 614 | choices = const.BRUSH_OP_NAME, |
610 | style = wx.CB_DROPDOWN|wx.CB_READONLY) | 615 | style = wx.CB_DROPDOWN|wx.CB_READONLY) |
611 | combo_brush_op.SetSelection(const.DEFAULT_BRUSH_OP) | 616 | combo_brush_op.SetSelection(const.DEFAULT_BRUSH_OP) |
612 | if sys.platform != 'win32': | 617 | if sys.platform != 'win32': |
613 | combo_brush_op.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | 618 | combo_brush_op.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
619 | + self.combo_brush_unity.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
614 | self.combo_brush_op = combo_brush_op | 620 | self.combo_brush_op = combo_brush_op |
615 | 621 | ||
616 | # Sizer which represents the second line | 622 | # Sizer which represents the second line |
617 | line2 = wx.BoxSizer(wx.HORIZONTAL) | 623 | line2 = wx.BoxSizer(wx.HORIZONTAL) |
618 | line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 0) | 624 | line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 0) |
619 | - line2.Add(spin_brush_size, 0, wx.RIGHT, 5) | 625 | + line2.Add(spin_brush_size, 1, wx.RIGHT, 5) |
626 | + line2.Add(self.combo_brush_unity, 1, wx.EXPAND| wx.RIGHT, 5) | ||
620 | line2.Add(combo_brush_op, 1, wx.EXPAND|wx.TOP|wx.RIGHT|wx.LEFT, 5) | 627 | line2.Add(combo_brush_op, 1, wx.EXPAND|wx.TOP|wx.RIGHT|wx.LEFT, 5) |
621 | 628 | ||
622 | ## LINE 3 | 629 | ## LINE 3 |
@@ -706,7 +713,8 @@ class EditionTools(wx.Panel): | @@ -706,7 +713,8 @@ class EditionTools(wx.Panel): | ||
706 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only | 713 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
707 | # in the text ctrl - so we are capturing only changes on text | 714 | # in the text ctrl - so we are capturing only changes on text |
708 | # Strangelly this is being called twice | 715 | # Strangelly this is being called twice |
709 | - Publisher.sendMessage('Set edition brush size',self.spin.GetValue()) | 716 | + Publisher.sendMessage('Set edition brush size', (self.spin.GetValue(), |
717 | + self.combo_brush_unity.GetValue())) | ||
710 | 718 | ||
711 | def OnComboBrushOp(self, evt): | 719 | def OnComboBrushOp(self, evt): |
712 | brush_op_id = evt.GetSelection() | 720 | brush_op_id = evt.GetSelection() |