Esempio n. 1
0
    def RemoveMasks(self):
        """
        Remove selected items.
        """
        selected_items = self.GetSelected()

        if selected_items:
            Publisher.sendMessage('Remove masks', mask_indexes=selected_items)
        else:
            dlg.MaskSelectionRequiredForRemoval()
            return

        self.DeleteAllItems()
        self.imagelist.RemoveAll()
        self.__init_image_list()

        new_dict = {}
        self.current_index = 0
        self.mask_list_index = {}
        mask_dict = project.Project().mask_dict
        for n, i in enumerate(mask_dict):
            mask = mask_dict[i]
            new_dict[n] = mask.index
            self.AddMask(mask)
            if mask.is_shown:
                self.current_index = n

        self.SetItemImage(self.current_index, 1)
        Publisher.sendMessage('Change mask selected', index=self.current_index)
        Publisher.sendMessage('Show mask', index=self.current_index, value=1)
        Publisher.sendMessage('Refresh viewer')
Esempio n. 2
0
    def RemoveMasks(self):
        """
        Remove selected items.
        """
        selected_items = self.GetSelected()

        if selected_items:
            Publisher.sendMessage('Remove masks', mask_indexes=selected_items)
        else:
            dlg.MaskSelectionRequiredForRemoval()
            return

        # it is necessary to update internal dictionary
        # that maps bitmap given item index
        old_dict = self.mask_list_index
        if selected_items:
            for index in selected_items:
                new_dict = {}
                self.DeleteItem(index)
                for i in old_dict:
                    if i < index:
                        new_dict[i] = old_dict[i]
                    if i > index:
                        new_dict[i-1] = old_dict[i]
                old_dict = new_dict
            self.mask_list_index = new_dict

        if new_dict:
            if index == self.current_index:
                self.SetItemImage(0, 1)
                Publisher.sendMessage('Change mask selected', index=0)
                Publisher.sendMessage('Show mask', index=0, value=1)
                Publisher.sendMessage('Refresh viewer')
                for key in new_dict:
                    if key:
                         self.SetItemImage(key, 0)

            elif index < self.current_index:
                self.current_index -= 1
                self.SetItemImage(self.current_index, 1)