Commit 10ef6cb7b59260c1102f086a8f3e5a5f902b0693
1 parent
bcb8814f
Exists in
master
and in
68 other branches
FIX:Edit points is not erased when you use the erase brush. FIX #205
Showing
1 changed file
with
21 additions
and
21 deletions
Show diff stats
invesalius/data/slice_.py
| ... | ... | @@ -108,7 +108,7 @@ class Slice(object): |
| 108 | 108 | # compute copy name |
| 109 | 109 | name = original_mask.name |
| 110 | 110 | names_list = [mask_dict[i].name for i in mask_dict.keys()] |
| 111 | - new_name = utils.next_copy_name(name, names_list) | |
| 111 | + new_name = utils.next_copy_name(name, names_list) | |
| 112 | 112 | # create new mask |
| 113 | 113 | self.CreateMask(imagedata = original_mask.imagedata, |
| 114 | 114 | name = new_name, |
| ... | ... | @@ -131,7 +131,7 @@ class Slice(object): |
| 131 | 131 | if (state in const.SLICE_STYLES): |
| 132 | 132 | new_state = self.interaction_style.RemoveState(state) |
| 133 | 133 | ps.Publisher().sendMessage('Set slice interaction style', new_state) |
| 134 | - | |
| 134 | + | |
| 135 | 135 | if (state == const.SLICE_STATE_EDITOR): |
| 136 | 136 | ps.Publisher().sendMessage('Set interactor default cursor') |
| 137 | 137 | |
| ... | ... | @@ -190,7 +190,7 @@ class Slice(object): |
| 190 | 190 | #Clear edited points |
| 191 | 191 | self.current_mask.edited_points = {} |
| 192 | 192 | self.num_gradient += 1 |
| 193 | - | |
| 193 | + | |
| 194 | 194 | def __set_current_mask_colour(self, pubsub_evt): |
| 195 | 195 | # "if" is necessary because wx events are calling this before any mask |
| 196 | 196 | # has been created |
| ... | ... | @@ -298,10 +298,10 @@ class Slice(object): |
| 298 | 298 | else: |
| 299 | 299 | proj = Project() |
| 300 | 300 | proj.mask_dict[index].threshold_range = threshold_range |
| 301 | - | |
| 301 | + | |
| 302 | 302 | proj = Project() |
| 303 | 303 | proj.mask_dict[self.current_mask.index].threshold_range = threshold_range |
| 304 | - | |
| 304 | + | |
| 305 | 305 | |
| 306 | 306 | def ShowMask(self, index, value): |
| 307 | 307 | "Show a mask given its index and 'show' value (0: hide, other: show)" |
| ... | ... | @@ -317,19 +317,19 @@ class Slice(object): |
| 317 | 317 | #--------------------------------------------------------------------------- |
| 318 | 318 | def ErasePixel(self, position): |
| 319 | 319 | "Delete pixel, based on x, y and z position coordinates." |
| 320 | - x, y, z = position | |
| 320 | + x, y, z = round(position[0],0), round(position[1],0),position[2] | |
| 321 | 321 | colour = self.imagedata.GetScalarRange()[0] |
| 322 | 322 | imagedata = self.current_mask.imagedata |
| 323 | 323 | imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) |
| 324 | 324 | self.current_mask.edited_points[(x, y, z)] = colour |
| 325 | - | |
| 325 | + | |
| 326 | 326 | session = ses.Session() |
| 327 | 327 | session.ChangeProject() |
| 328 | 328 | |
| 329 | 329 | |
| 330 | 330 | def DrawPixel(self, position, colour=None): |
| 331 | 331 | "Draw pixel, based on x, y and z position coordinates." |
| 332 | - x, y, z = position | |
| 332 | + x, y, z = round(position[0],0), round(position[1],0),position[2] | |
| 333 | 333 | colour = self.imagedata.GetScalarRange()[1] |
| 334 | 334 | imagedata = self.current_mask.imagedata |
| 335 | 335 | imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) |
| ... | ... | @@ -341,7 +341,7 @@ class Slice(object): |
| 341 | 341 | |
| 342 | 342 | def EditPixelBasedOnThreshold(self, position): |
| 343 | 343 | "Erase or draw pixel based on edition threshold range." |
| 344 | - x, y, z = position | |
| 344 | + x, y, z = round(position[0],0), round(position[1],0),position[2] | |
| 345 | 345 | colour = self.imagedata.GetScalarComponentAsDouble(x, y, z, 0) |
| 346 | 346 | thresh_min, thresh_max = self.current_mask.edition_threshold_range |
| 347 | 347 | if (colour >= thresh_min) and (colour <= thresh_max): |
| ... | ... | @@ -366,7 +366,7 @@ class Slice(object): |
| 366 | 366 | future_mask = proj.GetMask(index) |
| 367 | 367 | future_mask.is_shown = True |
| 368 | 368 | self.current_mask = future_mask |
| 369 | - | |
| 369 | + | |
| 370 | 370 | colour = future_mask.colour |
| 371 | 371 | #index = future_mask.index |
| 372 | 372 | print index |
| ... | ... | @@ -392,7 +392,7 @@ class Slice(object): |
| 392 | 392 | |
| 393 | 393 | def CreateSurfaceFromIndex(self, pubsub_evt): |
| 394 | 394 | mask_index, overwrite_surface = pubsub_evt.data |
| 395 | - | |
| 395 | + | |
| 396 | 396 | |
| 397 | 397 | proj = Project() |
| 398 | 398 | mask = proj.mask_dict[mask_index] |
| ... | ... | @@ -496,18 +496,18 @@ class Slice(object): |
| 496 | 496 | thresh_min, thresh_max = self.window_level.GetOutput().GetScalarRange() |
| 497 | 497 | self.lut_bg.SetTableRange(thresh_min, thresh_max) |
| 498 | 498 | |
| 499 | - | |
| 499 | + | |
| 500 | 500 | def InputImageWidget(self, pubsub_evt): |
| 501 | 501 | widget = pubsub_evt.data |
| 502 | - | |
| 502 | + | |
| 503 | 503 | flip = vtk.vtkImageFlip() |
| 504 | 504 | flip.SetInput(self.window_level.GetOutput()) |
| 505 | 505 | flip.SetFilteredAxis(1) |
| 506 | 506 | flip.FlipAboutOriginOn() |
| 507 | 507 | flip.Update() |
| 508 | - | |
| 508 | + | |
| 509 | 509 | widget.SetInput(flip.GetOutput()) |
| 510 | - | |
| 510 | + | |
| 511 | 511 | |
| 512 | 512 | def CreateMask(self, imagedata=None, name=None, colour=None, |
| 513 | 513 | opacity=None, threshold_range=None, |
| ... | ... | @@ -570,7 +570,7 @@ class Slice(object): |
| 570 | 570 | keys.sort() |
| 571 | 571 | for key in keys: |
| 572 | 572 | mask = mask_dict[key] |
| 573 | - | |
| 573 | + | |
| 574 | 574 | # update gui related to mask |
| 575 | 575 | utils.debug("__load_masks") |
| 576 | 576 | utils.debug('THRESHOLD_RANGE %s'% mask.threshold_range) |
| ... | ... | @@ -609,22 +609,22 @@ class Slice(object): |
| 609 | 609 | lut_mask.SetRampToLinear() |
| 610 | 610 | lut_mask.Build() |
| 611 | 611 | self.lut_mask = lut_mask |
| 612 | - | |
| 612 | + | |
| 613 | 613 | mask_thresh_imagedata = self.__create_mask_threshold(imagedata) |
| 614 | - | |
| 614 | + | |
| 615 | 615 | if create: |
| 616 | 616 | # threshold pipeline |
| 617 | 617 | current_mask.imagedata.DeepCopy(mask_thresh_imagedata) |
| 618 | 618 | else: |
| 619 | 619 | mask_thresh_imagedata = self.current_mask.imagedata |
| 620 | - | |
| 620 | + | |
| 621 | 621 | # map the input image through a lookup table |
| 622 | 622 | img_colours_mask = vtk.vtkImageMapToColors() |
| 623 | 623 | img_colours_mask.SetOutputFormatToRGBA() |
| 624 | 624 | img_colours_mask.SetLookupTable(lut_mask) |
| 625 | - | |
| 625 | + | |
| 626 | 626 | img_colours_mask.SetInput(mask_thresh_imagedata) |
| 627 | - | |
| 627 | + | |
| 628 | 628 | self.img_colours_mask = img_colours_mask |
| 629 | 629 | |
| 630 | 630 | return img_colours_mask.GetOutput() | ... | ... |