Kstars

opsastrometry.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 Jasem Mutlaq <[email protected]>
3  SPDX-FileCopyrightText: 2017 Robert Lancaster <[email protected]>
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 
16 namespace Ekos
17 {
18 OpsAstrometry::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 
51 void 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.
62 void 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.
102 void OpsAstrometry::slotUpdatePosition()
103 {
104  estRA->setText(alignModule->ScopeRAOut->text());
105  estDec->setText(alignModule->ScopeDecOut->text());
106 }
107 
108 void 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 }
virtual void setD(const double &x)
Sets floating-point value of angle, in degrees.
Definition: dms.h:179
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
Definition: dms.cpp:370
void setHidden(bool hidden)
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
Definition: dms.cpp:279
static KConfigDialog * exists(const QString &name)
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
void setupUi(QWidget *widget)
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
const double & Degrees() const
Definition: dms.h:141
QObject * parent() const const
WA_LayoutUsesWidgetRect
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.