• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
kstarsdata.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  kstarsdata.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sun Jul 29 2001
5  copyright : (C) 2001 by Heiko Evermann
6  email : heiko@evermann.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "kstarsdata.h"
19 
20 #include <QApplication>
21 #include <QFileInfo>
22 #include <QSet>
23 #include <QTextStream>
24 
25 #include <kcomponentdata.h>
26 #include <kmessagebox.h>
27 #include <kdebug.h>
28 #include <klocale.h>
29 #include <kstandarddirs.h>
30 
31 #include "Options.h"
32 #include "dms.h"
33 #include "fov.h"
34 #include "skymap.h"
35 #include "ksutils.h"
36 #include "ksfilereader.h"
37 #include "ksnumbers.h"
38 #include "skyobjects/skyobject.h"
39 #include "skycomponents/supernovaecomponent.h"
40 #include "skycomponents/skymapcomposite.h"
41 
42 #include "simclock.h"
43 #include "timezonerule.h"
44 
45 #include <config-kstars.h>
46 #include "dialogs/detaildialog.h"
47 
48 namespace {
49  // Convert string to integer and complain on failure.
50  //
51  // This function is used in processCity
52  bool strToInt(int& i, QString str, QString line = QString()) {
53  bool ok;
54  i = str.toInt( &ok );
55  if( !ok )
56  kDebug() << str << i18n( "\nCities.dat: Bad integer. Line was:\n" ) << line;
57  return ok;
58  }
59 
60  // Report fatal error during data loading to user
61  // Calls QApplication::exit
62  void fatalErrorMessage(QString fname) {
63  KMessageBox::sorry(0, i18n("The file %1 could not be found. "
64  "KStars cannot run properly without this file. "
65  "KStars search for this file in following locations:\n\n"
66  "\t$(KDEDIR)/share/apps/kstars/%1\n"
67  "\t~/.kde/share/apps/kstars/%1\n\n"
68  "It appears that your setup is broken.", fname),
69  i18n( "Critical File Not Found: %1", fname ));
70  qApp->exit(1);
71  }
72 
73  // Report non-fatal error during data loading to user and ask
74  // whether he wants to continue.
75  // Calls QApplication::exit if he don't
76  bool nonFatalErrorMessage(QString fname) {
77  int res = KMessageBox::warningContinueCancel(0,
78  i18n("The file %1 could not be found. "
79  "KStars can still run without this file. "
80  "KStars search for this file in following locations:\n\n"
81  "\t$(KDEDIR)/share/apps/kstars/%1\n"
82  "\t~/.kde/share/apps/kstars/%1\n\n"
83  "It appears that you setup is broken. Press Continue to run KStars without this file ", fname),
84  i18n( "Non-Critical File Not Found: %1", fname ));
85  if( res != KMessageBox::Continue )
86  qApp->exit(1);
87  return res == KMessageBox::Continue;
88  }
89 }
90 
91 KStarsData* KStarsData::pinstance = 0;
92 
93 KStarsData* KStarsData::Create()
94 {
95  // This method should never be called twice within a run, since a
96  // lot of the code assumes that KStarsData, once created, is never
97  // destroyed. They maintain local copies of KStarsData::Instance()
98  // for efficiency (maybe this should change, but it is not
99  // required to delete and reinstantiate KStarsData). Thus, when we
100  // call this method, pinstance MUST be zero, i.e. this must be the
101  // first (and last) time we are calling it. -- asimha
102  Q_ASSERT( !pinstance );
103 
104  delete pinstance;
105  pinstance = new KStarsData();
106  return pinstance;
107 }
108 
109 KStarsData::KStarsData() :
110  m_SkyComposite(0),
111  m_Geo(dms(0), dms(0)),
112  m_ksuserdb(),
113  m_catalogdb(),
114  temporaryTrail( false ),
115  locale( new KLocale( "kstars" ) ),
116  m_preUpdateID(0), m_updateID(0),
117  m_preUpdateNumID(0), m_updateNumID(0),
118  m_preUpdateNum( J2000 ), m_updateNum( J2000 )
119 {
120  m_logObject = new OAL::Log;
121  // at startup times run forward
122  setTimeDirection( 0.0 );
123 
124 }
125 
126 KStarsData::~KStarsData() {
127  Q_ASSERT( pinstance );
128 
129  delete locale;
130  delete m_logObject;
131 
132  qDeleteAll( geoList );
133  qDeleteAll( ADVtreeList );
134 
135  pinstance = 0;
136 }
137 
138 bool KStarsData::initialize() {
139  //Initialize CatalogDB//
140  catalogdb()->Initialize();
141 
142  //Load Time Zone Rules//
143  emit progressText( i18n("Reading time zone rules") );
144  if( !readTimeZoneRulebook( ) ) {
145  fatalErrorMessage( "TZrules.dat" );
146  return false;
147  }
148 
149  //Load Cities//
150  emit progressText( i18n("Loading city data") );
151  if ( !readCityData( ) ) {
152  fatalErrorMessage( "Cities.dat" );
153  return false;
154  }
155 
156  //Initialize SkyMapComposite//
157  emit progressText(i18n("Loading sky objects" ) );
158  m_SkyComposite = new SkyMapComposite(0);
159 
160  //Load Image URLs//
161  emit progressText( i18n("Loading Image URLs" ) );
162  if( !readURLData( "image_url.dat", 0 ) && !nonFatalErrorMessage( "image_url.dat" ) )
163  return false;
164 
165  //Load Information URLs//
166  emit progressText( i18n("Loading Information URLs" ) );
167  if( !readURLData( "info_url.dat", 1 ) && !nonFatalErrorMessage( "info_url.dat" ) )
168  return false;
169 
170  emit progressText( i18n("Loading Variable Stars" ) );
171 
172  //Initialize User Database//
173  emit progressText( i18n("Loading User Information" ) );
174  m_ksuserdb.Initialize();
175 
176  //Update supernovae list if enabled
177  if( Options::updateSupernovaeOnStartup() ) {
178  emit progressText( i18n("Queueing update of list of supernovae from the internet") );
179  skyComposite()->supernovaeComponent()->slotTriggerDataFileUpdate();
180  }
181 
182  readUserLog();
183 
184  readADVTreeData();
185 
186  return true;
187 }
188 
189 void KStarsData::updateTime( GeoLocation *geo, SkyMap *skymap, const bool automaticDSTchange ) {
190  // sync LTime with the simulation clock
191  LTime = geo->UTtoLT( ut() );
192  syncLST();
193 
194  //Only check DST if (1) TZrule is not the empty rule, and (2) if we have crossed
195  //the DST change date/time.
196  if ( !geo->tzrule()->isEmptyRule() ) {
197  if ( TimeRunsForward ) {
198  // timedirection is forward
199  // DST change happens if current date is bigger than next calculated dst change
200  if ( ut() > NextDSTChange ) resetToNewDST(geo, automaticDSTchange);
201  } else {
202  // timedirection is backward
203  // DST change happens if current date is smaller than next calculated dst change
204  if ( ut() < NextDSTChange ) resetToNewDST(geo, automaticDSTchange);
205  }
206  }
207 
208  KSNumbers num( ut().djd() );
209 
210  if ( fabs( ut().djd() - LastNumUpdate.djd() ) > 1.0 ) {
211  LastNumUpdate = ut().djd();
212  m_preUpdateNumID++;
213  m_preUpdateNum = KSNumbers( num );
214  skyComposite()->update( &num );
215  }
216 
217  if ( fabs( ut().djd() - LastPlanetUpdate.djd() ) > 0.01 ) {
218  LastPlanetUpdate = ut().djd();
219  skyComposite()->updatePlanets( &num );
220  }
221 
222  // Moon moves ~30 arcmin/hr, so update its position every minute.
223  if ( fabs( ut().djd() - LastMoonUpdate.djd() ) > 0.00069444 ) {
224  LastMoonUpdate = ut();
225  skyComposite()->updateMoons( &num );
226  }
227 
228  //Update Alt/Az coordinates. Timescale varies with zoom level
229  //If Clock is in Manual Mode, always update. (?)
230  if ( fabs( ut().djd() - LastSkyUpdate.djd() ) > 0.1/Options::zoomFactor() || clock()->isManualMode() ) {
231  LastSkyUpdate = ut();
232  m_preUpdateID++;
233  skyComposite()->update(); //omit KSNumbers arg == just update Alt/Az coords
234 
235  //Update focus
236  skymap->updateFocus();
237 
238  if ( clock()->isManualMode() )
239  QTimer::singleShot( 0, skymap, SLOT( forceUpdateNow() ) );
240  else
241  skymap->forceUpdate();
242  }
243 }
244 
245 void KStarsData::syncUpdateIDs()
246 {
247  m_updateID = m_preUpdateID;
248  if ( m_updateNumID == m_preUpdateNumID ) return;
249  m_updateNumID = m_preUpdateNumID;
250  m_updateNum = KSNumbers( m_preUpdateNum );
251 }
252 
253 unsigned int KStarsData::incUpdateID() {
254  m_preUpdateID++;
255  m_preUpdateNumID++;
256  syncUpdateIDs();
257  return m_updateID;
258 }
259 
260 void KStarsData::setFullTimeUpdate() {
261  //Set the update markers to invalid dates to trigger updates in each category
262  LastSkyUpdate = KDateTime();
263  LastPlanetUpdate = KDateTime();
264  LastMoonUpdate = KDateTime();
265  LastNumUpdate = KDateTime();
266 }
267 
268 void KStarsData::syncLST() {
269  LST = geo()->GSTtoLST( ut().gst() );
270 }
271 
272 void KStarsData::changeDateTime( const KStarsDateTime &newDate ) {
273  //Turn off animated slews for the next time step.
274  setSnapNextFocus();
275 
276  clock()->setUTC( newDate );
277 
278  LTime = geo()->UTtoLT( ut() );
279  //set local sideral time
280  syncLST();
281 
282  //Make sure Numbers, Moon, planets, and sky objects are updated immediately
283  setFullTimeUpdate();
284 
285  // reset tzrules data with new local time and time direction (forward or backward)
286  geo()->tzrule()->reset_with_ltime(LTime, geo()->TZ0(), isTimeRunningForward() );
287 
288  // reset next dst change time
289  setNextDSTChange( geo()->tzrule()->nextDSTChange() );
290 }
291 
292 void KStarsData::resetToNewDST(GeoLocation *geo, const bool automaticDSTchange) {
293  // reset tzrules data with local time, timezone offset and time direction (forward or backward)
294  // force a DST change with option true for 3. parameter
295  geo->tzrule()->reset_with_ltime( LTime, geo->TZ0(), TimeRunsForward, automaticDSTchange );
296  // reset next DST change time
297  setNextDSTChange( geo->tzrule()->nextDSTChange() );
298  //reset LTime, because TZoffset has changed
299  LTime = geo->UTtoLT( ut() );
300 }
301 
302 void KStarsData::setTimeDirection( float scale ) {
303  TimeRunsForward = scale >= 0;
304 }
305 
306 GeoLocation* KStarsData::locationNamed( const QString &city, const QString &province, const QString &country ) {
307  foreach ( GeoLocation *loc, geoList ) {
308  if ( loc->translatedName() == city &&
309  ( province.isEmpty() || loc->translatedProvince() == province ) &&
310  ( country.isEmpty() || loc->translatedCountry() == country ) ) {
311  return loc;
312  }
313  }
314  return 0;
315 }
316 
317 void KStarsData::setLocationFromOptions() {
318  setLocation( GeoLocation ( dms(Options::longitude()), dms(Options::latitude()),
319  Options::cityName(), Options::provinceName(), Options::countryName(),
320  Options::timeZone(), &(Rulebook[ Options::dST() ]), 4, Options::elevation() ) );
321 }
322 
323 void KStarsData::setLocation( const GeoLocation &l ) {
324  m_Geo = GeoLocation(l);
325  if ( m_Geo.lat()->Degrees() >= 90.0 ) m_Geo.setLat( dms(89.99) );
326  if ( m_Geo.lat()->Degrees() <= -90.0 ) m_Geo.setLat( dms(-89.99) );
327 
328  //store data in the Options objects
329  Options::setCityName( m_Geo.name() );
330  Options::setProvinceName( m_Geo.province() );
331  Options::setCountryName( m_Geo.country() );
332  Options::setTimeZone( m_Geo.TZ0() );
333  Options::setElevation( m_Geo.height() );
334  Options::setLongitude( m_Geo.lng()->Degrees() );
335  Options::setLatitude( m_Geo.lat()->Degrees() );
336  // set the rule from rulebook
337  foreach( const QString& key, Rulebook.keys() ) {
338  if( !key.isEmpty() && m_Geo.tzrule()->equals(&Rulebook[key]) )
339  Options::setDST(key);
340  }
341 
342  emit geoChanged();
343 }
344 
345 SkyObject* KStarsData::objectNamed( const QString &name ) {
346  if ( (name== "star") || (name== "nothing") || name.isEmpty() )
347  return NULL;
348  return skyComposite()->findByName( name );
349 }
350 
351 bool KStarsData::readCityData() {
352  QFile file;
353  bool citiesFound = false;
354 
355  if ( KSUtils::openDataFile( file, "Cities.dat" ) ) {
356  KSFileReader fileReader( file ); // close file is included
357  while ( fileReader.hasMoreLines() ) {
358  citiesFound |= processCity( fileReader.readLine() );
359  }
360  file.close();
361  }
362 
363  //check for local cities database, but don't require it.
364  //determine filename in local user KDE directory tree.
365  file.setFileName( KStandardDirs::locate( "appdata", "mycities.dat" ) );
366  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
367  QTextStream stream( &file );
368  while ( !stream.atEnd() ) {
369  QString line = stream.readLine();
370  citiesFound |= processCity( line );
371  }
372  file.close();
373  }
374 
375  return citiesFound;
376 }
377 
378 bool KStarsData::processCity( const QString& line ) {
379  TimeZoneRule *TZrule;
380  double TZ;
381 
382  // separate fields
383  QStringList fields = line.split( ':' );
384  for(int i = 0; i < fields.size(); ++i )
385  fields[i] = fields[i].trimmed();
386 
387  if ( fields.size() < 11 ) {
388  kDebug() << i18n( "Cities.dat: Ran out of fields. Line was:" );
389  kDebug() << line;
390  return false;
391  } else if ( fields.size() < 12 ) {
392  // allow old format (without TZ) for mycities.dat
393  fields.append(QString());
394  fields.append("--");
395  } else if ( fields.size() < 13 ) {
396  // Set TZrule to "--"
397  fields.append("--");
398  }
399 
400  // Read names
401  QString name = fields[0];
402  QString province = fields[1];
403  QString country = fields[2];
404 
405  // Read coordinates
406  int lngD, lngM, lngS;
407  int latD, latM, latS;
408  bool ok =
409  strToInt(latD, fields[3], line) &&
410  strToInt(latM, fields[4], line) &&
411  strToInt(latS, fields[5], line) &&
412  strToInt(lngD, fields[7], line) &&
413  strToInt(lngM, fields[8], line) &&
414  strToInt(lngS, fields[9], line);
415  if( !ok )
416  return false;
417 
418  double lat = latD + (latM + latS/60.0)/60.0;
419  double lng = lngD + (lngM + lngS/60.0)/60.0;
420 
421  // Read sign for latitude
422  switch( fields[6].at(0).toAscii() ) {
423  case 'N' : break;
424  case 'S' : lat *= -1; break;
425  default :
426  kDebug() << i18n( "\nCities.dat: Invalid latitude sign. Line was:\n" ) << line;
427  return false;
428  }
429 
430  // Read sign for longitude
431  switch( fields[10].at(0).toAscii() ) {
432  case 'E' : break;
433  case 'W' : lng *= -1; break;
434  default:
435  kDebug() << i18n( "\nCities.dat: Invalid longitude sign. Line was:\n" ) << line;
436  return false;
437  }
438 
439  // find time zone. Use value from Cities.dat if available.
440  // otherwise use the old approximation: int(lng/15.0);
441  if ( fields[11].isEmpty() || ('x' == fields[11].at(0)) ) {
442  TZ = int(lng/15.0);
443  } else {
444  bool doubleCheck;
445  TZ = fields[11].toDouble( &doubleCheck);
446  if ( !doubleCheck ) {
447  kDebug() << fields[11] << i18n( "\nCities.dat: Bad time zone. Line was:\n" ) << line;
448  return false;
449  }
450  }
451 
452  //last field is the TimeZone Rule ID.
453  // FIXME: no checking performed. Crash is possible
454  TZrule = &( Rulebook[ fields[12] ] );
455 
456  // appends city names to list
457  geoList.append ( new GeoLocation( dms(lng), dms(lat), name, province, country, TZ, TZrule ));
458  return true;
459 }
460 
461 bool KStarsData::readTimeZoneRulebook() {
462  QFile file;
463 
464  if ( KSUtils::openDataFile( file, "TZrules.dat" ) ) {
465  QTextStream stream( &file );
466 
467  while ( !stream.atEnd() ) {
468  QString line = stream.readLine().trimmed();
469  if ( line.length() && !line.startsWith('#') ) { //ignore commented and blank lines
470  QStringList fields = line.split( ' ', QString::SkipEmptyParts );
471  QString id = fields[0];
472  QTime stime = QTime( fields[3].left( fields[3].indexOf(':')).toInt() ,
473  fields[3].mid( fields[3].indexOf(':')+1, fields[3].length()).toInt() );
474  QTime rtime = QTime( fields[6].left( fields[6].indexOf(':')).toInt(),
475  fields[6].mid( fields[6].indexOf(':')+1, fields[6].length()).toInt() );
476 
477  Rulebook[ id ] = TimeZoneRule( fields[1], fields[2], stime, fields[4], fields[5], rtime );
478  }
479  }
480  return true;
481  } else {
482  return false;
483  }
484 }
485 
486 bool KStarsData::openUrlFile(const QString &urlfile, QFile & file) {
487  //QFile file;
488  QString localFile;
489  bool fileFound = false;
490  QFile localeFile;
491 
492  if ( locale->language() != "en_US" )
493  localFile = locale->language() + '/' + urlfile;
494 
495  if ( ! localFile.isEmpty() && KSUtils::openDataFile( file, localFile ) ) {
496  fileFound = true;
497  } else {
498  // Try to load locale file, if not successful, load regular urlfile and then copy it to locale.
499  file.setFileName( KStandardDirs::locateLocal( "appdata", urlfile ) );
500  if ( file.open( QIODevice::ReadOnly ) ) {
501  //local file found. Now, if global file has newer timestamp, then merge the two files.
502  //First load local file into QStringList
503  bool newDataFound( false );
504  QStringList urlData;
505  QTextStream lStream( &file );
506  while ( ! lStream.atEnd() ) urlData.append( lStream.readLine() );
507 
508  //Find global file(s) in findAllResources() list.
509  QFileInfo fi_local( file.fileName() );
510  QStringList flist = KGlobal::mainComponent().dirs()->findAllResources( "appdata", urlfile );
511  for ( int i=0; i< flist.size(); i++ ) {
512  if ( flist[i] != file.fileName() ) {
513  QFileInfo fi_global( flist[i] );
514 
515  //Is this global file newer than the local file?
516  if ( fi_global.lastModified() > fi_local.lastModified() ) {
517  //Global file has newer timestamp than local. Add lines in global file that don't already exist in local file.
518  //be smart about this; in some cases the URL is updated but the image is probably the same if its
519  //label string is the same. So only check strings up to last ":"
520  QFile globalFile( flist[i] );
521  if ( globalFile.open( QIODevice::ReadOnly ) ) {
522  QTextStream gStream( &globalFile );
523  while ( ! gStream.atEnd() ) {
524  QString line = gStream.readLine();
525 
526  //If global-file line begins with "XXX:" then this line should be removed from the local file.
527  if ( line.startsWith(QLatin1String("XXX:")) && urlData.contains( line.mid( 4 ) ) ) {
528  urlData.removeAt( urlData.indexOf( line.mid( 4 ) ) );
529  } else {
530  //does local file contain the current global file line, up to second ':' ?
531 
532  bool linefound( false );
533  for ( int j=0; j< urlData.size(); ++j ) {
534  if ( urlData[j].contains( line.left( line.indexOf( ':', line.indexOf( ':' ) + 1 ) ) ) ) {
535  //replace line in urlData with its equivalent in the newer global file.
536  urlData.replace( j, line );
537  if ( !newDataFound ) newDataFound = true;
538  linefound = true;
539  break;
540  }
541  }
542  if ( ! linefound ) {
543  urlData.append( line );
544  if ( !newDataFound ) newDataFound = true;
545  }
546  }
547  }
548  }
549  }
550  }
551  }
552 
553  file.close();
554 
555  //(possibly) write appended local file
556  if ( newDataFound ) {
557  if ( file.open( QIODevice::WriteOnly ) ) {
558  QTextStream outStream( &file );
559  for ( int i=0; i<urlData.size(); i++ ) {
560  outStream << urlData[i] << endl;
561  }
562  file.close();
563  }
564  }
565 
566  if ( file.open( QIODevice::ReadOnly ) ) fileFound = true;
567 
568  } else {
569  if ( KSUtils::openDataFile( file, urlfile ) ) {
570  if ( locale->language() != "en_US" ) kDebug() << i18n( "No localized URL file; using default English file." );
571  // we found urlfile, we need to copy it to locale
572  localeFile.setFileName( KStandardDirs::locateLocal( "appdata", urlfile ) );
573  if (localeFile.open(QIODevice::WriteOnly)) {
574  QTextStream readStream(&file);
575  QTextStream writeStream(&localeFile);
576  while ( ! readStream.atEnd() ) {
577  QString line = readStream.readLine();
578  if ( !line.startsWith( QLatin1String( "XXX:" ) ) ) //do not write "deleted" lines
579  writeStream << line << endl;
580  }
581 
582  localeFile.close();
583  file.reset();
584  } else {
585  kDebug() << i18n( "Failed to copy default URL file to locale folder, modifying default object links is not possible" );
586  }
587  fileFound = true;
588  }
589  }
590  }
591  return fileFound;
592 }
593 
594 bool KStarsData::readURLData( const QString &urlfile, int type, bool deepOnly ) {
595  QFile file;
596  if (!openUrlFile(urlfile, file)) return false;
597 
598  QTextStream stream(&file);
599 
600  while ( !stream.atEnd() ) {
601  QString line = stream.readLine();
602 
603  //ignore comment lines
604  if ( !line.startsWith('#') ) {
605  int idx = line.indexOf(':');
606  QString name = line.left( idx );
607  QString sub = line.mid( idx + 1 );
608  idx = sub.indexOf(':');
609  QString title = sub.left( idx );
610  QString url = sub.mid( idx + 1 );
611  // Dirty hack to fix things up for planets
612  SkyObject *o;
613  if( name == "Mercury" || name == "Venus" || name == "Mars" || name == "Jupiter"
614  || name == "Saturn" || name == "Uranus" || name == "Neptune" || name == "Pluto" )
615  o = skyComposite()->findByName( i18n( name.toLocal8Bit().data() ) );
616  else
617  o = skyComposite()->findByName( name );
618 
619  if ( !o ) {
620  kWarning() << i18n( "Object named %1 not found", name ) ;
621  } else {
622  if ( ! deepOnly || ( o->type() > 2 && o->type() < 9 ) ) {
623  if ( type==0 ) { //image URL
624  o->ImageList().append( url );
625  o->ImageTitle().append( title );
626  } else if ( type==1 ) { //info URL
627  o->InfoList().append( url );
628  o->InfoTitle().append( title );
629  }
630  }
631  }
632  }
633  }
634  file.close();
635  return true;
636 }
637 
638 bool KStarsData::readUserLog()
639 {
640  QFile file;
641  QString buffer;
642  QString sub, name, data;
643 
644  if (!KSUtils::openDataFile( file, "userlog.dat" )) return false;
645 
646  QTextStream stream(&file);
647 
648  if (!stream.atEnd()) buffer = stream.readAll();
649 
650  while (!buffer.isEmpty()) {
651  int startIndex, endIndex;
652 
653  startIndex = buffer.indexOf(QLatin1String("[KSLABEL:"));
654  sub = buffer.mid(startIndex);
655  endIndex = sub.indexOf(QLatin1String("[KSLogEnd]"));
656 
657  // Read name after KSLABEL identifer
658  name = sub.mid(startIndex + 9, sub.indexOf(']') - (startIndex + 9));
659  // Read data and skip new line
660  data = sub.mid(sub.indexOf(']') + 2, endIndex - (sub.indexOf(']') + 2));
661  buffer = buffer.mid(endIndex + 11);
662 
663  //Find the sky object named 'name'.
664  //Note that ObjectNameList::find() looks for the ascii representation
665  //of star genetive names, so stars are identified that way in the user log.
666  SkyObject *o = skyComposite()->findByName(name);
667  if ( !o ) {
668  kWarning() << name << " not found" ;
669  } else {
670  o->userLog() = data;
671  }
672 
673  } // end while
674  file.close();
675  return true;
676 }
677 
678 bool KStarsData::readADVTreeData()
679 {
680  QFile file;
681  QString Interface;
682  QString Name, Link, subName;
683 
684  if (!KSUtils::openDataFile(file, "advinterface.dat"))
685  return false;
686 
687  QTextStream stream(&file);
688  QString Line;
689 
690  while (!stream.atEnd())
691  {
692  int Type, interfaceIndex;
693 
694  Line = stream.readLine();
695 
696  if (Line.startsWith(QLatin1String("[KSLABEL]")))
697  {
698  Name = Line.mid(9);
699  Type = 0;
700  }
701  else if (Line.startsWith(QLatin1String("[END]")))
702  Type = 1;
703  else if (Line.startsWith(QLatin1String("[KSINTERFACE]")))
704  {
705  Interface = Line.mid(13);
706  continue;
707  }
708 
709  else
710  {
711  int idx = Line.indexOf(':');
712  Name = Line.left(idx);
713  Link = Line.mid(idx + 1);
714 
715  // Link is empty, using Interface instead
716  if (Link.isEmpty())
717  {
718  Link = Interface;
719  subName = Name;
720  interfaceIndex = Link.indexOf(QLatin1String("KSINTERFACE"));
721  Link.remove(interfaceIndex, 11);
722  Link = Link.insert(interfaceIndex, subName.replace(' ', '+'));
723 
724  }
725 
726  Type = 2;
727  }
728 
729  ADVTreeData *ADVData = new ADVTreeData;
730 
731  ADVData->Name = Name;
732  ADVData->Link = Link;
733  ADVData->Type = Type;
734 
735  ADVtreeList.append(ADVData);
736  }
737 
738  return true;
739 }
740 
741 //There's a lot of code duplication here, but it's not avoidable because
742 //this function is only called from main.cpp when the user is using
743 //"dump" mode to produce an image from the command line. In this mode,
744 //there is no KStars object, so none of the DBus functions can be called
745 //directly.
746 bool KStarsData::executeScript( const QString &scriptname, SkyMap *map ) {
747  int cmdCount(0);
748 
749  QFile f( scriptname );
750  if ( !f.open( QIODevice::ReadOnly) ) {
751  kDebug() << i18n( "Could not open file %1", f.fileName() );
752  return false;
753  }
754 
755  QTextStream istream(&f);
756  while ( ! istream.atEnd() ) {
757  QString line = istream.readLine();
758  line.remove( "string:" );
759  line.remove( "int:" );
760  line.remove( "double:" );
761  line.remove( "bool:" );
762 
763  //find a dbus line and extract the function name and its arguments
764  //The function name starts after the last occurrence of "org.kde.kstars."
765  //or perhaps "org.kde.kstars.SimClock.".
766  if ( line.startsWith(QString("dbus-send")) ) {
767  QString funcprefix = "org.kde.kstars.SimClock.";
768  int i = line.lastIndexOf( funcprefix );
769  if ( i >= 0 ) {
770  i += funcprefix.length();
771  } else {
772  funcprefix = "org.kde.kstars.";
773  i = line.lastIndexOf( funcprefix );
774  if ( i >= 0 ) {
775  i += funcprefix.length();
776  }
777  }
778  if ( i < 0 ) {
779  kWarning() << "Could not parse line: " << line;
780  return false;
781  }
782 
783  QStringList fn = line.mid(i).split( ' ' );
784 
785  //DEBUG
786  kDebug() << fn << endl;
787 
788  if ( fn[0] == "lookTowards" && fn.size() >= 2 ) {
789  double az(-1.0);
790  QString arg = fn[1].toLower();
791  if ( arg == "n" || arg == "north" ) az = 0.0;
792  if ( arg == "ne" || arg == "northeast" ) az = 45.0;
793  if ( arg == "e" || arg == "east" ) az = 90.0;
794  if ( arg == "se" || arg == "southeast" ) az = 135.0;
795  if ( arg == "s" || arg == "south" ) az = 180.0;
796  if ( arg == "sw" || arg == "southwest" ) az = 225.0;
797  if ( arg == "w" || arg == "west" ) az = 270.0;
798  if ( arg == "nw" || arg == "northwest" ) az = 335.0;
799  if ( az >= 0.0 ) {
800  map->setFocusAltAz( dms(90.0), map->focus()->az() );
801  map->focus()->HorizontalToEquatorial( &LST, geo()->lat() );
802  map->setDestination( *map->focus() );
803  cmdCount++;
804  }
805 
806  if ( arg == "z" || arg == "zenith" ) {
807  map->setFocusAltAz( dms(90.0), map->focus()->az() );
808  map->focus()->HorizontalToEquatorial( &LST, geo()->lat() );
809  map->setDestination( *map->focus() );
810  cmdCount++;
811  }
812 
813  //try a named object. The name is everything after fn[0],
814  //concatenated with spaces.
815  fn.removeAll( fn.first() );
816  QString objname = fn.join( " " );
817  SkyObject *target = objectNamed( objname );
818  if ( target ) {
819  map->setFocus( target );
820  map->focus()->EquatorialToHorizontal( &LST, geo()->lat() );
821  map->setDestination( *map->focus() );
822  cmdCount++;
823  }
824 
825  } else if ( fn[0] == "setRaDec" && fn.size() == 3 ) {
826  bool ok( false );
827  dms r(0.0), d(0.0);
828 
829  ok = r.setFromString( fn[1], false ); //assume angle in hours
830  if ( ok ) ok = d.setFromString( fn[2], true ); //assume angle in degrees
831  if ( ok ) {
832  map->setFocus( r, d );
833  map->focus()->EquatorialToHorizontal( &LST, geo()->lat() );
834  cmdCount++;
835  }
836 
837  } else if ( fn[0] == "setAltAz" && fn.size() == 3 ) {
838  bool ok( false );
839  dms az(0.0), alt(0.0);
840 
841  ok = alt.setFromString( fn[1] );
842  if ( ok ) ok = az.setFromString( fn[2] );
843  if ( ok ) {
844  map->setFocusAltAz( alt, az );
845  map->focus()->HorizontalToEquatorial( &LST, geo()->lat() );
846  cmdCount++;
847  }
848 
849  } else if ( fn[0] == "loadColorScheme" ) {
850  fn.removeAll( fn.first() );
851  QString csName = fn.join(" ").remove( '\"' );
852  kDebug() << "Color scheme: " << csName << endl;
853 
854  QString filename = csName.toLower().trimmed();
855  bool ok( false );
856 
857  //Parse default names which don't follow the regular file-naming scheme
858  if ( csName == i18nc("use default color scheme", "Default Colors") ) filename = "classic.colors";
859  if ( csName == i18nc("use 'star chart' color scheme", "Star Chart") ) filename = "chart.colors";
860  if ( csName == i18nc("use 'night vision' color scheme", "Night Vision") ) filename = "night.colors";
861 
862  //Try the filename if it ends with ".colors"
863  if ( filename.endsWith( QLatin1String( ".colors" ) ) )
864  ok = colorScheme()->load( filename );
865 
866  //If that didn't work, try assuming that 'name' is the color scheme name
867  //convert it to a filename exactly as ColorScheme::save() does
868  if ( ! ok ) {
869  if ( !filename.isEmpty() ) {
870  for( int i=0; i<filename.length(); ++i)
871  if ( filename.at(i)==' ' ) filename.replace( i, 1, "-" );
872 
873  filename = filename.append( ".colors" );
874  ok = colorScheme()->load( filename );
875  }
876 
877  if ( ! ok ) kDebug() << i18n( "Unable to load color scheme named %1. Also tried %2.", csName, filename ) << endl;
878  }
879 
880  } else if ( fn[0] == "zoom" && fn.size() == 2 ) {
881  bool ok(false);
882  double z = fn[1].toDouble(&ok);
883  if ( ok ) {
884  if ( z > MAXZOOM ) z = MAXZOOM;
885  if ( z < MINZOOM ) z = MINZOOM;
886  Options::setZoomFactor( z );
887  cmdCount++;
888  }
889 
890  } else if ( fn[0] == "zoomIn" ) {
891  if ( Options::zoomFactor() < MAXZOOM ) {
892  Options::setZoomFactor( Options::zoomFactor() * DZOOM );
893  cmdCount++;
894  }
895  } else if ( fn[0] == "zoomOut" ) {
896  if ( Options::zoomFactor() > MINZOOM ) {
897  Options::setZoomFactor( Options::zoomFactor() / DZOOM );
898  cmdCount++;
899  }
900  } else if ( fn[0] == "defaultZoom" ) {
901  Options::setZoomFactor( DEFAULTZOOM );
902  cmdCount++;
903  } else if ( fn[0] == "setLocalTime" && fn.size() == 7 ) {
904  bool ok(false);
905  // min is a macro - use mnt
906  int yr(0), mth(0), day(0) ,hr(0), mnt(0), sec(0);
907  yr = fn[1].toInt(&ok);
908  if ( ok ) mth = fn[2].toInt(&ok);
909  if ( ok ) day = fn[3].toInt(&ok);
910  if ( ok ) hr = fn[4].toInt(&ok);
911  if ( ok ) mnt = fn[5].toInt(&ok);
912  if ( ok ) sec = fn[6].toInt(&ok);
913  if ( ok ) {
914  changeDateTime( geo()->LTtoUT( KStarsDateTime( QDate(yr, mth, day), QTime(hr,mnt,sec) ) ) );
915  cmdCount++;
916  } else {
917  kWarning() << ki18n( "Could not set time: %1 / %2 / %3 ; %4:%5:%6" )
918  .subs( day ).subs( mth ).subs( yr )
919  .subs( hr ).subs( mnt ).subs( sec ).toString() << endl;
920  }
921  } else if ( fn[0] == "changeViewOption" && fn.size() == 3 ) {
922  bool bOk(false), dOk(false);
923 
924  //parse bool value
925  bool bVal(false);
926  if ( fn[2].toLower() == "true" ) { bOk = true; bVal = true; }
927  if ( fn[2].toLower() == "false" ) { bOk = true; bVal = false; }
928  if ( fn[2] == "1" ) { bOk = true; bVal = true; }
929  if ( fn[2] == "0" ) { bOk = true; bVal = false; }
930 
931  //parse double value
932  double dVal = fn[2].toDouble( &dOk );
933 
934  // FIXME: REGRESSION
935 // if ( fn[1] == "FOVName" ) { Options::setFOVName( fn[2] ); cmdCount++; }
936 // if ( fn[1] == "FOVSizeX" && dOk ) { Options::setFOVSizeX( (float)dVal ); cmdCount++; }
937 // if ( fn[1] == "FOVSizeY" && dOk ) { Options::setFOVSizeY( (float)dVal ); cmdCount++; }
938 // if ( fn[1] == "FOVShape" && nOk ) { Options::setFOVShape( nVal ); cmdCount++; }
939 // if ( fn[1] == "FOVColor" ) { Options::setFOVColor( fn[2] ); cmdCount++; }
940  if ( fn[1] == "ShowStars" && bOk ) { Options::setShowStars( bVal ); cmdCount++; }
941  if ( fn[1] == "ShowMessier" && bOk ) { Options::setShowMessier( bVal ); cmdCount++; }
942  if ( fn[1] == "ShowMessierImages" && bOk ) { Options::setShowMessierImages( bVal ); cmdCount++; }
943  if ( fn[1] == "ShowCLines" && bOk ) { Options::setShowCLines( bVal ); cmdCount++; }
944  if ( fn[1] == "ShowCNames" && bOk ) { Options::setShowCNames( bVal ); cmdCount++; }
945  if ( fn[1] == "ShowNGC" && bOk ) { Options::setShowNGC( bVal ); cmdCount++; }
946  if ( fn[1] == "ShowIC" && bOk ) { Options::setShowIC( bVal ); cmdCount++; }
947  if ( fn[1] == "ShowMilkyWay" && bOk ) { Options::setShowMilkyWay( bVal ); cmdCount++; }
948  if ( fn[1] == "ShowEquatorialGrid" && bOk ) { Options::setShowEquatorialGrid( bVal ); cmdCount++; }
949  if ( fn[1] == "ShowHorizontalGrid" && bOk ) { Options::setShowHorizontalGrid( bVal ); cmdCount++; }
950  if ( fn[1] == "ShowEquator" && bOk ) { Options::setShowEquator( bVal ); cmdCount++; }
951  if ( fn[1] == "ShowEcliptic" && bOk ) { Options::setShowEcliptic( bVal ); cmdCount++; }
952  if ( fn[1] == "ShowHorizon" && bOk ) { Options::setShowHorizon( bVal ); cmdCount++; }
953  if ( fn[1] == "ShowGround" && bOk ) { Options::setShowGround( bVal ); cmdCount++; }
954  if ( fn[1] == "ShowSun" && bOk ) { Options::setShowSun( bVal ); cmdCount++; }
955  if ( fn[1] == "ShowMoon" && bOk ) { Options::setShowMoon( bVal ); cmdCount++; }
956  if ( fn[1] == "ShowMercury" && bOk ) { Options::setShowMercury( bVal ); cmdCount++; }
957  if ( fn[1] == "ShowVenus" && bOk ) { Options::setShowVenus( bVal ); cmdCount++; }
958  if ( fn[1] == "ShowMars" && bOk ) { Options::setShowMars( bVal ); cmdCount++; }
959  if ( fn[1] == "ShowJupiter" && bOk ) { Options::setShowJupiter( bVal ); cmdCount++; }
960  if ( fn[1] == "ShowSaturn" && bOk ) { Options::setShowSaturn( bVal ); cmdCount++; }
961  if ( fn[1] == "ShowUranus" && bOk ) { Options::setShowUranus( bVal ); cmdCount++; }
962  if ( fn[1] == "ShowNeptune" && bOk ) { Options::setShowNeptune( bVal ); cmdCount++; }
963  if ( fn[1] == "ShowPluto" && bOk ) { Options::setShowPluto( bVal ); cmdCount++; }
964  if ( fn[1] == "ShowAsteroids" && bOk ) { Options::setShowAsteroids( bVal ); cmdCount++; }
965  if ( fn[1] == "ShowComets" && bOk ) { Options::setShowComets( bVal ); cmdCount++; }
966  if ( fn[1] == "ShowSolarSystem" && bOk ) { Options::setShowSolarSystem( bVal ); cmdCount++; }
967  if ( fn[1] == "ShowDeepSky" && bOk ) { Options::setShowDeepSky( bVal ); cmdCount++; }
968  if ( fn[1] == "ShowSupernovae" && bOk ) { Options::setShowSupernovae( bVal ); cmdCount++; }
969  if ( fn[1] == "ShowStarNames" && bOk ) { Options::setShowStarNames( bVal ); cmdCount++; }
970  if ( fn[1] == "ShowStarMagnitudes" && bOk ) { Options::setShowStarMagnitudes( bVal ); cmdCount++; }
971  if ( fn[1] == "ShowAsteroidNames" && bOk ) { Options::setShowAsteroidNames( bVal ); cmdCount++; }
972  if ( fn[1] == "ShowCometNames" && bOk ) { Options::setShowCometNames( bVal ); cmdCount++; }
973  if ( fn[1] == "ShowPlanetNames" && bOk ) { Options::setShowPlanetNames( bVal ); cmdCount++; }
974  if ( fn[1] == "ShowPlanetImages" && bOk ) { Options::setShowPlanetImages( bVal ); cmdCount++; }
975 
976  if ( fn[1] == "UseAltAz" && bOk ) { Options::setUseAltAz( bVal ); cmdCount++; }
977  if ( fn[1] == "UseRefraction" && bOk ) { Options::setUseRefraction( bVal ); cmdCount++; }
978  if ( fn[1] == "UseAutoLabel" && bOk ) { Options::setUseAutoLabel( bVal ); cmdCount++; }
979  if ( fn[1] == "UseAutoTrail" && bOk ) { Options::setUseAutoTrail( bVal ); cmdCount++; }
980  if ( fn[1] == "UseAnimatedSlewing" && bOk ) { Options::setUseAnimatedSlewing( bVal ); cmdCount++; }
981  if ( fn[1] == "FadePlanetTrails" && bOk ) { Options::setFadePlanetTrails( bVal ); cmdCount++; }
982  if ( fn[1] == "SlewTimeScale" && dOk ) { Options::setSlewTimeScale( dVal ); cmdCount++; }
983  if ( fn[1] == "ZoomFactor" && dOk ) { Options::setZoomFactor( dVal ); cmdCount++; }
984  // if ( fn[1] == "MagLimitDrawStar" && dOk ) { Options::setMagLimitDrawStar( dVal ); cmdCount++; }
985  if ( fn[1] == "StarDensity" && dOk ) { Options::setStarDensity( dVal ); cmdCount++; }
986  // if ( fn[1] == "MagLimitDrawStarZoomOut" && dOk ) { Options::setMagLimitDrawStarZoomOut( dVal ); cmdCount++; }
987  if ( fn[1] == "MagLimitDrawDeepSky" && dOk ) { Options::setMagLimitDrawDeepSky( dVal ); cmdCount++; }
988  if ( fn[1] == "MagLimitDrawDeepSkyZoomOut" && dOk ) { Options::setMagLimitDrawDeepSkyZoomOut( dVal ); cmdCount++; }
989  if ( fn[1] == "StarLabelDensity" && dOk ) { Options::setStarLabelDensity( dVal ); cmdCount++; }
990  if ( fn[1] == "MagLimitHideStar" && dOk ) { Options::setMagLimitHideStar( dVal ); cmdCount++; }
991  if ( fn[1] == "MagLimitAsteroid" && dOk ) { Options::setMagLimitAsteroid( dVal ); cmdCount++; }
992  if ( fn[1] == "AsteroidLabelDensity" && dOk ) { Options::setAsteroidLabelDensity( dVal ); cmdCount++; }
993  if ( fn[1] == "MaxRadCometName" && dOk ) { Options::setMaxRadCometName( dVal ); cmdCount++; }
994 
995  //these three are a "radio group"
996  if ( fn[1] == "UseLatinConstellationNames" && bOk ) {
997  Options::setUseLatinConstellNames( true );
998  Options::setUseLocalConstellNames( false );
999  Options::setUseAbbrevConstellNames( false );
1000  cmdCount++;
1001  }
1002  if ( fn[1] == "UseLocalConstellationNames" && bOk ) {
1003  Options::setUseLatinConstellNames( false );
1004  Options::setUseLocalConstellNames( true );
1005  Options::setUseAbbrevConstellNames( false );
1006  cmdCount++;
1007  }
1008  if ( fn[1] == "UseAbbrevConstellationNames" && bOk ) {
1009  Options::setUseLatinConstellNames( false );
1010  Options::setUseLocalConstellNames( false );
1011  Options::setUseAbbrevConstellNames( true );
1012  cmdCount++;
1013  }
1014  } else if ( fn[0] == "setGeoLocation" && ( fn.size() == 3 || fn.size() == 4 ) ) {
1015  QString city( fn[1] ), province, country( fn[2] );
1016  province.clear();
1017  if ( fn.size() == 4 ) {
1018  province = fn[2];
1019  country = fn[3];
1020  }
1021 
1022  bool cityFound( false );
1023  foreach ( GeoLocation *loc, geoList ) {
1024  if ( loc->translatedName() == city &&
1025  ( province.isEmpty() || loc->translatedProvince() == province ) &&
1026  loc->translatedCountry() == country ) {
1027 
1028  cityFound = true;
1029  setLocation( *loc );
1030  cmdCount++;
1031  break;
1032  }
1033  }
1034 
1035  if ( !cityFound )
1036  kWarning() << i18n( "Could not set location named %1, %2, %3" , city, province, country) ;
1037  }
1038  }
1039  } //end while
1040 
1041  if ( cmdCount ) return true;
1042  return false;
1043 }
1044 
1045 void KStarsData::syncFOV()
1046 {
1047  visibleFOVs.clear();
1048  // Add visible FOVs
1049  foreach(FOV* fov, availFOVs) {
1050  if( Options::fOVNames().contains( fov->name() ) )
1051  visibleFOVs.append( fov );
1052  }
1053  // Remove unavailable FOVs
1054  QSet<QString> names = QSet<QString>::fromList( Options::fOVNames() );
1055  QSet<QString> all;
1056  foreach(FOV* fov, visibleFOVs) {
1057  all.insert(fov->name());
1058  }
1059  Options::setFOVNames( all.intersect(names).toList() );
1060 }
1061 
1062 #include "kstarsdata.moc"
Options::setShowStarNames
static void setShowStarNames(bool v)
Set Label star names in the sky map?
Definition: Options.h:2205
Options::setFOVNames
static void setFOVNames(const QStringList &v)
Set Name of selected FOV indicators.
Definition: Options.h:970
Options::setShowSupernovae
static void setShowSupernovae(bool v)
Set Draw supernovae in the sky map?
Definition: Options.h:1426
KStarsData::KStarsData
KStarsData()
Constructor.
Definition: kstarsdata.cpp:109
Options::setProvinceName
static void setProvinceName(const QString &v)
Set Province name of geographic location.
Definition: Options.h:818
Options::setShowJupiter
static void setShowJupiter(bool v)
Set Draw Jupiter in the sky map?
Definition: Options.h:2072
KStarsData::objectNamed
SkyObject * objectNamed(const QString &name)
Find object by name.
Definition: kstarsdata.cpp:345
KStarsData::locationNamed
GeoLocation * locationNamed(const QString &city, const QString &province=QString(), const QString &country=QString())
Definition: kstarsdata.cpp:306
Options::setMagLimitAsteroid
static void setMagLimitAsteroid(double v)
Set Faint limit for asteroids.
Definition: Options.h:2540
Options::setStarDensity
static void setStarDensity(int v)
Set Density of stars in the field of view.
Definition: Options.h:2616
SkyMapComposite::updateMoons
virtual void updateMoons(KSNumbers *num)
Delegate moon position updates to the SolarSystemComposite.
Definition: skymapcomposite.cpp:159
KStarsData::clock
SimClock * clock()
Definition: kstarsdata.h:158
Options::setShowMessier
static void setShowMessier(bool v)
Set Draw Messier objects in the sky map?
Definition: Options.h:1825
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
DZOOM
#define DZOOM
Definition: kstarsdata.h:41
FOV
class encapulating a Field-of-View symbol
Definition: fov.h:32
SkyMapComposite::updatePlanets
virtual void updatePlanets(KSNumbers *num)
Delegate planet position updates to the SolarSystemComposite.
Definition: skymapcomposite.cpp:154
GeoLocation::translatedName
QString translatedName() const
Definition: geolocation.cpp:78
SkyPoint::az
const dms & az() const
Definition: skypoint.h:177
Options::setShowPlanetNames
static void setShowPlanetNames(bool v)
Set Label planet names in the sky map?
Definition: Options.h:1958
SimClock::isManualMode
bool isManualMode() const
Manual Mode is a new (04/2002) addition to the SimClock.
Definition: simclock.h:72
Options::setLongitude
static void setLongitude(double v)
Set Geographic Longitude, in degrees.
Definition: Options.h:856
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
detaildialog.h
KStarsData::progressText
void progressText(const QString &)
Signal that specifies the text that should be drawn in the KStarsSplash window.
skyobject.h
Options::setFadePlanetTrails
static void setFadePlanetTrails(bool v)
Set Fade planet trails to background color?
Definition: Options.h:989
KStarsData::setLocationFromOptions
void setLocationFromOptions()
Set the GeoLocation according to the values stored in the configuration file.
Definition: kstarsdata.cpp:317
SkyMap::setDestination
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition: skymap.cpp:812
Options::setLatitude
static void setLatitude(double v)
Set Geographic Latitude, in degrees.
Definition: Options.h:875
Options::timeZone
static double timeZone()
Get Time Zone offset of geographic location, in hours.
Definition: Options.h:923
SkyMap::setFocus
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Definition: skymap.cpp:789
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
Options::setMagLimitDrawDeepSkyZoomOut
static void setMagLimitDrawDeepSkyZoomOut(double v)
Set Faint limit for deep-sky objects when zoomed out.
Definition: Options.h:2597
GeoLocation::lng
const dms * lng() const
Definition: geolocation.h:76
Options::setShowPluto
static void setShowPluto(bool v)
Set Draw Pluto in the sky map?
Definition: Options.h:2148
Options::setShowComets
static void setShowComets(bool v)
Set Draw comets in the sky map?
Definition: Options.h:1388
KStarsData::initialize
bool initialize()
Initialize KStarsData while running splash screen.
Definition: kstarsdata.cpp:138
KStarsData::~KStarsData
virtual ~KStarsData()
Destructor.
Definition: kstarsdata.cpp:126
Options::dST
static QString dST()
Get Two-letter code for daylight savings time rule used by geographic location.
Definition: Options.h:942
KStarsData::executeScript
bool executeScript(const QString &name, SkyMap *map)
Execute a script.
Definition: kstarsdata.cpp:746
SkyMap::forceUpdate
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition: skymap.cpp:985
KStarsData::catalogdb
CatalogDB * catalogdb()
Definition: kstarsdata.h:155
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
KStarsData::setFullTimeUpdate
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets...
Definition: kstarsdata.cpp:260
Options::setShowUranus
static void setShowUranus(bool v)
Set Draw Uranus in the sky map?
Definition: Options.h:2110
KStarsData::setTimeDirection
void setTimeDirection(float scale)
Sets the direction of time and stores it in bool TimeRunForwards.
Definition: kstarsdata.cpp:302
GeoLocation::tzrule
TimeZoneRule * tzrule()
Definition: geolocation.h:124
KSUserDB::Initialize
bool Initialize()
Initialize KStarsDB while running splash screen.
Definition: ksuserdb.cpp:32
ADVTreeData::Type
int Type
Definition: detaildialog.h:62
Options::updateSupernovaeOnStartup
static bool updateSupernovaeOnStartup()
Get Update recent supernovae list on startup?
Definition: Options.h:1531
TimeZoneRule
This class provides the information needed to determine whether Daylight Savings Time (DST; a...
Definition: timezonerule.h:56
Options::longitude
static double longitude()
Get Geographic Longitude, in degrees.
Definition: Options.h:866
GeoLocation::setLat
void setLat(dms l)
Set latitude according to dms argument.
Definition: geolocation.h:136
SkyObject::InfoList
QStringList & InfoList()
Definition: skyobject.h:309
fov.h
MAXZOOM
#define MAXZOOM
Definition: kstarsdata.h:39
Options::setUseAutoTrail
static void setUseAutoTrail(bool v)
Set Automatically add trail to centered solar system body?
Definition: Options.h:2414
KSUtils::openDataFile
bool openDataFile(QFile &file, const QString &filename)
Attempt to open the data file named filename, using the QFile object "file".
dms.h
GeoLocation::translatedProvince
QString translatedProvince() const
Definition: geolocation.cpp:88
GeoLocation::height
double height() const
Definition: geolocation.h:82
NaN::f
const float f
Definition: nan.h:36
Options::setShowCLines
static void setShowCLines(bool v)
Set Draw constellation lines in the sky map?
Definition: Options.h:1578
KStarsData::Create
static KStarsData * Create()
Definition: kstarsdata.cpp:93
Options::fOVNames
static QStringList fOVNames()
Get Name of selected FOV indicators.
Definition: Options.h:980
Options::setStarLabelDensity
static void setStarLabelDensity(double v)
Set Relative density for star name labels and/or magnitudes.
Definition: Options.h:2654
Options::setShowCNames
static void setShowCNames(bool v)
Set Draw constellation names in the sky map?
Definition: Options.h:1597
Options::setShowAsteroidNames
static void setShowAsteroidNames(bool v)
Set Label asteroid names in the sky map?
Definition: Options.h:1369
timezonerule.h
Options::setUseAbbrevConstellNames
static void setUseAbbrevConstellNames(bool v)
Set Use abbreviated constellation names?
Definition: Options.h:2319
TimeZoneRule::nextDSTChange
KStarsDateTime nextDSTChange()
Definition: timezonerule.h:103
Options::setUseLocalConstellNames
static void setUseLocalConstellNames(bool v)
Set Use localized constellation names?
Definition: Options.h:2357
skymapcomposite.h
Options::setShowMilkyWay
static void setShowMilkyWay(bool v)
Set Draw Milky Way contour in the sky map?
Definition: Options.h:1882
KStarsData::changeDateTime
void changeDateTime(const KStarsDateTime &newDate)
change the current simulation date/time to the KStarsDateTime argument.
Definition: kstarsdata.cpp:272
SkyMap::focus
SkyPoint * focus()
Retrieve the Focus point; the position on the sky at the center of the skymap.
Definition: skymap.h:120
GeoLocation
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
Definition: geolocation.h:39
Options::setShowHorizontalGrid
static void setShowHorizontalGrid(bool v)
Set Draw horizontal coordinate grid in the sky map?
Definition: Options.h:1711
SupernovaeComponent::slotTriggerDataFileUpdate
void slotTriggerDataFileUpdate()
This initiates updating of the data file by using supernovae_updates_parser.py.
Definition: supernovaecomponent.cpp:228
Options::setCountryName
static void setCountryName(const QString &v)
Set Country name of geographic location.
Definition: Options.h:837
Options::setShowCometNames
static void setShowCometNames(bool v)
Set Label comet names in the sky map?
Definition: Options.h:1407
SkyObject::ImageList
QStringList & ImageList()
Definition: skyobject.h:299
MINZOOM
#define MINZOOM
Definition: kstarsdata.h:38
GeoLocation::GSTtoLST
dms GSTtoLST(const dms &gst) const
Definition: geolocation.h:230
Options::setMagLimitDrawDeepSky
static void setMagLimitDrawDeepSky(double v)
Set Faint limit for deep-sky objects.
Definition: Options.h:2578
Options::setSlewTimeScale
static void setSlewTimeScale(double v)
Set Minimum timescale for forced-slewing mode.
Definition: Options.h:2262
KStarsData::syncUpdateIDs
void syncUpdateIDs()
Definition: kstarsdata.cpp:245
Options::setShowIC
static void setShowIC(bool v)
Set Draw IC objects in the sky map?
Definition: Options.h:1787
KStarsDateTime::djd
long double djd() const
Definition: kstarsdatetime.h:145
SkyMapComposite::supernovaeComponent
SupernovaeComponent * supernovaeComponent()
Definition: skymapcomposite.cpp:618
skymap.h
DEFAULTZOOM
#define DEFAULTZOOM
Definition: kstarsdata.h:40
i18nc
i18nc("string from libindi, used in the config dialog","100x")
SkyMap::setFocusAltAz
void setFocusAltAz(const dms &alt, const dms &az)
sets the focus point of the sky map, using its alt/az coordinates
Definition: skymap.cpp:801
SkyMapComposite
SkyMapComposite is the root object in the object hierarchy of the sky map.
Definition: skymapcomposite.h:65
SkyPoint::HorizontalToEquatorial
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:102
Options::setShowVenus
static void setShowVenus(bool v)
Set Draw Venus in the sky map?
Definition: Options.h:2034
Options::provinceName
static QString provinceName()
Get Province name of geographic location.
Definition: Options.h:828
KStarsDateTime
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Definition: kstarsdatetime.h:45
Options::setShowSaturn
static void setShowSaturn(bool v)
Set Draw Saturn in the sky map?
Definition: Options.h:2091
ksnumbers.h
KStarsData::skyComposite
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:146
Options::setUseAltAz
static void setUseAltAz(bool v)
Set Use horizontal coordinate system?
Definition: Options.h:2376
ColorScheme::load
bool load(const QString &filename)
Load a color scheme from a *.colors file filename the filename of the color scheme to be loaded...
Definition: colorscheme.cpp:130
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
simclock.h
Options::setShowPlanetImages
static void setShowPlanetImages(bool v)
Set Draw planets as images in the sky map?
Definition: Options.h:1939
Options::setShowEcliptic
static void setShowEcliptic(bool v)
Set Draw ecliptic line in the sky map?
Definition: Options.h:1635
KDateTime
Options::setTimeZone
static void setTimeZone(double v)
Set Time Zone offset of geographic location, in hours.
Definition: Options.h:913
Options::cityName
static QString cityName()
Get City name of geographic location.
Definition: Options.h:809
Options::setShowMoon
static void setShowMoon(bool v)
Set Draw Moon in the sky map?
Definition: Options.h:1996
Options::setCityName
static void setCityName(const QString &v)
Set City name of geographic location.
Definition: Options.h:799
Options::setUseAnimatedSlewing
static void setUseAnimatedSlewing(bool v)
Set Use animated slewing effects when changing focus position?
Definition: Options.h:951
SkyPoint::EquatorialToHorizontal
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:55
Options::setShowStarMagnitudes
static void setShowStarMagnitudes(bool v)
Set Label star magnitudes in the sky map?
Definition: Options.h:2186
GeoLocation::province
QString province() const
Definition: geolocation.h:103
TimeZoneRule::reset_with_ltime
void reset_with_ltime(KStarsDateTime &ltime, const double TZoffset, const bool time_runs_forward, const bool automaticDSTchange=false)
Recalculate next dst change and if DST is active by a given local time with timezone offset and time ...
Definition: timezonerule.cpp:301
Options::setZoomFactor
static void setZoomFactor(double v)
Set Zoom Factor, in pixels per radian.
Definition: Options.h:2509
KStarsData::syncFOV
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
Definition: kstarsdata.cpp:1045
Options.h
GeoLocation::name
QString name() const
Definition: geolocation.h:97
Options::setUseRefraction
static void setUseRefraction(bool v)
Set Correct positions for atmospheric refraction?
Definition: Options.h:2452
QTextStream
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
SkyObject::InfoTitle
QStringList & InfoTitle()
Definition: skyobject.h:314
CatalogDB::Initialize
bool Initialize()
Initializes the database and sets up pointers to Catalog DB Performs the following actions: ...
Definition: catalogdb.cpp:22
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
GeoLocation::TZ0
double TZ0() const
Definition: geolocation.h:118
ksfilereader.h
KSFileReader
Definition: ksfilereader.h:65
ADVTreeData
Definition: detaildialog.h:58
SkyObject::type
int type(void) const
Definition: skyobject.h:164
NaN::d
const double d
Definition: nan.h:35
KStarsData::setSnapNextFocus
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition: kstarsdata.h:194
Options::setUseAutoLabel
static void setUseAutoLabel(bool v)
Set Automatically label focused object?
Definition: Options.h:2395
J2000
#define J2000
Definition: kstarsdatetime.h:21
Options::latitude
static double latitude()
Get Geographic Latitude, in degrees.
Definition: Options.h:885
Options::zoomFactor
static double zoomFactor()
Get Zoom Factor, in pixels per radian.
Definition: Options.h:2531
Options::countryName
static QString countryName()
Get Country name of geographic location.
Definition: Options.h:847
KStarsData::setNextDSTChange
void setNextDSTChange(const KStarsDateTime &dt)
Set the NextDSTChange member.
Definition: kstarsdata.h:106
Options::setShowMessierImages
static void setShowMessierImages(bool v)
Set Draw Messier object images in the sky map?
Definition: Options.h:1844
Options::setShowMercury
static void setShowMercury(bool v)
Set Draw Mercury in the sky map?
Definition: Options.h:2015
SkyMap
This is the canvas on which the sky is painted.
Definition: skymap.h:72
Options::setShowAsteroids
static void setShowAsteroids(bool v)
Set Draw asteroids in the sky map?
Definition: Options.h:1350
Options::setShowEquator
static void setShowEquator(bool v)
Set Draw equator line in the sky map?
Definition: Options.h:1654
Options::setShowSun
static void setShowSun(bool v)
Set Draw Sun in the sky map?
Definition: Options.h:1977
Options::setElevation
static void setElevation(double v)
Set Elevation above sea level of geographic location, in meters.
Definition: Options.h:894
SkyMapComposite::findByName
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument...
Definition: skymapcomposite.cpp:426
ADVTreeData::Link
QString Link
Definition: detaildialog.h:61
Options::setShowNGC
static void setShowNGC(bool v)
Set Draw NGC objects in the sky map?
Definition: Options.h:1806
Options::setDST
static void setDST(const QString &v)
Set Two-letter code for daylight savings time rule used by geographic location.
Definition: Options.h:932
KStarsData::updateTime
void updateTime(GeoLocation *geo, SkyMap *skymap, const bool automaticDSTchange=true)
Update the Simulation Clock.
Definition: kstarsdata.cpp:189
Options::setAsteroidLabelDensity
static void setAsteroidLabelDensity(double v)
Set Label density for asteroid names.
Definition: Options.h:2559
Options::setShowHorizon
static void setShowHorizon(bool v)
Set Draw horizon line in the sky map?
Definition: Options.h:1749
KStarsData::isTimeRunningForward
bool isTimeRunningForward()
Returns true if time is running forward else false.
Definition: kstarsdata.h:111
FOV::name
QString name() const
Definition: fov.h:46
SkyMap::updateFocus
void updateFocus()
Update the focus position according to current options.
Definition: skymap.cpp:833
KStarsData::geoChanged
void geoChanged()
Emitted when geo location changed.
ADVTreeData::Name
QString Name
Definition: detaildialog.h:60
GeoLocation::UTtoLT
KStarsDateTime UTtoLT(const KStarsDateTime &ut) const
Definition: geolocation.h:233
kstarsdata.h
KStarsData::ut
const KStarsDateTime & ut() const
Definition: kstarsdata.h:140
OAL::Log
Definition: log.h:41
Options::setShowGround
static void setShowGround(bool v)
Set Draw opaque ground in the sky map?
Definition: Options.h:1730
Options::setShowMars
static void setShowMars(bool v)
Set Draw Mars in the sky map?
Definition: Options.h:2053
Options::elevation
static double elevation()
Get Elevation above sea level of geographic location, in meters.
Definition: Options.h:904
Options::setMagLimitHideStar
static void setMagLimitHideStar(double v)
Set Faint limit for stars when slewing.
Definition: Options.h:2635
ksutils.h
GeoLocation::translatedCountry
QString translatedCountry() const
Definition: geolocation.cpp:92
SkyObject
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
Definition: skyobject.h:46
SkyMapComposite::update
virtual void update(KSNumbers *num=0)
Delegate update-position requests to all sub components.
Definition: skymapcomposite.cpp:117
Options::setMaxRadCometName
static void setMaxRadCometName(double v)
Set Maximum distance from Sun for labeling comets, in AU.
Definition: Options.h:2711
Options::setShowDeepSky
static void setShowDeepSky(bool v)
Set Draw "deep sky" objects in the sky map?
Definition: Options.h:1616
TimeZoneRule::isEmptyRule
bool isEmptyRule()
Definition: timezonerule.h:79
SkyObject::ImageTitle
QStringList & ImageTitle()
Definition: skyobject.h:304
Options::setShowNeptune
static void setShowNeptune(bool v)
Set Draw Neptune in the sky map?
Definition: Options.h:2129
Options::setUseLatinConstellNames
static void setUseLatinConstellNames(bool v)
Set Use Latin constellation names?
Definition: Options.h:2338
KStarsData::incUpdateID
unsigned int incUpdateID()
Definition: kstarsdata.cpp:253
Options::setShowStars
static void setShowStars(bool v)
Set Draw stars in the sky map?
Definition: Options.h:2167
SkyObject::userLog
QString & userLog()
Definition: skyobject.h:319
Options::setShowSolarSystem
static void setShowSolarSystem(bool v)
Set Meta-option for all planets in the sky map.
Definition: Options.h:1920
GeoLocation::country
QString country() const
Definition: geolocation.h:109
TimeZoneRule::equals
bool equals(TimeZoneRule *r)
Definition: timezonerule.cpp:406
Options::setShowEquatorialGrid
static void setShowEquatorialGrid(bool v)
Set Draw equatorial coordinate grid in the sky map?
Definition: Options.h:1692
SimClock::setUTC
Q_SCRIPTABLE Q_NOREPLY void setUTC(const KStarsDateTime &newtime)
DBUS function to set the time of the SimClock.
Definition: simclock.cpp:136
KStarsData::setLocation
void setLocation(const GeoLocation &l)
Set the GeoLocation according to the argument.
Definition: kstarsdata.cpp:323
supernovaecomponent.h
KStarsData::syncLST
void syncLST()
Sync the LST with the simulation clock.
Definition: kstarsdata.cpp:268
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal