Simple Comet Tails.

Jasem Mutlaq mutlaqja at ikarustech.com
Thu Apr 6 06:01:13 UTC 2017


Hi Valentin,

Great work! It seems patch file was included inline? Please send a file or
just link to it.

Regards,
Jasem


On Thu, Apr 6, 2017 at 12:27 AM, Valentin Boettcher <valentin at boettcher.cf>
wrote:

> 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.)
>
> Cheers.
>
> ________________________________________
>
>
> diff --git a/.astylerc b/.astylerc
> new file mode 100644
> index 000000000..01ad4bed2
> --- /dev/null
> +++ b/.astylerc
> @@ -0,0 +1,7 @@
> +
> +-A1
> +-W3
> +-k2
> +-S
> +-xG
> +-C
> diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
> index 2754758fa..6b06c2f2a 100644
> --- a/kstars/kstars.kcfg
> +++ b/kstars/kstars.kcfg
> @@ -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>
> diff --git a/kstars/options/opssolarsystem.cpp
> b/kstars/options/opssolarsystem.cpp
> index df1969d46..6ac1f5a4c 100644
> --- a/kstars/options/opssolarsystem.cpp
> +++ b/kstars/options/opssolarsystem.cpp
> @@ -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();
>  }
> -
> diff --git a/kstars/options/opssolarsystem.ui
> b/kstars/options/opssolarsystem.ui
> index 62edda6c0..d1e36c493 100644
> --- a/kstars/options/opssolarsystem.ui
> +++ b/kstars/options/opssolarsystem.ui
> @@ -6,8 +6,8 @@
>     <rect>
>      <x>0</x>
>      <y>0</y>
> -    <width>438</width>
> -    <height>516</height>
> +    <width>465</width>
> +    <height>644</height>
>     </rect>
>    </property>
>    <layout class="QVBoxLayout">
> @@ -285,6 +285,45 @@
>       <layout class="QVBoxLayout">
>        <item>
>         <layout class="QGridLayout">
> +        <item row="1" column="1">
> +         <widget class="QLabel" name="label_3">
> +          <property name="text">
> +           <string>Download asteroids brighter than</string>
> +          </property>
> +         </widget>
> +        </item>
> +        <item row="0" column="0">
> +         <widget class="QCheckBox" name="kcfg_ShowAsteroids">
> +          <property name="toolTip">
> +           <string>Draw asteroids?</string>
> +          </property>
> +          <property name="whatsThis">
> +           <string>If checked, asteroids will be drawn on the map</string>
> +          </property>
> +          <property name="text">
> +           <string>Asteroids</string>
> +          </property>
> +          <attribute name="buttonGroup">
> +           <string notr="true">solarButtonGroup</string>
> +          </attribute>
> +         </widget>
> +        </item>
> +        <item row="4" column="0">
> +         <widget class="QCheckBox" name="kcfg_ShowComets">
> +          <property name="toolTip">
> +           <string>Draw comets?</string>
> +          </property>
> +          <property name="whatsThis">
> +           <string>If checked, comets will be drawn on the map</string>
> +          </property>
> +          <property name="text">
> +           <string>Comets</string>
> +          </property>
> +          <attribute name="buttonGroup">
> +           <string notr="true">solarButtonGroup</string>
> +          </attribute>
> +         </widget>
> +        </item>
>          <item row="3" column="0">
>           <spacer>
>            <property name="orientation">
> @@ -301,34 +340,17 @@
>            </property>
>           </spacer>
>          </item>
> -        <item row="1" column="2">
> -         <layout class="QHBoxLayout" name="horizontalLayout">
> -          <item>
> -           <widget class="QDoubleSpinBox"
> name="kcfg_MagLimitAsteroidDownload"/>
> -          </item>
> -          <item>
> -           <widget class="QLabel" name="label_2">
> -            <property name="text">
> -             <string>mag</string>
> -            </property>
> -           </widget>
> -          </item>
> -         </layout>
> -        </item>
> -        <item row="0" column="0">
> -         <widget class="QCheckBox" name="kcfg_ShowAsteroids">
> -          <property name="toolTip">
> -           <string>Draw asteroids?</string>
> -          </property>
> -          <property name="whatsThis">
> -           <string>If checked, asteroids will be drawn on the map</string>
> +        <item row="2" column="0" colspan="3">
> +         <widget class="QLabel" name="MagLimitAsteroidDownloadWarning">
> +          <property name="styleSheet">
> +           <string notr="true">color:red; font-weight:bold;</string>
>            </property>
>            <property name="text">
> -           <string>Asteroids</string>
> +           <string>This value might result in a big data file and
> reduced performance!</string>
> +          </property>
> +          <property name="alignment">
> +           <set>Qt::AlignCenter</set>
>            </property>
> -          <attribute name="buttonGroup">
> -           <string notr="true">solarButtonGroup</string>
> -          </attribute>
>           </widget>
>          </item>
>          <item row="0" column="1">
> @@ -338,6 +360,22 @@
>            </property>
>           </widget>
>          </item>
> +        <item row="4" column="1">
> +         <widget class="QCheckBox" name="kcfg_ShowCometNames">
> +          <property name="toolTip">
> +           <string>Show names of comets near the Sun</string>
> +          </property>
> +          <property name="whatsThis">
> +           <string>If checked, the comets near the Sun will have name
> labels attached.  Comets vary in brightness in their orbits, so a faint
> magnitude is not effective in this case.</string>
> +          </property>
> +          <property name="text">
> +           <string>Show names of comets within</string>
> +          </property>
> +          <attribute name="buttonGroup">
> +           <string notr="true">solarButtonGroup</string>
> +          </attribute>
> +         </widget>
> +        </item>
>          <item row="0" column="2">
>           <layout class="QHBoxLayout">
>            <item>
> @@ -368,44 +406,42 @@
>            </item>
>           </layout>
>          </item>
> -        <item row="3" column="1">
> -         <layout class="QHBoxLayout">
> +        <item row="1" column="2">
> +         <layout class="QHBoxLayout" name="horizontalLayout">
>            <item>
> -           <widget class="QCheckBox" name="kcfg_ShowAsteroidNames">
> -            <property name="toolTip">
> -             <string>Attach name labels to asteroids?</string>
> -            </property>
> -            <property name="whatsThis">
> -             <string>If checked, then name labels will be attached to
> asteroids</string>
> -            </property>
> +           <widget class="QDoubleSpinBox"
> name="kcfg_MagLimitAsteroidDownload"/>
> +          </item>
> +          <item>
> +           <widget class="QLabel" name="label_2">
>              <property name="text">
> -             <string>Show names</string>
> +             <string>mag</string>
>              </property>
> -            <attribute name="buttonGroup">
> -             <string notr="true">solarButtonGroup</string>
> -            </attribute>
>             </widget>
>            </item>
> +         </layout>
> +        </item>
> +        <item row="4" column="2">
> +         <layout class="QHBoxLayout">
>            <item>
> -           <spacer>
> -            <property name="orientation">
> -             <enum>Qt::Horizontal</enum>
> +           <widget class="QDoubleSpinBox" name="kcfg_MaxRadCometName">
> +            <property name="toolTip">
> +             <string>Maximum distance for comet names</string>
>              </property>
> -            <property name="sizeType">
> -             <enum>QSizePolicy::Preferred</enum>
> +            <property name="whatsThis">
> +             <string>Set the maximum distance from the Sun for a comet
> to have a name label, in Astronomical Units (AU).  1 AU is the distance
> between the Earth and the Sun, approximately 150 million km</string>
>              </property>
> -            <property name="sizeHint" stdset="0">
> -             <size>
> -              <width>20</width>
> -              <height>20</height>
> -             </size>
> +            <property name="decimals">
> +             <number>2</number>
>              </property>
> -           </spacer>
> +            <property name="maximum">
> +             <double>9999.000000000000000</double>
> +            </property>
> +           </widget>
>            </item>
>            <item>
> -           <widget class="QLabel" name="LabelDensity">
> +           <widget class="QLabel" name="textLabel4">
>              <property name="text">
> -             <string>Label density:</string>
> +             <string>AU</string>
>              </property>
>             </widget>
>            </item>
> @@ -421,82 +457,53 @@
>            </property>
>           </widget>
>          </item>
> -        <item row="4" column="0">
> -         <widget class="QCheckBox" name="kcfg_ShowComets">
> -          <property name="toolTip">
> -           <string>Draw comets?</string>
> -          </property>
> -          <property name="whatsThis">
> -           <string>If checked, comets will be drawn on the map</string>
> -          </property>
> -          <property name="text">
> -           <string>Comets</string>
> -          </property>
> -          <attribute name="buttonGroup">
> -           <string notr="true">solarButtonGroup</string>
> -          </attribute>
> -         </widget>
> -        </item>
> -        <item row="4" column="1">
> -         <widget class="QCheckBox" name="kcfg_ShowCometNames">
> -          <property name="toolTip">
> -           <string>Show names of comets near the Sun</string>
> -          </property>
> -          <property name="whatsThis">
> -           <string>If checked, the comets near the Sun will have name
> labels attached.  Comets vary in brightness in their orbits, so a faint
> magnitude is not effective in this case.</string>
> -          </property>
> -          <property name="text">
> -           <string>Show names of comets within</string>
> -          </property>
> -          <attribute name="buttonGroup">
> -           <string notr="true">solarButtonGroup</string>
> -          </attribute>
> -         </widget>
> -        </item>
> -        <item row="4" column="2">
> +        <item row="3" column="1">
>           <layout class="QHBoxLayout">
>            <item>
> -           <widget class="QDoubleSpinBox" name="kcfg_MaxRadCometName">
> +           <widget class="QCheckBox" name="kcfg_ShowAsteroidNames">
>              <property name="toolTip">
> -             <string>Maximum distance for comet names</string>
> +             <string>Attach name labels to asteroids?</string>
>              </property>
>              <property name="whatsThis">
> -             <string>Set the maximum distance from the Sun for a comet
> to have a name label, in Astronomical Units (AU).  1 AU is the distance
> between the Earth and the Sun, approximately 150 million km</string>
> -            </property>
> -            <property name="decimals">
> -             <number>2</number>
> +             <string>If checked, then name labels will be attached to
> asteroids</string>
>              </property>
> -            <property name="maximum">
> -             <double>9999.000000000000000</double>
> +            <property name="text">
> +             <string>Show names</string>
>              </property>
> +            <attribute name="buttonGroup">
> +             <string notr="true">solarButtonGroup</string>
> +            </attribute>
>             </widget>
>            </item>
>            <item>
> -           <widget class="QLabel" name="textLabel4">
> +           <spacer>
> +            <property name="orientation">
> +             <enum>Qt::Horizontal</enum>
> +            </property>
> +            <property name="sizeType">
> +             <enum>QSizePolicy::Preferred</enum>
> +            </property>
> +            <property name="sizeHint" stdset="0">
> +             <size>
> +              <width>20</width>
> +              <height>20</height>
> +             </size>
> +            </property>
> +           </spacer>
> +          </item>
> +          <item>
> +           <widget class="QLabel" name="LabelDensity">
>              <property name="text">
> -             <string>AU</string>
> +             <string>Label density:</string>
>              </property>
>             </widget>
>            </item>
>           </layout>
>          </item>
> -        <item row="1" column="1">
> -         <widget class="QLabel" name="label_3">
> -          <property name="text">
> -           <string>Download asteroids brighter than</string>
> -          </property>
> -         </widget>
> -        </item>
> -        <item row="2" column="0" colspan="3">
> -         <widget class="QLabel" name="MagLimitAsteroidDownloadWarning">
> -          <property name="styleSheet">
> -           <string notr="true">color:red; font-weight:bold;</string>
> -          </property>
> +        <item row="5" column="1">
> +         <widget class="QCheckBox" name="kcfg_ShowCometComas">
>            <property name="text">
> -           <string>This value might result in a big data file and
> reduced performance!</string>
> -          </property>
> -          <property name="alignment">
> -           <set>Qt::AlignCenter</set>
> +           <string>Show Comet Comas</string>
>            </property>
>           </widget>
>          </item>
> diff --git a/kstars/skycomponents/cometscomponent.cpp
> b/kstars/skycomponents/cometscomponent.cpp
> index 7faf91675..8fc949e79 100644
> --- a/kstars/skycomponents/cometscomponent.cpp
> +++ b/kstars/skycomponents/cometscomponent.cpp
> @@ -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();
>  }
> diff --git a/kstars/skycomponents/solarsystemcomposite.h
> b/kstars/skycomponents/solarsystemcomposite.h
> index 1f2c30ca9..a5fa1d13b 100644
> --- a/kstars/skycomponents/solarsystemcomposite.h
> +++ b/kstars/skycomponents/solarsystemcomposite.h
> @@ -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;
> diff --git a/kstars/skyobjects/kscomet.h b/kstars/skyobjects/kscomet.h
> index 37fdfb3cc..05d74e7f0 100644
> --- a/kstars/skyobjects/kscomet.h
> +++ b/kstars/skyobjects/kscomet.h
> @@ -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 ;
> diff --git a/kstars/skyobjects/ksplanetbase.cpp
> b/kstars/skyobjects/ksplanetbase.cpp
> index f30d87c10..171e38a1a 100644
> --- a/kstars/skyobjects/ksplanetbase.cpp
> +++ b/kstars/skyobjects/ksplanetbase.cpp
> @@ -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 */
> diff --git a/kstars/skypainter.h b/kstars/skypainter.h
> index c590141e6..6c52e613e 100644
> --- a/kstars/skypainter.h
> +++ b/kstars/skypainter.h
> @@ -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
> diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
> index c6cfa7140..ee02d8805 100644
> --- a/kstars/skyqpainter.cpp
> +++ b/kstars/skyqpainter.cpp
> @@ -9,7 +9,7 @@
>      This program is distributed in the hope that it will be useful,
>      but WITHOUT ANY WARRANTY; without even the implied warranty of
>      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -    GNU General Public License for more details.
> +    GNU General Public License for more decomas.
>
>      You should have received a copy of the GNU General Public License
> along
>      with this program; if not, write to the Free Software Foundation,
> Inc.,
> @@ -29,6 +29,7 @@
>  #include "skycomponents/skymapcomposite.h"
>  #include "skycomponents/flagcomponent.h"
>  #include "skycomponents/satellitescomponent.h"
> +#include "skycomponents/solarsystemcomposite.h"
>
>  #include "skyobjects/deepskyobject.h"
>  #include "skyobjects/kscomet.h"
> @@ -37,6 +38,7 @@
>  #include "skyobjects/satellite.h"
>  #include "skyobjects/supernova.h"
>  #include "skyobjects/constellationsart.h"
> +#include "skyobjects/kssun.h"
>  #include "projections/projector.h"
>  #include "ksutils.h"
>
> @@ -45,15 +47,12 @@
>
>  #include <functional>
>
> -namespace
> -{
> +namespace {
>
>  // Convert spectral class to numerical index.
>  // If spectral class is invalid return index for white star (A class)
> -int harvardToIndex(char c)
> -{
> -    switch( c )
> -    {
> +int harvardToIndex( char c ) {
> +    switch ( c ) {
>          case 'o':
>          case 'O':
>              return 0;
> @@ -92,17 +91,15 @@ const int nSPclasses = 7;
>  // These pixmaps are never deallocated. Not really good...
>  QPixmap * imageCache[nSPclasses][nStarSizes] = {{0}};
>
> -QPixmap * visibleSatPixmap=0, *invisibleSatPixmap=0;
> +QPixmap * visibleSatPixmap = 0, *invisibleSatPixmap = 0;
>  }
>
>  int SkyQPainter::starColorMode = 0;
>  QColor SkyQPainter::m_starColor = QColor();
>  QMap<char, QColor> SkyQPainter::ColorMap = QMap<char, QColor>();
>
> -
>  SkyQPainter::SkyQPainter( QPaintDevice * pd )
> -    : SkyPainter(), QPainter()
> -{
> +    : SkyPainter(), QPainter() {
>      Q_ASSERT( pd );
>      m_pd = pd;
>      m_size = QSize( pd->width(), pd->height() );
> @@ -110,8 +107,7 @@ SkyQPainter::SkyQPainter( QPaintDevice * pd )
>  }
>
>  SkyQPainter::SkyQPainter( QPaintDevice * pd, const QSize &size )
> -    : SkyPainter(), QPainter()
> -{
> +    : SkyPainter(), QPainter() {
>      Q_ASSERT( pd );
>      m_pd = pd;
>      m_size = size;
> @@ -119,8 +115,7 @@ SkyQPainter::SkyQPainter( QPaintDevice * pd, const
> QSize &size )
>  }
>
>  SkyQPainter::SkyQPainter( QWidget * widget, QPaintDevice * pd )
> -    : SkyPainter(), QPainter()
> -{
> +    : SkyPainter(), QPainter() {
>      Q_ASSERT( widget );
>      // Set paint device pointer to pd or to the widget if pd = 0
>      m_pd = ( pd ? pd : widget );
> @@ -128,48 +123,40 @@ SkyQPainter::SkyQPainter( QWidget * widget,
> QPaintDevice * pd )
>      m_vectorStars = false;
>  }
>
> -SkyQPainter::~SkyQPainter()
> -{
> +SkyQPainter::~SkyQPainter() {
>  }
>
> -void SkyQPainter::begin()
> -{
> -    QPainter::begin(m_pd);
> +void SkyQPainter::begin() {
> +    QPainter::begin( m_pd );
>      bool aa = !m_sm->isSlewing() && Options::useAntialias();
> -    setRenderHint(QPainter::Antialiasing, aa );
> -    setRenderHint(QPainter::HighQualityAntialiasing, aa);
> +    setRenderHint( QPainter::Antialiasing, aa );
> +    setRenderHint( QPainter::HighQualityAntialiasing, aa );
>      m_proj = m_sm->projector();
>  }
>
> -void SkyQPainter::end()
> -{
> +void SkyQPainter::end() {
>      QPainter::end();
>  }
>
> -void SkyQPainter::drawSkyBackground()
> -{
> +void SkyQPainter::drawSkyBackground() {
>      //FIXME use projector
>      fillRect( 0, 0, m_size.width(), m_size.height(),
> KStarsData::Instance()->colorScheme()->colorNamed( "SkyColor" ) );
>  }
>
> -void SkyQPainter::setPen(const QPen &pen)
> -{
> -    QPainter::setPen(pen);
> +void SkyQPainter::setPen( const QPen &pen ) {
> +    QPainter::setPen( pen );
>  }
>
> -void SkyQPainter::setBrush(const QBrush &brush)
> -{
> -    QPainter::setBrush(brush);
> +void SkyQPainter::setBrush( const QBrush &brush ) {
> +    QPainter::setBrush( brush );
>  }
>
> -void SkyQPainter::initStarImages()
> -{
> +void SkyQPainter::initStarImages() {
>
>      const int starColorIntensity = Options::starColorIntensity();
>
>      ColorMap.clear();
> -    switch( Options::starColorMode() )
> -    {
> +    switch ( Options::starColorMode() ) {
>          case 1: // Red stars.
>              m_starColor = Qt::red;
>              break;
> @@ -191,8 +178,7 @@ void SkyQPainter::initStarImages()
>              ColorMap.insert( 'M', QColor::fromRgb( 255,   0,   0 ) );
>              break;
>      }
> -    if ( ColorMap.isEmpty() )
> -    {
> +    if ( ColorMap.isEmpty() ) {
>          ColorMap.insert( 'O', m_starColor );
>          ColorMap.insert( 'B', m_starColor );
>          ColorMap.insert( 'A', m_starColor );
> @@ -202,93 +188,79 @@ void SkyQPainter::initStarImages()
>          ColorMap.insert( 'M', m_starColor );
>      }
>
> -    foreach( char color, ColorMap.keys() )
> -    {
> +    foreach ( char color, ColorMap.keys() ) {
>          QPixmap BigImage( 15, 15 );
>          BigImage.fill( Qt::transparent );
>
>          QPainter p;
>          p.begin( &BigImage );
>
> -        if ( Options::starColorMode() == 0 )
> -        {
> +        if ( Options::starColorMode() == 0 ) {
>              qreal h, s, v, a;
>              p.setRenderHint( QPainter::Antialiasing, false );
>              QColor starColor = ColorMap[color];
> -            starColor.getHsvF(&h, &s, &v, &a);
> -            for (int i = 0; i < 8; i++ )
> -            {
> -                for (int j = 0; j < 8; j++ )
> -                {
> +            starColor.getHsvF( &h, &s, &v, &a );
> +            for ( int i = 0; i < 8; i++ ) {
> +                for ( int j = 0; j < 8; j++ ) {
>                      qreal x = i - 7;
>                      qreal y = j - 7;
> -                    qreal dist = sqrt( x*x + y*y ) / 7.0;
> -                    starColor.setHsvF(h,
> -                                      qMin( qreal(1), dist <
> (10-starColorIntensity)/10.0 ? 0 : dist ),
> -                                      v,
> -                                      qMax( qreal(0), dist <
> (10-starColorIntensity)/20.0 ? 1 : 1-dist ) );
> +                    qreal dist = sqrt( x * x + y * y ) / 7.0;
> +                    starColor.setHsvF( h,
> +                                       qMin( qreal( 1 ), dist < ( 10 -
> starColorIntensity ) / 10.0 ? 0 : dist ),
> +                                       v,
> +                                       qMax( qreal( 0 ), dist < ( 10 -
> starColorIntensity ) / 20.0 ? 1 : 1 - dist ) );
>                      p.setPen( starColor );
>                      p.drawPoint( i, j );
> -                    p.drawPoint( 14-i, j );
> -                    p.drawPoint( i, 14-j );
> -                    p.drawPoint (14-i, 14-j);
> +                    p.drawPoint( 14 - i, j );
> +                    p.drawPoint( i, 14 - j );
> +                    p.drawPoint ( 14 - i, 14 - j );
>                  }
>              }
> -        }
> -        else
> -        {
> -            p.setRenderHint(QPainter::Antialiasing, true );
> -            p.setPen( QPen(ColorMap[color], 2.0 ) );
> +        } else {
> +            p.setRenderHint( QPainter::Antialiasing, true );
> +            p.setPen( QPen( ColorMap[color], 2.0 ) );
>              p.setBrush( p.pen().color() );
>              p.drawEllipse( QRectF( 2, 2, 10, 10 ) );
>          }
>          p.end();
>
>          // Cache array slice
> -        QPixmap ** pmap = imageCache[ harvardToIndex(color) ];
> -        for( int size = 1; size < nStarSizes; size++ )
> -        {
> -            if( !pmap[size] )
> +        QPixmap ** pmap = imageCache[ harvardToIndex( color ) ];
> +        for ( int size = 1; size < nStarSizes; size++ ) {
> +            if ( !pmap[size] )
>                  pmap[size] = new QPixmap();
>              *pmap[size] = BigImage.scaled( size, size,
> Qt::KeepAspectRatio, Qt::SmoothTransformation );
>          }
>      }
>      starColorMode = Options::starColorMode();
>
> -    visibleSatPixmap = new
> QPixmap(":/icons/breeze/default/kstars_satellites_visible.svg");
> -    invisibleSatPixmap = new
> QPixmap(":/icons/breeze/default/kstars_satellites_invisible.svg");
> +    visibleSatPixmap = new QPixmap(
> ":/icons/breeze/default/kstars_satellites_visible.svg" );
> +    invisibleSatPixmap = new QPixmap(
> ":/icons/breeze/default/kstars_satellites_invisible.svg" );
>  }
>
> -void SkyQPainter::drawSkyLine(SkyPoint * a, SkyPoint * b)
> -{
> +void SkyQPainter::drawSkyLine( SkyPoint * a, SkyPoint * b ) {
>
>      bool aVisible, bVisible;
> -    QPointF aScreen = m_proj->toScreen(a,true,&aVisible);
> -    QPointF bScreen = m_proj->toScreen(b,true,&bVisible);
> +    QPointF aScreen = m_proj->toScreen( a, true, &aVisible );
> +    QPointF bScreen = m_proj->toScreen( b, true, &bVisible );
>
> -    drawLine(aScreen, bScreen);
> +    drawLine( aScreen, bScreen );
>      return;
>
>      //THREE CASES:
> -    if( aVisible && bVisible )
> -    {
> +    if ( aVisible && bVisible ) {
>          //Both a,b visible, so paint the line normally:
> -        drawLine(aScreen, bScreen);
> -    }
> -    else if( aVisible )
> -    {
> +        drawLine( aScreen, bScreen );
> +    } else if ( aVisible ) {
>          //a is visible but b isn't:
> -        drawLine(aScreen, m_proj->clipLine(a,b));
> -    }
> -    else if( bVisible )
> -    {
> +        drawLine( aScreen, m_proj->clipLine( a, b ) );
> +    } else if ( bVisible ) {
>          //b is visible but a isn't:
> -        drawLine(bScreen, m_proj->clipLine(b,a));
> +        drawLine( bScreen, m_proj->clipLine( b, a ) );
>      } //FIXME: what if both are offscreen but the line isn't?
>  }
>
> -void SkyQPainter::drawSkyPolyline(LineList * list, SkipList * skipList,
> LineListLabel * label)
> -{
> +void SkyQPainter::drawSkyPolyline( LineList * list, SkipList *
> skipList, LineListLabel * label ) {
>      SkyList * points = list->points();
>      bool isVisible, isVisibleLast;
>
> @@ -297,33 +269,26 @@ void SkyQPainter::drawSkyPolyline(LineList * list,
> SkipList * skipList, LineList
>      isVisibleLast &= m_proj->checkVisibility( points->first() );
>      QPointF oThis, oThis2;
>
> -    for ( int j = 1 ; j < points->size() ; j++ )
> -    {
> +    for ( int j = 1 ; j < points->size() ; j++ ) {
>          SkyPoint * pThis = points->at( j );
>          oThis2 = oThis = m_proj->toScreen( pThis, true, &isVisible );
>          // & with the result of checkVisibility to clip away things
> below horizon
> -        isVisible &= m_proj->checkVisibility(pThis);
> +        isVisible &= m_proj->checkVisibility( pThis );
>          bool doSkip = false;
> -        if( skipList )
> -        {
> -            doSkip = skipList->skip(j);
> +        if ( skipList ) {
> +            doSkip = skipList->skip( j );
>          }
>
>          bool pointsVisible = false;
>          //Temporary solution to avoid random lines in Gnomonic
> projection and draw lines up to horizon
> -        if(SkyMap::Instance()->projector()->type() ==
> Projector::Gnomonic)
> -        {
> +        if ( SkyMap::Instance()->projector()->type() ==
> Projector::Gnomonic ) {
>              if ( isVisible && isVisibleLast ) pointsVisible = true;
> -        }
> -        else
> -        {
> +        } else {
>              if ( isVisible || isVisibleLast ) pointsVisible = true;
>          }
>
> -        if ( !doSkip )
> -        {
> -            if(pointsVisible)
> -            {
> +        if ( !doSkip ) {
> +            if ( pointsVisible ) {
>                  drawLine( oLast, oThis );
>                  if ( label )
>                      label->updateLabelCandidates( oThis.x(), oThis.y(),
> list, j );
> @@ -335,23 +300,20 @@ void SkyQPainter::drawSkyPolyline(LineList * list,
> SkipList * skipList, LineList
>      }
>  }
>
> -void SkyQPainter::drawSkyPolygon(LineList * list, bool forceClip)
> -{
> +void SkyQPainter::drawSkyPolygon( LineList * list, bool forceClip ) {
>      bool isVisible = false, isVisibleLast;
>      SkyList * points = list->points();
>      QPolygonF polygon;
>
> -    if (forceClip == false)
> -    {
> -        for ( int i = 0; i < points->size(); ++i )
> -        {
> -            polygon << m_proj->toScreen( points->at( i ), false,
> &isVisibleLast);
> +    if ( forceClip == false ) {
> +        for ( int i = 0; i < points->size(); ++i ) {
> +            polygon << m_proj->toScreen( points->at( i ), false,
> &isVisibleLast );
>              isVisible |= isVisibleLast;
>          }
>
>          // If 1+ points are visible, draw it
> -        if ( polygon.size() && isVisible)
> -            drawPolygon(polygon);
> +        if ( polygon.size() && isVisible )
> +            drawPolygon( polygon );
>
>          return;
>      }
> @@ -360,27 +322,21 @@ void SkyQPainter::drawSkyPolygon(LineList * list,
> bool forceClip)
>      SkyPoint * pLast = points->last();
>      QPointF   oLast = m_proj->toScreen( pLast, true, &isVisibleLast );
>      // & with the result of checkVisibility to clip away things below
> horizon
> -    isVisibleLast &= m_proj->checkVisibility(pLast);
> +    isVisibleLast &= m_proj->checkVisibility( pLast );
>
> -    for ( int i = 0; i < points->size(); ++i )
> -    {
> +    for ( int i = 0; i < points->size(); ++i ) {
>          SkyPoint * pThis = points->at( i );
>          QPointF oThis = m_proj->toScreen( pThis, true, &isVisible );
>          // & with the result of checkVisibility to clip away things
> below horizon
> -        isVisible &= m_proj->checkVisibility(pThis);
> +        isVisible &= m_proj->checkVisibility( pThis );
>
>
> -        if ( isVisible && isVisibleLast )
> -        {
> +        if ( isVisible && isVisibleLast ) {
>              polygon << oThis;
> -        }
> -        else if ( isVisibleLast )
> -        {
> +        } else if ( isVisibleLast ) {
>              QPointF oMid = m_proj->clipLine( pLast, pThis );
>              polygon << oMid;
> -        }
> -        else if ( isVisible )
> -        {
> +        } else if ( isVisible ) {
>              QPointF oMid = m_proj->clipLine( pThis, pLast );
>              polygon << oMid;
>              polygon << oThis;
> @@ -392,113 +348,148 @@ void SkyQPainter::drawSkyPolygon(LineList *
> list, bool forceClip)
>      }
>
>      if ( polygon.size() )
> -        drawPolygon(polygon);
> +        drawPolygon( polygon );
>
>  }
>
> -bool SkyQPainter::drawPlanet(KSPlanetBase * planet)
> -{
> -    if( !m_proj->checkVisibility(planet) ) return false;
> +bool SkyQPainter::drawPlanet( KSPlanetBase * planet ) {
> +    if ( !m_proj->checkVisibility( planet ) ) return false;
>
>      bool visible = false;
> -    QPointF pos = m_proj->toScreen(planet,true,&visible);
> -    if( !visible || !m_proj->onScreen(pos) ) return false;
> +    QPointF pos = m_proj->toScreen( planet, true, &visible );
> +    if ( !visible || !m_proj->onScreen( pos ) ) return false;
>
>      float fakeStarSize = ( 10.0 + log10( Options::zoomFactor() ) -
> log10( MINZOOM ) ) * ( 10 - planet->mag() ) / 10;
> -    if( fakeStarSize > 15.0 )
> +    if ( fakeStarSize > 15.0 )
>          fakeStarSize = 15.0;
>
> -    float size = planet->angSize() * dms::PI *
> Options::zoomFactor()/10800.0;
> -    if( size < fakeStarSize && planet->name() != "Sun" &&
> planet->name() != "Moon" )
> -    {
> +    float size = planet->angSize() * dms::PI * Options::zoomFactor() /
> 10800.0;
> +    if ( size < fakeStarSize && planet->name() != "Sun" &&
> planet->name() != "Moon" ) {
>          // Draw them as bright stars of appropriate color instead of
> images
>          char spType;
>          //FIXME: do these need i18n?
> -        if( planet->name() == i18n("Mars") )
> -        {
> +        if ( planet->name() == i18n( "Mars" ) ) {
>              spType = 'K';
> -        }
> -        else if( planet->name() == i18n("Jupiter") || planet->name() ==
> i18n("Mercury") || planet->name() == i18n("Saturn") )
> -        {
> +        } else if ( planet->name() == i18n( "Jupiter" ) ||
> planet->name() == i18n( "Mercury" ) || planet->name() == i18n( "Saturn"
> ) ) {
>              spType = 'F';
> -        }
> -        else
> -        {
> +        } else {
>              spType = 'B';
>          }
> -        drawPointSource(pos,fakeStarSize,spType);
> -    }
> -    else
> -    {
> +        drawPointSource( pos, fakeStarSize, spType );
> +    } else {
>          float sizemin = 1.0;
> -        if( planet->name() == "Sun" || planet->name() == "Moon" )
> +        if ( planet->name() == "Sun" || planet->name() == "Moon" )
>              sizemin = 8.0;
>
> -        float size = planet->angSize() * dms::PI *
> Options::zoomFactor()/10800.0;
> -        if( size < sizemin )
> +        if ( size < sizemin )
>              size = sizemin;
> -        if( Options::showPlanetImages() && !planet->image().isNull() )
> -        {
> +
> +        if ( Options::showPlanetImages() && !planet->image().isNull() ) {
>              //Because Saturn has rings, we inflate its image size by a
> factor 2.5
> -            if( planet->name() == "Saturn" )
> -                size = int(2.5*size);
> +            if ( planet->name() == "Saturn" )
> +                size = int( 2.5 * size );
>              // Scale size exponentially so it is visible at large zooms
> -            else if (planet->name() == "Pluto")
> -                size = int(size*exp(1.5*size));
> +            else if ( planet->name() == "Pluto" )
> +                size = int( size * exp( 1.5 * size ) );
>
>              save();
> -            translate(pos);
> +            translate( pos );
>              rotate( m_proj->findPA( planet, pos.x(), pos.y() ) );
> -            drawImage( QRect(-0.5*size, -0.5*size, size, size),
> +            drawImage( QRect( -0.5 * size, -0.5 * size, size, size ),
>                         planet->image() );
>              restore();
> -        }
> -        else     //Otherwise, draw a simple circle.
> -        {
> +        } else { //Otherwise, draw a simple circle.
>              drawEllipse( pos, size, size );
>          }
>      }
>      return true;
>  }
>
> -bool SkyQPainter::drawPointSource(SkyPoint * loc, float mag, char sp)
> -{
> -    //Check if it's even visible before doing anything
> -    if( !m_proj->checkVisibility(loc) ) return false;
> +bool SkyQPainter::drawComet( KSComet * com ) {
> +    if ( !m_proj->checkVisibility( com ) ) return false;
> +
> +    float size = com->angSize() * dms::PI * Options::zoomFactor() /
> 10800.0;
> +    if ( size < 1 )
> +        size = 1;
>
>      bool visible = false;
> -    QPointF pos = m_proj->toScreen(loc,true,&visible);
> -    if( visible && m_proj->onScreen(pos) )   // FIXME: onScreen here
> should use canvas size rather than SkyMap size, especially while
> printing in portrait mode!
> -    {
> -        drawPointSource(pos, starWidth(mag), sp);
> +    QPointF pos = m_proj->toScreen( com, true, &visible );
> +
> +    // Draw the coma.
> +    if ( visible && m_proj->onScreen( pos ) ) {
> +        // Draw the comet.
> +        drawEllipse( pos, size, size );
> +
> +        double comaLength = ( com->getComaAngSize().arcmin() * dms::PI
> * Options::zoomFactor() / 10800.0 );
> +
> +        // If coma is visible and long enough.
> +        if ( Options::showCometComas() && comaLength > size ) {
> +            KSSun * sun =
> KStarsData::Instance()->skyComposite()->solarSystemComposite()->sun();
> +
> +            // Find the anlge to the sun.
> +            double comaAngle = m_proj->findPA( sun, pos.x(), pos.y() );
> +
> +            const QVector<QPoint> coma = {
> +                QPoint( pos.x() - size, pos.y() ),
> +                QPoint( pos.x() + size, pos.y() ),
> +                QPoint( pos.x(), pos.y() + comaLength )
> +            };
> +
> +            QPolygon comaPoly( coma );
> +
> +            comaPoly = QTransform()
> +                       .translate( pos.x(), pos.y() )
> +                       .rotate( comaAngle ) // Already + 180 Deg,
> because rotated from south, not north.
> +                       .translate( -pos.x(), -pos.y() )
> +                       .map( comaPoly );
> +
> +            save();
> +
> +            // Nice fade for the Coma.
> +            QLinearGradient linearGrad( pos, comaPoly.point( 2 ) );
> +            linearGrad.setColorAt( 0,  QColor( "white" ) );
> +            linearGrad.setColorAt( size / comaLength,  QColor( "white" )
> );
> +            linearGrad.setColorAt( 0.9, QColor( "transparent" ) );
> +            setBrush( linearGrad );
> +
> +            // Render Coma.
> +            drawConvexPolygon( comaPoly );
> +            restore();
> +        }
> +
>          return true;
> +    } else {
> +        return false;
>      }
> -    else
> -    {
> +}
> +
> +bool SkyQPainter::drawPointSource( SkyPoint * loc, float mag, char sp ) {
> +    //Check if it's even visible before doing anything
> +    if ( !m_proj->checkVisibility( loc ) ) return false;
> +
> +    bool visible = false;
> +    QPointF pos = m_proj->toScreen( loc, true, &visible );
> +    if ( visible && m_proj->onScreen( pos ) ) { // FIXME: onScreen here
> should use canvas size rather than SkyMap size, especially while
> printing in portrait mode!
> +        drawPointSource( pos, starWidth( mag ), sp );
> +        return true;
> +    } else {
>          return false;
>      }
>  }
>
> -void SkyQPainter::drawPointSource(const QPointF &pos, float size, char
> sp)
> -{
> -    int isize = qMin(static_cast<int>(size), 14);
> -    if( !m_vectorStars || starColorMode == 0  )
> -    {
> +void SkyQPainter::drawPointSource( const QPointF &pos, float size, char
> sp ) {
> +    int isize = qMin( static_cast<int>( size ), 14 );
> +    if ( !m_vectorStars || starColorMode == 0  ) {
>          // Draw stars as bitmaps, either because we were asked to, or
> because we're painting real colors
> -        QPixmap * im = imageCache[ harvardToIndex(sp) ][isize];
> +        QPixmap * im = imageCache[ harvardToIndex( sp ) ][isize];
>          float offset = 0.5 * im->width();
> -        drawPixmap( QPointF(pos.x()-offset, pos.y()-offset), *im );
> -    }
> -    else
> -    {
> +        drawPixmap( QPointF( pos.x() - offset, pos.y() - offset ), *im );
> +    } else {
>          // Draw stars as vectors, for better printing / SVG export etc.
> -        if ( starColorMode != 4 )
> -        {
> +        if ( starColorMode != 4 ) {
>              setPen( m_starColor );
>              setBrush( m_starColor );
> -        }
> -        else
> -        {
> +        } else {
>              // Note: This is not efficient, but we use vector stars
> only when plotting SVG, not when drawing the skymap, so speed is not
> very important.
>              QColor c = ColorMap.value( sp, Qt::white );
>              setPen( c );
> @@ -506,62 +497,59 @@ void SkyQPainter::drawPointSource(const QPointF
> &pos, float size, char sp)
>          }
>
>          // Be consistent with old raster representation
> -        if( size > 14 )
> +        if ( size > 14 )
>              size = 14;
> -        if( size >= 2 )
> -            drawEllipse( pos.x() - 0.5 * size, pos.y() - 0.5 * size,
> int(size), int(size) );
> -        else if( size >= 1 )
> +        if ( size >= 2 )
> +            drawEllipse( pos.x() - 0.5 * size, pos.y() - 0.5 * size,
> int( size ), int( size ) );
> +        else if ( size >= 1 )
>              drawPoint( pos.x(), pos.y() );
>      }
>  }
>
> -bool SkyQPainter::drawConstellationArtImage(ConstellationsArt * obj)
> -{
> +bool SkyQPainter::drawConstellationArtImage( ConstellationsArt * obj ) {
>      double zoom = Options::zoomFactor();
>
>      bool visible = false;
> -    obj->EquatorialToHorizontal(KStarsData::Instance()->lst(),
> KStarsData::Instance()->geo()->lat());
> -    QPointF constellationmidpoint = m_proj->toScreen(obj, true, &visible);
> +    obj->EquatorialToHorizontal( KStarsData::Instance()->lst(),
> KStarsData::Instance()->geo()->lat() );
> +    QPointF constellationmidpoint = m_proj->toScreen( obj, true,
> &visible );
>
> -    if ( !visible || !m_proj->onScreen(constellationmidpoint))
> +    if ( !visible || !m_proj->onScreen( constellationmidpoint ) )
>          return false;
>
>      //qDebug() << "o->pa() " << obj->pa();
> -    float positionangle = m_proj->findPA(obj,
> constellationmidpoint.x(), constellationmidpoint.y());
> +    float positionangle = m_proj->findPA( obj,
> constellationmidpoint.x(), constellationmidpoint.y() );
>      //qDebug() << " final PA " << positionangle;
>
>
> -    float w = obj->getWidth()*60*dms::PI*zoom/10800;
> -    float h = obj->getHeight()*60*dms::PI*zoom/10800;
> +    float w = obj->getWidth() * 60 * dms::PI * zoom / 10800;
> +    float h = obj->getHeight() * 60 * dms::PI * zoom / 10800;
>
>      save();
>
> -    setRenderHint(QPainter::SmoothPixmapTransform);
> +    setRenderHint( QPainter::SmoothPixmapTransform );
>
> -    translate(constellationmidpoint);
> -    rotate(positionangle);
> -    setOpacity(0.7);
> -    drawImage( QRect(-0.5*w, -0.5*h, w, h), obj->image() );
> -    setOpacity(1);
> +    translate( constellationmidpoint );
> +    rotate( positionangle );
> +    setOpacity( 0.7 );
> +    drawImage( QRect( -0.5 * w, -0.5 * h, w, h ), obj->image() );
> +    setOpacity( 1 );
>
> -    setRenderHint(QPainter::SmoothPixmapTransform, false);
> +    setRenderHint( QPainter::SmoothPixmapTransform, false );
>      restore();
>      return true;
>  }
>
> -bool SkyQPainter::drawDeepSkyObject(DeepSkyObject * obj, bool drawImage)
> -{
> -    if( !m_proj->checkVisibility(obj) ) return false;
> +bool SkyQPainter::drawDeepSkyObject( DeepSkyObject * obj, bool
> drawImage ) {
> +    if ( !m_proj->checkVisibility( obj ) ) return false;
>
>      bool visible = false;
> -    QPointF pos = m_proj->toScreen(obj, true, &visible);
> -    if( !visible || !m_proj->onScreen(pos) ) return false;
> +    QPointF pos = m_proj->toScreen( obj, true, &visible );
> +    if ( !visible || !m_proj->onScreen( pos ) ) return false;
>
>      // if size is 0.0 set it to 1.0, this are normally stars (type 0 and
> 1)
>      // if we use size 0.0 the star wouldn't be drawn
>      float majorAxis = obj->a();
> -    if ( majorAxis == 0.0 )
> -    {
> +    if ( majorAxis == 0.0 ) {
>          majorAxis = 1.0;
>      }
>
> @@ -572,50 +560,48 @@ bool SkyQPainter::drawDeepSkyObject(DeepSkyObject
> * obj, bool drawImage)
>
>      //Draw Image
>      if ( drawImage && Options::zoomFactor() > 5.*MINZOOM )
> -        drawDeepSkyImage(pos, obj, positionAngle);
> +        drawDeepSkyImage( pos, obj, positionAngle );
>
>      //Draw Symbol
> -    drawDeepSkySymbol(pos, obj->type(), size, obj->e(), positionAngle);
> +    drawDeepSkySymbol( pos, obj->type(), size, obj->e(), positionAngle );
>
>      return true;
>  }
>
> -bool SkyQPainter::drawDeepSkyImage(const QPointF &pos, DeepSkyObject *
> obj, float positionAngle)
> -{
> +bool SkyQPainter::drawDeepSkyImage( const QPointF &pos, DeepSkyObject *
> obj, float positionAngle ) {
>      double zoom = Options::zoomFactor();
> -    double w = obj->a() * dms::PI * zoom/10800.0;
> +    double w = obj->a() * dms::PI * zoom / 10800.0;
>      double h = obj->e() * w;
>
>      save();
> -    translate(pos);
> +    translate( pos );
>      rotate( positionAngle );
> -    drawImage( QRect(-0.5*w, -0.5*h, w, h), obj->image() );
> +    drawImage( QRect( -0.5 * w, -0.5 * h, w, h ), obj->image() );
>      restore();
>
>      return true;
>  }
>
> -void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float
> size, float e, float positionAngle)
> -{
> +void SkyQPainter::drawDeepSkySymbol( const QPointF &pos, int type,
> float size, float e, float positionAngle ) {
>      float x = pos.x();
>      float y = pos.y();
>      float zoom = Options::zoomFactor();
>
> -    int isize = int(size);
> +    int isize = int( size );
>
> -    float dx1 = -0.5*size;
> -    float dx2 =  0.5*size;
> -    float dy1 = -1.0*e*size/2.;
> -    float dy2 = e*size/2.;
> +    float dx1 = -0.5 * size;
> +    float dx2 =  0.5 * size;
> +    float dy1 = -1.0 * e * size / 2.;
> +    float dy2 = e * size / 2.;
>      float x1 = x + dx1;
>      float x2 = x + dx2;
>      float y1 = y + dy1;
>      float y2 = y + dy2;
>
> -    float dxa = -size/4.;
> -    float dxb =  size/4.;
> -    float dya = -1.0*e*size/4.;
> -    float dyb = e*size/4.;
> +    float dxa = -size / 4.;
> +    float dxb =  size / 4.;
> +    float dya = -1.0 * e * size / 4.;
> +    float dyb = e * size / 4.;
>      float xa = x + dxa;
>      float xb = x + dxb;
>      float ya = y + dya;
> @@ -631,61 +617,49 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>      std::function<void( float, float, float, float )> lambdaDrawLine;
>      std::function<void( float, float, float, float )> lambdaDrawCross;
>
> -    if ( Options::useAntialias() )
> -    {
> -        lambdaDrawEllipse = [this]( float x, float y, float width,
> float height )
> -        {
> +    if ( Options::useAntialias() ) {
> +        lambdaDrawEllipse = [this]( float x, float y, float width,
> float height ) {
>              drawEllipse( QRectF( x, y, width, height ) );
>          };
> -        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 )
> -        {
> +        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 )
> {
>              drawLine( QLineF( x1, y1, x2, y2 ) );
>          };
> -        lambdaDrawCross = [this]( float centerX, float centerY, float
> sizeX, float sizeY )
> -        {
> -            drawLine( QLineF( centerX - sizeX/2., centerY, centerX +
> sizeX/2., centerY ) );
> -            drawLine( QLineF( centerX, centerY - sizeY/2., centerX,
> centerY + sizeY/2. ) );
> +        lambdaDrawCross = [this]( float centerX, float centerY, float
> sizeX, float sizeY ) {
> +            drawLine( QLineF( centerX - sizeX / 2., centerY, centerX +
> sizeX / 2., centerY ) );
> +            drawLine( QLineF( centerX, centerY - sizeY / 2., centerX,
> centerY + sizeY / 2. ) );
>          };
> -    }
> -    else
> -    {
> -        lambdaDrawEllipse = [this]( float x, float y, float width,
> float height )
> -        {
> +    } else {
> +        lambdaDrawEllipse = [this]( float x, float y, float width,
> float height ) {
>              drawEllipse( QRect( x, y, width, height ) );
>          };
> -        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 )
> -        {
> +        lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 )
> {
>              drawLine( QLine( x1, y1, x2, y2 ) );
>          };
> -        lambdaDrawCross = [this]( float centerX, float centerY, float
> sizeX, float sizeY )
> -        {
> -            drawLine( QLine( centerX - sizeX/2., centerY, centerX +
> sizeX/2., centerY ) );
> -            drawLine( QLine( centerX, centerY - sizeY/2., centerX,
> centerY + sizeY/2. ) );
> +        lambdaDrawCross = [this]( float centerX, float centerY, float
> sizeX, float sizeY ) {
> +            drawLine( QLine( centerX - sizeX / 2., centerY, centerX +
> sizeX / 2., centerY ) );
> +            drawLine( QLine( centerX, centerY - sizeY / 2., centerX,
> centerY + sizeY / 2. ) );
>          };
>      }
>
> -    switch ( type )
> -    {
> +    switch ( type ) {
>          case 0:
>          case 1: //catalog star
>              //Some NGC/IC objects are stars...changed their type to 1
> (was double star)
> -            if (size<2.) size = 2.;
> -            lambdaDrawEllipse( x - size/2., y - size/2., size, size );
> +            if ( size < 2. ) size = 2.;
> +            lambdaDrawEllipse( x - size / 2., y - size / 2., size, size );
>              break;
>          case 2: //Planet
>              break;
>          case 3: //Open cluster; draw circle of points
> -        case 13:   // Asterism
> -        {
> +        case 13: { // Asterism
>              tempBrush = brush();
>              color = pen().color().name();
>              setBrush( pen().color() );
>              psize = 2.;
>              if ( size > 50. )  psize *= 2.;
>              if ( size > 100. ) psize *= 2.;
> -            auto putDot = [this, psize, &lambdaDrawEllipse]( float x,
> float y )
> -            {
> -                lambdaDrawEllipse( x - psize/2., y - psize/2., psize,
> psize );
> +            auto putDot = [this, psize, &lambdaDrawEllipse]( float x,
> float y ) {
> +                lambdaDrawEllipse( x - psize / 2., y - psize / 2.,
> psize, psize );
>              };
>              putDot( xa, y1 );
>              putDot( xb, y1 );
> @@ -699,19 +673,19 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>              break;
>          }
>          case 4: //Globular Cluster
> -            if (size<2.) size = 2.;
> +            if ( size < 2. ) size = 2.;
>              save();
>              translate( x, y );
>              color = pen().color().name();
>              rotate( positionAngle );  //rotate the coordinate system
> -            lambdaDrawEllipse( dx1, dy1, size, e*size );
> -            lambdaDrawCross( 0, 0, size, e*size );
> +            lambdaDrawEllipse( dx1, dy1, size, e * size );
> +            lambdaDrawCross( 0, 0, size, e * size );
>              restore(); //reset coordinate system
>              break;
>
>          case 5: //Gaseous Nebula
>          case 15: // Dark Nebula
> -            if (size <2.) size = 2.;
> +            if ( size < 2. ) size = 2.;
>              save();
>              translate( x, y );
>              rotate( positionAngle );  //rotate the coordinate system
> @@ -723,20 +697,20 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>              restore(); //reset coordinate system
>              break;
>          case 6: //Planetary Nebula
> -            if (size<2.) size = 2.;
> +            if ( size < 2. ) size = 2.;
>              save();
>              translate( x, y );
>              rotate( positionAngle );  //rotate the coordinate system
>              color = pen().color().name();
> -            lambdaDrawEllipse( dx1, dy1, size, e*size );
> -            lambdaDrawLine( 0., dy1, 0., dy1 - e*size/2. );
> -            lambdaDrawLine( 0., dy2, 0., dy2 + e*size/2. );
> -            lambdaDrawLine( dx1, 0., dx1 - size/2., 0. );
> -            lambdaDrawLine( dx2, 0., dx2 + size/2., 0. );
> +            lambdaDrawEllipse( dx1, dy1, size, e * size );
> +            lambdaDrawLine( 0., dy1, 0., dy1 - e * size / 2. );
> +            lambdaDrawLine( 0., dy2, 0., dy2 + e * size / 2. );
> +            lambdaDrawLine( dx1, 0., dx1 - size / 2., 0. );
> +            lambdaDrawLine( dx2, 0., dx2 + size / 2., 0. );
>              restore(); //reset coordinate system
>              break;
>          case 7: //Supernova remnant // FIXME: Why is SNR drawn
> different from a gaseous nebula?
> -            if (size<2) size = 2;
> +            if ( size < 2 ) size = 2;
>              save();
>              translate( x, y );
>              rotate( positionAngle );  //rotate the coordinate system
> @@ -750,24 +724,20 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>          case 8: //Galaxy
>          case 16: // Quasar
>              color = pen().color().name();
> -            if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force
> ellipse above zoomFactor 20
> -            if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force
> points above zoomFactor 5
> -            if ( size>2. )
> -            {
> +            if ( size < 1. && zoom > 20 * MINZOOM ) size = 3.; //force
> ellipse above zoomFactor 20
> +            if ( size < 1. && zoom > 5 * MINZOOM ) size = 1.; //force
> points above zoomFactor 5
> +            if ( size > 2. ) {
>                  save();
>                  translate( x, y );
>                  rotate( positionAngle );  //rotate the coordinate system
> -                lambdaDrawEllipse( dx1, dy1, size, e*size );
> +                lambdaDrawEllipse( dx1, dy1, size, e * size );
>                  restore(); //reset coordinate system
>
> -            }
> -            else if ( size>0. )
> -            {
> -                drawPoint( QPointF(x, y) );
> +            } else if ( size > 0. ) {
> +                drawPoint( QPointF( x, y ) );
>              }
>              break;
> -        case 14:   // Galaxy cluster - draw a dashed circle
> -        {
> +        case 14: { // Galaxy cluster - draw a dashed circle
>              tempBrush = brush();
>              setBrush( QBrush() );
>              psize = 1.;
> @@ -779,17 +749,16 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>              QPen newPen = pen();
>              newPen.setStyle( Qt::DashLine );
>              setPen( newPen );
> -            lambdaDrawEllipse( dx1, dy1, size, e*size );
> +            lambdaDrawEllipse( dx1, dy1, size, e * size );
>              restore();
>              setBrush( tempBrush );
>              break;
>          }
>          default: // Unknown object or something we don't know how to
> draw. Just draw an ellipse with a ?-mark
>              color = pen().color().name();
> -            if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force
> ellipse above zoomFactor 20
> -            if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force
> points above zoomFactor 5
> -            if ( size>2. )
> -            {
> +            if ( size < 1. && zoom > 20 * MINZOOM ) size = 3.; //force
> ellipse above zoomFactor 20
> +            if ( size < 1. && zoom > 5 * MINZOOM ) size = 1.; //force
> points above zoomFactor 5
> +            if ( size > 2. ) {
>                  save();
>                  QFont f = font();
>                  const QString qMark = " ? ";
> @@ -798,21 +767,18 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>                  setFont( f );
>                  translate( x, y );
>                  rotate( positionAngle );  //rotate the coordinate system
> -                lambdaDrawEllipse( dx1, dy1, size, e*size );
> +                lambdaDrawEllipse( dx1, dy1, size, e * size );
>                  if ( Options::useAntialias() )
> -                    drawText( QRectF(dx1, dy1, size, e*size),
> Qt::AlignCenter, qMark );
> -                else
> -                {
> -                    int idx1 = int(dx1);
> -                    int idy1 = int(dy1);
> -                    drawText( QRect(idx1, idy1, isize, int(e*size)),
> Qt::AlignCenter, qMark );
> +                    drawText( QRectF( dx1, dy1, size, e * size ),
> Qt::AlignCenter, qMark );
> +                else {
> +                    int idx1 = int( dx1 );
> +                    int idy1 = int( dy1 );
> +                    drawText( QRect( idx1, idy1, isize, int( e * size )
> ), Qt::AlignCenter, qMark );
>                  }
>                  restore(); //reset coordinate system (and font?)
> -            }
> -            else if ( size>0. )
> -            {
> +            } else if ( size > 0. ) {
>                  if ( Options::useAntialias() )
> -                    drawPoint( QPointF(x, y) );
> +                    drawPoint( QPointF( x, y ) );
>                  else
>                      drawPoint( QPoint( x, y ) );
>              }
> @@ -820,24 +786,21 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF
> &pos, int type, float size, fl
>
>  }
>
> -void SkyQPainter::drawObservingList(const QList< SkyObject * > &obs)
> -{
> -    foreach ( SkyObject * obj, obs )
> -    {
> +void SkyQPainter::drawObservingList( const QList< SkyObject * > &obs ) {
> +    foreach ( SkyObject * obj, obs ) {
>          bool visible = false;
>          QPointF o = m_proj->toScreen( obj, true, &visible );
> -        if( !visible || !m_proj->onScreen(o) ) continue;
> +        if ( !visible || !m_proj->onScreen( o ) ) continue;
>
>          float size = 20.;
> -        float x1 = o.x() - 0.5*size;
> -        float y1 = o.y() - 0.5*size;
> -        drawArc( QRectF(x1, y1, size, size), -60*16, 120*16 );
> -        drawArc( QRectF(x1, y1, size, size), 120*16, 120*16 );
> +        float x1 = o.x() - 0.5 * size;
> +        float y1 = o.y() - 0.5 * size;
> +        drawArc( QRectF( x1, y1, size, size ), -60 * 16, 120 * 16 );
> +        drawArc( QRectF( x1, y1, size, size ), 120 * 16, 120 * 16 );
>      }
>  }
>
> -void SkyQPainter::drawFlags()
> -{
> +void SkyQPainter::drawFlags() {
>      KStarsData * data = KStarsData::Instance();
>      SkyPoint * point;
>      QImage image;
> @@ -845,8 +808,7 @@ void SkyQPainter::drawFlags()
>      QPointF pos;
>      int i;
>
> -    for ( i=0; i<data->skyComposite()->flags()->size(); i++ )
> -    {
> +    for ( i = 0; i < data->skyComposite()->flags()->size(); i++ ) {
>          point = data->skyComposite()->flags()->pointList().at( i );
>          image = data->skyComposite()->flags()->image( i );
>
> @@ -857,39 +819,35 @@ void SkyQPainter::drawFlags()
>          pos = m_proj->toScreen( point, true, &visible );
>
>          // Return if flag is not visible
> -        if( !visible || !m_proj->onScreen( pos ) ) continue;
> +        if ( !visible || !m_proj->onScreen( pos ) ) continue;
>
>          // Draw flag image
> -        drawImage( pos.x()-0.5*image.width(),
> pos.y()-0.5*image.height(), image );
> +        drawImage( pos.x() - 0.5 * image.width(), pos.y() - 0.5 *
> image.height(), image );
>
>          // Draw flag label
>          setPen( data->skyComposite()->flags()->labelColor( i ) );
>          setFont( QFont( "Helvetica", 10, QFont::Bold ) );
> -        drawText( pos.x()+10, pos.y()-10,
> data->skyComposite()->flags()->label( i ) );
> +        drawText( pos.x() + 10, pos.y() - 10,
> data->skyComposite()->flags()->label( i ) );
>      }
>  }
>
> -void SkyQPainter::drawHorizon(bool filled, SkyPoint * labelPoint, bool
> * drawLabel)
> -{
> -    QVector<Vector2f> ground = m_proj->groundPoly(labelPoint, drawLabel);
> -    if( ground.size() )
> -    {
> -        QPolygonF groundPoly(ground.size());
> -        for(int i = 0; i < ground.size(); ++i)
> -            groundPoly[i] = KSUtils::vecToPoint(ground[i]);
> -        if( filled )
> -            drawPolygon(groundPoly);
> -        else
> -        {
> +void SkyQPainter::drawHorizon( bool filled, SkyPoint * labelPoint, bool
> * drawLabel ) {
> +    QVector<Vector2f> ground = m_proj->groundPoly( labelPoint, drawLabel
> );
> +    if ( ground.size() ) {
> +        QPolygonF groundPoly( ground.size() );
> +        for ( int i = 0; i < ground.size(); ++i )
> +            groundPoly[i] = KSUtils::vecToPoint( ground[i] );
> +        if ( filled )
> +            drawPolygon( groundPoly );
> +        else {
>              groundPoly.append( groundPoly.first() );
> -            drawPolyline(groundPoly);
> +            drawPolyline( groundPoly );
>          }
>      }
>  }
>
> -bool SkyQPainter::drawSatellite( Satellite * sat )
> -{
> -    if( !m_proj->checkVisibility(sat) )
> +bool SkyQPainter::drawSatellite( Satellite * sat ) {
> +    if ( !m_proj->checkVisibility( sat ) )
>          return false;
>
>      QPointF pos;
> @@ -899,19 +857,16 @@ bool SkyQPainter::drawSatellite( Satellite * sat )
>
>      pos = m_proj->toScreen( sat, true, &visible );
>
> -    if( !visible || !m_proj->onScreen( pos ) )
> +    if ( !visible || !m_proj->onScreen( pos ) )
>          return false;
>
> -    if ( Options::drawSatellitesLikeStars() )
> -    {
> -        drawPointSource(pos, 3.5, 'B');
> -    }
> -    else
> -    {
> +    if ( Options::drawSatellitesLikeStars() ) {
> +        drawPointSource( pos, 3.5, 'B' );
> +    } else {
>          if ( sat->isVisible() )
> -            drawPixmap(QPoint( pos.x() - 15, pos.y() - 11 ),
> *visibleSatPixmap);
> +            drawPixmap( QPoint( pos.x() - 15, pos.y() - 11 ),
> *visibleSatPixmap );
>          else
> -            drawPixmap(QPoint( pos.x() - 15, pos.y() - 11 ),
> *invisibleSatPixmap);
> +            drawPixmap( QPoint( pos.x() - 15, pos.y() - 11 ),
> *invisibleSatPixmap );
>
>          //drawPixmap(pos, *genericSatPixmap);
>          /*drawLine( QPoint( pos.x() - 0.5, pos.y() - 0.5 ), QPoint(
> pos.x() + 0.5, pos.y() - 0.5 ) );
> @@ -926,21 +881,19 @@ bool SkyQPainter::drawSatellite( Satellite * sat )
>      //data->skyComposite()->satellites()->drawLabel( sat, pos );
>  }
>
> -bool SkyQPainter::drawSupernova(Supernova * sup)
> -{
> +bool SkyQPainter::drawSupernova( Supernova * sup ) {
>      KStarsData * data = KStarsData::Instance();
> -    if( !m_proj->checkVisibility(sup) )
> -    {
> +    if ( !m_proj->checkVisibility( sup ) ) {
>          return false;
>      }
>
>      bool visible = false;
> -    QPointF pos = m_proj->toScreen(sup,true,&visible);
> +    QPointF pos = m_proj->toScreen( sup, true, &visible );
>      //qDebug()<<"sup->ra() = "<<(sup->ra()).toHMSString()<<"sup->dec()
> = "<<sup->dec().toDMSString();
>      //qDebug()<<"pos = "<<pos<<"m_proj->onScreen(pos) =
> "<<m_proj->onScreen(pos);
> -    if( !visible || !m_proj->onScreen(pos) ) return false;
> +    if ( !visible || !m_proj->onScreen( pos ) ) return false;
>
> -    setPen( data->colorScheme()->colorNamed("SupernovaColor") );
> +    setPen( data->colorScheme()->colorNamed( "SupernovaColor" ) );
>      //qDebug()<<"Here"<<endl;
>      drawLine ( QPoint( pos.x () - 2.0, pos.y() ), QPoint( pos.x() +
> 2.0, pos.y() ) );
>      drawLine ( QPoint( pos.x (), pos.y() - 2.0 ), QPoint( pos.x(),
> pos.y() + 2.0 ) );
> diff --git a/kstars/skyqpainter.h b/kstars/skyqpainter.h
> index 0407a04bc..a9ee35024 100644
> --- a/kstars/skyqpainter.h
> +++ b/kstars/skyqpainter.h
> @@ -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);
>
>
>


-- 
Best Regards,
Jasem Mutlaq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kstars-devel/attachments/20170406/e3b07c5d/attachment-0001.html>


More information about the Kstars-devel mailing list