diff --git a/invesalius/data/cursor_actors.py b/invesalius/data/cursor_actors.py index 61f6e10..3f1cb05 100644 --- a/invesalius/data/cursor_actors.py +++ b/invesalius/data/cursor_actors.py @@ -26,7 +26,6 @@ class CursorCircle: self.__build_actor() self.__calculate_area_pixels() - def __build_actor(self): """ Function to plot the circle @@ -113,15 +112,18 @@ class CursorCircle: px, py, pz = self.edition_position orient = self.orientation xs, ys, zs = self.spacing + abs_pixel = {"AXIAL": lambda x,y: (px + x / xs, py+(y/ys), pz), + "CORONAL": lambda x,y: (px+(x/xs), py, + pz+(y/zs)), + "SAGITAL": lambda x,y: (px, py+(x/ys), + pz+(y/zs))} + function_orientation = abs_pixel[orient] for pixel_0,pixel_1 in self.pixel_list: # The position of the pixels in this list is relative (based only on # the area, and not the cursor position). # Let's calculate the absolute position # TODO: Optimize this!!!! - abs_pixel = {"AXIAL": [px+pixel_0/xs, py+(pixel_1/ys), pz], - "CORONAL": [px+(pixel_0/xs), py, pz+(pixel_1/zs)], - "SAGITAL": [px, py+(pixel_0/ys), pz+(pixel_1/zs)]} - yield abs_pixel[orient] + yield function_orientation(pixel_0, pixel_1) #------------------------------------------------------------------------------- diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 64595da..b4f4346 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -98,16 +98,19 @@ class Slice(object): self.ShowMask(index, value) #--------------------------------------------------------------------------- def __erase_mask_pixel(self, pubsub_evt): - position = pubsub_evt.data - self.ErasePixel(position) + positions = pubsub_evt.data + for position in positions: + self.ErasePixel(position) def __edit_mask_pixel(self, pubsub_evt): - position = pubsub_evt.data - self.EditPixelBasedOnThreshold(position) + positions = pubsub_evt.data + for position in positions: + self.EditPixelBasedOnThreshold(position) def __add_mask_pixel(self, pubsub_evt): - position = pubsub_evt.data - self.DrawPixel(position) + positions = pubsub_evt.data + for position in positions: + self.DrawPixel(position) #--------------------------------------------------------------------------- # END PUBSUB_EVT METHODS #--------------------------------------------------------------------------- @@ -191,7 +194,7 @@ class Slice(object): colour = self.imagedata.GetScalarRange()[0]# - 1 # Important to effect erase imagedata = self.current_mask.imagedata imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) - imagedata.Update() + #imagedata.Update() self.current_mask.edited_points[(x, y, z)] = colour def DrawPixel(self, position, colour=None): @@ -201,7 +204,6 @@ class Slice(object): colour = self.imagedata.GetScalarRange()[1] imagedata = self.current_mask.imagedata imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) - imagedata.Update() self.current_mask.edited_points[(x, y, z)] = colour def EditPixelBasedOnThreshold(self, position): diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index cd5fc85..16e8d7b 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -195,8 +195,7 @@ class Viewer(wx.Panel): pixels = itertools.ifilter(self.TestOperationPosition, self.cursor.GetPixels()) - for coord in pixels: - ps.Publisher().sendMessage(evt_msg, coord) + ps.Publisher().sendMessage(evt_msg, pixels) # FIXME: This is idiot, but is the only way that brush operations are # working when cross is disabled @@ -219,10 +218,9 @@ class Viewer(wx.Panel): if self.mouse_pressed: pixels = itertools.ifilter(self.TestOperationPosition, self.cursor.GetPixels()) - for coord in pixels: - ps.Publisher().sendMessage(evt_msg, coord) + ps.Publisher().sendMessage(evt_msg, pixels) + ps.Publisher().sendMessage('Update slice viewer') self.interactor.Render() - ps.Publisher().sendMessage('Update slice viewer') def OnCrossMove(self, obj, evt_vtk): coord = self.GetCoordinate() -- libgit2 0.21.2