Kstars

guidemanager.cpp
1 /*
2  SPDX-FileCopyrightText: 2012 Jasem Mutlaq <[email protected]>
3  SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <[email protected]>
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 
13 namespace Ekos
14 {
15 GuideManager::GuideManager(QWidget *parent) : QWidget(parent)
16 {
17  setupUi(this);
18  guideStateWidget = new GuideStateWidget();
19  guideTitleLayout->addWidget(guideStateWidget, 0, Qt::AlignRight);
20 }
21 
22 void GuideManager::init(Guide *guideProcess)
23 {
24  // guide details buttons
25  connect(guideDetailNextButton, &QPushButton::clicked, [this]()
26  {
27  const int pos = guideDetailWidget->currentIndex();
28  if (pos == 0 || (pos == 1 && guideStarPixmap.get() != nullptr))
29  guideDetailWidget->setCurrentIndex(pos + 1);
30  else if (pos > 0)
31  guideDetailWidget->setCurrentIndex(0);
32 
33  updateGuideDetailView();
34  });
35 
36  connect(guideDetailPrevButton, &QPushButton::clicked, [this]()
37  {
38  const int pos = guideDetailWidget->currentIndex();
39  if (pos > 0)
40  guideDetailWidget->setCurrentIndex(pos - 1);
41  else if (guideStarPixmap.get() != nullptr)
42  guideDetailWidget->setCurrentIndex(2);
43  else
44  guideDetailWidget->setCurrentIndex(1);
45 
46  updateGuideDetailView();
47  });
48 
49  // feed guide state widget
50  connect(guideProcess, &Ekos::Guide::newStatus, guideStateWidget, &Ekos::GuideStateWidget::updateGuideStatus);
51 
52  if (!guidePI)
53  {
54  guidePI = new QProgressIndicator(guideProcess);
55  guideTitleLayout->insertWidget(2, guidePI);
56  }
57 
58  // initialize the target rings
59  targetPlot->buildTarget(Options::guiderAccuracyThreshold());
60 
61 
62  // establish connections to receive guiding data
63  driftGraph->connectGuider(guideProcess->getGuiderInstance());
64  targetPlot->connectGuider(guideProcess->getGuiderInstance());
65 
66  // connect to Guide UI controls
67  //This connects all the buttons and slider below the guide plots.
68  connect(guideProcess->showRAPlotCheck, &QCheckBox::toggled, [this](bool isChecked)
69  {
70  driftGraph->toggleShowPlot(GuideGraph::G_RA, isChecked);
71  });
72  connect(guideProcess->showDECPlotCheck, &QCheckBox::toggled, [this](bool isChecked)
73  {
74  driftGraph->toggleShowPlot(GuideGraph::G_DEC, isChecked);
75  });
76  connect(guideProcess->showRACorrectionsCheck, &QCheckBox::toggled, [this](bool isChecked)
77  {
78  driftGraph->toggleShowPlot(GuideGraph::G_RA_PULSE, isChecked);
79  });
80  connect(guideProcess->showDECorrectionsCheck, &QCheckBox::toggled, [this](bool isChecked)
81  {
82  driftGraph->toggleShowPlot(GuideGraph::G_DEC_PULSE, isChecked);
83  });
84  connect(guideProcess->showSNRPlotCheck, &QCheckBox::toggled, [this](bool isChecked)
85  {
86  driftGraph->toggleShowPlot(GuideGraph::G_SNR, isChecked);
87  });
88  connect(guideProcess->showRMSPlotCheck, &QCheckBox::toggled, [this](bool isChecked)
89  {
90  driftGraph->toggleShowPlot(GuideGraph::G_RMS, isChecked);
91  });
92  connect(guideProcess->correctionSlider, &QSlider::sliderMoved, driftGraph, &GuideDriftGraph::setCorrectionGraphScale);
93 
94  connect(guideProcess->latestCheck, &QCheckBox::toggled, targetPlot, &GuideTargetPlot::setLatestGuidePoint);
95  connect(guideProcess->accuracyRadiusSpin, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), targetPlot,
96  &GuideTargetPlot::buildTarget);
97 
98 
99 }
100 
101 
102 void GuideManager::updateGuideStatus(Ekos::GuideState status)
103 {
104  guideStatus->setText(Ekos::getGuideStatusString(status));
105 
106  switch (status)
107  {
108  case Ekos::GUIDE_IDLE:
109  case Ekos::GUIDE_CALIBRATION_ERROR:
110  case Ekos::GUIDE_ABORTED:
111  case Ekos::GUIDE_SUSPENDED:
112  case Ekos::GUIDE_DITHERING_ERROR:
113  case Ekos::GUIDE_CALIBRATION_SUCCESS:
114  if (guidePI->isAnimated())
115  guidePI->stopAnimation();
116  break;
117 
118  case Ekos::GUIDE_CALIBRATING:
119  guidePI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor")));
120  if (guidePI->isAnimated() == false)
121  guidePI->startAnimation();
122  break;
123  case Ekos::GUIDE_GUIDING:
124  guidePI->setColor(Qt::darkGreen);
125  if (guidePI->isAnimated() == false)
126  guidePI->startAnimation();
127  targetPlot->clear();
128  driftGraph->clear();
129  break;
130  case Ekos::GUIDE_DITHERING:
131  guidePI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor")));
132  if (guidePI->isAnimated() == false)
133  guidePI->startAnimation();
134  break;
135  case Ekos::GUIDE_DITHERING_SUCCESS:
136  guidePI->setColor(Qt::darkGreen);
137  if (guidePI->isAnimated() == false)
138  guidePI->startAnimation();
139  break;
140 
141  default:
142  if (guidePI->isAnimated())
143  guidePI->stopAnimation();
144  break;
145  }
146 
147 }
148 
149 
150 
151 void GuideManager::updateGuideStarPixmap(QPixmap &starPix)
152 {
153  if (starPix.isNull())
154  return;
155 
156  guideStarPixmap.reset(new QPixmap(starPix));
157  updateGuideDetailView();
158 }
159 
160 void GuideManager::updateSigmas(double ra, double de)
161 {
162  errRA->setText(QString::number(ra, 'f', 2) + "\"");
163  errDEC->setText(QString::number(de, 'f', 2) + "\"");
164 }
165 
166 void GuideManager::updateGuideDetailView()
167 {
168  const int pos = guideDetailWidget->currentIndex();
169  if (pos == 2 && guideStarPixmap.get() != nullptr)
170  guideStarView->setPixmap(guideStarPixmap.get()->scaled(guideStarView->width(), guideStarView->height(),
172 }
173 
174 void GuideManager::reset()
175 {
176  guideStatus->setText(i18n("Idle"));
177 
178  if (guidePI)
179  guidePI->stopAnimation();
180 }
181 
182 }
AlignRight
QString number(int n, int base)
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:66
void clicked(bool checked)
void valueChanged(double d)
void toggled(bool checked)
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
KeepAspectRatio
QString i18n(const char *text, const TYPE &arg...)
void sliderMoved(int value)
bool isNull() const const
SmoothTransformation
darkGreen
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.