[Kstars-devel] RFC: Refactoring of SkyMap

Jason Harris kstars at 30doradus.org
Wed Jul 27 18:15:04 CEST 2005


Hi Thomas,

I think this is a great idea.  

regards,
Jason

On Wednesday 27 July 2005 05:02 am, Thomas Kabelmann wrote:
> Hi everyone,
>
> while looking in the code of current svn head, I found that class SkyMap is
> a big mess. A "wc -l skymap*" says that ~5000 lines are in that class
> (comments and free lines included).
>
> My idea for refactoring the class is following:
> - split SkyMap into SkyMap + SkyMapElements
> - SkyMap stores all data like focus and so on
> - SkyMapElement is an interface for all drawable elements (like horizon,
> milkyway, ...)
> - each element implements this interface so the skymap can store all
> elements in a list -- the advantage is, skymap doesn't need a member
> variable for each element and adding new elements just require to add this
> in the implemenation of skymap, not in the interface
>
> Here is some pseudo code for sketching my idea:
>
> class SkyMap
> {
> 	...
> 	SkyMap() {
> 		elementList = new QList();
> 		elementList.add(new Horizon());
> 		...
> 		elementList.add(new CoordinatGrid());
> 	}
>
> 	QList elementList;
> 	paintEvent()
> 	{
> 		foreach (element in elementList)
> 			element->draw();
> 	}
> }
>
> class SkyMapElement
> {
> 	SkyMap *map;
> 	public:
> 		SkyMapElement(SkyMap *m) { map = m; }
> 		virtual void draw() = 0;
> }
>
> class Horizon : SkyMapElement
> {
> 	void draw()
> 	{
> 		if (!Options::drawHorizon) return;
> 		// insert drawing code here
> 	}
> }
>
> The API is perhaps not complete, it's just an idea at this time. Any ideas,
> comments?
>
> Regards,
> Thomas
> _______________________________________________
> Kstars-devel mailing list
> Kstars-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kstars-devel

-- 
-------------------------------
KStars: KDE Desktop Planetarium
http://edu.kde.org/kstars


More information about the Kstars-devel mailing list