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 | 78 | self.size = 15.0 |
79 | 79 | self.orientation = "AXIAL" |
80 | 80 | self.spacing = (1, 1, 1) |
81 | + self.unity = 'mm' | |
81 | 82 | if vtk.vtkVersion().GetVTKVersion() > '5.8.0': |
82 | 83 | self.mapper = vtk.vtkImageSliceMapper() |
83 | 84 | cursor_property = vtk.vtkImageProperty() |
... | ... | @@ -91,8 +92,9 @@ class CursorBase(object): |
91 | 92 | self._build_actor() |
92 | 93 | self._calculate_area_pixels() |
93 | 94 | |
94 | - def SetSize(self, diameter): | |
95 | + def SetSize(self, diameter, unity): | |
95 | 96 | self.radius = diameter/2.0 |
97 | + self.unity = unity | |
96 | 98 | self._build_actor() |
97 | 99 | self._calculate_area_pixels() |
98 | 100 | |
... | ... | @@ -241,7 +243,10 @@ class CursorCircle(CursorBase): |
241 | 243 | """ |
242 | 244 | print "Building circle cursor", self.orientation |
243 | 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 | 250 | if self.orientation == 'AXIAL': |
246 | 251 | xi = math.floor(-r/sx) |
247 | 252 | xf = math.ceil(r/sx) + 1 |
... | ... | @@ -293,15 +298,18 @@ class CursorCircle(CursorBase): |
293 | 298 | Return the cursor's pixels. |
294 | 299 | """ |
295 | 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 | 314 | xi = math.floor(-r/sx) |
307 | 315 | xf = math.ceil(r/sx) + 1 | ... | ... |
invesalius/data/viewer_slice.py
... | ... | @@ -534,10 +534,11 @@ class Viewer(wx.Panel): |
534 | 534 | self.interactor.Render() |
535 | 535 | |
536 | 536 | def ChangeBrushSize(self, pubsub_evt): |
537 | - size = pubsub_evt.data | |
537 | + size = pubsub_evt.data[0] | |
538 | + unity = pubsub_evt.data[1] | |
538 | 539 | self._brush_cursor_size = size |
539 | 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 | 543 | def ChangeBrushColour(self, pubsub_evt): |
543 | 544 | vtk_colour = pubsub_evt.data[3] |
... | ... | @@ -570,7 +571,7 @@ class Viewer(wx.Panel): |
570 | 571 | cursor.SetPosition(coordinates[self.orientation]) |
571 | 572 | cursor.SetSpacing(self.slice_.spacing) |
572 | 573 | cursor.SetColour(self._brush_cursor_colour) |
573 | - cursor.SetSize(self._brush_cursor_size) | |
574 | + cursor.SetSize(self._brush_cursor_size, 'mm') | |
574 | 575 | slice_data.SetCursor(cursor) |
575 | 576 | self.interactor.Render() |
576 | 577 | ... | ... |
invesalius/gui/task_slice.py
... | ... | @@ -599,24 +599,31 @@ class EditionTools(wx.Panel): |
599 | 599 | btn_brush_format.SetMenu(menu) |
600 | 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 | 603 | spin_brush_size.SetRange(1,100) |
604 | 604 | spin_brush_size.SetValue(const.BRUSH_SIZE) |
605 | 605 | spin_brush_size.Bind(wx.EVT_TEXT, self.OnBrushSize) |
606 | 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 | 613 | combo_brush_op = wx.ComboBox(self, -1, "", size=(15,-1), |
609 | 614 | choices = const.BRUSH_OP_NAME, |
610 | 615 | style = wx.CB_DROPDOWN|wx.CB_READONLY) |
611 | 616 | combo_brush_op.SetSelection(const.DEFAULT_BRUSH_OP) |
612 | 617 | if sys.platform != 'win32': |
613 | 618 | combo_brush_op.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
619 | + self.combo_brush_unity.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | |
614 | 620 | self.combo_brush_op = combo_brush_op |
615 | 621 | |
616 | 622 | # Sizer which represents the second line |
617 | 623 | line2 = wx.BoxSizer(wx.HORIZONTAL) |
618 | 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 | 627 | line2.Add(combo_brush_op, 1, wx.EXPAND|wx.TOP|wx.RIGHT|wx.LEFT, 5) |
621 | 628 | |
622 | 629 | ## LINE 3 |
... | ... | @@ -706,7 +713,8 @@ class EditionTools(wx.Panel): |
706 | 713 | # FIXME: Using wx.EVT_SPINCTRL in MacOS it doesnt capture changes only |
707 | 714 | # in the text ctrl - so we are capturing only changes on text |
708 | 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 | 719 | def OnComboBrushOp(self, evt): |
712 | 720 | brush_op_id = evt.GetSelection() | ... | ... |