File indexing completed on 2024-04-28 15:09:02

0001 /*  Ekos Alignment Manual Rotator
0002     SPDX-FileCopyrightText: 2021 Rick Bassham
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 
0008 #include "manualrotator.h"
0009 
0010 #include "align.h"
0011 #include "ksnotification.h"
0012 #include "ksmessagebox.h"
0013 
0014 // Options
0015 #include "Options.h"
0016 
0017 #include <QIcon>
0018 #include <ekos_align_debug.h>
0019 
0020 namespace Ekos
0021 {
0022 
0023 ManualRotator::ManualRotator(Align *parent) : QDialog(parent)
0024 {
0025     setupUi(this);
0026 
0027     m_AlignInstance = parent;
0028     //setWindowFlags(Qt::WindowStaysOnTopHint);
0029     connect(takeImageB, &QPushButton::clicked, this, &Ekos::ManualRotator::captureAndSolve);
0030     connect(cancelB, &QPushButton::clicked, this, &QDialog::reject);
0031 
0032 }
0033 
0034 ManualRotator::~ManualRotator()
0035 {
0036 
0037 }
0038 
0039 void ManualRotator::setRotatorDiff(double current, double target, double diff)
0040 {
0041     double threshold = Options::astrometryRotatorThreshold() / 60.0;
0042     QString iconName;
0043 
0044     if (std::abs(diff) < threshold)
0045     {
0046         iconName = "checkmark";
0047         diffLabel->setText(i18n("Done"));
0048     }
0049     else
0050     {
0051         diffLabel->setText(i18n("%1°", QString::number(diff, 'f', 1)));
0052         iconName = (diff < 0.0) ? "object-rotate-left" : "object-rotate-right";
0053     }
0054 
0055     icon->setPixmap(QIcon::fromTheme(iconName).pixmap(300, 300));
0056     targetRotation->setText(i18n("%1°", QString::number(target, 'f', 1)));
0057     currentRotation->setText(i18n("%1°", QString::number(current, 'f', 1)));
0058 }
0059 
0060 }