Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

core/StelUtils.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2002 Fabien Chereau
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELUTILS_HPP_
00021 #define _STELUTILS_HPP_
00022 
00023 #include "VecMath.hpp"
00024 #include "fixx11h.h"
00025 
00026 #include <QVariantMap>
00027 #include <QDateTime>
00028 #include <QString>
00029 
00030 // astonomical unit (km)
00031 #define AU 149597870.691
00032 // Parsec (km)
00033 #define PARSEC 30.857e12
00034 // speed of light (km/sec)
00035 #define SPEED_OF_LIGHT 299792.458
00036 
00038 namespace StelUtils
00039 {
00040 
00046     double hmsToRad(unsigned int h, unsigned int m, double s);
00047                
00053     double dmsToRad(int d, unsigned int m, double s);
00054     
00060     void radToHms(double rad, unsigned int& h, unsigned int& m, double& s);
00061     
00068     void radToDms(double rad, bool& sign, unsigned int& d, unsigned int& m, double& s); 
00069 
00073     QString radToHmsStrAdapt(double angle);
00074     
00078     QString radToHmsStr(double angle, bool decimal=false);
00079     
00084     QString radToDmsStrAdapt(double angle, bool useD=false);
00085     
00090     QString radToDmsStr(double angle, bool decimal=false, bool useD=false);
00091     
00096     Vec3f strToVec3f(const QStringList& s);
00097     Vec3f strToVec3f(const QString& s);
00098     
00102     QString vec3fToHtmlColor(const Vec3f& v);
00103 
00106     Vec3f htmlColorToVec3f(const QString& c);
00107         
00112     void spheToRect(double lng, double lat, Vec3d& v);
00113     
00118     void spheToRect(float lng, float lat, Vec3f& v);
00119     
00124     void rectToSphe(double *lng, double *lat, const Vec3d& v);
00125 
00130     void rectToSphe(float *lng, float *lat, const Vec3d& v);
00131 
00152     double getDecAngle(const QString& str);
00153     
00155     bool isPowerOfTwo(int value);
00156     
00158     int getBiggerPowerOfTwo(int value);
00159     
00161     double asinh(double z);
00162     
00164     // New Qt based General Calendar Functions. 
00166     void getDateFromJulianDay(double julianDay, int *year, int *month, int *day);
00167 
00169     void getTimeFromJulianDay(double julianDay, int *hour, int *minute, int *second);
00170 
00172     QString sixIntsToIsoString( int year, int month, int day, int hour, int minute, int second );
00173 
00174     QString jdToIsoString(double jd);
00175 
00178     QString localeDateString(int year, int month, int day, int dayOfWeek, QString fmt);
00179 
00182     QString localeDateString(int year, int month, int day, int dayOfWeek);
00183 
00186     double getJDFromSystem(void);
00187 
00191     double qTimeToJDFraction(const QTime& time);
00192 
00194     QTime jdFractionToQTime(const double jd);
00195 
00197     float getGMTShiftFromQT(double JD);
00198 
00202     double qDateTimeToJd(const QDateTime& dateTime);
00203 
00207     QDateTime jdToQDateTime(const double& jd);
00208 
00209     bool getJDFromDate(double* newjd, int y, int m, int d, int h, int min, int s);
00210 
00211     int numberOfDaysInMonthInYear(int month, int year);
00212     bool changeDateTimeForRollover(int oy, int om, int od, int oh, int omin, int os,
00213                                    int* ry, int* rm, int* rd, int* rh, int* rmin, int* rs);
00214 
00216     void debugQVariantMap(const QVariant& m, const QString& indent="", const QString& key="");
00217     
00219     QList<int> getIntsFromISO8601String(const QString& iso8601Date);
00220 }
00221 
00222 #endif // _STELUTILS_HPP_

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5