Skip to content

Commit

Permalink
fixed : hydrogens not updated if attached bond is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharindam committed Oct 20, 2023
1 parent fd87c2d commit dfa8bb1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chemcanvas/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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 ---------------------------


Expand Down

0 comments on commit dfa8bb1

Please sign in to comment.