Commit 5f6db7500729a1095387b0c77896dd2970047b04

Authored by Thiago Franco de Moraes
1 parent 6ccb6c2f
Exists in select_part

Better create_new_mask method and doc

Showing 1 changed file with 12 additions and 7 deletions   Show diff stats
invesalius/data/slice_.py
... ... @@ -1290,17 +1290,22 @@ class Slice(object):
1290 1290 op, m1, m2 = pubsub_evt.data
1291 1291 self.do_boolean_op(op, m1, m2)
1292 1292  
1293   - def create_new_mask(self, show=True):
1294   - last_name = self.current_mask.name
  1293 + def create_new_mask(self, name=None, show=True):
  1294 + """
  1295 + Creates a new mask and add it to project.
1295 1296  
1296   - proj = Project()
1297   - mask_dict = proj.mask_dict
1298   - names_list = [mask_dict[i].name for i in mask_dict.keys()]
1299   - new_name = utils.next_copy_name(last_name, names_list)
  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)
1300 1305  
1301 1306 future_mask = Mask()
1302 1307 future_mask.create_mask(self.matrix.shape)
1303   - future_mask.name = new_name
  1308 + future_mask.name = name
1304 1309  
1305 1310 self._add_mask_into_proj(future_mask, show=show)
1306 1311  
... ...