-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from badarsh2/LAMMPS-input
LAMMPS Input plugin ported from Avogadro 1
- Loading branch information
Showing
7 changed files
with
2,393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Extension | ||
set(gamessinput_srcs | ||
lammpsinputdialog.cpp | ||
lammpsinput.cpp | ||
) | ||
|
||
avogadro_plugin(LammpsInput | ||
"LAMMPS input file generation" | ||
ExtensionPlugin | ||
lammpsinput.h | ||
LammpsInput | ||
"${gamessinput_srcs}" | ||
lammpsinputdialog.ui | ||
) | ||
|
||
target_link_libraries(LammpsInput) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
Copyright 2018 Kitware, Inc. | ||
This source code is released under the New BSD License, (the "License"). | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************/ | ||
|
||
#include "lammpsinput.h" | ||
|
||
#include "lammpsinputdialog.h" | ||
|
||
#include <avogadro/io/fileformat.h> | ||
#include <avogadro/qtgui/fileformatdialog.h> | ||
#include <avogadro/qtgui/molecule.h> | ||
|
||
#include <QtCore/QDebug> | ||
|
||
#include <QtWidgets/QAction> | ||
#include <QtWidgets/QMessageBox> | ||
|
||
namespace Avogadro { | ||
namespace Core { | ||
class Molecule; | ||
} | ||
namespace QtPlugins { | ||
|
||
LammpsInput::LammpsInput(QObject* parent_) | ||
: ExtensionPlugin(parent_), m_action(new QAction(this)), m_molecule(nullptr), | ||
m_dialog(nullptr), m_outputFormat(nullptr) | ||
{ | ||
m_action->setEnabled(true); | ||
m_action->setText(tr("&LAMMPS Input")); | ||
connect(m_action, SIGNAL(triggered()), SLOT(menuActivated())); | ||
} | ||
|
||
LammpsInput::~LammpsInput() | ||
{ | ||
} | ||
|
||
QList<QAction*> LammpsInput::actions() const | ||
{ | ||
QList<QAction*> actions_; | ||
actions_.append(m_action); | ||
return actions_; | ||
} | ||
|
||
QStringList LammpsInput::menuPath(QAction*) const | ||
{ | ||
QStringList path; | ||
path << tr("&Extensions") << tr("Molecular Dynamics"); | ||
return path; | ||
} | ||
|
||
void LammpsInput::setMolecule(QtGui::Molecule* mol) | ||
{ | ||
if (m_dialog) | ||
m_dialog->setMolecule(mol); | ||
m_molecule = mol; | ||
} | ||
|
||
bool LammpsInput::readMolecule(QtGui::Molecule& mol) | ||
{ | ||
Io::FileFormat* reader = m_outputFormat->newInstance(); | ||
bool success = reader->readFile(m_outputFileName.toStdString(), mol); | ||
if (!success) { | ||
QMessageBox::information(qobject_cast<QWidget*>(parent()), tr("Error"), | ||
tr("Error reading output file '%1':\n%2") | ||
.arg(m_outputFileName) | ||
.arg(QString::fromStdString(reader->error()))); | ||
} | ||
|
||
m_outputFormat = nullptr; | ||
m_outputFileName.clear(); | ||
|
||
return success; | ||
} | ||
|
||
void LammpsInput::menuActivated() | ||
{ | ||
if (!m_dialog) { | ||
m_dialog = new LammpsInputDialog(qobject_cast<QWidget*>(parent())); | ||
} | ||
m_dialog->setMolecule(m_molecule); | ||
m_dialog->show(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
Copyright 2018 Kitware, Inc. | ||
This source code is released under the New BSD License, (the "License"). | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
******************************************************************************/ | ||
|
||
#ifndef AVOGADRO_QTPLUGINS_LAMMPSINPUT_H | ||
#define AVOGADRO_QTPLUGINS_LAMMPSINPUT_H | ||
|
||
#include <avogadro/qtgui/extensionplugin.h> | ||
|
||
class QAction; | ||
class QDialog; | ||
|
||
namespace Avogadro { | ||
namespace Io { | ||
class FileFormat; | ||
} | ||
|
||
namespace QtPlugins { | ||
|
||
class LammpsInputDialog; | ||
|
||
class LammpsInput : public QtGui::ExtensionPlugin | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit LammpsInput(QObject* parent = 0); | ||
~LammpsInput() override; | ||
|
||
QString name() const override { return tr("LAMMPS input"); } | ||
|
||
QString description() const override | ||
{ | ||
return tr("Generate input for LAMMPS."); | ||
} | ||
|
||
QList<QAction*> actions() const override; | ||
|
||
QStringList menuPath(QAction*) const override; | ||
|
||
void setMolecule(QtGui::Molecule* mol) override; | ||
|
||
public slots: | ||
/** | ||
* Emitted when the user requests that a job's output be loaded in Avogadro. | ||
*/ | ||
// void openJobOutput(const MoleQueue::JobObject& job); | ||
|
||
bool readMolecule(QtGui::Molecule& mol) override; | ||
|
||
private slots: | ||
void menuActivated(); | ||
|
||
private: | ||
QAction* m_action; | ||
QtGui::Molecule* m_molecule; | ||
LammpsInputDialog* m_dialog; | ||
const Io::FileFormat* m_outputFormat; | ||
QString m_outputFileName; | ||
}; | ||
} | ||
} | ||
|
||
#endif // AVOGADRO_QTPLUGINS_LAMMPSINPUT_H |
Oops, something went wrong.