Kstars

sequenceeditor.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "sequenceeditor.h"
8
9#include "camera.h"
10#include "ekos/auxiliary/opticaltrainsettings.h"
11#include <kstars_debug.h>
12
13// These strings are used to store information in the optical train
14// for later use in the stand-alone esq editor.
15#define KEY_FILTERS "filtersList"
16#define KEY_FORMATS "formatsList"
17#define KEY_ISOS "isoList"
18#define KEY_INDEX "isoIndex"
19#define KEY_H "captureFrameHN"
20#define KEY_W "captureFrameWN"
21#define KEY_GAIN_KWD "ccdGainKeyword"
22#define KEY_OFFSET_KWD "ccdOffsetKeyword"
23#define KEY_TEMPERATURE "ccdTemperatures"
24#define KEY_TIMESTAMP "timestamp"
25
26namespace
27{
28
29// Columns in the job table
30// Adds the items to the QComboBox if they're not there already.
31void addToCombo(QComboBox *combo, const QStringList &items)
32{
33 if (items.size() == 0)
34 return;
35 QStringList existingItems;
36 for (int index = 0; index < combo->count(); index++)
37 existingItems << combo->itemText(index);
38
39 for (const auto &item : items)
40 if (existingItems.indexOf(item) == -1)
41 combo->addItem(item);
42}
43
44} // namespace
45namespace Ekos
46{
47
48SequenceEditor::SequenceEditor(QWidget * parent) : QDialog(parent)
49{
50#ifdef Q_OS_MACOS
51 setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
52#endif
53 setupUi(this);
54
55 // initialize standalone camera
56 m_camera.reset(new Camera(true));
57 initStandAlone();
58 sequenceEditorLayout->insertWidget(1, m_camera.get());
59}
60void SequenceEditor::showEvent(QShowEvent* event)
61{
62 QWidget::showEvent(event);
63 onStandAloneShow();
64 m_camera->onStandAloneShow(event);
65}
66
67void SequenceEditor::initStandAlone()
68{
69 QSharedPointer<Camera> mainCam = m_camera;
70 mainCam->processGrid->setVisible(false);
71 mainCam->loadSaveBox->setVisible(true);
72 mainCam->loadSaveBox->setEnabled(true);
73 mainCam->horizontalSpacer_SQ2->changeSize(0, 0);
74
75 QList<QWidget*> unusedWidgets =
76 {
77 mainCam->opticalTrainCombo, mainCam->trainB, mainCam->restartCameraB, mainCam->clearConfigurationB, mainCam->resetFrameB, mainCam->opticalTrainLabel,
78 mainCam->coolerOnB, mainCam->coolerOffB, mainCam->setTemperatureB, mainCam->temperatureRegulationB, mainCam->temperatureOUT,
79 mainCam->previewB, mainCam->loopB, mainCam->liveVideoB, mainCam->startB, mainCam->pauseB,
80 mainCam->previewLabel, mainCam->loopLabel, mainCam->videoLabel,
81 mainCam->resetB, mainCam->queueLoadB, mainCam->queueSaveB, mainCam->queueSaveAsB,
82 mainCam->darkB, mainCam->darkLibraryB, mainCam->darksLibraryLabel, mainCam->exposureCalcB, mainCam->exposureCalculationLabel,
83 mainCam->filterManagerB
84 };
85 for (auto &widget : unusedWidgets)
86 {
87 widget->setEnabled(false);
88 widget->setVisible(false);
89 }
90}
91
92void SequenceEditor::onStandAloneShow()
93{
94 OpticalTrainSettings::Instance()->setOpticalTrainID(Options::captureTrainID());
95 auto settings = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Capture);
96 m_Settings = settings.toJsonObject().toVariantMap();
97
99
100 // Default comment if there is no previously saved stand-alone parameters.
101 QString comment = i18n("<b><font color=\"red\">Please run the Capture tab connected to INDI with your desired "
102 "camera/filterbank at least once before using the Sequence Editor. </font></b><p>");
103
104 if (m_Settings.contains(KEY_TIMESTAMP) && m_Settings[KEY_TIMESTAMP].toString().size() > 0)
105 comment = i18n("<b>Using camera and filterwheel attributes from Capture session started at %1.</b>"
106 "<p>If you wish to use other cameras/filterbanks, please edit the sequence "
107 "using the Capture tab.<br>It is not recommended to overwrite a sequence file currently running, "
108 "please rename it instead.</p><p>", m_Settings[KEY_TIMESTAMP].toString());
109 sequenceEditorComment->setVisible(true);
110 sequenceEditorComment->setEnabled(true);
111 sequenceEditorComment->setStyleSheet("{color: #C0BBFE}");
112 sequenceEditorComment->setText(comment);
113
114 // Add extra load and save buttons at the bottom of the window.
115 m_camera->loadSaveBox->setEnabled(true);
116 m_camera->loadSaveBox->setVisible(true);
117 connect(m_camera->esqSaveAsB, &QPushButton::clicked, m_camera.get(),
118 &Camera::saveSequenceQueueAs);
119 connect(m_camera->esqLoadB, &QPushButton::clicked, m_camera.get(),
120 static_cast<void(Camera::*)()>(&Camera::loadSequenceQueue));
121
122 m_camera->FilterPosCombo->clear();
123 if (m_Settings.contains(KEY_FILTERS))
124 addToCombo(m_camera->FilterPosCombo, m_Settings[KEY_FILTERS].toStringList());
125
126 if (m_camera->FilterPosCombo->count() > 0)
127 {
128 m_camera->filterEditB->setEnabled(true);
129 m_camera->filterManagerB->setEnabled(true);
130 }
131
132 m_camera->captureGainN->setEnabled(true);
133 m_camera->captureGainN->setSpecialValueText(i18n("--"));
134
135 m_camera->captureOffsetN->setEnabled(true);
136 m_camera->captureOffsetN->setSpecialValueText(i18n("--"));
137
138 // Always add these strings to the types menu. Might also add other ones
139 // that were used in the last capture session.
140 const QStringList frameTypes = {"Light", "Dark", "Bias", "Flat"};
141 m_camera->captureTypeS->clear();
142 m_camera->captureTypeS->addItems(frameTypes);
143
144 // Always add these strings to the encodings menu. Might also add other ones
145 // that were used in the last capture session.
146 const QStringList frameEncodings = {"FITS", "Native", "XISF"};
147 m_camera->captureEncodingS->clear();
148 m_camera->captureEncodingS->addItems(frameEncodings);
149
150 if (m_Settings.contains(KEY_FORMATS))
151 {
152 m_camera->captureFormatS->clear();
153 addToCombo(m_camera->captureFormatS, m_Settings[KEY_FORMATS].toStringList());
154 }
155
156 m_camera->cameraTemperatureN->setEnabled(true);
157 m_camera->cameraTemperatureN->setReadOnly(false);
158 m_camera->cameraTemperatureN->setSingleStep(1);
159 m_camera->cameraTemperatureS->setEnabled(true);
160
161 double minTemp = -50, maxTemp = 50;
162 if (m_Settings.contains(KEY_TEMPERATURE))
163 {
164 QStringList temperatureList = m_Settings[KEY_TEMPERATURE].toStringList();
165 if (temperatureList.size() > 1)
166 {
167 minTemp = temperatureList[0].toDouble();
168 maxTemp = temperatureList[1].toDouble();
169 }
170 }
171 m_camera->cameraTemperatureN->setMinimum(minTemp);
172 m_camera->cameraTemperatureN->setMaximum(maxTemp);
173
174 // No pre-configured ISOs are available--would be too much of a guess, but
175 // we will use ISOs from the last live capture session.
176
177 if (m_Settings.contains(KEY_ISOS))
178 {
179 QStringList isoList = m_Settings[KEY_ISOS].toStringList();
180 m_camera->captureISOS->clear();
181 if (isoList.size() > 0)
182 {
183 m_camera->captureISOS->addItems(isoList);
184 if (m_Settings.contains(KEY_INDEX))
185 m_camera->captureISOS->setCurrentIndex(m_Settings[KEY_INDEX].toString().toInt());
186 else
187 m_camera->captureISOS->setCurrentIndex(0);
188 m_camera->captureISOS->blockSignals(false);
189 m_camera->captureISOS->setEnabled(true);
190 }
191 }
192 else
193 {
194 m_camera->captureISOS->blockSignals(true);
195 m_camera->captureISOS->clear();
196 m_camera->captureISOS->setEnabled(false);
197 }
198
199 // Remember the sensor width and height from the last live session.
200 // The user can always edit the input box.
201 constexpr int maxFrame = 20000;
202 m_camera->captureFrameXN->setMaximum(static_cast<int>(maxFrame));
203 m_camera->captureFrameYN->setMaximum(static_cast<int>(maxFrame));
204 m_camera->captureFrameWN->setMaximum(static_cast<int>(maxFrame));
205 m_camera->captureFrameHN->setMaximum(static_cast<int>(maxFrame));
206
207 if (m_Settings.contains(KEY_H))
208 m_camera->captureFrameHN->setValue(m_Settings[KEY_H].toUInt());
209
210 if (m_Settings.contains(KEY_W))
211 m_camera->captureFrameWN->setValue(m_Settings[KEY_W].toUInt());
212}
213
214}
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
void clicked(bool checked)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
QString itemText(int index) const const
void clear()
qsizetype size() const const
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
virtual void showEvent(QShowEvent *event)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.