Stellarium 0.14.3
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 
91 class Satellite : public StelObject
92 {
93  friend class Satellites;
94  friend class SatellitesDialog;
95  friend class SatellitesListModel;
96 
97 public:
101  Satellite(const QString& identifier, const QVariantMap& data);
102  ~Satellite();
103 
106  QVariantMap getMap(void);
107 
108  virtual QString getType(void) const
109  {
110  return "Satellite";
111  }
112  virtual float getSelectPriority(const StelCore* core) const;
113 
121  virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
122  virtual Vec3f getInfoColor(void) const;
123  virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;
124  virtual float getVMagnitude(const StelCore* core) const;
125  virtual double getAngularSize(const StelCore* core) const;
126  virtual QString getNameI18n(void) const
127  {
128  return name;
129  }
130  virtual QString getEnglishName(void) const
131  {
132  return name;
133  }
135  QString getCatalogNumberString() const {return id;}
136 
139  void setNewTleElements(const QString& tle1, const QString& tle2);
140 
141  // calculate faders, new position
142  void update(double deltaTime);
143 
144  double getDoppler(double freq) const;
145  static float showLabels;
146  static double roundToDp(float n, int dp);
147 
148  // when the observer location changes we need to
149  void recalculateOrbitLines(void);
150 
151  void setNew() {newlyAdded = true;}
152  bool isNew() const {return newlyAdded;}
153 
155  SatFlags getFlags();
157  void setFlags(const SatFlags& flags);
158 
161  void parseInternationalDesignator(const QString& tle1);
162 
165  bool operator<(const Satellite& another) const;
166 
168  float calculateIlluminatedFraction() const;
169 
170 private:
171  //draw orbits methods
172  void computeOrbitPoints();
173  void drawOrbit(StelPainter& painter);
176  float calculateOrbitSegmentIntensity(int segNum);
177 
178 private:
179  bool initialized;
183  bool displayed;
185  bool orbitDisplayed; // draw orbit enabled/disabled
189  bool userDefined;
191  bool newlyAdded;
192  bool orbitValid;
193 
197  QString id;
200  QString name;
202  QString description;
204  QString internationalDesignator;
209  double jdLaunchYearJan1;
211  double stdMag;
213  Vec3d XYZ;
214  QPair< QByteArray, QByteArray > tleElements;
215  double height, range, rangeRate;
216  QList<CommLink> comms;
217  Vec3f hintColor;
220  GroupSet groups;
221  QDateTime lastUpdated;
222 
223  static StelTextureSP hintTexture;
224  static SphericalCap viewportHalfspace;
225  static float hintBrightness;
226  static float hintScale;
227  static int orbitLineSegments;
228  static int orbitLineFadeSegments;
229  static int orbitLineSegmentDuration; //measured in seconds
230  static bool orbitLinesFlag;
231  static bool realisticModeFlag;
233  static StelObject::InfoStringGroupFlags flagsMask;
234  static Vec3f invisibleSatelliteColor;
235 
236  void draw(StelCore *core, StelPainter& painter, float maxMagHints);
237 
238  //Satellite Orbit Position calculation
239  gSatWrapper *pSatWrapper;
240  Vec3d position;
241  Vec3d velocity;
242  Vec3d latLongSubPointPosition;
243  Vec3d elAzPosition;
244 
245 #ifdef IRIDIUM_SAT_TEXT_DEBUG
246  static QString myText;
247 #endif
248 
249  int visibility;
250  double phaseAngle; // phase angle for the satellite
251  static double sunReflAngle; // for Iridium satellites
252  static double timeShift; // for Iridium satellites
253 
254  //Satellite Orbit Draw
255  QFont font;
256  Vec3f orbitColor;
257  double lastEpochCompForOrbit; //measured in Julian Days
258  double epochTime; //measured in Julian Days
259  QList<Vec3d> orbitPoints; //orbit points represented by ElAzPos vectors
260  QList<int> visibilityPoints; //orbit visibility points
261 };
262 
263 typedef QSharedPointer<Satellite> SatelliteP;
264 bool operator<(const SatelliteP& left, const SatelliteP& right);
265 
266 #endif // _SATELLITE_HPP_
267 
Main configuration window of the Satellites plugin.
Wrapper allowing compatibility between gsat and Stellarium/Qt.
Definition: gSatWrapper.hpp:47
SatFlag
Flag type reflecting internal flags of Satellite.
Definition: Satellite.hpp:66
SatelliteDataRole
Description of the data roles used in SatellitesListModel.
Definition: Satellite.hpp:51
QSet< QString > GroupSet
Type for sets of satellite group IDs.
Definition: Satellite.hpp:62
Main class of the Satellites plugin.
Definition: Satellites.hpp:143
A representation of a satellite in Earth orbit.
Definition: Satellite.hpp:77
A model encapsulating a satellite list.
QSharedPointer< StelTexture > StelTextureSP