Skip to content

Commit

Permalink
Add script command to create or remove bonding
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Oct 17, 2023
1 parent 2414366 commit 27d7585
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions avogadro/qtplugins/bonding/bonding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ void Bonding::setMolecule(QtGui::Molecule* mol)
m_molecule = mol;
}

void Bonding::registerCommands()
{
emit registerCommand("removeBonds",
tr("Remove bonds from all or selected atoms."));
emit registerCommand("createBonds",
tr("Create bonds between all or selected atoms."));
emit registerCommand("addBondOrders", tr("Perceive bond orders."));
}

bool Bonding::handleCommand(const QString& command, const QVariantMap& options)
{
if (m_molecule == nullptr)
return false; // No molecule to handle the command.

if (command == "removeBonds") {
clearBonds();
return true;
} else if (command == "createBonds") {
bond();
return true;
} else if (command == "addBondOrders") {
bondOrders();
return true;
}
return false;
}

void Bonding::configure()
{
if (!m_ui) {
Expand Down
5 changes: 5 additions & 0 deletions avogadro/qtplugins/bonding/bonding.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class Bonding : public QtGui::ExtensionPlugin

QStringList menuPath(QAction* action) const override;

bool handleCommand(const QString& command,
const QVariantMap& options) override;

void registerCommands() override;

public slots:
void setMolecule(QtGui::Molecule* mol) override;

Expand Down

0 comments on commit 27d7585

Please sign in to comment.