File indexing completed on 2024-04-28 03:43:38
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikartech.com> 0003 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "guidemanager.h" 0009 0010 #include "kstarsdata.h" 0011 #include "Options.h" 0012 #include "ekos/guide/guide.h" 0013 0014 namespace Ekos 0015 { 0016 GuideManager::GuideManager(QWidget *parent) : QWidget(parent) 0017 { 0018 setupUi(this); 0019 guideStateWidget = new GuideStateWidget(); 0020 guideTitleLayout->addWidget(guideStateWidget, 0, Qt::AlignRight); 0021 } 0022 0023 void GuideManager::init(Guide *guideProcess) 0024 { 0025 // guide details buttons 0026 connect(guideDetailNextButton, &QPushButton::clicked, this, [this]() 0027 { 0028 const int pos = guideDetailWidget->currentIndex(); 0029 if (pos == 0 || (pos == 1 && guideStarPixmap.get() != nullptr)) 0030 guideDetailWidget->setCurrentIndex(pos + 1); 0031 else if (pos > 0) 0032 guideDetailWidget->setCurrentIndex(0); 0033 0034 updateGuideDetailView(); 0035 }); 0036 0037 connect(guideDetailPrevButton, &QPushButton::clicked, this, [this]() 0038 { 0039 const int pos = guideDetailWidget->currentIndex(); 0040 if (pos > 0) 0041 guideDetailWidget->setCurrentIndex(pos - 1); 0042 else if (guideStarPixmap.get() != nullptr) 0043 guideDetailWidget->setCurrentIndex(2); 0044 else 0045 guideDetailWidget->setCurrentIndex(1); 0046 0047 updateGuideDetailView(); 0048 }); 0049 0050 // feed guide state widget 0051 connect(guideProcess, &Ekos::Guide::newStatus, guideStateWidget, &Ekos::GuideStateWidget::updateGuideStatus); 0052 0053 // initialize the target rings 0054 targetPlot->buildTarget(Options::guiderAccuracyThreshold()); 0055 0056 0057 // establish connections to receive guiding data 0058 driftGraph->connectGuider(guideProcess->getGuiderInstance()); 0059 targetPlot->connectGuider(guideProcess->getGuiderInstance()); 0060 0061 // connect to Guide UI controls 0062 //This connects all the buttons and slider below the guide plots. 0063 connect(guideProcess->rADisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0064 { 0065 driftGraph->toggleShowPlot(GuideGraph::G_RA, isChecked); 0066 }); 0067 connect(guideProcess->dEDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0068 { 0069 driftGraph->toggleShowPlot(GuideGraph::G_DEC, isChecked); 0070 }); 0071 connect(guideProcess->rACorrDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0072 { 0073 driftGraph->toggleShowPlot(GuideGraph::G_RA_PULSE, isChecked); 0074 }); 0075 connect(guideProcess->dECorrDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0076 { 0077 driftGraph->toggleShowPlot(GuideGraph::G_DEC_PULSE, isChecked); 0078 }); 0079 connect(guideProcess->sNRDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0080 { 0081 driftGraph->toggleShowPlot(GuideGraph::G_SNR, isChecked); 0082 }); 0083 connect(guideProcess->rMSDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked) 0084 { 0085 driftGraph->toggleShowPlot(GuideGraph::G_RMS, isChecked); 0086 }); 0087 connect(guideProcess->correctionSlider, &QSlider::sliderMoved, driftGraph, &GuideDriftGraph::setCorrectionGraphScale); 0088 0089 connect(guideProcess->latestCheck, &QCheckBox::toggled, targetPlot, &GuideTargetPlot::setLatestGuidePoint); 0090 connect(guideProcess->guiderAccuracyThreshold, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), 0091 targetPlot, 0092 &GuideTargetPlot::buildTarget); 0093 connect(guideProcess->guideDataClearB, &QPushButton::clicked, [this]() 0094 { 0095 driftGraph->clear(); 0096 targetPlot->clear(); 0097 }); 0098 } 0099 0100 0101 void GuideManager::updateGuideStatus(Ekos::GuideState status) 0102 { 0103 guideStatus->setText(Ekos::getGuideStatusString(status)); 0104 } 0105 0106 0107 0108 void GuideManager::updateGuideStarPixmap(QPixmap &starPix) 0109 { 0110 if (starPix.isNull()) 0111 return; 0112 0113 guideStarPixmap.reset(new QPixmap(starPix)); 0114 updateGuideDetailView(); 0115 } 0116 0117 void GuideManager::updateSigmas(double ra, double de) 0118 { 0119 errRA->setText(QString::number(ra, 'f', 2) + "\" "); 0120 errDEC->setText(QString::number(de, 'f', 2) + "\" "); 0121 const double total = std::hypot(ra, de); 0122 errRMS->setText(QString::number(total, 'f', 2) + "\" "); 0123 } 0124 0125 void GuideManager::updateGuideDetailView() 0126 { 0127 const int pos = guideDetailWidget->currentIndex(); 0128 if (pos == 2 && guideStarPixmap.get() != nullptr) 0129 guideStarView->setPixmap(guideStarPixmap.get()->scaled(guideStarView->width(), guideStarView->height(), 0130 Qt::KeepAspectRatio, Qt::SmoothTransformation)); 0131 } 0132 0133 void GuideManager::reset() 0134 { 0135 guideStatus->setText(i18n("Idle")); 0136 } 0137 0138 }