From b0406681c37458ea1c8adc318f259c989182f54d Mon Sep 17 00:00:00 2001 From: Bruce Waddington Date: Tue, 5 Nov 2024 18:31:19 -0800 Subject: [PATCH 1/5] Cleanup of MultiStar processing and UI if subframes enabled --- src/guider_multistar.cpp | 5 +++-- src/star.cpp | 36 +++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/guider_multistar.cpp b/src/guider_multistar.cpp index 075d2399a..a6a7b9684 100644 --- a/src/guider_multistar.cpp +++ b/src/guider_multistar.cpp @@ -466,7 +466,8 @@ bool GuiderMultiStar::AutoSelect(const wxRect& roi) edgeAllowance = wxMax(edgeAllowance, pSecondaryMount->CalibrationTotDistance()); GuideStar newStar; - if (!newStar.AutoFind(*image, edgeAllowance, m_searchRegion, roi, m_guideStars, MAX_LIST_SIZE)) + if (!newStar.AutoFind(*image, edgeAllowance, m_searchRegion, roi, m_guideStars, + (pCamera->UseSubframes || !m_multiStarMode) ? 1 : MAX_LIST_SIZE)) { throw ERROR_INFO("Unable to AutoFind"); } @@ -1213,7 +1214,7 @@ void GuiderMultiStar::OnPaint(wxPaintEvent& event) } // show in-use secondary stars - if (m_multiStarMode && m_guideStars.size() > 1) + if (m_multiStarMode && m_guideStars.size() > 1 && !pCamera->UseSubframes) { if (m_primaryStar.WasFound()) dc.SetPen(wxPen(wxColour(0, 255, 0), 1, wxPENSTYLE_SOLID)); diff --git a/src/star.cpp b/src/star.cpp index 7dc9275f8..472f1d967 100644 --- a/src/star.cpp +++ b/src/star.cpp @@ -1021,22 +1021,26 @@ bool GuideStar::AutoFind(const usImage& image, int extraEdgeAllowance, int searc double minSNR = pFrame->pGuider->GetAFMinStarSNR(); double maxHFD = pFrame->pGuider->GetMaxStarHFD(); foundStars.clear(); - for (std::set::reverse_iterator it = stars.rbegin(); it != stars.rend(); ++it) + if (maxStars > 1) { - GuideStar tmp; - tmp.Find(&image, searchRegion, it->x, it->y, FIND_CENTROID, pFrame->pGuider->GetMinStarHFD(), maxHFD, - pCamera->GetSaturationADU(), FIND_LOGGING_VERBOSE); - // We're repeating the find, so we're vulnerable to hot pixels and creation of unwanted duplicates - if (tmp.WasFound() && tmp.SNR >= minSNR) + for (std::set::reverse_iterator it = stars.rbegin(); it != stars.rend(); ++it) { - bool duplicate = std::find_if(foundStars.begin(), foundStars.end(), [&tmp](const GuideStar& other) - { return CloseToReference(tmp, other); }) != foundStars.end(); - - if (!duplicate) + GuideStar tmp; + tmp.Find(&image, searchRegion, it->x, it->y, FIND_CENTROID, pFrame->pGuider->GetMinStarHFD(), maxHFD, + pCamera->GetSaturationADU(), FIND_LOGGING_VERBOSE); + // We're repeating the find, so we're vulnerable to hot pixels and creation of unwanted duplicates + if (tmp.WasFound() && tmp.SNR >= minSNR) { - tmp.referencePoint.X = tmp.X; - tmp.referencePoint.Y = tmp.Y; - foundStars.push_back(tmp); + bool duplicate = + std::find_if(foundStars.begin(), foundStars.end(), + [&tmp](const GuideStar& other) { return CloseToReference(tmp, other); }) != foundStars.end(); + + if (!duplicate) + { + tmp.referencePoint.X = tmp.X; + tmp.referencePoint.Y = tmp.Y; + foundStars.push_back(tmp); + } } } } @@ -1118,6 +1122,12 @@ bool GuideStar::AutoFind(const usImage& image, int extraEdgeAllowance, int searc Debug.Write("MultiStar: primary star forcibly inserted in list\n"); } } + else + { + tmp.referencePoint.X = tmp.X; + tmp.referencePoint.Y = tmp.Y; + foundStars.push_back(tmp); + } return true; } } From 0017d773dc05cbca0ca233fb2c58b3c74e636a44 Mon Sep 17 00:00:00 2001 From: Bruce Waddington Date: Sat, 9 Nov 2024 09:58:07 -0800 Subject: [PATCH 2/5] Force rebuild of MultiStar list when subframes are disabled --- src/camera.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/camera.cpp b/src/camera.cpp index 6931eaa41..16061c4f5 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -1185,8 +1185,14 @@ void CameraConfigDialogCtrlSet::UnloadValues() if (m_pCamera->HasSubframes) { - m_pCamera->UseSubframes = m_pUseSubframes->GetValue(); - pConfig->Profile.SetBoolean("/camera/UseSubframes", m_pCamera->UseSubframes); + bool oldVal = m_pCamera->UseSubframes; + bool newVal = m_pUseSubframes->GetValue(); + m_pCamera->UseSubframes = newVal; + pConfig->Profile.SetBoolean("/camera/UseSubframes", newVal); + // MultiStar can't track secondary star locations during periods when subframes are used + if (oldVal && !newVal) + if (pFrame->pGuider->GetMultiStarMode()) + pFrame->pGuider->SetMultiStarMode(true); // Will force a refresh of secondary stars } if (m_pCamera->HasGainControl) From e06b0631e7506d729a2ac8ba8136ceb043247331 Mon Sep 17 00:00:00 2001 From: Bruce Waddington Date: Tue, 26 Nov 2024 20:17:07 -0800 Subject: [PATCH 3/5] Add PercentChange() function in AD; avoid clearing calibration for minor changes in pixel size or focal length --- src/advanced_dialog.cpp | 15 +++++++++++++++ src/advanced_dialog.h | 1 + src/camera.cpp | 5 ++++- src/myframe.cpp | 5 +++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/advanced_dialog.cpp b/src/advanced_dialog.cpp index 34878fba1..27f6ae40a 100644 --- a/src/advanced_dialog.cpp +++ b/src/advanced_dialog.cpp @@ -592,6 +592,21 @@ double AdvancedDialog::DetermineGuideSpeed() } return sidRate; } + +// Floating point equality comparisons can be a problem due to rounding and trivial inequalities. +// PercentChange can be used to see if a change is worth reacting to +double AdvancedDialog::PercentChange(double oldVal, double newVal) +{ + double chg; + if (oldVal > 0) + { + chg = fabs(1.0 - newVal / oldVal); + } + else + chg = fabs(newVal); + return 100.0 * chg; +} + // Reacts to param changes in the AD that change the image scale. Calibration step-size is recalculated, calibration is // cleared, MinMoves are set to defaults based on new image scale void AdvancedDialog::MakeImageScaleAdjustments() diff --git a/src/advanced_dialog.h b/src/advanced_dialog.h index 18fae66eb..2affbfaa1 100644 --- a/src/advanced_dialog.h +++ b/src/advanced_dialog.h @@ -103,6 +103,7 @@ class AdvancedDialog : public wxDialog bool Validate() override; void ShowInvalid(wxWindow *ctrl, const wxString& message); + double PercentChange(double oldVal, double newVal); void FlagImageScaleChange() { m_imageScaleChanged = true; diff --git a/src/camera.cpp b/src/camera.cpp index 16061c4f5..5948df1da 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -1247,7 +1247,10 @@ void CameraConfigDialogCtrlSet::UnloadValues() double oldPxSz = m_pCamera->GetCameraPixelSize(); double newPxSz = m_pPixelSize->GetValue(); - if (oldPxSz != newPxSz) + if (oldPxSz != newPxSz && + pFrame->pAdvancedDialog->PercentChange(oldPxSz, newPxSz) > + 5.0) // Avoid rounding problems with floating point equality test; don't clear + // calibration for inconsequential changes pFrame->pAdvancedDialog->FlagImageScaleChange(); m_pCamera->SetCameraPixelSize(m_pPixelSize->GetValue()); diff --git a/src/myframe.cpp b/src/myframe.cpp index e926e5fd0..955dc2af5 100644 --- a/src/myframe.cpp +++ b/src/myframe.cpp @@ -3327,8 +3327,9 @@ void MyFrameConfigDialogCtrlSet::UnloadValues() m_varExpDelayLong->GetValue() * 1000); int oldFL = m_pFrame->GetFocalLength(); int newFL = GetFocalLength(); // From UI control - if (oldFL != newFL) // Validator insures fl is generally reasonable and non-zero - m_pFrame->pAdvancedDialog->FlagImageScaleChange(); + if (oldFL != newFL) // Validator insures fl is generally reasonable and non-zero; don't react to trivial changes + if (m_pFrame->pAdvancedDialog->PercentChange(oldFL, newFL) > 5.0) + m_pFrame->pAdvancedDialog->FlagImageScaleChange(); m_pFrame->SetFocalLength(GetFocalLength()); int idx = m_pLanguage->GetSelection(); From e480b74a867613670e27dd02013336ed9400a81b Mon Sep 17 00:00:00 2001 From: Bruce Waddington Date: Fri, 29 Nov 2024 18:51:09 -0800 Subject: [PATCH 4/5] Format change to correct clang problem on server --- src/star.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/star.cpp b/src/star.cpp index 472f1d967..d7aa5bec5 100644 --- a/src/star.cpp +++ b/src/star.cpp @@ -1031,9 +1031,8 @@ bool GuideStar::AutoFind(const usImage& image, int extraEdgeAllowance, int searc // We're repeating the find, so we're vulnerable to hot pixels and creation of unwanted duplicates if (tmp.WasFound() && tmp.SNR >= minSNR) { - bool duplicate = - std::find_if(foundStars.begin(), foundStars.end(), - [&tmp](const GuideStar& other) { return CloseToReference(tmp, other); }) != foundStars.end(); + bool duplicate = std::find_if(foundStars.begin(), foundStars.end(), [&tmp](const GuideStar& other) + { return CloseToReference(tmp, other); }) != foundStars.end(); if (!duplicate) { From 91ea2e0528d7953c2c609ddc030b842b605e84b5 Mon Sep 17 00:00:00 2001 From: Bruce Waddington Date: Sat, 30 Nov 2024 19:32:36 -0800 Subject: [PATCH 5/5] Corrections from PR. --- src/advanced_dialog.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/advanced_dialog.cpp b/src/advanced_dialog.cpp index 27f6ae40a..2e2c54d96 100644 --- a/src/advanced_dialog.cpp +++ b/src/advanced_dialog.cpp @@ -598,13 +598,12 @@ double AdvancedDialog::DetermineGuideSpeed() double AdvancedDialog::PercentChange(double oldVal, double newVal) { double chg; - if (oldVal > 0) + if (fabs(oldVal) < 0.0001) { - chg = fabs(1.0 - newVal / oldVal); + return 100. * newVal; // not meaningful, but avoids divide by zero } else - chg = fabs(newVal); - return 100.0 * chg; + return 100. * fabs(1. - newVal / oldVal); } // Reacts to param changes in the AD that change the image scale. Calibration step-size is recalculated, calibration is