Stellarium 0.13.1
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  Mat4d getRotAltAzToEquatorial(double jd) const;
54  Mat4d getRotEquatorialToVsop87(void) const;
55 
56  virtual const QSharedPointer<Planet> getHomePlanet(void) const;
57 
59  virtual const StelLocation& getCurrentLocation() const {return currentLocation;}
60 
63  virtual bool isObserverLifeOver() const {return false;}
64 
66  virtual bool isTraveling() const {return false;}
67 
69  virtual StelObserver* getNextObserver() const {return new StelObserver(currentLocation);}
70 
71 protected:
72  StelLocation currentLocation;
73  QSharedPointer<Planet> planet;
74 };
75 
79 {
80 public:
81  SpaceShipObserver(const StelLocation& startLoc, const StelLocation& target, double transitSeconds=1.f);
83 
85  virtual void update(double deltaTime);
86  virtual const QSharedPointer<Planet> getHomePlanet() const;
87  virtual bool isObserverLifeOver() const {return timeToGo <= 0.;}
88  virtual bool isTraveling() const {return !isObserverLifeOver();}
89  virtual StelObserver* getNextObserver() const {return new StelObserver(moveTargetLocation);}
90 
91 private:
92  StelLocation moveStartLocation;
93  StelLocation moveTargetLocation;
94  QSharedPointer<Planet> artificialPlanet;
95  double timeToGo;
96  double transitSeconds;
97 };
98 
99 #endif // _STELOBSERVER_HPP_
100 
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.
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.
A templatized column-major 4x4 matrix compatible with openGL.
Definition: VecMath.hpp:35
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.
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.