| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "supercelldialog.h" |
| 7 |
#include "ui_supercelldialog.h" |
| 8 |
|
| 9 |
#include <avogadro/core/crystaltools.h> |
| 10 |
#include <avogadro/core/molecule.h> |
| 11 |
|
| 12 |
#include <avogadro/qtgui/molecule.h> |
| 13 |
#include <avogadro/qtgui/rwmolecule.h> |
| 14 |
|
| 15 |
namespace Avogadro::QtPlugins { |
| 16 |
|
| 17 |
SupercellDialog::SupercellDialog(QWidget* p) |
| 18 |
: QDialog(p), m_ui(new Ui::SupercellDialog) |
| 19 |
{ |
| 20 |
m_ui->setupUi(this); |
| 21 |
} |
| 22 |
|
| 23 |
SupercellDialog::~SupercellDialog() |
| 24 |
{ |
| 25 |
delete m_ui; |
| 26 |
} |
| 27 |
|
| 28 |
bool SupercellDialog::buildSupercell(Avogadro::QtGui::Molecule& mol) |
| 29 |
{ |
| 30 |
// If the user rejected, just return false |
| 31 |
if (this->exec() == QDialog::Rejected) |
| 32 |
return false; |
| 33 |
|
| 34 |
// Read the values |
| 35 |
unsigned int a = m_ui->aCellSpinBox->value(); |
| 36 |
unsigned int b = m_ui->bCellSpinBox->value(); |
| 37 |
unsigned int c = m_ui->cCellSpinBox->value(); |
| 38 |
|
| 39 |
// No need to do anything if all the values are one |
| 40 |
if (a == 1 && b == 1 && c == 1) |
| 41 |
return true; |
| 42 |
|
| 43 |
// Run the supercell-building tool |
| 44 |
mol.undoMolecule()->buildSupercell(a, b, c); |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
} // namespace Avogadro::QtPlugins |