31 #include <kio/netaccess.h>
32 #include <kio/jobuidelegate.h>
33 #include <kstandarddirs.h>
80 void CometsComponent::loadData() {
81 QString name, orbit_id, orbit_class, dimensions;
84 double q, e, dble_i, dble_w, dble_N, Tp, earth_moid;
86 float M1, M2, K1, K2, diameter, albedo, rot_period, period;
114 QString file_name = KStandardDirs::locate(
"appdata",
115 QString(
"comets.dat") );
116 KSParser cometParser(file_name,
'#', sequence);
118 QHash<QString, QVariant> row_content;
119 while (cometParser.HasNextRow()){
121 row_content = cometParser.ReadNextRow();
122 name = row_content[
"full name"].toString();
123 name = name.trimmed();
124 mJD = row_content[
"epoch_mjd"].toInt();
125 q = row_content[
"q"].toDouble();
126 e = row_content[
"e"].toDouble();
127 dble_i = row_content[
"i"].toDouble();
128 dble_w = row_content[
"w"].toDouble();
129 dble_N = row_content[
"om"].toDouble();
130 Tp = row_content[
"tp_calc"].toDouble();
131 orbit_id = row_content[
"orbit_id"].toString();
132 neo = row_content[
"neo"] ==
"Y";
134 if(row_content[
"M1"].toFloat()==0.0)
137 M1 = row_content[
"M1"].toFloat();
139 if(row_content[
"M2"].toFloat()==0.0)
142 M2 = row_content[
"M2"].toFloat();
144 diameter = row_content[
"diameter"].toFloat();
145 dimensions = row_content[
"extent"].toString();
146 albedo = row_content[
"albedo"].toFloat();
147 rot_period = row_content[
"rot_period"].toFloat();
148 period = row_content[
"per_y"].toFloat();
149 earth_moid = row_content[
"moid"].toDouble();
150 orbit_class = row_content[
"class"].toString();
151 K1 = row_content[
"H"].toFloat();
152 K2 = row_content[
"G"].toFloat();
154 JD =
static_cast<double>( mJD ) + 2400000.5;
156 com =
new KSComet( name, QString(), JD, q, e,
157 dms( dble_i ),
dms( dble_w ),
158 dms( dble_N ), Tp, M1, M2,
188 skyp->
setPen( QPen( QColor(
"darkcyan" ) ) );
189 skyp->
setBrush( QBrush( QColor(
"darkcyan" ) ) );
194 if ( drawn && !(hideLabels || com->
rsun() >= rsunLabelLimit) )
201 KUrl url = KUrl(
"http://ssd.jpl.nasa.gov/sbdb_query.cgi" );
202 QByteArray post_data = QByteArray(
"obj_group=all&obj_kind=com&obj_numbere"
203 "d=all&OBJ_field=0&OBJ_op=0&OBJ_value=&ORB_field=0&ORB_op=0&ORB_value=&com"
204 "bine_mode=AND&c1_group=OBJ&c1_item=Af&c1_op=!%3D&c1_value=D&c2_group=OBJ&"
205 "c2_item=Ae&c2_op=!%3D&c2_value=SOHO&c_fields=AcBdBiBgBjBlBkBqBbAgAkAlApAq"
206 "ArAsBsBtChAmAn&table_format=CSV&max_rows=10&format_option=full&query=Gene"
207 "rate%20Table&.cgifields=format_option&.cgifields=field_list&.cgifields=ob"
208 "j_kind&.cgifields=obj_group&.cgifields=obj_numbered&.cgifields=combine_mo"
209 "de&.cgifields=ast_orbit_class&.cgifields=table_format&.cgifields=ORB_fiel"
210 "d_set&.cgifields=OBJ_field_set&.cgifields=preset_field_set&.cgifields=com"
212 QString content_type =
"Content-Type: application/x-www-form-urlencoded";
215 KIO::StoredTransferJob* get_job = KIO::storedHttpPost( post_data, url );
216 get_job->addMetaData(
"content-type", content_type );
218 if( KIO::NetAccess::synchronousRun( get_job, 0 ) ) {
220 QByteArray data = get_job->data();
221 data.insert( 0,
'#' );
224 QFile file( KStandardDirs::locateLocal(
"appdata",
"comets.dat" ) );
225 file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
234 get_job->ui()->showErrorMessage();
virtual bool drawPointSource(SkyPoint *loc, float mag, char sp= 'A')=0
Draw a point source (e.g., a star).
void setDiameter(float diam)
Sets the comet's diameter.
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
Generic class for text file parsers used in KStars.
static bool showComets()
Get Draw comets in the sky map?
QList< SkyObject * > m_ObjectList
static KStars * Instance()
void setPeriod(float per)
Sets the comet's period.
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets...
static bool hideLabels()
Get Hide object name labels while moving?
void setEarthMOID(double earth_moid)
Sets the comet's earth minimum orbit intersection distance.
void setRotationPeriod(float rot_per)
Sets the comet's rotation period.
void setOrbitClass(QString orbit_class)
Sets the comet's orbit class.
static double maxRadCometName()
Get Maximum distance from Sun for labeling comets, in AU.
A subclass of KSPlanetBase that implements comets.
void setOrbitID(QString orbit_id)
Sets the comet's orbit solution ID.
float getTotalMagnitudeParameter()
An angle, stored as degrees, but expressible in many ways.
virtual ~CometsComponent()
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
virtual void draw(SkyPainter *skyp)
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
void setDimensions(QString dim)
Sets the comet's dimensions.
static double zoomFactor()
Get Zoom Factor, in pixels per radian.
void setAlbedo(float albedo)
Sets the comet's albedo.
static SkyMap * Instance()
KStarsData * data() const
virtual void emitProgressText(const QString &message)
Emit signal about progress.
void setAngularSize(double size)
set the planet's angular size, in km.
virtual QString name(void) const
QHash< int, QStringList > & objectNames()
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
Draws things on the sky, without regard to backend.
static bool showCometNames()
Get Label comet names in the sky map?
The solar system composite manages all planets, asteroids and comets.
static void AddLabel(SkyObject *obj, label_t type)
static version of addLabel() below.
CometsComponent(SolarSystemComposite *parent)
Default constructor.
void setNEO(bool neo)
Sets if the comet is a near earth object.