Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/classes/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ int Structure::nAtoms(Atom::Presence withPresence) const
{ return i->isPresence(withPresence); });
}

// Return atom at index
StructureAtom *Structure::atomAt(int i) { return atoms_[i].get(); }

// Return atoms
const std::vector<std::unique_ptr<StructureAtom>> &Structure::atoms() const { return atoms_; }
std::vector<std::unique_ptr<StructureAtom>> &Structure::atoms() { return atoms_; }
Expand Down
2 changes: 2 additions & 0 deletions src/classes/structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Structure : public Serialisable<>
void removeAtoms(const std::vector<const StructureAtom *> &atoms);
// Return the number of atoms
int nAtoms(Atom::Presence withPresence = Atom::Presence::Any) const;
// Return atom at index
StructureAtom *atomAt(int i);
// Return atoms
const std::vector<std::unique_ptr<StructureAtom>> &atoms() const;
std::vector<std::unique_ptr<StructureAtom>> &atoms();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/createGrapheneSpeciesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "gui/selectElementDialog.h"
#include "gui/ui_createGrapheneSpeciesDialog.h"
#include "gui/wizard.h"
#include "io/import/cif.h"
#include "main/dissolve.h"
#include "nodes/cif/io/cifContext.h"
#include <QDialog>

// Forward Declarations
Expand Down
82 changes: 41 additions & 41 deletions src/gui/importCIFDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <QInputDialog>

ImportCIFDialog::ImportCIFDialog(QWidget *parent, Dissolve &dissolve)
: QDialog(parent), cifAssemblyModel_(cifHandler_.assemblies()), dissolve_(dissolve)
: QDialog(parent), cifAssemblyModel_(cifContext_.assemblies()), dissolve_(dissolve)
{
ui_.setupUi(this);

Expand All @@ -38,7 +38,7 @@ ImportCIFDialog::ImportCIFDialog(QWidget *parent, Dissolve &dissolve)
ComboEnumOptionsPopulator(ui_.DensityUnitsCombo, Units::densityUnits());

// Set display configuration
ui_.StructureViewer->setConfiguration(cifHandler_.generatedConfiguration());
ui_.StructureViewer->setConfiguration(cifContext_.generatedConfiguration());

createMoietyRemovalNETA(ui_.MoietyNETARemovalEdit->text().toStdString());
}
Expand All @@ -53,34 +53,34 @@ void ImportCIFDialog::updateWidgets()
Locker updateLock(widgetsUpdating_);

// DATA_ ID
ui_.InfoDataLabel->setText(QString::fromStdString(cifHandler_.getTagString("DATA_").value_or("<Unknown>")));
ui_.InfoDataLabel->setText(QString::fromStdString(cifContext_.getTagString("DATA_").value_or("<Unknown>")));

// Chemical Formula
ui_.InfoChemicalFormulaLabel->setText(QString::fromStdString(cifHandler_.chemicalFormula()));
ui_.InfoChemicalFormulaLabel->setText(QString::fromStdString(cifContext_.chemicalFormula()));

// Publication Data
ui_.InfoPublicationTitleLabel->setText(
QString::fromStdString(cifHandler_.getTagString("_publ_section_title").value_or("<Unknown>")));
QString::fromStdString(cifContext_.getTagString("_publ_section_title").value_or("<Unknown>")));
ui_.InfoPublicationReferenceLabel->setText(QString::fromStdString(std::format(
"{}, {}, <b>{}</b>, {}", cifHandler_.getTagString("_journal_name_full").value_or("N/A"),
cifHandler_.getTagString("_journal_year").value_or("N/A"), cifHandler_.getTagString("_journal_volume").value_or("N/A"),
cifHandler_.getTagString("_journal_page_first").value_or("N/A"))));
"{}, {}, <b>{}</b>, {}", cifContext_.getTagString("_journal_name_full").value_or("N/A"),
cifContext_.getTagString("_journal_year").value_or("N/A"), cifContext_.getTagString("_journal_volume").value_or("N/A"),
cifContext_.getTagString("_journal_page_first").value_or("N/A"))));
ui_.InfoAuthorsList->clear();
auto authors = cifHandler_.getTagStrings("_publ_author_name");
auto authors = cifContext_.getTagStrings("_publ_author_name");
for (auto &author : authors)
ui_.InfoAuthorsList->addItem(QString::fromStdString(author));

// Spacegroup
ui_.SpaceGroupsCombo->setCurrentIndex(cifHandler_.spaceGroup() - 1);
ui_.SpaceGroupsCombo->setCurrentIndex(cifContext_.spaceGroup() - 1);

// Bonding
ui_.BondFromCIFRadio->setEnabled(cifHandler_.hasBondDistances());
ui_.BondFromCIFRadio->setEnabled(cifContext_.hasBondDistances());

// Assemblies
ui_.AssemblyView->expandAll();

// Configuration information
auto *cfg = cifHandler_.generatedConfiguration();
auto *cfg = cifContext_.generatedConfiguration();
const auto *box = cfg->box();
ui_.CurrentBoxTypeLabel->setText(QString::fromStdString(std::string(Box::boxTypes().keyword(box->type()))));
QString boxInfo = QString("<b>A:</b> %1 &#8491;<br>").arg(box->axisLengths().x);
Expand All @@ -95,7 +95,7 @@ void ImportCIFDialog::updateWidgets()
ui_.MoleculePopulationLabel->setText(QString::number(cfg->nMolecules()));

// Output
auto validSpecies = !cifHandler_.molecularSpecies().empty();
auto validSpecies = !cifContext_.molecularSpecies().empty();
ui_.OutputMolecularRadio->setEnabled(validSpecies);
ui_.OutputFrameworkRadio->setEnabled(!validSpecies);
ui_.OutputSupermoleculeRadio->setEnabled(!validSpecies);
Expand All @@ -106,7 +106,7 @@ void ImportCIFDialog::updateWidgets()

// Update molecular species list
ui_.OutputMolecularSpeciesList->clear();
for (auto &molecularSp : cifHandler_.molecularSpecies())
for (auto &molecularSp : cifContext_.molecularSpecies())
{
ui_.OutputMolecularSpeciesList->addItem(QString::fromStdString(std::string(molecularSp.species()->name())));
}
Expand All @@ -118,7 +118,7 @@ void ImportCIFDialog::updateWidgets()
// Update density label
void ImportCIFDialog::updateDensityLabel()
{
auto *cfg = cifHandler_.generatedConfiguration();
auto *cfg = cifContext_.generatedConfiguration();
if (!cfg)
ui_.DensityUnitsLabel->setText("N/A");
else
Expand All @@ -131,11 +131,11 @@ void ImportCIFDialog::updateDensityLabel()
void ImportCIFDialog::on_InputFileEdit_editingFinished()
{
// Load the CIF file
if (!cifHandler_.read(ui_.InputFileEdit->text().toStdString()))
if (!cifContext_.read(ui_.InputFileEdit->text().toStdString()))
Messenger::error("Failed to load CIF file '{}'.\n", ui_.InputFileEdit->text().toStdString());
else
{
cifHandler_.generate();
cifContext_.generate();
updateWidgets();
}
}
Expand All @@ -157,7 +157,7 @@ void ImportCIFDialog::on_SpaceGroupsCombo_currentIndexChanged(int index)
if (widgetsUpdating_)
return;

cifHandler_.setSpaceGroup((SpaceGroups::SpaceGroupId)(ui_.SpaceGroupsCombo->currentIndex() + 1));
cifContext_.setSpaceGroup((SpaceGroups::SpaceGroupId)(ui_.SpaceGroupsCombo->currentIndex() + 1));

updateWidgets();
}
Expand All @@ -166,7 +166,7 @@ void ImportCIFDialog::on_NormalOverlapToleranceRadio_clicked(bool checked)
{
if (checked)
{
cifHandler_.setOverlapTolerance(0.1);
cifContext_.setOverlapTolerance(0.1);
updateWidgets();
}
}
Expand All @@ -175,7 +175,7 @@ void ImportCIFDialog::on_LooseOverlapToleranceRadio_clicked(bool checked)
{
if (checked)
{
cifHandler_.setOverlapTolerance(0.5);
cifContext_.setOverlapTolerance(0.5);
updateWidgets();
}
}
Expand All @@ -184,7 +184,7 @@ void ImportCIFDialog::on_CalculateBondingRadio_clicked(bool checked)
{
if (checked)
{
cifHandler_.setUseCIFBondingDefinitions(false);
cifContext_.setUseCIFBondingDefinitions(false);
updateWidgets();
}
}
Expand All @@ -193,14 +193,14 @@ void ImportCIFDialog::on_BondFromCIFRadio_clicked(bool checked)
{
if (checked)
{
cifHandler_.setUseCIFBondingDefinitions(true);
cifContext_.setUseCIFBondingDefinitions(true);
updateWidgets();
}
}

void ImportCIFDialog::on_BondingPreventMetallicCheck_clicked(bool checked)
{
cifHandler_.setPreventMetallicBonds(checked);
cifContext_.setPreventMetallicBonds(checked);

updateWidgets();
}
Expand All @@ -217,13 +217,13 @@ bool ImportCIFDialog::createMoietyRemovalNETA(std::string definition)

void ImportCIFDialog::on_MoietyRemoveAtomicsCheck_clicked(bool checked)
{
cifHandler_.setRemoveAtomics(checked);
cifContext_.setRemoveAtomics(checked);
updateWidgets();
}

void ImportCIFDialog::on_MoietyRemoveWaterCheck_clicked(bool checked)
{
cifHandler_.setRemoveWaterAndCoordinateOxygens(checked);
cifContext_.setRemoveWaterAndCoordinateOxygens(checked);
updateWidgets();
}

Expand All @@ -236,7 +236,7 @@ void ImportCIFDialog::on_MoietyRemoveByNETACheck_clicked(bool checked)
if (ui_.MoietyNETARemovalIndicator->state() != CheckIndicator::OKState)
return;

cifHandler_.setRemoveNETA(checked, ui_.MoietyNETARemoveFragmentsCheck->isChecked());
cifContext_.setRemoveNETA(checked, ui_.MoietyNETARemoveFragmentsCheck->isChecked());
updateWidgets();
}

Expand All @@ -245,8 +245,8 @@ void ImportCIFDialog::on_MoietyNETARemovalEdit_textEdited(const QString &text)
if (!createMoietyRemovalNETA(ui_.MoietyNETARemovalEdit->text().toStdString()))
return;

cifHandler_.setRemoveNETA(ui_.MoietyRemoveByNETACheck->isChecked(), ui_.MoietyNETARemoveFragmentsCheck->isChecked());
cifHandler_.setMoietyRemovalNETA(moietyNETA_.definitionString());
cifContext_.setRemoveNETA(ui_.MoietyRemoveByNETACheck->isChecked(), ui_.MoietyNETARemoveFragmentsCheck->isChecked());
cifContext_.setMoietyRemovalNETA(moietyNETA_.definitionString());
updateWidgets();
}

Expand All @@ -255,32 +255,32 @@ void ImportCIFDialog::on_MoietyNETARemoveFragmentsCheck_clicked(bool checked)
if (ui_.MoietyNETARemovalIndicator->state() != CheckIndicator::OKState)
return;

cifHandler_.setRemoveNETA(ui_.MoietyRemoveByNETACheck->isChecked(), checked);
cifContext_.setRemoveNETA(ui_.MoietyRemoveByNETACheck->isChecked(), checked);
updateWidgets();
}

void ImportCIFDialog::assembliesChanged(const QModelIndex &, const QModelIndex &, const QList<int> &)
{
cifHandler_.generate();
cifContext_.generate();
updateWidgets();
}

void ImportCIFDialog::on_RepeatASpin_valueChanged(int value)
{
cifHandler_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
cifContext_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
updateWidgets();
}

void ImportCIFDialog::on_RepeatBSpin_valueChanged(int value)
{
cifHandler_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
cifContext_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
updateWidgets();
}

void ImportCIFDialog::on_RepeatCSpin_valueChanged(int value)
{

cifHandler_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
cifContext_.setSupercellRepeat({ui_.RepeatASpin->value(), ui_.RepeatBSpin->value(), ui_.RepeatCSpin->value()});
updateWidgets();
}

Expand All @@ -300,22 +300,22 @@ void ImportCIFDialog::on_OutputSupermoleculeRadio_clicked(bool checked) {}

void ImportCIFDialog::on_OKButton_clicked(bool checked)
{
Flags<CIFHandler::OutputFlags> outputFlags;
Flags<CIFContext::OutputFlags> outputFlags;
if (ui_.OutputMolecularRadio->isChecked())
outputFlags.setFlag(CIFHandler::OutputFlags::OutputMolecularSpecies);
outputFlags.setFlag(CIFContext::OutputFlags::OutputMolecularSpecies);
else if (ui_.OutputFrameworkRadio->isChecked())
outputFlags.setFlag(CIFHandler::OutputFlags::OutputFramework);
outputFlags.setFlag(CIFContext::OutputFlags::OutputFramework);
else if (ui_.OutputSupermoleculeRadio->isChecked())
outputFlags.setFlag(CIFHandler::OutputFlags::OutputSupermolecule);
outputFlags.setFlag(CIFContext::OutputFlags::OutputSupermolecule);

// Output a configuration as well as the species for certain options
if (outputFlags.isSet(CIFHandler::OutputFlags::OutputMolecularSpecies) ||
outputFlags.isSet(CIFHandler::OutputFlags::OutputFramework))
if (outputFlags.isSet(CIFContext::OutputFlags::OutputMolecularSpecies) ||
outputFlags.isSet(CIFContext::OutputFlags::OutputFramework))
{
outputFlags.setFlag(CIFHandler::OutputFlags::OutputConfiguration);
outputFlags.setFlag(CIFContext::OutputFlags::OutputConfiguration);
}

cifHandler_.finalise(dissolve_.coreData(), outputFlags);
cifContext_.finalise(dissolve_.coreData(), outputFlags);

accept();
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/importCIFDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "gui/models/cifAssemblyModel.h"
#include "gui/ui_importCIFDialog.h"
#include "gui/wizard.h"
#include "io/import/cif.h"
#include "main/dissolve.h"
#include "nodes/cif/io/cifContext.h"
#include <QDialog>

// Forward Declarations
Expand Down Expand Up @@ -39,7 +39,7 @@ class ImportCIFDialog : public QDialog
// Main Dissolve object
Dissolve &dissolve_;
// CIF Handler
CIFHandler cifHandler_;
CIFContext cifContext_;
// NETA for moiety removal
NETADefinition moietyNETA_;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/models/cifAssemblyModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma once

#include "io/import/cif.h"
#include "nodes/cif/io/cifContext.h"
#include <QAbstractItemModel>
#include <QModelIndex>

Expand Down
2 changes: 1 addition & 1 deletion src/io/import/CIFImportErrorListeners.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "io/import/CIFImportErrorListeners.h"
#include "nodes/cif/io/CIFImportErrorListeners.h"
#include "base/messenger.h"
#include "base/sysFunc.h"

Expand Down
2 changes: 1 addition & 1 deletion src/io/import/CIFImportLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lexer grammar CIFImportLexer;
// Add custom includes after standard ANTLR includes in both *.h and *.cpp files
@lexer::postinclude {
#include "base/sysFunc.h"
#include "io/import/CIFImportVisitor.h"
#include "nodes/cif/io/CIFImportVisitor.h"
}

// Directly precedes the lexer class declaration in the h file (e.g. for additional types etc.).
Expand Down
4 changes: 2 additions & 2 deletions src/io/import/CIFImportVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "io/import/CIFImportVisitor.h"
#include "nodes/cif/io/CIFImportVisitor.h"
#include "base/messenger.h"
#include "base/sysFunc.h"
#include "io/import/CIFImportErrorListeners.h"
#include "nodes/cif/io/CIFImportErrorListeners.h"

CIFImportVisitor::CIFImportVisitor(CIFHandler::CIFTags &tags) : tags_(tags) {}

Expand Down
2 changes: 1 addition & 1 deletion src/io/import/CIFImportVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#include "CIFImportParserBaseVisitor.h"
#include "io/import/cif.h"
#include "nodes/cif/io/cif.h"
#include "templates/optionalRef.h"
#include <antlr4-runtime.h>

Expand Down
Loading