[Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents
Akarsh Simha
akarshsimha at gmail.com
Sun Jul 20 23:04:34 CEST 2008
SVN commit 835613 by asimha:
Adding code to SkyMesh to support multiple meshes with different
levels.
CCMAIL: kstars-devel at kde.org
M +17 -5 skymesh.cpp
M +10 -2 skymesh.h
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymesh.cpp #835612:835613
@@ -29,20 +29,32 @@
#include "kstarsdata.h"
#include "skymap.h"
-SkyMesh* SkyMesh::pinstance = 0;
+QMap<int, SkyMesh *> SkyMesh::pinstances;
+int SkyMesh::defaultLevel = -1;
SkyMesh* SkyMesh::Create( KStarsData* data, int level )
{
- if ( pinstance ) delete pinstance;
- pinstance = new SkyMesh( data, level );
- return pinstance;
+ SkyMesh *newInstance;
+ newInstance = pinstances.value( level, NULL );
+ if( newInstance )
+ delete newInstance;
+ newInstance = new SkyMesh( data, level );
+ pinstances.insert( level, newInstance );
+ if( defaultLevel < 0 )
+ defaultLevel = newInstance->level();
+ return newInstance;
}
SkyMesh* SkyMesh::Instance( )
{
- return pinstance;
+ return pinstances.value( defaultLevel, NULL );
}
+SkyMesh* SkyMesh::Instance( int level )
+{
+ return pinstances.value( level, NULL );
+}
+
SkyMesh::SkyMesh( KStarsData* data, int level) :
HTMesh(level, level, NUM_MESH_BUF),
m_drawID(0), m_data( data ), m_KSNumbers( 0 )
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymesh.h #835612:835613
@@ -108,11 +108,18 @@
*/
static SkyMesh* Create( KStarsData* data, int level );
- /* @short returns the single instance of SkyMesh or null if it has not
+ /* @short returns the default instance of SkyMesh or null if it has not
* yet been created.
*/
static SkyMesh* Instance();
+ /**
+ *@short returns the instance of SkyMesh corresponding to the given level
+ *@return the instance of SkyMesh at the given level, or NULL if it has not
+ *yet been created.
+ */
+ static SkyMesh* Instance( int level );
+
/**@short finds the set of trixels that cover the circular aperture
* specified after first performing a reverse precession correction on
* the center so we don't have to re-index objects simply due to
@@ -293,7 +300,8 @@
int m_zoomedInPercent;
bool m_inDraw;
- static SkyMesh* pinstance;
+ static int defaultLevel;
+ static QMap<int, SkyMesh *> pinstances;
};
#endif
More information about the Kstars-devel
mailing list