From 6af2a829248de88c0804934f4f0b6ee88853c77f Mon Sep 17 00:00:00 2001 From: Dale Eason Date: Mon, 3 Jul 2023 10:53:37 -0500 Subject: [PATCH 1/3] corrected but for edge mask not updating artificial null on initial open if edge mask is enabled. Saved region state after region delete. --- IgramArea.h | 1 + igramarea.cpp | 31 ++++++++++++++++++++++--------- mirrordlg.cpp | 9 ++++++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/IgramArea.h b/IgramArea.h index f53886f6..0b80ffe5 100644 --- a/IgramArea.h +++ b/IgramArea.h @@ -223,6 +223,7 @@ public slots: cv::Point2d findBestCenterOutline(cv::Mat gray, int start, int end, int step, double &resp, int *radius, bool useExisting); QString m_outlineMsg; double m_edgeMaskWidth; + void saveRegions(); public: void deleteRegions(); cv::Point2d findBestOutsideOutline(cv::Mat gray, int start, int end, int step, double &resp, int *radius, int pass); diff --git a/igramarea.cpp b/igramarea.cpp index 06fa1a90..5e07fc1a 100644 --- a/igramarea.cpp +++ b/igramarea.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "opencv2/imgproc.hpp" #include "opencv2/features2d.hpp" #include "graphicsutilities.h" @@ -1958,6 +1958,21 @@ void IgramArea::paintEvent(QPaintEvent *event) +} +void IgramArea::saveRegions(){ + QString text; + QTextStream regions(&text); + + for (int i = 0; i < m_polygons.size(); ++i){ + regions << "Poly"; + for(int j = 0; j < m_polygons[i].size(); ++j){ + regions << " " << QString().number(m_polygons[i][j].x) << ","<< + QString().number(m_polygons[i][j].y); + } + regions << "\n"; + } + QSettings set; + set.setValue("lastRegions", text); } void IgramArea::createActions() @@ -1986,7 +2001,7 @@ void IgramArea::crop() { set.setValue("lastOutsideRad", radx); set.setValue("lastOutsideCx",cx); set.setValue("lastOutsideCy",cy); -qDebug() << "crop saving" << cx << cy << radx; + int width = igramGray.width(); int height = igramGray.height(); int right = width - (radx + cx); @@ -2018,19 +2033,16 @@ qDebug() << "crop saving" << cx << cy << radx; x = igramGray.width()/2; y = igramGray.height()/2; - QString text; - QTextStream regions(&text); + for (int i = 0; i < m_polygons.size(); ++i){ - regions << "Poly"; for(int j = 0; j < m_polygons[i].size(); ++j){ - regions << " " << QString().number(m_polygons[i][j].x) << ","<< - QString().number(m_polygons[i][j].y); m_polygons[i][j].x -=crop_dx; m_polygons[i][j].y -= crop_dy; } - regions << "\n"; + } - set.setValue("lastRegions", text); + saveRegions(); + m_outside.translate(QPointF(-crop_dx,-crop_dy)); cx = m_outside.m_center.x() + crop_dx; cy = m_outside.m_center.y() + crop_dy; @@ -2248,6 +2260,7 @@ void IgramArea::deleteOutline(){ } m_polygons.clear(); syncRegions(); + saveRegions(); } else if (m_current_boundry == CenterOutline){ m_centerHist.clear(); diff --git a/mirrordlg.cpp b/mirrordlg.cpp index e321c1e2..e540b692 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -53,6 +53,7 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->cc->blockSignals(true); ui->unitsCB->blockSignals(true); ui->fringeSpacingEdit->blockSignals(true); + if (!doNull){ ui->roc->hide(); ui->rocLab->hide(); @@ -76,10 +77,14 @@ mirrorDlg::mirrorDlg(QWidget *parent) : cc = settings.value("config cc", -1.).toDouble(); ui->cc->setText(QString().sprintf("%6.2lf",cc)); - ui->reduceValue->setValue(aperatureReduction); + bool showEdgeMaskCtrls = settings.value("configAperatureReductionChecked",false).toBool(); + ui->ReducApp->setChecked(showEdgeMaskCtrls); if (aperatureReduction > 0) ui->reduceValue->setEnabled(true); + ui->reduceValue->setValue(aperatureReduction); + + ui->unitsCB->setChecked(mm); ui->FNumber->blockSignals(false); @@ -104,8 +109,6 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->cc->blockSignals(false); ui->unitsCB->blockSignals(false); ui->fringeSpacingEdit->blockSignals(false); - bool showEdgeMaskCtrls = settings.value("configAperatureReductionChecked",false).toBool(); - ui->ReducApp->setChecked(showEdgeMaskCtrls); ui->ClearAp->setVisible(showEdgeMaskCtrls); ui->clearApLabel->setVisible(showEdgeMaskCtrls); m_aperatureReductionValueChanged = false; From b0268c2acead681f9a0fb9cb127549a5b6407653 Mon Sep 17 00:00:00 2001 From: Dale Eason Date: Wed, 12 Jul 2023 02:08:41 -0500 Subject: [PATCH 2/3] updated edge mask to save and restore values from .oln file. Increased value of ronchi multiplier in foucult view. --- foucaultview.ui | 4 ++-- igramarea.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++------ mainwindow.cpp | 22 +++++++++---------- mirrordlg.cpp | 23 ++++++++++++++------ mirrordlg.h | 3 ++- 5 files changed, 82 insertions(+), 27 deletions(-) diff --git a/foucaultview.ui b/foucaultview.ui index 5f9f16f9..17bb3a7e 100644 --- a/foucaultview.ui +++ b/foucaultview.ui @@ -479,10 +479,10 @@ 1 - 1.000000000000000 + -20.000000000000000 - 10.000000000000000 + 20.000000000000000 0.500000000000000 diff --git a/igramarea.cpp b/igramarea.cpp index 5e07fc1a..4bba2ef8 100644 --- a/igramarea.cpp +++ b/igramarea.cpp @@ -150,6 +150,7 @@ void IgramArea::computeEdgeRadius(){ mirrorDlg &md = *mirrorDlg::get_Instance(); double pixelsPermm =(m_outside.m_radius/(md.diameter/2.)); m_edgeMaskWidth = md.aperatureReduction * pixelsPermm; + } void IgramArea::aperatureChanged(){ @@ -1696,8 +1697,9 @@ void IgramArea::drawBoundary() painter.setBrush(Qt::NoBrush); } outside.draw(painter,1.,s2); - if (md.m_clearAperature != md.diameter){ + if ( md.m_aperatureReductionEnabled && md.m_clearAperature != md.diameter){ painter.setPen(QPen(edgePenColor, edgePenWidth, Qt::DotLine)); + computeEdgeRadius(); painter.drawEllipse(outside.m_center, outside.m_radius - m_edgeMaskWidth, outside.m_radius- m_edgeMaskWidth); @@ -2112,7 +2114,7 @@ void IgramArea::loadOutlineFile(QString fileName){ fsize = file.tellg() - fsize; file.close(); file.open(fileName.toStdString().c_str()); - qDebug() << "ouline opened"; + if (!file.is_open()) { QMessageBox::warning(this, tr("Read Outline"), tr("Cannot read file %1: ") @@ -2121,11 +2123,16 @@ void IgramArea::loadOutlineFile(QString fileName){ } m_outside = readCircle(file); + m_OutterP1 = m_outside.m_p1.m_p; + m_OutterP2 = m_outside.m_p2.m_p; + outterPcount = 2; CircleOutline sideLobe = readCircle(file); emit dftCenterFilter(sideLobe.m_radius); + char b = file.peek(); + if ((file.tellg() > 0) && (fsize > file.tellg())) { - if (file.peek() != 'P'){ + if ((b != 'P') && (b != 'E')){ m_center = readCircle(file); m_innerP1 = m_center.m_p1.m_p; m_innerP2 = m_center.m_p2.m_p; @@ -2152,10 +2159,43 @@ void IgramArea::loadOutlineFile(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 change the config value to match?\n" + "If no then the config value will be used instead."); + + QMessageBox mb; + mb.setText(QString().sprintf("Outline mask value of %6.1lf is differnt than config value of %6.1lf.", + edge, md.aperatureReduction) ); + mb.setInformativeText(text); + mb.setStandardButtons( QMessageBox::Yes|QMessageBox::No ); + mb.setWindowTitle(" Config difference."); + + 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); + } } - m_OutterP1 = m_outside.m_p1.m_p; - m_OutterP2 = m_outside.m_p2.m_p; - outterPcount = 2; + if (!igramGray.isNull()){ computeEdgeRadius(); drawBoundary(); @@ -2225,6 +2265,11 @@ void IgramArea::writeOutlines(QString fileName){ file << std::endl; } } + if (m_edgeMaskWidth != 0){ + mirrorDlg &md = *mirrorDlg::get_Instance(); + file << "\nEdge Mask width" << std::endl << md.aperatureReduction << std::endl; + } + file.flush(); file.close(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 93a2f4f9..4f125b3d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -62,17 +62,17 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); -qDebug() << "here"; -const QString toolButtonStyle("QToolButton {" - "border-style: outset;" - "border-width: 3px;" - "border-radius:7px;" - "border-color: darkgray;" - "font: bold 12px;" - "min-width: 10em;" - "padding: 6px;}" - "QToolButton:hover {background-color: lightblue;" - " }"); + + const QString toolButtonStyle("QToolButton {" + "border-style: outset;" + "border-width: 3px;" + "border-radius:7px;" + "border-color: darkgray;" + "font: bold 12px;" + "min-width: 10em;" + "padding: 6px;}" + "QToolButton:hover {background-color: lightblue;" + " }"); QWidget *rw = ui->toolBar->widgetForAction(ui->actionRead_WaveFront); //igramArea = new IgramArea(ui->tabWidget->widget(0)); diff --git a/mirrordlg.cpp b/mirrordlg.cpp index e540b692..01c302c4 100644 --- a/mirrordlg.cpp +++ b/mirrordlg.cpp @@ -44,6 +44,7 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->nullCB->setChecked(doNull); diameter = settings.value("config diameter", 200.).toDouble(); aperatureReduction = settings.value("config aperatureReduction", 0.).toDouble(); + m_aperatureReductionEnabled = settings.value("configAperatureReductionChecked",false).toBool(); roc = settings.value("config roc", 2000.).toDouble(); FNumber = roc/(2. * diameter); @@ -77,9 +78,9 @@ mirrorDlg::mirrorDlg(QWidget *parent) : cc = settings.value("config cc", -1.).toDouble(); ui->cc->setText(QString().sprintf("%6.2lf",cc)); - bool showEdgeMaskCtrls = settings.value("configAperatureReductionChecked",false).toBool(); - ui->ReducApp->setChecked(showEdgeMaskCtrls); - if (aperatureReduction > 0) + + ui->ReducApp->setChecked( m_aperatureReductionEnabled); + if ( m_aperatureReductionEnabled) ui->reduceValue->setEnabled(true); ui->reduceValue->setValue(aperatureReduction); @@ -109,8 +110,8 @@ mirrorDlg::mirrorDlg(QWidget *parent) : ui->cc->blockSignals(false); ui->unitsCB->blockSignals(false); ui->fringeSpacingEdit->blockSignals(false); - ui->ClearAp->setVisible(showEdgeMaskCtrls); - ui->clearApLabel->setVisible(showEdgeMaskCtrls); + ui->ClearAp->setVisible( m_aperatureReductionEnabled); + ui->clearApLabel->setVisible( m_aperatureReductionEnabled); m_aperatureReductionValueChanged = false; setclearAp(); } @@ -481,6 +482,7 @@ void mirrorDlg::on_unitsCB_clicked(bool checked) { mm = checked; double div = ((mm) ? 1: 25.4); + ui->roc->blockSignals(true); ui->diameter->blockSignals(true); ui->diameter->setText(QString().sprintf("%6.2lf",diameter/div)); @@ -493,6 +495,7 @@ void mirrorDlg::on_unitsCB_clicked(bool checked) ui->reduceValue->blockSignals(true); QSettings set; aperatureReduction = set.value("config aperatureReduction",0.).toDouble(); + ui->reduceValue->setValue(aperatureReduction * ((mm) ? 1. : 1./25.4)); ui->reduceValue->blockSignals(false); ui->ClearAp->setText(QString().sprintf("%6.2lf ", m_clearAperature * ((mm) ? 1: 1./25.4))); @@ -601,7 +604,7 @@ void mirrorDlg::setclearAp(){ void mirrorDlg::on_ReducApp_clicked(bool checked) { - + m_aperatureReductionEnabled = checked; ui->reduceValue->setEnabled(checked); ui->ClearAp->setVisible(checked); ui->clearApLabel->setVisible(checked); @@ -609,7 +612,7 @@ void mirrorDlg::on_ReducApp_clicked(bool checked) QSettings set; set.setValue("configAperatureReductionChecked", checked); if (!checked){ - aperatureReduction = 0.; + //aperatureReduction = 0.; } else { aperatureReduction = set.value("config aperatureReduction",0.).toDouble(); @@ -621,7 +624,13 @@ 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 99082a04..c586242f 100644 --- a/mirrordlg.h +++ b/mirrordlg.h @@ -64,7 +64,8 @@ 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(); From a7eb7101a3621b3d6102e2487e9bacaa85215d89 Mon Sep 17 00:00:00 2001 From: Dale Eason Date: Thu, 13 Jul 2023 13:26:07 -0500 Subject: [PATCH 3/3] updated text in mirror edge params warnings --- igramarea.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/igramarea.cpp b/igramarea.cpp index 4bba2ef8..068f54fd 100644 --- a/igramarea.cpp +++ b/igramarea.cpp @@ -2165,28 +2165,31 @@ void IgramArea::loadOutlineFile(QString fileName){ 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 change the config value to match?\n" - "If no then the config value will be used instead."); - - QMessageBox mb; - mb.setText(QString().sprintf("Outline mask value of %6.1lf is differnt than config value of %6.1lf.", - edge, md.aperatureReduction) ); - mb.setInformativeText(text); - mb.setStandardButtons( QMessageBox::Yes|QMessageBox::No ); - mb.setWindowTitle(" Config difference."); - + 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().sprintf("Edge mask value in outline file for this interferogram is %6.1lf and is different than mirror config value of %6.1lf.", + edge, md.aperatureReduction) ); + mb.setInformativeText(text); + mb.setStandardButtons( QMessageBox::Yes|QMessageBox::No ); + mb.setWindowTitle("Existing Interferogram outline file and Mirror Config difference."); + int width = QGuiApplication::screens()[0]->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); + case QMessageBox::Yes: + md.changeEdgeMaskvalues(edge); break; - case QMessageBox::No: - md.changeEdgeMaskvalues(md.aperatureReduction); - break; + case QMessageBox::No: + md.changeEdgeMaskvalues(md.aperatureReduction); + break; } }