Kstars

yaxistool.h
1/*
2 SPDX-FileCopyrightText: 2023 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_yaxistool.h"
10#include "qcustomplot.h"
11
12#include <QDialog>
13#include <QFrame>
14
15#include <memory>
16
17/**
18 * @class YAxisInfo
19 * @short Used to keep track of the various Y-axes and connect them to the QLineEdits.
20 *
21 * @version 1.0
22 * @author Hy Murveit
23 */
25{
26 static constexpr double LOWER_RESCALE = -102, UPPER_RESCALE = -101;
27 QCPAxis *axis;
28 QCPRange initialRange;
29 bool rescale;
30 int graphIndex;
31 QCustomPlot *plot;
32 QCheckBox *checkBox;
33 QString name;
34 QString shortName;
35 QColor initialColor;
36 QColor color;
37 YAxisInfo() {}
38 YAxisInfo(QCPAxis *axis_, QCPRange initialRange_, bool rescale_, int graphIndex_,
39 QCustomPlot *plot_, QCheckBox *checkBox_, const QString &name_,
40 const QString &shortName_, const QColor &color_)
41 : axis(axis_), initialRange(initialRange_), rescale(rescale_), graphIndex(graphIndex_),
42 plot(plot_), checkBox(checkBox_), name(name_), shortName(shortName_),
43 initialColor(color_), color(color_) {}
44 static bool isRescale(const QCPRange &range)
45 {
46 return (range.lower == YAxisInfo::LOWER_RESCALE &&
47 range.upper == YAxisInfo::UPPER_RESCALE);
48 }
49};
50
51class YAxisToolUI : public QFrame, public Ui::YAxisTool
52{
54
55 public:
56 explicit YAxisToolUI(QWidget *parent);
57 void reset(const YAxisInfo &info);
58 private:
59};
60
61/**
62 * @class YAxisTool
63 * @short Manages adjusting the Y-axis of Analyze stats graphs.
64 *
65 * @version 1.0
66 * @author Hy Murveit
67 */
68class YAxisTool : public QDialog
69{
71 public:
72 explicit YAxisTool(QWidget *ks);
73 virtual ~YAxisTool() override = default;
74 void reset(QObject *key, const YAxisInfo &info, bool isLeftAxis);
75 void replot(bool isLeftAxis);
76 const QCPAxis *getAxis()
77 {
78 return m_Info.axis;
79 }
80
81 protected:
82 void closeEvent(QCloseEvent *event) override;
83 void showEvent(QShowEvent *event) override;
84
85 signals:
86 void axisChanged(QObject *key, const YAxisInfo &info);
87 void axisColorChanged(QObject *key, const YAxisInfo &info, const QColor &color);
88 void leftAxisChanged(QCPAxis *axis);
89
90 public slots:
91 void updateValues(const double value);
92 void slotClosed();
93
94 private slots:
95 void slotSaveChanges();
96
97 private:
98 void updateAutoValues();
99 void updateLeftAxis();
100 void updateToDefaults();
101 void updateSpins();
102 void updateColor();
103 void computeAutoLimits();
104
105 YAxisToolUI *ui { nullptr };
106 QObject *m_Key { nullptr };
107 YAxisInfo m_Info;
108};
Manages a single axis inside a QCustomPlot.
Represents the range an axis is encompassing.
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Manages adjusting the Y-axis of Analyze stats graphs.
Definition yaxistool.h:69
Q_OBJECTQ_OBJECT
QObject * parent() const const
virtual bool event(QEvent *event) override
Used to keep track of the various Y-axes and connect them to the QLineEdits.
Definition yaxistool.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.