Skip to content

Commit

Permalink
Merge pull request #492 from perminder-17/depth-blurring
Browse files Browse the repository at this point in the history
Add depth-of-field (Blurring rendering options)
  • Loading branch information
ghutchis authored Oct 12, 2024
2 parents 0a7ff71 + 3be7521 commit 197f0c5
Show file tree
Hide file tree
Showing 4 changed files with 411 additions and 272 deletions.
5 changes: 4 additions & 1 deletion avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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());
}
}
Expand Down
46 changes: 44 additions & 2 deletions avogadro/renderingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()),
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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)
{
Expand All @@ -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());
Expand Down
4 changes: 4 additions & 0 deletions avogadro/renderingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 197f0c5

Please sign in to comment.