Kstars

focushfrvplot.h
1 /*
2  SPDX-FileCopyrightText: 2012 Jasem Mutlaq <[email protected]>
3  SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <[email protected]>
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 
17 class FocusHFRVPlot : public QCustomPlot
18 {
19  public:
20  FocusHFRVPlot(QWidget *parent = nullptr);
21 
22  /**
23  * @brief add a single focus position result
24  * @param pos focuser position or iteration number
25  * @param newHFR HFR value for the given position
26  * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
27  * or the number of ticks in a relative or absolute focuser
28  */
29  void addPosition(double pos, double newHFR, int pulseDuration, bool plot = true);
30 
31  /**
32  * @brief add a single focus position result with error (sigma)
33  * @param pos focuser position or iteration number
34  * @param newHFR HFR value for the given position
35  * @param sigma value is the error (sigma) in the HFR measurement
36  * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
37  * or the number of ticks in a relative or absolute focuser
38  */
39  void addPositionWithSigma(double pos, double newHFR, double sigma, int pulseDuration, bool plot = true);
40 
41  /**
42  * @brief sets the plot title
43  * @param title the new plot title
44  */
45  void setTitle(const QString &title, bool plot = true);
46 
47  /**
48  * @brief updates the plot title
49  * @param title the new plot title
50  */
51  void updateTitle(const QString &title, bool plot = true);
52 
53  /**
54  * @brief Annotate's the plot's solution graph with the solution position.
55  * @param solutionPosition focuser position of the focal point
56  * @param solutionValue HFR value on the focal point
57  */
58  void drawMinimum(double solutionPosition, double solutionValue, bool plot = true);
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 showPosition show focuser position (true) or show focusing iteration number (false)
95  */
96  void init(bool showPosition);
97 
98  /// basic font size from which all others are derived
99  int basicFontSize() const
100  {
101  return m_basicFontSize;
102  }
103  void setBasicFontSize(int basicFontSize);
104 
105  private:
106  /**
107  * @brief Draw the HFR plot for all recent focuser positions
108  * @param currentHFR current HFR value
109  * @param pulseDuration Pulse duration in ms for relative focusers that only support timers,
110  * or the number of ticks in a relative or absolute focuser
111  */
112  void drawHFRPlot(double currentHFR, int pulseDuration);
113 
114  /**
115  * @brief Draw all positions and values of the current focusing run.
116  */
117  void drawHFRIndices();
118 
119  /**
120  * @brief Initialize and reset the HFR plot
121  * @param showPosition show the focuser positions (true) or the focus iteration number (false)
122  */
123 
124  /**
125  * @brief Set pen color depending upon the solution is sound (V-Shape) or unsound (U-Shape)
126  * @param isSound
127  */
128  void setSolutionVShape(bool isVShape);
129 
130  /**
131  * @brief Clear all the items on HFR plot
132  */
133  void clearItems();
134 
135  QCPGraph *polynomialGraph = nullptr;
136  QVector<double> hfr_position, hfr_value, hfr_sigma;
137 
138  // Error bars for the focus plot
139  bool useErrorBars = false;
140  QCPErrorBars * errorBars = nullptr;
141 
142  // Title text for the focus plot
143  QCPItemText *plotTitle { nullptr };
144 
145  /// Maximum HFR recorded
146  double maxHFR { -1 };
147  /// List of V curve plot points
148  /// V-Curve graph
149  QCPGraph *v_graph { nullptr };
150  /// focus point
151  QCPGraph *focusPoint { nullptr };
152  /// show focus position (true) or use focus step number?
153  bool m_showPositions = true;
154  /// is there a current polynomial solution
155  bool m_isVShape = false;
156  /// basic font size from which all others are derived
157  int m_basicFontSize = 10;
158 
159  bool m_polynomialGraphIsVisible = false;
160 };
A plottable that adds a set of error bars to other plottables.
Definition: qcustomplot.h:6272
A plottable representing a graph in a plot.
Definition: qcustomplot.h:5440
void init(KXmlGuiWindow *window, KgDifficulty *difficulty=nullptr)
A text label.
Definition: qcustomplot.h:6571
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition: qcustomplot.h:3735
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.