From 31b8ac01c67e2b12c8c80255d1afa6ecbf9f76c2 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sat, 2 Mar 2024 16:31:41 -0500 Subject: [PATCH] Ask before re-perceiving a space group (e.g., if run on a primitive unit cell) Signed-off-by: Geoff Hutchison --- avogadro/qtplugins/spacegroup/spacegroup.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/avogadro/qtplugins/spacegroup/spacegroup.cpp b/avogadro/qtplugins/spacegroup/spacegroup.cpp index f50fa34bf0..cedeecfea5 100644 --- a/avogadro/qtplugins/spacegroup/spacegroup.cpp +++ b/avogadro/qtplugins/spacegroup/spacegroup.cpp @@ -174,6 +174,25 @@ void SpaceGroup::updateActions() void SpaceGroup::perceiveSpaceGroup() { + // only do this if we don't have a Hall number set + if (m_molecule == nullptr) + return; + + if (m_molecule->hallNumber() != 0) { + // Ask if the user wants to overwrite the current space group + std::string hallSymbol = + Core::SpaceGroups::hallSymbol(m_molecule->hallNumber()); + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(nullptr, tr("Perceive Space Group"), + tr("The space group is already set to: %1.\n" + "Would you like to overwrite it?") + .arg(hallSymbol.c_str()), + QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::No) + return; + } + unsigned short hallNumber = AvoSpglib::getHallNumber(*m_molecule, m_spgTol); unsigned short intNum = Core::SpaceGroups::internationalNumber(hallNumber); std::string hallSymbol = Core::SpaceGroups::hallSymbol(hallNumber);