12#include "rotatorsettings.h"
15#include "kstarsdata.h"
16#include "ekos/manager.h"
17#include "indi/indirotator.h"
19#include <basedevice.h>
22#include "ekos/align/align.h"
23#include "ekos/capture/capturedeviceadaptor.h"
24#include "ekos/align/opsalign.h"
25#include "ekos/auxiliary/rotatorutils.h"
27#include "ekos_capture_debug.h"
33 connect(
this, &RotatorSettings::newLog, Ekos::Manager::Instance()->captureModule(), &Ekos::Capture::appendLogText);
34 connect(RotatorUtils::Instance(), &RotatorUtils::changedPierside,
this, &RotatorSettings::updateGaugeZeroPos);
41 CameraPA->setKeyboardTracking(
false);
44 double RAngle = RotatorUtils::Instance()->calcRotatorAngle(PAngle);
45 RotatorAngle->setValue(RAngle);
47 activateRotator(RAngle);
48 CameraPASlider->setSliderPosition(PAngle * 100);
52 CameraPA->setValue(CameraPASlider->sliderPosition() / 100.0);
56 double PAngle = PAngle100 / 100;
57 paGauge->setValue(-(PAngle));
65 commitRotatorDirection(toggled);
69 rotatorGauge->setFormat(
"R");
70 rotatorGauge->setMinimum(-360);
71 rotatorGauge->setMaximum(0);
74 paGauge->setFormat(
"P");
75 paGauge->setMinimum(-181);
76 paGauge->setMaximum(181);
79 paRuler->plotLayout()->clear();
82 QColor TransparentBlack(0, 0, 0, 100);
83 QPen Pen(TransparentBlack, 3);
90 paRuler->plotLayout()->addElement(0, 0, angularAxis);
91 paRuler->setBackground(Qt::GlobalColor::transparent);
97 CameraPA->setMaximum(180.00);
98 CameraPA->setMinimum(-179.99);
100 CameraOffset->setValue(Options::pAOffset());
102 MountPierside->setCurrentIndex(ISD::Mount::PIER_UNKNOWN);
103 MountPierside->setDisabled(
true);
106void RotatorSettings::initRotator(
const QString &train, Ekos::CaptureDeviceAdaptor *CaptureDA,
ISD::Rotator *device)
108 m_CaptureDA = CaptureDA;
109 RotatorUtils::Instance()->initRotatorUtils(train);
112 RotatorName->setText(m_Rotator->getDeviceName());
113 updateFlipPolicy(Options::astrometryFlipRotationAllowed());
117 if (m_CaptureDA->getRotatorAngleState() < IPS_BUSY)
119 double RAngle = m_CaptureDA->getRotatorAngle();
120 updateRotator(RAngle);
121 updateGaugeZeroPos(RotatorUtils::Instance()->getMountPierside());
122 qCInfo(KSTARS_EKOS_CAPTURE()) <<
"Rotator Settings: Initial raw angle is" << RAngle <<
".";
123 emit newLog(
i18n(
"Initial rotator angle %1° is read in successfully.", RAngle));
126 qCWarning(KSTARS_EKOS_CAPTURE()) <<
"Rotator Settings: Reading initial raw angle failed.";
130void RotatorSettings::updateRotator(
double RAngle)
132 RotatorAngle->setValue(RAngle);
133 double PAngle = RotatorUtils::Instance()->calcCameraAngle(RAngle,
false);
134 CameraPA->blockSignals(
true);
135 CameraPA->setValue(PAngle);
136 CameraPA->blockSignals(
false);
137 CameraPASlider->setSliderPosition(PAngle * 100);
141void RotatorSettings::updateGauge(
double RAngle)
143 rotatorGauge->setValue(-RAngle);
145 paGauge->setValue(-(RotatorUtils::Instance()->calcCameraAngle(RAngle,
false)));
148void RotatorSettings::updateGaugeZeroPos(ISD::Mount::PierSide Pierside)
151 if (Pierside == ISD::Mount::PIER_UNKNOWN)
152 MountPierside->setStyleSheet(
"QComboBox {border: 1px solid red;}");
154 MountPierside->setStyleSheet(
"QComboBox {}");
155 MountPierside->setCurrentIndex(Pierside);
156 if (Pierside == ISD::Mount::PIER_WEST)
157 rotatorGauge->setNullPosition(QRoundProgressBar::PositionTop);
158 else if (Pierside == ISD::Mount::PIER_EAST)
159 rotatorGauge->setNullPosition(QRoundProgressBar::PositionBottom);
160 if (Options::astrometryFlipRotationAllowed())
161 RAngle = RotatorAngle->value();
164 RAngle = RotatorUtils::Instance()->calcRotatorAngle(CameraPA->value());
165 activateRotator(RAngle);
168 updateRotator(RAngle);
171void RotatorSettings::setFlipPolicy(
const int index)
173 Ekos::OpsAlign::FlipPriority Priority =
static_cast<Ekos::OpsAlign::FlipPriority
>(index);
174 Ekos::OpsAlign *AlignOptionsModule = Ekos::Manager::Instance()->alignModule()->getAlignOptionsModule();
175 if (AlignOptionsModule)
176 AlignOptionsModule->setFlipPolicy(Priority);
179void RotatorSettings::updateFlipPolicy(
const bool FlipRotationAllowed)
182 if (FlipRotationAllowed)
183 i =
static_cast<int>(Ekos::OpsAlign::FlipPriority::ROTATOR_ANGLE);
185 i =
static_cast<int>(Ekos::OpsAlign::FlipPriority::POSITION_ANGLE);
186 FlipPolicy->blockSignals(
true);
187 FlipPolicy->setCurrentIndex(i);
188 FlipPolicy->blockSignals(
false);
191void RotatorSettings::showAlignOptions()
196 alignSettings->setEnabled(
true);
197 alignSettings->show();
201void RotatorSettings::activateRotator(
double Angle)
203 m_CaptureDA->setRotatorAngle(Angle);
206void RotatorSettings::commitRotatorDirection(
bool Reverse)
208 m_CaptureDA->reverseRotator(Reverse);
211void RotatorSettings::refresh(
double PAngle)
213 CameraPA->setValue(PAngle);
215 CameraOffset->setValue(Options::pAOffset());
218void RotatorSettings::syncFOV(
double PA)
220 for (
auto oneFOV : KStarsData::Instance()->getTransientFOVs())
223 if (oneFOV->objectName() ==
"sensor_fov")
226 if (!Options::showSensorFOV())
228 Options::setShowSensorFOV(
true);
229 oneFOV->setProperty(
"visible",
true);
Rotator class handles control of INDI Rotator devices.
static KConfigDialog * exists(const QString &name)
The main container for polar plots, representing the angular axis as a circle.
void setTickPen(const QPen &pen)
void setTickLabels(bool show)
void setSubTickPen(const QPen &pen)
void setTickLength(int inside, int outside=0)
void setSubTickLength(int inside, int outside=0)
bool removeRadialAxis(QCPPolarAxisRadial *axis)
void setBasePen(const QPen &pen)
QCPPolarAxisRadial * radialAxis(int index=0) const
void setAngularPen(const QPen &pen)
QString i18n(const char *text, const TYPE &arg...)
void valueChanged(int value)
void currentIndexChanged(int index)
void valueChanged(double d)
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)