[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Tue Jun 10 02:14:11 CEST 2008
SVN commit 818909 by asimha:
+ Removing the StarObject::init() with many arguments and retaining
only StarObject::init( starData *stardata );
+ Adding StarObject::setNames() so that named stars can be initialized
from starObject::init() and have their names set later
+ Modifying the code in StarComponent to use the the other (only)
StarObject::init() method. Reducing the number of arguments to the
init() method reduced the time for creation of one star by 1 usec,
which is a 20% reduction in load time. (Earlier load time ~ 225ms,
current load time ~ 183ms). This also keeps the code clean and reduces
code duplication.
+ Documentation fixes, indentation fixes etc.
CCMAIL: kstars-devel at kde.org
M +6 -0 skycomponents/starcomponent.cpp
M +9 -8 skycomponents/starcomponent.h
M +26 -7 starobject.cpp
M +11 -2 starobject.h
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #818908:818909
@@ -469,9 +469,12 @@
/* Make a copy of the star template and set up the data in it */
star = (StarObject *)malloc(sizeof(StarObject));
star = (StarObject *)memcpy(star, &plainStarTemplate, sizeof(StarObject));
+ /*
star -> init(stardata.RA/1000000.0, stardata.Dec/100000.0, stardata.mag/100.0,
QByteArray(stardata.spec_type, 2), stardata.dRA/10.0, stardata.dDec/10.0,
stardata.parallax/10.0, stardata.flags & 0x02, stardata.flags & 0x04);
+ */
+ star->init( &stardata );
}
star->EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
++nstars;
@@ -562,9 +565,12 @@
kDebug() << "WARNING: Named Star encountered while reading StarBlock. Name will not be loaded!";
memcpy( SB->stars.at( i ), &plainStarTemplate, sizeof( StarObject ) );
+ /*
SB->stars.at( i )->init( stardata.RA/1000000.0, stardata.Dec/100000.0, stardata.mag/100.0,
QByteArray( stardata.spec_type, 2 ), stardata.dRA/10.0, stardata.dDec/10.0,
stardata.parallax/10.0, stardata.flags & 0x02, stardata.flags & 0x04 );
+ */
+ SB->stars.at( i )->init( &stardata );
SB->starsRead++;
}
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.h #818908:818909
@@ -18,14 +18,15 @@
#ifndef STARCOMPONENT_H
#define STARCOMPONENT_H
-/**@class StarComponent
-*Represents the stars on the sky map. For optimization reasons the stars are
-*not separate objects and are stored in a list.
+/**
+ *@class StarComponent
+ *Represents the stars on the sky map. For optimization reasons the stars are
+ *not separate objects and are stored in a list.
+ *
+ *@author Thomas Kabelmann
+ *@version 0.1
+ */
-*@author Thomas Kabelmann
-*@version 0.1
-*/
-
#include "listcomponent.h"
#include "kstarsdatetime.h"
#include "ksnumbers.h"
@@ -153,7 +154,7 @@
*/
// void readLineNumbers();
- // REMOVE
+ // REMOVED
/**
*@short returns an estimate of the stars.dat line number for a given
* star magnitude.
--- branches/kstars/summer/kdeedu/kstars/kstars/starobject.cpp #818908:818909
@@ -94,28 +94,31 @@
const QString &n, const QString &n2,
const QString &sptype, double pmra, double pmdec,
double par, bool mult, bool var )
- : SkyObject (SkyObject::STAR, r, d, m, n, n2, QString()),
- PM_RA(pmra), PM_Dec(pmdec),
- Parallax(par), Multiplicity(mult), Variability(var)
- // SONAME deprecated //, soName( 0 )
+ : SkyObject (SkyObject::STAR, r, d, m, n, n2, QString()),
+ PM_RA(pmra), PM_Dec(pmdec),
+ Parallax(par), Multiplicity(mult), Variability(var)
+ // SONAME deprecated //, soName( 0 )
{
const char *spt = (const char *)sptype.toAscii();
SpType[0] = spt[0];
SpType[1] = spt[1];
-
+
QString lname;
if ( hasName() ) {
lname = n;
if ( hasName2() )lname += n + " (" + gname() + ')';
} else if ( hasName2() )
lname = gname();
-
+
setLongName(lname);
updateID = updateNumID = 0;
}
+
+// DEPRECATED
+/*
void StarObject::init(double r, double d, float m, const QString &sptype, double pmra,
- double pmdec, double par, bool mult, bool var)
+ double pmdec, double par, bool mult, bool var)
{
setType( SkyObject::STAR );
setMag( m );
@@ -135,6 +138,7 @@
// setLongName(i18n("star"));
updateID = updateNumID = 0;
}
+*/
void StarObject::init( const starData *stardata )
{
@@ -157,6 +161,21 @@
updateID = updateNumID = 0;
}
+void StarObject::setNames( QString name, QString name2 ) {
+ QString lname;
+
+ setName( name );
+ setName2( name2 );
+
+ if ( hasName() ) {
+ lname = name;
+ if ( hasName2() ) lname += name + " (" + gname() + ')';
+ } else if ( hasName2() )
+ lname = gname();
+ setLongName(lname);
+}
+
+
void StarObject::initImages() {
SkyMap *map = SkyMap::Instance();
double scale = 1.0;
--- branches/kstars/summer/kdeedu/kstars/kstars/starobject.h #818908:818909
@@ -95,6 +95,7 @@
*/
~StarObject() { }
+ // REMOVED
/**
*@short Initializes a StarObject to given data
*
@@ -114,8 +115,8 @@
*@return Nothing
*/
- void init(double r, double d, float m=0.0, const QString &sptype="--", double pmra=0.0, double pmdec=0.0,
- double par=0.0, bool mult=false, bool var=false);
+ // void init(double r, double d, float m=0.0, const QString &sptype="--", double pmra=0.0, double pmdec=0.0,
+ // double par=0.0, bool mult=false, bool var=false);
/**
*@short Initializes a StarObject to given data
@@ -130,7 +131,15 @@
void init( const starData *stardata );
+ /**
+ *@short Sets the name, genetive name, and long name
+ *
+ *@param name Common name
+ *@param name2 Genetive name
+ */
+ void setNames( QString name, QString name2 );
+
/**
*@return true if the star has a name ("star" doesn't count)
*/
More information about the Kstars-devel
mailing list