Skip to content

Commit

Permalink
Add readProperties method for copying basis, etc. but not atoms
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 204a409 commit 01a1413
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
34 changes: 34 additions & 0 deletions avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "color3f.h"
#include "cube.h"
#include "elements.h"
#include "gaussianset.h"
#include "layermanager.h"
#include "mdlvalence_p.h"
#include "mesh.h"
Expand Down Expand Up @@ -74,6 +75,39 @@ Molecule::Molecule(const Molecule& other)
}
}

void Molecule::readProperties(const Molecule& other)
{
m_data = other.m_data;
m_partialCharges = other.m_partialCharges;
m_label = other.m_label;
m_colors = other.m_colors;

// copy orbital information
GaussianSet *gaussianSet = dynamic_cast<GaussianSet*>(other.m_basisSet);
if (gaussianSet) {
m_basisSet = gaussianSet->clone();
m_basisSet->setMolecule(this);
}

// copy spectra information
m_vibrationFrequencies = other.m_vibrationFrequencies;
m_vibrationIRIntensities = other.m_vibrationIRIntensities;
m_vibrationRamanIntensities = other.m_vibrationRamanIntensities;
m_vibrationLx = other.m_vibrationLx;

// Copy over any meshes
for (Index i = 0; i < other.meshCount(); ++i) {
Mesh* m = addMesh();
*m = *other.mesh(i);
}

// Copy over any cubes
for (Index i = 0; i < other.cubeCount(); ++i) {
Cube* c = addCube();
*c = *other.cube(i);
}
}

Molecule::Molecule(Molecule&& other) noexcept
: m_data(other.m_data), m_partialCharges(std::move(other.m_partialCharges)),
m_customElementMap(std::move(other.m_customElementMap)),
Expand Down
7 changes: 7 additions & 0 deletions avogadro/core/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class AVOGADROCORE_EXPORT Molecule
/** Destroys the molecule object. */
virtual ~Molecule();

/**
* Adds the properties from the supplied
* molecule to this molecule. Does not otherwise
* modify atoms / bonds / residues, etc.
*/
void readProperties(const Molecule& other);

/** Sets the data value with @p name to @p value. */
void setData(const std::string& name, const Variant& value);

Expand Down

0 comments on commit 01a1413

Please sign in to comment.