Stellarium 0.15.2
StelObserver.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELOBSERVER_HPP_
21 #define _STELOBSERVER_HPP_
22 
23 #include "Planet.hpp"
24 #include "StelLocation.hpp"
25 #include "VecMath.hpp"
26 
27 #include <QObject>
28 #include <QString>
29 #include <QSharedPointer>
30 
31 
32 class ArtificialPlanet;
33 class StelObserver;
34 
37 class StelObserver : public QObject
38 {
39  Q_OBJECT
40 
41 public:
43  StelObserver(const StelLocation& loc);
44  ~StelObserver();
45 
48  virtual bool update(double) {return false;}
49 
51  Vec3d getCenterVsop87Pos(void) const;
53  double getDistanceFromCenter(void) const;
54 
57  Mat4d getRotAltAzToEquatorial(double JD, double JDE) const;
58  Mat4d getRotEquatorialToVsop87(void) const;
59 
60  virtual const QSharedPointer<Planet> getHomePlanet(void) const;
61 
63  virtual const StelLocation& getCurrentLocation() const {return currentLocation;}
64 
67  virtual bool isObserverLifeOver() const {return false;}
68 
70  virtual bool isTraveling() const {return false;}
71 
73  virtual StelObserver* getNextObserver() const {return new StelObserver(currentLocation);}
74 
75 protected:
76  StelLocation currentLocation;
77  QSharedPointer<Planet> planet;
78 };
79 
83 {
84  Q_OBJECT
85 public:
86  SpaceShipObserver(const StelLocation& startLoc, const StelLocation& target, double transitSeconds=1.f, double timeToGo=-1.0);
88 
90  virtual bool update(double deltaTime);
91  virtual const QSharedPointer<Planet> getHomePlanet() const;
92  virtual bool isObserverLifeOver() const {return timeToGo <= 0.;}
93  virtual bool isTraveling() const {return !isObserverLifeOver();}
94  virtual StelObserver* getNextObserver() const {return new StelObserver(moveTargetLocation);}
95 
97  StelLocation getTargetLocation() const { return moveTargetLocation; }
99  double getRemainingTime() const { return timeToGo; }
101  double getTransitTime() const { return transitSeconds; }
102 
103 private:
104  StelLocation moveStartLocation;
105  StelLocation moveTargetLocation;
106  QSharedPointer<Planet> artificialPlanet;
107  double timeToGo;
108  double transitSeconds;
109 };
110 
111 #endif // _STELOBSERVER_HPP_
112 
virtual bool isObserverLifeOver() const
Get whether the life of this observer is over, and therefore that it should be changed to the next on...
virtual const StelLocation & getCurrentLocation() const
Get the informations on the current location.
Store the informations for a location on a planet.
double getDistanceFromCenter(void) const
Get the distance between observer and home planet center in AU.
Vec3d getCenterVsop87Pos(void) const
Get the position of the home planet center in the heliocentric VSOP87 frame in AU.
StelLocation getTargetLocation() const
Returns the target location.
virtual bool isObserverLifeOver() const
Get whether the life of this observer is over, and therefore that it should be changed to the next on...
StelObserver(const StelLocation &loc)
Create a new StelObserver instance which is at a fixed Location.
virtual bool update(double)
Update StelObserver info if needed.
double getTransitTime() const
Returns the total movement time.
double getRemainingTime() const
Returns the remaining movement time.
virtual bool isTraveling() const
Get whether the location is a moving one.
Should be renamed as PlanetBasedObserver and derive from a more generical StelObserver class...
An observer which moves from from one position to another one and/or from one planet to another one...
virtual StelObserver * getNextObserver() const
Get the next observer to use once the life of this one is over.
virtual bool isTraveling() const
Get whether the location is a moving one.
Mat4d getRotAltAzToEquatorial(double JD, double JDE) const
returns rotation matrix for conversion of alt-azimuthal to equatorial coordinates For Earth we need J...
virtual StelObserver * getNextObserver() const
Get the next observer to use once the life of this one is over.