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
38 /**
39 * @brief updates the plot title
40 * @param title the new plot title
41 */
42 void finalUpdates(const QString &title, bool plot = true);
43
44 /**
45 * @brief Annotate's the plot's solution graph with the solution position.
46 * @param solutionPosition focuser position of the focal point
47 * @param solutionValue HFR value on the focal point
48 */
49 void drawMinimum(double solutionPosition, double solutionValue, bool plot = true);
50
51 /**
52 * @brief Draw the CFZ on the graph
53 * @param solutionPosition focuser position of the focal point
54 * @param solutionValue HFR value on the focal point
55 * @param cfzSteps The CFZ size
56 * @param plot Whether to plot
57 */
58 void drawCFZ(double solutionPosition, double solutionValue, int cfzSteps, bool plot);
59
60 /**
61 * @brief Draws the polynomial on the plot's graph.
62 * @param polyFit pointer to the polynomial approximation
63 * @param isVShape is the polynomial of a V shape (true) or U shape (false)?
64 * @param makeVisible make the polynomial graph visible (true) or use the last state (false)?
65 */
66 void drawPolynomial(Ekos::PolynomialFit *polyFit, bool isVShape, bool makeVisible, bool plot = true);
67
68 /**
69 * @brief Draws the curve on the plot's graph.
70 * @param curveFit pointer to the curve approximation
71 * @param isVShape is the curve of a V shape (true) or U shape (false)?
72 * @param makeVisible make the graph visible (true) or use the last state (false)?
73 */
74 void drawCurve(Ekos::CurveFitting *curveFit, bool isVShape, bool makeVisible, bool plot = true);
75
76 /**
77 * @brief Refresh the entire graph
78 * @param polyFit pointer to the polynomial approximation
79 * @param solutionPosition focuser position of the focal point
80 * @param solutionValue HFR value on the focal point
81 */
82 void redraw(Ekos::PolynomialFit *polyFit, double solutionPosition, double solutionValue);
83
84 /**
85 * @brief Refresh the entire graph
86 * @param curveFit pointer to the curve approximation
87 * @param solutionPosition focuser position of the focal point
88 * @param solutionValue HFR value on the focal point
89 */
90 void redrawCurve(Ekos::CurveFitting *curveFit, double solutionPosition, double solutionValue);
91
92 /**
93 * @brief Initialize and reset the entire HFR V-plot
94 * @param yAxisLabel is the label to display
95 * @param starUnits the units multiplier to display the pixel data
96 * @param minimum whether the curve shape is a minimum or maximum
97 * @param useWeights whether or not to display weights on the graph
98 * @param showPosition show focuser position (true) or show focusing iteration number (false)
99 */
100 void init(QString yAxisLabel, double starUnits, bool minimum, bool useWeights, bool showPosition);
101
102 /// basic font size from which all others are derived
103 int basicFontSize() const
104 {
105 return m_basicFontSize;
106 }
107 void setBasicFontSize(int basicFontSize);
108
109 private:
110 /**
111 * @brief Draw the HFR plot for all recent focuser positions
112 * @param currentValue current HFR value
113 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
114 * or the number of ticks in a relative or absolute focuser
115 */
116 void drawHFRPlot(double currentValue, int pulseDuration);
117
118 /**
119 * @brief Draw all positions and values of the current focusing run.
120 */
121 void drawHFRIndices();
122
123 /**
124 * @brief Initialize and reset the HFR plot
125 * @param showPosition show the focuser positions (true) or the focus iteration number (false)
126 */
127
128 /**
129 * @brief Set pen color depending upon the solution is sound (V-Shape) or unsound (U-Shape)
130 * @param isSound
131 */
132 void setSolutionVShape(bool isVShape);
133
134 /**
135 * @brief Clear all the items on HFR plot
136 */
137 void clearItems();
138
139 /**
140 * @brief Convert input value to output display value
141 * @param value to convert
142 */
143 double getDisplayValue(const double value);
144
145 QCPGraph *polynomialGraph = nullptr;
146 QVector<double> m_position, m_value, m_displayValue, m_sigma;
147 QVector<bool> m_goodPosition;
148
149 // Error bars for the focus plot
150 bool m_useErrorBars = false;
151 QCPErrorBars * errorBars = nullptr;
152
153 // CFZ
154 QCPItemBracket * CFZ = nullptr;
155
156 // Title text for the focus plot
157 QCPItemText *plotTitle { nullptr };
158
159 /// Maximum and minimum y-values recorded
160 double minValue { -1 }, maxValue { -1 };
161 /// List of V curve plot points
162 /// V-Curve graph
163 QCPGraph *v_graph { nullptr };
164 /// focus point
165 QCPGraph *focusPoint { nullptr };
166 /// show focus position (true) or use focus step number?
167 bool m_showPositions = true;
168 /// is there a current polynomial solution
169 bool m_isVShape = false;
170 /// basic font size from which all others are derived
171 int m_basicFontSize = 10;
172 /// Is the curve V-shaped or n-shaped
173 bool m_Minimum = true;
174 // Units multiplier for star measure value
175 double m_starUnits = 1.0;
176
177 bool m_polynomialGraphIsVisible = false;
178};
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 Tue Mar 26 2024 11:19:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.