| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the MoleQueue project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "volumescalingdialog.h" |
| 7 |
#include "ui_volumescalingdialog.h" |
| 8 |
|
| 9 |
namespace Avogadro::QtPlugins { |
| 10 |
|
| 11 |
VolumeScalingDialog::VolumeScalingDialog(QWidget* p) |
| 12 |
: QDialog(p), m_ui(new Ui::VolumeScalingDialog), m_currentVolume(0.) |
| 13 |
{ |
| 14 |
m_ui->setupUi(this); |
| 15 |
connect(m_ui->newVolume, SIGNAL(valueChanged(double)), SLOT(volumeEdited())); |
| 16 |
connect(m_ui->scalingFactor, SIGNAL(valueChanged(double)), |
| 17 |
SLOT(factorEdited())); |
| 18 |
} |
| 19 |
|
| 20 |
VolumeScalingDialog::~VolumeScalingDialog() |
| 21 |
{ |
| 22 |
delete m_ui; |
| 23 |
} |
| 24 |
|
| 25 |
void VolumeScalingDialog::setCurrentVolume(double vol) |
| 26 |
{ |
| 27 |
m_currentVolume = vol; |
| 28 |
m_ui->currentVolume->setText(QString::number(vol, 'f', 5)); |
| 29 |
m_ui->newVolume->setValue(vol); |
| 30 |
} |
| 31 |
|
| 32 |
double VolumeScalingDialog::newVolume() const |
| 33 |
{ |
| 34 |
return m_ui->newVolume->value(); |
| 35 |
} |
| 36 |
|
| 37 |
bool VolumeScalingDialog::transformAtoms() const |
| 38 |
{ |
| 39 |
return m_ui->transformAtoms->isChecked(); |
| 40 |
} |
| 41 |
|
| 42 |
void VolumeScalingDialog::volumeEdited() |
| 43 |
{ |
| 44 |
double v = m_ui->newVolume->value(); |
| 45 |
m_ui->scalingFactor->blockSignals(true); |
| 46 |
m_ui->scalingFactor->setValue(v / m_currentVolume); |
| 47 |
m_ui->scalingFactor->blockSignals(false); |
| 48 |
} |
| 49 |
|
| 50 |
void VolumeScalingDialog::factorEdited() |
| 51 |
{ |
| 52 |
double f = m_ui->scalingFactor->value(); |
| 53 |
m_ui->newVolume->blockSignals(true); |
| 54 |
m_ui->newVolume->setValue(m_currentVolume * f); |
| 55 |
m_ui->newVolume->blockSignals(false); |
| 56 |
} |
| 57 |
|
| 58 |
} // namespace Avogadro::QtPlugins |