8#include "capturepreviewwidget.h"
9#include "sequencejob.h"
10#include <ekos_capture_debug.h>
12#include "ksmessagebox.h"
13#include "ekos/mount/mount.h"
16#include "sequencejob.h"
17#include "fitsviewer/fitsdata.h"
18#include "fitsviewer/summaryfitsview.h"
19#include "ekos/scheduler/schedulerjob.h"
20#include "ekos/scheduler/schedulermodulestate.h"
22using Ekos::SequenceJob;
24CapturePreviewWidget::CapturePreviewWidget(
QWidget *parent) :
QWidget(parent)
28 m_overlay->setVisible(
false);
38 trainSelectionCB->setVisible(
false);
41void CapturePreviewWidget::shareCaptureModule(
Ekos::Capture *module)
43 m_captureModule =
module;
44 captureCountsWidget->shareCaptureProcess(module);
46 trainSelectionCB->clear();
48 trainSelectionCB->setVisible(
false);
49 captureLabel->setVisible(
true);
51 if (m_captureModule !=
nullptr)
53 connect(m_captureModule, &Ekos::Capture::newDownloadProgress,
this, &CapturePreviewWidget::updateDownloadProgress);
54 connect(m_captureModule, &Ekos::Capture::newExposureProgress,
this, &CapturePreviewWidget::updateExposureProgress);
55 connect(m_captureModule, &Ekos::Capture::captureTarget,
this, &CapturePreviewWidget::setTargetName);
61 m_schedulerModuleState = state;
62 captureCountsWidget->shareSchedulerState(state);
65void CapturePreviewWidget::shareMountModule(
Ekos::Mount *module)
67 m_mountModule =
module;
75 if (!m_trainNames.
contains(trainname))
77 m_trainNames.
append(trainname);
78 trainSelectionCB->addItem(trainname);
80 trainSelectionCB->setVisible(m_trainNames.
count() >= 2);
81 captureLabel->setVisible(m_trainNames.
count() < 2);
87 m_currentFrame[trainname].frameType = job->getFrameType();
88 if (job->getFrameType() == FRAME_LIGHT)
90 if (m_schedulerModuleState !=
nullptr && m_schedulerModuleState->activeJob() !=
nullptr)
91 m_currentFrame[trainname].target = m_schedulerModuleState->activeJob()->getName();
93 m_currentFrame[trainname].target = m_mountTarget;
97 m_currentFrame[trainname].target =
"";
100 m_currentFrame[trainname].filterName = job->getCoreProperty(SequenceJob::SJ_Filter).
toString();
101 m_currentFrame[trainname].exptime = job->getCoreProperty(SequenceJob::SJ_Exposure).
toDouble();
102 m_currentFrame[trainname].targetdrift = -1.0;
103 m_currentFrame[trainname].binning = job->getCoreProperty(SequenceJob::SJ_Binning).
toPoint();
104 m_currentFrame[trainname].gain = job->getCoreProperty(SequenceJob::SJ_Gain).
toDouble();
105 m_currentFrame[trainname].offset = job->getCoreProperty(SequenceJob::SJ_Offset).
toDouble();
106 m_currentFrame[trainname].jobType = job->jobType();
107 m_currentFrame[trainname].frameType = job->getFrameType();
108 m_currentFrame[trainname].
count = job->getCoreProperty(SequenceJob::SJ_Count).
toInt();
109 m_currentFrame[trainname].completed = job->getCompleted();
113 m_currentFrame[trainname].filename = data->filename();
114 m_currentFrame[trainname].width = data->width();
115 m_currentFrame[trainname].height = data->height();
118 const auto ISOIndex = job->getCoreProperty(SequenceJob::SJ_Offset).
toInt();
119 if (ISOIndex >= 0 && ISOIndex <= m_captureModule->mainCamera()->captureISOS->count())
120 m_currentFrame[trainname].iso = m_captureModule->mainCamera()->captureISOS->itemText(ISOIndex);
122 m_currentFrame[trainname].iso =
"";
126 captureCountsWidget->updateJobProgress(m_currentFrame[trainname], trainname);
131 m_overlay->addFrameData(m_currentFrame[trainname], trainname);
132 m_overlay->setVisible(
true);
136 if (m_fitsPreview !=
nullptr && Options::useSummaryPreview() && trainSelectionCB->currentText() == trainname)
137 m_fitsPreview->loadData(data);
140void CapturePreviewWidget::updateJobPreview(
const QString &filePath)
147 if (m_fitsPreview !=
nullptr && Options::useSummaryPreview())
148 m_fitsPreview->loadFile(filePath);
151void CapturePreviewWidget::showNextFrame()
153 m_overlay->setEnabled(
false);
154 if (m_overlay->showNextFrame())
155 m_fitsPreview->loadFile(m_overlay->currentFrame().filename);
158 m_overlay->setEnabled(
true);
161void CapturePreviewWidget::showPreviousFrame()
163 m_overlay->setEnabled(
false);
164 if (m_overlay->showPreviousFrame())
165 m_fitsPreview->loadFile(m_overlay->currentFrame().filename);
168 m_overlay->setEnabled(
true);
171void CapturePreviewWidget::deleteCurrentFrame()
173 m_overlay->setEnabled(
false);
174 if (m_overlay->hasFrames() ==
false)
179 int pos = m_overlay->currentPosition();
180 CaptureProcessOverlay::FrameData current = m_overlay->getFrame(
pos);
186 permanentlyDeleteCB->
setChecked(m_permanentlyDelete);
187 KSMessageBox::Instance()->
setCheckBox(permanentlyDeleteCB);
190 this->m_permanentlyDelete = checked;
196 bool success =
false;
197 if (this->m_permanentlyDelete ==
false && (success = file->
moveToTrash()))
199 qCInfo(KSTARS_EKOS_CAPTURE) << m_overlay->currentFrame().filename <<
"moved to Trash.";
201 else if (this->m_permanentlyDelete && (success = file->
remove()))
203 qCInfo(KSTARS_EKOS_CAPTURE) << m_overlay->currentFrame().filename <<
"deleted.";
209 if (m_overlay->deleteFrame(
pos) && m_overlay->hasFrames())
211 m_fitsPreview->loadFile(m_overlay->currentFrame().filename);
216 m_fitsPreview->clearData();
217 m_overlay->setEnabled(
true);
222 qCWarning(KSTARS_EKOS_CAPTURE) <<
"Deleting" << m_overlay->currentFrame().filename <<
225 m_overlay->setEnabled(
true);
238 m_overlay->setEnabled(
true);
243 KSMessageBox::Instance()->warningContinueCancel(
i18n(
"Do you really want to delete %1 from the file system?",
244 fileinfo.fileName()),
245 i18n(
"Delete %1", fileinfo.fileName()), 0,
false,
i18n(
"Delete"));
251 m_fitsPreview = view;
255 previewWidget->setLayout(vlayout);
256 previewWidget->setContentsMargins(0, 0, 0, 0);
263 view->processInfoWidget->setLayout(
layout);
267 m_overlay->setEnabled(true);
271 m_overlay->setEnabled(true);
275void CapturePreviewWidget::setEnabled(
bool enabled)
278 captureCountsWidget->setEnabled(
enabled);
282void CapturePreviewWidget::reset()
284 if (m_overlay->hasFrames())
285 m_overlay->captureHistory().reset();
286 m_overlay->setVisible(
false);
288 captureCountsWidget->reset();
294 captureStatusWidget->setCaptureState(status);
295 captureCountsWidget->updateCaptureStatus(status, isPreview, trainname);
298void CapturePreviewWidget::updateTargetDistance(
double targetDiff)
301 m_overlay->updateTargetDistance(targetDiff);
304void CapturePreviewWidget::updateCaptureCountDown(
int delta)
307 captureCountsWidget->updateCaptureCountDown(delta);
310void CapturePreviewWidget::selectedTrainChanged(
QString newName)
312 m_overlay->setCurrentTrainName(newName);
313 captureCountsWidget->setCurrentTrainName(newName);
315 m_overlay->setEnabled(
false);
316 if (m_overlay->hasFrames())
319 m_fitsPreview->loadFile(m_overlay->currentFrame().filename);
323 m_fitsPreview->clearData();
324 m_overlay->setEnabled(
true);
328void CapturePreviewWidget::updateExposureProgress(Ekos::SequenceJob *job,
const QString &trainname)
330 if (trainname == trainSelectionCB->currentText())
331 captureCountsWidget->updateExposureProgress(job, trainname);
334void CapturePreviewWidget::updateDownloadProgress(
double downloadTimeLeft,
const QString &trainname)
336 if (trainname == trainSelectionCB->currentText())
337 captureCountsWidget->updateDownloadProgress(downloadTimeLeft, trainname);
340void CapturePreviewWidget::setTargetName(
QString name)
344 mountTarget->setText(name);
345 m_mountTarget =
name;
346 m_currentFrame[trainSelectionCB->currentText()].target =
name;
Captures single or sequence of images from a CCD.
Supports controlling INDI telescope devices including setting/retrieving mount properties,...
void newTargetName(const QString &name)
The mount has finished the slew to a new target.
QString i18n(const char *text, const TYPE &arg...)
CaptureState
Capture states.
QString name(StandardAction id)
void currentTextChanged(const QString &text)
void setContentsMargins(const QMargins &margins)
void append(QList< T > &&value)
bool contains(const AT &value) const const
qsizetype count() const const
size_type count() const const
void setCheckBox(QCheckBox *cb)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
bool isNull() const const
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
double toDouble(bool *ok) const const
int toInt(bool *ok) const const
QPoint toPoint() const const
QString toString() const const