Warning, file /education/kstars/kstars/ekos/focus/focushfrvplot.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com> 0003 SPDX-FileCopyrightText: 2021 Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <QObject> 0011 #include <QWidget> 0012 #include "qcustomplot.h" 0013 #include "ekos/ekos.h" 0014 #include "ekos/focus/polynomialfit.h" 0015 #include "ekos/focus/curvefit.h" 0016 0017 class FocusHFRVPlot : public QCustomPlot 0018 { 0019 public: 0020 FocusHFRVPlot(QWidget *parent = nullptr); 0021 0022 /** 0023 * @brief add a single focus position result with error (sigma) 0024 * @param pos focuser position or iteration number 0025 * @param newHFR HFR value for the given position 0026 * @param sigma value is the error (sigma) in the HFR measurement 0027 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers, 0028 * or the number of ticks in a relative or absolute focuser 0029 */ 0030 void addPosition(double pos, double newHFR, double sigma, bool outlier, int pulseDuration, bool plot = true); 0031 0032 /** 0033 * @brief sets the plot title 0034 * @param title the new plot title 0035 */ 0036 void setTitle(const QString &title, bool plot = true); 0037 0038 /** 0039 * @brief updates the plot title 0040 * @param title the new plot title 0041 */ 0042 void finalUpdates(const QString &title, bool plot = true); 0043 0044 /** 0045 * @brief Annotate's the plot's solution graph with the solution position. 0046 * @param solutionPosition focuser position of the focal point 0047 * @param solutionValue HFR value on the focal point 0048 */ 0049 void drawMinimum(double solutionPosition, double solutionValue, bool plot = true); 0050 0051 /** 0052 * @brief Draw the CFZ on the graph 0053 * @param solutionPosition focuser position of the focal point 0054 * @param solutionValue HFR value on the focal point 0055 * @param cfzSteps The CFZ size 0056 * @param plot Whether to plot 0057 */ 0058 void drawCFZ(double solutionPosition, double solutionValue, int cfzSteps, bool plot); 0059 0060 /** 0061 * @brief Draws the polynomial on the plot's graph. 0062 * @param polyFit pointer to the polynomial approximation 0063 * @param isVShape is the polynomial of a V shape (true) or U shape (false)? 0064 * @param makeVisible make the polynomial graph visible (true) or use the last state (false)? 0065 */ 0066 void drawPolynomial(Ekos::PolynomialFit *polyFit, bool isVShape, bool makeVisible, bool plot = true); 0067 0068 /** 0069 * @brief Draws the curve on the plot's graph. 0070 * @param curveFit pointer to the curve approximation 0071 * @param isVShape is the curve of a V shape (true) or U shape (false)? 0072 * @param makeVisible make the graph visible (true) or use the last state (false)? 0073 */ 0074 void drawCurve(Ekos::CurveFitting *curveFit, bool isVShape, bool makeVisible, bool plot = true); 0075 0076 /** 0077 * @brief Refresh the entire graph 0078 * @param polyFit pointer to the polynomial approximation 0079 * @param solutionPosition focuser position of the focal point 0080 * @param solutionValue HFR value on the focal point 0081 */ 0082 void redraw(Ekos::PolynomialFit *polyFit, double solutionPosition, double solutionValue); 0083 0084 /** 0085 * @brief Refresh the entire graph 0086 * @param curveFit pointer to the curve approximation 0087 * @param solutionPosition focuser position of the focal point 0088 * @param solutionValue HFR value on the focal point 0089 */ 0090 void redrawCurve(Ekos::CurveFitting *curveFit, double solutionPosition, double solutionValue); 0091 0092 /** 0093 * @brief Initialize and reset the entire HFR V-plot 0094 * @param yAxisLabel is the label to display 0095 * @param starUnits the units multiplier to display the pixel data 0096 * @param minimum whether the curve shape is a minimum or maximum 0097 * @param useWeights whether or not to display weights on the graph 0098 * @param showPosition show focuser position (true) or show focusing iteration number (false) 0099 */ 0100 void init(QString yAxisLabel, double starUnits, bool minimum, bool useWeights, bool showPosition); 0101 0102 /// basic font size from which all others are derived 0103 int basicFontSize() const 0104 { 0105 return m_basicFontSize; 0106 } 0107 void setBasicFontSize(int basicFontSize); 0108 0109 private: 0110 /** 0111 * @brief Draw the HFR plot for all recent focuser positions 0112 * @param currentValue current HFR value 0113 * @param pulseDuration Pulse duration in ms for relative focusers that only support timers, 0114 * or the number of ticks in a relative or absolute focuser 0115 */ 0116 void drawHFRPlot(double currentValue, int pulseDuration); 0117 0118 /** 0119 * @brief Draw all positions and values of the current focusing run. 0120 */ 0121 void drawHFRIndices(); 0122 0123 /** 0124 * @brief Initialize and reset the HFR plot 0125 * @param showPosition show the focuser positions (true) or the focus iteration number (false) 0126 */ 0127 0128 /** 0129 * @brief Set pen color depending upon the solution is sound (V-Shape) or unsound (U-Shape) 0130 * @param isSound 0131 */ 0132 void setSolutionVShape(bool isVShape); 0133 0134 /** 0135 * @brief Clear all the items on HFR plot 0136 */ 0137 void clearItems(); 0138 0139 /** 0140 * @brief Convert input value to output display value 0141 * @param value to convert 0142 */ 0143 double getDisplayValue(const double value); 0144 0145 QCPGraph *polynomialGraph = nullptr; 0146 QVector<double> m_position, m_value, m_displayValue, m_sigma; 0147 QVector<bool> m_goodPosition; 0148 0149 // Error bars for the focus plot 0150 bool m_useErrorBars = false; 0151 QCPErrorBars * errorBars = nullptr; 0152 0153 // CFZ 0154 QCPItemBracket * CFZ = nullptr; 0155 0156 // Title text for the focus plot 0157 QCPItemText *plotTitle { nullptr }; 0158 0159 /// Maximum and minimum y-values recorded 0160 double minValue { -1 }, maxValue { -1 }; 0161 /// List of V curve plot points 0162 /// V-Curve graph 0163 QCPGraph *v_graph { nullptr }; 0164 /// focus point 0165 QCPGraph *focusPoint { nullptr }; 0166 /// show focus position (true) or use focus step number? 0167 bool m_showPositions = true; 0168 /// is there a current polynomial solution 0169 bool m_isVShape = false; 0170 /// basic font size from which all others are derived 0171 int m_basicFontSize = 10; 0172 /// Is the curve V-shaped or n-shaped 0173 bool m_Minimum = true; 0174 // Units multiplier for star measure value 0175 double m_starUnits = 1.0; 0176 0177 bool m_polynomialGraphIsVisible = false; 0178 };