Stellarium 0.15.0
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 
47  virtual void update(double) {;}
48 
50  Vec3d getCenterVsop87Pos(void) const;
52  double getDistanceFromCenter(void) const;
53 
56  Mat4d getRotAltAzToEquatorial(double JD, double JDE) const;
57  Mat4d getRotEquatorialToVsop87(void) const;
58 
59  virtual const QSharedPointer<Planet> getHomePlanet(void) const;
60 
62  virtual const StelLocation& getCurrentLocation() const {return currentLocation;}
63 
66  virtual bool isObserverLifeOver() const {return false;}
67 
69  virtual bool isTraveling() const {return false;}
70 
72  virtual StelObserver* getNextObserver() const {return new StelObserver(currentLocation);}
73 
74 protected:
75  StelLocation currentLocation;
76  QSharedPointer<Planet> planet;
77 };
78 
82 {
83  Q_OBJECT
84 public:
85  SpaceShipObserver(const StelLocation& startLoc, const StelLocation& target, double transitSeconds=1.f, double timeToGo=-1.0);
87 
89  virtual void update(double deltaTime);
90  virtual const QSharedPointer<Planet> getHomePlanet() const;
91  virtual bool isObserverLifeOver() const {return timeToGo <= 0.;}
92  virtual bool isTraveling() const {return !isObserverLifeOver();}
93  virtual StelObserver* getNextObserver() const {return new StelObserver(moveTargetLocation);}
94 
96  StelLocation getTargetLocation() const { return moveTargetLocation; }
98  double getRemainingTime() const { return timeToGo; }
100  double getTransitTime() const { return transitSeconds; }
101 
102 private:
103  StelLocation moveStartLocation;
104  StelLocation moveTargetLocation;
105  QSharedPointer<Planet> artificialPlanet;
106  double timeToGo;
107  double transitSeconds;
108 };
109 
110 #endif // _STELOBSERVER_HPP_
111 
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.
virtual void update(double deltaTime)
Update StelObserver info if needed. Default implementation does nothing.
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.
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 void update(double)
Update StelObserver info if needed. Default implementation does nothing.
virtual StelObserver * getNextObserver() const
Get the next observer to use once the life of this one is over.
A templatized column-major 4x4 matrix compatible with openGL.
Definition: VecMath.hpp:35