void AdvancedDialog::LoadValues(void) { // Late-binding rebuild of all the panels if (m_rebuildPanels) RebuildPanels(); // Load all the current params m_pGlobalCtrlSet->LoadValues(); if (m_pCameraCtrlSet) m_pCameraCtrlSet->LoadValues(); if (m_pGuiderCtrlSet) m_pGuiderCtrlSet->LoadValues(); if (m_pRotatorCtrlSet) m_pRotatorCtrlSet->LoadValues(); // Mount sub-classes use a hybrid approach involving both CtrlSets and Panes if (TheAO()) { m_pAOCtrlSet->LoadValues(); } if (TheScope()) { m_pScopeCtrlSet->LoadValues(); m_pMountPane->LoadValues(); } if (s_selectedPage != -1) m_pNotebook->ChangeSelection(s_selectedPage); }
// CalSanity dialog may get launched as part of an 'alert' if the last calibration looked wonky - this one is non-modal CalSanityDialog::CalSanityDialog(wxFrame *parent, const Calibration& oldParams, const CalibrationDetails& oldDetails, CalibrationIssueType issue) { m_pScope = TheScope(); m_pScope->GetLastCalibration(&m_newParams); pMount->GetCalibrationDetails(&m_calDetails); m_oldParams = oldParams; m_oldDetails = oldDetails; m_issue = issue; m_childDialog = true; m_oldValid = oldParams.isValid; // All above data must be initialized before the UI can be built Create(parent, _("Calibration Sanity Check")); }
// Needed to handle reset if the camera binning changes on the fly void AdvancedDialog::ResetGuidingParams() { m_pMountPane->ResetRAGuidingParams(); m_pMountPane->ResetDecGuidingParams(); // No dialog active, so we need to make these changes take effect if (TheAO()) { m_pAOCtrlSet->UnloadValues(); } if (TheScope()) { m_pScopeCtrlSet->UnloadValues(); m_pMountPane->UnloadValues(); } }
bool MyFrame::FlipRACal() { bool bError = false; Mount *scope = TheScope(); if (scope) { bError = scope->FlipCalibration(); if (!bError) { EvtServer.NotifyCalibrationDataFlipped(scope); } } return bError; }
// ------------------- BacklashTool Implementation BacklashTool::BacklashTool() { m_scope = TheScope(); m_lastDecGuideRate = GetLastDecGuideRate(); // -1 if we aren't calibrated if (m_lastDecGuideRate > 0) m_bltState = BLT_STATE_INITIALIZE; else { m_bltState = BLT_STATE_ABORTED; m_lastStatus = _("Backlash measurement cannot be run - please re-run your mount calibration"); Debug.Write("BLT: Could not get calibration data\n"); } m_backlashResultPx = 0; m_backlashResultMs = 0; m_cumClearingDistance = 0; m_backlashExemption = false; }
// ------------------- BacklashTool Implementation BacklashTool::BacklashTool() { Calibration lastCalibration; m_scope = TheScope(); if (m_scope->GetLastCalibrationParams(&lastCalibration)) { m_lastDecGuideRate = lastCalibration.yRate; m_bltState = BLT_STATE_INITIALIZE; } else { m_bltState = BLT_STATE_ABORTED; m_lastStatus = _("Backlash measurement cannot be run - please re-run your mount calibration"); Debug.AddLine("BLT: Could not get calibration data"); } m_backlashResultPx = 0; m_backlashResultMs = 0; }
void AdvancedDialog::BuildCtrlSets() { m_pGlobalCtrlSet = m_pFrame->GetConfigDlgCtrlSet(m_pFrame, this, m_brainCtrls); if (pCamera) m_pCameraCtrlSet = pCamera->GetConfigDlgCtrlSet(m_pCameraSettingsPanel, pCamera, this, m_brainCtrls); else m_pCameraCtrlSet = NULL; m_pGuiderCtrlSet = m_pFrame->pGuider->GetConfigDialogCtrlSet(m_pGuiderSettingsPanel, m_pFrame->pGuider, this, m_brainCtrls); if (TheAO()) m_pAOCtrlSet = new AOConfigDialogCtrlSet(m_pDevicesSettingsPanel, pMount, this, m_brainCtrls); else m_pAOCtrlSet = NULL; if (pRotator) m_pRotatorCtrlSet = pRotator->GetConfigDlgCtrlSet(m_pDevicesSettingsPanel, pRotator, this, m_brainCtrls); else m_pRotatorCtrlSet = NULL; // Need a scope ctrl set even if pMount is null - it exports generic controls needed by other panes m_pScopeCtrlSet = new ScopeConfigDialogCtrlSet(m_pGuiderSettingsPanel, TheScope(), this, m_brainCtrls); }
void AdvancedDialog::UnloadValues(void) { // Unload all the current params m_pGlobalCtrlSet->UnloadValues(); if (m_pCameraCtrlSet) m_pCameraCtrlSet->UnloadValues(); if (m_pGuiderCtrlSet) m_pGuiderCtrlSet->UnloadValues(); if (m_pRotatorCtrlSet) m_pRotatorCtrlSet->UnloadValues(); // Mount sub-classes use a hybrid approach involving both CtrlSets and Panes if (TheAO()) { m_pAOCtrlSet->UnloadValues(); } if (TheScope()) { m_pScopeCtrlSet->UnloadValues(); m_pMountPane->UnloadValues(); } }
void MyFrame::OnEEGG(wxCommandEvent& evt) { if (evt.GetId() == EEGG_RESTORECAL || evt.GetId() == EEGG_REVIEWCAL) { wxString savedCal = pConfig->Profile.GetString("/scope/calibration/timestamp", wxEmptyString); if (savedCal.IsEmpty()) { wxMessageBox(_("There is no calibration data available.")); return; } if (!pMount) { wxMessageBox(_("Please connect a mount first.")); return; } if (evt.GetId() == EEGG_RESTORECAL) { CalRestoreDialog(this).ShowModal(); } else { if (pCalReviewDlg) // Review dialog is non-modal pCalReviewDlg->Destroy(); pCalReviewDlg = new CalReviewDialog(this); pCalReviewDlg->Show(); } } else if (evt.GetId() == EEGG_MANUALCAL) { if (pMount) { Calibration cal; cal.xRate = pMount->xRate(); cal.yRate = pMount->yRate(); cal.xAngle = pMount->xAngle(); cal.yAngle = pMount->yAngle(); cal.declination = pPointingSource->GetGuidingDeclination(); cal.pierSide = pPointingSource->SideOfPier(); cal.rotatorAngle = Rotator::RotatorPosition(); if (!pMount->IsCalibrated()) { cal.xRate = 1.0; cal.yRate = 1.0; cal.xAngle = 0.0; cal.yAngle = M_PI / 2.; cal.declination = 0.0; } ManualCalDialog manualcal(cal); if (manualcal.ShowModal () == wxID_OK) { manualcal.GetValues(&cal); pMount->SetCalibration(cal); } } } else if (evt.GetId() == EEGG_CLEARCAL) { wxString devicestr = ""; if (!(pGuider && pGuider->IsCalibratingOrGuiding())) if (pMount) { if (pMount->IsStepGuider()) devicestr = _("AO"); else devicestr = _("Mount"); } if (pSecondaryMount) { devicestr += _(", Mount"); } if (devicestr.Length() > 0) { if (wxMessageBox(wxString::Format(_("%s calibration will be cleared - calibration will be re-done when guiding is started."), devicestr), _("Clear Calibration"), wxOK | wxCANCEL) == wxOK) { if (pMount) pMount->ClearCalibration(); if (pSecondaryMount) pSecondaryMount->ClearCalibration(); Debug.AddLine("User cleared calibration on " + devicestr); } } } else if (evt.GetId() == EEGG_FLIPRACAL) { Mount *scope = TheScope(); if (scope) { double xorig = degrees(scope->xAngle()); double yorig = degrees(scope->yAngle()); Debug.AddLine("User-requested FlipRACal"); if (FlipRACal()) { wxMessageBox(_("Failed to flip RA calibration")); } else { double xnew = degrees(scope->xAngle()); double ynew = degrees(scope->yAngle()); wxMessageBox(wxString::Format(_("RA calibration angle flipped: (%.2f, %.2f) to (%.2f, %.2f)"), xorig, yorig, xnew, ynew)); } } } else if (evt.GetId() == EEGG_MANUALLOCK) { if (!pFrame->pNudgeLock) pFrame->pNudgeLock = NudgeLockTool::CreateNudgeLockToolWindow(); pFrame->pNudgeLock->Show(); } else if (evt.GetId() == EEGG_STICKY_LOCK) { bool sticky = evt.IsChecked(); pFrame->pGuider->SetLockPosIsSticky(sticky); pConfig->Global.SetBoolean("/StickyLockPosition", sticky); NudgeLockTool::UpdateNudgeLockControls(); } else { evt.Skip(); } }
void SBStateIndicatorItem::UpdateState() { int quadState = -1; bool cameraOk = true; bool problems = false; bool partials = false; wxString MIAs; switch (type) { case Field_Gear: if (pCamera && pCamera->Connected) { partials = true; } else { MIAs += _("Camera, "); cameraOk = false; problems = true; } if ((pMount && pMount->IsConnected()) || (pSecondaryMount && pSecondaryMount->IsConnected())) partials = true; else { MIAs += _("Mount, "); problems = true; } if (pPointingSource && pPointingSource->IsConnected()) partials = true; else { MIAs += _("Aux Mount, "); problems = true; } if (pMount && pMount->IsStepGuider()) { if (pMount->IsConnected()) partials = true; else { MIAs += _("AO, "); problems = true; } } if (pRotator) { if (pRotator->IsConnected()) partials = true; else { MIAs += _("Rotator, "); problems = true; } } if (partials) { if (!problems) { pic->SetIcon(wxIcon(container->icoGreenLed)); quadState = 1; otherInfo = ""; } else { if (cameraOk) pic->SetIcon(container->icoYellowLed); else pic->SetIcon(container->icoRedLed); // What good are we without a camera quadState = 0; otherInfo = MIAs.Mid(0, MIAs.Length() - 2); pic->SetToolTip(IndicatorToolTip(type, quadState)); } } else { pic->SetIcon(container->icoRedLed); quadState = -1; } break; case Field_Darks: if (pFrame) { if (pFrame->m_useDarksMenuItem->IsChecked() || pFrame->m_useDefectMapMenuItem->IsChecked()) { quadState = 1; wxString lastLabel = ctrl->GetLabelText(); wxString currLabel = (pFrame->m_useDefectMapMenuItem->IsChecked() ? _("BPM") : _("Dark")); if (lastLabel != currLabel) { ctrl->SetLabelText(currLabel); ctrl->SetToolTip(IndicatorToolTip(type, quadState)); } } } break; case Field_Calib: { // For calib: -1 => no cal, 0 => cal but no pointing compensation, 1 => golden bool calibrated = (!pMount || pMount->IsCalibrated()) && (!pSecondaryMount || pSecondaryMount->IsCalibrated()); if (calibrated) { Scope *scope = TheScope(); bool deccomp = scope && scope->DecCompensationActive(); quadState = deccomp ? 1 : 0; } break; } default: break; } // Don't flog the status icons unless something has changed if (lastState != quadState) { if (type != Field_Gear) { switch (quadState) { case -2: ctrl->SetForegroundColour(*wxLIGHT_GREY); break; case -1: ctrl->SetForegroundColour(*wxRED); break; case 0: ctrl->SetForegroundColour(*wxYELLOW); break; case 1: ctrl->SetForegroundColour(*wxGREEN); break; } ctrl->Refresh(); if (quadState != -2) ctrl->SetToolTip(IndicatorToolTip(type, quadState)); } else if (quadState != -2) { pic->SetToolTip(IndicatorToolTip(type, quadState)); } lastState = quadState; } }
void MyFrame::GuideButtonClick(bool interactive) { try { if (pMount == NULL) { // no mount selected -- should never happen throw ERROR_INFO("pMount == NULL"); } if (!pMount->IsConnected()) { throw ERROR_INFO("Unable to guide with no scope Connected"); } if (!pCamera || !pCamera->Connected) { throw ERROR_INFO("Unable to guide with no camera Connected"); } if (pGuider->GetState() < STATE_SELECTED) { wxMessageBox(_T("Please select a guide star before attempting to guide")); throw ERROR_INFO("Unable to guide with state < STATE_SELECTED"); } ValidateDarksLoaded(); if (wxGetKeyState(WXK_SHIFT)) { bool recalibrate = true; if (pMount->IsCalibrated() || (pSecondaryMount && pSecondaryMount->IsCalibrated())) { recalibrate = ConfirmDialog::Confirm(_("Are you sure you want force recalibration?"), "/force_recalibration_ok", _("Force Recalibration")); } if (recalibrate) { pMount->ClearCalibration(); if (pSecondaryMount) pSecondaryMount->ClearCalibration(); } } if (interactive && pPointingSource && pPointingSource->IsConnected() && pPointingSource->CanReportPosition()) { bool proceed = true; bool error = pPointingSource->PreparePositionInteractive(); if (!error && fabs(pPointingSource->GetDeclination()) > Scope::DEC_COMP_LIMIT && !TheScope()->IsCalibrated() ) { proceed = ConfirmDialog::Confirm( _("Calibration this far from the celestial equator will be error-prone. For best results, calibrate at a declination of -20 to +20."), "/highdec_calibration_ok", _("Confirm Calibration at Large Declination") ); } if (error || !proceed) return; } StartGuiding(); } catch (const wxString& Msg) { POSSIBLY_UNUSED(Msg); pGuider->Reset(false); } }