AngleSpinBox.hpp   AngleSpinBox.hpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2008 Matthew Gates * Copyright (C) 2008 Matthew Gates
* Copyright (C) 2015 Georg Zotti (min/max limits)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 25 skipping to change at line 26
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _ANGLESPINBOX_HPP_ #ifndef _ANGLESPINBOX_HPP_
#define _ANGLESPINBOX_HPP_ #define _ANGLESPINBOX_HPP_
#include <QAbstractSpinBox> #include <QAbstractSpinBox>
#include <QString> #include <QString>
#include <cmath>
//! @class AngleSpinBox //! @class AngleSpinBox
//! A spin box for displaying/entering angular values. //! A spin box for displaying/entering angular values.
//! This class can accept angles in various formats commonly used in astron omy //! This class can accept angles in various formats commonly used in astron omy
//! including decimal degrees, DMS and HMS. //! including decimal degrees, DMS and HMS.
//! You should set upper and lower limits (maximum, minimum) and
//! decide whether the values wrap around or are blocked at the limits (wra
pping).
class AngleSpinBox : public QAbstractSpinBox class AngleSpinBox : public QAbstractSpinBox
{ {
Q_OBJECT Q_OBJECT
public: public:
//! @enum DisplayFormat //! @enum DisplayFormat
//! Used to decide how to display the angle. //! Used to decide how to display the angle.
enum DisplayFormat enum DisplayFormat
{ {
DMSLetters, //!< Degrees, minutes and seconds, e .g. 180d 4m 8s, with negative values, [-360..360d] DMSLetters, //!< Degrees, minutes and seconds, e .g. 180d 4m 8s, with negative values, [-360..360d]
skipping to change at line 97 skipping to change at line 101
DisplayFormat displayFormat() { return angleSpinBoxFormat; } DisplayFormat displayFormat() { return angleSpinBoxFormat; }
//! Set the prefix type. //! Set the prefix type.
//! @param prefix the new prefix type to use. //! @param prefix the new prefix type to use.
void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; fo rmatText(); } void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; fo rmatText(); }
//! Get the current display format. //! Get the current display format.
//! @return the current DisplayFormat. //! @return the current DisplayFormat.
PrefixType prefixType() { return currentPrefixType; } PrefixType prefixType() { return currentPrefixType; }
//! Set the minimum value.
//! @param min the new minimum value
//! @param isDegrees true if the new minimum value is given in degre
es, else min is understood as radians.
void setMinimum(const double min, const bool isDegrees=false) {minRa
d = min * (isDegrees? M_PI/180.0 : 1.); }
//! Get the minimum value.
//! @return the current minimum value
//! @param isDegrees true if the minimum value is required in degree
s, else min is returned as radians.
double getMinimum(const bool isDegrees) { return minRad * (isDegrees
? 180.0/M_PI : 1.0); }
//! Set the maximum value.
//! @param max the new maximum value
//! @param isDegrees true if the new maximum value is given in degre
es, else max is understood as radians.
void setMaximum(const double max, const bool isDegrees=false) {maxRa
d = max * (isDegrees? M_PI/180.0 : 1.); }
//! Get the maximum value.
//! @return the current maximum value
//! @param isDegrees true if the maximum value is required in degree
s, else max is returned as radians.
double getMaximum(const bool isDegrees) { return maxRad * (isDegrees
? 180.0/M_PI : 1.0); }
public slots: public slots:
//! Set the value to default 0 angle. //! Set the value to default 0 angle.
virtual void clear(); virtual void clear();
//! Set the value of the spin box in radians. //! Set the value of the spin box in radians.
//! @param radians the value to set, in radians. //! @param radians the value to set, in radians.
void setRadians(double radians); void setRadians(double radians);
//! Set the value of the spin box in decimal degrees. //! Set the value of the spin box in decimal degrees.
//! @param degrees the value to set, in decimal degrees. //! @param degrees the value to set, in decimal degrees.
skipping to change at line 155 skipping to change at line 177
//! e.g. when RETURN is pressed. //! e.g. when RETURN is pressed.
void formatText(void); void formatText(void);
static const QString positivePrefix(PrefixType prefix); static const QString positivePrefix(PrefixType prefix);
static const QString negativePrefix(PrefixType prefix); static const QString negativePrefix(PrefixType prefix);
DisplayFormat angleSpinBoxFormat; DisplayFormat angleSpinBoxFormat;
PrefixType currentPrefixType; PrefixType currentPrefixType;
int decimalPlaces; int decimalPlaces;
double radAngle; double radAngle;
// min/max angles (radians), users should not be able to enter more/
less.
// Use together with the wrapping() property!
double minRad;
double maxRad;
}; };
#endif // _ANGLESPINBOX_HPP_ #endif // _ANGLESPINBOX_HPP_
 End of changes. 5 change blocks. 
1 lines changed or deleted 36 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/