[Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents
Akarsh Simha
akarshsimha at gmail.com
Wed May 30 22:36:42 CEST 2007
Hi Jason.
Could you please confirm that the SVN commit was not corrupt?
I had compile errors after doing an svn up and found some nonsense in
skycomponents/skymapcomposite.h
Thank you.
On 5/30/07, Jason Harris <kstars at 30doradus.org> wrote:
> SVN commit 669815 by harris:
>
> Fixed a bug that Akarsh reported where Jupiter moons were not drawn when
> they were on the far side of their orbit. This was basically an
> incomplete port of the old way to get the z-order correct between
> Jupiter and its moons.
>
> Now, we loop over the four moons. Moons further than Jupiter are drawn
> immediately; those nearer are stored in a list. Then Jupiter is drawn.
> Then the near moons are drawn. Finally, the moon name labels are drawn
> (so they will always appear in front of Jupiter).
>
> To do this, I am now storing a pointer to the SolarSystemSingleComponent
> representing Jupiter in JupiterMoonsComponent.
>
> I also commented out the dubug string reporting the positions of earth
> satellites.
>
> CCMAIL: kstars-devel at kde.org
>
>
>
> M +36 -13 jupitermoonscomponent.cpp
> M +3 -1 jupitermoonscomponent.h
> M +1 -1 satellitecomposite.cpp
> M +3 -2 solarsystemcomposite.cpp
> M +2 -2 solarsystemsinglecomponent.h
>
>
> --- trunk/KDE/kdeedu/kstars/kstars/skycomponents/jupitermoonscomponent.cpp #669814:669815
> @@ -28,10 +28,12 @@
> #include "skypoint.h"
> #include "dms.h"
> #include "Options.h"
> +#include "solarsystemsinglecomponent.h"
>
> -JupiterMoonsComponent::JupiterMoonsComponent( SkyComponent *p, bool (*visibleMethod)() ) : SkyComponent( p, visibleMethod )
> +JupiterMoonsComponent::JupiterMoonsComponent( SkyComponent *p, SolarSystemSingleComponent *jupiterComponent, bool (*visibleMethod)() ) : SkyComponent( p, visibleMethod )
> {
> jmoons = 0;
> + m_Jupiter = jupiterComponent;
> }
>
> JupiterMoonsComponent::~JupiterMoonsComponent()
> @@ -54,7 +56,7 @@
> {
> //TODO findPosition should named updatePosition
> if ( visible() )
> - jmoons->findPosition( num, (KSPlanet*)(parent()->findByName("Jupiter")), (KSSun*)(parent()->findByName( "Sun" )) );
> + jmoons->findPosition( num, (KSPlanet*)(m_Jupiter->skyObject()), (KSSun*)(parent()->findByName( "Sun" )) );
> }
>
> void JupiterMoonsComponent::draw(KStars *ks, QPainter& psky, double scale)
> @@ -65,30 +67,51 @@
> float Width = scale * map->width();
> float Height = scale * map->height();
>
> - //Re-draw Jovian moons which are in front of Jupiter, also draw all 4 moon labels.
> psky.setPen( QPen( QColor( "white" ) ) );
> - if ( Options::zoomFactor() > 10.*MINZOOM )
> - {
> + if ( Options::zoomFactor() > 10.*MINZOOM ) {
> QFont pfont = psky.font();
> QFont moonFont = psky.font();
> moonFont.setPointSize( pfont.pointSize() - 2 );
> psky.setFont( moonFont );
>
> - for ( unsigned int i=0; i<4; ++i )
> - {
> + //In order to get the z-order right for the moons and Jupiter,
> + //we need to first draw the moons that are further away than Jupiter,
> + //then re-draw Jupiter, then draw the moons nearer than Jupiter.
> + QList<QPointF> frontMoons;
> + for ( unsigned int i=0; i<4; ++i ) {
> QPointF o = map->toScreen( jmoons->pos(i), scale );
>
> - if ( ( o.x() >= 0. && o.x() <= Width && o.y() >= 0. && o.y() <= Height ) )
> - {
> - if ( jmoons->z(i) < 0.0 ) //Moon is nearer than Jupiter
> + if ( ( o.x() >= 0. && o.x() <= Width && o.y() >= 0. && o.y() <= Height ) ) {
> + if ( jmoons->z(i) < 0.0 ) { //Moon is nearer than Jupiter
> + frontMoons.append( o );
> + } else {
> + //Draw Moons that are further than Jupiter
> if ( Options::useAntialias() )
> psky.drawEllipse( QRectF( o.x()-1., o.y()-1., 2., 2. ) );
> else
> psky.drawEllipse( QRect( int(o.x())-1, int(o.y())-1, 2, 2 ) );
> + }
> + }
> + }
>
> - //Draw Moon name labels if at high zoom
> - if (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM)
> - {
> + //Now redraw Jupiter
> + m_Jupiter->draw( ks, psky, scale );
> +
> + //Now draw the remaining moons, as stored in frontMoons
> + psky.setPen( QPen( QColor( "white" ) ) );
> + foreach ( QPointF o, frontMoons ) {
> + if ( Options::useAntialias() )
> + psky.drawEllipse( QRectF( o.x()-1., o.y()-1., 2., 2. ) );
> + else
> + psky.drawEllipse( QRect( int(o.x())-1, int(o.y())-1, 2, 2 ) );
> + }
> +
> + //Draw Moon name labels if at high zoom
> + if (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM) {
> + for ( unsigned int i=0; i<4; ++i ) {
> + QPointF o = map->toScreen( jmoons->pos(i), scale );
> +
> + if ( ( o.x() >= 0. && o.x() <= Width && o.y() >= 0. && o.y() <= Height ) ) {
> float offset = 3.0*scale;
> if ( Options::useAntialias() )
> psky.drawText( QPointF( o.x() + offset, o.y() + offset ), jmoons->name(i));
> --- trunk/KDE/kdeedu/kstars/kstars/skycomponents/jupitermoonscomponent.h #669814:669815
> @@ -21,6 +21,7 @@
> #include "skycomponent.h"
>
> class SkyComposite;
> +class SolarSystemSingleComponent;
> class KStarsData;
> class SkyMap;
> class KSNumbers;
> @@ -41,7 +42,7 @@
> *@short Constructor
> *@p parent pointer to the parent SkyComposite
> */
> - JupiterMoonsComponent( SkyComponent *parent, bool (*visibleMethod)() );
> + JupiterMoonsComponent( SkyComponent *parent, SolarSystemSingleComponent *jup, bool (*visibleMethod)() );
>
> /**
> *@short Destructor
> @@ -68,6 +69,7 @@
> private:
>
> JupiterMoons *jmoons;
> + SolarSystemSingleComponent *m_Jupiter;
> };
>
> #endif
> --- trunk/KDE/kdeedu/kstars/kstars/skycomponents/satellitecomposite.cpp #669814:669815
> @@ -100,7 +100,7 @@
> KStarsDateTime dt( ps->jd );
> dms alt( ps->sat_ele );
> dms az( ps->sat_azi );
> - kDebug() << ps->name << " " << dt.toString() << " " << alt.toDMSString() << " " << az.toDMSString() << endl;
> +// kDebug() << ps->name << " " << dt.toString() << " " << alt.toDMSString() << " " << az.toDMSString() << endl;
> }
> }
> }
> --- trunk/KDE/kdeedu/kstars/kstars/skycomponents/solarsystemcomposite.cpp #669814:669815
> @@ -47,8 +47,9 @@
> addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP("Mercury"), "mercury.png", QColor( "slateblue" ), 4879.4 /*diameter in km*/ ), Options::showMercury, 4 ) );
> addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP("Venus"), "venus.png", QColor( "lightgreen" ), 12103.6 /*diameter in km*/ ), Options::showVenus, 4 ) );
> addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP( "Mars" ), "mars.png", QColor( "red" ), 6792.4 /*diameter in km*/ ), Options::showMars, 4 ) );
> - addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP( "Jupiter" ), "jupiter.png", QColor( "goldenrod" ), 142984. /*diameter in km*/ ), Options::showJupiter, 4 ) );
> - m_JupiterMoons = new JupiterMoonsComponent( this, &Options::showJupiter);
> + SolarSystemSingleComponent *jup = new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP( "Jupiter" ), "jupiter.png", QColor( "goldenrod" ), 142984. /*diameter in km*/ ), Options::showJupiter, 4 );
> + addComponent( jup );
> + m_JupiterMoons = new JupiterMoonsComponent( this, jup, &Options::showJupiter);
> addComponent( m_JupiterMoons );
> addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP( "Saturn" ), "saturn.png", QColor( "khaki" ), 120536. /*diameter in km*/ ), Options::showSaturn, 4 ) );
> addComponent( new SolarSystemSingleComponent( this, new KSPlanet( data, I18N_NOOP( "Uranus" ), "uranus.png", QColor( "lightseagreen" ), 51118. /*diameter in km*/ ), Options::showUranus, 4 ) );
> --- trunk/KDE/kdeedu/kstars/kstars/skycomponents/solarsystemsinglecomponent.h #669814:669815
> @@ -64,6 +64,8 @@
> */
> virtual void updatePlanets( KStarsData *data, KSNumbers *num );
>
> + void draw( KStars *ks, QPainter &psky, double scale );
> +
> /**
> *@short Set the size scale. Default value is 1.0 and only
> *Saturn uses a scale of 2.5.
> @@ -76,8 +78,6 @@
>
> KSPlanetBase *ksp() { return (KSPlanetBase*)skyObject(); }
>
> - void draw( KStars *ks, QPainter &psky, double scale );
> -
> /**
> *@short Draws the planet's trail, if necessary.
> */
> _______________________________________________
> Kstars-devel mailing list
> Kstars-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kstars-devel
>
--
Regards,
Akarsh
http://www.bas.org.in
http://www.nascent-technologies.com
More information about the Kstars-devel
mailing list