Skip to content

Commit

Permalink
Connect to molecule changes (e.g., in basis sets)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Nov 27, 2023
1 parent 323086e commit 55628fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions avogadro/qtplugins/surfaces/surfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ bool Surfaces::handleCommand(const QString& command, const QVariantMap& options)

void Surfaces::setMolecule(QtGui::Molecule* mol)
{
if (m_molecule != nullptr) {
m_molecule->disconnect(this);
}

if (mol->basisSet()) {
m_basis = mol->basisSet();
} else if (mol->cubes().size() != 0) {
Expand All @@ -234,6 +238,18 @@ void Surfaces::setMolecule(QtGui::Molecule* mol)
m_mesh1 = nullptr;
m_mesh2 = nullptr;
m_molecule = mol;

if (m_molecule != nullptr) {
connect(m_molecule, SIGNAL(changed(uint)), SLOT(moleculeChanged(uint)));
}
}

void Surfaces::moleculeChanged(unsigned int changes)
{
if (changes & Molecule::Added || changes & Molecule::Removed) {
m_cubes = m_molecule->cubes();
m_basis = m_molecule->basisSet();
}
}

QList<QAction*> Surfaces::actions() const
Expand Down
1 change: 1 addition & 0 deletions avogadro/qtplugins/surfaces/surfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Surfaces : public QtGui::ExtensionPlugin
public slots:
bool handleCommand(const QString& command,
const QVariantMap& options) override;
void moleculeChanged(unsigned int changes);

private slots:
void surfacesActivated();
Expand Down

0 comments on commit 55628fb

Please sign in to comment.