Warning, file /education/kstars/kstars/ekos/analyze/yaxistool.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: 2023 Hy Murveit <hy@murveit.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "ui_yaxistool.h" 0010 #include "qcustomplot.h" 0011 0012 #include <QDialog> 0013 #include <QFrame> 0014 0015 #include <memory> 0016 0017 /** 0018 * @class YAxisInfo 0019 * @short Used to keep track of the various Y-axes and connect them to the QLineEdits. 0020 * 0021 * @version 1.0 0022 * @author Hy Murveit 0023 */ 0024 struct YAxisInfo 0025 { 0026 static constexpr double LOWER_RESCALE = -102, UPPER_RESCALE = -101; 0027 QCPAxis *axis; 0028 QCPRange initialRange; 0029 bool rescale; 0030 int graphIndex; 0031 QCustomPlot *plot; 0032 QCheckBox *checkBox; 0033 QString name; 0034 QString shortName; 0035 QColor initialColor; 0036 QColor color; 0037 YAxisInfo() {} 0038 YAxisInfo(QCPAxis *axis_, QCPRange initialRange_, bool rescale_, int graphIndex_, 0039 QCustomPlot *plot_, QCheckBox *checkBox_, const QString &name_, 0040 const QString &shortName_, const QColor &color_) 0041 : axis(axis_), initialRange(initialRange_), rescale(rescale_), graphIndex(graphIndex_), 0042 plot(plot_), checkBox(checkBox_), name(name_), shortName(shortName_), 0043 initialColor(color_), color(color_) {} 0044 static bool isRescale(const QCPRange &range) 0045 { 0046 return (range.lower == YAxisInfo::LOWER_RESCALE && 0047 range.upper == YAxisInfo::UPPER_RESCALE); 0048 } 0049 }; 0050 0051 class YAxisToolUI : public QFrame, public Ui::YAxisTool 0052 { 0053 Q_OBJECT 0054 0055 public: 0056 explicit YAxisToolUI(QWidget *parent); 0057 void reset(const YAxisInfo &info); 0058 private: 0059 }; 0060 0061 /** 0062 * @class YAxisTool 0063 * @short Manages adjusting the Y-axis of Analyze stats graphs. 0064 * 0065 * @version 1.0 0066 * @author Hy Murveit 0067 */ 0068 class YAxisTool : public QDialog 0069 { 0070 Q_OBJECT 0071 public: 0072 explicit YAxisTool(QWidget *ks); 0073 virtual ~YAxisTool() override = default; 0074 void reset(QObject *key, const YAxisInfo &info, bool isLeftAxis); 0075 void replot(bool isLeftAxis); 0076 const QCPAxis *getAxis() 0077 { 0078 return m_Info.axis; 0079 } 0080 0081 protected: 0082 void closeEvent(QCloseEvent *event) override; 0083 void showEvent(QShowEvent *event) override; 0084 0085 signals: 0086 void axisChanged(QObject *key, const YAxisInfo &info); 0087 void axisColorChanged(QObject *key, const YAxisInfo &info, const QColor &color); 0088 void leftAxisChanged(QCPAxis *axis); 0089 0090 public slots: 0091 void updateValues(const double value); 0092 void slotClosed(); 0093 0094 private slots: 0095 void slotSaveChanges(); 0096 0097 private: 0098 void updateAutoValues(); 0099 void updateLeftAxis(); 0100 void updateToDefaults(); 0101 void updateSpins(); 0102 void updateColor(); 0103 void computeAutoLimits(); 0104 0105 YAxisToolUI *ui { nullptr }; 0106 QObject *m_Key { nullptr }; 0107 YAxisInfo m_Info; 0108 };