File indexing completed on 2024-04-28 15:09:53
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikartech.com> 0003 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "focusmanager.h" 0009 #include "kstarsdata.h" 0010 #include "Options.h" 0011 0012 namespace Ekos 0013 { 0014 FocusManager::FocusManager(QWidget * parent) : QWidget(parent) 0015 { 0016 setupUi(this); 0017 } 0018 0019 void FocusManager::updateCurrentHFR(double newHFR) 0020 { 0021 currentHFR->setText(QString("%1").arg(newHFR, 0, 'f', 2) + " px"); 0022 profilePlot->drawProfilePlot(newHFR); 0023 } 0024 0025 void FocusManager::updateFocusDetailView() 0026 { 0027 const int pos = focusDetailView->currentIndex(); 0028 if (pos == 1 && focusStarPixmap.get() != nullptr) 0029 { 0030 focusStarView->setPixmap(focusStarPixmap.get()->scaled(focusDetailView->width(), focusDetailView->height(), 0031 Qt::KeepAspectRatio, Qt::SmoothTransformation)); 0032 } 0033 } 0034 0035 void FocusManager::updateFocusStarPixmap(QPixmap &starPixmap) 0036 { 0037 if (starPixmap.isNull()) 0038 return; 0039 0040 focusStarPixmap.reset(new QPixmap(starPixmap)); 0041 updateFocusDetailView(); 0042 } 0043 0044 void FocusManager::updateFocusStatus(Ekos::FocusState status) 0045 { 0046 focusStatus->setFocusState(status); 0047 } 0048 0049 void FocusManager::init() 0050 { 0051 0052 // focus details buttons 0053 connect(focusDetailNextButton, &QPushButton::clicked, [this]() 0054 { 0055 const int pos = focusDetailView->currentIndex(); 0056 if (pos == 0 || (pos == 1 && focusStarPixmap.get() != nullptr)) 0057 focusDetailView->setCurrentIndex(pos + 1); 0058 else if (pos > 0) 0059 focusDetailView->setCurrentIndex(0); 0060 updateFocusDetailView(); 0061 }); 0062 connect(focusDetailPrevButton, &QPushButton::clicked, [this]() 0063 { 0064 const int pos = focusDetailView->currentIndex(); 0065 if (pos == 0 && focusStarPixmap.get() != nullptr) 0066 focusDetailView->setCurrentIndex(pos + 2); 0067 else if (pos == 0) 0068 focusDetailView->setCurrentIndex(pos + 1); 0069 else if (pos > 0) 0070 focusDetailView->setCurrentIndex(pos - 1); 0071 updateFocusDetailView(); 0072 }); 0073 } 0074 0075 void FocusManager::reset() 0076 { 0077 focusStatus->setFocusState(FOCUS_IDLE); 0078 } 0079 0080 } // namespace Ekos