Commit 9c6c0c85 authored by Valentin Boettcher's avatar Valentin Boettcher Committed by Jasem Mutlaq

I've added some simple comet tails and an option to disable them.

There is a bit of Fuzz, cause astyle was doing it's thing. (Has anyone
run astyle recursively yet? There are still some unformated files.)

To clarify things: I just added a "drawComet" method to the skypainter,
an option to the kcfg and the UI and one tweak to retrieve an instance
of the sun.

To note: the findPA method could be tweaked, by somehow caching the Suns
position, because by now it is re-projected for every comet tail. (Well
that's actually OK, because you hardly see more then two at a time.)
parent c194c72b
......@@ -378,6 +378,11 @@
<whatsthis>Toggle whether comets are drawn in the sky map.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowCometComas" type="Bool">
<label>Draw comet comas in the sky map?</label>
<whatsthis>Toggle whether comet comas are drawn in the sky map.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowCometNames" type="Bool">
<label>Label comet names in the sky map?</label>
<whatsthis>Toggle whether comet name labels are drawn in the sky map.</whatsthis>
......
......@@ -32,6 +32,7 @@ OpsSolarSystem::OpsSolarSystem()
connect( kcfg_ShowAsteroids, SIGNAL( toggled(bool) ), SLOT( slotAsteroidWidgets(bool) ) );
connect( kcfg_MagLimitAsteroidDownload, SIGNAL( valueChanged( double ) ), this, SLOT( slotChangeMagDownload( double ) ) );
connect( kcfg_ShowComets, SIGNAL( toggled(bool) ), SLOT( slotCometWidgets(bool) ) );
connect( ClearAllTrails, SIGNAL( clicked() ), KStars::Instance(), SLOT( slotClearAllTrails() ) );
connect( showAllPlanets, SIGNAL( clicked() ), this, SLOT( slotSelectPlanets() ) );
connect( showNonePlanets, SIGNAL( clicked() ), this, SLOT( slotSelectPlanets() ) );
......@@ -94,6 +95,7 @@ void OpsSolarSystem::slotCometWidgets( bool on )
kcfg_ShowCometNames->setEnabled( on );
kcfg_MaxRadCometName->setEnabled( on );
textLabel4->setEnabled( on );
kcfg_ShowCometComas->setEnabled( on );
}
void OpsSolarSystem::slotSelectPlanets()
......@@ -127,4 +129,3 @@ void OpsSolarSystem::slotApply()
KStars::Instance()->updateTime();
KStars::Instance()->map()->forceUpdate();
}
This diff is collapsed.
......@@ -95,42 +95,42 @@ void CometsComponent::loadData()
long double JD;
float M1, M2, K1, K2, diameter, albedo, rot_period, period;
emitProgressText(i18n("Loading comets"));
emitProgressText( i18n( "Loading comets" ) );
qDeleteAll(m_ObjectList);
qDeleteAll( m_ObjectList );
m_ObjectList.clear();
objectNames(SkyObject::COMET).clear();
objectLists(SkyObject::COMET).clear();
objectNames( SkyObject::COMET ).clear();
objectLists( SkyObject::COMET ).clear();
QList< QPair<QString, KSParser::DataTypes> > sequence;
sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
sequence.append(qMakePair(QString("epoch_mjd"), KSParser::D_INT));
sequence.append(qMakePair(QString("q"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("e"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("i"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("w"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("om"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("tp_calc"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("orbit_id"), KSParser::D_QSTRING));
sequence.append(qMakePair(QString("neo"), KSParser::D_QSTRING));
sequence.append(qMakePair(QString("M1"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("M2"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("diameter"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("extent"), KSParser::D_QSTRING));
sequence.append(qMakePair(QString("albedo"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("rot_period"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("per_y"), KSParser::D_FLOAT));
sequence.append(qMakePair(QString("moid"), KSParser::D_DOUBLE));
sequence.append(qMakePair(QString("class"), KSParser::D_QSTRING));
sequence.append(qMakePair(QString("H"), KSParser::D_SKIP));
sequence.append(qMakePair(QString("G"), KSParser::D_SKIP));
QString file_name = KSPaths::locate(QStandardPaths::GenericDataLocation, QString("comets.dat") );
KSParser cometParser(file_name, '#', sequence);
sequence.append( qMakePair( QString( "full name" ), KSParser::D_QSTRING ) );
sequence.append( qMakePair( QString( "epoch_mjd" ), KSParser::D_INT ) );
sequence.append( qMakePair( QString( "q" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "e" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "i" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "w" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "om" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "tp_calc" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "orbit_id" ), KSParser::D_QSTRING ) );
sequence.append( qMakePair( QString( "neo" ), KSParser::D_QSTRING ) );
sequence.append( qMakePair( QString( "M1" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "M2" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "diameter" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "extent" ), KSParser::D_QSTRING ) );
sequence.append( qMakePair( QString( "albedo" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "rot_period" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "per_y" ), KSParser::D_FLOAT ) );
sequence.append( qMakePair( QString( "moid" ), KSParser::D_DOUBLE ) );
sequence.append( qMakePair( QString( "class" ), KSParser::D_QSTRING ) );
sequence.append( qMakePair( QString( "H" ), KSParser::D_SKIP ) );
sequence.append( qMakePair( QString( "G" ), KSParser::D_SKIP ) );
QString file_name = KSPaths::locate( QStandardPaths::GenericDataLocation, QString( "comets.dat" ) );
KSParser cometParser( file_name, '#', sequence );
QHash<QString, QVariant> row_content;
while (cometParser.HasNextRow())
while ( cometParser.HasNextRow() )
{
KSComet * com = 0;
row_content = cometParser.ReadNextRow();
......@@ -146,12 +146,12 @@ void CometsComponent::loadData()
orbit_id = row_content["orbit_id"].toString();
neo = row_content["neo"] == "Y";
if(row_content["M1"].toFloat()==0.0)
if ( row_content["M1"].toFloat() == 0.0 )
M1 = 101.0;
else
M1 = row_content["M1"].toFloat();
if(row_content["M2"].toFloat()==0.0)
if ( row_content["M2"].toFloat() == 0.0 )
M2 = 101.0;
else
M2 = row_content["M2"].toFloat();
......@@ -186,34 +186,34 @@ void CometsComponent::loadData()
// Add *short* name to the list of object names
objectNames( SkyObject::COMET ).append( com->name() );
objectLists( SkyObject::COMET ).append(QPair<QString, const SkyObject *>(com->name(),com));
objectLists( SkyObject::COMET ).append( QPair<QString, const SkyObject *>( com->name(), com ) );
}
}
void CometsComponent::draw( SkyPainter * skyp )
{
Q_UNUSED(skyp)
Q_UNUSED( skyp )
#ifndef KSTARS_LITE
if( !selected() || Options::zoomFactor() < 10*MINZOOM )
if ( !selected() || Options::zoomFactor() < 10 * MINZOOM )
return;
bool hideLabels = ! Options::showCometNames() ||
(SkyMap::Instance()->isSlewing() &&
Options::hideLabels() );
( SkyMap::Instance()->isSlewing() &&
Options::hideLabels() );
double rsunLabelLimit = Options::maxRadCometName();
//FIXME: Should these be config'able?
skyp->setPen( QPen( QColor( "darkcyan" ) ) );
skyp->setBrush( QBrush( QColor( "darkcyan" ) ) );
skyp->setPen( QPen( QColor( "transparent" ) ) );
skyp->setBrush( QBrush( QColor( "white" ) ) );
foreach ( SkyObject * so, m_ObjectList )
{
KSComet * com = (KSComet *)so;
double mag= com->mag();
if (std::isnan(mag) == 0)
KSComet * com = ( KSComet * )so;
double mag = com->mag();
if ( std::isnan( mag ) == 0 )
{
bool drawn = skyp->drawPointSource(com,mag);
if ( drawn && !(hideLabels || com->rsun() >= rsunLabelLimit) )
bool drawn = skyp->drawComet( com );
if ( drawn && !( hideLabels || com->rsun() >= rsunLabelLimit ) )
SkyLabeler::AddLabel( com, SkyLabeler::COMET_LABEL );
}
}
......@@ -224,15 +224,15 @@ void CometsComponent::updateDataFile()
{
downloadJob = new FileDownloader();
downloadJob->setProgressDialogEnabled(true, i18n("Comets Update"), i18n("Downloading comets updates..."));
downloadJob->setProgressDialogEnabled( true, i18n( "Comets Update" ), i18n( "Downloading comets updates..." ) );
connect(downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));
connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
connect( downloadJob, SIGNAL( downloaded() ), this, SLOT( downloadReady() ) );
connect( downloadJob, SIGNAL( error( QString ) ), this, SLOT( downloadError( QString ) ) );
QUrl url = QUrl( "https://ssd.jpl.nasa.gov/sbdb_query.cgi" );
QByteArray post_data = KSUtils::getJPLQueryString("com", "AcBdBiBgBjBlBkBqBbAgAkAlApAqArAsBsBtChAmAn", QVector<KSUtils::JPLFilter> {{"Af", "!=", "D"}});
QByteArray post_data = KSUtils::getJPLQueryString( "com", "AcBdBiBgBjBlBkBqBbAgAkAlApAqArAsBsBtChAmAn", QVector<KSUtils::JPLFilter> {{"Af", "!=", "D"}} );
downloadJob->post(url, post_data);
downloadJob->post( url, post_data );
}
void CometsComponent::downloadReady()
......@@ -242,8 +242,8 @@ void CometsComponent::downloadReady()
data.insert( 0, '#' );
// Write data to asteroids.dat
QFile file( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "comets.dat" ) ;
file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
QFile file( KSPaths::writableLocation( QStandardPaths::GenericDataLocation ) + "comets.dat" ) ;
file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text );
file.write( data );
file.close();
......@@ -259,12 +259,12 @@ void CometsComponent::downloadReady()
downloadJob->deleteLater();
}
void CometsComponent::downloadError(const QString &errorString)
void CometsComponent::downloadError( const QString &errorString )
{
#ifndef KSTARS_LITE
KMessageBox::error(0, i18n("Error downloading asteroids data: %1", errorString));
KMessageBox::error( 0, i18n( "Error downloading asteroids data: %1", errorString ) );
#else
qDebug() << i18n("Error downloading comets data: %1", errorString);
qDebug() << i18n( "Error downloading comets data: %1", errorString );
#endif
downloadJob->deleteLater();
}
......@@ -48,6 +48,12 @@ class SolarSystemComposite : public SkyComposite
{
return m_Earth;
}
KSSun * sun()
{
return m_Sun;
}
const QList<SkyObject *> &asteroids() const;
const QList<SkyObject *> &comets() const;
const QList<SkyObject *> &planetObjects() const;
......
......@@ -149,17 +149,17 @@ class KSComet : public KSPlanetBase
/**
*@short Sets the comet's apparent tail length in degrees
*/
void setTailAngSize( double tailangsize )
void setComaAngSize( double comaAngSize )
{
TailAngSize = tailangsize;
ComaAngSize = comaAngSize;
}
/**
*@return the estimated angular size of the tail as a dms
*/
inline dms getTailAngSize()
inline dms getComaAngSize()
{
return dms( TailAngSize );
return dms( ComaAngSize );
}
/**
......@@ -295,7 +295,7 @@ class KSComet : public KSPlanetBase
*@param Earth planet Earth (needed to calculate geocentric coords)
*@return true if position was successfully calculated.
*/
virtual bool findGeocentricPosition( const KSNumbers * num, const KSPlanetBase * Earth=NULL );
virtual bool findGeocentricPosition( const KSNumbers * num, const KSPlanetBase * Earth = NULL );
/**
*@short Estimate physical parameters of the comet such as coma size, tail length and size of the nucleus
......@@ -305,11 +305,11 @@ class KSComet : public KSPlanetBase
private:
virtual void findMagnitude(const KSNumbers *);
virtual void findMagnitude( const KSNumbers * );
long double JD, JDp;
double q, e, a, P, EarthMOID;
double TailSize, TailAngSize, ComaSize, NuclearSize; // All in kilometres
double TailSize, ComaAngSize, ComaSize, NuclearSize; // All in kilometres
float M1, M2, K1, K2, Albedo, Diameter, RotationPeriod, Period;
dms i, w, N;
QString OrbitID, OrbitClass, Dimensions ;
......
......@@ -39,16 +39,16 @@
#include "texturemanager.h"
QVector<QColor> KSPlanetBase::planetColor = QVector<QColor>() <<
QColor("slateblue") << //Mercury
QColor("lightgreen") << //Venus
QColor("red") << //Mars
QColor("goldenrod") << //Jupiter
QColor("khaki") << //Saturn
QColor("lightseagreen") << //Uranus
QColor("skyblue") << //Neptune
QColor("grey") << //Pluto
QColor("yellow") << //Sun
QColor("white"); //Moon
QColor( "slateblue" ) << //Mercury
QColor( "lightgreen" ) << //Venus
QColor( "red" ) << //Mars
QColor( "goldenrod" ) << //Jupiter
QColor( "khaki" ) << //Saturn
QColor( "lightseagreen" ) << //Uranus
QColor( "skyblue" ) << //Neptune
QColor( "grey" ) << //Pluto
QColor( "yellow" ) << //Sun
QColor( "white" ); //Moon
const SkyObject::UID KSPlanetBase::UID_SOL_BIGOBJ = 0;
......@@ -119,7 +119,7 @@ void KSPlanetBase::updateCoords( const KSNumbers * num, bool includePlanets, con
{
findPosition( num, lat, LST, kd->skyComposite()->earth() );
//Don't add to the trail this time
if( hasTrail() )
if ( hasTrail() )
Trail.takeLast();
}
else
......@@ -134,29 +134,29 @@ void KSPlanetBase::findPosition( const KSNumbers * num, const CachingDms * lat,
// DEBUG edit
findGeocentricPosition( num, Earth ); //private function, reimplemented in each subclass
findPhase();
setAngularSize( asin(physicalSize()/Rearth/AU_KM)*60.*180./dms::PI ); //angular size in arcmin
setAngularSize( asin( physicalSize() / Rearth / AU_KM ) * 60.*180. / dms::PI ); //angular size in arcmin
if ( lat && LST )
localizeCoords( num, lat, LST ); //correct for figure-of-the-Earth
if ( hasTrail() )
{
addToTrail( KStarsDateTime( num->getJD() ).toString( "yyyy.MM.dd hh:mm" ) + i18nc("Universal time", "UT") ); // TODO: Localize date/time format?
addToTrail( KStarsDateTime( num->getJD() ).toString( "yyyy.MM.dd hh:mm" ) + i18nc( "Universal time", "UT" ) ); // TODO: Localize date/time format?
if ( Trail.size() > TrailObject::MaxTrail )
clipTrail();
}
findMagnitude(num);
findMagnitude( num );
if ( type() == SkyObject::COMET )
{
// Compute tail size
KSComet * me = (KSComet *)this;
double TailAngSize;
KSComet * me = ( KSComet * )this;
double comaAngSize;
// Convert the tail size in km to angular tail size (degrees)
TailAngSize = asin(physicalSize()/Rearth/AU_KM)*60.0*180.0/dms::PI;
comaAngSize = asin( physicalSize() / Rearth / AU_KM ) * 60.0 * 180.0 / dms::PI;
// Find the apparent length as projected on the celestial sphere (the comet's tail points away from the sun)
me->setTailAngSize( TailAngSize * fabs(sin( phase().radians() )));
me->setComaAngSize( comaAngSize * fabs( sin( phase().radians() ) ) );
}
}
......@@ -177,14 +177,14 @@ void KSPlanetBase::localizeCoords( const KSNumbers * num, const CachingDms * lat
double rsinp, rcosp, u, sinHA, cosHA, sinDec, cosDec, D;
double cosHA2;
double r = Rearth * AU_KM; //distance from Earth, in km
u = atan( 0.996647*tan( lat->radians() ) );
rsinp = 0.996647*sin( u );
u = atan( 0.996647 * tan( lat->radians() ) );
rsinp = 0.996647 * sin( u );
rcosp = cos( u );
HA.setD( LST->Degrees() - ra().Degrees() );
HA.SinCos( sinHA, cosHA );
dec().SinCos( sinDec, cosDec );
D = atan2( rcosp*sinHA, r*cosDec/6378.14 - rcosp*cosHA );
D = atan2( rcosp * sinHA, r * cosDec / 6378.14 - rcosp * cosHA );
dms temp;
temp.setRadians( ra().radians() - D );
setRA( temp );
......@@ -194,7 +194,7 @@ void KSPlanetBase::localizeCoords( const KSNumbers * num, const CachingDms * lat
//temp.setRadians( atan2( cosHA2*( r*sinDec/6378.14 - rsinp ), r*cosDec*cosHA/6378.14 - rcosp ) );
// The atan2() version above makes the planets move crazy in the htm branch -jbb
temp.setRadians( atan( cosHA2*( r*sinDec/6378.14 - rsinp )/( r*cosDec*cosHA/6378.14 - rcosp ) ) );
temp.setRadians( atan( cosHA2 * ( r * sinDec / 6378.14 - rsinp ) / ( r * cosDec * cosHA / 6378.14 - rcosp ) ) );
setDec( temp );
......@@ -219,7 +219,7 @@ void KSPlanetBase::setRearth( const KSPlanetBase * Earth )
{
double sinL, sinB, sinL0, sinB0;
double cosL, cosB, cosL0, cosB0;
double x,y,z;
double x, y, z;
//The Moon's Rearth is set in its findGeocentricPosition()...
if ( name() == "Moon" )
......@@ -242,20 +242,20 @@ void KSPlanetBase::setRearth( const KSPlanetBase * Earth )
Earth->ecLong().SinCos( sinL0, cosL0 );
Earth->ecLat().SinCos( sinB0, cosB0 );
double eX = Earth->rsun()*cosB0*cosL0;
double eY = Earth->rsun()*cosB0*sinL0;
double eZ = Earth->rsun()*sinB0;
double eX = Earth->rsun() * cosB0 * cosL0;
double eY = Earth->rsun() * cosB0 * sinL0;
double eZ = Earth->rsun() * sinB0;
helEcLong().SinCos( sinL, cosL );
helEcLat().SinCos( sinB, cosB );
x = rsun()*cosB*cosL - eX;
y = rsun()*cosB*sinL - eY;
z = rsun()*sinB - eZ;
x = rsun() * cosB * cosL - eX;
y = rsun() * cosB * sinL - eY;
z = rsun() * sinB - eZ;
Rearth = sqrt(x*x + y*y + z*z);
Rearth = sqrt( x * x + y * y + z * z );
//Set angular size, in arcmin
AngularSize = asin(PhysicalSize/Rearth/AU_KM)*60.*180./dms::PI;
AngularSize = asin( PhysicalSize / Rearth / AU_KM ) * 60.*180. / dms::PI;
}
void KSPlanetBase::findPA( const KSNumbers * num )
......@@ -271,7 +271,7 @@ void KSPlanetBase::findPA( const KSNumbers * num )
double pa;
if ( dy )
{
pa = atan2( dx, dy )*180.0/dms::PI;
pa = atan2( dx, dy ) * 180.0 / dms::PI;
}
else
{
......@@ -282,7 +282,7 @@ void KSPlanetBase::findPA( const KSNumbers * num )
double KSPlanetBase::labelOffset() const
{
double size = angSize() * dms::PI * Options::zoomFactor()/10800.0;
double size = angSize() * dms::PI * Options::zoomFactor() / 10800.0;
//Determine minimum size for offset
double minsize = 4.;
......@@ -295,17 +295,17 @@ double KSPlanetBase::labelOffset() const
//Inflate offset for Saturn
if ( name() == i18n( "Saturn" ) )
size = int(2.5*size);
size = int( 2.5 * size );
return 0.5*size + 4.;
return 0.5 * size + 4.;
}
void KSPlanetBase::findPhase()
{
/* Compute the phase of the planet in degrees */
double earthSun = KStarsData::Instance()->skyComposite()->earth()->rsun();
double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun)
/ (2 * rsun() * rearth() );
double cosPhase = ( rsun() * rsun() + rearth() * rearth() - earthSun * earthSun )
/ ( 2 * rsun() * rearth() );
Phase = acos ( cosPhase ) * 180.0 / dms::PI;
/* More elegant way of doing it, but requires the Sun.
TODO: Switch to this if and when we make KSSun a singleton */
......
......@@ -36,7 +36,9 @@ class LineListLabel;
class Satellite;
class Supernova;
class ConstellationsArt;
class KSComet;
class SolarSystemComposite;
class KSSun;
/** @short Draws things on the sky, without regard to backend.
This class serves as an interface to draw objects onto the sky without
......@@ -110,6 +112,12 @@ class SkyPainter
*/
virtual void drawSkyPolygon(LineList * list, bool forceClip=true) =0;
/** @short Draw a comet in the sky.
@param com comet to draw
@return true if a comet was drawn
*/
virtual bool drawComet(KSComet * com) =0;
/** @short Draw a point source (e.g., a star).
@param loc the location of the source in the sky
@param mag the magnitude of the source
......
This diff is collapsed.
......@@ -26,6 +26,7 @@ class Projector;
class QWidget;
class QSize;
class QMessageBox;
/** @short The QPainter-based painting backend.
This class implements the SkyPainter interface using a QPainter.
For documentation, @see SkyPainter. */
......@@ -92,6 +93,7 @@ class SkyQPainter : public SkyPainter, public QPainter
virtual void drawDeepSkySymbol(const QPointF &pos, int type, float size, float e,
float positionAngle);
virtual bool drawSupernova(Supernova * sup);
virtual bool drawComet(KSComet * com);
///This function exists so that we can draw other objects (e.g., planets) as point sources.
virtual void drawPointSource(const QPointF &pos, float size, char sp = 'A');
virtual bool drawConstellationArtImage(ConstellationsArt * obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment