[Kstars-devel] branches/KDE/3.5/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Jan 27 21:51:17 CET 2008
SVN commit 767344 by harris:
Backporting fix for bug #147742 to 3.5 branch. In addition, I added
a fix that allows you to save stars with only a genetive name (i.e.,
"sigma Orionis"). Prior to this fix, the greek letter was
represented as a "?" in the observing list file, and could not be
parsed when reopening the list. Now, the greek letters are saved as
ascii-letter words instead of the actual greek letter.
Will forward-port this genetive name fix to 4.0 and trunk as well.
CCBUG: 147742
CCMAIL: kstars-devel at kde.org
M +6 -0 kstarsdata.cpp
M +1 -0 kstarsdata.h
M +46 -2 tools/observinglist.cpp
--- branches/KDE/3.5/kdeedu/kstars/kstars/kstarsdata.cpp #767343:767344
@@ -2315,6 +2315,12 @@
if ( name==cnameList.at(i)->name() ) return cnameList.at(i);
}
+ //Still no match. Try interpreting the string as a genetive star name
+ //(with ascii characters instead of a Greek letter)
+ for ( unsigned int i=0; i<starList.count(); ++i ) {
+ if ( name==starList.at(i)->gname( false ) ) return starList.at(i);
+ }
+
//reach here only if argument is not matched
return NULL;
}
--- branches/KDE/3.5/kdeedu/kstars/kstars/kstarsdata.h #767343:767344
@@ -112,6 +112,7 @@
friend class JMoonTool;
friend class telescopeWizardProcess;
friend class KSNewStuff;
+ friend class ObservingList;
friend class ObsListWizard;
/**Constructor. */
--- branches/KDE/3.5/kdeedu/kstars/kstars/tools/observinglist.cpp #767343:767344
@@ -41,6 +41,7 @@
#include "kstars.h"
#include "kstarsdata.h"
#include "skyobject.h"
+#include "starobject.h"
#include "skymap.h"
#include "detaildialog.h"
#include "tools/altvstime.h"
@@ -541,7 +542,34 @@
while ( ! istream.eof() ) {
line = istream.readLine();
- SkyObject *o = ks->data()->objectNamed( line );
+ //DEBUG
+ kdDebug() << line << endl;
+
+ //If the object is named "star", add it by coordinates
+ SkyObject *o = 0;
+ if ( line.startsWith( "star" ) ) {
+ QStringList fields = QStringList::split( " ", line );
+ //DEBUG
+ kdDebug() << fields << endl;
+
+ double ra = dms::fromString( fields[1], false ).Degrees(); //false = hours
+ double dc = dms::fromString( fields[2], true ).Degrees(); //true = degrees
+
+ //Identify the star with these coordinates
+ double rmax = 1.;
+ for ( uint i=0; i < ks->data()->starList.count(); ++i ) {
+ SkyObject *s = (SkyObject*)(ks->data()->starList.at(i));
+ double dra = fabs( ra - s->ra()->Degrees() );
+ double ddc = fabs( dc - s->dec()->Degrees() );
+ if ( dra < rmax && ddc < rmax ) {
+ o = s;
+ rmax = sqrt( dra*dra + ddc*ddc );
+ }
+ }
+ } else {
+ o = ks->data()->objectNamed( line );
+ }
+
if ( o ) slotAddObject( o );
}
@@ -610,8 +638,24 @@
QTextStream ostream(&f);
ostream << ListName << endl;
+
+ //Save objects to the list using their name. If it's a star with a genetive name
+ //(i.e., "sigma orionis"), save the name with ascii characters, not greek letters.
+ //If it's an unnamed star, save "star" and the star's coordinates.
for ( SkyObject* o = obsList.first(); o; o = obsList.next() ) {
- ostream << o->name() << endl;
+ if ( o->name() == "star" ) {
+ ostream << o->name() << " " << o->ra()->Hours() << " " << o->dec()->Degrees() << endl;
+ } else if ( o->type() == SkyObject::STAR ) {
+ StarObject *s = (StarObject*)o;
+
+ if ( s->name() == s->gname() ) {
+ ostream << s->gname( false ) << endl;
+ } else {
+ ostream << o->name() << endl;
+ }
+ } else {
+ ostream << o->name() << endl;
+ }
}
f.close();
More information about the Kstars-devel
mailing list