Kstars

focushfrvplot.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <QObject>
11#include <QWidget>
12#include "qcustomplot.h"
13#include "ekos/ekos.h"
14#include "ekos/focus/polynomialfit.h"
15#include "ekos/focus/curvefit.h"
16
17class FocusHFRVPlot : public QCustomPlot
18{
19 public:
20 FocusHFRVPlot(QWidget *parent = nullptr);
21
22 /**
23 * @brief add a single focus position result with error (sigma)
24 * @param pos focuser position or iteration number
25 * @param newHFR HFR value for the given position
26 * @param sigma value is the error (sigma) in the HFR measurement
27 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
28 * or the number of ticks in a relative or absolute focuser
29 */
30 void addPosition(double pos, double newHFR, double sigma, bool outlier, int pulseDuration, bool plot = true);
31
32 /**
33 * @brief sets the plot title
34 * @param title the new plot title
35 */
36 void setTitle(const QString &title, bool plot = true);
37 QString title() const;
38
39 /**
40 * @brief updates the plot title
41 * @param title the new plot title
42 */
43 void finalUpdates(const QString &title, bool plot = true);
44
45 /**
46 * @brief Annotate's the plot's solution graph with the solution position.
47 * @param solutionPosition focuser position of the focal point
48 * @param solutionValue HFR value on the focal point
49 */
50 void drawMinimum(double solutionPosition, double solutionValue, bool plot = true);
51
52 /**
53 * @brief Draw the CFZ on the graph
54 * @param solutionPosition focuser position of the focal point
55 * @param solutionValue HFR value on the focal point
56 * @param cfzSteps The CFZ size
57 * @param plot Whether to plot
58 */
59 void drawCFZ(double solutionPosition, double solutionValue, int cfzSteps, bool plot);
60
61 /**
62 * @brief Draws the polynomial on the plot's graph.
63 * @param polyFit pointer to the polynomial approximation
64 * @param isVShape is the polynomial of a V shape (true) or U shape (false)?
65 * @param makeVisible make the polynomial graph visible (true) or use the last state (false)?
66 */
67 void drawPolynomial(Ekos::PolynomialFit *polyFit, bool isVShape, bool makeVisible, bool plot = true);
68
69 /**
70 * @brief Draws the curve on the plot's graph.
71 * @param curveFit pointer to the curve approximation
72 * @param isVShape is the curve of a V shape (true) or U shape (false)?
73 * @param makeVisible make the graph visible (true) or use the last state (false)?
74 */
75 void drawCurve(Ekos::CurveFitting *curveFit, bool isVShape, bool makeVisible, bool plot = true);
76
77 /**
78 * @brief Refresh the entire graph
79 * @param polyFit pointer to the polynomial approximation
80 * @param solutionPosition focuser position of the focal point
81 * @param solutionValue HFR value on the focal point
82 */
83 void redraw(Ekos::PolynomialFit *polyFit, double solutionPosition, double solutionValue);
84
85 /**
86 * @brief Refresh the entire graph
87 * @param curveFit pointer to the curve approximation
88 * @param solutionPosition focuser position of the focal point
89 * @param solutionValue HFR value on the focal point
90 */
91 void redrawCurve(Ekos::CurveFitting *curveFit, double solutionPosition, double solutionValue);
92
93 /**
94 * @brief Initialize and reset the entire HFR V-plot
95 * @param yAxisLabel is the label to display
96 * @param starUnits the units multiplier to display the pixel data
97 * @param minimum whether the curve shape is a minimum or maximum
98 * @param useWeights whether or not to display weights on the graph
99 * @param showPosition show focuser position (true) or show focusing iteration number (false)
100 */
101 void init(QString yAxisLabel, double starUnits, bool minimum, bool useWeights, bool showPosition);
102
103 /// basic font size from which all others are derived
104 int basicFontSize() const
105 {
106 return m_basicFontSize;
107 }
108 void setBasicFontSize(int basicFontSize);
109
110 private:
111 /**
112 * @brief Draw the HFR plot for all recent focuser positions
113 * @param currentValue current HFR value
114 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
115 * or the number of ticks in a relative or absolute focuser
116 */
117 void drawHFRPlot(double currentValue, int pulseDuration);
118
119 /**
120 * @brief Draw all positions and values of the current focusing run.
121 */
122 void drawHFRIndices();
123
124 /**
125 * @brief Initialize and reset the HFR plot
126 * @param showPosition show the focuser positions (true) or the focus iteration number (false)
127 */
128
129 /**
130 * @brief Set pen color depending upon the solution is sound (V-Shape) or unsound (U-Shape)
131 * @param isSound
132 */
133 void setSolutionVShape(bool isVShape);
134
135 /**
136 * @brief Clear all the items on HFR plot
137 */
138 void clearItems();
139
140 /**
141 * @brief Convert input value to output display value
142 * @param value to convert
143 */
144 double getDisplayValue(const double value);
145
146 QCPGraph *polynomialGraph = nullptr;
147 QVector<double> m_position, m_value, m_displayValue, m_sigma;
148 QVector<bool> m_goodPosition;
149
150 // Error bars for the focus plot
151 bool m_useErrorBars = false;
152 QCPErrorBars * errorBars = nullptr;
153
154 // CFZ
155 QCPItemBracket * CFZ = nullptr;
156
157 // Title text for the focus plot
158 QCPItemText *plotTitle { nullptr };
159
160 /// Maximum and minimum y-values recorded
161 double minValue { -1 }, maxValue { -1 };
162 /// List of V curve plot points
163 /// V-Curve graph
164 QCPGraph *v_graph { nullptr };
165 /// focus point
166 QCPGraph *focusPoint { nullptr };
167 /// show focus position (true) or use focus step number?
168 bool m_showPositions = true;
169 /// is there a current polynomial solution
170 bool m_isVShape = false;
171 /// basic font size from which all others are derived
172 int m_basicFontSize = 10;
173 /// Is the curve V-shaped or n-shaped
174 bool m_Minimum = true;
175 // Units multiplier for star measure value
176 double m_starUnits = 1.0;
177
178 bool m_polynomialGraphIsVisible = false;
179};
A plottable that adds a set of error bars to other plottables.
A plottable representing a graph in a plot.
A bracket for referencing/highlighting certain parts in the plot.
A text label.
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.