[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Mon Jun 9 03:41:50 CEST 2008
SVN commit 818628 by asimha:
Implementing a method that initializes a StarObject from a starData
structure. This function call is expected to be faster than the
earlier StarObject::init(...) which used to take several parameters.
CCMAIL: kstars-devel at kde.org
M +21 -2 starobject.cpp
M +16 -3 starobject.h
--- branches/kstars/summer/kdeedu/kstars/kstars/starobject.cpp #818627:818628
@@ -117,8 +117,6 @@
void StarObject::init(double r, double d, float m, const QString &sptype, double pmra,
double pmdec, double par, bool mult, bool var)
{
-
- /* TODO: Fix bug and uncomment this code */
setType( SkyObject::STAR );
setMag( m );
setRA0( r );
@@ -138,6 +136,27 @@
updateID = updateNumID = 0;
}
+void StarObject::init( const starData *stardata )
+{
+ double ra, dec;
+ ra = stardata->RA / 1000000.0;
+ dec = stardata->Dec / 100000.0;
+ setType( SkyObject::STAR );
+ setMag( stardata->mag / 100.0 );
+ setRA0( ra );
+ setDec0( dec );
+ setRA( ra );
+ setDec( dec );
+ SpType[0] = stardata->spec_type[0];
+ SpType[1] = stardata->spec_type[1];
+ PM_RA = stardata->dRA / 10.0;
+ PM_Dec = stardata->dDec / 10.0;
+ Parallax = stardata->parallax / 10.0;
+ Multiplicity = stardata->flags & 0x02;
+ Variability = stardata->flags & 0x04 ;
+ updateID = updateNumID = 0;
+}
+
void StarObject::initImages() {
SkyMap *map = SkyMap::Instance();
double scale = 1.0;
--- branches/kstars/summer/kdeedu/kstars/kstars/starobject.h #818627:818628
@@ -23,6 +23,7 @@
#include <QPixmap>
#include "skyobject.h"
+#include "stardata.h"
class QPainter;
class QString;
@@ -111,14 +112,26 @@
*@param mult Multiplicity flag (false=dingle star; true=multiple star)
*@param var Variability flag (true if star is a known periodic variable)
*@return Nothing
- *
- * WARNING: This method is dangerous. Use only if you didn't call the default constructor.
- * Calling this method otherwise may lead to memory leakage!
*/
+
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
+ *
+ * This is almost like the StarObject constructor itself, but it avoids
+ * setting up name, gname etc for unnamed stars. If called instead of the
+ * constructor, this method will be much faster for unnamed stars
+ *
+ *@param stardata Pointer to starData object containing required data (except name and gname)
+ *@return Nothing
+ */
+
+ void init( const starData *stardata );
+
+
+ /**
*@return true if the star has a name ("star" doesn't count)
*/
inline bool hasName() const { return ( !Name.isEmpty() && Name!=starString ); }
More information about the Kstars-devel
mailing list