Skip to content

Commit

Permalink
Merge pull request #1487 from ghutchis/fix-vibration-animation
Browse files Browse the repository at this point in the history
Fix vibration animation
  • Loading branch information
ghutchis committed Dec 1, 2023
2 parents aa127e0 + f0458e8 commit 9898a5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ void Molecule::readProperties(const Molecule& other)
m_label = other.m_label;
m_colors = other.m_colors;
// merge data maps by iterating through other's map
for (auto it = other.m_data.constBegin(); it != other.m_data.constEnd(); ++it) {
for (auto it = other.m_data.constBegin(); it != other.m_data.constEnd();
++it) {
// even if we have the same key, we want to overwrite
m_data.setValue(it->first, it->second);
}
Expand Down Expand Up @@ -1218,6 +1219,11 @@ bool Molecule::setCoordinate3d(int coord)
return false;
}

void Molecule::clearCoordinate3d()
{
m_coordinates3d.clear();
}

Array<Vector3> Molecule::coordinate3d(int index) const
{
return m_coordinates3d[index];
Expand Down
5 changes: 5 additions & 0 deletions avogadro/core/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ class AVOGADROCORE_EXPORT Molecule
Array<Vector3> coordinate3d(int index) const;
bool setCoordinate3d(const Array<Vector3>& coords, int index);

/**
* Clear coordinate sets (except the default set)
*/
void clearCoordinate3d();

/**
* Timestep property is used when molecular dynamics trajectories are read
*/
Expand Down
3 changes: 2 additions & 1 deletion avogadro/qtplugins/spectra/spectra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ void Spectra::setMode(int mode)
m_molecule->setForceVector(atom, v);
++atom;
}
m_molecule->emitChanged(QtGui::Molecule::Atoms | QtGui::Molecule::Added);
// m_molecule->emitChanged(QtGui::Molecule::Atoms | QtGui::Molecule::Added);

int frames = 5; // TODO: needs an option
int frameCounter = 0;
m_molecule->clearCoordinate3d();
m_molecule->setCoordinate3d(atomPositions, frameCounter++);

// Current coords + displacement.
Expand Down

0 comments on commit 9898a5c

Please sign in to comment.