diff --git a/surfacemanager.cpp b/surfacemanager.cpp
index 2ab2fae6..5cad0345 100644
--- a/surfacemanager.cpp
+++ b/surfacemanager.cpp
@@ -350,6 +350,11 @@ void SurfaceManager::generateSurfacefromWavefront(int wavefrontNdx) {
void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){
zernikeProcess &zp = *zernikeProcess::get_Instance();
+ if (wf->zernEnablesApplied.empty()) {
+ wf->zernEnablesApplied = zernEnables;
+ } else if (wf->zernEnablesApplied.size() != zernEnables.size()) {
+ wf->zernEnablesApplied.resize(zernEnables.size(), true);
+ }
m_GB_enabled = wf->gbEnabled;
m_gbValue = wf->gbValue;
if (wf->dirtyZerns){
@@ -426,6 +431,7 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){
// AUTO INVERT CODE ENDS HERE/
//
+ ((MainWindow*)parent())-> zernTablemodel->setAppliedEnables(&wf->zernEnablesApplied);
((MainWindow*)parent())-> zernTablemodel->setValues(wf->InputZerns, !wf->useSANull);
((MainWindow*)parent())-> zernTablemodel->update();
// fill in void from obstruction of igram.
@@ -435,7 +441,7 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){
//cv::Mat tiltremoved = zp.null_unwrapped(*wf, wf->InputZerns, zernEnables, 0,3);
//wf->data = tiltremoved;
//zp.unwrap_to_zernikes(*wf);
- wf->nulledData = zp.null_unwrapped(*wf, wf->InputZerns, zernEnables,0,Z_TERMS );
+ wf->nulledData = zp.null_unwrapped(*wf, wf->InputZerns, wf->zernEnablesApplied,0,Z_TERMS );
wf->dirtyZerns = false;
}
@@ -464,10 +470,14 @@ void SurfaceManager::generateSurfacefromWavefront(wavefront * wf){
wf->nulledData.release();
}
cv::Mat SurfaceManager::computeWaveFrontFromZernikes(int wx, int wy, std::vector &zerns, QVector zernsToUse){
- double rad = getCurrent()->m_outside.m_radius;
- double xcen = (wx-1)/2, ycen = (wy-1)/2;
-
+ wavefront *currentWf = getCurrent();
cv::Mat result = cv::Mat::zeros(wy,wx, numType);
+ if (currentWf == nullptr) {
+ return result;
+ }
+
+ double rad = currentWf->m_outside.m_radius;
+ double xcen = (wx-1)/2, ycen = (wy-1)/2;
double rho;
@@ -476,9 +486,7 @@ cv::Mat SurfaceManager::computeWaveFrontFromZernikes(int wx, int wy, std::vector
if (value > maxZernToUse)
maxZernToUse = value;
}
-
-
- std::vector &en = zernEnables;
+ std::vector &en = (currentWf->zernEnablesApplied.empty()) ? zernEnables : currentWf->zernEnablesApplied;
mirrorDlg *md = mirrorDlg::get_Instance();
for (int i = 0; i < wx; ++i)
{
@@ -538,7 +546,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_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_wftStats(0)
+ m_inverseMode(invNOTSET),m_ignoreInverse(false), m_standAstigWizard(nullptr), workToDo(0), m_applyFloatingZernEnables(false), m_wftStats(0)
{
okToUpdateSurfacesOnGenerateComplete = true;
@@ -923,7 +931,7 @@ void SurfaceManager::computeMetrics(wavefront *wf){
wf->min = mmin * md->lambda/outputLambda;
wf->max = mmax * md->lambda/outputLambda;
-
+ ((MainWindow*)parent())->zernTablemodel->setAppliedEnables(&wf->zernEnablesApplied);
((MainWindow*)(parent()))->zernTablemodel->setValues(wf->InputZerns, !wf->useSANull);
((MainWindow*)parent())-> zernTablemodel->update();
((MainWindow*)(parent()))->updateMetrics(*wf);
@@ -960,6 +968,7 @@ void SurfaceManager::computeZerns()
{
QList doThese = m_surfaceTools->SelectedWaveFronts();
workToDo = doThese.size();
+ m_applyFloatingZernEnables = !doThese.isEmpty();
mirrorDlg &md = *mirrorDlg::get_Instance();
foreach(int ndx , doThese){
wavefront &wf = *m_wavefronts[ndx];
@@ -1143,6 +1152,7 @@ void SurfaceManager::createSurfaceFromPhaseMap(cv::Mat phase, CircleOutline outs
wf->diameter = md->diameter;
wf->lambda = md->lambda;
wf->roc = md->roc;
+ wf->zernEnablesApplied = zernEnables;
wf->gbEnabled = m_GB_enabled;
wf->gbValue = m_gbValue;
wf->dirtyZerns = true;
@@ -1435,6 +1445,7 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){
wf->diameter = diam;
wf->roc = roc;
wf->lambda = lambda;
+ wf->zernEnablesApplied = zernEnables;
wf->gbEnabled = m_GB_enabled;
wf->gbValue = m_gbValue;
wf->wasSmoothed = false;
@@ -1637,7 +1648,12 @@ void SurfaceManager::backGroundUpdate(){
workToDo = doThese.size();
pd->setLabelText("Updating Selected Surfaces");
pd->setRange(0,doThese.size());
+ const bool applyFloatingZerns = m_applyFloatingZernEnables;
+ m_applyFloatingZernEnables = false;
foreach (int i, doThese){
+ if (applyFloatingZerns) {
+ m_wavefronts[i]->zernEnablesApplied = zernEnables;
+ }
m_wavefronts[i]->dirtyZerns = true;
m_wavefronts[i]->wasSmoothed = false;
makeMask(i);
@@ -3065,7 +3081,10 @@ void SurfaceManager::report(){
int half = Z_TERMS/2 +2;
for (int i = 3; i < half; ++i){
double val = wf->InputZerns[i];
- bool enabled = zernEnables[i];
+ bool enabled = true;
+ if (static_cast(i) < wf->zernEnablesApplied.size()) {
+ enabled = wf->zernEnablesApplied[i];
+ }
if ( i == 3 && m_surfaceTools->m_useDefocus){
val = m_surfaceTools->m_defocus;
enabled = true;
@@ -3099,9 +3118,13 @@ void SurfaceManager::report(){
for (int i = half; i < Z_TERMS; ++i){
double val = wf->InputZerns[i];
+ bool enabled = true;
+ if (static_cast(i) < wf->zernEnablesApplied.size()) {
+ enabled = wf->zernEnablesApplied[i];
+ }
zerns.append("| " + QString(zernsNames[i]) + " | ").arg(
val, 6, 'f', 3).arg(computeRMS(i,val), 6, 'f', 3) + " | " +
- QString((zernEnables[i]) ? QString("") : QString("Disabled")) + " |
");
+ QString((enabled) ? QString("") : QString("Disabled")) + "");
}
zerns.append("
");
diff --git a/surfacemanager.h b/surfacemanager.h
index 16ce5d87..297a7054 100644
--- a/surfacemanager.h
+++ b/surfacemanager.h
@@ -132,6 +132,7 @@ class SurfaceManager : public QObject
QPointer m_standAstigWizard;
int workToDo;
int workProgress;
+ bool m_applyFloatingZernEnables;
wftStats *m_wftStats;
diff --git a/wavefront.cpp b/wavefront.cpp
index 7862a6a5..b62cf757 100644
--- a/wavefront.cpp
+++ b/wavefront.cpp
@@ -18,7 +18,7 @@
#include "wavefront.h"
wavefront::wavefront():
- 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)
+ zernEnablesApplied(),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)
{
}
@@ -40,6 +40,7 @@ wavefront::wavefront( const wavefront &wf):
workData(wf.workData.clone()),
workMask(wf.workMask.clone()),
InputZerns(wf.InputZerns),
+ zernEnablesApplied(wf.zernEnablesApplied),
gaussian_diameter(wf.gaussian_diameter),
gbEnabled(wf.gbEnabled),
gbValue(wf.gbValue),
diff --git a/wavefront.h b/wavefront.h
index 00a04b73..e35c088a 100644
--- a/wavefront.h
+++ b/wavefront.h
@@ -48,6 +48,7 @@ class wavefront
cv::Mat_ workData;
cv::Mat_ workMask;
std::vector InputZerns;
+ std::vector zernEnablesApplied;
double gaussian_diameter;
bool gbEnabled;
double gbValue;
diff --git a/zernikedlg.cpp b/zernikedlg.cpp
index b95416b4..1c540f97 100644
--- a/zernikedlg.cpp
+++ b/zernikedlg.cpp
@@ -30,7 +30,7 @@
// Zernike_terms message handlers
ZernTableModel::ZernTableModel(QObject *parent, std::vector *enables, bool editEnable)
- :QAbstractTableModel(parent), m_enables(enables),canEdit(editEnable), m_nulled(false)
+ :QAbstractTableModel(parent), m_enables(enables),canEdit(editEnable), m_nulled(false), m_appliedEnables(nullptr)
{
zernikeProcess &zp = *zernikeProcess::get_Instance();
values = std::vector(zp.m_norms.size(), 0.);
@@ -48,6 +48,11 @@ void ZernTableModel::setValues(const std::vector &vals, bool nulled){
emit dataChanged(topLeft, bottomRight);
}
+void ZernTableModel::setAppliedEnables(const std::vector *appliedEnables){
+ m_appliedEnables = appliedEnables;
+ update();
+}
+
void ZernTableModel::update(){
QModelIndex topLeft = index(0, 0);
QModelIndex bottomRight = index(rowCount() - 1, columnCount() - 1);
@@ -103,13 +108,25 @@ QVariant ZernTableModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole)
{
if (index.column() == 0){
+ QString marker;
+ if (m_appliedEnables != nullptr &&
+ index.row() < (int)m_appliedEnables->size() &&
+ index.row() < (int)m_enables->size()) {
+ const bool floatingEnabled = m_enables->at(index.row());
+ const bool appliedEnabled = m_appliedEnables->at(index.row());
+ if (floatingEnabled && !appliedEnabled) {
+ marker = "[+] ";
+ } else if (!floatingEnabled && appliedEnabled) {
+ marker = "[-] ";
+ }
+ }
if (index.row() <= 48)
- return zernsNames[index.row()];
+ return marker + zernsNames[index.row()];
else {
int row = index.row();
int sr = floor(sqrt(row+1));
- return (QString("%1 %2").arg(index.row()).arg(
+ return marker + (QString("%1 %2").arg(index.row()).arg(
( sr * sr == index.row()+1)? "Spherical" : ""));
}
}
@@ -137,6 +154,18 @@ QVariant ZernTableModel::data(const QModelIndex &index, int role) const
return m_enables->at(index.row()) ? Qt::Checked : Qt::Unchecked;
}
}
+ if (role == Qt::ToolTipRole && index.column() == 0 && m_appliedEnables != nullptr &&
+ index.row() < (int)m_appliedEnables->size() && index.row() < (int)m_enables->size()) {
+ const bool floatingEnabled = m_enables->at(index.row());
+ const bool appliedEnabled = m_appliedEnables->at(index.row());
+ if (floatingEnabled && !appliedEnabled) {
+ return QString("Will be enabled on recompute for this wavefront.");
+ }
+ if (!floatingEnabled && appliedEnabled) {
+ return QString("Will be disabled on recompute for this wavefront.");
+ }
+ return QString("No change for this wavefront on recompute.");
+ }
return QVariant();
}
bool ZernTableModel::setData(const QModelIndex & index, const QVariant & value, int role)
@@ -152,6 +181,7 @@ bool ZernTableModel::setData(const QModelIndex & index, const QVariant & value,
if (role == Qt::CheckStateRole){
m_enables->at(index.row()) = value.toBool();
}
+ emit dataChanged(this->index(index.row(), 0), this->index(index.row(), 1));
return true;
}
diff --git a/zernikedlg.h b/zernikedlg.h
index c636aa21..029d7871 100644
--- a/zernikedlg.h
+++ b/zernikedlg.h
@@ -44,6 +44,7 @@ class ZernTableModel : public QAbstractTableModel
void resizeRows(const int rowCnt);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
void setValues(const std::vector &vals, bool nulled);
+ void setAppliedEnables(const std::vector *appliedEnables);
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex & index) const ;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
@@ -56,6 +57,7 @@ class ZernTableModel : public QAbstractTableModel
private:
bool canEdit;
bool m_nulled;
+ const std::vector *m_appliedEnables;
};