[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Oct 7 01:21:56 CEST 2003


CVS commit by harris: 

Dynamic loading of stars works now.  There were two fixes required:

(1) Loading more stars by increasing the faint limit.  This code was in place already, but in 
FileSource::sendTo() it parses the star's magnitude from the data file, and this was not updated 
when the star catalog was switched to the Hipparcos catalog, so it was looking at the wrong 
position in the line.

(2) Removing stars when decreasing the faint limit.  Previously, stars were not unloaded from the 
program, just the faint limit was changed.  Now unused faint stars are actually removed, thus 
giving users the ability to free up memory by decreasing the faint limit.  Also, if any removed 
star is named, its entry is removed from the list of named objects.  I had to add a function 
ObjectNameList::remove(const QString &name) for this.

CCMAIL: kstars-devel at kde.org


  M +1 -1      filesource.cpp   1.11
  M +18 -0     kstarsdata.cpp   1.99
  M +10 -1     objectnamelist.cpp   1.13
  M +4 -0      objectnamelist.h   1.16


--- kdeedu/kstars/kstars/filesource.cpp  #1.10:1.11
@@ -60,5 +60,5 @@ void FileSource::sendTo(QDataSink *sink,
         while (data->starFileReader->hasMoreLines() && counter < maxLines) {
                 QString line = data->starFileReader->readLine();
-                float mag = line.mid(33, 4).toFloat();  // check magnitude
+                float mag = line.mid( 46, 5 ).toFloat();  // check magnitude
 //              kdDebug() << "mag=" << mag << " maxmag=" << maxMagnitude << endl;
                 if (mag > maxMagnitude) {

--- kdeedu/kstars/kstars/kstarsdata.cpp  #1.98:1.99
@@ -576,4 +576,8 @@ void KStarsData::processStar(QString *li
         starList.append(o);
 
+        //STAR_SIZE
+//      StarObject *p = new StarObject(r, d, mag, name, gname, SpType, pmra, pmdec, plx, mult, var );
+//      starList.append(p);
+
         // add named stars to list
         if (starIsUnnamed == false) {
@@ -1434,5 +1438,19 @@ void KStarsData::setMagnitude( float new
                         pump = new QDataPump (source, (QDataSink*) loader);
                 }
+        } else if ( newMagnitude < maxSetMagnitude ) {
+                StarObject *lastStar = starList.last();
+                while ( lastStar->mag() > newMagnitude  && starList.count() ) {
+                        //check if star is named.  If so, remove it from ObjNames
+                        if ( ! lastStar->name().isEmpty() ) {
+                                ObjNames.remove( lastStar->name() );
+                        }
+                        starList.removeLast();
+                        lastStar = starList.last();
+
+                        //Need to recompute names of objects
+                        sendClearCache();
         }
+        }
+
         // change current magnitude level in KStarsOptions
         options->setMagLimitDrawStar(newMagnitude);

--- kdeedu/kstars/kstars/objectnamelist.cpp  #1.12:1.13
@@ -172,4 +172,13 @@ void ObjectNameList::sort() {
 }
 
+void ObjectNameList::remove ( const QString &name ) {
+        setMode(oneList);
+        int index = getIndex(name);
+        SortedList <SkyObjectName> *l = &(list[language][index]);
+
+        SkyObjectName *son = find( name );
+        if ( son ) l->remove( son );
+}
+
 SkyObjectName* ObjectNameList::find(const QString &name) {
         sort();
@@ -189,5 +198,5 @@ SkyObjectName* ObjectNameList::find(cons
         int next;
         // items are translated stored
-        QString translatedName = i18n(name.latin1());
+        QString translatedName = i18n(name.utf8());
 
         // it's the "binary search" algorithm

--- kdeedu/kstars/kstars/objectnamelist.h  #1.15:1.16
@@ -77,4 +77,8 @@ class ObjectNameList {
                 SkyObjectName* find(const QString &name = QString::null);
 
+        /**@short remove named object from the list.
+                */
+                void remove( const QString &name = QString::null );
+
         /**
                 *Define the languages which should be used.




More information about the Kstars-devel mailing list