File indexing completed on 2024-04-28 15:09:53

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 
0011 #include <QObject>
0012 #include <QWidget>
0013 
0014 #include "qcustomplot.h"
0015 #include "guidegraph.h"
0016 
0017 namespace Ekos
0018 {
0019 class GuideInterface;
0020 }
0021 class GuideDriftGraph : public QCustomPlot
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     GuideDriftGraph(QWidget *parent = nullptr);
0027     void guideHistory(int sliderValue, bool graphOnLatestPt);
0028     /**
0029      * @brief setRMSVisibility Decides which RMS plot is visible.
0030      */
0031     void setRMSVisibility();
0032     void exportGuideData();
0033     void resetTimer();
0034     void connectGuider(Ekos::GuideInterface *guider);
0035 
0036 public slots:
0037     void handleVerticalPlotSizeChange();
0038     void handleHorizontalPlotSizeChange();
0039 
0040     void setupNSEWLabels();
0041     void autoScaleGraphs();
0042     void zoomX(int zoomLevel);
0043     void zoomInX();
0044     void zoomOutX();
0045     void setCorrectionGraphScale(int value);
0046     void setLatestGuidePoint(bool isChecked) {graphOnLatestPt = isChecked;}
0047     void clear();
0048 
0049     void toggleShowPlot(GuideGraph::DRIFT_GRAPH_INDICES plot, bool isChecked);
0050     void setAxisDelta(double ra, double de);
0051     void setAxisSigma(double ra, double de);
0052     void setAxisPulse(double ra, double de);
0053     void setSNR(double snr);
0054     void updateCorrectionsScaleVisibility();
0055 
0056     // Display guide information when hovering over the drift graph
0057     void mouseOverLine(QMouseEvent *event);
0058 
0059     // Reset graph if right clicked
0060     void mouseClicked(QMouseEvent *event);
0061 
0062     /** @brief Update colors following a color scheme update notification.
0063      */
0064     void refreshColorScheme();
0065 
0066 private:
0067     // The scales of these zoom levels are defined in Guide::zoomX().
0068     static constexpr int defaultXZoomLevel = 3;
0069     int driftGraphZoomLevel {defaultXZoomLevel};
0070     bool graphOnLatestPt = true;
0071 
0072     // Axis for the SNR part of the driftGraph. Qt owns this pointer's memory.
0073     QCPAxis *snrAxis;
0074 
0075     // Guide timer
0076     QTime guideTimer;
0077     QElapsedTimer guideElapsedTimer;
0078 
0079     QUrl guideURLPath;
0080 };