1 /****************************************************************************** 2 3 This source file is part of the Avogadro project. 4 5 Copyright 2016 Kitware, Inc. 6 7 This source code is released under the New BSD License, (the "License"). 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 15 ******************************************************************************/ 16 17 #include "supercelldialog.h" 18 #include "ui_supercelldialog.h" 19 20 #include <avogadro/core/crystaltools.h> 21 #include <avogadro/core/molecule.h> 22 23 #include <avogadro/qtgui/molecule.h> 24 #include <avogadro/qtgui/rwmolecule.h> 25 26 using Avogadro::Core::CrystalTools; 27 28 namespace Avogadro { 29 namespace QtPlugins { 30 SupercellDialog(QWidget * p)31SupercellDialog::SupercellDialog(QWidget* p) 32 : QDialog(p), m_ui(new Ui::SupercellDialog) 33 { 34 m_ui->setupUi(this); 35 } 36 ~SupercellDialog()37SupercellDialog::~SupercellDialog() 38 { 39 delete m_ui; 40 } 41 buildSupercell(Avogadro::QtGui::Molecule & mol)42bool SupercellDialog::buildSupercell(Avogadro::QtGui::Molecule& mol) 43 { 44 // If the user rejected, just return false 45 if (this->exec() == QDialog::Rejected) 46 return false; 47 48 // Read the values 49 unsigned int a = m_ui->aCellSpinBox->value(); 50 unsigned int b = m_ui->bCellSpinBox->value(); 51 unsigned int c = m_ui->cCellSpinBox->value(); 52 53 // No need to do anything if all the values are one 54 if (a == 1 && b == 1 && c == 1) 55 return true; 56 57 // Run the supercell-building tool 58 mol.undoMolecule()->buildSupercell(a, b, c); 59 return true; 60 } 61 62 } // namespace QtPlugins 63 } // namespace Avogadro 64