[Kstars-devel] Questions about planet skycomponents

Thomas Kabelmann thomas.kabelmann at gmx.de
Tue Sep 27 12:01:48 CEST 2005


Hello Jason,

> If we do it this way, each Component would have its own ClickedObject,
> FocusObject, and TransientObject.  There should only be one of each.  I
> know that the "clickedComponent()" functions discriminate between them, but
> that's very messy and non-intuitive.
Yes, I didn't considered the transient and focus object. This sucks, if we 
have an clicked, focus and transient object in each component.

> ---Attaching/Removing a Trail:----------------------
> (The actual Trail management is done as we do now, in SkyMap and
> KSPlanetBase. The only difference: KSPB::addToTrail() and
> KSPB::clearTrail() send Signals to SolarSystemComposite, which contain a
> pointer to the object which has added/removed a trail)
>
> //This way does not use the trick of checking the object's type to
> //determine the Component
> void SolarSystemComposite::slotAddTrail(SkyObject *o) {
> 	foreach ( SkyComponent *comp, components() ) {
> 		bool result = comp->addTrail(o);
> 		if ( result ) return; //stop when object found
> 	}
> }
Why not returning a bool value like the components? This is more generic and 
we can traverse through all components without knowing the 
SolarSystemComponent. We just need our root composite - SkyMapComposite. This 
is easy to implement, as we already know the SkyMapComposite. On the other 
hand the Stars/DeepSkyComponents needs to know this methods to and we have to 
add the slots there too.

bool SkyComposite::addTrail(SkyObject *o) {
 	foreach ( SkyComponent *comp, components() ) {
 		bool result = comp->addTrail(o);
 		if ( result ) break; //stop when object found
	}
	return result;
}

And the generic component looks like this. It must be overridden in components 
which can add trails.

bool SkyComponent::addTrail(SkyObject *o) {
	return false;
}

To avoid making the components derived from QObject, we could add a slot in 
SkyMap or KStarsData and call there skyMapComposite->addTrail(SkyObject *o).
With all other code I agree with you.

Thomas


More information about the Kstars-devel mailing list