Stellarium 0.15.2
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:
101  {
102  StatusOperational = 1,
103  StatusNonoperational = 2,
104  StatusPartiallyOperational = 3,
105  StatusStandby = 4,
106  StatusSpare = 5,
107  StatusExtendedMission = 6,
108  StatusDecayed = 7,
109  StatusUnknown = 0
110  };
111 
115  Satellite(const QString& identifier, const QVariantMap& data);
116  ~Satellite();
117 
120  QVariantMap getMap(void);
121 
122  virtual QString getType(void) const
123  {
124  return "Satellite";
125  }
126  virtual float getSelectPriority(const StelCore* core) const;
127 
135  virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
156  virtual QVariantMap getInfoMap(const StelCore *core) const;
157  virtual Vec3f getInfoColor(void) const;
158  virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;
159  virtual float getVMagnitude(const StelCore* core) const;
160  virtual double getAngularSize(const StelCore* core) const;
161  virtual QString getNameI18n(void) const;
162  virtual QString getEnglishName(void) const
163  {
164  return name;
165  }
167  QString getCatalogNumberString() const {return id;}
168 
171  void setNewTleElements(const QString& tle1, const QString& tle2);
172 
173  // calculate faders, new position
174  void update(double deltaTime);
175 
176  double getDoppler(double freq) const;
177  static float showLabels;
178  static double roundToDp(float n, int dp);
179 
180  // when the observer location changes we need to
181  void recalculateOrbitLines(void);
182 
183  void setNew() {newlyAdded = true;}
184  bool isNew() const {return newlyAdded;}
185 
187  SatFlags getFlags();
189  void setFlags(const SatFlags& flags);
190 
193  void parseInternationalDesignator(const QString& tle1);
194 
197  bool operator<(const Satellite& another) const;
198 
200  float calculateIlluminatedFraction() const;
201 
203  QString getOperationalStatus() const;
204 
205 private:
206  //draw orbits methods
207  void computeOrbitPoints();
208  void drawOrbit(StelPainter& painter);
211  float calculateOrbitSegmentIntensity(int segNum);
212 
213 private:
214  bool initialized;
218  bool displayed;
220  bool orbitDisplayed; // draw orbit enabled/disabled
224  bool userDefined;
226  bool newlyAdded;
227  bool orbitValid;
228 
232  QString id;
235  QString name;
237  QString description;
239  QString internationalDesignator;
244  double jdLaunchYearJan1;
246  double stdMag;
248  int status;
250  Vec3d XYZ;
251  QPair< QByteArray, QByteArray > tleElements;
252  double height, range, rangeRate;
253  QList<CommLink> comms;
254  Vec3f hintColor;
257  GroupSet groups;
258  QDateTime lastUpdated;
259 
260  static StelTextureSP hintTexture;
261  static SphericalCap viewportHalfspace;
262  static float hintBrightness;
263  static float hintScale;
264  static int orbitLineSegments;
265  static int orbitLineFadeSegments;
266  static int orbitLineSegmentDuration; //measured in seconds
267  static bool orbitLinesFlag;
268  static bool realisticModeFlag;
270  static StelObject::InfoStringGroupFlags flagsMask;
271  static Vec3f invisibleSatelliteColor;
272 
273  void draw(StelCore *core, StelPainter& painter, float maxMagHints);
274 
275  //Satellite Orbit Position calculation
276  gSatWrapper *pSatWrapper;
277  Vec3d position;
278  Vec3d velocity;
279  Vec3d latLongSubPointPosition;
280  Vec3d elAzPosition;
281 
282 #ifdef IRIDIUM_SAT_TEXT_DEBUG
283  static QString myText;
284 #endif
285 
286  int visibility;
287  double phaseAngle; // phase angle for the satellite
288  static double sunReflAngle; // for Iridium satellites
289  static double timeShift; // for Iridium satellites
290 
291  //Satellite Orbit Draw
292  QFont font;
293  Vec3f orbitColor;
294  double lastEpochCompForOrbit; //measured in Julian Days
295  double epochTime; //measured in Julian Days
296  QList<Vec3d> orbitPoints; //orbit points represented by ElAzPos vectors
297  QList<int> visibilityPoints; //orbit visibility points
298 };
299 
300 typedef QSharedPointer<Satellite> SatelliteP;
301 bool operator<(const SatelliteP& left, const SatelliteP& right);
302 
303 #endif // _SATELLITE_HPP_
304 
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:47
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:100
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:122
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
SatFlag
Flag type reflecting internal flags of Satellite.
Definition: Satellite.hpp:66
SatFlags getFlags()
Get internal flags as a single value.
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
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 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:162
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:167