7#include "focusadvisor.h"
9#include "focusalgorithms.h"
11#include "ekos/auxiliary/opticaltrainmanager.h"
12#include "ekos/auxiliary/opticaltrainsettings.h"
13#include "ekos/auxiliary/stellarsolverprofile.h"
20const char * FOCUSER_SIMULATOR =
"Focuser Simulator";
21const int MAXIMUM_FOCUS_ADVISOR_ITERATIONS = 1001;
22const int NUM_JUMPS_PER_SECTOR = 10;
23const int FIND_STARS_MIN_STARS = 2;
24const double TARGET_MAXMIN_HFR_RATIO = 3.0;
25const double INITIAL_MAXMIN_HFR_RATIO = 2.0;
26const int NUM_STEPS_PRE_AF = 11;
35 m_focus =
static_cast<Focus *
>(parent);
41FocusAdvisor::~FocusAdvisor()
45void FocusAdvisor::processUI()
48 m_helpDialog =
new QDialog(
this);
49 m_helpUI.reset(
new Ui::focusAdvisorHelpDialog());
50 m_helpUI->setupUi(m_helpDialog);
60 m_runButton->setToolTip(
"Run Focus Advisor");
61 m_stopButton->setToolTip(
"Stop Focus Advisor");
62 m_helpButton->setToolTip(
"List parameter settings");
76void FocusAdvisor::setupResultsTable()
78 focusAdvTable->setColumnCount(RESULTS_MAX_COLS);
79 focusAdvTable->setRowCount(0);
83 focusAdvTable->setHorizontalHeaderItem(RESULTS_SECTION, itemSection);
87 focusAdvTable->setHorizontalHeaderItem(RESULTS_RUN_NUMBER, itemRunNumber);
91 focusAdvTable->setHorizontalHeaderItem(RESULTS_START_POSITION, itemStartPosition);
95 focusAdvTable->setHorizontalHeaderItem(RESULTS_STEP_SIZE, itemStepSize);
99 focusAdvTable->setHorizontalHeaderItem(RESULTS_AFOVERSCAN, itemAFOverscan);
103 focusAdvTable->setHorizontalHeaderItem(RESULTS_TEXT, itemText);
106 focusAdvTable->hide();
111void FocusAdvisor::setupHelpTable()
115 m_helpUI->table->setHorizontalHeaderItem(HELP_PARAMETER, itemParameter);
118 itemCurrentValue->
setToolTip(
i18n(
"Current value of the parameter"));
119 m_helpUI->table->setHorizontalHeaderItem(HELP_CURRENT_VALUE, itemCurrentValue);
122 itemProposedValue->
setToolTip(
i18n(
"Focus Advisor proposed value for the parameter"));
123 m_helpUI->table->setHorizontalHeaderItem(HELP_NEW_VALUE, itemProposedValue);
131void FocusAdvisor::setButtons(
const bool running)
133 bool canRun = m_focus->m_Focuser && m_focus->m_Focuser->isConnected() && m_focus->m_Focuser->canAbsMove();
134 m_runButton->setEnabled(!running && canRun);
135 m_stopButton->setEnabled(running);
136 m_helpButton->setEnabled(!running);
140bool FocusAdvisor::canFocusAdvisorRun()
143 return m_focus->m_Focuser && m_focus->m_Focuser->isConnected() && m_focus->m_Focuser->canAbsMove() &&
144 m_focus->m_FocusAlgorithm == Focus::FOCUS_LINEAR1PASS &&
145 (m_focus->m_StarMeasure == Focus::FOCUS_STAR_HFR || m_focus->m_StarMeasure == Focus::FOCUS_STAR_HFR_ADJ
146 || m_focus->m_StarMeasure == Focus::FOCUS_STAR_FWHM) &&
147 (m_focus->m_CurveFit == CurveFitting::FOCUS_HYPERBOLA || m_focus->m_CurveFit == CurveFitting::FOCUS_PARABOLA);
150bool FocusAdvisor::start()
153 focusAdvTable->setRowCount(0);
154 focusAdvTable->sizePolicy();
159 if (m_focus->inFocusLoop || m_focus->inAdjustFocus || m_focus->inAutoFocus || m_focus->inBuildOffsets
160 || m_focus->inScanStartPos || inFocusAdvisor())
162 m_focus->appendLogText(
i18n(
"Focus Advisor: another focus action in progress. Please try again."));
166 if (focusAdvUpdateParams->isChecked())
169 focusAdvUpdateParamsLabel->setText(
i18n(
"Done"));
170 emit newStage(UpdatingParameters);
173 m_inFindStars = focusAdvFindStars->isChecked();
174 m_inPreAFAdj = focusAdvCoarseAdj->isChecked();
175 m_inAFAdj = focusAdvFineAdj->isChecked();
176 if (m_inFindStars || m_inPreAFAdj || m_inAFAdj)
178 if (canFocusAdvisorRun())
181 m_initialScanStartPos = m_focus->m_OpsFocusProcess->focusScanStartPos->isChecked();
182 m_focus->m_OpsFocusProcess->focusScanStartPos->setChecked(
false);
183 m_focus->runAutoFocus(FOCUS_FOCUS_ADVISOR,
"");
187 m_focus->appendLogText(
i18n(
"Focus Advisor cannot run with current params."));
195void FocusAdvisor::stop()
197 abort(
i18n(
"Focus Advisor stopped"));
202void FocusAdvisor::help()
205 m_helpDialog->show();
206 m_helpDialog->raise();
209void FocusAdvisor::addSectionToHelpTable(
int &row,
const QString §ion)
211 if (++row >= m_helpUI->table->rowCount())
212 m_helpUI->table->setRowCount(row + 1);
219 m_helpUI->table->setItem(row, HELP_PARAMETER, item);
222void FocusAdvisor::addParamToHelpTable(
int &row,
const QString ¶meter,
const QString ¤tValue,
225 if (m_helpUI->focusAdvHelpOnlyChanges->isChecked() && newValue == currentValue)
228 if (++row >= m_helpUI->table->rowCount())
229 m_helpUI->table->setRowCount(row + 1);
231 m_helpUI->table->setItem(row, HELP_PARAMETER, itemParameter);
233 m_helpUI->table->setItem(row, HELP_CURRENT_VALUE, itemCurrentValue);
235 if (newValue != currentValue)
242 m_helpUI->table->setItem(row, HELP_NEW_VALUE, itemNewValue);
246void FocusAdvisor::resizeHelpDialog()
253 m_helpUI->verticalLayout->layout()->getContentsMargins(&left, &top, &right, &bottom);
255 const int width = m_helpUI->table->horizontalHeader()->length() +
256 m_helpUI->table->verticalHeader()->width() +
257 m_helpUI->table->verticalScrollBar()->width() +
258 m_helpUI->table->frameWidth() * 2 +
260 m_helpDialog->contentsMargins().left() + m_helpDialog->contentsMargins().right() + 8;
262 m_helpDialog->resize(width, m_helpDialog->height());
266void FocusAdvisor::updateParams()
268 m_focus->setAllSettings(m_map);
269 addResultsTable(
i18n(
"Update Parameters"), -1, -1, -1, -1,
"Done");
273void FocusAdvisor::setupParams(
const QString &OTName)
276 m_map = getOTDefaults(OTName);
277 bool noDefaults = m_map.isEmpty();
279 if (!m_map.isEmpty())
283 bool longFL = m_focus->m_FocalLength > 1500;
284 double imageScale = m_focus->getStarUnits(Focus::FOCUS_STAR_HFR, Focus::FOCUS_UNITS_ARCSEC);
285 bool centralObstruction = scopeHasObstruction(m_focus->m_ScopeType);
288 m_helpUI->helpLabel->setText(
QString(
"Recommendations: %1 FL=%2 ImageScale=%3")
289 .arg(m_focus->m_ScopeType).
arg(m_focus->m_FocalLength).
arg(imageScale, 0,
'f', 2));
293 m_helpUI->table->setRowCount(0);
297 addSectionToHelpTable(row,
i18n(
"Camera & Filter Wheel Parameters"));
300 double exposure = longFL ? 4.0 : 2.0;
301 processParam(exposure, row, m_map, m_focus->focusExposure,
"Exposure");
305 if (m_focus->focusBinning->isEnabled())
308 QString binTarget = (imageScale < 1.0) ?
"2x2" :
"1x1";
310 for (
int i = 0; i < m_focus->focusBinning->count(); i++)
312 if (m_focus->focusBinning->itemText(i) == binTarget)
319 processParam(binning, row, m_map, m_focus->focusBinning,
"Binning");
322 processParam(m_focus->focusGain->value(), row, m_map, m_focus->focusGain,
"Gain");
325 processParam(m_focus->focusISO->currentText(), row, m_map, m_focus->focusISO,
"ISO");
328 processParam(m_focus->focusFilter->currentText(), row, m_map, m_focus->focusFilter,
"Filter");
331 addSectionToHelpTable(row,
i18n(
"Settings Parameters"));
334 processParam(
false, row, m_map, m_focus->m_OpsFocusSettings->focusAutoStarEnabled,
"Auto Select Star");
337 processParam(m_focus->m_OpsFocusSettings->focusSuspendGuiding->isChecked(), row, m_map,
338 m_focus->m_OpsFocusSettings->focusSuspendGuiding,
"Auto Select Star");
341 processParam(
false, row, m_map, m_focus->m_OpsFocusSettings->useFocusDarkFrame,
"Dark Frame");
344 processParam(
true, row, m_map, m_focus->m_OpsFocusSettings->focusUseFullField,
"Full Field");
345 processParam(
false, row, m_map, m_focus->m_OpsFocusSettings->focusSubFrame,
"Sub Frame");
348 processParam(32, row, m_map, m_focus->m_OpsFocusSettings->focusBoxSize,
"Box");
351 processParam(m_focus->m_OpsFocusSettings->focusUnits->currentText(), row, m_map, m_focus->m_OpsFocusSettings->focusUnits,
355 processParam(m_focus->m_OpsFocusSettings->focusGuideSettleTime->value(), row, m_map,
356 m_focus->m_OpsFocusSettings->focusGuideSettleTime,
"Guide Settle");
360 if (m_focus->m_OpsFocusSettings->focusNoMaskRB->isChecked())
361 maskCurrent =
"Use all stars";
362 else if (m_focus->m_OpsFocusSettings->focusRingMaskRB->isChecked())
364 double inner = m_focus->m_OpsFocusSettings->focusFullFieldInnerRadius->value();
365 double outer = m_focus->m_OpsFocusSettings->focusFullFieldOuterRadius->value();
366 maskCurrent =
QString(
"Ring Mask %1%-%2%").
arg(inner, 0,
'f', 1).
arg(outer, 0,
'f', 1);
370 int width = m_focus->m_OpsFocusSettings->focusMosaicTileWidth->value();
371 int spacer = m_focus->m_OpsFocusSettings->focusMosaicSpace->value();
372 maskCurrent =
QString(
"Mosaic Mask %1% (%2 px)").
arg(width).
arg(spacer);
378 m_map.insert(
"focusNoMaskRB",
false);
379 m_map.insert(
"focusRingMaskRB",
true);
380 m_map.insert(
"focusMosaicMaskRB",
false);
381 m_map.insert(
"focusFullFieldInnerRadius", 0.0);
382 m_map.insert(
"focusFullFieldOuterRadius", 80.0);
383 maskNew =
QString(
"Ring Mask %1%-%2%").
arg(0.0, 0,
'f', 1).
arg(80.0, 0,
'f', 1);
387 bool noMask = m_map.value(
"focusNoMaskRB",
false).toBool();
388 bool ringMask = m_map.value(
"focusRingMaskRB",
false).toBool();
389 bool mosaicMask = m_map.value(
"focusMosaicMaskRB",
false).toBool();
391 maskNew =
"Use all stars";
394 double inner = m_map.value(
"focusFullFieldInnerRadius", 0.0).toDouble(&ok);
395 if (!ok || inner < 0.0 || inner > 100.0)
397 double outer = m_map.value(
"focusFullFieldOuterRadius", 80.0).toDouble(&ok);
398 if (!ok || outer < 0.0 || outer > 100.0)
400 maskNew =
QString(
"Ring Mask %1%-%2%").
arg(inner, 0,
'f', 1).
arg(outer, 0,
'f', 1);
404 int width = m_map.value(
"focusMosaicTileWidth", 0.0).toInt(&ok);
405 if (!ok || width < 0 || width > 100)
407 int spacer = m_map.value(
"focusMosaicSpace", 0.0).toInt(&ok);
408 if (!ok || spacer < 0 || spacer > 100)
410 maskNew =
QString(
"Mosaic Mask %1% (%2 px)").
arg(width).
arg(spacer);
413 addParamToHelpTable(row,
i18n(
"Mask"), maskCurrent, maskNew);
416 processParam(
false, row, m_map, m_focus->m_OpsFocusSettings->focusAdaptive,
"Adaptive Focus");
419 processParam(m_focus->m_OpsFocusSettings->focusAdaptiveMinMove->value(), row, m_map,
420 m_focus->m_OpsFocusSettings->focusAdaptiveMinMove,
"Min Move");
423 processParam(
false, row, m_map, m_focus->m_OpsFocusSettings->focusAdaptStart,
"Adapt Start Pos");
426 processParam(m_focus->m_OpsFocusSettings->focusAdaptiveMaxMove->value(), row, m_map,
427 m_focus->m_OpsFocusSettings->focusAdaptiveMaxMove,
"Max Total Move");
430 addSectionToHelpTable(row,
i18n(
"Process Parameters"));
433 processParam(
QString(
"SEP"), row, m_map, m_focus->m_OpsFocusProcess->focusDetection,
"Detection");
436 QString profile = centralObstruction ? FOCUS_DEFAULT_DONUT_NAME : FOCUS_DEFAULT_NAME;
437 processParam(profile, row, m_map, m_focus->m_OpsFocusProcess->focusSEPProfile,
"SEP Profile");
440 processParam(
QString(
"Linear 1 Pass"), row, m_map, m_focus->m_OpsFocusProcess->focusAlgorithm,
"Algorithm");
443 processParam(
QString(
"Hyperbola"), row, m_map, m_focus->m_OpsFocusProcess->focusCurveFit,
"Curve Fit");
446 processParam(
QString(
"HFR"), row, m_map, m_focus->m_OpsFocusProcess->focusStarMeasure,
"Measure");
449 processParam(
true, row, m_map, m_focus->m_OpsFocusProcess->focusUseWeights,
"Use Weights");
452 processParam(0.8, row, m_map, m_focus->m_OpsFocusProcess->focusR2Limit,
"R² Limit");
455 processParam(
true, row, m_map, m_focus->m_OpsFocusProcess->focusRefineCurveFit,
"Refine Curve Fit");
458 processParam(1, row, m_map, m_focus->m_OpsFocusProcess->focusFramesCount,
"Average Over");
461 processParam(1, row, m_map, m_focus->m_OpsFocusProcess->focusHFRFramesCount,
"Average HFR Check");
464 processParam(centralObstruction, row, m_map, m_focus->m_OpsFocusProcess->focusDonut,
"Donut Buster");
465 processParam(1.0, row, m_map, m_focus->m_OpsFocusProcess->focusTimeDilation,
"Time Dilation x");
466 processParam(0.2, row, m_map, m_focus->m_OpsFocusProcess->focusOutlierRejection,
"Outlier Rejection");
469 processParam(
true, row, m_map, m_focus->m_OpsFocusProcess->focusScanStartPos,
"Scan for Start Position");
470 processParam(
false, row, m_map, m_focus->m_OpsFocusProcess->focusScanAlwaysOn,
"Always On");
471 processParam(5, row, m_map, m_focus->m_OpsFocusProcess->focusScanDatapoints,
"Num Datapoints");
472 processParam(1.0, row, m_map, m_focus->m_OpsFocusProcess->focusScanStepSizeFactor,
"Initial Step Sixe x");
475 addSectionToHelpTable(row,
i18n(
"Mechanics Parameters"));
478 processParam(
QString(
"Fixed Steps"), row, m_map, m_focus->m_OpsFocusMechanics->focusWalk,
"Walk");
481 processParam(1.0, row, m_map, m_focus->m_OpsFocusMechanics->focusSettleTime,
"Focuser Settle");
484 int stepSize = m_focus->m_Focuser && m_focus->m_Focuser->getDeviceName() == FOCUSER_SIMULATOR ? 5000 : 20;
485 processParam(stepSize, row, m_map, m_focus->m_OpsFocusMechanics->focusTicks,
"Initial Step Size");
488 processParam(11, row, m_map, m_focus->m_OpsFocusMechanics->focusNumSteps,
"Number Steps");
491 processParam(m_focus->m_OpsFocusMechanics->focusMaxTravel->maximum(), row, m_map,
492 m_focus->m_OpsFocusMechanics->focusMaxTravel,
"Max Travel");
495 processParam(m_focus->m_OpsFocusMechanics->focusBacklash->value(), row, m_map, m_focus->m_OpsFocusMechanics->focusBacklash,
499 processParam(m_focus->m_OpsFocusMechanics->focusAFOverscan->value(), row, m_map,
500 m_focus->m_OpsFocusMechanics->focusAFOverscan,
"AF Overscan");
503 processParam(0.0, row, m_map, m_focus->m_OpsFocusMechanics->focusOverscanDelay,
"AF Overscan Delay");
506 processParam(30, row, m_map, m_focus->m_OpsFocusMechanics->focusCaptureTimeout,
"Capture Timeout");
509 processParam(30, row, m_map, m_focus->m_OpsFocusMechanics->focusMotionTimeout,
"Motion Timeout");
515QString FocusAdvisor::boolText(
const bool flag)
517 return flag ?
"On" :
"Off";
521void FocusAdvisor::setInFocusAdvisor(
bool value)
523 m_inFocusAdvisor = value;
527QString FocusAdvisor::getFocusFramePrefix()
530 if (inFocusAdvisor() && m_inFindStars)
531 prefix =
"_fs_" +
QString(
"%1_%2").
arg(m_findStarsRunNum).
arg(m_focus->absIterations + 1);
532 else if (inFocusAdvisor() && m_inPreAFAdj)
533 prefix =
"_ca_" +
QString(
"%1_%2").
arg(m_preAFRunNum).
arg(m_focus->absIterations + 1);
534 else if (inFocusAdvisor() && m_focus->inScanStartPos)
535 prefix =
"_ssp_" +
QString(
"%1_%2").
arg(m_focus->m_AFRun).
arg(m_focus->absIterations + 1);
540QVariantMap FocusAdvisor::getOTDefaults(
const QString &OTName)
548 for (
auto &tName : OpticalTrainManager::Instance()->getTrainNames())
552 auto tFocuser = OpticalTrainManager::Instance()->getFocuser(tName);
553 if (tFocuser != m_focus->m_Focuser)
555 auto tScope = OpticalTrainManager::Instance()->getScope(tName);
556 auto tScopeType = tScope[
"type"].toString();
557 if (tScopeType != m_focus->m_ScopeType)
561 auto tID = OpticalTrainManager::Instance()->id(tName);
562 OpticalTrainSettings::Instance()->setOpticalTrainID(tID);
563 auto settings = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Focus);
564 if (settings.isValid())
567 map = settings.toJsonObject().toVariantMap();
570 auto tAperture = tScope[
"aperture"].toDouble(-1);
571 auto tFocalLength = tScope[
"focal_length"].toDouble(-1);
572 auto tFocalRatio = tScope[
"focal_ratio"].toDouble(-1);
573 auto tReducer = OpticalTrainManager::Instance()->getReducer(tName);
574 if (tFocalLength > 0.0)
575 tFocalLength *= tReducer;
578 if (tFocalRatio <= 0.0)
580 tFocalRatio = (tAperture > 0.001) ? tFocalLength / tAperture : 0.0f;
586 if (m_focus->m_Focuser && m_focus->m_Focuser->getDeviceName() == FOCUSER_SIMULATOR)
590 stepSize =
map.value(
"focusTicks", stepSize).toInt() * pow(m_focus->m_FocalRatio, 2.0) / pow(tFocalRatio, 2.0);
592 map.insert(
"focusTicks", stepSize);
597 auto id = OpticalTrainManager::Instance()->id(OTName);
598 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
606bool FocusAdvisor::scopeHasObstruction(
const QString &scopeType)
608 return (scopeType !=
"Refractor" && scopeType !=
"Kutter (Schiefspiegler)");
612void FocusAdvisor::initControl()
614 setInFocusAdvisor(
true);
616 m_initialStepSize = m_focus->m_OpsFocusMechanics->focusTicks->value();
617 m_initialBacklash = m_focus->m_OpsFocusMechanics->focusBacklash->value();
618 m_initialAFOverscan = m_focus->m_OpsFocusMechanics->focusAFOverscan->value();
619 m_initialUseWeights = m_focus->m_OpsFocusProcess->focusUseWeights->isChecked();
622 initFindStars(m_focus->currentPosition);
623 else if (m_inPreAFAdj)
624 initPreAFAdj(m_focus->currentPosition);
626 initAFAdj(m_focus->currentPosition,
false);
630void FocusAdvisor::control()
632 if (!inFocusAdvisor())
637 else if (m_inPreAFAdj)
640 abort(
i18n(
"Focus Advisor aborted due to internal error"));
644void FocusAdvisor::initFindStars(
const int startPos)
647 if (!canFocusAdvisorRun())
649 abort(
i18n(
"Focus Advisor cannot run with current params"));
653 focusAdvFindStarsLabel->setText(
i18n(
"In progress..."));
654 emit newStage(FindingStars);
657 m_focus->initialFocuserAbsPosition = startPos;
658 m_focus->linearRequestedPosition = startPos;
661 m_focus->m_OpsFocusProcess->focusUseWeights->setChecked(
false);
663 m_focus->absIterations = 0;
666 m_focus->clearDataPoints();
667 m_jumpsToGo = NUM_JUMPS_PER_SECTOR;
668 m_jumpSize = m_focus->m_OpsFocusMechanics->focusTicks->value() * NUM_JUMPS_PER_SECTOR;
669 m_findStarsIn =
false;
670 m_findStarsMaxBound = m_findStarsMinBound =
false;
671 m_findStarsSector = 0;
672 m_findStarsRange =
false;
673 m_findStarsRangeIn =
false;
674 m_findStarsFindInEdge =
false;
675 m_findStarsInRange = -1;
676 m_findStarsOutRange = -1;
680 m_focus->m_OpsFocusMechanics->focusBacklash->setValue(0);
681 m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(0);
683 addResultsTable(
i18n(
"Find Stars"), m_findStarsRunNum, startPos, m_jumpSize,
684 m_focus->m_OpsFocusMechanics->focusAFOverscan->value(),
"");
685 emit m_focus->setTitle(
QString(
i18n(
"Find Stars: Scanning for stars...")),
true);
686 if (!m_focus->changeFocus(startPos - m_focus->currentPosition))
687 abort(
i18n(
"Find Stars: Failed"));
694void FocusAdvisor::findStars()
697 emit m_focus->newHFRPlotPosition(
static_cast<double>(m_focus->currentPosition), m_focus->currentMeasure,
698 std::pow(m_focus->currentWeight, -0.5),
false, m_jumpSize,
true);
701 bool starsExist = starsFound();
702 if (m_findStarsRange)
704 bool outOfRange =
false;
708 if (m_findStarsRangeIn)
709 outOfRange = (m_focus->currentPosition - m_jumpSize) <
static_cast<int>(m_focus->absMotionMin);
711 outOfRange = (m_focus->currentPosition + m_jumpSize) >
static_cast<int>(m_focus->absMotionMax);
714 if (m_findStarsFindInEdge)
719 m_findStarsFindInEdge =
false;
720 m_findStarsInRange = m_focus->currentPosition - m_jumpSize;
723 else if (!starsExist && m_findStarsInRange < 0 && m_findStarsOutRange < 0)
727 if (m_findStarsRangeIn)
729 m_findStarsInRange = m_focus->currentPosition;
730 auto max = std::max_element(std::begin(m_position), std::end(m_position));
731 offset = *max - m_focus->currentPosition;
735 m_findStarsOutRange = m_focus->currentPosition;
736 auto min = std::min_element(std::begin(m_position), std::end(m_position));
737 offset = *min - m_focus->currentPosition;
739 m_findStarsRangeIn = !m_findStarsRangeIn;
741 else if (!starsExist || outOfRange)
745 m_inFindStars =
false;
746 if (m_findStarsRangeIn)
748 m_findStarsInRange = m_focus->currentPosition;
751 m_findStarsOutRange = m_focus->currentPosition;
752 const int zoneCentre = (m_findStarsInRange + m_findStarsOutRange) / 2;
753 focusAdvFindStarsLabel->setText(
i18n(
"Done"));
757 initPreAFAdj(zoneCentre);
759 initAFAdj(zoneCentre,
true);
762 m_focus->absTicksSpin->setValue(zoneCentre);
763 emit m_focus->setTitle(
QString(
i18n(
"Stars detected, range centre %1", zoneCentre)),
true);
764 complete(
false,
i18n(
"Focus Advisor Find Stars completed"));
771 m_position.push_back(m_focus->currentPosition);
772 m_measure.push_back(m_focus->currentMeasure);
779 if (!m_findStarsRange)
781 m_findStarsRange =
true;
785 if (m_position.size() > 1)
787 if (m_position.last() < m_position[m_position.size() - 2])
791 std::sort(positionsCopy.
begin(), positionsCopy.
end(), std::greater<int>());
792 m_findStarsOutRange = positionsCopy[1];
793 m_findStarsOutRange = m_position[m_position.size() - 2];
794 m_findStarsRangeIn =
true;
800 m_findStarsFindInEdge =
true;
802 std::sort(positionsCopy.
begin(), positionsCopy.
end(), std::greater<int>());
803 offset = positionsCopy[1] - m_focus->currentPosition;
810 if (++m_focus->absIterations > MAXIMUM_FOCUS_ADVISOR_ITERATIONS)
812 abort(
i18n(
"Find Stars: exceeded max iterations %1", MAXIMUM_FOCUS_ADVISOR_ITERATIONS));
817 if (m_findStarsRange)
820 emit m_focus->setTitle(
QString(
i18n(
"Stars detected, centering range")),
true);
821 updateResultsTable(
i18n(
"Stars detected, centering range"));
823 if (m_findStarsRangeIn)
824 nextPos = std::max(m_focus->currentPosition + offset - m_jumpSize,
static_cast<int>(m_focus->absMotionMin));
826 nextPos = std::min(m_focus->currentPosition + offset + m_jumpSize,
static_cast<int>(m_focus->absMotionMax));
827 deltaPos = nextPos - m_focus->currentPosition;
829 else if (m_position.size() == 1)
832 deltaPos = m_jumpSize * m_jumpsToGo;
834 if (m_focus->currentPosition + deltaPos >= m_focus->absMotionMax)
836 deltaPos = m_focus->absMotionMax - m_focus->currentPosition;
837 m_jumpsToGo = deltaPos / m_jumpSize + (deltaPos % m_jumpSize != 0);
838 m_findStarsMaxBound =
true;
840 m_findStarsJumpsInSector = m_jumpsToGo;
841 m_findStarsSector = 1;
842 emit m_focus->setTitle(
QString(
i18n(
"Find Stars Run %1: No stars at start %2, scanning...", m_findStarsRunNum,
843 m_focus->currentPosition)),
true);
845 else if (m_jumpsToGo > 0)
848 emit m_focus->setTitle(
QString(
i18n(
"Find Stars Run %1 Sector %2: Scanning %3/%4", m_findStarsRunNum, m_findStarsSector,
849 m_jumpsToGo, m_findStarsJumpsInSector)),
true);
850 updateResultsTable(
i18n(
"Find Stars Run %1: Scanning Sector %2", m_findStarsRunNum, m_findStarsSector));
851 int nextPos = std::max(m_focus->currentPosition - m_jumpSize,
static_cast<int>(m_focus->absMotionMin));
852 deltaPos = nextPos - m_focus->currentPosition;
857 if(m_findStarsMaxBound && m_findStarsMinBound)
861 updateResultsTable(
i18n(
"No stars detected"));
862 int newStepSize = m_focus->m_OpsFocusMechanics->focusTicks->value() / 2;
865 m_focus->m_OpsFocusMechanics->focusTicks->setValue(newStepSize);
866 initFindStars(m_focus->initialFocuserAbsPosition);
869 abort(
i18n(
"Find Stars Run %1: failed to find any stars", m_findStarsRunNum));
874 m_jumpsToGo = NUM_JUMPS_PER_SECTOR;
878 if (m_findStarsMaxBound)
881 if (m_focus->currentPosition - m_jumpSize <
static_cast<int>(m_focus->absMotionMin))
882 deltaPos =
static_cast<int>(m_focus->absMotionMin) - m_focus->currentPosition;
884 deltaPos = -m_jumpSize;
888 auto max = std::max_element(std::begin(m_position), std::end(m_position));
889 int sweepMax = *max + (m_jumpSize * m_jumpsToGo);
890 if (sweepMax >=
static_cast<int>(m_focus->absMotionMax))
892 sweepMax =
static_cast<int>(m_focus->absMotionMax);
893 m_jumpsToGo = (sweepMax - *max) / m_jumpSize + ((sweepMax - *max) % m_jumpSize != 0);
894 m_findStarsMaxBound =
true;
896 m_findStarsIn =
false;
897 deltaPos = sweepMax - m_focus->currentPosition;
903 if (m_findStarsMinBound)
905 auto max = std::max_element(std::begin(m_position), std::end(m_position));
906 int sweepMax = *max + (m_jumpSize * m_jumpsToGo);
907 if (sweepMax >=
static_cast<int>(m_focus->absMotionMax))
909 sweepMax =
static_cast<int>(m_focus->absMotionMax);
910 m_jumpsToGo = (sweepMax - *max) / m_jumpSize + ((sweepMax - *max) % m_jumpSize != 0);
911 m_findStarsMaxBound =
true;
913 deltaPos = sweepMax - m_focus->currentPosition;
917 auto min = std::min_element(std::begin(m_position), std::end(m_position));
918 int sweepMin = *min - (m_jumpSize * m_jumpsToGo);
919 if (sweepMin <=
static_cast<int>(m_focus->absMotionMin))
922 m_findStarsMinBound =
true;
923 sweepMin =
static_cast<int>(m_focus->absMotionMin);
924 m_jumpsToGo = (*min - sweepMin) / m_jumpSize + ((*min - sweepMin) % m_jumpSize != 0);
927 m_findStarsIn =
true;
928 int nextJumpPos = std::max(*min - m_jumpSize,
static_cast<int>(m_focus->absMotionMin));
929 deltaPos = nextJumpPos - m_focus->currentPosition;
933 m_findStarsJumpsInSector = m_jumpsToGo;
934 emit m_focus->setTitle(
QString(
i18n(
"Find Stars Run %1 Sector %2: scanning %3/%4", m_findStarsRunNum, m_findStarsSector,
935 m_jumpsToGo, m_findStarsJumpsInSector)),
true);
937 if (!m_findStarsRange)
939 m_focus->linearRequestedPosition = m_focus->currentPosition + deltaPos;
940 if (!m_focus->changeFocus(deltaPos))
941 abort(
i18n(
"Focus Advisor Find Stars run %1: failed to move focuser", m_findStarsRunNum));
944bool FocusAdvisor::starsFound()
946 return (m_focus->currentMeasure != INVALID_STAR_MEASURE && m_focus->currentNumStars > FIND_STARS_MIN_STARS);
951void FocusAdvisor::initPreAFAdj(
const int startPos)
954 if (!canFocusAdvisorRun())
956 abort(
i18n(
"Focus Advisor cannot run with current params"));
961 if (m_preAFRunNum > 50)
963 abort(
i18n(
"Focus Advisor Coarse Adjustment aborted after %1 runs", m_preAFRunNum));
967 focusAdvCoarseAdjLabel->setText(
i18n(
"In progress..."));
968 emit newStage(CoarseAdjustments);
970 m_focus->initialFocuserAbsPosition = startPos;
971 m_focus->absIterations = 0;
975 m_preAFNoStarsOut = m_preAFNoStarsIn =
false;
979 m_focus->clearDataPoints();
980 emit m_focus->setTitle(
QString(
i18n(
"Coarse Adjustment Scan...")),
true);
983 m_jumpSize = m_focus->m_OpsFocusMechanics->focusTicks->value() * NUM_STEPS_PRE_AF;
986 if (m_jumpSize > m_focus->absMotionMax - m_focus->absMotionMin)
988 m_jumpSize = m_focus->absMotionMax - m_focus->absMotionMin;
989 m_focus->m_OpsFocusMechanics->focusTicks->setValue(m_jumpSize / NUM_STEPS_PRE_AF);
992 int deltaPos = (startPos - m_focus->currentPosition) + m_jumpSize / 2;
993 if (m_focus->currentPosition + deltaPos > maxStarsLimit())
994 deltaPos = maxStarsLimit() - m_focus->currentPosition;
996 m_preAFInner = startPos - m_jumpSize / 2;
997 if (m_preAFInner < minStarsLimit())
998 m_preAFInner = minStarsLimit();
1001 if (m_preAFRunNum == 1)
1003 m_focus->m_OpsFocusMechanics->focusBacklash->setValue(0);
1004 m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(0);
1005 m_focus->m_OpsFocusProcess->focusUseWeights->setChecked(m_initialUseWeights);
1008 addResultsTable(
i18n(
"Coarse Adjustment"), m_preAFRunNum, startPos,
1009 m_focus->m_OpsFocusMechanics->focusTicks->value(),
1010 m_focus->m_OpsFocusMechanics->focusAFOverscan->value(),
"");
1012 m_focus->linearRequestedPosition = m_focus->currentPosition + deltaPos;
1013 if (!m_focus->changeFocus(deltaPos))
1014 abort(
i18n(
"Focus Advisor Coarse Adjustment failed to move focuser"));
1019void FocusAdvisor::preAFAdj()
1022 if (++m_focus->absIterations > MAXIMUM_FOCUS_ADVISOR_ITERATIONS)
1024 abort(
i18n(
"Focus Advisor Coarse Adjustment: exceeded max iterations %1", MAXIMUM_FOCUS_ADVISOR_ITERATIONS));
1029 const int step = m_focus->m_OpsFocusMechanics->focusTicks->value();
1031 bool starsExist = starsFound();
1035 m_position.push_back(m_focus->currentPosition);
1036 m_measure.push_back(m_focus->currentMeasure);
1038 if (m_preAFNoStarsOut && (m_position.size() == 0))
1040 if (m_findStarsOutRange < 0)
1041 m_findStarsOutRange = m_focus->currentPosition;
1043 m_findStarsOutRange = std::max(m_findStarsOutRange, m_focus->currentPosition);
1049 if (m_position.size() < 2)
1050 m_preAFNoStarsOut =
true;
1051 else if (m_focus->currentPosition - (2 * step) <= m_preAFInner)
1053 m_preAFNoStarsIn =
true;
1054 if (m_findStarsInRange < 0)
1055 m_findStarsInRange = m_position.last();
1057 m_findStarsInRange = std::min(m_findStarsInRange, m_position.last());
1061 emit m_focus->newHFRPlotPosition(
static_cast<double>(m_focus->currentPosition), m_focus->currentMeasure,
1062 std::pow(m_focus->currentWeight, -0.5),
false, step,
true);
1065 if (m_focus->currentPosition - step < m_preAFInner && starsExist)
1068 auto it = std::min_element(std::begin(m_measure), std::end(m_measure));
1069 auto min = std::distance(std::begin(m_measure), it);
1070 if (m_position.size() < 5 || (m_position.size() < 2 * NUM_STEPS_PRE_AF && m_position.size() - min < 3))
1073 if (m_preAFInner - step >= minStarsLimit())
1074 m_preAFInner -= step;
1078 if (m_focus->currentPosition - step >= m_preAFInner)
1081 emit m_focus->setTitle(
QString(
i18n(
"Coarse Adjustment Run %1 scan...", m_preAFRunNum)),
true);
1087 if (m_position.size() < 5)
1089 abort(
i18n(
"Focus Advisor Coarse Adjustment Run %1: insufficient data to proceed", m_preAFRunNum));
1094 auto it = std::min_element(std::begin(m_measure), std::end(m_measure));
1095 auto min = std::distance(std::begin(m_measure), it);
1096 const double minMeasure = *it;
1097 int minPos = m_position[min];
1099 auto it2 = std::max_element(std::begin(m_measure), std::end(m_measure));
1100 const double maxMeasure = *it2;
1102 const double scaling =
static_cast<double>(NUM_STEPS_PRE_AF) /
static_cast<double>(m_measure.count());
1103 const double measureRatio = maxMeasure / minMeasure * scaling;
1106 double whereInRange =
static_cast<double>(minPos - m_position.last()) /
static_cast<double>
1107 (m_position.first() - m_position.last());
1108 bool nearCenter = whereInRange > 0.3 && whereInRange < 0.7;
1111 for (
int i = 0; i < m_position.size() - 1; i++)
1113 double gradient = (m_measure[i] - m_measure[i + 1]) / (m_position[i] - m_position[i + 1]);
1114 gradients.
push_back(std::abs(gradient));
1120 std::sort(gradientsCopy.
begin(), gradientsCopy.
end(), std::greater<double>());
1121 std::vector<double> gradientsMax;
1122 for (
int i = 0; i < 3; i++)
1123 gradientsMax.push_back(gradientsCopy[i]);
1125 double gradientsMean = Mathematics::RobustStatistics::ComputeLocation(Mathematics::RobustStatistics::LOCATION_MEAN,
1128 const double threshold = gradientsMean * 0.5;
1129 int overscan = m_focus->m_OpsFocusMechanics->focusAFOverscan->value();
1130 for (
int i = 0; i < gradients.
size(); i++)
1132 if (gradients[i] <= threshold)
1133 overscan += m_position[i] - m_position[i + 1];
1137 overscan = std::max(overscan, step);
1138 m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(overscan);
1140 const bool hitNoStarsRegion = m_preAFNoStarsIn || m_preAFNoStarsOut;
1143 if (nearCenter && maxMinRatioOK(INITIAL_MAXMIN_HFR_RATIO, measureRatio) && !hitNoStarsRegion)
1147 m_inPreAFAdj =
false;
1148 focusAdvCoarseAdjLabel->setText(
i18n(
"Done"));
1149 m_focus->absIterations = 0;
1155 m_focus->clearDataPoints();
1158 initAFAdj(minPos,
true);
1162 m_focus->absTicksSpin->setValue(minPos);
1163 complete(
false,
i18n(
"Focus Advisor Coarse Adjustment completed."));
1171 const double expansion = TARGET_MAXMIN_HFR_RATIO / measureRatio;
1172 int newStepSize = m_focus->m_OpsFocusMechanics->focusTicks->value() * expansion;
1174 if (m_preAFNoStarsIn && m_preAFNoStarsOut)
1177 const int range = m_position.first() - m_position.last();
1178 newStepSize = range / NUM_STEPS_PRE_AF;
1179 startPosition = (m_position.first() + m_position.last()) / 2;
1180 m_preAFMaxRange =
true;
1181 if (newStepSize < 1)
1184 abort(
i18n(
"Focus Advisor Coarse Adjustment: data quality too poor to continue"));
1188 else if (m_preAFNoStarsIn)
1191 int range = NUM_STEPS_PRE_AF * newStepSize;
1192 int jumpPosition = m_position.last() + range;
1193 if (jumpPosition > maxStarsLimit())
1195 range = maxStarsLimit() - m_position.last();
1196 newStepSize = range / NUM_STEPS_PRE_AF;
1197 m_preAFMaxRange =
true;
1199 startPosition = m_position.last() + (range / 2);
1201 else if (m_preAFNoStarsOut)
1204 int range = NUM_STEPS_PRE_AF * newStepSize;
1205 int endPosition = m_position.first() - range;
1206 if (endPosition < minStarsLimit())
1208 range = m_position.first() - minStarsLimit();
1209 newStepSize = range / NUM_STEPS_PRE_AF;
1210 m_preAFMaxRange =
true;
1212 startPosition = m_position.first() - (range / 2);
1216 startPosition = minPos;
1218 updateResultsTable(
i18n(
"Max/Min Ratio: %1, Next Step Size: %2, Next Overscan: %3",
QString::number(measureRatio,
'f', 1),
1220 m_focus->m_OpsFocusMechanics->focusTicks->setValue(newStepSize);
1221 initPreAFAdj(startPosition);
1226 m_focus->linearRequestedPosition = m_focus->currentPosition + deltaPos;
1227 if (!m_focus->changeFocus(deltaPos))
1228 abort(
i18n(
"Focus Advisor Coarse Adjustment failed to move focuser"));
1232bool FocusAdvisor::maxMinRatioOK(
const double limit,
const double maxMinRatio)
1234 if (m_preAFMaxRange)
1237 return maxMinRatio >= limit;
1241int FocusAdvisor::minStarsLimit()
1243 return std::max(
static_cast<int>(m_focus->absMotionMin), m_findStarsInRange);
1247int FocusAdvisor::maxStarsLimit()
1249 if (m_findStarsOutRange < 0)
1250 return m_focus->absMotionMax;
1252 return std::min(
static_cast<int>(m_focus->absMotionMax), m_findStarsOutRange);
1255void FocusAdvisor::initAFAdj(
const int startPos,
const bool retryOverscan)
1258 if (!canFocusAdvisorRun())
1260 abort(
i18n(
"Focus Advisor cannot run with current params"));
1264 focusAdvFineAdjLabel->setText(
i18n(
"In progress..."));
1265 emit newStage(FineAdjustments);
1271 const int newOverscan = m_focus->m_OpsFocusMechanics->focusAFOverscan->value() / 2;
1272 m_focus->m_OpsFocusMechanics->focusBacklash->setValue(0);
1273 m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(newOverscan);
1277 m_focus->m_OpsFocusProcess->focusUseWeights->setChecked(m_initialUseWeights);
1279 addResultsTable(
i18n(
"Fine Adjustment"), ++m_AFRunCount, startPos,
1280 m_focus->m_OpsFocusMechanics->focusTicks->value(),
1281 m_focus->m_OpsFocusMechanics->focusAFOverscan->value(),
"");
1286void FocusAdvisor::startAF(
const int startPos)
1290 setInFocusAdvisor(
false);
1291 m_focus->absIterations = 0;
1292 m_focus->setupLinearFocuser(startPos);
1293 if (!m_focus->changeFocus(m_focus->linearRequestedPosition - m_focus->currentPosition))
1294 m_focus->completeFocusProcedure(Ekos::FOCUS_ABORTED, Ekos::FOCUS_FAIL_FOCUSER_NO_MOVE);
1299 m_focus->initScanStartPos(
true, startPos);
1303bool FocusAdvisor::analyseAF()
1305 if (m_focus->m_FocusAlgorithm != Focus::FOCUS_LINEAR1PASS || !m_focus->linearFocuser || !m_focus->linearFocuser->isDone()
1306 || m_focus->linearFocuser->solution() == -1)
1309 bool runAgainRatio =
false;
1313 m_focus->linearFocuser->getPass1Measurements(&positions, &measures, &weights, &outliers);
1315 int minPosition = m_focus->linearFocuser->solution();
1316 double minMeasure = m_focus->linearFocuser->solutionValue();
1318 int maxPositon = positions[0];
1319 double maxMeasure = m_focus->curveFitting->f(maxPositon);
1321 const int stepSize = m_focus->m_OpsFocusMechanics->focusTicks->value();
1322 int newStepSize = stepSize;
1324 double measureRatio = maxMeasure / minMeasure;
1325 if (measureRatio > 2.5 && measureRatio < 3.5)
1327 runAgainRatio =
false;
1330 runAgainRatio =
true;
1332 int pos = m_focus->curveFitting->fy(minMeasure * TARGET_MAXMIN_HFR_RATIO);
1333 newStepSize = (pos - minPosition) / ((positions.
size() - 1.0) / 2.0);
1337 double ratio =
static_cast<double>(newStepSize) /
static_cast<double>(stepSize);
1338 ratio = std::max(std::min(ratio, 2.0), 0.5);
1339 newStepSize = stepSize * ratio;
1340 m_focus->m_OpsFocusMechanics->focusTicks->setValue(newStepSize);
1345 if (!m_overscanFound)
1347 double backlashPoints = 0.0;
1348 for (
int i = 0; i < positions.
size() / 2; i++)
1350 double deltaAct = measures[i] - measures[i + 1];
1351 double deltaExp = m_focus->curveFitting->f(positions[i]) - m_focus->curveFitting->f(positions[i + 1]);
1352 double delta = std::abs(deltaAct / deltaExp);
1357 backlashPoints += 0.5;
1362 const int overscan = m_focus->m_OpsFocusMechanics->focusAFOverscan->value();
1363 int newOverscan = overscan;
1365 if (backlashPoints > 0.0)
1368 newOverscan = overscan + (stepSize * backlashPoints);
1369 m_overscanFound =
true;
1371 else if (overscan == 0)
1372 m_overscanFound =
true;
1373 else if (!m_overscanFound)
1375 newOverscan = overscan <= 2 * stepSize ? 0 : overscan / 2;
1377 m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(newOverscan);
1382 m_runAgainR2 =
false;
1384 m_runAgainR2 = m_focus->R2 < m_focus->m_OpsFocusProcess->focusR2Limit->value();
1385 bool runAgain = runAgainRatio || m_runAgainR2 || !m_overscanFound;
1387 updateResultsTable(
i18n(
"Max/Min Ratio: %1, R2: %2, Step Size: %3, Overscan: %4",
QString::number(measureRatio,
'f', 1),
1389 QString::number(m_focus->m_OpsFocusMechanics->focusAFOverscan->value())));
1393 focusAdvFineAdjLabel->setText(
i18n(
"Done"));
1394 complete(
true,
i18n(
"Focus Advisor Fine Adjustment completed"));
1395 emit newStage(Idle);
1401void FocusAdvisor::reset()
1403 m_inFocusAdvisor =
false;
1404 m_initialStepSize = -1;
1405 m_initialBacklash = -1;
1406 m_initialAFOverscan = -1;
1407 m_initialUseWeights =
false;
1408 m_initialScanStartPos =
false;
1411 m_inFindStars =
false;
1412 m_inPreAFAdj =
false;
1416 m_findStarsIn =
false;
1417 m_findStarsMaxBound =
false;
1418 m_findStarsMinBound =
false;
1419 m_findStarsSector = 0;
1420 m_findStarsRunNum = 0;
1421 m_findStarsRange =
false;
1422 m_findStarsRangeIn =
false;
1423 m_findStarsFindInEdge =
false;
1424 m_findStarsInRange = -1;
1425 m_findStarsOutRange = -1;
1427 m_preAFNoStarsOut =
false;
1428 m_preAFNoStarsIn =
false;
1429 m_preAFMaxRange =
false;
1431 m_overscanFound =
false;
1432 m_runAgainR2 =
false;
1433 m_nearFocus =
false;
1436 focusAdvUpdateParamsLabel->setText(
"");
1437 focusAdvFindStarsLabel->setText(
"");
1438 focusAdvCoarseAdjLabel->setText(
"");
1439 focusAdvFineAdjLabel->setText(
"");
1443void FocusAdvisor::abort(
const QString &msg)
1445 m_focus->appendLogText(msg);
1448 resetSavedSettings(
false);
1449 m_focus->processAbort();
1454void FocusAdvisor::complete(
const bool autofocus,
const QString &msg)
1456 m_focus->appendLogText(msg);
1458 resetSavedSettings(
true);
1462 if (m_initialBacklash > -1) m_focus->m_OpsFocusMechanics->focusBacklash->setValue(m_initialBacklash);
1463 if (m_initialAFOverscan > -1) m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(m_initialAFOverscan);
1464 m_focus->completeFocusProcedure(Ekos::FOCUS_IDLE, Ekos::FOCUS_FAIL_ADVISOR_COMPLETE);
1468void FocusAdvisor::resetSavedSettings(
const bool success)
1470 m_focus->m_OpsFocusProcess->focusUseWeights->setChecked(m_initialUseWeights);
1471 m_focus->m_OpsFocusProcess->focusScanStartPos->setChecked(m_initialScanStartPos);
1476 if (m_initialStepSize > -1) m_focus->m_OpsFocusMechanics->focusTicks->setValue(m_initialStepSize);
1477 if (m_initialBacklash > -1) m_focus->m_OpsFocusMechanics->focusBacklash->setValue(m_initialBacklash);
1478 if (m_initialAFOverscan > -1) m_focus->m_OpsFocusMechanics->focusAFOverscan->setValue(m_initialAFOverscan);
1483void FocusAdvisor::addResultsTable(
QString section,
int run,
int startPos,
int stepSize,
int overscan,
QString text)
1485 m_focus->appendLogText(
i18n(
"Focus Advisor Result (%1): Run: %2 startPos: %3 stepSize: %4 overscan: %5",
1486 section, run, startPos, stepSize, overscan));
1488 focusAdvTable->insertRow(0);
1490 focusAdvTable->setItem(0, RESULTS_SECTION, itemSection);
1494 focusAdvTable->setItem(0, RESULTS_RUN_NUMBER, itemRunNumber);
1498 focusAdvTable->setItem(0, RESULTS_START_POSITION, itemStartPos);
1502 focusAdvTable->setItem(0, RESULTS_STEP_SIZE, itemStepSize);
1506 focusAdvTable->setItem(0, RESULTS_AFOVERSCAN, itemAFOverscan);
1508 focusAdvTable->setItem(0, RESULTS_TEXT, itemText);
1510 emit newMessage(text);
1512 if (focusAdvTable->rowCount() == 1)
1514 focusAdvTable->show();
1520void FocusAdvisor::updateResultsTable(
QString text)
1522 m_focus->appendLogText(
i18n(
"Focus Advisor Result Update: %1", text));
1525 focusAdvTable->setItem(0, RESULTS_TEXT, itemText);
1529void FocusAdvisor::resizeDialog()
1533 this->verticalLayout->layout()->getContentsMargins(&left, &top, &right, &bottom);
1536 for (
int i = 0; i < focusAdvTable->horizontalHeader()->count(); i++)
1537 width += focusAdvTable->columnWidth(i);
1538 const int height = focusAdvGroupBox->height() + focusAdvTable->height() + focusAdvButtonBox->height();
1539 focusAdvTable->horizontalHeader()->height() + focusAdvTable->rowHeight(0);
1540 this->resize(width, height);
QString i18n(const char *text, const TYPE &arg...)
Ekos is an advanced Astrophotography tool for Linux.
void stateChanged(int state)
int pointSize() const const
void setBold(bool enable)
void setPointSize(int pointSize)
void setUnderline(bool enable)
void push_back(parameter_type value)
qsizetype size() const const
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
void setText(const QString &text)
void setTextAlignment(Qt::Alignment alignment)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< T > run(Function function,...)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)