cut 3.3.0
Loading...
Searching...
No Matches
QeAngleLabel.hpp
1#ifndef QEANGLELABEL_HPP
2#define QEANGLELABEL_HPP
3
4#include <QObject>
5#include <QString>
6#include <QVariant>
7#include <QWidget>
8#include <QLabel>
9
21class QeAngleLabel : public QLabel {
22 Q_OBJECT
23
28 Q_PROPERTY(double radians READ getRadians WRITE setRadians NOTIFY radiansChanged )
29
30
37 Q_PROPERTY(int precision READ getPrecision WRITE setPrecision NOTIFY precisionChanged )
38
43 Q_PROPERTY(bool showUnits READ getShowUnits WRITE setShowUnits NOTIFY showUnitsChanged )
44
49 Q_PROPERTY(Units units READ getUnits WRITE setUnits NOTIFY unitChanged )
50
54 Q_PROPERTY(Units hmsDmsHandling READ getHmsDmsHandling WRITE setHmsDmsHandling NOTIFY hmsDmsHandlingChanged )
55
56public:
57 explicit QeAngleLabel(QWidget *parent = Q_NULLPTR);
58 ~QeAngleLabel();
59 enum Units {SEXAGESIMAL=0, SEXAGECIMAL=0, RADIANS=1, HMS, DMS};
60 Q_ENUM(Units)
61 double getRadians(){ return m_radians; }
62 int getPrecision(){ return m_precision; }
63 bool getShowUnits(){ return m_showUnits; }
64 Units getUnits(){ return m_units; }
65 Units getHmsDmsHandling(){return m_hmsDmsHandling; }
66
67
68signals:
72 void radiansChanged(double newValue);
73
77 void precisionChanged(int newValue);
78
83
87 [[deprecated("Please use unitChanged(QeAngleLabel::Units newUnit) signal instead")]]
88 void unitsChanged(QeAngleLabel::Units units);
89
93 void unitChanged(QeAngleLabel::Units units);
94
98 void hmsDmsHandlingChanged(QeAngleLabel::Units hmsDmsHandling);
99
100public slots:
101 void setRadians(double newValue){this->m_radians = newValue; emit radiansChanged(newValue); this->update();};
102 void setPrecision(int newValue){this->m_precision = newValue; emit precisionChanged(newValue); this->update();};
103 void setShowUnits(bool newValue){this->m_showUnits = newValue; emit showUnitsChanged(newValue); this->update();};
104 void setUnits(Units units)
105 {
106 if (m_units == units)
107 return;
108
109 m_units = units;
110 emit unitChanged(m_units);
111
112 this->update();
113 }
119 if (m_units == static_cast<Units>(units))
120 return;
121
122 m_units = static_cast<Units>(units);
123 emit unitChanged(m_units);
124
125 this->update();
126 }
127 void update();
128
129 void setHmsDmsHandling(Units units)
130 {
131 if (m_hmsDmsHandling == units)
132 return;
133
134 m_hmsDmsHandling = units;
135 emit hmsDmsHandlingChanged(m_hmsDmsHandling);
136 this->update();
137 }
138
139private:
140 double m_radians = 0.0;
141 int m_precision = 3;
142 bool m_showUnits = true;
143 Units m_units = Units::DMS;
144 Units m_hmsDmsHandling = Units::SEXAGECIMAL;
145};
146
147#endif // QEANGLELABEL_HPP
void radiansChanged(double newValue)
Indicates that the radians value has been changed.
double radians
Value to represent in radians.
Definition QeAngleLabel.hpp:28
void setUnitsInt(int units)
Convinience method to allow setting Units using its integer representation.
Definition QeAngleLabel.hpp:118
void precisionChanged(int newValue)
Indicates the precision configuration has been changed.
Units hmsDmsHandling
Enum value to determine if the widget supports HMS/DMS units.
Definition QeAngleLabel.hpp:54
void showUnitsChanged(bool showUnits)
Indicates that showUnits member has been changed.
bool showUnits
Bool value to determine if units should be visible.
Definition QeAngleLabel.hpp:43
Units units
Enum value to determine which units should be used to represent displayed value.
Definition QeAngleLabel.hpp:49
int precision
Precision used in the subsecond section of the label.
Definition QeAngleLabel.hpp:37
void unitChanged(QeAngleLabel::Units units)
Indicates that units of displayed value has been changed.
void unitsChanged(QeAngleLabel::Units units)
Indicates that units of displayed value has been changed.
void hmsDmsHandlingChanged(QeAngleLabel::Units hmsDmsHandling)
Indicates that HMS/DMS handling changed.