Skip to content
Merged
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
3 changes: 2 additions & 1 deletion averagewavefrontfilesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ void averageWaveFrontFilesDlg::on_process_clicked()
ui->progressBar->setValue(0);
ui->progressBar->setFormat("Done");

emit averageComplete( average );
if (average)
emit averageComplete( average );
}
if (rejects.size() > 0){
rejectedWavefrontsDlg dlg(rejects);
Expand Down
4 changes: 2 additions & 2 deletions dftarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ void DFTArea::makeSurface(){
showData("result surface", result.clone());
}

emit newWavefront(result, m_outside, m_center, QFileInfo(igramArea->m_filename).baseName(),
emit newWavefront(result, m_outside, m_center, QFileInfo(igramArea->m_filename).baseName(), WavefrontOrigin::Igram,
m_poly);
QApplication::restoreOverrideCursor();
success = true;
Expand Down Expand Up @@ -1514,7 +1514,7 @@ qDebug() << "rec" << left << top << width << height;
m_center.m_center.rx() = (result.cols-1) - m_center.m_center.x();
}
QString wfname = QString("PSI")+ finfo.baseName() + QString("-") + QFileInfo(m_psiFiles[imagecount-1]).baseName();
emit newWavefront(result, m_outside, m_center, wfname, m_poly);
emit newWavefront(result, m_outside, m_center, wfname, WavefrontOrigin::Igram, m_poly);
QApplication::restoreOverrideCursor();
}

Expand Down
3 changes: 2 additions & 1 deletion dftarea.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <string>
#include "psi_dlg.h"
#include "psiphasedisplay.h"
#include "wavefront.h"

extern void showData(const std::string& txt, const cv::Mat &mat, bool useLog = false);
extern QImage showMag(const cv::Mat &complexI, bool show = false, const char *title = "FFT", bool doLog = true, double gamma = 0);
Expand Down Expand Up @@ -87,7 +88,7 @@ public slots:
void setDftSizeVal(int);
void selectDFTTab();
void updateFilterSize(int);
void newWavefront(cv::Mat, CircleOutline, CircleOutline, const QString &,
void newWavefront(cv::Mat, CircleOutline, CircleOutline, const QString &, WavefrontOrigin origin,
QVector<std::vector<cv::Point> >);
void dftReady(QImage);
void statusBarUpdate(QString, int);
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ void MainWindow::on_actionWavefront_triggered()
m_surfaceManager->createSurfaceFromPhaseMap(result,
CircleOutline(QPointF(xcen,ycen),rad),
CircleOutline(QPointF(0,0),0),
QString("Simulated_Wavefront"));
QString("Simulated_Wavefront"), WavefrontOrigin::Simulation);
}

void MainWindow::on_actionIgram_triggered()
Expand Down
28 changes: 21 additions & 7 deletions surfacemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,14 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){

mirrorDlg *md = mirrorDlg::get_Instance();
zp.unwrap_to_zernikes(*wf);
// check for swapped conic value
if (!m_ignoreInverse)

//
// AUTO INVERT CODE STARTS HERE
//

if (!m_ignoreInverse &&
wf->m_manuallyInverted == false && // don't auto-invert if user already manually inverted
wf->m_origin == WavefrontOrigin::Igram) // only auto-invert if wavefront created from processed igram
{
if (m_inverseMode==invNOTSET)
{
Expand Down Expand Up @@ -413,6 +419,9 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){
}
}

//
// AUTO INVERT CODE ENDS HERE/
//

((MainWindow*)parent())-> zernTablemodel->setValues(wf->InputZerns, !wf->useSANull);
((MainWindow*)parent())-> zernTablemodel->update();
Expand Down Expand Up @@ -806,7 +815,7 @@ void SurfaceManager::useDemoWaveFront(){
createSurfaceFromPhaseMap(result,
CircleOutline(QPointF(xcen,ycen),rad),
CircleOutline(QPointF(0,0),0),
QString("Demo"));
QString("Demo"), WavefrontOrigin::Demo);
}

void SurfaceManager::waveFrontClickedSlot(int ndx)
Expand Down Expand Up @@ -1062,7 +1071,8 @@ void SurfaceManager::SaveWavefronts(bool saveNulled){
}
void SurfaceManager::createSurfaceFromPhaseMap(cv::Mat phase, CircleOutline outside,
CircleOutline center,
const QString &name, QVector<std::vector<cv::Point> > polyArea){
const QString &name, WavefrontOrigin origin,
QVector<std::vector<cv::Point> > polyArea){

wavefront *wf;

Expand Down Expand Up @@ -1100,6 +1110,7 @@ void SurfaceManager::createSurfaceFromPhaseMap(cv::Mat phase, CircleOutline outs
m_surfaceTools->addWaveFront(wf->name);
m_currentNdx = m_wavefronts.size()-1;
}
wf->m_origin = origin;
wf->m_outside = outside;
wf->m_inside = center;
wf->data = phase;
Expand Down Expand Up @@ -1129,6 +1140,7 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){
}
spdlog::get("logger")->trace("readWaveFront() step 1");
wavefront *wf = new wavefront();
wf->m_origin = WavefrontOrigin::File;
double width;
double height;
file >> width;
Expand Down Expand Up @@ -1634,6 +1646,7 @@ void SurfaceManager::average(QList<wavefront *> wfList){
wf->data = sum.clone();
wf->mask = mask;
wf->workMask = mask.clone();
wf->m_origin = WavefrontOrigin::Average;
m_wavefronts << wf;
wf->wasSmoothed = false;
wf->name = "Average.wft";
Expand All @@ -1658,6 +1671,7 @@ void SurfaceManager::averageComplete(wavefront *wf){
wf->wasSmoothed = false;
wf->name = "Average.wft";
wf->dirtyZerns = true;
wf->m_origin = WavefrontOrigin::Average;
m_surfaceTools->addWaveFront(wf->name);
m_currentNdx = m_wavefronts.size()-1;
//makeMask(m_currentNdx);
Expand Down Expand Up @@ -1726,7 +1740,7 @@ void SurfaceManager::rotateThese(double angle, QList<int> list){
QStringList l = oldWf->name.split('.');
QString newName = QString("%1_%2%3.wft").arg(l[0]).arg((angle >= 0) ? "CW":"CCW").arg(fabs(angle), 5, 'f', 1, QLatin1Char('0')); // clazy:exclude=qstring-arg
wavefront *wf = new wavefront();
*wf = *oldWf; // copy everything to new wavefront including basic things like diameter,wavelength
*wf = *oldWf; // copy everything to new wavefront including basic things like diameter,wavelength,origin
//emit nameChanged(wf->name, newName);

wf->name = newName;
Expand Down Expand Up @@ -1802,6 +1816,7 @@ void SurfaceManager::subtract(wavefront *wf1, wavefront *wf2, bool use_null){
resultwf->data = result.clone();
resultwf->mask = mask.clone();
resultwf->workMask = mask.clone();
resultwf->m_origin = WavefrontOrigin::Subtraction;
m_wavefronts << resultwf;
m_currentNdx = m_wavefronts.size() -1;

Expand Down Expand Up @@ -1861,8 +1876,7 @@ void SurfaceManager::invert(QList<int> list){
m_wavefronts[list[i]]->data *= -1;
m_wavefronts[list[i]]->dirtyZerns = true;
m_wavefronts[list[i]]->wasSmoothed = false;
m_ignoreInverse = true;

m_wavefronts[list[i]]->m_manuallyInverted = true;
}
m_waveFrontTimer->start(500);
}
Expand Down
2 changes: 1 addition & 1 deletion surfacemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private slots:
public slots:
void rotateThese(double angle, QList<int> list);
void createSurfaceFromPhaseMap(cv::Mat phase, CircleOutline outside,
CircleOutline center, const QString &name,
CircleOutline center, const QString &name, WavefrontOrigin origin,
QVector<std::vector<cv::Point> > polyArea= QVector<std::vector<cv::Point> >());
void invert(QList<int> list);
void wftNameChanged(int, const QString&);
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),dirtyZerns(true),regions_have_been_expanded(false)
gaussian_diameter(0.),useSANull(true),m_origin(WavefrontOrigin::Unknown),m_manuallyInverted(false),dirtyZerns(true),regions_have_been_expanded(false)
{
}

Expand All @@ -44,6 +44,8 @@ wavefront::wavefront( const wavefront &wf):
wasSmoothed(wf.wasSmoothed),
useSANull(wf.useSANull),
GBSmoothingValue(wf.GBSmoothingValue),
m_origin(wf.m_origin),
m_manuallyInverted(wf.m_manuallyInverted),
lambda(wf.lambda),
m_outside(wf.m_outside),
m_inside(wf.m_inside),
Expand Down
14 changes: 14 additions & 0 deletions wavefront.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
#include <opencv2/opencv.hpp>
#include "Circleoutline.h"
#include <QPointF>

enum class WavefrontOrigin : std::uint8_t {
Unknown = 0,
Igram,
File,
Simulation,
Demo,
Average,
Subtraction,
Zernikes,
Smoothed
};
class wavefront
{
public:
Expand All @@ -40,6 +52,8 @@ class wavefront
bool wasSmoothed;
bool useSANull;
double GBSmoothingValue;
WavefrontOrigin m_origin;
bool m_manuallyInverted; // true if user inverted this wavefront

QString name;
double lambda;
Expand Down
2 changes: 1 addition & 1 deletion zernikeeditdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void zernikeEditDlg::on_createSurface_clicked()

m_sm->createSurfaceFromPhaseMap(result, CircleOutline(QPointF(xcen,ycen),rad),
CircleOutline(QPointF(0,0),0),
QString("Zernike_Wavefront"));
QString("Zernike_Wavefront"), WavefrontOrigin::Zernikes);
}

void zernikeEditDlg::on_clearAll_clicked()
Expand Down
3 changes: 1 addition & 2 deletions zernikesmoothingdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ void ZernikeSmoothingDlg::on_createWaveFront_clicked()
l.back().append(QString("_sm%1").arg(m_noOfTerms));

m_sm->createSurfaceFromPhaseMap(result, m_wf.m_outside, m_wf.m_inside

,l.back());
,l.back(), WavefrontOrigin::Smoothed);

if (ui->showResidual->isChecked()){
m_sm->subtract(&m_wf, m_sm->m_wavefronts.back(), false);
Expand Down
Loading