summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/planetcatalog.h
blob: c6337b2ae0efee434756fd51262db7ede5415a21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/***************************************************************************
                          planetcatalog.h  -  description
                             -------------------
    begin                : Mon Feb 18 2002
    copyright          : (C) 2002 by Mark Hollomon
    email                : mhh@mindspring.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PLANETCATALOG_H
#define PLANETCATALOG_H

/**@class PlanetCatalog
	*This class contains a TQPtrList of the eight major planets, as well as pointers
	*to objects representing the Earth and Sun.  Note that the Sun also exists
	*in the TQPtrList, the external pointer is just for convenience.
	*There are methods to search
	*the collection by name, identify if a given object pointer is a planet,
	*find the coordinates of a planet, and find the planet closest to a given
	*SkyPoint.
	*@short the collection of planet objects.
	*@author Mark Hollomon
	*@version 1.0
	*/

#include <tqglobal.h>
#include <tqobject.h>
#include <tqptrlist.h>

class TQString;
class KStarsData;
class KSNumbers;
class KSPlanetBase;
class KSPlanet;
class KSSun;
class SkyPoint;
class SkyObject;
class ObjectNameList;
class dms;

class PlanetCatalog : public TQObject {
	TQ_OBJECT


	public:
	/**Constructor. */
		PlanetCatalog(KStarsData *dat);

	/**Destructor. Delete the Earth object (all others auto-deleted by TQPtrList)*/
		~PlanetCatalog();

	/**Loads all planetary data from files on disk into the appropriate objects. */
		bool initialize();

	/**Add pointers to the planetary objects to the ObjNames list.
		*@p ObjNames the list of all named objects to which we will add the planets.
		*/
		void addObject( ObjectNameList &ObjNames ) const;

	/**Determine the coordinates for all of the planets
		*@param num pointer to a ksnumbers object for the target date/time
		*@param lat pointer to the geographic latitude
		*@param LST pointer to the local sidereal time
		*/
		void findPosition( const KSNumbers *num, const dms *lat, const dms *LST );

	/**@return pointer to the Sun. */
		const KSSun *planetSun() const { return Sun; }

	/**@return pointer to the Earth. (must not be const because we call findPosition on it in KSPlanetBase::updateCoords() )*/
		KSPlanet *earth() { return Earth; }

	/**Compute the present Horizontal coordinates of all planets.
		*@p LST pointer to the current local sidereal time
		*@p lat pointer to the current geographic latitude
		*/
		void EquatorialToHorizontal( dms *LST, const dms *lat );

	/**@return true if the SkyObject argument is a planet.
		*@p so pointer to the SkyObject to be tested
		*/
		bool isPlanet(SkyObject *so) const;

	/**@return a pointer to the KSPlanetBase of the planet named in the argument.
		*@p n the name of the planet to point to
		*@note if no planet with this name is found, return the NULL pointer.
		*/
		KSPlanetBase *findByName( const TQString n) const;

	/**@return a pointer to the planet closest to the given SkyPoint
		*(within a maximum angular search radius)
		*@p p the Sky point to find a planet near
		*@p r the maximum angular search radius
		*/
		SkyObject *findClosest(const SkyPoint *p, double &r) const;

	private:
		TQPtrList<KSPlanetBase> planets;
		KSPlanet *Earth;
		KSSun *Sun;
		KStarsData *kd;
};

#endif