From 7cfb48ee2fdaac83a0116235213aeeecfa82585e Mon Sep 17 00:00:00 2001 From: gr5 Date: Mon, 23 Jun 2025 08:23:53 -0400 Subject: [PATCH 1/9] wip. Fancier auto invert feature where you have more options to let DFTF know when to invert the wavefront. This is version in my video explaining my ideas. I need to fix a few things still. work in progress. --- autoinvertdlg.cpp | 52 +++++ autoinvertdlg.h | 33 +++ autoinvertdlg.ui | 175 +++++++++++++++ mainwindow.cpp | 7 +- mirrordlg.cpp | 34 ++- mirrordlg.h | 5 + mirrordlg.ui | 463 +++++++++++++++++++++------------------ surfaceanalysistools.cpp | 6 + surfacemanager.cpp | 39 ++-- surfacemanager.h | 2 + 10 files changed, 584 insertions(+), 232 deletions(-) create mode 100644 autoinvertdlg.cpp create mode 100644 autoinvertdlg.h create mode 100644 autoinvertdlg.ui diff --git a/autoinvertdlg.cpp b/autoinvertdlg.cpp new file mode 100644 index 00000000..36d996b5 --- /dev/null +++ b/autoinvertdlg.cpp @@ -0,0 +1,52 @@ +#include "autoinvertdlg.h" +#include "ui_autoinvertdlg.h" +#include "surfacemanager.h" + +autoInvertDlg::autoInvertDlg(QWidget *parent) : + QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), + ui(new Ui::autoInvertDlg) +{ + ui->setupUi(this); +} + +autoInvertDlg::~autoInvertDlg() +{ + delete ui; +} + +autoInvertDlg *autoInvertDlg::get_Instance(){ + static autoInvertDlg m_Instance{}; + return &m_Instance; +} + +void autoInvertDlg::on_btnUseConic_clicked() +{ + SurfaceManager *sm = SurfaceManager::get_instance(); + sm->m_inverseMode = invCONIC; + accept(); +} + + +void autoInvertDlg::on_btnManual_clicked() +{ + SurfaceManager *sm = SurfaceManager::get_instance(); + sm->m_inverseMode = invMANUAL; + accept(); +} + + +void autoInvertDlg::on_btnInside_clicked() +{ + SurfaceManager *sm = SurfaceManager::get_instance(); + sm->m_inverseMode = invINSIDE; + accept(); +} + + +void autoInvertDlg::on_btnOutside_clicked() +{ + SurfaceManager *sm = SurfaceManager::get_instance(); + sm->m_inverseMode = invOUTSIDE; + accept(); +} + diff --git a/autoinvertdlg.h b/autoinvertdlg.h new file mode 100644 index 00000000..c8c90d6a --- /dev/null +++ b/autoinvertdlg.h @@ -0,0 +1,33 @@ +#ifndef AUTOINVERTDLG_H +#define AUTOINVERTDLG_H + +#include + +namespace Ui { +class autoInvertDlg; +} + +class autoInvertDlg : public QDialog +{ + Q_OBJECT + +public: + explicit autoInvertDlg(QWidget *parent = nullptr); + ~autoInvertDlg(); + static autoInvertDlg *get_Instance(); + + +private slots: + void on_btnUseConic_clicked(); + + void on_btnManual_clicked(); + + void on_btnInside_clicked(); + + void on_btnOutside_clicked(); + +private: + Ui::autoInvertDlg *ui; +}; + +#endif // AUTOINVERTDLG_H diff --git a/autoinvertdlg.ui b/autoinvertdlg.ui new file mode 100644 index 00000000..eab0f023 --- /dev/null +++ b/autoinvertdlg.ui @@ -0,0 +1,175 @@ + + + autoInvertDlg + + + + 0 + 0 + 487 + 410 + + + + Invert Wavefront Mode + + + true + + + + + 30 + 130 + 81 + 24 + + + + Manual + + + + + + 30 + 60 + 81 + 24 + + + + Parabolized + + + + + + 30 + 180 + 81 + 24 + + + + Inside Focus + + + + + + 30 + 260 + 81 + 24 + + + + Outside Focus + + + + + + 140 + 120 + 261 + 41 + + + + I'll invert the wavefront myself as needed + + + true + + + + + + 140 + 50 + 291 + 61 + + + + Most common. This mirror is at least partially figured. DFTFringe will invert the wavefront if S.A. sign doesn't match mirror configuration conic constant sign. This option disabled if CC=0. + + + true + + + + + + 140 + 170 + 261 + 61 + + + + This and future interferograms of this mirror are inside focus (interferometer closer to mirror). DFTFringe will use that fact to invert as needed. + + + true + + + + + + 140 + 250 + 261 + 61 + + + + This and future interferograms of this mirror are outside focus (interferometer farther from mirror). DFTFringe will use that fact to invert as needed. + + + true + + + + + + 20 + 0 + 411 + 41 + + + + + 14 + + + + Your wavefront may be inverted. What do you want to do? + + + true + + + + + + 20 + 340 + 441 + 71 + + + + Once you choose an option you won't be bothered again about this until you restart the program. You can also get back to this window from within the mirror configuration window. + + + true + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 4794b430..d8edac46 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -49,6 +49,7 @@ #include "opencv2/opencv.hpp" #include "spdlog/spdlog.h" #include +#include "autoinvertdlg.h" using namespace QtConcurrent; std::vector g_wavefronts; @@ -353,6 +354,7 @@ MainWindow::~MainWindow() delete m_ogl; userMapDlg->close(); mirrorDlg::get_Instance()->close(); + autoInvertDlg::get_Instance()->close(); settingsDlg->close(); delete settingsDlg; delete ui; @@ -2107,7 +2109,8 @@ void MainWindow::on_actiondebugSomething_triggered() void MainWindow::on_actionStop_auto_invert_triggered() { - m_surfaceManager->m_askAboutReverse = true; - QMessageBox::information(this, "auto invert", "DFTFringe will now ask if it thinks it needs to invert a wave front."); + m_surfaceManager->m_inverseMode = invNOTSET; + m_mirrorDlg->updateAutoInvertStatus(); + //QMessageBox::information(this, "auto invert", "DFTFringe will now ask if it thinks it needs to invert a wave front."); } diff --git a/mirrordlg.cpp b/mirrordlg.cpp index 192d42af..99eca06a 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -29,6 +29,8 @@ #include #include #include "annulushelpdlg.h" +#include "surfacemanager.h" + QString mirrorDlg::m_projectPath = ""; mirrorDlg *mirrorDlg::get_Instance(){ @@ -51,7 +53,7 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->useAnnulus->setChecked(m_useAnnular); enableAnnular(m_useAnnular); ui->annulusPercent->setValue(settings.value("md annulus percent",0.).toDouble() * 100 ); - + m_autoInvertDlg = autoInvertDlg::get_Instance(); ui->nullCB->setChecked(doNull); diameter = settings.value("config diameter", 200.).toDouble(); @@ -849,3 +851,33 @@ void mirrorDlg::setObsPercent(double obs){ ui->annulusPercent->setValue(obs); } +void mirrorDlg::updateAutoInvertStatus() +{ + switch(SurfaceManager::get_instance()->m_inverseMode) + { + case invNOTSET: + ui->lblAutoInvert->setText("Autoinvert: Not Set"); + break; + case invMANUAL: + ui->lblAutoInvert->setText("Autoinvert: Manual"); + break; + case invCONIC: + ui->lblAutoInvert->setText("Autoinvert: Parabolic"); + break; + case invINSIDE: + ui->lblAutoInvert->setText("Autoinvert: Inside Focus"); + break; + case invOUTSIDE: + ui->lblAutoInvert->setText("Autoinvert: Outside Focus"); + break; + } + +} + +void mirrorDlg::on_btnChangeAutoInvert_clicked() +{ + m_autoInvertDlg->exec(); + updateAutoInvertStatus(); +} + + diff --git a/mirrordlg.h b/mirrordlg.h index 860ddb5a..a935e985 100644 --- a/mirrordlg.h +++ b/mirrordlg.h @@ -20,6 +20,7 @@ #include #include +#include "autoinvertdlg.h" namespace Ui { class mirrorDlg; @@ -37,6 +38,7 @@ class mirrorDlg : public QDialog void loadFile(QString & fileName); void updateZ8(); + void updateAutoInvertStatus(); QString m_name; bool mm; @@ -118,6 +120,8 @@ private slots: void on_annularDiameter_valueChanged(double arg1); + void on_btnChangeAutoInvert_clicked(); + signals: void diameterChanged(double); void rocChanged(double); @@ -138,6 +142,7 @@ private slots: QTimer spacingChangeTimer; void saveJson(QString fileName); void enableAnnular(bool enable); + autoInvertDlg *m_autoInvertDlg; }; #endif // MIRRORDLG_H diff --git a/mirrordlg.ui b/mirrordlg.ui index 5bed7ddc..f4240ab5 100644 --- a/mirrordlg.ui +++ b/mirrordlg.ui @@ -6,189 +6,61 @@ 0 0 - 518 - 465 + 757 + 477 Mirror configuration - - - - Artificial Null - - - - - - - Mirror - - - - - - <html><head/><body><p>If set units are displayed in mm. If not then units are in inches. But only for this mirror configurion dialog.</p></body></html> - - - Units in mm - - - - - - - - - Diameter: - - - - - - - <html><head/><body><p>Daimeter of clear apature of the mirror or Horizontal axis of ellipse.</p></body></html> - - - - - - - - - - - Roc: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <html><head/><body><p>Positive value of Radius of curvature of mirror or 0 if testing a flat. Will be ignored if Artificial Null is checked.</p><p>The Fnumber will be computed from this value and the diameter.</p></body></html> - - - - - - - - - - - FNumber: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Changing this value will compute the Roc value. - - - - - - - - - - - Obstruction: - - - - - - - <html><head/><body><p>Usually the size of the diagonal shadow on the mirror. The surface error in this area will be ignored by the metrics.</p></body></html> - - - - - - - - - - - Conic Constant: - - - - - - - <html><head/><body><p>Desired conic Constant. The actual value will be computed by the analysis.</p><p>This value is used in computing the Artiicial Null value.</p><p>Set to 0 if testing a flat or a sphere.</p><p>Set to -1 if testing a paraboloid.</p></body></html> - - - - - - - - - - - <html><head/><body><p>Enable masking the clear apature at the outside edge of the mirror.</p></body></html> - - - Edge Mask - - - - - - - false - - - <html><head/><body><p>Width of the edge to mask. New SA artificial null will be computed based on the clear aperature of the mirror with this this mask value.</p></body></html> - - - 3 - - - 1000.000000000000000 - - - - - - - - - - - Unmasked Aperature: - - - - - - - false - - - true - - - - - - - - - - + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Autoinvert: not set + + + + + + + Change... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -222,33 +94,17 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + + Read Existing File - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + - Save in a File + Flip Interferogram left to right on loading @@ -306,20 +162,6 @@ Wave Length nm - - - - Read Existing File - - - - - - - Flip Interferogram left to right on loading - - - @@ -330,6 +172,9 @@ Wave Length nm + + + @@ -428,6 +273,196 @@ Wave Length nm + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + + + + + Mirror + + + + + + <html><head/><body><p>If set units are displayed in mm. If not then units are in inches. But only for this mirror configurion dialog.</p></body></html> + + + Units in mm + + + + + + + + + Diameter: + + + + + + + <html><head/><body><p>Daimeter of clear apature of the mirror or Horizontal axis of ellipse.</p></body></html> + + + + + + + + + + + Roc: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <html><head/><body><p>Positive value of Radius of curvature of mirror or 0 if testing a flat. Will be ignored if Artificial Null is checked.</p><p>The Fnumber will be computed from this value and the diameter.</p></body></html> + + + + + + + + + + + FNumber: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Changing this value will compute the Roc value. + + + + + + + + + + + Obstruction: + + + + + + + <html><head/><body><p>Usually the size of the diagonal shadow on the mirror. The surface error in this area will be ignored by the metrics.</p></body></html> + + + + + + + + + + + Conic Constant: + + + + + + + <html><head/><body><p>Desired conic Constant. The actual value will be computed by the analysis.</p><p>This value is used in computing the Artiicial Null value.</p><p>Set to 0 if testing a flat or a sphere.</p><p>Set to -1 if testing a paraboloid.</p></body></html> + + + + + + + + + + + <html><head/><body><p>Enable masking the clear apature at the outside edge of the mirror.</p></body></html> + + + Edge Mask + + + + + + + false + + + <html><head/><body><p>Width of the edge to mask. New SA artificial null will be computed based on the clear aperature of the mirror with this this mask value.</p></body></html> + + + 3 + + + 1000.000000000000000 + + + + + + + + + + + Unmasked Aperature: + + + + + + + false + + + true + + + + + + + + + + + + Artificial Null + + + + + + + Save in a File + + + diff --git a/surfaceanalysistools.cpp b/surfaceanalysistools.cpp index 4fcea51b..6c7d8bde 100644 --- a/surfaceanalysistools.cpp +++ b/surfaceanalysistools.cpp @@ -27,6 +27,7 @@ #include "mirrordlg.h" #include "renamewavefrontdlg.h" #include +#include "surfacemanager.h" surfaceAnalysisTools *surfaceAnalysisTools::m_Instance = NULL; surfaceAnalysisTools * surfaceAnalysisTools::get_Instance(QWidget *parent){ @@ -292,6 +293,8 @@ void surfaceAnalysisTools::defocusControlChanged(double val){ void surfaceAnalysisTools::on_InvertPB_pressed() { emit invert(SelectedWaveFronts()); + SurfaceManager::get_instance()->m_inverseMode = invMANUAL; // switch to manual mode of inverting wavefronts + mirrorDlg::get_Instance()->updateAutoInvertStatus(); } // this is triggered on renaming/editing end @@ -357,3 +360,6 @@ void surfaceAnalysisTools::closeDefocus(int /*result*/){ m_defocus = 0.; emit defocusChanged(); } + + + diff --git a/surfacemanager.cpp b/surfacemanager.cpp index 26587e7b..94a1949e 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -375,26 +375,35 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){ mirrorDlg *md = mirrorDlg::get_Instance(); zp.unwrap_to_zernikes(*wf); // check for swapped conic value - if (!m_ignoreInverse && (md->cc != 0.0) && md->cc * wf->InputZerns[8] < 0.){ - bool reverse = false; - if (m_askAboutReverse){ - if (QMessageBox::Yes == QMessageBox::question(0,"should invert?","Wavefront seems inverted. Do you want to invert it?")) - { - reverse = true; - m_askAboutReverse = false; - }else - { - reverse = false; - } + if (!m_ignoreInverse) + { + if (m_inverseMode==invNOTSET) + { + autoInvertDlg *dlg_ai = autoInvertDlg::get_Instance(); + dlg_ai->exec(); + md->updateAutoInvertStatus(); } - else { - reverse = true; + bool reverse = false; + if (m_inverseMode == invCONIC) + { + if (md->cc != 0.0 && md->cc * wf->InputZerns[8] < 0.) + reverse = true; + } else if (m_inverseMode == invINSIDE) + { + if (wf->InputZerns[3]>0) + reverse = true; + } else if (m_inverseMode == invOUTSIDE) + { + if (wf->InputZerns[3]<0) + reverse = true; } if (reverse){ wf->data *= -1; + zp.unwrap_to_zernikes(*wf); } - zp.unwrap_to_zernikes(*wf); } + + ((MainWindow*)parent())-> zernTablemodel->setValues(wf->InputZerns, !wf->useSANull); ((MainWindow*)parent())-> zernTablemodel->update(); // fill in void from obstruction of igram. @@ -491,7 +500,7 @@ SurfaceManager::SurfaceManager(QObject *parent, surfaceAnalysisTools *tools, ProfilePlot *profilePlot, contourView *contourView, SurfaceGraph *glPlot, metricsDisplay *mets): QObject(parent), m_surfaceTools(tools),m_profilePlot(profilePlot), m_contourView(contourView), - m_SurfaceGraph(glPlot), m_metrics(mets), + m_SurfaceGraph(glPlot), m_metrics(mets),m_inverseMode(invNOTSET), m_gbValue(21),m_GB_enabled(false),m_currentNdx(-1),m_standAvg(0),insideOffset(0), outsideOffset(0),m_askAboutReverse(true),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0) { diff --git a/surfacemanager.h b/surfacemanager.h index c1182160..ee8eb044 100644 --- a/surfacemanager.h +++ b/surfacemanager.h @@ -44,6 +44,7 @@ #include #include "surfacegraph.h" enum configRESPONSE { YES, NO, ASK}; +enum AutoInvertMode {invNOTSET, invMANUAL, invCONIC, invINSIDE, invOUTSIDE}; struct textres { QTextEdit *Edit; QList res; @@ -110,6 +111,7 @@ class SurfaceManager : public QObject void average(QList wfList); void subtractWavefronts(); + AutoInvertMode m_inverseMode; bool m_askAboutReverse; bool m_ignoreInverse; bool m_surface_finished; From 6ffbef770248237df19f370c5109d198cb36900d Mon Sep 17 00:00:00 2001 From: gr5 Date: Fri, 26 Sep 2025 15:07:40 -0400 Subject: [PATCH 2/9] Minor tweaks to new auto-invert feature: Removed the code where I had "invert" button change the autoinvert status Changed wording a little in the auto invert dialog Spaced things out in the auto invert dialog for people with >100% scaling Tested at 225% scaling Fixed project files to include the new autoinvert dialog --- DFTFringe.pro | 3 ++ DFTFringe_Dale.pro | 4 ++- autoinvertdlg.ui | 70 +++++++++++++++++++++++----------------- surfaceanalysistools.cpp | 3 -- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/DFTFringe.pro b/DFTFringe.pro index cf7ec6e0..dc0aca04 100644 --- a/DFTFringe.pro +++ b/DFTFringe.pro @@ -152,6 +152,7 @@ SOURCES += SingleApplication/singleapplication.cpp \ astigscatterplot.cpp \ astigstatsdlg.cpp \ astigzoomer.cpp \ + autoinvertdlg.cpp \ averagewavefrontfilesdlg.cpp \ batchigramwizard.cpp \ bathastigdlg.cpp \ @@ -276,6 +277,7 @@ HEADERS += bezier/bezier.h \ astigscatterplot.h \ astigstatsdlg.h \ astigzoomer.h \ + autoinvertdlg.h \ averagewavefrontfilesdlg.h \ batchigramwizard.h \ bathastigdlg.h \ @@ -397,6 +399,7 @@ FORMS += arbitrarywavefronthelp.ui \ annulushelpdlg.ui \ astigpolargraph.ui \ astigstatsdlg.ui \ + autoinvertdlg.ui \ averagewavefrontfilesdlg.ui \ batchigramwizard.ui \ bathastigdlg.ui \ diff --git a/DFTFringe_Dale.pro b/DFTFringe_Dale.pro index c4307ac2..37cb12ee 100644 --- a/DFTFringe_Dale.pro +++ b/DFTFringe_Dale.pro @@ -31,6 +31,7 @@ SOURCES += main.cpp \ arbitrarywavefronthelp.cpp \ arbitrarywavwidget.cpp \ astigpolargraph.cpp \ + autoinvertdlg.cpp \ cpoint.cpp \ defocusdlg.cpp \ edgeplot.cpp \ @@ -154,6 +155,7 @@ HEADERS += mainwindow.h \ arbitrarywavefronthelp.h \ arbitrarywavwidget.h \ astigpolargraph.h \ + autoinvertdlg.h \ cpoint.h \ defocusdlg.h \ edgeplot.h \ @@ -282,6 +284,7 @@ FORMS += mainwindow.ui \ annulushelpdlg.ui \ arbitrarywavefronthelp.ui \ astigpolargraph.ui \ + autoinvertdlg.ui \ defocusdlg.ui \ dfttools.ui \ dftarea.ui \ @@ -389,7 +392,6 @@ LIBS += D:\opencv\opencv-3.4.12\build\bin\libopencv_imgproc3412.dll LIBS += D:\opencv\opencv-3.4.12\build\bin\libopencv_features2d3412.dll LIBS += D:\opencv\opencv-3.4.12\build\bin\libopencv_calib3d3412.dll - #LIBS += D:\armadillo\bin\libarmadillo.dll LIBS += D:\lapack\build64\bin\liblapack.dll LIBS += D:\lapack\build64\bin\libblas.dll diff --git a/autoinvertdlg.ui b/autoinvertdlg.ui index eab0f023..15344106 100644 --- a/autoinvertdlg.ui +++ b/autoinvertdlg.ui @@ -6,8 +6,8 @@ 0 0 - 487 - 410 + 678 + 464 @@ -19,9 +19,9 @@ - 30 - 130 - 81 + 20 + 150 + 111 24 @@ -32,22 +32,22 @@ - 30 - 60 - 81 + 20 + 80 + 111 24 - Parabolized + Match Conic - 30 - 180 - 81 + 20 + 200 + 111 24 @@ -58,9 +58,9 @@ - 30 - 260 - 81 + 20 + 280 + 111 24 @@ -72,14 +72,17 @@ 140 - 120 - 261 + 150 + 521 41 I'll invert the wavefront myself as needed + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + true @@ -88,14 +91,17 @@ 140 - 50 - 291 + 80 + 521 61 Most common. This mirror is at least partially figured. DFTFringe will invert the wavefront if S.A. sign doesn't match mirror configuration conic constant sign. This option disabled if CC=0. + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + true @@ -104,14 +110,17 @@ 140 - 170 - 261 - 61 + 200 + 521 + 71 This and future interferograms of this mirror are inside focus (interferometer closer to mirror). DFTFringe will use that fact to invert as needed. + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + true @@ -120,14 +129,17 @@ 140 - 250 - 261 + 280 + 521 61 This and future interferograms of this mirror are outside focus (interferometer farther from mirror). DFTFringe will use that fact to invert as needed. + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + true @@ -137,8 +149,8 @@ 20 0 - 411 - 41 + 641 + 61 @@ -157,9 +169,9 @@ 20 - 340 - 441 - 71 + 350 + 631 + 91 diff --git a/surfaceanalysistools.cpp b/surfaceanalysistools.cpp index 6c7d8bde..6c7835f0 100644 --- a/surfaceanalysistools.cpp +++ b/surfaceanalysistools.cpp @@ -27,7 +27,6 @@ #include "mirrordlg.h" #include "renamewavefrontdlg.h" #include -#include "surfacemanager.h" surfaceAnalysisTools *surfaceAnalysisTools::m_Instance = NULL; surfaceAnalysisTools * surfaceAnalysisTools::get_Instance(QWidget *parent){ @@ -293,8 +292,6 @@ void surfaceAnalysisTools::defocusControlChanged(double val){ void surfaceAnalysisTools::on_InvertPB_pressed() { emit invert(SelectedWaveFronts()); - SurfaceManager::get_instance()->m_inverseMode = invMANUAL; // switch to manual mode of inverting wavefronts - mirrorDlg::get_Instance()->updateAutoInvertStatus(); } // this is triggered on renaming/editing end From 184bc74942b4918ace11ed5dbcce08949507755b Mon Sep 17 00:00:00 2001 From: gr5 Date: Fri, 26 Sep 2025 17:34:29 -0400 Subject: [PATCH 3/9] auto invert small fixes: Disable the "conic" button if cc=0. If user changes cc to zero within the mirror config and clicks "ok" and if it's in conic mode it switches to "not set" mode. I realized "Your wavefront may be inverted" is inappropriate when running the dialog from the mirror config screen so that text changes depending how you got there. fixed a compiler warning, fixed other minor stuff. --- autoinvertdlg.cpp | 7 +++++++ autoinvertdlg.h | 2 ++ autoinvertdlg.ui | 2 +- mirrordlg.cpp | 10 +++++++++- surfacemanager.cpp | 8 +++++--- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/autoinvertdlg.cpp b/autoinvertdlg.cpp index 36d996b5..8113f420 100644 --- a/autoinvertdlg.cpp +++ b/autoinvertdlg.cpp @@ -50,3 +50,10 @@ void autoInvertDlg::on_btnOutside_clicked() accept(); } +void autoInvertDlg::setMainLabel(const QString & str) { + ui->lblMain->setText(str); +} + +void autoInvertDlg::enableConic(bool b) { + ui->btnUseConic->setEnabled(b); +} diff --git a/autoinvertdlg.h b/autoinvertdlg.h index c8c90d6a..5a1895e6 100644 --- a/autoinvertdlg.h +++ b/autoinvertdlg.h @@ -15,6 +15,8 @@ class autoInvertDlg : public QDialog explicit autoInvertDlg(QWidget *parent = nullptr); ~autoInvertDlg(); static autoInvertDlg *get_Instance(); + void setMainLabel(const QString & str); + void enableConic(bool b); private slots: diff --git a/autoinvertdlg.ui b/autoinvertdlg.ui index 15344106..12b76a95 100644 --- a/autoinvertdlg.ui +++ b/autoinvertdlg.ui @@ -144,7 +144,7 @@ true - + 20 diff --git a/mirrordlg.cpp b/mirrordlg.cpp index 99eca06a..b0dc9cdf 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -664,6 +664,12 @@ void mirrorDlg::on_buttonBox_accepted() setclearAp(); updateZ8(); + SurfaceManager * sm = SurfaceManager::get_instance(); + if (sm->m_inverseMode == invCONIC && cc==0) { + sm->m_inverseMode = invNOTSET; // don't allow inverse mode to be conic if conic constant is zero + updateAutoInvertStatus(); + } + settings.setValue("config mirror name", ui->name->text()); settings.setValue("config roc", roc); settings.setValue("config lambda",lambda); @@ -862,7 +868,7 @@ void mirrorDlg::updateAutoInvertStatus() ui->lblAutoInvert->setText("Autoinvert: Manual"); break; case invCONIC: - ui->lblAutoInvert->setText("Autoinvert: Parabolic"); + ui->lblAutoInvert->setText("Autoinvert: Conic"); break; case invINSIDE: ui->lblAutoInvert->setText("Autoinvert: Inside Focus"); @@ -876,6 +882,8 @@ void mirrorDlg::updateAutoInvertStatus() void mirrorDlg::on_btnChangeAutoInvert_clicked() { + m_autoInvertDlg->setMainLabel("How should DFTFringe choose to auto invert?"); + m_autoInvertDlg->enableConic(cc != 0); m_autoInvertDlg->exec(); updateAutoInvertStatus(); } diff --git a/surfacemanager.cpp b/surfacemanager.cpp index 94a1949e..02e5bce2 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -380,6 +380,8 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){ if (m_inverseMode==invNOTSET) { autoInvertDlg *dlg_ai = autoInvertDlg::get_Instance(); + dlg_ai->setMainLabel("Your wavefront may be inverted. What do you want to do?"); + dlg_ai->enableConic(md->cc != 0); dlg_ai->exec(); md->updateAutoInvertStatus(); } @@ -500,9 +502,9 @@ SurfaceManager::SurfaceManager(QObject *parent, surfaceAnalysisTools *tools, ProfilePlot *profilePlot, contourView *contourView, SurfaceGraph *glPlot, metricsDisplay *mets): QObject(parent), m_surfaceTools(tools),m_profilePlot(profilePlot), m_contourView(contourView), - m_SurfaceGraph(glPlot), m_metrics(mets),m_inverseMode(invNOTSET), - m_gbValue(21),m_GB_enabled(false),m_currentNdx(-1),m_standAvg(0),insideOffset(0), - outsideOffset(0),m_askAboutReverse(true),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0) + m_SurfaceGraph(glPlot), m_metrics(mets),m_gbValue(21), + m_GB_enabled(false),m_currentNdx(-1),m_standAvg(0),insideOffset(0),outsideOffset(0), + m_inverseMode(invNOTSET),m_askAboutReverse(true),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0) { okToUpdateSurfacesOnGenerateComplete = true; From b74e7c0acdc5f2252bd0ed4945213ddf1e12059a Mon Sep 17 00:00:00 2001 From: gr5 Date: Sat, 27 Sep 2025 20:25:22 -0400 Subject: [PATCH 4/9] Forgot to edit this 3rd project file. Should compile now. --- DFTFringe_QT5.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DFTFringe_QT5.pro b/DFTFringe_QT5.pro index 2ec59040..d62f24e3 100644 --- a/DFTFringe_QT5.pro +++ b/DFTFringe_QT5.pro @@ -154,6 +154,7 @@ SOURCES += SingleApplication/singleapplication.cpp \ astigscatterplot.cpp \ astigstatsdlg.cpp \ astigzoomer.cpp \ + autoinvertdlg.cpp \ averagewavefrontfilesdlg.cpp \ batchigramwizard.cpp \ bathastigdlg.cpp \ @@ -278,6 +279,7 @@ HEADERS += bezier/bezier.h \ astigscatterplot.h \ astigstatsdlg.h \ astigzoomer.h \ + autoinvertdlg.h \ averagewavefrontfilesdlg.h \ batchigramwizard.h \ bathastigdlg.h \ @@ -397,6 +399,7 @@ FORMS += arbitrarywavefronthelp.ui \ annulushelpdlg.ui \ astigpolargraph.ui \ astigstatsdlg.ui \ + autoinvertdlg.ui \ averagewavefrontfilesdlg.ui \ batchigramwizard.ui \ bathastigdlg.ui \ From 565df9053d9545dbb270633d410c50fb814fc6e1 Mon Sep 17 00:00:00 2001 From: gr5 Date: Sat, 11 Oct 2025 19:36:51 -0400 Subject: [PATCH 5/9] Update mirrordlg.ui Co-authored-by: Julien Staub --- mirrordlg.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirrordlg.ui b/mirrordlg.ui index f4240ab5..6c677ac4 100644 --- a/mirrordlg.ui +++ b/mirrordlg.ui @@ -292,7 +292,7 @@ Wave Length nm - <html><head/><body><p>If set units are displayed in mm. If not then units are in inches. But only for this mirror configurion dialog.</p></body></html> + <html><head/><body><p>If set units are displayed in mm. If not, then units are in inches. But only for this mirror configuration dialog.</p></body></html> Units in mm From dcb6a802c66c38332909213db8904bad638c3872 Mon Sep 17 00:00:00 2001 From: gr5 Date: Sat, 11 Oct 2025 19:37:10 -0400 Subject: [PATCH 6/9] Update mirrordlg.ui Co-authored-by: Julien Staub --- mirrordlg.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirrordlg.ui b/mirrordlg.ui index 6c677ac4..d6bca11d 100644 --- a/mirrordlg.ui +++ b/mirrordlg.ui @@ -311,7 +311,7 @@ Wave Length nm - <html><head/><body><p>Daimeter of clear apature of the mirror or Horizontal axis of ellipse.</p></body></html> + <html><head/><body><p>Diameter of clear aperture of the mirror or Horizontal axis of ellipse.</p></body></html> From 480759f0b8886535612986533b4748f374b7f423 Mon Sep 17 00:00:00 2001 From: gr5 Date: Sat, 11 Oct 2025 19:38:03 -0400 Subject: [PATCH 7/9] Update autoinvertdlg.ui Co-authored-by: Julien Staub --- autoinvertdlg.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoinvertdlg.ui b/autoinvertdlg.ui index 12b76a95..441e325d 100644 --- a/autoinvertdlg.ui +++ b/autoinvertdlg.ui @@ -175,7 +175,7 @@ - Once you choose an option you won't be bothered again about this until you restart the program. You can also get back to this window from within the mirror configuration window. + Once you choose an option you won't be asked again until you restart the program. You can get back to this window from within the mirror configuration window. true From bd904e9b521c9e8d6242529da381b47a36266fca Mon Sep 17 00:00:00 2001 From: gr5 Date: Wed, 15 Oct 2025 12:05:23 -0400 Subject: [PATCH 8/9] Removed singleton design pattern from autoinvertdlg. Code is a little simpler, smaller. --- autoinvertdlg.cpp | 5 ----- autoinvertdlg.h | 1 - mainwindow.cpp | 2 -- mirrordlg.cpp | 8 ++++---- surfacemanager.cpp | 12 ++++++------ surfacemanager.h | 1 - 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/autoinvertdlg.cpp b/autoinvertdlg.cpp index 8113f420..50f6c4f7 100644 --- a/autoinvertdlg.cpp +++ b/autoinvertdlg.cpp @@ -14,11 +14,6 @@ autoInvertDlg::~autoInvertDlg() delete ui; } -autoInvertDlg *autoInvertDlg::get_Instance(){ - static autoInvertDlg m_Instance{}; - return &m_Instance; -} - void autoInvertDlg::on_btnUseConic_clicked() { SurfaceManager *sm = SurfaceManager::get_instance(); diff --git a/autoinvertdlg.h b/autoinvertdlg.h index 5a1895e6..dd41699f 100644 --- a/autoinvertdlg.h +++ b/autoinvertdlg.h @@ -14,7 +14,6 @@ class autoInvertDlg : public QDialog public: explicit autoInvertDlg(QWidget *parent = nullptr); ~autoInvertDlg(); - static autoInvertDlg *get_Instance(); void setMainLabel(const QString & str); void enableConic(bool b); diff --git a/mainwindow.cpp b/mainwindow.cpp index 18e47710..8af6b7bc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -49,7 +49,6 @@ #include "colorchannel.h" #include "opencv2/opencv.hpp" #include -#include "autoinvertdlg.h" #include "zapm_interface.h" #include "zernikeprocess.h" @@ -354,7 +353,6 @@ MainWindow::~MainWindow() delete m_ogl; userMapDlg->close(); mirrorDlg::get_Instance()->close(); - autoInvertDlg::get_Instance()->close(); settingsDlg->close(); delete settingsDlg; delete ui; diff --git a/mirrordlg.cpp b/mirrordlg.cpp index ee21c852..95403981 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -53,7 +53,6 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->useAnnulus->setChecked(m_useAnnular); enableAnnular(m_useAnnular); ui->annulusPercent->setValue(settings.value("md annulus percent",0.).toDouble() * 100 ); - m_autoInvertDlg = autoInvertDlg::get_Instance(); ui->nullCB->setChecked(doNull); diameter = settings.value("config diameter", 200.).toDouble(); @@ -840,9 +839,10 @@ void mirrorDlg::updateAutoInvertStatus() void mirrorDlg::on_btnChangeAutoInvert_clicked() { - m_autoInvertDlg->setMainLabel("How should DFTFringe choose to auto invert?"); - m_autoInvertDlg->enableConic(cc != 0); - m_autoInvertDlg->exec(); + autoInvertDlg dlg; + dlg.setMainLabel("How should DFTFringe choose to auto invert?"); + dlg.enableConic(cc != 0); + dlg.exec(); updateAutoInvertStatus(); } diff --git a/surfacemanager.cpp b/surfacemanager.cpp index e6266d0c..b49e6036 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -383,11 +383,11 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){ // Temporarily restore cursor so QMessageBox does not show waitCursor // QGuiApplication::setOverrideCursor do stack so we will go back to previous state (any state) QGuiApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); - autoInvertDlg *dlg_ai = autoInvertDlg::get_Instance(); - dlg_ai->setMainLabel("Your wavefront may be inverted. What do you want to do?"); - dlg_ai->enableConic(md->cc != 0); - dlg_ai->exec(); - QGuiApplication::restoreOverrideCursor(); + autoInvertDlg dlg_ai; + dlg_ai.setMainLabel("Your wavefront may be inverted. What do you want to do?"); + dlg_ai.enableConic(md->cc != 0); + dlg_ai.exec(); + QGuiApplication::restoreOverrideCursor(); md->updateAutoInvertStatus(); } bool reverse = false; @@ -508,7 +508,7 @@ SurfaceManager::SurfaceManager(QObject *parent, surfaceAnalysisTools *tools, m_surfaceTools(tools),m_profilePlot(profilePlot), m_contourView(contourView), m_SurfaceGraph(glPlot), m_metrics(mets),m_gbValue(21), m_GB_enabled(false),m_currentNdx(-1),m_standAvg(0),insideOffset(0),outsideOffset(0), - m_inverseMode(invNOTSET),m_askAboutReverse(true),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0) + m_inverseMode(invNOTSET),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0) { okToUpdateSurfacesOnGenerateComplete = true; diff --git a/surfacemanager.h b/surfacemanager.h index da2e74ce..5f6f1052 100644 --- a/surfacemanager.h +++ b/surfacemanager.h @@ -112,7 +112,6 @@ class SurfaceManager : public QObject void subtractWavefronts(); AutoInvertMode m_inverseMode; - bool m_askAboutReverse; bool m_ignoreInverse; bool m_surface_finished; configRESPONSE diamResp; From 7d10a47891c738d99a8511341fa0c50f96ddf8a5 Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Thu, 16 Oct 2025 19:08:04 +0200 Subject: [PATCH 9/9] Apply suggestion from @atsju --- mirrordlg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/mirrordlg.h b/mirrordlg.h index 884ac89b..a810e1e8 100644 --- a/mirrordlg.h +++ b/mirrordlg.h @@ -142,7 +142,6 @@ private slots: QTimer spacingChangeTimer; void saveJson(const QString &fileName); void enableAnnular(bool enable); - autoInvertDlg *m_autoInvertDlg; }; #endif // MIRRORDLG_H