Commit 7c25cbf9f0ed61960bb6e1058f44d7b463d06d64

Authored by Thiago Franco de Moraes
1 parent 5f6db750
Exists in select_part

Removed the old method to add new mask

Showing 1 changed file with 28 additions and 31 deletions   Show diff stats
invesalius/data/slice_.py
@@ -302,14 +302,14 @@ class Slice(object): @@ -302,14 +302,14 @@ class Slice(object):
302 302
303 def __add_mask(self, pubsub_evt): 303 def __add_mask(self, pubsub_evt):
304 mask_name = pubsub_evt.data 304 mask_name = pubsub_evt.data
305 - self.CreateMask(name=mask_name) 305 + self.create_new_mask(name=mask_name)
306 self.SetMaskColour(self.current_mask.index, self.current_mask.colour) 306 self.SetMaskColour(self.current_mask.index, self.current_mask.colour)
307 307
308 def __add_mask_thresh(self, pubsub_evt): 308 def __add_mask_thresh(self, pubsub_evt):
309 mask_name = pubsub_evt.data[0] 309 mask_name = pubsub_evt.data[0]
310 thresh = pubsub_evt.data[1] 310 thresh = pubsub_evt.data[1]
311 colour = pubsub_evt.data[2] 311 colour = pubsub_evt.data[2]
312 - self.CreateMask(name=mask_name, threshold_range=thresh, colour =colour) 312 + self.create_new_mask(name=mask_name, threshold_range=thresh, colour=colour)
313 self.SetMaskColour(self.current_mask.index, self.current_mask.colour) 313 self.SetMaskColour(self.current_mask.index, self.current_mask.colour)
314 self.SelectCurrentMask(self.current_mask.index) 314 self.SelectCurrentMask(self.current_mask.index)
315 Publisher.sendMessage('Reload actual slice') 315 Publisher.sendMessage('Reload actual slice')
@@ -1034,14 +1034,31 @@ class Slice(object): @@ -1034,14 +1034,31 @@ class Slice(object):
1034 #else: 1034 #else:
1035 #widget.SetInput(cast.GetOutput()) 1035 #widget.SetInput(cast.GetOutput())
1036 1036
  1037 + def create_new_mask(self, name=None,
  1038 + colour=None,
  1039 + opacity=None,
  1040 + threshold_range=None,
  1041 + edition_threshold_range=None,
  1042 + show=True):
  1043 + """
  1044 + Creates a new mask and add it to project.
1037 1045
  1046 + Parameters:
  1047 + name (string): name of the new mask. If name is None a automatic
  1048 + name will be used.
  1049 + colour (R, G, B): a RGB tuple of float number.
  1050 + opacity (float): a float number, from 0 to 1. If opacity is None
  1051 + the default one will be used.
  1052 + threshold_range (int, int): a 2-tuple indicating threshold range.
  1053 + If None the default one will be used.
  1054 + edition_threshold_range (int, int): a 2-tuple indicating threshold
  1055 + range. If None the default one will be used.
  1056 + show (bool): if this new mask will be showed and set as current
  1057 + mask.
1038 1058
1039 - def CreateMask(self, imagedata=None, name=None, colour=None,  
1040 - opacity=None, threshold_range=None,  
1041 - edition_threshold_range = None,  
1042 - edited_points=None):  
1043 -  
1044 - # TODO: mask system to new system. 1059 + Returns:
  1060 + new_mask: The new mask object.
  1061 + """
1045 future_mask = Mask() 1062 future_mask = Mask()
1046 future_mask.create_mask(self.matrix.shape) 1063 future_mask.create_mask(self.matrix.shape)
1047 1064
@@ -1053,12 +1070,12 @@ class Slice(object): @@ -1053,12 +1070,12 @@ class Slice(object):
1053 future_mask.opacity = opacity 1070 future_mask.opacity = opacity
1054 if edition_threshold_range: 1071 if edition_threshold_range:
1055 future_mask.edition_threshold_range = edition_threshold_range 1072 future_mask.edition_threshold_range = edition_threshold_range
1056 - if edited_points:  
1057 - future_mask.edited_points = edited_points  
1058 if threshold_range: 1073 if threshold_range:
1059 future_mask.threshold_range = threshold_range 1074 future_mask.threshold_range = threshold_range
1060 1075
1061 - self._add_mask_into_proj(future_mask) 1076 + self._add_mask_into_proj(future_mask, show=show)
  1077 +
  1078 + return future_mask
1062 1079
1063 1080
1064 def _add_mask_into_proj(self, mask, show=True): 1081 def _add_mask_into_proj(self, mask, show=True):
@@ -1290,26 +1307,6 @@ class Slice(object): @@ -1290,26 +1307,6 @@ class Slice(object):
1290 op, m1, m2 = pubsub_evt.data 1307 op, m1, m2 = pubsub_evt.data
1291 self.do_boolean_op(op, m1, m2) 1308 self.do_boolean_op(op, m1, m2)
1292 1309
1293 - def create_new_mask(self, name=None, show=True):  
1294 - """  
1295 - Creates a new mask and add it to project.  
1296 -  
1297 - Parameters:  
1298 - name (string): name of the new mask. If name is None a automatic  
1299 - name will be used.  
1300 - show (bool): if this new mask will be showed and set as current  
1301 - mask.  
1302 - """  
1303 - if name is None:  
1304 - name = const.MASK_NAME_PATTERN %(Mask.general_index+2)  
1305 -  
1306 - future_mask = Mask()  
1307 - future_mask.create_mask(self.matrix.shape)  
1308 - future_mask.name = name  
1309 -  
1310 - self._add_mask_into_proj(future_mask, show=show)  
1311 -  
1312 - return future_mask  
1313 1310
1314 def do_boolean_op(self, op, m1, m2): 1311 def do_boolean_op(self, op, m1, m2):
1315 name_ops = {const.BOOLEAN_UNION: _(u"Union"), 1312 name_ops = {const.BOOLEAN_UNION: _(u"Union"),