Kstars

focusmanager.cpp
1 /*
2  SPDX-FileCopyrightText: 2012 Jasem Mutlaq <[email protected]>
3  SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "focusmanager.h"
9 #include "kstarsdata.h"
10 #include "Options.h"
11 
12 namespace Ekos
13 {
14 FocusManager::FocusManager(QWidget * parent) : QWidget(parent)
15 {
16  setupUi(this);
17 }
18 
19 void FocusManager::updateCurrentHFR(double newHFR)
20 {
21  currentHFR->setText(QString("%1").arg(newHFR, 0, 'f', 2) + " px");
22  profilePlot->drawProfilePlot(newHFR);
23 }
24 
25 void FocusManager::updateFocusDetailView()
26 {
27  const int pos = focusDetailView->currentIndex();
28  if (pos == 1 && focusStarPixmap.get() != nullptr)
29  {
30  focusStarView->setPixmap(focusStarPixmap.get()->scaled(focusDetailView->width(), focusDetailView->height(),
32  }
33 }
34 
35 void FocusManager::stopAnimation()
36 {
37  if (focusPI->isAnimated())
38  focusPI->stopAnimation();
39 }
40 
41 void FocusManager::updateFocusStarPixmap(QPixmap &starPixmap)
42 {
43  if (starPixmap.isNull())
44  return;
45 
46  focusStarPixmap.reset(new QPixmap(starPixmap));
47  updateFocusDetailView();
48 }
49 
50 void FocusManager::updateFocusStatus(Ekos::FocusState status)
51 {
52  focusStatus->setText(Ekos::getFocusStatusString(status));
53 
54  if (status >= Ekos::FOCUS_PROGRESS)
55  {
56  focusPI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor")));
57  if (focusPI->isAnimated() == false)
58  focusPI->startAnimation();
59  }
60  else if (status == Ekos::FOCUS_COMPLETE && Options::enforceAutofocus())
61  {
62  focusPI->setColor(Qt::darkGreen);
63  if (focusPI->isAnimated() == false)
64  focusPI->startAnimation();
65  }
66  else
67  {
68  if (focusPI->isAnimated())
69  focusPI->stopAnimation();
70  }
71 }
72 
73 void FocusManager::init(Focus *focusProcess)
74 {
75 
76  // focus details buttons
77  connect(focusDetailNextButton, &QPushButton::clicked, [this]() {
78  const int pos = focusDetailView->currentIndex();
79  if (pos == 0 || (pos == 1 && focusStarPixmap.get() != nullptr))
80  focusDetailView->setCurrentIndex(pos+1);
81  else if (pos > 0)
82  focusDetailView->setCurrentIndex(0);
83  updateFocusDetailView();
84  });
85  connect(focusDetailPrevButton, &QPushButton::clicked, [this]() {
86  const int pos = focusDetailView->currentIndex();
87  if (pos == 0 && focusStarPixmap.get() != nullptr)
88  focusDetailView->setCurrentIndex(pos+2);
89  else if (pos == 0)
90  focusDetailView->setCurrentIndex(pos+1);
91  else if (pos > 0)
92  focusDetailView->setCurrentIndex(pos-1);
93  updateFocusDetailView();
94  });
95 
96  if (!focusPI)
97  {
98  focusPI = new QProgressIndicator(focusProcess);
99  focusTitleLayout->insertWidget(2, focusPI);
100  }
101 
102 }
103 
104 void FocusManager::reset()
105 {
106  focusStatus->setText(i18n("Idle"));
107 
108  if (focusPI)
109  focusPI->stopAnimation();
110 }
111 
112 } // namespace Ekos
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
void clicked(bool checked)
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
KeepAspectRatio
QString i18n(const char *text, const TYPE &arg...)
void setupUi(QWidget *widget)
bool isNull() const const
SmoothTransformation
darkGreen
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:01:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.