Skip to content

Commit

Permalink
Implement script commands
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Oct 9, 2023
1 parent b945974 commit e046ba3
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion avogadro/qtplugins/aligntool/aligntool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,51 @@ bool AlignTool::handleCommand(const QString& command,
if (m_molecule == nullptr)
return false; // No molecule to handle the command.

return true;
if (command == "centerAtom") {
if (options.contains("id")) {
Index atomIndex = options["id"].toInt();
if (atomIndex >= 0 && atomIndex < m_molecule->atomCount())
shiftAtomToOrigin(atomIndex);
return true;
} else if (options.contains("index")) {
Index atomIndex = options["index"].toInt();
if (atomIndex >= 0 && atomIndex < m_molecule->atomCount())
shiftAtomToOrigin(atomIndex);
return true;
}
return false;
} else if (command == "alignAtom") {
int axis = -1;
if (options.contains("axis") && options["axis"].type() == QVariant::Int) {
axis = options["axis"].toInt();
} else if (options.contains("axis") &&
options["axis"].type() == QVariant::String) {
QString axisString = options["axis"].toString();
if (axisString == "x")
axis = 0;
else if (axisString == "y")
axis = 1;
else if (axisString == "z")
axis = 2;
}

if (axis >= 0 && axis < 3) {
if (options.contains("id")) {
Index atomIndex = options["id"].toInt();
if (atomIndex >= 0 && atomIndex < m_molecule->atomCount())
alignAtomToAxis(atomIndex, axis);
return true;
} else if (options.contains("index")) {
Index atomIndex = options["index"].toInt();
if (atomIndex >= 0 && atomIndex < m_molecule->atomCount())
alignAtomToAxis(atomIndex, axis);
return true;
}
}

return true;
}

}

} // namespace Avogadro::QtPlugins

1 comment on commit e046ba3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.

Please sign in to comment.