27 void dms::setD(
const int &
d, 
const int &m, 
const int &s, 
const int &ms) {
 
   28     D = (double)abs(d) + ((double)m + ((
double)s + (double)ms/1000.)/60.)/60.;
 
   29     if (d<0) {D = -1.0*D;}
 
   32 void dms::setH( 
const double &x ) {
 
   36 void dms::setH(
const int &h, 
const int &m, 
const int &s, 
const int &ms) {
 
   37     D = 15.0*((double)abs(h) + ((double)m + ((
double)s + (double)ms/1000.)/60.)/60.);
 
   38     if (h<0) {D = -1.0*D;}
 
   41 void dms::setRadians( 
const double &Rad ) {
 
   45 bool dms::setFromString( 
const QString &str, 
bool isDeg ) {
 
   48     bool checkValue( 
false ), badEntry( 
false ), negative( 
false );
 
   49     QString entry = str.trimmed();
 
   50     entry.remove( QRegExp(
"[hdms'\"°]") );
 
   54     entry.replace( KGlobal::locale()->decimalSymbol(), 
"." );
 
   57     if ( entry.isEmpty() ) {
 
   63     d = entry.toInt( &checkValue );
 
   65         if (isDeg) 
setD( d, 0, 0 );
 
   71     double x = entry.toDouble( &checkValue );
 
   73         if ( isDeg ) 
setD( x );
 
   82     if ( entry.contains(
':') )
 
   83         fields = entry.split( 
':', QString::SkipEmptyParts );
 
   84     else fields = entry.split( 
' ', QString::SkipEmptyParts );
 
   87     if ( fields.count() == 1 ) {
 
   97     if ( fields.count() == 2 ) {
 
   98         m = fields[1].toInt( &checkValue );
 
   99         if ( checkValue ) fields.append( QString( 
"0" ) );
 
  101             double mx = fields[1].toDouble( &checkValue );
 
  103                 fields[1] = QString::number( 
int(mx) );
 
  104                 fields.append( QString::number( 
int( 60.0*(mx - 
int(mx)) ) ) );
 
  114     if ( fields.count() >= 3 ) {
 
  117         d = fields[0].toInt( &checkValue );
 
  118         if ( !checkValue ) badEntry = 
true;
 
  119         m = fields[1].toInt( &checkValue );
 
  120         if ( !checkValue ) badEntry = 
true;
 
  121         s = fields[2].toDouble( &checkValue );
 
  122         if ( !checkValue ) badEntry = 
true;
 
  126         if ( fields[0].at(0) == 
'-' && d == 0 ) negative = 
true;
 
  130         double D = (double)abs(d) + (double)abs(m)/60.
 
  131                    + (double)fabs(s)/3600.;
 
  133         if ( negative || d<0 || m < 0 || s<0 ) { D = -1.0*D;}
 
  149     int am = int( 
float( 60.0*( fabs(D) - abs( 
degree() ) ) ) );
 
  150     if ( D<0.0 && D>-1.0 ) { 
 
  157     int as = int( 
float( 60.0*( 60.0*( fabs(D) - abs( 
degree() ) ) - abs( 
arcmin() ) ) ) );
 
  166     int as = int( 
float( 1000.0*(60.0*( 60.0*( fabs(D) - abs( 
degree() ) ) - abs( 
arcmin() ) ) - abs( 
arcsec() ) ) ) );
 
  175     int hm = int( 
float( 60.0*( fabs( 
Hours() ) - abs( 
hour() ) ) ) );
 
  183     int hs = int( 
float( 60.0*( 60.0*( fabs( 
Hours() ) - abs( 
hour() ) ) - abs( 
minute() ) ) ) );
 
  191     int hs = int( 
float( 1000.0*(60.0*( 60.0*( fabs( 
Hours() ) - abs( 
hour() ) ) - abs( 
minute() ) ) - abs( 
second() ) ) ) );
 
  199 const dms dms::reduce( 
void )
 const {
 
  200     return dms( D - 360.0*floor(D/360.0) );
 
  203 const QString dms::toDMSString(
const bool forceSign)
 const {
 
  210     if ( 
Degrees() < 0.0 ) pm = 
'-';
 
  211     else if (forceSign && 
Degrees() > 0.0 ) pm = 
'+';
 
  214         return dummy.sprintf(
"%c%1d%c %02d\' %02d\"", pm, dd, 176, dm, ds);
 
  216         return dummy.sprintf(
"%c%2d%c %02d\' %02d\"", pm, dd, 176, dm, ds);
 
  218     return dummy.sprintf(
"%c%3d%c %02d\' %02d\"", pm, dd, 176, dm, ds);
 
  221 const QString dms::toHMSString()
 const {
 
  226 dms dms::fromString(
const QString &st, 
bool deg) {
 
  230     ok = result.setFromString( st, deg );
 
  242 const double dms::DegToRad = 
PI/180.0;
 
const double & Degrees() const 
 
dms()
Default constructor. 
 
An angle, stored as degrees, but expressible in many ways. 
 
void setD(const double &x)
Sets floating-point value of angle, in degrees.