def deleteActiveArea(self, name): for i in range(len(self.namedActiveAreas)): if self.namedActiveAreas[i].name == name: aa = self.namedActiveAreas[i] for pxl in aa.activearea.members(): activearea.areaListFromPixel(self, pxl).remove(name) del self.namedActiveAreas[i] return
def renameActiveArea(self, oldname, newname): for naa in self.namedActiveAreas: if naa.name == oldname: real_new_name = utils.uniqueName(newname, self.activeAreaNames(), exclude=oldname) naa.name = real_new_name for pxl in naa.activearea.members(): aal = activearea.areaListFromPixel(self, pxl) aal.remove(oldname) aal.add(real_new_name)
def _namedactivearea(menuitem, microstructure, category, active_areas): # Get the pixels for this category, and add all the active areas # associated with this category to each pixel. ms_obj = ms_module.getMicrostructure(microstructure) pxls = microstructureIO.getCategoryPixels(microstructure, category) px_dict = {} for name in active_areas: px_dict[name] = [] for p in pxls: aal = activearea.areaListFromPixel(ms_obj, p) for name in active_areas: aal.add(name) px_dict[name].append(p) for name in active_areas: aa = ms_obj.getNamedActiveArea(name) aa.activearea.add_pixels(px_dict[name])
def _namedactivearea(menuitem, microstructure, category, active_areas): # Get the pixels for this category, and add all the active areas # associated with this category to each pixel. ms_obj = ms_module.getMicrostructure(microstructure) pxls = microstructureIO.getCategoryPixels(microstructure, category) px_dict = {} aa_dict = {} for name in active_areas: px_dict[name] = [] aa_dict[name] = ms_obj.getNamedActiveArea(name) for p in pxls: aal = activearea.areaListFromPixel(ms_obj, p) for name in active_areas: aal.add(aa_dict[name]) px_dict[name].append(p) for name in active_areas: aa_dict[name].add_pixels(px_dict[name])
def saveActiveArea(self, name): aa = self.activearea.getObject().clone() self.namedActiveAreas.append(activearea.NamedActiveArea(name, aa)) for pxl in aa.members(): activearea.areaListFromPixel(self, pxl).add(name)