Kstars

captureprocessoverlay.h
1 /*
2  SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
7 #pragma once
8 
9 #include "ui_captureprocessoverlay.h"
10 
11 #include "indi/indicommon.h"
12 #include "fitsviewer/fitsdata.h"
13 
14 #include <QWidget>
15 
16 class CaptureProcessOverlay : public QWidget, public Ui::CaptureProcessOverlay
17 {
18  Q_OBJECT
19 
20 public:
21  explicit CaptureProcessOverlay(QWidget *parent = nullptr);
22 
23  // data describing a single frame
24  struct FrameData
25  {
26  QString target;
27  CCDFrameType frameType;
28  QString filterName;
29  QString filename;
30  double exptime;
31  double targetdrift;
32  QPoint binning;
33  int width;
34  int height;
35  double gain;
36  double offset;
37  QString iso;
38  };
39 
40  // structs for frame statistics
41  // map (frame type, filter) --> (exp time * 100, counter)
42  typedef QMap<QPair<CCDFrameType, QString>, QList<QPair<int, int>*>> FrameStatistics;
43  // map target --> frame statistics
44  typedef QMap<QString, FrameStatistics> TargetStatistics;
45 
46  /**
47  * @brief Navigator through the capture history.
48  */
50  public:
51  /**
52  * @brief Add a newly captured frame to the history
53  * @param data frame data
54  * @return true iff this is a new frame, i.e. its filename does not exist in the history
55  */
56  bool addFrame(FrameData data);
57 
58  /**
59  * @brief Delete the current frame and (if possible) the corresponding file.
60  * If the last one has been deleted, navigate to the frame before, if possible.
61  * @return true iff deleting was successful
62  */
63  bool deleteFrame(int pos);
64 
65  /**
66  * @brief the currently pointed capture frame
67  */
68  const FrameData currentFrame() {return m_history.at(m_position);}
69 
70  /**
71  * @brief The current navigation position in the capture history
72  */
73  int position() {return m_position;}
74  /**
75  * @brief Obtain the frame from the given position in the history
76  */
77  const FrameData getFrame(int pos) {return m_history.at(pos);}
78  /**
79  * @brief Capture history size
80  */
81  int size() {return m_history.size();}
82  /**
83  * @brief Reset the history
84  */
85  void reset();
86  /**
87  * @brief Move one step forward in the history
88  * @return true iff the move was possible within the limits
89  */
90  bool forward();
91  /**
92  * @brief Move one step backwards in the history
93  * @return true iff the move was possible within the limits
94  */
95  bool backward();
96  /**
97  * @brief Iterate over the current target history and add all
98  * those where the corresponding file exists.
99  */
100  void updateTargetStatistics();
101 
102  // capture statistics
103  TargetStatistics statistics;
104 
105  private:
106  QList<FrameData> m_history;
107  int m_position = -1;
108 
109  /**
110  * @brief Add a new frame to the statistics
111  * @param target current target being processed
112  * @param frameType type of the currently captured frame
113  * @param filter selected filter for the captured frame
114  * @param exptime exposure time of the captured frame
115  */
116  void countNewFrame(QString target, CCDFrameType frameType, QString filter, double exptime);
117  };
118 
119  bool addFrameData(FrameData data);
120  /**
121  * @brief Update the overlay with the meta data of the current frame and add it to the history
122  */
123  void updateFrameData();
124 
125  /**
126  * @brief Update the current target distance.
127  * @param targetDiff distance to the target in arcseconds.
128  */
129  void updateTargetDistance(double targetDiff);
130 
131  /**
132  * @brief Obtain the position of the current frame from the history
133  */
134  int currentPosition() {return m_captureHistory.position();}
135 
136  /**
137  * @brief Retrieve the currently selected frame
138  */
139  const FrameData currentFrame() {return m_captureHistory.currentFrame();}
140 
141  /**
142  * @brief Obtain the frame from the given position in the history
143  */
144  const FrameData getFrame(int pos) {return m_captureHistory.getFrame(pos);}
145 
146  /**
147  * @brief Obtain the position of the current frame from the history
148  */
149 
150  /**
151  * @brief Returns true iff there are frames in the capture history
152  */
153  bool hasFrames() {return m_captureHistory.size() > 0;}
154 
155  /**
156  * @brief Update the statistics display for captured frames
157  */
158  void displayTargetStatistics();
159 
160  /**
161  * @brief Loads a new frame into the view and displays meta data in the overlay
162  * @param data pointer to FITSData object
163  */
164  bool addFrame(const QSharedPointer<FITSData> &data);
165 
166  /**
167  * @brief Show the next frame from the capture history
168  */
169  bool showNextFrame();
170 
171  /**
172  * @brief Show the previous frame from the capture history
173  */
174  bool showPreviousFrame();
175 
176  /**
177  * @brief Delete the currently displayed frame
178  */
179  bool deleteFrame(int pos);
180 
181 private:
182  //capture history
183  CaptureHistory m_captureHistory;
184 
185 };
Q_OBJECTQ_OBJECT
Navigator through the capture history.
bool backward()
Move one step backwards in the history.
const FrameData currentFrame()
the currently pointed capture frame
bool deleteFrame(int pos)
Delete the current frame and (if possible) the corresponding file.
const FrameData getFrame(int pos)
Obtain the frame from the given position in the history.
int size() const const
const T & at(int i) const const
bool addFrame(FrameData data)
Add a newly captured frame to the history.
bool forward()
Move one step forward in the history.
void updateTargetStatistics()
Iterate over the current target history and add all those where the corresponding file exists.
int position()
The current navigation position in the capture history.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.