Kstars

rotatorsettings.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 
8 #include "rotatorsettings.h"
9 #include "Options.h"
10 #include "fov.h"
11 #include "kstarsdata.h"
12 #include "ekos/auxiliary/solverutils.h"
13 
14 #include <indicom.h>
15 #include <basedevice.h>
16 #include <cmath>
17 
18 RotatorSettings::RotatorSettings(QWidget *parent) : QDialog(parent)
19 {
20  setupUi(this);
21 
22  rotatorGauge->setFormat("%v");
23  rotatorGauge->setMinimum(0);
24  rotatorGauge->setMaximum(360);
25 
26  connect(angleSlider, &QSlider::valueChanged, this, [this](int angle)
27  {
28  angleSpin->setValue(angle);
29  });
30 
31  PAMulSpin->setValue(Options::pAMultiplier());
32  PAOffsetSpin->setValue(Options::pAOffset());
33 
34  syncFOVPA->setChecked(Options::syncFOVPA());
35  connect(syncFOVPA, &QCheckBox::toggled, this, [this](bool toggled)
36  {
37  Options::setSyncFOVPA(toggled);
38  if (toggled) syncPA(targetPASpin->value());
39  });
40 
41  connect(enforceRotationCheck, SIGNAL(toggled(bool)), targetPASpin, SLOT(setEnabled(bool)));
42  connect(targetPASpin, SIGNAL(valueChanged(double)), this, SLOT(syncPA(double)));
43  connect(PAMulSpin, &QSpinBox::editingFinished, this, [this]()
44  {
45  Options::setPAMultiplier(PAMulSpin->value());
46  updatePA();
47  });
48 
49  connect(PAOffsetSpin, &QSpinBox::editingFinished, this, [this]()
50  {
51  Options::setPAOffset(PAOffsetSpin->value());
52  updatePA();
53  });
54 }
55 
56 
57 void RotatorSettings::setCurrentAngle(double angle)
58 {
59  angleEdit->setText(QString::number(angle, 'f', 3));
60  rawAngle->setText(QString::number(angle, 'f', 3));
61  rotatorGauge->setValue(angle);
62  updatePA();
63 }
64 
65 void RotatorSettings::updatePA()
66 {
67  // 1. PA = (RawAngle * Multiplier) - Offset
68  // 2. Offset = (RawAngle * Multiplier) - PA
69  // 3. RawAngle = (Offset + PA) / Multiplier
70  double PA = SolverUtils::rangePA((rotatorGauge->value() * PAMulSpin->value()) - PAOffsetSpin->value());
71  PAOut->setText(QString::number(PA, 'f', 3));
72 }
73 
74 void RotatorSettings::refresh()
75 {
76  PAMulSpin->setValue(Options::pAMultiplier());
77  PAOffsetSpin->setValue(Options::pAOffset());
78  updatePA();
79 }
80 
81 void RotatorSettings::syncPA(double PA)
82 {
83  if (syncFOVPA->isChecked())
84  {
85  for (auto oneFOV : KStarsData::Instance()->getTransientFOVs())
86  {
87  // Only change the PA for the sensor FOV
88  if (oneFOV->objectName() == "sensor_fov")
89  {
90  // Make sure that it is always displayed
91  if (!Options::showSensorFOV())
92  {
93  Options::setShowSensorFOV(true);
94  oneFOV->setProperty("visible", true);
95  }
96 
97  // JM 2020-10-15
98  // While we have the correct Position Angle
99  // Because Ekos reads frame TOP-BOTTOM instead of the BOTTOM-TOP approach
100  // used by astrometry, the PA is always 180 degree off. To avoid confusion to the user
101  // the PA is drawn REVERSED to show the *expected* frame. However, the final PA is
102  // the "correct" PA as expected by astrometry.
103  //double drawnPA = PA >= 0 ? (PA - 180) : (PA + 180);
104  oneFOV->setPA(PA);
105  break;
106  }
107  }
108  }
109 }
QString number(int n, int base)
void toggled(bool checked)
void editingFinished()
void valueChanged(int value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.