Kstars

guidemanager.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikartech.com>
3 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#include "guidemanager.h"
9
10#include "kstarsdata.h"
11#include "Options.h"
12#include "ekos/guide/guide.h"
13
14namespace Ekos
15{
16GuideManager::GuideManager(QWidget *parent) : QWidget(parent)
17{
18 setupUi(this);
19 guideStateWidget = new GuideStateWidget();
20 guideTitleLayout->addWidget(guideStateWidget, 0, Qt::AlignRight);
21}
22
23void GuideManager::init(Guide *guideProcess)
24{
25 // guide details buttons
26 connect(guideDetailNextButton, &QPushButton::clicked, this, [this]()
27 {
28 const int pos = guideDetailWidget->currentIndex();
29 if (pos == 0 || (pos == 1 && guideStarPixmap.get() != nullptr))
30 guideDetailWidget->setCurrentIndex(pos + 1);
31 else if (pos > 0)
32 guideDetailWidget->setCurrentIndex(0);
33
34 updateGuideDetailView();
35 });
36
37 connect(guideDetailPrevButton, &QPushButton::clicked, this, [this]()
38 {
39 const int pos = guideDetailWidget->currentIndex();
40 if (pos > 0)
41 guideDetailWidget->setCurrentIndex(pos - 1);
42 else if (guideStarPixmap.get() != nullptr)
43 guideDetailWidget->setCurrentIndex(2);
44 else
45 guideDetailWidget->setCurrentIndex(1);
46
47 updateGuideDetailView();
48 });
49
50 // feed guide state widget
51 connect(guideProcess, &Ekos::Guide::newStatus, guideStateWidget, &Ekos::GuideStateWidget::updateGuideStatus);
52
53 // initialize the target rings
54 targetPlot->buildTarget(Options::guiderAccuracyThreshold());
55
56
57 // establish connections to receive guiding data
58 driftGraph->connectGuider(guideProcess->getGuiderInstance());
59 targetPlot->connectGuider(guideProcess->getGuiderInstance());
60
61 // connect to Guide UI controls
62 //This connects all the buttons and slider below the guide plots.
63 connect(guideProcess->rADisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
64 {
65 driftGraph->toggleShowPlot(GuideGraph::G_RA, isChecked);
66 });
67 connect(guideProcess->dEDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
68 {
69 driftGraph->toggleShowPlot(GuideGraph::G_DEC, isChecked);
70 });
71 connect(guideProcess->rACorrDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
72 {
73 driftGraph->toggleShowPlot(GuideGraph::G_RA_PULSE, isChecked);
74 });
75 connect(guideProcess->dECorrDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
76 {
77 driftGraph->toggleShowPlot(GuideGraph::G_DEC_PULSE, isChecked);
78 });
79 connect(guideProcess->sNRDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
80 {
81 driftGraph->toggleShowPlot(GuideGraph::G_SNR, isChecked);
82 });
83 connect(guideProcess->rMSDisplayedOnGuideGraph, &QCheckBox::toggled, this, [this](bool isChecked)
84 {
85 driftGraph->toggleShowPlot(GuideGraph::G_RMS, isChecked);
86 });
87 connect(guideProcess->correctionSlider, &QSlider::sliderMoved, driftGraph, &GuideDriftGraph::setCorrectionGraphScale);
88
89 connect(guideProcess->latestCheck, &QCheckBox::toggled, targetPlot, &GuideTargetPlot::setLatestGuidePoint);
90 connect(guideProcess->guiderAccuracyThreshold, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
91 targetPlot,
92 &GuideTargetPlot::buildTarget);
93 connect(guideProcess->guideDataClearB, &QPushButton::clicked, [this]()
94 {
95 driftGraph->clear();
96 targetPlot->clear();
97 });
98}
99
100
101void GuideManager::updateGuideStatus(Ekos::GuideState status)
102{
103 guideStatus->setText(Ekos::getGuideStatusString(status));
104}
105
106
107
108void GuideManager::updateGuideStarPixmap(QPixmap &starPix)
109{
110 if (starPix.isNull())
111 return;
112
113 guideStarPixmap.reset(new QPixmap(starPix));
114 updateGuideDetailView();
115}
116
117void GuideManager::updateSigmas(double ra, double de)
118{
119 errRA->setText(QString::number(ra, 'f', 2) + "\" ");
120 errDEC->setText(QString::number(de, 'f', 2) + "\" ");
121 const double total = std::hypot(ra, de);
122 errRMS->setText(QString::number(total, 'f', 2) + "\" ");
123}
124
125void GuideManager::updateGuideDetailView()
126{
127 const int pos = guideDetailWidget->currentIndex();
128 if (pos == 2 && guideStarPixmap.get() != nullptr)
129 guideStarView->setPixmap(guideStarPixmap.get()->scaled(guideStarView->width(), guideStarView->height(),
131}
132
133void GuideManager::reset()
134{
135 guideStatus->setText(i18n("Idle"));
136}
137
138}
Guide is a special class that handles ST4 commands.
QString i18n(const char *text, const TYPE &arg...)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
void clicked(bool checked)
void toggled(bool checked)
void sliderMoved(int value)
void valueChanged(double d)
bool isNull() const const
QString number(double n, char format, int precision)
AlignRight
KeepAspectRatio
SmoothTransformation
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.