Skip to content

Commit

Permalink
Initial work to diagnose crashes with dipole moment
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Nov 21, 2024
1 parent 9e353ed commit aacaa48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion avogadro/qtplugins/dipole/dipole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ void Dipole::process(const QtGui::Molecule& molecule,
if (molecule.hasData("dipoleMoment")) {
m_dipoleVector = molecule.data("dipoleMoment").toVector3();
} else {
if (!molecule.isInteractive()) {
if (!molecule.isInteractive() && m_updateNeeded) {
m_updateNeeded = false;
// 500ms delay to allow the molecule to be updated
QTimer::singleShot(500, this, &Dipole::updateFinished);
m_dipoleVector =
Calc::ChargeManager::instance().dipoleMoment(m_type, molecule);
}
Expand All @@ -60,6 +63,11 @@ void Dipole::process(const QtGui::Molecule& molecule,
arrow->addSingleArrow(m_dipoleVector.cast<float>(), origin);
}

void Dipole::updateFinished()
{
m_updateNeeded = true;
}

QWidget* Dipole::setupWidget()
{
return nullptr;
Expand Down
4 changes: 4 additions & 0 deletions avogadro/qtplugins/dipole/dipole.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ class Dipole : public QtGui::ScenePlugin
QWidget* setupWidget() override;
bool hasSetupWidget() const override { return false; }

public slots:
void updateFinished();

private:
std::string m_name = "Dipole Moment";
std::string m_type = "MMFF94";
std::vector<std::string> m_types;
Vector3 m_dipoleVector;
bool m_customDipole = false; // Custom dipole moment set
bool m_updateNeeded = true;
};

} // end namespace QtPlugins
Expand Down

0 comments on commit aacaa48

Please sign in to comment.