Kstars

opsastrometry.cpp
1/*
2 SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 SPDX-FileCopyrightText: 2017 Robert Lancaster <rlancaste@gmail.com>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#include "opsastrometry.h"
9
10#include "align.h"
11#include "kstars.h"
12#include "Options.h"
13
14#include <KConfigDialog>
15
16namespace Ekos
17{
18OpsAstrometry::OpsAstrometry(Align *parent) : QWidget(KStars::Instance())
19{
20 setupUi(this);
21
22 alignModule = parent;
23
24 //Get a pointer to the KConfigDialog
25 m_ConfigDialog = KConfigDialog::exists("alignsettings");
26
27 dms ra, de;
28 ra.setD(Options::astrometryPositionRA());
29 de.setD(Options::astrometryPositionDE());
30
31 estRA->setText(ra.toHMSString());
32 estDec->setText(de.toDMSString());
33
34 imageWarningLabel->setHidden(kcfg_AstrometryAutoUpdateImageScale->isChecked());
35 positionWarningLabel->setHidden(kcfg_AstrometryAutoUpdatePosition->isChecked());
36
37 connect(kcfg_AstrometryAutoUpdateImageScale, SIGNAL(toggled(bool)), imageWarningLabel, SLOT(setHidden(bool)));
38 connect(kcfg_AstrometryAutoUpdatePosition, SIGNAL(toggled(bool)), positionWarningLabel, SLOT(setHidden(bool)));
39
40 connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
41 connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
42
43 connect(updateScale, SIGNAL(clicked()), this, SLOT(slotUpdateScale()));
44 connect(updatePosition, SIGNAL(clicked()), this, SLOT(slotUpdatePosition()));
45 updateScale->setIcon(QIcon::fromTheme("edit-copy"));
46 updateScale->setAttribute(Qt::WA_LayoutUsesWidgetRect);
47 updatePosition->setIcon(QIcon::fromTheme("edit-copy"));
48 updatePosition->setAttribute(Qt::WA_LayoutUsesWidgetRect);
49}
50
51void OpsAstrometry::showEvent(QShowEvent *)
52{
53 dms ra, de;
54 ra.setD(Options::astrometryPositionRA());
55 de.setD(Options::astrometryPositionDE());
56
57 estRA->setText(ra.toHMSString());
58 estDec->setText(de.toDMSString());
59}
60
61//This updates the telescope/image field scale in the astrometry options editor to match the currently connected devices.
62void OpsAstrometry::slotUpdateScale()
63{
64 double fov_w, fov_h, fov_pixscale;
65
66 // Values in arcmins. Scale in arcsec per pixel
67 alignModule->getCalculatedFOVScale(fov_w, fov_h, fov_pixscale);
68
69 if (fov_w == 0 || fov_h == 0)
70 {
71 kcfg_AstrometryImageScaleLow->setValue(0);
72 kcfg_AstrometryImageScaleHigh->setValue(0);
73 return;
74 }
75
76 switch (kcfg_AstrometryImageScaleUnits->currentIndex())
77 {
78 case SSolver::DEG_WIDTH:
79 fov_w /= 60;
80 fov_h /= 60;
81 kcfg_AstrometryImageScaleLow->setValue(qMin(fov_w, fov_h));
82 kcfg_AstrometryImageScaleHigh->setValue(qMax(fov_w, fov_h));
83 break;
84
85 case SSolver::ARCMIN_WIDTH:
86 kcfg_AstrometryImageScaleLow->setValue(qMin(fov_w, fov_h));
87 kcfg_AstrometryImageScaleHigh->setValue(qMax(fov_w, fov_h));
88 break;
89
90 case SSolver::ARCSEC_PER_PIX:
91 // 10% range
92 kcfg_AstrometryImageScaleLow->setValue(fov_pixscale * 0.9);
93 kcfg_AstrometryImageScaleHigh->setValue(fov_pixscale * 1.1);
94 break;
95
96 default:
97 return;
98 }
99}
100
101//This updates the RA and DEC position in the astrometry options editor to match the current telescope position.
102void OpsAstrometry::slotUpdatePosition()
103{
104 estRA->setText(alignModule->ScopeRAOut->text());
105 estDec->setText(alignModule->ScopeDecOut->text());
106}
107
108void OpsAstrometry::slotApply()
109{
110 //if (Options::solverBackend() != 1)
111 // return;
112
113 bool raOK = false, deOK = false;
114 dms RA = estRA->createDms(&raOK);
115 dms DE = estDec->createDms(&deOK);
116
117 if (raOK && deOK)
118 {
119 Options::setAstrometryPositionRA(RA.Degrees());
120 Options::setAstrometryPositionDE(DE.Degrees());
121 }
122
123 //alignModule->generateArgs();
124}
125}
static KConfigDialog * exists(const QString &name)
This is the main window for KStars.
Definition kstars.h:89
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
Definition dms.cpp:287
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
Definition dms.cpp:378
virtual void setD(const double &x)
Sets floating-point value of angle, in degrees.
Definition dms.h:179
const double & Degrees() const
Definition dms.h:141
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
QIcon fromTheme(const QString &name)
WA_LayoutUsesWidgetRect
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 Fri Nov 29 2024 11:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.