[Kstars-devel] Painting of the various objects

kstars at 30doradus.org kstars at 30doradus.org
Sun Jan 4 22:37:06 CET 2004


Hi Alessio,

Sorry, I won't have time to meet you on IRC today.  Here's a brief 
rundown of what is required to add a new class of objects to KStars:

1.  Create a new class derived from SkyObject for your objects.  
SkyObject is a generic class for objects in the sky.  All objects in 
KStars are SkyObjects, or a class derived from SkyObject.  SkyObject 
stores the object's name(s), object type, magnitude, and coordinates.
Since earth satellites will need additional member data and will need 
specialized "updateCoordinates()" code,  you will need to create a 
new class (KSatellite?) that derives from SkyObject.  See 
deepskyobject.h, starobject.h and ksplanetbase.h for examples.

2.  Create the input data file(s).  These should be text files that 
store all of the data for satellite objects, one object per line.  

3.  Write the code to parse the data file(s).  See kstarsdata.cpp for 
examples (all of the readXXXData() functions).  You should follow the 
template of these functions; it's pretty easy and robust.  Your 
readSatelliteData() function will read in your data file line by line 
and create a new KSatellite object from each line.  You will also 
need to add a QPtrList object to KStarsData that will hold the 
collection of pointers to all of these objects (see kstarsdata.h for 
examples).

4.  Modify KStarsData::slotInitialize() to include satellites in the 
initial startup procedure.  slotInitialize() is a big switch 
statement that reads in all of the data files while the splashscreen 
is visible.  You'll just add a "case" label for satellites and 
include the call to readSatelliteData() there, similar to the way all 
the others are done.

5.  Add a SkyMap::drawSatellites() function to skymapdraw.cpp.  Again, 
see the other draw functions for an idea how to implement this.  
You'll see lots of code devoted to whether or not to draw a given 
object type depending on config options, program state, etc.  You can 
just forget about that stuff at first, once you have satellites 
working, we can worry about the config options and such.  Other 
details we'll want to add later might include a specialized popup 
menu for satellite objects.

6.  Add a call to drawSatellites() in SkyMap::paintEvent().  Once this 
is all done, you should have satellites in KStars!

It seems like a lot of work, and frankly it *is* a lot of work :).  
But, it's very doable.  I think you should attempt each step in the 
order I have presented here.  Get each step working before proceeding 
to the next, and you'll have it in no time.

I'm looking forward to seeing satellites in KStars!  Please don't 
hesitate to ask if you have any questions or need more help.

thanks,
Jason




More information about the Kstars-devel mailing list