Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions surfaceanalysistools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QShortcut>
#include <QtAlgorithms>
#include <QLineEdit>
#include <QSignalBlocker>
#include "mirrordlg.h"
#include <QMessageBox>
surfaceAnalysisTools *surfaceAnalysisTools::m_Instance = NULL;
Expand Down Expand Up @@ -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('/');
Expand Down
1 change: 1 addition & 0 deletions surfaceanalysistools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
37 changes: 33 additions & 4 deletions surfacemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand All @@ -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;
}
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1527,6 +1554,7 @@ void SurfaceManager::next(){
++m_currentNdx;
else
m_currentNdx = 0;
syncGaussianStateForWavefront(m_wavefronts[m_currentNdx]);
sendSurface(m_wavefronts[m_currentNdx]);


Expand All @@ -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<int> histo(const std::vector<double> &data, int bins, double min, double max){
Expand Down
1 change: 1 addition & 0 deletions surfacemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
4 changes: 3 additions & 1 deletion wavefront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions wavefront.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class wavefront
cv::Mat_<uint8_t> workMask;
std::vector<double> InputZerns;
double gaussian_diameter;
bool gbEnabled;
double gbValue;
bool wasSmoothed;
bool useSANull;
double GBSmoothingValue;
Expand Down
Loading