diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp index 51f12e5e..b4620210 100644 --- a/avogadro/mainwindow.cpp +++ b/avogadro/mainwindow.cpp @@ -389,6 +389,8 @@ void MainWindow::setupInterface() if (pipeline) { pipeline->setAoEnabled( settings.value("MainWindow/ao_enabled", true).toBool()); + pipeline->setDofEnabled( + settings.value("MainWindow/dof_enabled", true).toBool()); pipeline->setFogEnabled( settings.value("MainWindow/fog_enabled", true).toBool()); pipeline->setAoStrength( @@ -1843,8 +1845,9 @@ void MainWindow::setRenderingSettings() dialog.exec(); QSettings settings; settings.setValue("MainWindow/ao_enabled", pipeline->getAoEnabled()); - settings.setValue("MainWindow/fog_enabled", pipeline->getFogEnabled()); settings.setValue("MainWindow/ao_strength", pipeline->getAoStrength()); + settings.setValue("MainWindow/dof_enabled", pipeline->getDofEnabled()); + settings.setValue("MainWindow/fog_enabled", pipeline->getFogEnabled()); settings.setValue("MainWindow/ed_enabled", pipeline->getEdEnabled()); } } diff --git a/avogadro/renderingdialog.cpp b/avogadro/renderingdialog.cpp index a317de25..a3887c19 100644 --- a/avogadro/renderingdialog.cpp +++ b/avogadro/renderingdialog.cpp @@ -12,14 +12,27 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline) : QDialog(parent_), m_ui(new Ui::RenderingDialog), m_solidPipeline(pipeline) { m_ui->setupUi(this); - + m_ui->aoEnableCheckBox->setCheckState(pipeline.getAoEnabled()? Qt::Checked : Qt::Unchecked); + m_ui->dofEnableCheckBox->setCheckState(pipeline.getDofEnabled()? Qt::Checked : Qt::Unchecked); m_ui->fogEnableCheckBox->setCheckState(pipeline.getFogEnabled()? Qt::Checked : Qt::Unchecked); m_ui->aoStrengthDoubleSpinBox->setMinimum(0.0); m_ui->aoStrengthDoubleSpinBox->setValue(pipeline.getAoStrength()); m_ui->aoStrengthDoubleSpinBox->setMaximum(2.0); m_ui->aoStrengthDoubleSpinBox->setDecimals(1); m_ui->aoStrengthDoubleSpinBox->setSingleStep(0.1); + m_ui->dofStrengthDoubleSpinBox->setMinimum(0.0); + m_ui->dofStrengthDoubleSpinBox->setValue(pipeline.getDofStrength()); + m_ui->dofStrengthDoubleSpinBox->setMaximum(2.0); + m_ui->dofStrengthDoubleSpinBox->setDecimals(1); + m_ui->dofStrengthDoubleSpinBox->setSingleStep(0.1); + m_ui->dofPositionDoubleSpinBox->setMinimum(0.0); + m_ui->dofPositionDoubleSpinBox->setValue(pipeline.getDofPosition()); + // We can adjust the max and min value + // after testing with several molecules + m_ui->dofPositionDoubleSpinBox->setMaximum(20.0); + m_ui->dofPositionDoubleSpinBox->setDecimals(1); + m_ui->dofPositionDoubleSpinBox->setSingleStep(0.1); m_ui->fogStrengthDoubleSpinBox->setMinimum(-20.0); m_ui->fogStrengthDoubleSpinBox->setValue(pipeline.getFogStrength()); m_ui->fogStrengthDoubleSpinBox->setMaximum(20.0); @@ -34,6 +47,8 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline) connect(m_ui->aoEnableCheckBox, SIGNAL(stateChanged(int)), SLOT(aoEnableCheckBoxChanged(int))); + connect(m_ui->dofEnableCheckBox, SIGNAL(stateChanged(int)), + SLOT(dofEnableCheckBoxChanged(int))); connect(m_ui->fogEnableCheckBox, SIGNAL(stateChanged(int)), SLOT(fogEnableCheckBoxChanged(int))); connect(m_ui->saveButton, SIGNAL(clicked()), @@ -52,6 +67,10 @@ bool RenderingDialog::aoEnabled() return m_ui->aoEnableCheckBox->checkState() == Qt::Checked; } +bool RenderingDialog::dofEnabled() +{ + return m_ui->dofEnableCheckBox->checkState() == Qt::Checked; +} bool RenderingDialog::fogEnabled() { return m_ui->fogEnableCheckBox->checkState() == Qt::Checked; @@ -62,6 +81,15 @@ float RenderingDialog::aoStrength() return m_ui->aoStrengthDoubleSpinBox->value(); } +float RenderingDialog::dofStrength() +{ + return m_ui->dofStrengthDoubleSpinBox->value(); +} + +float RenderingDialog::dofPosition() +{ + return m_ui->dofPositionDoubleSpinBox->value(); +} float RenderingDialog::fogStrength() { return m_ui->fogStrengthDoubleSpinBox->value(); @@ -77,7 +105,18 @@ bool RenderingDialog::edEnabled() return m_ui->edEnableCheckBox->checkState() == Qt::Checked; } -// TODO: will correct it. + +void RenderingDialog::dofEnableCheckBoxChanged(int state) +{ + if (state == Qt::Unchecked){ + m_ui->dofStrengthDoubleSpinBox->setEnabled(false); + m_ui->dofPositionDoubleSpinBox->setEnabled(false); + } + else{ + m_ui->dofStrengthDoubleSpinBox->setEnabled(true); + m_ui->dofPositionDoubleSpinBox->setEnabled(true); + } +} void RenderingDialog::fogEnableCheckBoxChanged(int state) { @@ -102,7 +141,10 @@ void RenderingDialog::aoEnableCheckBoxChanged(int state) void RenderingDialog::saveButtonClicked() { m_solidPipeline.setAoEnabled(aoEnabled()); + m_solidPipeline.setDofEnabled(dofEnabled()); m_solidPipeline.setAoStrength(aoStrength()); + m_solidPipeline.setDofStrength(dofStrength()); + m_solidPipeline.setDofPosition(dofPosition()); m_solidPipeline.setFogStrength(fogStrength()); m_solidPipeline.setFogEnabled(fogEnabled()); m_solidPipeline.setFogPosition(fogPosition()); diff --git a/avogadro/renderingdialog.h b/avogadro/renderingdialog.h index 9cfad6b9..e3dedc53 100644 --- a/avogadro/renderingdialog.h +++ b/avogadro/renderingdialog.h @@ -31,11 +31,15 @@ class RenderingDialog : public QDialog float aoStrength(); float fogStrength(); bool fogEnabled(); + bool dofEnabled(); + float dofStrength(); + float dofPosition(); bool edEnabled(); protected slots: void aoEnableCheckBoxChanged(int state); void fogEnableCheckBoxChanged(int state); + void dofEnableCheckBoxChanged(int state); void saveButtonClicked(); void closeButtonClicked(); diff --git a/avogadro/renderingdialog.ui b/avogadro/renderingdialog.ui index 1f682d81..b30d1429 100644 --- a/avogadro/renderingdialog.ui +++ b/avogadro/renderingdialog.ui @@ -1,272 +1,362 @@ - RenderingDialog - - - - 0 - 0 - 284 - 302 - - - - - 0 - 0 - - - - - - - true - - - - - - - - Ambient Occlusion: - - - - - - - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - + RenderingDialog + + + + 0 + 0 + 284 + 182 + + + + + 0 + 0 + + + + + + + true + + + + + + + + Ambient Occlusion: + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Shadow Strength: + + + + + + + + + Qt::Horizontal + + + + + + + + + FOG : + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + FOG STRENGTH: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + FOG Position: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Depth-of-field : + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + DOF Strength : + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + DOF Position: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Edge Detection: + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + border-color: rgb(53, 132, 228); + + + Save + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Shadow Strength: - - - - - - - - - Qt::Horizontal - - - - - - - - - Fog: - - - - - - - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Strength of the fog effect (smaller number is weaker) - - - Fog Strength: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Location of the fog effect relative to the camera (near / far) - - - Fog Position: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - Edge Detection: - - - - - - - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - border-color: rgb(53, 132, 228); - - - Save - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Close - - - - - - - - - - - - + + + + + + \ No newline at end of file