From dfa8bb1e830464cd30377f22bb64471367e7593b Mon Sep 17 00:00:00 2001 From: Arindam Chaudhuri Date: Fri, 20 Oct 2023 09:54:48 +0530 Subject: [PATCH] fixed : hydrogens not updated if attached bond is deleted --- chemcanvas/tools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chemcanvas/tools.py b/chemcanvas/tools.py index 547de74..1b942ef 100644 --- a/chemcanvas/tools.py +++ b/chemcanvas/tools.py @@ -295,6 +295,12 @@ def delete_objects(objects): bonds |= set(atom.bonds) marks |= set(atom.marks) + # need to redraw atoms whose bonds are deleted, and occupied valency changed + to_redraw = set() + for bond in bonds: + to_redraw |= set(bond.atoms) + to_redraw -= atoms + # delete all other objects while marks: mark = marks.pop() @@ -321,6 +327,7 @@ def delete_objects(objects): while modified_molecules: mol = modified_molecules.pop() if len(mol.bonds)==0:# delete lone atom + to_redraw -= set(mol.atoms) for child in mol.children: child.deleteFromPaper() mol.paper.removeObject(mol) @@ -329,6 +336,8 @@ def delete_objects(objects): # delete lone atoms [modified_molecules.add(mol) for mol in new_mols if len(mol.bonds)==0] + draw_objs_recursively(to_redraw) + # ---------------------------- END MOVE TOOL ---------------------------