Kstars

buildfilteroffsets.h
1/*
2 SPDX-FileCopyrightText: 2023 John Evans <john.e.evans.email@googlemail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_buildfilteroffsets.h"
10#include "filtermanager.h"
11#include "ekos/focus/focusutils.h"
12
13namespace Ekos
14{
15
16class BuildFilterOffsets : public QDialog, public Ui::buildOffsetsDialog
17{
19
20 public:
21
22 BuildFilterOffsets(QSharedPointer<FilterManager> filterManager);
23 ~BuildFilterOffsets();
24
25 // Used by build filter offsets utility to process the completion of an AF run.
26 void autoFocusComplete(FocusState completionState, int currentPosition, double currentTemperature, double currentAlt);
27
28 signals:
29 // Trigger Autofocus
30 void runAutoFocus(AutofocusReason autofocusReason, const QString &reasonInfo);
31 // User has elected to abort Autofocus, pass on signal to FilterManager
32 void abortAutoFocus();
33 // New Focus offset requested
34 void newFocusOffset(int value, bool useAbsoluteOffset);
35 // Emitted when filter change completed including all required actions
36 void ready();
37
38 private slots:
39 void itemChanged(QStandardItem *item);
40 void refChanged(QModelIndex index);
41
42 private:
43
44 // BFOColID references the columns in the table
45 typedef enum
46 {
47 BFO_FILTER = 0,
48 BFO_OFFSET,
49 BFO_LOCK,
50 BFO_NUM_FOCUS_RUNS,
51 BFO_AF_RUN_1,
52 BFO_AVERAGE,
53 BFO_NEW_OFFSET,
54 BFO_SAVE_CHECK
55 } BFOColID;
56
57 // BFOButtonState controls the states used when using the dialog
58 typedef enum
59 {
60 BFO_INIT,
61 BFO_RUN,
62 BFO_SAVE,
63 BFO_STOP
64 } BFOButtonState;
65
66 // buildOffsetsQItem is used to queue items for processing
67 typedef struct
68 {
69 QString color;
70 bool changeFilter;
71 int numAFRun;
72 } buildOffsetsQItem;
73
74 // AFSolutionDetail is used to store data used to calculate adaptive focus position info
75 typedef struct
76 {
77 int position;
78 int adaptedPosition;
79 double temperature;
80 double deltaTemp;
81 double altitude;
82 double deltaAlt;
83 double ticksPerTemp;
84 double ticksPerAlt;
85 double deltaTicksTemperature;
86 double deltaTicksAltitude;
87 double deltaTicksTotal;
88 } AFSolutionDetail;
89
90 // Function to setup signal/slots in and out of Build Filter Offsets
91 void setupConnections();
92 // Setup the dialog GUI
93 void setupGUI();
94 // Function to initialise resources for the build filter offsers dialog
95 void initBuildFilterOffsets();
96 // Setup the table widget
97 void setupBuildFilterOffsetsTable();
98 // Set the buttons state
99 void setBuildFilterOffsetsButtons(const BFOButtonState state);
100 // Function to setup the work required to build the offsets
101 void buildTheOffsets();
102 // Function to stop in-flight processing, e.g AF runs
103 void stopProcessing();
104 // Function to persist the calculated filter offsets
105 void saveTheOffsets();
106 // When all automated processing is complete allow some cells to be editable
107 void setCellsEditable();
108 // Function to call Autofocus to build the filter offsets
109 void runBuildOffsets();
110 // Function to process a filter change event
111 void buildTheOffsetsTaskComplete();
112 // Resize the dialog
113 void buildOffsetsDialogResize();
114 // Calculate the average of the AF runs
115 void calculateAFAverage(const int row, const int col);
116 // Calculate the new offset for the filter
117 void calculateOffset(const int row);
118 // Process the passed in Q item
119 void processQItem(const buildOffsetsQItem qitem);
120 // Process successful Autofocus data
121 void processAFcomplete(const int position, const double temperature, const double altitude);
122 // Load the AF position into the table.
123 void loadPosition(const bool checked, const int row, const int col);
124 // Reload all AF positions processed so far depending on setting of adaptFocus checkbox
125 void reloadPositions(const bool checked);
126 // Return the column for the passed in ID
127 int getColumn(const BFOColID id);
128 // Get the number of AF runs for the passed in row
129 int getNumRuns(const int row);
130 // Get the maximum number of AF runs
131 int getMaxRuns();
132
133 QStandardItemModel m_BFOModel;
134
135 QVector <QString> m_filters;
136 int m_refFilter { -1 };
137 double m_refTemperature { INVALID_VALUE };
138 double m_refAltitude { INVALID_VALUE };
139
140 QQueue<buildOffsetsQItem> m_buildOffsetsQ;
141 buildOffsetsQItem m_qItemInProgress;
142
143 QSharedPointer<FilterManager> m_filterManager;
144
145 bool m_inBuildOffsets { false };
146 int m_rowIdx { 0 };
147 int m_colIdx { 0 };
148 QPushButton *m_runButton;
149 QPushButton *m_stopButton;
150 bool m_problemFlag { false };
151 bool m_stopFlag { false };
152 bool m_abortAFPending { false };
153 bool m_tableInEditMode {false};
154 QVector<AFSolutionDetail> m_AFSolutions;
155};
156
157}
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.