• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

kstars.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kstars.cpp  -  K Desktop Planetarium
00003                              -------------------
00004     begin                : Mon Feb  5 01:11:45 PST 2001
00005     copyright            : (C) 2001 by Jason Harris
00006     email                : jharris@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 //JH 11.06.2002: replaced infoPanel with infoBoxes
00018 //JH 24.08.2001: reorganized infoPanel
00019 //JH 25.08.2001: added toolbar, converted menu items to KAction objects
00020 //JH 25.08.2001: main window now resizable, window size saved in config file
00021 
00022 
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 //#include <iostream.h>
00026 #include <kdebug.h>
00027 #include <kactioncollection.h>
00028 #include <kiconloader.h>
00029 #include <qpalette.h>
00030 #include <kstatusbar.h>
00031 
00032 #include "Options.h"
00033 #include "kstars.h"
00034 #include "kstarsdata.h"
00035 #include "kstarssplash.h"
00036 #include "skymap.h"
00037 #include "simclock.h"
00038 #include "finddialog.h"
00039 #include "ksutils.h"
00040 #include "infoboxes.h"
00041 #include "observinglist.h"
00042 #include "imagesequence.h"
00043 #include "toggleaction.h"
00044 
00045 // to remove warnings
00046 #include "indimenu.h"
00047 #include "indidriver.h"
00048 
00049 KStars::KStars( bool doSplash, bool clockrun, const QString &startdate ) :
00050     DCOPObject("KStarsInterface"), KMainWindow(),
00051     skymap(0), centralWidget(0), topLayout(0), viewToolBar(0), TimeStep(0),
00052     actCoordSys(0), colorActionMenu(0), fovActionMenu(0),
00053     AAVSODialog(0), findDialog(0), kns(0), 
00054     indimenu(0), indidriver(0), indiseq(0),
00055     DialogIsObsolete(false), StartClockRunning( clockrun ), StartDateString( startdate )
00056 {
00057     pd = new privatedata(this);
00058 
00059     // we're nowhere near ready to take dcop calls
00060     kapp->dcopClient()->suspend();
00061 
00062     if ( doSplash ) {
00063         pd->kstarsData = new KStarsData();
00064         QObject::connect(pd->kstarsData, SIGNAL( initFinished(bool) ),
00065                 this, SLOT( datainitFinished(bool) ) );
00066 
00067         pd->splash = new KStarsSplash(0, "Splash");
00068         QObject::connect(pd->splash, SIGNAL( closeWindow() ), kapp, SLOT( quit() ) );
00069         QObject::connect(pd->kstarsData, SIGNAL( progressText(QString) ),
00070                 pd->splash, SLOT( setMessage(QString) ));
00071         pd->splash->show();
00072     }
00073 
00074     pd->kstarsData->initialize();
00075 
00076     //Set Geographic Location
00077     pd->kstarsData->setLocationFromOptions();
00078 
00079     //Pause the clock if the user gave the "--paused" arg
00080     if ( ! StartClockRunning ) pd->kstarsData->clock()->stop();
00081     
00082     //set up Dark color scheme for application windows
00083     DarkPalette = QPalette(QColor("red4"), QColor("DarkRed"));
00084     DarkPalette.setColor( QPalette::Normal, QColorGroup::Base, QColor( "black" ) );
00085     DarkPalette.setColor( QPalette::Normal, QColorGroup::Text, QColor( "red2" ) );
00086     DarkPalette.setColor( QPalette::Normal, QColorGroup::Highlight, QColor( "red2" ) );
00087     DarkPalette.setColor( QPalette::Normal, QColorGroup::HighlightedText, QColor( "black" ) );
00088     //store original color scheme
00089     OriginalPalette = QApplication::palette();
00090 
00091     #if ( __GLIBC__ >= 2 &&__GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__))
00092     kdDebug() << "glibc >= 2.1 detected.  Using GNU extension sincos()" << endl;
00093     #else
00094     kdDebug() << "Did not find glibc >= 2.1.  Will use ANSI-compliant sin()/cos() functions." << endl;
00095     #endif
00096 
00097     obsList = new ObservingList( this, this );
00098 }
00099 
00100 KStars::~KStars()
00101 {
00102     //store focus values in Options
00103     Options::setFocusRA( skymap->focus()->ra()->Hours() );
00104     Options::setFocusDec( skymap->focus()->dec()->Degrees() );
00105 
00106     //Store Window geometry in Options object
00107     Options::setWindowWidth( width() );
00108     Options::setWindowHeight( height() );
00109 
00110     //We need to explicitly save the colorscheme data to the config file
00111     data()->colorScheme()->saveToConfig( kapp->config() );
00112 
00113     //synch the config file with the Config object
00114     Options::writeConfig();
00115 
00116     clearCachedFindDialog();
00117 
00118     delete skymap;
00119     delete pd;
00120     delete centralWidget;
00121     delete AAVSODialog;
00122     delete indimenu;
00123     delete indidriver;
00124     delete indiseq;
00125     
00126     skymap = 0;
00127     pd = 0;
00128     centralWidget = 0;
00129     AAVSODialog = 0;
00130     indimenu = 0;
00131     indidriver = 0;
00132     indiseq = 0;
00133 }
00134 
00135 KStars::privatedata::~privatedata() {
00136     delete splash;
00137     delete kstarsData;
00138 
00139     splash = 0;
00140     kstarsData = 0;
00141 }
00142 
00143 void KStars::clearCachedFindDialog() {
00144     if ( findDialog  ) {  // dialog is cached
00148         if ( findDialog->isHidden() ) {
00149             delete findDialog;
00150             findDialog = 0;
00151             DialogIsObsolete = false;
00152         }
00153         else
00154             DialogIsObsolete = true;  // dialog was opened so it could not deleted
00155    }
00156 }
00157 
00158 void KStars::applyConfig() {
00159     if ( Options::isTracking() ) {
00160         actionCollection()->action("track_object")->setText( i18n( "Stop &Tracking" ) );
00161         actionCollection()->action("track_object")->setIconSet( BarIcon( "encrypted" ) );
00162     }
00163 
00164     //Toggle actions
00165     if ( Options::useAltAz() ) ((ToggleAction*)actionCollection()->action("coordsys"))->turnOff();
00166     ((KToggleAction*)actionCollection()->action("show_time_box"))->setChecked( Options::showTimeBox() );
00167     ((KToggleAction*)actionCollection()->action("show_location_box"))->setChecked( Options::showGeoBox() );
00168     ((KToggleAction*)actionCollection()->action("show_focus_box"))->setChecked( Options::showFocusBox() );
00169     ((KToggleAction*)actionCollection()->action("show_mainToolBar"))->setChecked( Options::showMainToolBar() );
00170     ((KToggleAction*)actionCollection()->action("show_viewToolBar"))->setChecked( Options::showViewToolBar() );
00171     ((KToggleAction*)actionCollection()->action("show_statusBar"))->setChecked( Options::showStatusBar() );
00172     ((KToggleAction*)actionCollection()->action("show_sbAzAlt"))->setChecked( Options::showAltAzField() );
00173     ((KToggleAction*)actionCollection()->action("show_sbRADec"))->setChecked( Options::showRADecField() );
00174     ((KToggleAction*)actionCollection()->action("show_stars"))->setChecked( Options::showStars() );
00175     ((KToggleAction*)actionCollection()->action("show_deepsky"))->setChecked( Options::showDeepSky() );
00176     ((KToggleAction*)actionCollection()->action("show_planets"))->setChecked( Options::showPlanets() );
00177     ((KToggleAction*)actionCollection()->action("show_clines"))->setChecked( Options::showCLines() );
00178     ((KToggleAction*)actionCollection()->action("show_cnames"))->setChecked( Options::showCNames() );
00179     ((KToggleAction*)actionCollection()->action("show_cbounds"))->setChecked( Options::showCBounds() );
00180     ((KToggleAction*)actionCollection()->action("show_mw"))->setChecked( Options::showMilkyWay() );
00181     ((KToggleAction*)actionCollection()->action("show_grid"))->setChecked( Options::showGrid() );
00182     ((KToggleAction*)actionCollection()->action("show_horizon"))->setChecked( Options::showGround() );
00183     
00184     //color scheme
00185     pd->kstarsData->colorScheme()->loadFromConfig( kapp->config() );
00186     if ( Options::darkAppColors() ) {
00187         QApplication::setPalette( DarkPalette, true );
00188     } else {
00189         QApplication::setPalette( OriginalPalette, true );
00190     }
00191 
00192     //Infoboxes, toolbars, statusbars
00193     infoBoxes()->setVisible( Options::showInfoBoxes() );
00194     if ( ! Options::showMainToolBar() ) toolBar( "mainToolBar" )->hide();
00195     if ( ! Options::showViewToolBar() ) toolBar( "viewToolBar" )->hide();
00196     if ( ! Options::showAltAzField() ) statusBar()->removeItem(1);
00197     if ( ! Options::showRADecField() ) statusBar()->removeItem(2);
00198 
00199     //Geographic location
00200     setGeoLocation( Options::cityName(), Options::provinceName(), Options::countryName() );
00201 
00202     //Focus
00203     SkyObject *fo = data()->objectNamed( Options::focusObject() );
00204     if ( fo && fo != map()->focusObject() ) {
00205         map()->setClickedObject( fo );
00206         map()->setClickedPoint( fo );
00207         map()->slotCenter();
00208     }
00209 
00210     if ( ! fo ) {
00211         SkyPoint fp( Options::focusRA(), Options::focusDec() );
00212         if ( fp.ra()->Degrees() != map()->focus()->ra()->Degrees() || fp.dec()->Degrees() != map()->focus()->dec()->Degrees() ) {
00213             map()->setClickedPoint( &fp );
00214             map()->slotCenter();
00215         }
00216     }
00217 }
00218 
00219 void KStars::updateTime( const bool automaticDSTchange ) {
00220     dms oldLST( LST()->Degrees() );
00221     // Due to frequently use of this function save data and map pointers for speedup.
00222     // Save options and geo() to a pointer would not speedup because most of time options
00223     // and geo will accessed only one time.
00224     KStarsData *Data = data();
00225     SkyMap *Map = map();
00226 
00227     Data->updateTime( geo(), Map, automaticDSTchange );
00228     if ( infoBoxes()->timeChanged( Data->ut(), Data->lt(), LST() ) )
00229         Map->update();
00230 
00231     //We do this outside of kstarsdata just to get the coordinates
00232     //displayed in the infobox to update every second.
00233 //  if ( !Options::isTracking() && LST()->Degrees() > oldLST.Degrees() ) {
00234 //      int nSec = int( 3600.*( LST()->Hours() - oldLST.Hours() ) );
00235 //      Map->focus()->setRA( Map->focus()->ra()->Hours() + double( nSec )/3600. );
00236 //      if ( Options::useAltAz() ) Map->focus()->EquatorialToHorizontal( LST(), geo()->lat() );
00237 //      Map->showFocusCoords();
00238 //  }
00239 
00240     //If time is accelerated beyond slewTimescale, then the clock's timer is stopped,
00241     //so that it can be ticked manually after each update, in order to make each time
00242     //step exactly equal to the timeScale setting.
00243     //Wrap the call to manualTick() in a singleshot timer so that it doesn't get called until
00244     //the skymap has been completely updated.
00245     if ( Data->clock()->isManualMode() && Data->clock()->isActive() ) {
00246         QTimer::singleShot( 0, Data->clock(), SLOT( manualTick() ) );
00247     }
00248 }
00249 
00250 KStarsData* KStars::data( void ) { return pd->kstarsData; }
00251 
00252 SkyMap* KStars::map( void )  { return skymap; }
00253 
00254 InfoBoxes* KStars::infoBoxes( void )  { return map()->infoBoxes(); }
00255 
00256 GeoLocation* KStars::geo() { return data()->geo(); }
00257 
00258 void KStars::mapGetsFocus() { map()->QWidget::setFocus(); }
00259 
00260 dms* KStars::LST() { return data()->LST; }
00261 
00262 ObservingList* KStars::observingList() { return obsList; }
00263 
00264 #include "kstars.moc"
00265 

kstars

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

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal