moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / skyobject.h
blobe5626d6a5637377d38e3a6f6a39d5ed83fc009f9
1 /***************************************************************************
2 skyobject.h - K Desktop Planetarium
3 -------------------
4 begin : Sun Feb 11 2001
5 copyright : (C) 2001 by Jason Harris
6 email : jharris@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef SKYOBJECT_H
19 #define SKYOBJECT_H
21 #include <qstring.h>
22 #include <qstringlist.h>
24 #include <klocale.h>
26 #include "skypoint.h"
27 #include "dms.h"
28 #include "kspopupmenu.h"
30 /**@class SkyObject
31 *Provides all necessary information about an object in the sky:
32 *its coordinates, name(s), type, magnitude, and QStringLists of
33 *URLs for images and webpages regarding the object.
34 *@short Information about an object in the sky.
35 *@author Jason Harris
36 *@version 1.0
39 class QPoint;
40 class GeoLocation;
41 class KStarsDateTime;
43 class SkyObject : public SkyPoint {
44 public:
45 /**Constructor. Set SkyObject data according to arguments.
46 *@param t Type of object
47 *@param r catalog Right Ascension
48 *@param d catalog Declination
49 *@param m magnitude (brightness)
50 *@param n Primary name
51 *@param n2 Secondary name
53 SkyObject( int t=TYPE_UNKNOWN, dms r=dms(0.0), dms d=dms(0.0),
54 float m=0.0, QString n="", QString n2="", QString lname="" );
55 /**
56 *Constructor. Set SkyObject data according to arguments. Differs from
57 *above function only in data type of RA and Dec.
58 *@param t Type of object
59 *@param r catalog Right Ascension
60 *@param d catalog Declination
61 *@param m magnitude (brightness)
62 *@param n Primary name
63 *@param n2 Secondary name
64 *@param lname Long name (common name)
66 SkyObject( int t, double r, double d, float m=0.0,
67 QString n="", QString n2="", QString Tlname="" );
69 /**Copy constructor.
70 *@param o SkyObject from which to copy data
72 SkyObject( SkyObject &o );
74 /**
75 *Destructor (empty)
77 ~SkyObject();
79 /**@enum TYPE
80 *The type classification of the SkyObject.
82 enum TYPE { STAR=0, CATALOG_STAR=1, PLANET=2, OPEN_CLUSTER=3, GLOBULAR_CLUSTER=4,
83 GASEOUS_NEBULA=5, PLANETARY_NEBULA=6, SUPERNOVA_REMNANT=7, GALAXY=8, COMET=9,
84 ASTEROID=10, CONSTELLATION=11, TYPE_UNKNOWN };
86 /**@return object's primary name.
88 virtual QString name( void ) const { return hasName() ? *Name : unnamedString;}
90 /**@return object's primary name, translated to local language.
92 QString translatedName() const { return i18n( name().utf8() );}
94 /**Set the object's primary name.
95 *@param name the object's primary name
97 void setName( const QString &name );
99 /**@return object's secondary name
101 QString name2( void ) const { return hasName2() ? *Name2 : emptyString; }
103 /**@return object's secondary name, translated to local language.
105 QString translatedName2() const { return i18n( name2().utf8() );}
107 /**Set the object's secondary name.
108 *@param the object's secondary name.
110 void setName2( const QString &name2="" );
112 /**@return object's common (long) name
114 virtual QString longname( void ) const { return hasLongName() ? *LongName : unnamedObjectString; }
116 /**@return object's common (long) name, translated to local language.
118 QString translatedLongName() const { return i18n( longname().utf8() );}
120 /**Set the object's long name.
121 *@param the object's long name.
123 void setLongName( const QString &longname="" );
125 /**@return object's type identifier (int)
126 *@see enum TYPE
128 int type( void ) const { return (int)Type; }
130 /**Set the object's type identifier to the argument.
131 *@param t the object's type identifier (e.g., "SkyObject::PLANETARY_NEBULA")
132 *@see enum TYPE
134 void setType( int t ) { Type = (unsigned char)t; }
136 /**@return a string describing object's type.
138 QString typeName( void ) const;
140 /**@return object's magnitude
142 float mag( void ) const { return Magnitude; }
144 /**Set the object's magnitude.
145 *@param m the object's magnitude.
147 void setMag( float m ) { Magnitude = m; }
149 /**@return the object's position angle. This is overridden in KSPlanetBase
150 *and DeepSkyObject; for all other SkyObjects, this returns 0.0.
152 virtual double pa() const { return 0.0; }
154 /**@return true if the object is a solar system body.
156 bool isSolarSystem() { return ( type() == 2 || type() == 9 || type() == 10 ); }
158 /**Show Type-specific popup menu. This is a two-line function that needs to be
159 *overloaded by each subclass of SkyObject, to make sure that the correct popupmenu
160 *function gets called. By overloading the function, we don't have to check the
161 *object type when we need the menu.
163 virtual void showPopupMenu( KSPopupMenu *pmenu, QPoint pos ) { pmenu->createEmptyMenu( this ); pmenu->popup( pos ); }
165 /**Determine the time at which the point will rise or set. Because solar system
166 *objects move across the sky, it is necessary to iterate on the solution.
167 *We compute the rise/set time for the object's current position, then
168 *compute the object's position at that time. Finally, we recompute then
169 *rise/set time for the new coordinates. Further iteration is not necessary,
170 *even for the most swiftly-moving object (the Moon).
171 *@return the local time that the object will rise
172 *@param dt current UT date/time
173 *@param geo current geographic location
174 *@param rst If TRUE, compute rise time. If FALSE, compute set time.
176 QTime riseSetTime( const KStarsDateTime &dt, const GeoLocation *geo, bool rst );
178 /**@return the UT time when the object will rise or set
179 *@param dt target date/time
180 *@param geo pointer to Geographic location
181 *@param rst Boolean. If TRUE will compute rise time. If FALSE
182 * will compute set time.
184 QTime riseSetTimeUT( const KStarsDateTime &dt, const GeoLocation *geo, bool rst);
186 /**@return the LST time when the object will rise or set
187 *@param dt target date/time
188 *@param geo pointer to Geographic location
189 *@param gLt Geographic latitude
190 *@param rst Boolean. If TRUE will compute rise time. If FALSE
191 * will compute set time.
193 dms riseSetTimeLST( const KStarsDateTime &dt, const GeoLocation *geo, bool rst);
195 /**@return the Azimuth time when the object will rise or set. This function
196 *recomputes set or rise UT times.
197 *@param dt target date/time
198 *@param geo GeoLocation object
199 *@param rst Boolen. If TRUE will compute rise time. If FALSE
200 * will compute set time.
202 dms riseSetTimeAz( const KStarsDateTime &dt, const GeoLocation *geo, bool rst);
204 /**The same iteration technique described in riseSetTime() is used here.
205 *@return the local time that the object will transit the meridian.
206 *@param dt target date/time
207 *@param geo pointer to the geographic location
209 QTime transitTime( const KStarsDateTime &dt, const GeoLocation *geo );
211 /**@return the universal time that the object will transit the meridian.
212 *@param dt target date/time
213 *@param gLng pointer to the geographic longitude
215 QTime transitTimeUT( const KStarsDateTime &dt, const GeoLocation *geo );
217 /**@return the altitude of the object at the moment it transits the meridian.
218 *@param dt target date/time
219 *@param geo pointer to the geographic location
221 dms transitAltitude( const KStarsDateTime &dt, const GeoLocation *geo );
223 /**Check whether a source is circumpolar or not. True = cirmcumpolar
224 *False = Not circumpolar
225 *@return true if circumpolar
227 bool checkCircumpolar( const dms *gLng );
229 /**The coordinates for the object on date dt are computed and returned,
230 *but the object's internal coordinates are not permanently modified.
231 *@return the coordinates of the selected object for the time given by jd
232 *@param dt date/time for which the coords will be computed.
233 *@param geo pointer to geographic location (used for solar system only)
235 SkyPoint recomputeCoords( const KStarsDateTime &dt, const GeoLocation *geo=0 );
237 const bool hasName() const { return Name != 0; }
239 const bool hasName2() const { return Name2 != 0; }
241 const bool hasLongName() const { return LongName != 0; }
243 /**@short Given the Image title from a URL file, try to convert it to an image credit string.
245 QString messageFromTitle( const QString &imageTitle );
247 /**@short Save new user log text
249 void saveUserLog( const QString &newLog );
251 QStringList ImageList, ImageTitle;
252 QStringList InfoList, InfoTitle;
253 QString userLog;
255 private:
257 /**Compute the UT time when the object will rise or set. It is an auxiliary
258 *procedure because it does not use the RA and DEC of the object but values
259 *given as parameters. You may want to use riseSetTimeUT() which is
260 *public. riseSetTimeUT() calls this function iteratively.
261 *@param dt target date/time
262 *@param geo pointer to Geographic location
263 *@param righta pointer to Right ascention of the object
264 *@param decl pointer to Declination of the object
265 *@param rst Boolean. If TRUE will compute rise time. If FALSE
266 * will compute set time.
267 *@return the time at which the given position will rise or set.
269 QTime auxRiseSetTimeUT( const KStarsDateTime &dt, const GeoLocation *geo,
270 const dms *righta, const dms *decl, bool riseT);
272 /**Compute the LST time when the object will rise or set. It is an auxiliary
273 *procedure because it does not use the RA and DEC of the object but values
274 *given as parameters. You may want to use riseSetTimeLST() which is
275 *public. riseSetTimeLST() calls this function iteratively.
276 *@param gLt Geographic latitude
277 *@param rga Right ascention of the object
278 *@param decl Declination of the object
279 *@param rst Boolean. If TRUE will compute rise time. If FALSE
280 * will compute set time.
282 dms auxRiseSetTimeLST( const dms *gLt, const dms *rga, const dms *decl, bool rst );
284 /**Compute the approximate hour angle that an object with declination d will have
285 *when its altitude is h (as seen from geographic latitude gLat).
286 *This function is only used by auxRiseSetTimeLST().
287 *@param h pointer to the altitude of the object
288 *@param gLat pointer to the geographic latitude
289 *@param d pointer to the declination of the object.
290 *@return the Hour Angle, in degrees.
292 double approxHourAngle( const dms *h, const dms *gLat, const dms *d );
294 /**Correct for the geometric altitude of the center of the body at the
295 *time of rising or setting. This is due to refraction at the horizon
296 *and to the size of the body. The moon correction has also to take into
297 *account parallax. The value we use here is a rough approximation
298 *suggeted by J. Meeus.
300 *Weather status (temperature and pressure basically) is not taken
301 *into account although change of conditions between summer and
302 *winter could shift the times of sunrise and sunset by 20 seconds.
304 *This function is only used by auxRiseSetTimeLST().
305 *@return dms object with the correction.
307 dms elevationCorrection(void);
309 unsigned char Type;
310 float Magnitude;
312 protected:
314 QString *Name, *Name2, *LongName;
316 // store often used name strings in static variables
317 static QString emptyString;
318 static QString unnamedString;
319 static QString unnamedObjectString;
320 static QString starString;
323 #endif