From c8e3fed348fe07d9bb6394e1a79a033f8c348e7e Mon Sep 17 00:00:00 2001 From: gr5 Date: Wed, 22 Nov 2023 15:31:00 -0500 Subject: [PATCH] Fixes issue #115 - issues with "edge mask" aka aperture reduction When reading old OLN files, ignore edge mask When writing OLN files don't save edge mask Fixed 2 locations where edge mask needs to be set to zero when checkbox is not checked in mirror dialog Fixed bug where edge mask is checked if not found in OLN file! --- dftarea.cpp | 2 ++ igramarea.cpp | 84 ++------------------------------------------------- mirrordlg.cpp | 9 ++---- mirrordlg.h | 1 - 4 files changed, 7 insertions(+), 89 deletions(-) diff --git a/dftarea.cpp b/dftarea.cpp index f3bf400e..f165e558 100644 --- a/dftarea.cpp +++ b/dftarea.cpp @@ -252,6 +252,8 @@ cv::Mat DFTArea::grayComplexMatfromImage(QImage &img){ double pixelsPermm =(igramArea->m_outside.m_radius/(md.diameter/2.)); double reduction = md.aperatureReduction * pixelsPermm; + if (md.m_aperatureReductionEnabled == false) + reduction = 0; double rad = igramArea->m_outside.m_radius - reduction; diff --git a/igramarea.cpp b/igramarea.cpp index f3e0c9a7..0961be9c 100644 --- a/igramarea.cpp +++ b/igramarea.cpp @@ -152,6 +152,8 @@ void IgramArea::computeEdgeRadius(){ mirrorDlg &md = *mirrorDlg::get_Instance(); double pixelsPermm =(m_outside.m_radius/(md.diameter/2.)); m_edgeMaskWidth = md.aperatureReduction * pixelsPermm; + if (md.m_aperatureReductionEnabled == false) + m_edgeMaskWidth = 0; } @@ -2140,45 +2142,6 @@ void IgramArea::loadOutlineFile(QString fileName){ emit dftCenterFilter(filter); - // edge mask - const QJsonValue jedge = loadDoc["edge_mask_width_mm"]; - mirrorDlg &md = *mirrorDlg::get_Instance(); - if (jedge.isDouble()) { - const double edge = jedge.toDouble(); - // if outline edge mask is different than current ask user - if (edge != md.aperatureReduction){ - QString text( - "Do you want to change the mirror config value to match the value in the outline file?\n" - "If no then the current mirror config value will be used instead." - ); - - QMessageBox mb; - mb.setText(QString("Edge mask value in outline file for this interferogram is %1 and is different than mirror config value of %2.").arg( - edge, 6, 'f', 1).arg(md.aperatureReduction, 6, 'f', 1) ); - mb.setInformativeText(text); - mb.setStandardButtons( QMessageBox::Yes|QMessageBox::No ); - mb.setWindowTitle("Existing Interferogram outline file and Mirror Config difference."); - int width = QGuiApplication::primaryScreen()->geometry().width() * .5; - QSpacerItem* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - QGridLayout* layout = (QGridLayout*)mb.layout(); - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - int resp = mb.exec(); - - switch (resp){ - case QMessageBox::Yes: - md.changeEdgeMaskvalues(edge); - - break; - case QMessageBox::No: - default: // if they click red X do same thing as "no" button - md.changeEdgeMaskvalues(md.aperatureReduction); - break; - } - } - } - else{ // just enable edge mask check box to use the current value. - md.changeEdgeMaskvalues(md.aperatureReduction); - } // mask polygons regions m_polygons.clear(); @@ -2257,40 +2220,7 @@ void IgramArea::loadOutlineFileOldV6(QString fileName){ mirrorDlg &md = *mirrorDlg::get_Instance(); if (line == "Edge Mask width"){ std::getline(file,line); - double edge = QString::fromStdString(line).toDouble(); - // if outline edge mask is different than current ask user - if (edge != md.aperatureReduction){ - QString text( - "Do you want to change the mirror config value to match the value in the outline file?\n" - "If no then the current mirror config value will be used instead." -); - - QMessageBox mb; - mb.setText(QString("Edge mask value in outline file for this interferogram is %1 and is different than mirror config value of %2.").arg( - edge, 6, 'f', 1).arg(md.aperatureReduction, 6, 'f', 1) ); - mb.setInformativeText(text); - mb.setStandardButtons( QMessageBox::Yes|QMessageBox::No ); - mb.setWindowTitle("Existing Interferogram outline file and Mirror Config difference."); - int width = QGuiApplication::primaryScreen()->geometry().width() * .5; - QSpacerItem* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - QGridLayout* layout = (QGridLayout*)mb.layout(); - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - int resp = mb.exec(); - - switch (resp){ - case QMessageBox::Yes: - md.changeEdgeMaskvalues(edge); - break; - case QMessageBox::No: - md.changeEdgeMaskvalues(md.aperatureReduction); - break; - } - } - - } - else{ // just enable edge mask check box to use the current value. - md.changeEdgeMaskvalues(md.aperatureReduction); } } @@ -2370,10 +2300,7 @@ void IgramArea::writeOutlinesOldV6(QString fileName){ } } saveRegions(); // save regions to registry also - if (m_edgeMaskWidth != 0){ - mirrorDlg &md = *mirrorDlg::get_Instance(); - file << "\nEdge Mask width" << std::endl << md.aperatureReduction << std::endl; - } + file.flush(); file.close(); @@ -2404,11 +2331,6 @@ void IgramArea::writeOutlines(QString fileName){ double filterRad = set.value("DFT Center Filter",10).toDouble(); j1["dft_filter_radius"]=filterRad; - if (m_edgeMaskWidth != 0) { - mirrorDlg &md = *mirrorDlg::get_Instance(); - j1["edge_mask_width_mm"] = md.aperatureReduction; - } - QJsonArray jRegions; for (int i = 0; i < m_polygons.size(); ++ i){ if (m_polygons[i].size() > 0){ diff --git a/mirrordlg.cpp b/mirrordlg.cpp index f2c795e1..dc3c44b2 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -600,6 +600,8 @@ void mirrorDlg::on_buttonBox_helpRequested() void mirrorDlg::setclearAp(){ m_clearAperature = (diameter - aperatureReduction * 2) ; + if (m_aperatureReductionEnabled == false) + m_clearAperature = diameter; ui->ClearAp->setText(QString("%1 ").arg(m_clearAperature * ((mm) ? 1: 1./25.4), 6, 'f', 2)); } @@ -625,13 +627,6 @@ void mirrorDlg::on_ReducApp_clicked(bool checked) } -void mirrorDlg::changeEdgeMaskvalues(double val){ - m_aperatureReductionEnabled = true; - ui->ReducApp->setChecked(true); - ui->reduceValue->setValue(val); - ui->reduceValue->setEnabled(true); - -} void mirrorDlg::on_reduceValue_valueChanged(double arg1) { aperatureReduction = ((mm) ? 1: 25.4) * arg1; diff --git a/mirrordlg.h b/mirrordlg.h index f3beca39..0b7f2cde 100644 --- a/mirrordlg.h +++ b/mirrordlg.h @@ -66,7 +66,6 @@ class mirrorDlg : public QDialog outlineShape m_outlineShape; bool isEllipse(); void setMinorAxis(double val); - void changeEdgeMaskvalues(double val); bool m_aperatureReductionEnabled; private slots: void on_ReadBtn_clicked();