Skip to content

Commit

Permalink
Split spectra plot and vibrations extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 10, 2023
1 parent 97a7d9f commit d1f7701
Show file tree
Hide file tree
Showing 18 changed files with 1,258 additions and 272 deletions.
40 changes: 36 additions & 4 deletions avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ Molecule::Molecule()

Molecule::Molecule(const Molecule& other)
: m_data(other.m_data), m_partialCharges(other.m_partialCharges),
m_customElementMap(other.m_customElementMap), m_elements(other.m_elements),
m_positions2d(other.m_positions2d), m_positions3d(other.m_positions3d),
m_label(other.m_label), m_coordinates3d(other.m_coordinates3d),
m_timesteps(other.m_timesteps), m_hybridizations(other.m_hybridizations),
m_spectra(other.m_spectra), m_customElementMap(other.m_customElementMap),
m_elements(other.m_elements), m_positions2d(other.m_positions2d),
m_positions3d(other.m_positions3d), m_label(other.m_label),
m_coordinates3d(other.m_coordinates3d), m_timesteps(other.m_timesteps),
m_hybridizations(other.m_hybridizations),
m_formalCharges(other.m_formalCharges), m_colors(other.m_colors),
m_vibrationFrequencies(other.m_vibrationFrequencies),
m_vibrationIRIntensities(other.m_vibrationIRIntensities),
Expand Down Expand Up @@ -92,6 +93,9 @@ void Molecule::readProperties(const Molecule& other)
m_partialCharges[it->first] = it->second;
}

// copy spectra
m_spectra = other.m_spectra;

// copy orbital information
SlaterSet* slaterSet = dynamic_cast<SlaterSet*>(other.m_basisSet);
if (slaterSet != nullptr) {
Expand Down Expand Up @@ -127,6 +131,7 @@ void Molecule::readProperties(const Molecule& other)

Molecule::Molecule(Molecule&& other) noexcept
: m_data(other.m_data), m_partialCharges(std::move(other.m_partialCharges)),
m_spectra(other.m_spectra),
m_customElementMap(std::move(other.m_customElementMap)),
m_elements(other.m_elements), m_positions2d(other.m_positions2d),
m_positions3d(other.m_positions3d), m_label(other.m_label),
Expand Down Expand Up @@ -166,6 +171,7 @@ Molecule& Molecule::operator=(const Molecule& other)
if (this != &other) {
m_data = other.m_data;
m_partialCharges = other.m_partialCharges;
m_spectra = other.m_spectra;
m_customElementMap = other.m_customElementMap;
m_elements = other.m_elements;
m_positions2d = other.m_positions2d;
Expand Down Expand Up @@ -227,6 +233,7 @@ Molecule& Molecule::operator=(Molecule&& other) noexcept
if (this != &other) {
m_data = other.m_data;
m_partialCharges = std::move(other.m_partialCharges);
m_spectra = other.m_spectra;
m_customElementMap = std::move(other.m_customElementMap);
m_elements = other.m_elements;
m_positions2d = other.m_positions2d;
Expand Down Expand Up @@ -322,6 +329,31 @@ std::set<std::string> Molecule::partialChargeTypes() const
return types;
}

std::set<std::string> Molecule::spectraTypes() const
{
std::set<std::string> types;
for (auto& it : m_spectra)
types.insert(it.first);
return types;
}

void Molecule::setSpectra(const std::string& type, const MatrixX& value)
{
m_spectra[type] = value;
}

MatrixX Molecule::spectra(const std::string& type) const
{
MatrixX value;

auto search = m_spectra.find(type);
if (search != m_spectra.end()) {
value = search->second; // value from the map
}

return value;
}

void Molecule::setFrozenAtom(Index atomId, bool frozen)
{
if (atomId >= m_atomicNumbers.size())
Expand Down
11 changes: 11 additions & 0 deletions avogadro/core/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ class AVOGADROCORE_EXPORT Molecule
/** \overload */
VariantMap& dataMap();

/** @return a specific spectra entry */
MatrixX spectra(const std::string& name) const;

/** Sets the spectra value with @p name to @p value. */
void setSpectra(const std::string& name, const MatrixX& value);

/** @return the list of available spectra */
std::set<std::string> spectraTypes() const;

/** Sets atomic partial charges with @p type to @p value. */
void setPartialCharges(const std::string& type, const MatrixX& value);

Expand Down Expand Up @@ -764,6 +773,8 @@ class AVOGADROCORE_EXPORT Molecule
VariantMap m_data;
std::map<std::string, MatrixX>
m_partialCharges; //!< Sets of atomic partial charges

std::map<std::string, MatrixX> m_spectra; //!< Sets of spectra

Check notice on line 777 in avogadro/core/molecule.h

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

avogadro/core/molecule.h#L777

class member 'Molecule::m_spectra' is never used.
CustomElementMap m_customElementMap;
ElementMask m_elements; //!< Which elements this molecule contains (e.g., for
//!< force fields)
Expand Down
24 changes: 10 additions & 14 deletions avogadro/qtplugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ add_subdirectory(hydrogens)
add_subdirectory(importpqr)
add_subdirectory(insertdna)
add_subdirectory(label)
add_subdirectory(lammpsinput)
add_subdirectory(lineformatinput)
add_subdirectory(manipulator)
add_subdirectory(measuretool)
add_subdirectory(navigator)
add_subdirectory(networkdatabases)
add_subdirectory(openbabel)
add_subdirectory(openmminput)
add_subdirectory(playertool)
add_subdirectory(ply)
add_subdirectory(povray)
Expand All @@ -130,36 +132,32 @@ if(USE_SPGLIB)
add_subdirectory(spacegroup)
endif()
add_subdirectory(surfaces)
add_subdirectory(lammpsinput)
add_subdirectory(openmminput)
add_subdirectory(templatetool)
add_subdirectory(vibrations)
add_subdirectory(vrml)

if(QT_VERSION EQUAL 5)
# This will need some work on the QRegExp migration
add_subdirectory(apbs)
add_subdirectory(coordinateeditor)
add_subdirectory(cp2kinput)
add_subdirectory(gamessinput)
add_subdirectory(insertfragment)
add_subdirectory(molecularproperties)
# The SVG library is not available in Qt 6
add_subdirectory(svg)
endif()
add_subdirectory(spectra)
add_subdirectory(templatetool)
add_subdirectory(vrml)

# Plugins that require VTK
if(USE_VTK)
add_subdirectory(coloropacitymap)
add_subdirectory(spectra)
add_subdirectory(plotpdf)
add_subdirectory(plotrmsd)
add_subdirectory(plotxrd)
add_subdirectory(yaehmop)
endif()

if(QT_VERSION EQUAL 5)
# QRegExp fixes needed in classes these depend on
add_subdirectory(apbs)
add_subdirectory(cp2kinput)
add_subdirectory(gamessinput)
endif()

# script plugins (input generators, etc.)
if(QT_VERSION EQUAL 5)
# QRegExp fixes needed in classes these depend on
Expand All @@ -186,8 +184,6 @@ add_subdirectory(licorice)
add_subdirectory(meshes)
add_subdirectory(noncovalent)
add_subdirectory(vanderwaals)
# redundant since there's universal AO
# add_subdirectory(vanderwaalsao)
add_subdirectory(wireframe)
if (USE_OPENGL)
# needs some raw OpenGL code
Expand Down
12 changes: 4 additions & 8 deletions avogadro/qtplugins/spectra/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
set(plugin_srcs
vibrationdialog.cpp
vibrationmodel.cpp
spectradialog.cpp
spectra.cpp
)

avogadro_plugin(Spectra
"Spectra and Vibrations"
"Spectra Plots"
ExtensionPlugin
spectra.h
Spectra
"${plugin_srcs}"
"vibrationdialog.ui"
"spectradialog.ui"
)

if (USE_VTK)
add_definitions(-DUSE_VTK)
target_link_libraries(Spectra PRIVATE Avogadro::Vtk)
endif()
target_link_libraries(Spectra PRIVATE Avogadro::Vtk)
Loading

0 comments on commit d1f7701

Please sign in to comment.