Skip to content

Commit

Permalink
Merge pull request #1377 from ghutchis/add-bond-commands
Browse files Browse the repository at this point in the history
Add script command to create or remove bonding
  • Loading branch information
ghutchis authored Oct 17, 2023
2 parents fd05cc6 + 27d7585 commit 575bee9
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 575bee9

Please sign in to comment.