00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025
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
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
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
00077 pd->kstarsData->setLocationFromOptions();
00078
00079
00080 if ( ! StartClockRunning ) pd->kstarsData->clock()->stop();
00081
00082
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
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
00103 Options::setFocusRA( skymap->focus()->ra()->Hours() );
00104 Options::setFocusDec( skymap->focus()->dec()->Degrees() );
00105
00106
00107 Options::setWindowWidth( width() );
00108 Options::setWindowHeight( height() );
00109
00110
00111 data()->colorScheme()->saveToConfig( kapp->config() );
00112
00113
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 ) {
00148 if ( findDialog->isHidden() ) {
00149 delete findDialog;
00150 findDialog = 0;
00151 DialogIsObsolete = false;
00152 }
00153 else
00154 DialogIsObsolete = true;
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
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
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
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
00200 setGeoLocation( Options::cityName(), Options::provinceName(), Options::countryName() );
00201
00202
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
00222
00223
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
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
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