Skip to content

Commit

Permalink
Image scale change improvements (OpenPHDGuiding#1260)
Browse files Browse the repository at this point in the history
* Cleanup of MultiStar processing and UI if subframes enabled

* Force rebuild of MultiStar list when subframes are disabled

* Add PercentChange() function in AD; avoid clearing calibration for minor changes in pixel size or focal length

* Format change to correct clang problem on server

* Corrections from PR.
  • Loading branch information
bwdev01 authored Dec 1, 2024
1 parent 8b85e2b commit 08cc798
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/advanced_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,20 @@ 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 (fabs(oldVal) < 0.0001)
{
return 100. * newVal; // not meaningful, but avoids divide by zero
}
else
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
// cleared, MinMoves are set to defaults based on new image scale
void AdvancedDialog::MakeImageScaleAdjustments()
Expand Down
1 change: 1 addition & 0 deletions src/advanced_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
5 changes: 3 additions & 2 deletions src/myframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 08cc798

Please sign in to comment.