From 0edc456a81790462fea68f5021d846deeb37d679 Mon Sep 17 00:00:00 2001 From: Julien STAUB Date: Wed, 5 Aug 2026 18:31:22 +0200 Subject: [PATCH] fix gaussian blur checkbox not aligned with applied settings --- surfaceanalysistools.cpp | 9 +++++++++ surfaceanalysistools.h | 1 + surfacemanager.cpp | 37 +++++++++++++++++++++++++++++++++---- surfacemanager.h | 1 + wavefront.cpp | 4 +++- wavefront.h | 2 ++ 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/surfaceanalysistools.cpp b/surfaceanalysistools.cpp index 2c8d8bfe..f8c7aa08 100644 --- a/surfaceanalysistools.cpp +++ b/surfaceanalysistools.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "mirrordlg.h" #include surfaceAnalysisTools *surfaceAnalysisTools::m_Instance = NULL; @@ -69,6 +70,14 @@ void surfaceAnalysisTools::setBlurText(const QString &txt){ ui->blurMm->setText(txt); } +void surfaceAnalysisTools::setGaussianControls(bool enabled, double value){ + const QSignalBlocker blurToggleBlocker(ui->blurCB); + const QSignalBlocker blurValueBlocker(ui->surfaceSmoothGausianBlurr); + ui->blurCB->setChecked(enabled); + ui->surfaceSmoothGausianBlurr->setValue(value); + ui->surfaceSmoothGausianBlurr->setEnabled(enabled); +} + void surfaceAnalysisTools::addWaveFront(const QString &name){ QStringList list = name.split('/'); diff --git a/surfaceanalysistools.h b/surfaceanalysistools.h index 7b5df724..9abc25c3 100644 --- a/surfaceanalysistools.h +++ b/surfaceanalysistools.h @@ -48,6 +48,7 @@ class surfaceAnalysisTools : public QDockWidget double m_defocus; double m_defocusInmm; void setBlurText(const QString &txt); + void setGaussianControls(bool enabled, double value); void nameChangedN(int, const QString&); void select(int item); diff --git a/surfacemanager.cpp b/surfacemanager.cpp index 228f2e35..2ab2fae6 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -350,13 +350,15 @@ void SurfaceManager::generateSurfacefromWavefront(int wavefrontNdx) { void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){ zernikeProcess &zp = *zernikeProcess::get_Instance(); + m_GB_enabled = wf->gbEnabled; + m_gbValue = wf->gbValue; if (wf->dirtyZerns){ if (mirrorDlg::get_Instance()->isEllipse()){ wf->nulledData = wf->data.clone(); - if (m_GB_enabled){ + if (wf->gbEnabled){ // compute blur radius - int gaussianRad = 2 * wf->m_outside.m_radius * m_gbValue * .01; + int gaussianRad = 2 * wf->m_outside.m_radius * wf->gbValue * .01; gaussianRad &= 0xfffffffe; ++gaussianRad; @@ -440,9 +442,9 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){ wf->workData = wf->nulledData.clone(); - if (m_GB_enabled){ + if (wf->gbEnabled){ // compute blur radius - int gaussianRad = 2 * wf->m_outside.m_radius * m_gbValue * .01; + int gaussianRad = 2 * wf->m_outside.m_radius * wf->gbValue * .01; gaussianRad &= 0xfffffffe; ++gaussianRad; @@ -823,6 +825,7 @@ void SurfaceManager::waveFrontClickedSlot(int ndx) { m_currentNdx = ndx; + syncGaussianStateForWavefront(m_wavefronts[ndx]); QString msg = QString(" %1x%2 ").arg(m_wavefronts[ndx]->data.cols).arg(m_wavefronts[ndx]->data.rows); ((MainWindow*)parent())->statusBar()->showMessage(msg); sendSurface(m_wavefronts[ndx]); @@ -842,6 +845,7 @@ void SurfaceManager::wavefrontDClicked(const QString & name){ for (int i = 0; i < m_wavefronts.size(); ++i){ if (m_wavefronts[i]->name.endsWith(name)){ //TODO JST 2023/09/11 this does not work on some name combinations. To be fixed m_currentNdx = i; + syncGaussianStateForWavefront(m_wavefronts[i]); sendSurface(m_wavefronts[i]); break; } @@ -853,6 +857,9 @@ void SurfaceManager::surfaceSmoothGBValue(double value){ QSettings settings; settings.setValue("GBValue", (int)(value)); m_gbValue = value; + if (m_wavefronts.size() > 0) { + m_wavefronts[m_currentNdx]->gbValue = value; + } mirrorDlg *md = mirrorDlg::get_Instance(); m_surfaceTools->setBlurText(QString("%1 mm").arg( .01 * value * md->diameter, 6, 'f', 2)); @@ -868,6 +875,9 @@ void SurfaceManager::surfaceSmoothGBValue(double value){ void SurfaceManager::surfaceSmoothGBEnabled(bool b){ m_GB_enabled = b; + if (m_wavefronts.size() > 0) { + m_wavefronts[m_currentNdx]->gbEnabled = b; + } QSettings settings; settings.setValue("GBlur", m_GB_enabled); @@ -885,6 +895,19 @@ void SurfaceManager::surfaceSmoothGBEnabled(bool b){ m_waveFrontTimer->start(500); } +void SurfaceManager::syncGaussianStateForWavefront(wavefront *wf){ + if (wf == nullptr) { + return; + } + + m_GB_enabled = wf->gbEnabled; + m_gbValue = wf->gbValue; + m_surfaceTools->setGaussianControls(wf->gbEnabled, wf->gbValue); + + mirrorDlg *md = mirrorDlg::get_Instance(); + m_surfaceTools->setBlurText(QString("%1 mm").arg(.01 * wf->gbValue * md->diameter, 6, 'f', 2)); +} + void SurfaceManager::computeMetrics(wavefront *wf){ mirrorDlg *md = mirrorDlg::get_Instance(); cv::Scalar mean,std; @@ -1120,6 +1143,8 @@ void SurfaceManager::createSurfaceFromPhaseMap(cv::Mat phase, CircleOutline outs wf->diameter = md->diameter; wf->lambda = md->lambda; wf->roc = md->roc; + wf->gbEnabled = m_GB_enabled; + wf->gbValue = m_gbValue; wf->dirtyZerns = true; wf->wasSmoothed = false; wf->regions = polyArea; @@ -1410,6 +1435,8 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){ wf->diameter = diam; wf->roc = roc; wf->lambda = lambda; + wf->gbEnabled = m_GB_enabled; + wf->gbValue = m_gbValue; wf->wasSmoothed = false; return wf; @@ -1527,6 +1554,7 @@ void SurfaceManager::next(){ ++m_currentNdx; else m_currentNdx = 0; + syncGaussianStateForWavefront(m_wavefronts[m_currentNdx]); sendSurface(m_wavefronts[m_currentNdx]); @@ -1541,6 +1569,7 @@ void SurfaceManager::previous(){ else m_currentNdx = m_wavefronts.length()-1; + syncGaussianStateForWavefront(m_wavefronts[m_currentNdx]); sendSurface(m_wavefronts[m_currentNdx]); } QVector histo(const std::vector &data, int bins, double min, double max){ diff --git a/surfacemanager.h b/surfacemanager.h index 39587023..16ce5d87 100644 --- a/surfacemanager.h +++ b/surfacemanager.h @@ -77,6 +77,7 @@ class SurfaceManager : public QObject void initWaveFrontLoad(); void averageWavefrontFiles(const QStringList &files); void downSizeWf(wavefront *wf); + void syncGaussianStateForWavefront(wavefront *wf); void process(int wavefront_index, SurfaceManager *sm); wavefront *readWaveFront(const QString &fileName); inline wavefront *getCurrent(){ diff --git a/wavefront.cpp b/wavefront.cpp index 1beff681..7862a6a5 100644 --- a/wavefront.cpp +++ b/wavefront.cpp @@ -18,7 +18,7 @@ #include "wavefront.h" wavefront::wavefront(): - gaussian_diameter(0.),useSANull(true),m_origin(WavefrontOrigin::Unknown),m_manuallyInverted(false),dirtyZerns(true),regions_have_been_expanded(false) + gaussian_diameter(0.),gbEnabled(false),gbValue(20.),wasSmoothed(false),useSANull(true),GBSmoothingValue(0.),m_origin(WavefrontOrigin::Unknown),m_manuallyInverted(false),dirtyZerns(true),regions_have_been_expanded(false) { } @@ -41,6 +41,8 @@ wavefront::wavefront( const wavefront &wf): workMask(wf.workMask.clone()), InputZerns(wf.InputZerns), gaussian_diameter(wf.gaussian_diameter), + gbEnabled(wf.gbEnabled), + gbValue(wf.gbValue), wasSmoothed(wf.wasSmoothed), useSANull(wf.useSANull), GBSmoothingValue(wf.GBSmoothingValue), diff --git a/wavefront.h b/wavefront.h index 1d7d13df..00a04b73 100644 --- a/wavefront.h +++ b/wavefront.h @@ -49,6 +49,8 @@ class wavefront cv::Mat_ workMask; std::vector InputZerns; double gaussian_diameter; + bool gbEnabled; + double gbValue; bool wasSmoothed; bool useSANull; double GBSmoothingValue;