Stellarium  23.4
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions
AngleSpinBox Class Reference

A spin box for displaying/entering angular values. More...

#include <AngleSpinBox.hpp>

Public Types

enum  DisplayFormat {
  DMSLetters , DMSSymbols , DMSLettersUnsigned , DMSSymbolsUnsigned ,
  HMSLetters , HMSSymbols , DecimalDeg
}
 Used to decide how to display the angle. More...
 
enum  PrefixType {
  Normal , NormalPlus , Longitude , Latitude ,
  Unknown
}
 Determines how positive and negative values are indicated. More...
 

Public Slots

virtual void clear () Q_DECL_OVERRIDE
 Set the value to default 0 angle.
 
void setRadians (double radians)
 Set the value of the spin box in radians. More...
 
void setDegrees (double degrees)
 Set the value of the spin box in decimal degrees. More...
 

Signals

void valueChanged ()
 Emitted when the value changes.
 
void valueChangedDeg (double)
 
void valueChangedRad (double)
 

Public Member Functions

 AngleSpinBox (QWidget *parent=Q_NULLPTR, DisplayFormat format=DMSSymbols, PrefixType prefix=Normal)
 
virtual void stepBy (int steps) Q_DECL_OVERRIDE
 
virtual QValidator::State validate (QString &input, int &pos) const Q_DECL_OVERRIDE
 
double valueRadians () const
 Get the angle held in the AngleSpinBox. More...
 
double valueDegrees () const
 Get the angle held in the AngleSpinBox. More...
 
void setDecimals (int places)
 Set the number of decimal places to express float values to (e.g. More...
 
int decimals () const
 Get the number of decimal places to express float values to (e.g. More...
 
void setDisplayFormat (DisplayFormat format)
 Set the display format. More...
 
DisplayFormat displayFormat () const
 Get the current display format. More...
 
void setPrefixType (PrefixType prefix)
 Set the prefix type. More...
 
PrefixType prefixType () const
 Get the current display format. More...
 
void setMinimum (const double min, const bool isDegrees=false)
 Set the minimum value. More...
 
double getMinimum (const bool isDegrees) const
 Get the minimum value. More...
 
void setMaximum (const double max, const bool isDegrees=false)
 Set the maximum value. More...
 
double getMaximum (const bool isDegrees) const
 Get the maximum value. More...
 
QSize minimumSizeHint () const override
 

Protected Member Functions

virtual StepEnabled stepEnabled () const Q_DECL_OVERRIDE
 

Detailed Description

A spin box for displaying/entering angular values.

This class can accept angles in various formats commonly used in astronomy 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 (wrapping).

Member Enumeration Documentation

◆ DisplayFormat

Used to decide how to display the angle.

Enumerator
DMSLetters 

Degrees, minutes and seconds, e.g. 180d 4m 8s, with negative values, [-360..360d].

DMSSymbols 

Degrees, minutes and seconds, e.g. 180° 4' 8", with negative values, [-360..360°].

DMSLettersUnsigned 

Degrees, minutes and seconds, e.g. 180d 4m 8s, [0..360d].

DMSSymbolsUnsigned 

Degrees, minutes and seconds, e.g. 180° 4' 8", [0..360°].

HMSLetters 

Hours, minutes and seconds, e.g. 12h 4m 6s.

HMSSymbols 

Hours, minutes and seconds, e.g. 12h 4' 6s".

DecimalDeg 

Decimal degrees, e.g. 180.06888.

◆ PrefixType

Determines how positive and negative values are indicated.

Enumerator
Normal 

negative values have '-' prefix

NormalPlus 

positive values have '+' prefix, negative values have '-' prefix.

Longitude 

positive values have 'E' prefix, negative values have 'W' prefix.

Latitude 

positive values have 'N' prefix, negative values have 'S' prefix.

Member Function Documentation

◆ decimals()

int AngleSpinBox::decimals ( ) const
inline

Get the number of decimal places to express float values to (e.g.

seconds in DMSLetters format).

Returns
the number of decimal places used.

◆ displayFormat()

DisplayFormat AngleSpinBox::displayFormat ( ) const
inline

Get the current display format.

Returns
the current DisplayFormat.

◆ getMaximum()

double AngleSpinBox::getMaximum ( const bool  isDegrees) const
inline

Get the maximum value.

Returns
the current maximum value
Parameters
isDegreestrue if the maximum value is required in degrees, else max is returned as radians.

◆ getMinimum()

double AngleSpinBox::getMinimum ( const bool  isDegrees) const
inline

Get the minimum value.

Returns
the current minimum value
Parameters
isDegreestrue if the minimum value is required in degrees, else min is returned as radians.

◆ prefixType()

PrefixType AngleSpinBox::prefixType ( ) const
inline

Get the current display format.

Returns
the current DisplayFormat.

◆ setDecimals()

void AngleSpinBox::setDecimals ( int  places)
inline

Set the number of decimal places to express float values to (e.g.

seconds in DMSLetters format).

Parameters
placesthe number of decimal places to use.

◆ setDegrees

void AngleSpinBox::setDegrees ( double  degrees)
slot

Set the value of the spin box in decimal degrees.

Parameters
degreesthe value to set, in decimal degrees.

◆ setDisplayFormat()

void AngleSpinBox::setDisplayFormat ( DisplayFormat  format)
inline

Set the display format.

Parameters
formatthe new format to use.

◆ setMaximum()

void AngleSpinBox::setMaximum ( const double  max,
const bool  isDegrees = false 
)
inline

Set the maximum value.

Parameters
maxthe new maximum value
isDegreestrue if the new maximum value is given in degrees, else max is understood as radians.

◆ setMinimum()

void AngleSpinBox::setMinimum ( const double  min,
const bool  isDegrees = false 
)
inline

Set the minimum value.

Parameters
minthe new minimum value
isDegreestrue if the new minimum value is given in degrees, else min is understood as radians.

◆ setPrefixType()

void AngleSpinBox::setPrefixType ( PrefixType  prefix)
inline

Set the prefix type.

Parameters
prefixthe new prefix type to use.

◆ setRadians

void AngleSpinBox::setRadians ( double  radians)
slot

Set the value of the spin box in radians.

Parameters
radiansthe value to set, in radians.

◆ valueDegrees()

double AngleSpinBox::valueDegrees ( ) const

Get the angle held in the AngleSpinBox.

Returns
the angle in degrees

◆ valueRadians()

double AngleSpinBox::valueRadians ( ) const

Get the angle held in the AngleSpinBox.

Returns
the angle in radians