| 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 "conformersearchdialog.h" |
| 7 |
|
| 8 |
#include <QButtonGroup> |
| 9 |
#include <QDebug> |
| 10 |
#include <QPushButton> |
| 11 |
|
| 12 |
namespace Avogadro { |
| 13 |
|
| 14 |
ConformerSearchDialog::ConformerSearchDialog(QWidget* parent) : QDialog(parent) |
| 15 |
{ |
| 16 |
ui.setupUi(this); |
| 17 |
|
| 18 |
connect(ui.systematicRadio, SIGNAL(toggled(bool)), this, |
| 19 |
SLOT(systematicToggled(bool))); |
| 20 |
connect(ui.randomRadio, SIGNAL(toggled(bool)), this, |
| 21 |
SLOT(randomToggled(bool))); |
| 22 |
connect(ui.weightedRadio, SIGNAL(toggled(bool)), this, |
| 23 |
SLOT(weightedToggled(bool))); |
| 24 |
connect(ui.geneticRadio, SIGNAL(toggled(bool)), this, |
| 25 |
SLOT(geneticToggled(bool))); |
| 26 |
|
| 27 |
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, |
| 28 |
SLOT(buttonClicked(QAbstractButton*))); |
| 29 |
|
| 30 |
m_method = 1; // systematic |
| 31 |
m_numConformers = 100; |
| 32 |
|
| 33 |
ui.numSpin->setValue(0); |
| 34 |
ui.systematicRadio->setChecked(true); |
| 35 |
ui.randomRadio->setChecked(false); |
| 36 |
ui.weightedRadio->setChecked(false); |
| 37 |
ui.geneticRadio->setChecked(false); |
| 38 |
ui.childrenSpinBox->setEnabled(false); |
| 39 |
ui.mutabilitySpinBox->setEnabled(false); |
| 40 |
ui.convergenceSpinBox->setEnabled(false); |
| 41 |
ui.scoringComboBox->setEnabled(false); |
| 42 |
} |
| 43 |
|
| 44 |
ConformerSearchDialog::~ConformerSearchDialog() {} |
| 45 |
|
| 46 |
void ConformerSearchDialog::buttonClicked(QAbstractButton* button) |
| 47 |
{ |
| 48 |
if (button == ui.buttonBox->button(QDialogButtonBox::Ok)) { |
| 49 |
emit accepted(); |
| 50 |
} |
| 51 |
close(); |
| 52 |
} |
| 53 |
|
| 54 |
QStringList ConformerSearchDialog::options() const |
| 55 |
{ |
| 56 |
QStringList options; |
| 57 |
|
| 58 |
// in OB v3.2 |
| 59 |
options << "--steps" << QString::number(ui.optimizationStepsSpinBox->value()); |
| 60 |
|
| 61 |
if (ui.systematicRadio->isChecked()) |
| 62 |
options << "--systematic"; |
| 63 |
else if (ui.randomRadio->isChecked()) { |
| 64 |
options << "--random"; |
| 65 |
options << "--nconf" << QString::number(ui.numSpin->value()); |
| 66 |
} else if (ui.weightedRadio->isChecked()) { |
| 67 |
options << "--weighted"; |
| 68 |
options << "--nconf" << QString::number(ui.numSpin->value()); |
| 69 |
} else if (ui.geneticRadio->isChecked()) { |
| 70 |
// genetic is the default, no need to specify |
| 71 |
options << "--nconf" << QString::number(ui.numSpin->value()); |
| 72 |
options << "--children" << QString::number(ui.childrenSpinBox->value()); |
| 73 |
options << "--mutability" << QString::number(ui.mutabilitySpinBox->value()); |
| 74 |
options << "--convergence" |
| 75 |
<< QString::number(ui.convergenceSpinBox->value()); |
| 76 |
options << "--scoring" << ui.scoringComboBox->currentText(); |
| 77 |
} |
| 78 |
|
| 79 |
return options; |
| 80 |
} |
| 81 |
|
| 82 |
void ConformerSearchDialog::systematicToggled(bool checked) |
| 83 |
{ |
| 84 |
if (checked) { |
| 85 |
m_method = 1; |
| 86 |
ui.systematicRadio->setChecked(true); |
| 87 |
ui.randomRadio->setChecked(false); |
| 88 |
ui.weightedRadio->setChecked(false); |
| 89 |
ui.geneticRadio->setChecked(false); |
| 90 |
ui.childrenSpinBox->setEnabled(false); |
| 91 |
ui.mutabilitySpinBox->setEnabled(false); |
| 92 |
ui.convergenceSpinBox->setEnabled(false); |
| 93 |
ui.scoringComboBox->setEnabled(false); |
| 94 |
|
| 95 |
ui.numSpin->setEnabled(false); |
| 96 |
ui.numSpin->setValue(0); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
void ConformerSearchDialog::randomToggled(bool checked) |
| 101 |
{ |
| 102 |
if (checked) { |
| 103 |
m_method = 2; |
| 104 |
ui.systematicRadio->setChecked(false); |
| 105 |
ui.randomRadio->setChecked(true); |
| 106 |
ui.weightedRadio->setChecked(false); |
| 107 |
ui.geneticRadio->setChecked(false); |
| 108 |
ui.childrenSpinBox->setEnabled(false); |
| 109 |
ui.mutabilitySpinBox->setEnabled(false); |
| 110 |
ui.convergenceSpinBox->setEnabled(false); |
| 111 |
ui.scoringComboBox->setEnabled(false); |
| 112 |
ui.numSpin->setEnabled(true); |
| 113 |
ui.numSpin->setValue(100); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
void ConformerSearchDialog::weightedToggled(bool checked) |
| 118 |
{ |
| 119 |
if (checked) { |
| 120 |
m_method = 3; |
| 121 |
ui.systematicRadio->setChecked(false); |
| 122 |
ui.randomRadio->setChecked(false); |
| 123 |
ui.weightedRadio->setChecked(true); |
| 124 |
ui.geneticRadio->setChecked(false); |
| 125 |
ui.childrenSpinBox->setEnabled(false); |
| 126 |
ui.mutabilitySpinBox->setEnabled(false); |
| 127 |
ui.convergenceSpinBox->setEnabled(false); |
| 128 |
ui.scoringComboBox->setEnabled(false); |
| 129 |
ui.numSpin->setEnabled(true); |
| 130 |
ui.numSpin->setValue(100); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
void ConformerSearchDialog::geneticToggled(bool checked) |
| 135 |
{ |
| 136 |
if (checked) { |
| 137 |
m_method = 4; |
| 138 |
ui.systematicRadio->setChecked(false); |
| 139 |
ui.randomRadio->setChecked(false); |
| 140 |
ui.weightedRadio->setChecked(false); |
| 141 |
ui.geneticRadio->setChecked(true); |
| 142 |
ui.childrenSpinBox->setEnabled(true); |
| 143 |
ui.mutabilitySpinBox->setEnabled(true); |
| 144 |
ui.convergenceSpinBox->setEnabled(true); |
| 145 |
ui.scoringComboBox->setEnabled(true); |
| 146 |
ui.numSpin->setEnabled(true); |
| 147 |
ui.numSpin->setValue(100); |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
void ConformerSearchDialog::accept() |
| 152 |
{ |
| 153 |
m_numConformers = ui.numSpin->value(); |
| 154 |
hide(); |
| 155 |
} |
| 156 |
|
| 157 |
void ConformerSearchDialog::reject() |
| 158 |
{ |
| 159 |
hide(); |
| 160 |
} |
| 161 |
|
| 162 |
int ConformerSearchDialog::numConformers() |
| 163 |
{ |
| 164 |
return m_numConformers; |
| 165 |
} |
| 166 |
|
| 167 |
int ConformerSearchDialog::method() |
| 168 |
{ |
| 169 |
return m_method; |
| 170 |
} |
| 171 |
} // namespace Avogadro |