Kstars
7 #include "cometscomponent.h"
12 #include "ksfilereader.h"
14 #include "kstarsdata.h"
16 #include "ksnotification.h"
17 #include "kstars_debug.h"
21 #include "kstarslite.h"
24 #include "skylabeler.h"
25 #include "skypainter.h"
26 #include "solarsystemcomposite.h"
27 #include "auxiliary/filedownloader.h"
28 #include "auxiliary/kspaths.h"
29 #include "projections/projector.h"
30 #include "skyobjects/kscomet.h"
33 #include <QHttpMultiPart>
35 #include <QStandardPaths>
47 return Options::showComets();
79 void CometsComponent::loadData()
84 qCInfo(KSTARS) <<
"Loading comets";
86 qDeleteAll(m_ObjectList);
89 objectNames(SkyObject::COMET).
clear();
90 objectLists(SkyObject::COMET).
clear();
96 KSUtils::MPCParser com_parser(file_name);
103 int perihelion_year, perihelion_month, perihelion_day, perihelion_hour, perihelion_minute, perihelion_second;
106 double perihelion_distance =
get(
"Perihelion_dist").
toDouble();
110 double perihelion_argument =
get(
"Peri").
toDouble();
117 perihelion_year =
get(
"Year_of_perihelion").
toInt();
118 perihelion_month =
get(
"Month_of_perihelion").
toInt();
120 double peri_day =
get(
"Day_of_perihelion").
toDouble();
121 perihelion_day =
static_cast<int>(peri_day);
122 double peri_hour = (peri_day - perihelion_day) * 24;
123 perihelion_hour =
static_cast<int>(peri_hour);
124 perihelion_minute =
static_cast<int>((peri_hour - perihelion_hour) * 60);
125 perihelion_second = ( (( peri_hour - perihelion_hour) * 60) - perihelion_minute) * 60;
128 QTime(perihelion_hour, perihelion_minute, perihelion_second)).
djd();
140 dms(perihelion_argument),
153 objectNames(SkyObject::COMET).append(com->
name());
157 catch (
const std::runtime_error&)
159 qCInfo(KSTARS) <<
"Loading comets failed.";
160 qCInfo(KSTARS) <<
" -> was trying to read " + file_name;
256 if (!
selected() || Options::zoomFactor() < 1 * MINZOOM)
259 bool hideLabels = !Options::showCometNames() || (SkyMap::Instance()->isSlewing() && Options::hideLabels());
260 double rsunLabelLimit = Options::maxRadCometName();
266 for (
auto so : m_ObjectList)
269 double mag = com->
mag();
270 if (std::isnan(mag) == 0)
273 if (drawn && !(hideLabels || com->
rsun() >= rsunLabelLimit))
309 void CometsComponent::updateDataFile(
bool isAutoUpdate)
311 delete (downloadJob);
312 downloadJob =
new FileDownloader();
314 if (isAutoUpdate ==
false)
315 downloadJob->setProgressDialogEnabled(
true,
i18n(
"Comets Update"),
316 i18n(
"Downloading comets updates..."));
318 connect(downloadJob, SIGNAL(downloaded()),
this, SLOT(downloadReady()));
321 if (isAutoUpdate ==
false)
324 QUrl url =
QUrl(
"https://www.minorplanetcenter.net/Extended_Files/cometels.json.gz");
325 downloadJob->get(url);
328 void CometsComponent::downloadReady()
331 QByteArray data = downloadJob->downloadedData();
335 .filePath(
"cometels.json.gz"));
342 qCWarning(KSTARS) <<
"Failed writing comet data to" << file.fileName();
348 if (foc && foc->
type() == SkyObject::COMET)
350 focusedComet = foc->
name();
355 if (foc && foc->
type() == SkyObject::COMET)
357 focusedComet = foc->
name();
377 downloadJob->deleteLater();
433 void CometsComponent::downloadError(
const QString &errorString)
435 KSNotification::error(
i18n(
"Error downloading asteroids data: %1", errorString));
436 qCCritical(KSTARS) << errorString;
437 downloadJob->deleteLater();
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static void AddLabel(SkyObject *obj, label_t type)
static version of addLabel() below.
KStarsData * data() const
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
A subclass of KSPlanetBase that implements comets.
virtual QString name(void) const
static KStarsLite * Instance()
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static KStars * Instance()
virtual void emitProgressText(const QString &message)
Emit signal about progress.
double toDouble(bool *ok) const const
QString i18n(const char *text, const TYPE &arg...)
bool isEmpty() const const
void appendListObject(SkyObject *object)
Add an object to the Object list.
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
int toInt(bool *ok) const const
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Draws things on the sky, without regard to backend.
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
An angle, stored as degrees, but expressible in many ways.
void setOrbitClass(QString orbit_class)
Sets the comet's orbit class.
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
void setAngularSize(double size)
set the planet's angular size, in km.
virtual bool drawComet(KSComet *com)=0
Draw a comet in the sky.
KStarsData * data() const
Information about an object in the sky.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
CometsComponent(SolarSystemComposite *parent)
Default constructor.
virtual QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 03:57:53 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.