Stellarium  0.16.1
Satellite.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2009, 2012 Matthew Gates
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 _SATELLITE_HPP_
21 #define _SATELLITE_HPP_ 1
22 
23 #include <QDateTime>
24 #include <QFont>
25 #include <QList>
26 #include <QSharedPointer>
27 #include <QString>
28 #include <QStringList>
29 #include <QVariant>
30 
31 #include "StelObject.hpp"
32 #include "StelTextureTypes.hpp"
33 #include "StelSphereGeometry.hpp"
34 #include "gSatWrapper.hpp"
35 
36 
37 class StelPainter;
38 class StelLocation;
39 
42 typedef struct
43 {
44  double frequency;
45  QString modulation;
46  QString description;
47 } CommLink;
48 
52  SatIdRole = Qt::UserRole,
53  SatDescriptionRole,
54  SatFlagsRole,
55  SatGroupsRole,
56  FirstLineRole,
57  SecondLineRole
58 };
59 
62 typedef QSet<QString> GroupSet;
63 
66 enum SatFlag
67 {
68  SatNoFlags = 0x0,
69  SatDisplayed = 0x1,
70  SatNotDisplayed = 0x2,
71  SatUser = 0x4,
72  SatOrbit = 0x8,
73  SatNew = 0x10,
74  SatError = 0x20
75 };
76 typedef QFlags<SatFlag> SatFlags;
77 Q_DECLARE_OPERATORS_FOR_FLAGS(SatFlags)
78 
79 // Allows the type to be used by QVariant
80 Q_DECLARE_METATYPE(GroupSet)
81 Q_DECLARE_METATYPE(SatFlags)
82 
83 class Satellite : public StelObject
92 {
93  friend class Satellites;
94  friend class SatellitesDialog;
95  friend class SatellitesListModel;
96 
97  Q_ENUMS(OptStatus)
98 public:
99  static const QString SATELLITE_TYPE;
100 
103  {
104  StatusOperational = 1,
105  StatusNonoperational = 2,
106  StatusPartiallyOperational = 3,
107  StatusStandby = 4,
108  StatusSpare = 5,
109  StatusExtendedMission = 6,
110  StatusDecayed = 7,
111  StatusUnknown = 0
112  };
113 
117  Satellite(const QString& identifier, const QVariantMap& data);
118  ~Satellite();
119 
122  QVariantMap getMap(void);
123 
124  virtual QString getType(void) const
125  {
126  return SATELLITE_TYPE;
127  }
128 
129  virtual QString getID(void) const
130  {
131  return id;
132  }
133 
134  virtual float getSelectPriority(const StelCore* core) const;
135 
143  virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
164  virtual QVariantMap getInfoMap(const StelCore *core) const;
165  virtual Vec3f getInfoColor(void) const;
166  virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;
167  virtual float getVMagnitude(const StelCore* core) const;
168  virtual double getAngularSize(const StelCore* core) const;
169  virtual QString getNameI18n(void) const;
170  virtual QString getEnglishName(void) const
171  {
172  return name;
173  }
175  QString getCatalogNumberString() const {return id;}
176 
179  void setNewTleElements(const QString& tle1, const QString& tle2);
180 
181  // calculate faders, new position
182  void update(double deltaTime);
183 
184  double getDoppler(double freq) const;
185  static bool showLabels;
186  static double roundToDp(float n, int dp);
187 
188  // when the observer location changes we need to
189  void recalculateOrbitLines(void);
190 
191  void setNew() {newlyAdded = true;}
192  bool isNew() const {return newlyAdded;}
193 
195  SatFlags getFlags() const;
197  void setFlags(const SatFlags& flags);
198 
201  void parseInternationalDesignator(const QString& tle1);
202 
205  bool operator<(const Satellite& another) const;
206 
208  float calculateIlluminatedFraction() const;
209 
211  QString getOperationalStatus() const;
212 
213 private:
214  //draw orbits methods
215  void computeOrbitPoints();
216  void drawOrbit(StelCore* core, StelPainter& painter);
219  float calculateOrbitSegmentIntensity(int segNum);
220 
221 private:
222  bool initialized;
226  bool displayed;
228  bool orbitDisplayed; // draw orbit enabled/disabled
232  bool userDefined;
234  bool newlyAdded;
235  bool orbitValid;
236 
240  QString id;
243  QString name;
245  QString description;
247  QString internationalDesignator;
252  double jdLaunchYearJan1;
254  double stdMag;
256  int status;
258  Vec3d XYZ;
259  QPair< QByteArray, QByteArray > tleElements;
260  double height, range, rangeRate;
261  QList<CommLink> comms;
262  Vec3f hintColor;
265  GroupSet groups;
266  QDateTime lastUpdated;
267 
268  static StelTextureSP hintTexture;
269  static SphericalCap viewportHalfspace;
270  static float hintBrightness;
271  static float hintScale;
272  static int orbitLineSegments;
273  static int orbitLineFadeSegments;
274  static int orbitLineSegmentDuration; //measured in seconds
275  static bool orbitLinesFlag;
276  static bool realisticModeFlag;
278  static StelObject::InfoStringGroupFlags flagsMask;
279  static Vec3f invisibleSatelliteColor;
280 
281  static double timeRateLimit;
282 
283  void draw(StelCore *core, StelPainter& painter);
284 
285  //Satellite Orbit Position calculation
286  gSatWrapper *pSatWrapper;
287  Vec3d position;
288  Vec3d velocity;
289  Vec3d latLongSubPointPosition;
290  Vec3d elAzPosition;
291 
292 #ifdef IRIDIUM_SAT_TEXT_DEBUG
293  static QString myText;
294 #endif
295 
296  gSatWrapper::Visibility visibility;
297  double phaseAngle; // phase angle for the satellite
298  static double sunReflAngle; // for Iridium satellites
299  //static double timeShift; // for Iridium satellites UNUSED
300 
301  //Satellite Orbit Draw
302  QFont font;
303  Vec3f orbitColor;
304  double lastEpochCompForOrbit; //measured in Julian Days
305  double epochTime; //measured in Julian Days
306  QList<Vec3d> orbitPoints; //orbit points represented by ElAzPos vectors
307  QList<gSatWrapper::Visibility> visibilityPoints; //orbit visibility points
308 };
309 
310 typedef QSharedPointer<Satellite> SatelliteP;
311 bool operator<(const SatelliteP& left, const SatelliteP& right);
312 
313 #endif // _SATELLITE_HPP_
314 
Main configuration window of the Satellites plugin.
virtual Vec3f getInfoColor(void) const
Get a color used to display info about the object.
Store the informations for a location on a planet.
virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const
Get an HTML string to describe the object.
Wrapper allowing compatibility between gsat and Stellarium/Qt.
Definition: gSatWrapper.hpp:41
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
Define the StelTextureSP type.
QString getOperationalStatus() const
Get operational status of satellite.
OptStatus
operational statuses
Definition: Satellite.hpp:102
A SphericalCap is defined by a direction and an aperture.
Satellite(const QString &identifier, const QVariantMap &data)
virtual QString getType(void) const
Return object&#39;s type. It should be the name of the class.
Definition: Satellite.hpp:124
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
SatFlag
Flag type reflecting internal flags of Satellite.
Definition: Satellite.hpp:66
virtual Vec3d getJ2000EquatorialPos(const StelCore *) const
Get observer-centered equatorial coordinates at equinox J2000.
float calculateIlluminatedFraction() const
Calculation of illuminated fraction of the satellite.
virtual float getSelectPriority(const StelCore *core) const
Return a priority value which is used to discriminate objects by priority As for magnitudes, the lower is the higher priority.
void setNewTleElements(const QString &tle1, const QString &tle2)
Set new tleElements.
InfoStringGroupFlags
Used as named bitfield flags as specifiers to filter results of getInfoString.
Definition: StelObject.hpp:47
SatelliteDataRole
Description of the data roles used in SatellitesListModel.
Definition: Satellite.hpp:51
SatFlags getFlags() const
Get internal flags as a single value.
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
void setFlags(const SatFlags &flags)
Sets the internal flags in one operation (only display flags)!
QSet< QString > GroupSet
Type for sets of satellite group IDs.
Definition: Satellite.hpp:62
virtual QString getID(void) const
Returns a unique identifier for this object.
Definition: Satellite.hpp:129
virtual QString getNameI18n(void) const
Return translated object&#39;s name.
void parseInternationalDesignator(const QString &tle1)
Parse TLE line to extract International Designator and launch year.
Main class of the Satellites plugin.
Definition: Satellites.hpp:144
bool operator<(const Satellite &another) const
Needed for sorting lists (if this ever happens...).
QVariantMap getMap(void)
Get a QVariantMap which describes the satellite.
A representation of a satellite in Earth orbit.
Definition: Satellite.hpp:91
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:33
virtual QString getEnglishName(void) const
Return object&#39;s name in english.
Definition: Satellite.hpp:170
A model encapsulating a satellite list.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
virtual double getAngularSize(const StelCore *core) const
Return the angular radius of a circle containing the object as seen from the observer with the circle...
virtual QVariantMap getInfoMap(const StelCore *core) const
Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getInfoString...
Define all SphericalGeometry primitives as well as the SphericalRegionP type.
virtual float getVMagnitude(const StelCore *core) const
Return object&#39;s apparent V magnitude as seen from observer, without including extinction.
QString getCatalogNumberString() const
Returns the (NORAD) catalog number. (For now, the ID string.)
Definition: Satellite.hpp:175