From 50cb77a4e07fee23f2815df28581357fd6f5ab92 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 28 Nov 2024 16:52:16 -0500 Subject: [PATCH] Click to insert a fragment would leave dummy atoms Signed-off-by: Geoff Hutchison --- .../qtplugins/templatetool/templatetool.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/avogadro/qtplugins/templatetool/templatetool.cpp b/avogadro/qtplugins/templatetool/templatetool.cpp index c7ac628791..a631d33441 100644 --- a/avogadro/qtplugins/templatetool/templatetool.cpp +++ b/avogadro/qtplugins/templatetool/templatetool.cpp @@ -86,7 +86,8 @@ TemplateTool::TemplateTool(QObject* parent_) "Select an element and coordination geometry," "then click to insert a fragment.\n\n" "Select a ligand or functional group and click" - "on a hydrogen atom to attach it.").arg(shortcut)); + "on a hydrogen atom to attach it.") + .arg(shortcut)); setIcon(); reset(); } @@ -352,6 +353,14 @@ void TemplateTool::emptyLeftClick(QMouseEvent* e) return; center = templateMolecule.centerOfGeometry(); + // change the dummy atom(s) to hydrogen + for (size_t i = 0; i < templateMolecule.atomCount(); i++) { + if (templateMolecule.atomicNumber(i) == 0) { + templateMolecule.setAtomicNumber(i, 1); + templateMolecule.setFormalCharge(i, 0); + } + } + // done with clipboard ligands } else { // a ligand file QString path; @@ -372,6 +381,14 @@ void TemplateTool::emptyLeftClick(QMouseEvent* e) return; center = templateMolecule.centerOfGeometry(); + // change the dummy atom(s) to hydrogen + for (size_t i = 0; i < templateMolecule.atomCount(); i++) { + if (templateMolecule.atomicNumber(i) == 0) { + templateMolecule.setAtomicNumber(i, 1); + templateMolecule.setFormalCharge(i, 0); + } + } + // done with ligand } }