From b05d9245b8fd6ef1b923739823e05763c62d665d Mon Sep 17 00:00:00 2001 From: Perminder Date: Thu, 11 Apr 2024 08:10:57 +0530 Subject: [PATCH 1/6] Depth-blur feature Signed-off-by: Perminder --- avogadro/renderingdialog.cpp | 20 ++++++++++++++++- avogadro/renderingdialog.h | 2 ++ avogadro/renderingdialog.ui | 42 +++++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/avogadro/renderingdialog.cpp b/avogadro/renderingdialog.cpp index 7d875bd1..9fcb0b84 100644 --- a/avogadro/renderingdialog.cpp +++ b/avogadro/renderingdialog.cpp @@ -12,8 +12,9 @@ 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->aoStrengthDoubleSpinBox->setMinimum(0.0); m_ui->aoStrengthDoubleSpinBox->setValue(pipeline.getAoStrength()); m_ui->aoStrengthDoubleSpinBox->setMaximum(2.0); @@ -23,6 +24,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->saveButton, SIGNAL(clicked()), SLOT(saveButtonClicked())); connect(m_ui->closeButton, SIGNAL(clicked()), @@ -39,6 +42,11 @@ bool RenderingDialog::aoEnabled() return m_ui->aoEnableCheckBox->checkState() == Qt::Checked; } +bool RenderingDialog::dofEnabled() +{ + return m_ui->dofEnableCheckBox->checkState() == Qt::Checked; +} + float RenderingDialog::aoStrength() { return m_ui->aoStrengthDoubleSpinBox->value(); @@ -49,6 +57,15 @@ bool RenderingDialog::edEnabled() return m_ui->edEnableCheckBox->checkState() == Qt::Checked; } +// will correct this one. +void RenderingDialog::dofEnableCheckBoxChanged(int state) +{ + if (state == Qt::Unchecked) + m_ui->aoStrengthDoubleSpinBox->setEnabled(false); + else + m_ui->aoStrengthDoubleSpinBox->setEnabled(true); +} + void RenderingDialog::aoEnableCheckBoxChanged(int state) { if (state == Qt::Unchecked) @@ -60,6 +77,7 @@ void RenderingDialog::aoEnableCheckBoxChanged(int state) void RenderingDialog::saveButtonClicked() { m_solidPipeline.setAoEnabled(aoEnabled()); + m_solidPipeline.setDofEnabled(dofEnabled()); m_solidPipeline.setAoStrength(aoStrength()); m_solidPipeline.setEdEnabled(edEnabled()); this->accept(); diff --git a/avogadro/renderingdialog.h b/avogadro/renderingdialog.h index 8c8cb965..0fe53ee8 100644 --- a/avogadro/renderingdialog.h +++ b/avogadro/renderingdialog.h @@ -27,11 +27,13 @@ class RenderingDialog : public QDialog ~RenderingDialog() override; bool aoEnabled(); + bool dofEnabled(); float aoStrength(); bool edEnabled(); protected slots: void aoEnableCheckBoxChanged(int state); + void dofEnableCheckBoxChanged(int state); void saveButtonClicked(); void closeButtonClicked(); diff --git a/avogadro/renderingdialog.ui b/avogadro/renderingdialog.ui index 78cbead4..edae6246 100644 --- a/avogadro/renderingdialog.ui +++ b/avogadro/renderingdialog.ui @@ -56,7 +56,43 @@ + + + + + + + + + Depth-of-field: + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -76,14 +112,14 @@ - + Shadow Strength: - + @@ -161,7 +197,7 @@ - + From 1e47a7635751f3e37ff9e6552533d63bd34afbb5 Mon Sep 17 00:00:00 2001 From: Perminder Date: Thu, 11 Apr 2024 08:41:26 +0530 Subject: [PATCH 2/6] mainwindow Signed-off-by: Perminder --- avogadro/mainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp index 4118820d..b5ed6898 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->setAoStrength( settings.value("MainWindow/ao_strength", 1.0f).toFloat()); pipeline->setEdEnabled( @@ -577,7 +579,7 @@ void setDefaultViews(MultiViewWidget* viewWidget) bool anyPluginTrue = false; // load plugins normally, if all non-ignore are false. // restore the default behavior - for (ScenePlugin* plugin : sceneModel->scenePlugins()) { + for (auto plugin : sceneModel->scenePlugins()) { QString settingsKey("MainWindow/" + plugin->objectName()); bool enabled = settings.value(settingsKey, plugin->isEnabled()).toBool(); if (plugin->defaultBehavior() != ScenePlugin::DefaultBehavior::Ignore && @@ -1497,9 +1499,6 @@ bool MainWindow::saveFileAs(bool async) QFileDialog saveDialog(this, tr("Save chemical file"), dir, filter); saveDialog.setAcceptMode(QFileDialog::AcceptSave); saveDialog.exec(); - if (saveDialog.selectedFiles().isEmpty()) // user cancel - return false; - QString fileName = saveDialog.selectedFiles().first(); if (fileName.isEmpty()) // user cancel @@ -1837,6 +1836,7 @@ void MainWindow::setRenderingSettings() dialog.exec(); QSettings settings; settings.setValue("MainWindow/ao_enabled", pipeline->getAoEnabled()); + settings.setValue("MainWindow/dof_enabled", pipeline->getDofEnabled()); settings.setValue("MainWindow/ao_strength", pipeline->getAoStrength()); settings.setValue("MainWindow/ed_enabled", pipeline->getEdEnabled()); } From f8d2d1ccafb0e50ce0c69419180bcfb8b939432b Mon Sep 17 00:00:00 2001 From: Perminder Date: Thu, 11 Apr 2024 09:05:15 +0530 Subject: [PATCH 3/6] fixes Signed-off-by: Perminder --- avogadro/mainwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp index b5ed6898..40ed81d5 100644 --- a/avogadro/mainwindow.cpp +++ b/avogadro/mainwindow.cpp @@ -579,7 +579,7 @@ void setDefaultViews(MultiViewWidget* viewWidget) bool anyPluginTrue = false; // load plugins normally, if all non-ignore are false. // restore the default behavior - for (auto plugin : sceneModel->scenePlugins()) { + for (ScenePlugin* plugin : sceneModel->scenePlugins()) { QString settingsKey("MainWindow/" + plugin->objectName()); bool enabled = settings.value(settingsKey, plugin->isEnabled()).toBool(); if (plugin->defaultBehavior() != ScenePlugin::DefaultBehavior::Ignore && @@ -1499,6 +1499,9 @@ bool MainWindow::saveFileAs(bool async) QFileDialog saveDialog(this, tr("Save chemical file"), dir, filter); saveDialog.setAcceptMode(QFileDialog::AcceptSave); saveDialog.exec(); + if (saveDialog.selectedFiles().isEmpty()) // user cancel + return false; + QString fileName = saveDialog.selectedFiles().first(); if (fileName.isEmpty()) // user cancel From 89d9559d87a6b28b8820531229cfff184b5c36f6 Mon Sep 17 00:00:00 2001 From: Perminder Date: Sat, 8 Jun 2024 07:47:57 +0530 Subject: [PATCH 4/6] Ui for strength added Signed-off-by: Perminder --- avogadro/renderingdialog.cpp | 15 +- avogadro/renderingdialog.h | 1 + avogadro/renderingdialog.ui | 439 +++++++++++++++++++---------------- 3 files changed, 250 insertions(+), 205 deletions(-) diff --git a/avogadro/renderingdialog.cpp b/avogadro/renderingdialog.cpp index 9fcb0b84..a6ec0589 100644 --- a/avogadro/renderingdialog.cpp +++ b/avogadro/renderingdialog.cpp @@ -20,6 +20,11 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline) 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->edEnableCheckBox->setCheckState(pipeline.getEdEnabled()? Qt::Checked : Qt::Unchecked); connect(m_ui->aoEnableCheckBox, SIGNAL(stateChanged(int)), @@ -52,6 +57,11 @@ float RenderingDialog::aoStrength() return m_ui->aoStrengthDoubleSpinBox->value(); } +float RenderingDialog::dofStrength() +{ + return m_ui->dofStrengthDoubleSpinBox->value(); +} + bool RenderingDialog::edEnabled() { return m_ui->edEnableCheckBox->checkState() == Qt::Checked; @@ -61,9 +71,9 @@ bool RenderingDialog::edEnabled() void RenderingDialog::dofEnableCheckBoxChanged(int state) { if (state == Qt::Unchecked) - m_ui->aoStrengthDoubleSpinBox->setEnabled(false); + m_ui->dofStrengthDoubleSpinBox->setEnabled(false); else - m_ui->aoStrengthDoubleSpinBox->setEnabled(true); + m_ui->dofStrengthDoubleSpinBox->setEnabled(true); } void RenderingDialog::aoEnableCheckBoxChanged(int state) @@ -79,6 +89,7 @@ void RenderingDialog::saveButtonClicked() m_solidPipeline.setAoEnabled(aoEnabled()); m_solidPipeline.setDofEnabled(dofEnabled()); m_solidPipeline.setAoStrength(aoStrength()); + m_solidPipeline.setDofStrength(dofStrength()); m_solidPipeline.setEdEnabled(edEnabled()); this->accept(); } diff --git a/avogadro/renderingdialog.h b/avogadro/renderingdialog.h index 0fe53ee8..8cd7f79f 100644 --- a/avogadro/renderingdialog.h +++ b/avogadro/renderingdialog.h @@ -28,6 +28,7 @@ class RenderingDialog : public QDialog bool aoEnabled(); bool dofEnabled(); + float dofStrength(); float aoStrength(); bool edEnabled(); diff --git a/avogadro/renderingdialog.ui b/avogadro/renderingdialog.ui index edae6246..c096c516 100644 --- a/avogadro/renderingdialog.ui +++ b/avogadro/renderingdialog.ui @@ -1,206 +1,239 @@ - RenderingDialog - - - - 0 - 0 - 284 - 182 - - - - - 0 - 0 - - - - - - - true - - - - - - - - Ambient Occlusion: - - - - - - - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Depth-of-field: - - - - - - - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Shadow Strength: - - - - - - - - - Qt::Horizontal - + RenderingDialog + + + + 0 + 0 + 284 + 182 + + + + + 0 + 0 + + + + + + + true + + + + + + + + Ambient Occlusion: + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Shadow Strength: + + + + + + + + + Qt::Horizontal + + + + + + + + + Depth-of-field: + + + + + + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + DOF Strength: + + + + + + + + + + + + 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 + + + + + + - - - - - - - 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 From f636bf3bbdb92bce93a8fef5e9bd318477da003f Mon Sep 17 00:00:00 2001 From: Perminder Date: Fri, 21 Jun 2024 02:44:00 +0530 Subject: [PATCH 5/6] dof-position added Signed-off-by: Perminder --- avogadro/renderingdialog.cpp | 23 ++++++++++++++++++++--- avogadro/renderingdialog.h | 1 + avogadro/renderingdialog.ui | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/avogadro/renderingdialog.cpp b/avogadro/renderingdialog.cpp index a6ec0589..021e1862 100644 --- a/avogadro/renderingdialog.cpp +++ b/avogadro/renderingdialog.cpp @@ -25,6 +25,13 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline) 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->edEnableCheckBox->setCheckState(pipeline.getEdEnabled()? Qt::Checked : Qt::Unchecked); connect(m_ui->aoEnableCheckBox, SIGNAL(stateChanged(int)), @@ -62,18 +69,27 @@ float RenderingDialog::dofStrength() return m_ui->dofStrengthDoubleSpinBox->value(); } +float RenderingDialog::dofPosition() +{ + return m_ui->dofPositionDoubleSpinBox->value(); +} + bool RenderingDialog::edEnabled() { return m_ui->edEnableCheckBox->checkState() == Qt::Checked; } -// will correct this one. + void RenderingDialog::dofEnableCheckBoxChanged(int state) { - if (state == Qt::Unchecked) + if (state == Qt::Unchecked){ m_ui->dofStrengthDoubleSpinBox->setEnabled(false); - else + m_ui->dofPositionDoubleSpinBox->setEnabled(false); + } + else{ m_ui->dofStrengthDoubleSpinBox->setEnabled(true); + m_ui->dofPositionDoubleSpinBox->setEnabled(true); + } } void RenderingDialog::aoEnableCheckBoxChanged(int state) @@ -90,6 +106,7 @@ void RenderingDialog::saveButtonClicked() m_solidPipeline.setDofEnabled(dofEnabled()); m_solidPipeline.setAoStrength(aoStrength()); m_solidPipeline.setDofStrength(dofStrength()); + m_solidPipeline.setDofPosition(dofPosition()); m_solidPipeline.setEdEnabled(edEnabled()); this->accept(); } diff --git a/avogadro/renderingdialog.h b/avogadro/renderingdialog.h index 8cd7f79f..3d13e845 100644 --- a/avogadro/renderingdialog.h +++ b/avogadro/renderingdialog.h @@ -30,6 +30,7 @@ class RenderingDialog : public QDialog bool dofEnabled(); float dofStrength(); float aoStrength(); + float dofPosition(); bool edEnabled(); protected slots: diff --git a/avogadro/renderingdialog.ui b/avogadro/renderingdialog.ui index c096c516..7ef13ad5 100644 --- a/avogadro/renderingdialog.ui +++ b/avogadro/renderingdialog.ui @@ -152,6 +152,33 @@ + + + + DOF Position: + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + From 7730a57ee7c0b6e38b0757f9b284ef91e6293a6a Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 26 Sep 2024 04:48:57 +0530 Subject: [PATCH 6/6] fixing --- avogadro/renderingdialog.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/avogadro/renderingdialog.h b/avogadro/renderingdialog.h index c0b998f7..e3dedc53 100644 --- a/avogadro/renderingdialog.h +++ b/avogadro/renderingdialog.h @@ -27,19 +27,19 @@ class RenderingDialog : public QDialog ~RenderingDialog() override; bool aoEnabled(); - bool dofEnabled(); - float dofStrength(); - float aoStrength(); - float dofPosition(); float fogPosition(); + float aoStrength(); float fogStrength(); bool fogEnabled(); + bool dofEnabled(); + float dofStrength(); + float dofPosition(); bool edEnabled(); protected slots: void aoEnableCheckBoxChanged(int state); - void dofEnableCheckBoxChanged(int state); void fogEnableCheckBoxChanged(int state); + void dofEnableCheckBoxChanged(int state); void saveButtonClicked(); void closeButtonClicked();