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

KDE's Doxygen guidelines are available online.