Skip to content

Commit

Permalink
Merge pull request #1825 from ghutchis/insert-template-dummy
Browse files Browse the repository at this point in the history
Click to insert a fragment would leave dummy atoms
  • Loading branch information
ghutchis authored Nov 29, 2024
2 parents 7098118 + 50cb77a commit ab85ccd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion avogadro/qtplugins/templatetool/templatetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand All @@ -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
}
}
Expand Down

0 comments on commit ab85ccd

Please sign in to comment.