Skip to content

Commit

Permalink
patch yaehmop module
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Young <[email protected]>
  • Loading branch information
TactfulDeity committed Nov 13, 2024
1 parent a0592c8 commit f736761
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 66 deletions.
10 changes: 6 additions & 4 deletions avogadro/qtplugins/yaehmop/banddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
******************************************************************************/

#include "banddialog.h"

#include "ui_banddialog.h"

#include <QSettings>

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

BandDialog::BandDialog(QWidget* aParent, YaehmopSettings& yaehmopSettings)
: QDialog(aParent), m_ui(new Ui::BandDialog),
Expand All @@ -18,6 +18,9 @@ BandDialog::BandDialog(QWidget* aParent, YaehmopSettings& yaehmopSettings)
m_ui->setupUi(this);
}

// Destructor must be defined after Ui::BandDialog has been resovled
BandDialog::~BandDialog() = default;

int BandDialog::exec()
{
// Load the settings then exec
Expand Down Expand Up @@ -54,5 +57,4 @@ void BandDialog::accept()
QDialog::accept();
}

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins
13 changes: 6 additions & 7 deletions avogadro/qtplugins/yaehmop/banddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
#ifndef AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H
#define AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H

#include <memory>
#include "yaehmopsettings.h"

#include <QDialog>

#include "yaehmopsettings.h"
#include <memory>

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

namespace Ui {
class BandDialog;
Expand All @@ -28,7 +27,7 @@ class BandDialog : public QDialog

public:
explicit BandDialog(QWidget* parent, YaehmopSettings& yaehmopSettings);
~BandDialog() = default;
~BandDialog();

public slots:
int exec() override;
Expand All @@ -41,6 +40,6 @@ protected slots:
YaehmopSettings& m_yaehmopSettings;
};

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

#endif // AVOGADRO_QTPLUGINS_YAEHMOPBANDDIALOG_H
6 changes: 2 additions & 4 deletions avogadro/qtplugins/yaehmop/specialkpointsdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#ifndef AVOGADRO_QTPLUGINS_YAEHMOP_SPECIALKPOINTSDATA_H
#define AVOGADRO_QTPLUGINS_YAEHMOP_SPECIALKPOINTSDATA_H

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

// There are 230 of these (not including the first value, which is null)
// One point for each space group.
Expand Down Expand Up @@ -392,7 +391,6 @@ const char* special_k_points[] = {
"GM 0 0 0,H 0.5 -0.5 0.5,P 0.25 0.25 0.25,N 0 0 0.5" // 230
};

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

#endif
42 changes: 20 additions & 22 deletions avogadro/qtplugins/yaehmop/yaehmop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/

#include "yaehmop.h"

#include "banddialog.h"
#include "specialkpoints.h"
#include "yaehmopout.h"

#include <avogadro/core/array.h>
#include <avogadro/core/elements.h>
#include <avogadro/core/unitcell.h>
#include <avogadro/core/vector.h>
#include <avogadro/qtgui/molecule.h>
#include <avogadro/vtk/chartdialog.h>
#include <avogadro/vtk/chartwidget.h>

#include <QAction>
#include <QByteArray>
#include <QCoreApplication>
Expand All @@ -17,29 +31,14 @@
#include <QTextEdit>
#include <QVBoxLayout>

#include <avogadro/core/array.h>
#include <avogadro/core/elements.h>
#include <avogadro/core/unitcell.h>
#include <avogadro/core/vector.h>
#include <avogadro/qtgui/molecule.h>
#include <avogadro/vtk/chartdialog.h>
#include <avogadro/vtk/chartwidget.h>

#include "banddialog.h"
#include "specialkpoints.h"
#include "yaehmopout.h"

#include "yaehmop.h"

using Avogadro::Vector3;
using Avogadro::Vector3i;
using Avogadro::Core::Array;
using Avogadro::Core::Elements;
using Avogadro::Core::UnitCell;
using Avogadro::QtGui::Molecule;

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

Yaehmop::Yaehmop(QObject* parent_)
: Avogadro::QtGui::ExtensionPlugin(parent_), m_actions(QList<QAction*>()),
Expand Down Expand Up @@ -132,7 +131,7 @@ void Yaehmop::moleculeChanged(unsigned int c)
{
Q_ASSERT(m_molecule == qobject_cast<Molecule*>(sender()));

Molecule::MoleculeChanges changes = static_cast<Molecule::MoleculeChanges>(c);
auto changes = static_cast<Molecule::MoleculeChanges>(c);

if (changes & Molecule::UnitCell) {
if (changes & Molecule::Added || changes & Molecule::Removed)
Expand Down Expand Up @@ -586,15 +585,15 @@ bool Yaehmop::executeYaehmop(const QByteArray& input, QByteArray& output,

void Yaehmop::showYaehmopInput(const QString& input)
{
QDialog* dialog = new QDialog(qobject_cast<QWidget*>(this->parent()));
auto* dialog = new QDialog(qobject_cast<QWidget*>(this->parent()));

// Make sure this gets deleted upon closing
dialog->setAttribute(Qt::WA_DeleteOnClose);

QVBoxLayout* layout = new QVBoxLayout(dialog);
auto* layout = new QVBoxLayout(dialog);
dialog->setLayout(layout);
dialog->setWindowTitle(tr("Yaehmop Input"));
QTextEdit* edit = new QTextEdit(dialog);
auto* edit = new QTextEdit(dialog);
layout->addWidget(edit);
dialog->resize(500, 500);

Expand All @@ -603,5 +602,4 @@ void Yaehmop::showYaehmopInput(const QString& input)
dialog->show();
}

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins
23 changes: 10 additions & 13 deletions avogadro/qtplugins/yaehmop/yaehmop.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@
#ifndef AVOGADRO_QTPLUGINS_YAEHMOP_H
#define AVOGADRO_QTPLUGINS_YAEHMOP_H

#include "banddialog.h"
#include "yaehmopsettings.h"

#include <avogadro/qtgui/extensionplugin.h>

#include <avogadro/core/vector.h>

#include <memory>

#include "yaehmopsettings.h"

// Forward declarations
class QByteArray;

namespace VTK {
class ChartDialog;
}

namespace Avogadro {
namespace QtPlugins {

class BandDialog;
namespace Avogadro::QtPlugins {

/**
* @brief Perform extended Hückel calculations with yaehmop.
Expand All @@ -36,13 +34,13 @@ class Yaehmop : public Avogadro::QtGui::ExtensionPlugin
explicit Yaehmop(QObject* parent_ = nullptr);
~Yaehmop();

QString name() const { return tr("Yaehmop"); }
QString description() const;
QList<QAction*> actions() const;
QStringList menuPath(QAction*) const;
QString name() const override { return tr("Yaehmop"); }
QString description() const override;
QList<QAction*> actions() const override;
QStringList menuPath(QAction*) const override;

public slots:
void setMolecule(QtGui::Molecule* mol);
void setMolecule(QtGui::Molecule* mol) override;

void moleculeChanged(unsigned int changes);

Expand Down Expand Up @@ -88,7 +86,6 @@ inline QString Yaehmop::description() const
return tr("Perform extended Hückel calculations with yaehmop.");
}

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

#endif // AVOGADRO_QTPLUGINS_YAEHMOPEXTENSION_H
10 changes: 4 additions & 6 deletions avogadro/qtplugins/yaehmop/yaehmopout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@

#include "yaehmopout.h"

#include <avogadro/core/vector.h>

#include <QDebug>
#include <QRegularExpression>
#include <QString>
#include <QVector>

#include <avogadro/core/vector.h>

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

inline bool printAndReturnFalse(const QString& error)
{
Expand Down Expand Up @@ -134,5 +133,4 @@ bool YaehmopOut::readBandData(const QString& data,
return true;
}

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins
10 changes: 4 additions & 6 deletions avogadro/qtplugins/yaehmop/yaehmopout.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

#include <avogadro/core/vector.h>

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

typedef struct
using specialKPoint = struct
{
QString label;
Vector3 coords;
} specialKPoint;
};

// Static class for Yaehmop output
class YaehmopOut
Expand All @@ -34,7 +33,6 @@ class YaehmopOut
QVector<specialKPoint>& specialKPoints);
};

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

#endif // AVOGADRO_QTPLUGINS_YAEHMOPOUT_H
7 changes: 3 additions & 4 deletions avogadro/qtplugins/yaehmop/yaehmopsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#include <QString>

namespace Avogadro {
namespace QtPlugins {
namespace Avogadro::QtPlugins {

static const char* YAEHMOP_DEFAULT_SPECIAL_KPOINTS = "GM 0 0 0";

Expand All @@ -32,6 +31,6 @@ struct YaehmopSettings
unsigned short numDim;
};

} // namespace QtPlugins
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

#endif // AVOGADRO_QTPLUGINS_YAEHMOPSETTINGS_H
1 change: 1 addition & 0 deletions tests/core/elementtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <gtest/gtest.h>

#include <avogadro/core/avogadrocore.h>
#include <avogadro/core/elements.h>
#include <avogadro/core/utilities.h>

Expand Down

0 comments on commit f736761

Please sign in to comment.