00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _ANGLESPINBOX_HPP_
00021 #define _ANGLESPINBOX_HPP_
00022
00023 #include <QAbstractSpinBox>
00024 #include <QString>
00025
00030 class AngleSpinBox : public QAbstractSpinBox
00031 {
00032 Q_OBJECT
00033
00034 public:
00037 enum DisplayFormat
00038 {
00039 DMSLetters,
00040 DMSSymbols,
00041 HMSLetters,
00042 HMSSymbols,
00043 DecimalDeg
00044 };
00045
00048 enum PrefixType
00049 {
00050 Normal,
00051 NormalPlus,
00052 Longitude,
00053 Latitude,
00054 Unknown
00055 };
00056
00057 AngleSpinBox(QWidget* parent=0, DisplayFormat format=DMSSymbols, PrefixType prefix=Normal);
00058 ~AngleSpinBox();
00059
00060
00061 void stepBy (int steps);
00062 QValidator::State validate (QString& input, int& pos) const;
00063
00066 double valueRadians();
00069 double valueDegrees();
00070
00073 QString text();
00074
00082 double stringToDouble(QString input, QValidator::State* state, PrefixType prefix=Unknown) const;
00083
00086 void setDecimals(int places) { decimalPlaces = places; }
00087
00090 int decimals() { return decimalPlaces; }
00091
00094 void setDisplayFormat(DisplayFormat format) { angleSpinBoxFormat=format; formatText(); }
00095
00098 DisplayFormat displayFormat() { return angleSpinBoxFormat; }
00099
00102 void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; formatText(); }
00103
00106 PrefixType prefixType() { return currentPrefixType; }
00107
00108 public slots:
00109 void clear();
00110
00113 void setRadians(double radians);
00116 void setDegrees(double degrees);
00117
00118 signals:
00120 void valueChanged();
00121
00122 protected:
00123 StepEnabled stepEnabled () const;
00124
00125 private slots:
00127 void updateValue(void);
00128
00129 private:
00130
00132 enum AngleSpinboxSection
00133 {
00134 SectionPrefix,
00135 SectionDegreesHours,
00136 SectionMinutes,
00137 SectionSeconds,
00138 SectionNone
00139 };
00140
00142 AngleSpinboxSection getCurrentSection() const;
00143
00147 void formatText(void);
00148
00149 static const QString positivePrefix(PrefixType prefix);
00150 static const QString negativePrefix(PrefixType prefix);
00151
00152 DisplayFormat angleSpinBoxFormat;
00153 PrefixType currentPrefixType;
00154 int decimalPlaces;
00155 double radAngle;
00156
00157 };
00158
00159 #endif // _ANGLESPINBOX_HPP_