• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • satellites
SatellitesMSCItem.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Rene Kuettner <rene@bitkanal.net>
9 //
10 
11 
12 #include "SatellitesMSCItem.h"
13 
14 #include <QDateTime>
15 #include <QFile>
16 #include <QString>
17 #include <QColor>
18 
19 #include "MarbleClock.h"
20 #include "MarbleDebug.h"
21 #include "MarbleGlobal.h"
22 #include "GeoPainter.h"
23 #include "GeoDataCoordinates.h"
24 #include "GeoDataPlacemark.h"
25 #include "GeoDataStyle.h"
26 #include "GeoDataTrack.h"
27 #include "GeoDataPoint.h"
28 
29 namespace Marble {
30 
31 SatellitesMSCItem::SatellitesMSCItem( const QString &name,
32  const QString &category,
33  const QString &relatedBody,
34  const QString &catalog,
35  const QDateTime &missionStart,
36  const QDateTime &missionEnd,
37  int catalogIndex,
38  PlanetarySats *planSat,
39  const MarbleClock *clock )
40  : TrackerPluginItem( name ),
41  m_track( new GeoDataTrack() ),
42  m_clock( clock ),
43  m_planSat( planSat ),
44  m_category( category ),
45  m_relatedBody( relatedBody ),
46  m_catalog( catalog ),
47  m_catalogIndex( catalogIndex ),
48  m_missionStart( missionStart ),
49  m_missionEnd( missionEnd )
50 {
51  placemark()->setVisualCategory( GeoDataFeature::Satellite );
52  placemark()->setZoomLevel( 0 );
53  placemark()->setGeometry( m_track );
54 
55  m_planSat->getKeplerElements(
56  m_perc, m_apoc, m_inc, m_ecc, m_ra, m_tano, m_m0, m_a, m_n0 );
57 
58  setDescription();
59  update();
60 }
61 
62 SatellitesMSCItem::~SatellitesMSCItem()
63 {
64  delete m_planSat;
65 }
66 
67 QString SatellitesMSCItem::category() const
68 {
69  return m_category;
70 }
71 
72 QString SatellitesMSCItem::relatedBody() const
73 {
74  return m_relatedBody;
75 }
76 
77 QString SatellitesMSCItem::catalog() const
78 {
79  return m_catalog;
80 }
81 
82 int SatellitesMSCItem::catalogIndex() const
83 {
84  return m_catalogIndex;
85 }
86 
87 QString SatellitesMSCItem::id() const
88 {
89  return QString( "%1:%2" ).arg( catalog() ).arg( catalogIndex() );
90 }
91 
92 const QDateTime& SatellitesMSCItem::missionStart() const
93 {
94  return m_missionStart;
95 }
96 
97 const QDateTime& SatellitesMSCItem::missionEnd() const
98 {
99  return m_missionEnd;
100 }
101 
102 void SatellitesMSCItem::setDescription()
103 {
104  /*QString description =
105  QObject::tr( "Object name: %1 <br />"
106  "Category: %2 <br />"
107  "Pericentre: %3 km<br />"
108  "Apocentre: %4 km<br />"
109  "Inclination: %5 Degree<br />"
110  "Revolutions per day (24h): %6" )
111  .arg( name(), category(), QString::number( m_perc, 'f', 2 ),
112  QString::number( m_apoc, 'f', 2 ),
113  QString::number( m_inc, 'f', 2 ),
114  QString::number( m_n0, 'f', 2 ) );*/
115 
116  QFile templateFile(":/marble/satellites/satellite.html");
117  if (!templateFile.open(QIODevice::ReadOnly)) {
118  placemark()->setDescription(QObject::tr("No info available."));
119  return;
120  }
121  QString html = templateFile.readAll();
122 
123  html.replace("%name%", name());
124  html.replace("%noradId%", QString::number(catalogIndex()));
125  html.replace("%perigee%", QString::number(m_perc, 'f', 2));
126  html.replace("%apogee%", QString::number(m_apoc, 'f', 2));
127  html.replace("%inclination%", QString::number(m_inc, 'f', 2));
128  html.replace("%period%", "?");
129  html.replace("%semiMajorAxis%", "?");
130 
131  placemark()->setDescription( html );
132 }
133 
134 void SatellitesMSCItem::update()
135 {
136  if( m_missionStart.isValid() ) {
137  setVisible( ( m_clock->dateTime() > m_missionStart ) );
138  }
139 
140  if( m_missionEnd.isValid() ) {
141  setVisible( ( m_clock->dateTime() < m_missionEnd ) );
142  }
143 
144  if( !isEnabled() || !isVisible() ) {
145  return;
146  }
147 
148  double period = 24 * 3600 / m_n0;
149  QDateTime startTime = m_clock->dateTime();
150  QDateTime endTime = startTime;
151  if( isTrackVisible() ) {
152  startTime = startTime.addSecs( - period / 2. );
153  endTime = startTime.addSecs( period );
154  }
155 
156  m_track->removeBefore( startTime );
157  m_track->removeAfter( endTime );
158 
159  double step = period / 500.;
160 
161  for( double i = startTime.toTime_t(); i < endTime.toTime_t(); i += step ) {
162 
163  if ( i >= m_track->firstWhen().toTime_t() ) {
164  i = m_track->lastWhen().toTime_t() + step;
165  }
166 
167  addTrackPointAt( QDateTime::fromTime_t( i ) );
168  }
169 
170  addTrackPointAt( m_clock->dateTime() );
171 }
172 
173 void SatellitesMSCItem::addTrackPointAt( const QDateTime &dateTime )
174 {
175  double lng = 0.;
176  double lat = 0.;
177  double height = 0.;
178 
179  QDateTime dt = dateTime.toUTC();
180  QDate date = dt.date();
181  QTime time = dt.time();
182 
183  m_planSat->setMJD( date.year(), date.month(), date.day(),
184  time.hour(), time.minute(), time.second() );
185  m_planSat->currentPos();
186  m_planSat->getPlanetographic( lng, lat, height );
187 
188  m_track->addPoint( dateTime,
189  GeoDataCoordinates( lng, lat, height * 1000,
190  GeoDataCoordinates::Degree) );
191 }
192 
193 } // namespace Marble
Marble::GeoDataTrack::removeAfter
void removeAfter(const QDateTime &when)
Remove all points from the track whose time value is greater than when.
Definition: GeoDataTrack.cpp:242
GeoDataCoordinates.h
Marble::TrackerPluginItem::isEnabled
virtual bool isEnabled() const
Returns whether the item is enabled or disabled.
Definition: TrackerPluginItem.cpp:54
QTime::minute
int minute() const
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
Marble::GeoDataTrack
A geometry for tracking objects made of (time, coordinates) pairs.
Definition: GeoDataTrack.h:54
QDateTime::toUTC
QDateTime toUTC() const
Marble::GeoDataFeature::setVisualCategory
void setVisualCategory(GeoDataVisualCategory category)
Sets the symbol index of the placemark.
Definition: GeoDataFeature.cpp:770
PlanetarySats::setMJD
void setMJD(int year, int month, int day, int hour, int min, double sec)
Definition: planetarySats.cpp:128
Marble::GeoDataFeature::setDescription
void setDescription(const QString &value)
Set the description of this feature to value.
Definition: GeoDataFeature.cpp:593
Marble::SatellitesMSCItem::id
QString id() const
Definition: SatellitesMSCItem.cpp:87
Marble::SatellitesMSCItem::catalog
QString catalog() const
Definition: SatellitesMSCItem.cpp:77
GeoDataStyle.h
QDateTime::time
QTime time() const
Marble::SatellitesMSCItem::missionEnd
const QDateTime & missionEnd() const
Definition: SatellitesMSCItem.cpp:97
Marble::TrackerPluginItem::name
QString name() const
Satellite's name.
Definition: TrackerPluginItem.cpp:44
Marble::SatellitesMSCItem::update
void update()
Reimplement this method to update the placemark, for example to change its coordinates.
Definition: SatellitesMSCItem.cpp:134
QDate::month
int month() const
Marble::GeoDataTrack::addPoint
void addPoint(const QDateTime &when, const GeoDataCoordinates &coord)
Add a new point with coordinates coord associated with the time value when.
Definition: GeoDataTrack.cpp:184
QTime
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
GeoDataTrack.h
QFile
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
SatellitesMSCItem.h
QTime::second
int second() const
Marble::MarbleClock::dateTime
QDateTime dateTime() const
Returns the internal date and time.
Definition: MarbleClock.cpp:100
Marble::TrackerPluginItem::isVisible
virtual bool isVisible() const
Return whether the item is visible or invisible.
Definition: TrackerPluginItem.cpp:64
Marble::TrackerPluginItem::setVisible
virtual void setVisible(bool visible)
Set item visible/invisible according to visible.
Definition: TrackerPluginItem.cpp:69
QDateTime::fromTime_t
QDateTime fromTime_t(uint seconds)
QString::number
QString number(int n, int base)
Marble::GeoDataTrack::lastWhen
QDateTime lastWhen() const
Return the time value of the last point in the track, or an invalid QDateTime if the track is empty...
Definition: GeoDataTrack.cpp:105
QDate::day
int day() const
Marble::TrackerPluginItem::placemark
GeoDataPlacemark * placemark()
Returns the wrapped placemark which will be displayed if this item is in a TrackerPluginModel.
Definition: TrackerPluginItem.cpp:49
Marble::SatellitesMSCItem::category
QString category() const
Definition: SatellitesMSCItem.cpp:67
Marble::SatellitesMSCItem::missionStart
const QDateTime & missionStart() const
Definition: SatellitesMSCItem.cpp:92
QDate
QDate::year
int year() const
QString
PlanetarySats::getKeplerElements
void getKeplerElements(double &perc, double &apoc, double &inc, double &ecc, double &ra, double &tano, double &m0, double &a, double &n0)
Definition: planetarySats.cpp:386
GeoPainter.h
MarbleGlobal.h
GeoDataPlacemark.h
Marble::TrackerPluginItem
Subclass this to represent items in your TrackerPluginModel.
Definition: TrackerPluginItem.h:29
QTime::hour
int hour() const
Marble::SatellitesMSCItem::~SatellitesMSCItem
~SatellitesMSCItem()
Definition: SatellitesMSCItem.cpp:62
MarbleClock.h
QDateTime::toTime_t
uint toTime_t() const
QDateTime::isValid
bool isValid() const
Marble::GeoDataTrack::firstWhen
QDateTime firstWhen() const
Return the time value of the first point in the track, or an invalid QDateTime if the track is empty...
Definition: GeoDataTrack.cpp:96
PlanetarySats::currentPos
void currentPos()
Definition: planetarySats.cpp:459
QString::replace
QString & replace(int position, int n, QChar after)
GeoDataPoint.h
QDateTime::date
QDate date() const
Marble::GeoDataFeature::Satellite
Definition: GeoDataFeature.h:267
Marble::SatellitesMSCItem::catalogIndex
int catalogIndex() const
Definition: SatellitesMSCItem.cpp:82
Marble::TrackerPluginItem::isTrackVisible
virtual bool isTrackVisible() const
Return whether the track is visible or invisible.
Definition: TrackerPluginItem.cpp:74
Marble::GeoDataFeature::setZoomLevel
void setZoomLevel(int index)
Sets the popularity index of the placemark.
Definition: GeoDataFeature.cpp:802
QDateTime::addSecs
QDateTime addSecs(int s) const
Marble::SatellitesMSCItem::relatedBody
QString relatedBody() const
Definition: SatellitesMSCItem.cpp:72
Marble::MarbleClock
Definition: MarbleClock.h:25
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Marble::SatellitesMSCItem::SatellitesMSCItem
SatellitesMSCItem(const QString &name, const QString &category, const QString &relatedBody, const QString &catalog, const QDateTime &missionStart, const QDateTime &missionEnd, int catalogIndex, PlanetarySats *planSat, const MarbleClock *clock)
Definition: SatellitesMSCItem.cpp:31
Marble::GeoDataTrack::removeBefore
void removeBefore(const QDateTime &when)
Remove all points from the track whose time value is less than when.
Definition: GeoDataTrack.cpp:228
QDateTime
PlanetarySats::getPlanetographic
void getPlanetographic(double &lng, double &lat, double &height) const
Definition: planetarySats.cpp:475
PlanetarySats
Definition: planetarySats.h:17
Marble::GeoDataPlacemark::setGeometry
void setGeometry(GeoDataGeometry *entry)
Sets the current Geometry of this Placemark.
Definition: GeoDataPlacemark.cpp:230
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal