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

kstars

kstarsinit.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kstarsinit.cpp  -  K Desktop Planetarium
00003                              -------------------
00004     begin                : Mon Feb 25 2002
00005     copyright            : (C) 2002 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 
00018 #include <qlayout.h>
00019 #include <qfile.h>
00020 #include <qdir.h>
00021 #include <dcopclient.h>
00022 #include <kshortcut.h>
00023 #include <kiconloader.h>
00024 #include <kpopupmenu.h>
00025 #include <kstatusbar.h>
00026 #include <ktip.h>
00027 #include <kmessagebox.h>
00028 #include <kstandarddirs.h>
00029 #include <kdeversion.h>
00030 
00031 #include "Options.h"
00032 #include "kstars.h"
00033 #include "kstarsdata.h"
00034 #include "kstarssplash.h"
00035 #include "skymap.h"
00036 #include "skyobject.h"
00037 #include "ksplanetbase.h"
00038 #include "ksutils.h"
00039 #include "ksnumbers.h"
00040 #include "infoboxes.h"
00041 #include "toggleaction.h"
00042 #include "indimenu.h"
00043 #include "simclock.h"
00044 #include "timestepbox.h"
00045 
00046 //This file contains functions that kstars calls at startup (except constructors).
00047 //These functions are declared in kstars.h
00048 
00049 void KStars::initActions() {
00050 //File Menu:
00051     new KAction(i18n("&New Window"), "window_new", KShortcut( "Ctrl+N"  ),
00052             this, SLOT( newWindow() ), actionCollection(), "new_window");
00053     new KAction(i18n("&Close Window"), "fileclose", KShortcut( "Ctrl+W"  ),
00054             this, SLOT( closeWindow() ), actionCollection(), "close_window");
00055     new KAction( i18n( "&Download Data..." ), "knewstuff", KShortcut( "Ctrl+D" ),
00056             this, SLOT( slotDownload() ), actionCollection(), "get_data" );
00057     new KAction( i18n( "Open FITS..."), "fileopen", KShortcut( "Ctrl+O"), this, SLOT( slotOpenFITS()), actionCollection(), "open_file");
00058     new KAction( i18n( "&Save Sky Image..." ), "fileexport", KShortcut( "Ctrl+I" ),
00059             this, SLOT( slotExportImage() ), actionCollection(), "export_image" );
00060     new KAction( i18n( "&Run Script..." ), "launch", KShortcut( "Ctrl+R" ),
00061             this, SLOT( slotRunScript() ), actionCollection(), "run_script" );
00062     KStdAction::print(this, SLOT( slotPrint() ), actionCollection(), "print" );
00063     KStdAction::quit(this, SLOT( close() ), actionCollection(), "quit" );
00064 
00065 //Time Menu:
00066     new KAction( i18n( "Set Time to &Now" ), KShortcut( "Ctrl+E"  ),
00067         this, SLOT( slotSetTimeToNow() ), actionCollection(), "time_to_now" );
00068     new KAction( i18n( "set Clock to New Time", "&Set Time..." ), "clock", KShortcut( "Ctrl+S"  ),
00069         this, SLOT( slotSetTime() ), actionCollection(), "time_dialog" );
00070     ToggleAction *actTimeRun = new ToggleAction( i18n( "Stop &Clock" ), BarIcon("player_pause"),
00071                 i18n("Start &Clock"), BarIcon("1rightarrow"),
00072                 0, this, SLOT( slotToggleTimer() ), actionCollection(), "timer_control" );
00073     actTimeRun->setOffToolTip( i18n( "Start Clock" ) );
00074     actTimeRun->setOnToolTip( i18n( "Stop Clock" ) );
00075     QObject::connect(data()->clock(), SIGNAL(clockStarted()), actTimeRun, SLOT(turnOn()) );
00076     QObject::connect(data()->clock(), SIGNAL(clockStopped()), actTimeRun, SLOT(turnOff()) );
00077 //UpdateTime() if clock is stopped (so hidden objects get drawn)
00078     QObject::connect(data()->clock(), SIGNAL(clockStopped()), this, SLOT(updateTime()) );
00079 
00080 //Focus Menu:
00081     new KAction(i18n( "&Zenith" ), KShortcut( "Z" ),
00082             this, SLOT( slotPointFocus() ),  actionCollection(), "zenith");
00083     new KAction(i18n( "&North" ), KShortcut( "N" ),
00084             this, SLOT( slotPointFocus() ),  actionCollection(), "north");
00085     new KAction(i18n( "&East" ), KShortcut( "E" ),
00086             this, SLOT( slotPointFocus() ),  actionCollection(), "east");
00087     new KAction(i18n( "&South" ), KShortcut( "S" ),
00088             this, SLOT( slotPointFocus() ),  actionCollection(), "south");
00089     new KAction(i18n( "&West" ), KShortcut( "W" ),
00090             this, SLOT( slotPointFocus() ),  actionCollection(), "west");
00091     KAction *tmpAction = KStdAction::find( this, SLOT( slotFind() ),
00092                                                 actionCollection(), "find_object" );
00093     tmpAction->setText( i18n( "&Find Object..." ) );
00094     tmpAction->setToolTip( i18n( "Find object" ) );
00095 
00096     new KAction( i18n( "Engage &Tracking" ), "decrypted", KShortcut( "Ctrl+T"  ),
00097         this, SLOT( slotTrack() ), actionCollection(), "track_object" );
00098 
00099     new KAction( i18n( "Set Focus &Manually..." ), KShortcut( "Ctrl+M" ),
00100             this, SLOT( slotManualFocus() ),  actionCollection(), "manual_focus" );
00101 
00102 //View Menu:
00103     KStdAction::zoomIn(this, SLOT( slotZoomIn() ), actionCollection(), "zoom_in" );
00104     KStdAction::zoomOut(this, SLOT( slotZoomOut() ), actionCollection(), "zoom_out" );
00105     new KAction( i18n( "&Default Zoom" ), "viewmagfit.png", KShortcut( "Ctrl+Z" ),
00106         this, SLOT( slotDefaultZoom() ), actionCollection(), "zoom_default" );
00107     new KAction( i18n( "&Zoom to Angular Size..." ), "viewmag.png", KShortcut( "Ctrl+Shift+Z" ),
00108         this, SLOT( slotSetZoom() ), actionCollection(), "zoom_set" );
00109     actCoordSys = new ToggleAction( i18n("Horizontal &Coordinates"), i18n( "Equatorial &Coordinates" ),
00110             Key_Space, this, SLOT( slotCoordSys() ), actionCollection(), "coordsys" );
00111     KStdAction::fullScreen( this, SLOT( slotFullScreen() ), actionCollection(), 0 );
00112 
00113 
00114 //Settings Menu:
00115     //
00116     // MHH - 2002-01-13
00117     // Setting the slot in the KToggleAction constructor, connects the slot to
00118     // the activated signal instead of the toggled signal. This seems like a bug
00119     // to me, but ...
00120     //
00121     //Info Boxes option actions
00122     KToggleAction *a = new KToggleAction(i18n( "Show the information boxes", "Show &Info Boxes"),
00123             0, 0, 0, actionCollection(), "show_boxes");
00124     a->setChecked( Options::showInfoBoxes() );
00125     QObject::connect(a, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(setVisible(bool)));
00126     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00127 
00128     a = new KToggleAction(i18n( "Show time-related info box", "Show &Time Box"),
00129             0, 0, 0, actionCollection(), "show_time_box");
00130     QObject::connect(a, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showTimeBox(bool)));
00131     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00132 
00133     a = new KToggleAction(i18n( "Show focus-related info box", "Show &Focus Box"),
00134             0, 0, 0, actionCollection(), "show_focus_box");
00135     QObject::connect(a, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showFocusBox(bool)));
00136     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00137 
00138     a = new KToggleAction(i18n( "Show location-related info box", "Show &Location Box"),
00139             0, 0, 0, actionCollection(), "show_location_box");
00140     QObject::connect(a, SIGNAL( toggled(bool) ), infoBoxes(), SLOT(showGeoBox(bool)));
00141     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00142 
00143 //Toolbar view options
00144     a = new KToggleAction(i18n( "Show Main Toolbar" ),
00145             0, 0, 0, actionCollection(), "show_mainToolBar");
00146     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00147 
00148     a = new KToggleAction(i18n( "Show View Toolbar" ),
00149             0, 0, 0, actionCollection(), "show_viewToolBar");
00150     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00151 
00152 //Statusbar view options
00153     a = new KToggleAction(i18n( "Show Statusbar" ),
00154             0, 0, 0, actionCollection(), "show_statusBar");
00155     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00156 
00157     a = new KToggleAction(i18n( "Show Az/Alt Field" ),
00158             0, 0, 0, actionCollection(), "show_sbAzAlt");
00159     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00160 
00161     a = new KToggleAction(i18n( "Show RA/Dec Field" ),
00162             0, 0, 0, actionCollection(), "show_sbRADec");
00163     QObject::connect(a, SIGNAL( toggled(bool) ), this, SLOT(slotShowGUIItem(bool)));
00164 
00165 //Color scheme actions.  These are added to the "colorschemes" KActionMenu.
00166     colorActionMenu = new KActionMenu( i18n( "C&olor Schemes" ), actionCollection(), "colorschemes" );
00167     addColorMenuItem( i18n( "&Default" ), "cs_default" );
00168     addColorMenuItem( i18n( "&Star Chart" ), "cs_chart" );
00169     addColorMenuItem( i18n( "&Night Vision" ), "cs_night" );
00170     addColorMenuItem( i18n( "&Moonless Night" ), "cs_moonless-night" );
00171 
00172 //Add any user-defined color schemes:
00173     QFile file;
00174     QString line, schemeName, filename;
00175     file.setName( locate( "appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
00176     if ( file.exists() && file.open( IO_ReadOnly ) ) {
00177         QTextStream stream( &file );
00178 
00179         while ( !stream.eof() ) {
00180             line = stream.readLine();
00181             schemeName = line.left( line.find( ':' ) );
00182             //I call it filename here, but it's used as the name of the action!
00183             filename = "cs_" + line.mid( line.find( ':' ) +1, line.find( '.' ) - line.find( ':' ) - 1 );
00184             addColorMenuItem( i18n( schemeName.local8Bit() ), filename.local8Bit() );
00185         }
00186         file.close();
00187     }
00188 
00189     //Add FOV Symbol actions
00190     fovActionMenu = new KActionMenu( i18n( "&FOV Symbols" ), actionCollection(), "fovsymbols" );
00191     initFOV();
00192 
00193     new KAction( i18n( "Location on Earth", "&Geographic..." ), 
00194             "kstars_geo", KShortcut( "Ctrl+G"  ), this, 
00195             SLOT( slotGeoLocator() ), actionCollection(), "geolocation" );
00196 
00197     KStdAction::preferences( this, SLOT( slotViewOps() ), actionCollection(), "configure" );
00198 
00199     new KAction(i18n( "Startup Wizard..." ), "wizard", KShortcut(), 
00200             this, SLOT( slotWizard() ), actionCollection(), "startwizard" );
00201 
00202 //Tools Menu:
00203     new KAction(i18n( "Calculator..."), KShortcut( "Ctrl+C"),
00204             this, SLOT( slotCalculator() ), actionCollection(), "astrocalculator");
00205 
00206     new KAction(i18n( "Observing List..."), KShortcut( "Ctrl+L"),
00207             this, SLOT( slotObsList() ), actionCollection(), "obslist");
00208 
00209     // enable action only if file was loaded and processed successfully.
00210     if (!data()->VariableStarsList.isEmpty())
00211         new KAction(i18n( "AAVSO Light Curves..."), KShortcut( "Ctrl+V"),
00212                         this, SLOT( slotLCGenerator() ), actionCollection(), "lightcurvegenerator");
00213 
00214     new KAction(i18n( "Altitude vs. Time..."), KShortcut( "Ctrl+A"),
00215                         this, SLOT( slotAVT() ), actionCollection(), "altitude_vs_time");
00216     new KAction(i18n( "What's up Tonight..."), KShortcut("Ctrl+U"),
00217                         this, SLOT(slotWUT()), actionCollection(), "whats_up_tonight");
00218 //FIXME GLOSSARY
00219 //  new KAction(i18n( "Glossary..."), KShortcut("Ctrl+K"),
00220 //                      this, SLOT(slotGlossary()), actionCollection(), "glossary");
00221     new KAction(i18n( "Script Builder..."), KShortcut("Ctrl+B"),
00222                         this, SLOT(slotScriptBuilder()), actionCollection(), "scriptbuilder");
00223     new KAction(i18n( "Solar System..."), KShortcut("Ctrl+Y"),
00224                         this, SLOT(slotSolarSystem()), actionCollection(), "solarsystem");
00225     new KAction(i18n( "Jupiter's Moons..."), KShortcut("Ctrl+J"),
00226                         this, SLOT(slotJMoonTool()), actionCollection(), "jmoontool");
00227 
00228 // devices Menu
00229     new KAction(i18n("Telescope Wizard..."), 0, this, SLOT(slotTelescopeWizard()), actionCollection(), "telescope_wizard");
00230     new KAction(i18n("Telescope Properties..."), 0, this, SLOT(slotTelescopeProperties()), actionCollection(), "telescope_properties");
00231     new KAction(i18n("Device Manager..."), 0, this, SLOT(slotINDIDriver()), actionCollection(), "device_manager");
00232     
00233     tmpAction = new KAction(i18n("Capture Image Sequence..."), 0, this, SLOT(slotImageSequence()), actionCollection(), "capture_sequence");
00234     tmpAction->setEnabled(false);
00235     
00236     tmpAction = new KAction(i18n("INDI Control Panel..."), 0, this, SLOT(slotINDIPanel()), actionCollection(), "indi_control_panel");
00237     tmpAction->setEnabled(false);
00238     
00239     new KAction(i18n("Configure INDI..."), 0, this, SLOT(slotINDIConf()), actionCollection(), "configure_indi");
00240 
00241 
00242 
00243 //Help Menu:
00244     new KAction( i18n( "Tip of the Day" ), "idea", 0,
00245             this, SLOT( slotTipOfDay() ), actionCollection(), "help_tipofday" );
00246 
00247 //Handbook toolBar item:
00248     new KAction( i18n( "&Handbook" ), "contents", KShortcut( "F1"  ),
00249             this, SLOT( appHelpActivated() ), actionCollection(), "handbook" );
00250 
00251 //
00252 //viewToolBar actions:
00253 //
00254 
00255 //show_stars:
00256     a = new KToggleAction( i18n( "Toggle Stars" ), "kstars_stars", 
00257         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_stars" );
00258 
00259 //show_deepsky:
00260     a = new KToggleAction( i18n( "Toggle Deep Sky Objects" ), "kstars_deepsky", 
00261         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_deepsky" );
00262 
00263 //show_planets:
00264     a = new KToggleAction( i18n( "Toggle Solar System" ), "kstars_planets", 
00265         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_planets" );
00266 
00267 //show_clines:
00268     a = new KToggleAction( i18n( "Toggle Constellation Lines" ), "kstars_clines", 
00269         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_clines" );
00270 
00271 //show_cnames:
00272     a = new KToggleAction( i18n( "Toggle Constellation Names" ), "kstars_cnames", 
00273         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_cnames" );
00274 
00275 //show_cbound:
00276     a = new KToggleAction( i18n( "Toggle Constellation Boundaries" ), "kstars_cbound", 
00277         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_cbounds" );
00278 
00279 //show_mw:
00280     a = new KToggleAction( i18n( "Toggle Milky Way" ), "kstars_mw", 
00281         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_mw" );
00282 
00283 //show_grid:
00284     a = new KToggleAction( i18n( "Toggle Coordinate Grid" ), "kstars_grid", 
00285         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_grid" );
00286 
00287 //show_horizon:
00288     a = new KToggleAction( i18n( "Toggle Ground" ), "kstars_horizon", 
00289         0, this, SLOT( slotViewToolBar() ), actionCollection(), "show_horizon" );
00290     
00291     if (Options::fitsSaveDirectory().isEmpty())
00292             Options::setFitsSaveDirectory(QDir:: homeDirPath());
00293 }
00294 
00295 void KStars::initFOV() {
00296     //Read in the user's fov.dat and populate the FOV menu with its symbols.  If no fov.dat exists, populate
00297     //create a default version.
00298     QFile f;
00299     QStringList fields;
00300     QString nm;
00301 
00302     f.setName( locateLocal( "appdata", "fov.dat" ) );
00303 
00304     //if file s empty, let's start over
00305     if ( (uint)f.size() == 0 ) f.remove();
00306 
00307     if ( ! f.exists() ) {
00308         if ( ! f.open( IO_WriteOnly ) ) {
00309             kdDebug() << i18n( "Could not open fov.dat." ) << endl;
00310         } else {
00311             QTextStream ostream(&f);
00312             ostream << i18n( "Do not use a field-of-view indicator", "No FOV" ) <<  ":0.0:0:#AAAAAA" << endl;
00313             ostream << i18n( "use field-of-view for binoculars", "7x35 Binoculars" ) << ":558:1:#AAAAAA" << endl;
00314             ostream << i18n( "use 1-degree field-of-view indicator", "One Degree" ) << ":60:2:#AAAAAA" << endl;
00315             ostream << i18n( "use HST field-of-view indicator", "HST WFPC2" ) << ":2.4:0:#AAAAAA" << endl;
00316             ostream << i18n( "use Radiotelescope HPBW", "30m at 1.3cm" ) << ":1.79:1:#AAAAAA" << endl;
00317             f.close();
00318         }
00319     }
00320 
00321     //just populate the FOV menu with items, don't need to fully parse the lines
00322     if ( f.open( IO_ReadOnly ) ) {
00323         QTextStream stream( &f );
00324         while ( !stream.eof() ) {
00325             QString line = stream.readLine();
00326             fields = QStringList::split( ":", line );
00327 
00328             if ( fields.count() == 4 ) {
00329                 nm = fields[0].stripWhiteSpace();
00330                 KToggleAction *kta = new KToggleAction( nm, 0, this, SLOT( slotTargetSymbol() ), 
00331                         actionCollection(), nm.utf8() );
00332                 kta->setExclusiveGroup( "fovsymbol" );
00333                 if ( nm == Options::fOVName() ) kta->setChecked( true );
00334                 fovActionMenu->insert( kta );
00335             }
00336         }
00337     } else {
00338         kdDebug() << i18n( "Could not open file: %1" ).arg( f.name() ) << endl;
00339     }
00340 
00341     fovActionMenu->popupMenu()->insertSeparator();
00342     fovActionMenu->insert( new KAction( i18n( "Edit FOV Symbols..." ), 0, this, SLOT( slotFOVEdit() ), actionCollection(), "edit_fov" ) );
00343 }
00344 
00345 void KStars::initStatusBar() {
00346     statusBar()->insertItem( i18n( " Welcome to KStars " ), 0, 1, true );
00347     statusBar()->setItemAlignment( 0, AlignLeft | AlignVCenter );
00348 
00349     QString s = "000d 00m 00s,   +00d 00\' 00\""; //only need this to set the width
00350 
00351     if ( Options::showAltAzField() ) {
00352         statusBar()->insertFixedItem( s, 1, true );
00353         statusBar()->setItemAlignment( 1, AlignRight | AlignVCenter );
00354         statusBar()->changeItem( "", 1 );
00355     }
00356 
00357     if ( Options::showRADecField() ) {
00358         statusBar()->insertFixedItem( s, 2, true );
00359         statusBar()->setItemAlignment( 2, AlignRight | AlignVCenter );
00360         statusBar()->changeItem( "", 2 );
00361     }
00362 
00363     if ( ! Options::showStatusBar() ) statusBar()->hide();
00364 }
00365 
00366 void KStars::datainitFinished(bool worked) {
00367     if (!worked) {
00368         kapp->quit();
00369         return;
00370     }
00371 
00372     if (pd->splash) {
00373         delete pd->splash;
00374         pd->splash = 0;
00375     }
00376 
00377     pd->buildGUI();
00378     data()->setFullTimeUpdate();
00379     updateTime();
00380 
00381     //Do not start the clock if the user specified "--paused" on the cmd line
00382     if ( StartClockRunning )
00383         data()->clock()->start();
00384 
00385 //Initialize FOV symbol from options
00386     data()->fovSymbol.setName( Options::fOVName() );
00387     data()->fovSymbol.setSize( Options::fOVSize() );
00388     data()->fovSymbol.setShape( Options::fOVShape() );
00389     data()->fovSymbol.setColor( Options::fOVColor().name() );
00390 
00391     show();
00392 
00393     //If this is the first startup, show the wizard
00394     if ( Options::runStartupWizard() ) {
00395         slotWizard();
00396         //reset the clock to the system CPU
00397         slotSetTimeToNow();
00398     }
00399 
00400     //Check whether initial position is below the horizon.
00401     //We used to just call slotCenter() in buildGUI() which performs this check.
00402     //However, on some systems, if the messagebox is shown before show() is called,
00403     //the program exits.  It does not crash (at least there are no error messages),
00404     //it simply exits.  Very strange.
00405     if ( Options::useAltAz() && Options::showGround() &&
00406             map()->focus()->alt()->Degrees() < -1.0 ) {
00407         QString caption = i18n( "Initial Position is Below Horizon" );
00408         QString message = i18n( "The initial position is below the horizon.\nWould you like to reset to the default position?" );
00409         if ( KMessageBox::warningYesNo( this, message, caption,
00410                 i18n("Reset Position"), i18n("Do Not Reset"), "dag_start_below_horiz" ) == KMessageBox::Yes ) {
00411             map()->setClickedObject( NULL );
00412             map()->setFocusObject( NULL );
00413             Options::setIsTracking( false );
00414 
00415             data()->setSnapNextFocus(true);
00416 
00417             SkyPoint DefaultFocus;
00418             DefaultFocus.setAz( 180.0 );
00419             DefaultFocus.setAlt( 45.0 );
00420             DefaultFocus.HorizontalToEquatorial( LST(), geo()->lat() );
00421             map()->setDestination( &DefaultFocus );
00422         }
00423     }
00424 
00425     //Store focus coords in Options object before calling applyConfig()
00426     Options::setFocusRA( map()->focus()->ra()->Hours() );
00427     Options::setFocusDec( map()->focus()->dec()->Degrees() );
00428 
00429     //Propagate Options values through the program
00430     applyConfig();
00431 
00432     //If there is a focusObject() and it is a SS body, add a temporary Trail to it.
00433     if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
00434             && Options::useAutoTrail() ) {
00435         ((KSPlanetBase*)map()->focusObject())->addToTrail();
00436         data()->temporaryTrail = true;
00437     }
00438 
00439 // just show dialog if option is set (don't force it)
00440     KTipDialog::showTip( "kstars/tips" );
00441 }
00442 
00443 void KStars::privatedata::buildGUI() {
00444     //create the widgets
00445     ks->centralWidget = new QWidget( ks );
00446     ks->setCentralWidget( ks->centralWidget );
00447 
00448     //set AAVSO modaless dialog pointer to 0
00449     ks->AAVSODialog = 0;
00450 
00451     //INDI menu started without GUI
00452     ks->indimenu = new INDIMenu(ks);
00453 
00454     //INDI driver set to null
00455     ks->indidriver = 0;
00456     
00457     //INDI img sequence, set to null
00458     ks->indiseq = 0;
00459 
00460     ks->skymap = new SkyMap( ks->data(), ks->centralWidget );
00461     // update skymap if KStarsData send update signal
00462     QObject::connect(kstarsData, SIGNAL( update() ), ks->skymap, SLOT( forceUpdateNow() ) );
00463 
00464     // get focus of keyboard and mouse actions (for example zoom in with +)
00465     ks->map()->QWidget::setFocus();
00466 
00467     ks->initStatusBar();
00468     ks->initActions();
00469 
00470     // create the layout of the central widget
00471     ks->topLayout = new QVBoxLayout( ks->centralWidget );
00472     ks->topLayout->addWidget( ks->skymap );
00473 
00474     // 2nd parameter must be false, or plugActionList won't work!
00475     ks->createGUI("kstarsui.rc", false);
00476 
00477     //Do not show text on the view toolbar buttons
00478     //FIXME: after strings freeze, remove this and make the
00479     //text of each button shorter
00480     ks->toolBar( "viewToolBar" )->setIconText( KToolBar::IconOnly );
00481 
00482     ks->TimeStep = new TimeStepBox( ks->toolBar() );
00483     ks->toolBar()->insertWidget( 0, 6, ks->TimeStep, 15 );
00484 
00485 //Changing the timestep needs to propagate to the clock, check if slew mode should be
00486 //(dis)engaged, and return input focus to the skymap.
00487     connect( ks->TimeStep, SIGNAL( scaleChanged( float ) ), ks->data(), SLOT( setTimeDirection( float ) ) );
00488     connect( ks->TimeStep, SIGNAL( scaleChanged( float ) ), ks->data()->clock(), SLOT( setScale( float )) );
00489 //  connect( ks->TimeStep, SIGNAL( scaleChanged( float ) ), ks->skymap, SLOT( slotClockSlewing() ) );
00490     connect( ks->data()->clock(), SIGNAL( scaleChanged( float ) ), ks->map(), SLOT( slotClockSlewing() ) );
00491     connect( ks->TimeStep, SIGNAL( scaleChanged( float ) ), ks, SLOT( mapGetsFocus() ) );
00492 
00493     ks->resize( Options::windowWidth(), Options::windowHeight() );
00494 
00495     //Geographic location
00496     ks->setGeoLocation( Options::cityName(), Options::provinceName(), Options::countryName() );
00497 
00498     // initialize clock with current time/date or the date/time specified on the command line
00499     KStarsDateTime startDate = KStarsDateTime::fromString( ks->StartDateString );
00500     if ( startDate.isValid() )
00501         ks->data()->changeDateTime( ks->geo()->LTtoUT( startDate ) );
00502     else 
00503         ks->slotSetTimeToNow();
00504     
00505     //Define the celestial equator, horizon and ecliptic
00506     KSNumbers tempnum(ks->data()->ut().djd());
00507     ks->data()->initGuides(&tempnum);
00508 
00509     //Connect the clock.
00510     QObject::connect( ks->data()->clock(), SIGNAL( timeAdvanced() ), ks, SLOT( updateTime() ) );
00511     QObject::connect( ks->data()->clock(), SIGNAL( timeChanged() ), ks, SLOT( updateTime() ) );
00512 
00513     // Connect cache function
00514     QObject::connect( kstarsData, SIGNAL( clearCache() ), ks, SLOT( clearCachedFindDialog() ) );
00515 
00516     SkyPoint newPoint;
00517     if ( ks->data()->useDefaultOptions ) {
00518         newPoint.setAz( Options::focusRA() );
00519         newPoint.setAlt( Options::focusDec() + 0.0001 );
00520         newPoint.HorizontalToEquatorial( ks->LST(), ks->geo()->lat() );
00521     } else {
00522         newPoint.set( Options::focusRA(), Options::focusDec() );
00523     }
00524 
00525 //need to set focusObject before updateTime, otherwise tracking is set to false
00526     if ( (Options::focusObject() != i18n( "star" ) ) &&
00527              (Options::focusObject() != i18n( "nothing" ) ) )
00528             ks->map()->setFocusObject( ks->data()->objectNamed( Options::focusObject() ) );
00529 
00530     ks->updateTime();
00531 
00532     //Set focus of Skymap to value stored in config.
00533     //Set default position in case stored focus is below horizon
00534 //  SkyPoint DefaultFocus;
00535 //  DefaultFocus.setAz( 180.0 );
00536 //  DefaultFocus.setAlt( 45.0 );
00537 //  DefaultFocus.HorizontalToEquatorial( ks->LST(), ks->geo()->lat() );
00538 //  ks->map()->setDestination( &DefaultFocus );
00539 
00540     //if user was tracking last time, track on same object now.
00541     if ( Options::isTracking() ) {
00542         if ( (Options::focusObject() == i18n( "star" ) ) ||
00543              (Options::focusObject() == i18n( "nothing" ) ) ) {
00544             ks->map()->setFocusPoint( &newPoint );
00545         } else {
00546             ks->map()->setClickedObject( ks->data()->objectNamed( Options::focusObject() ) );
00547             if ( ks->map()->clickedObject() ) {
00548                 ks->map()->setFocusPoint( ks->map()->clickedObject() );
00549                 ks->map()->setFocusObject( ks->map()->clickedObject() );
00550             } else {
00551                 ks->map()->setFocusPoint( &newPoint );
00552             }
00553         }
00554 //      ks->map()->slotCenter();
00555     } else {
00556         ks->map()->setFocusPoint( &newPoint );
00557 //      ks->map()->slotCenter();
00558     }
00559 
00560 //  if ( Options::focusObject() == i18n( "star" ) ) Options::setFocusObject( i18n( "nothing" ) );
00561 
00562     ks->map()->setDestination( ks->map()->focusPoint() );
00563     ks->map()->destination()->EquatorialToHorizontal( ks->LST(), ks->geo()->lat() );
00564     ks->map()->setFocus( ks->map()->destination() );
00565     ks->map()->focus()->EquatorialToHorizontal( ks->LST(), ks->geo()->lat() );
00566 
00567 //  ks->infoBoxes()->focusObjChanged( Options::focusObject() );
00568 //  ks->infoBoxes()->focusCoordChanged( ks->map()->focus() );
00569     ks->map()->showFocusCoords();
00570     
00571     ks->data()->setHourAngle( ks->LST()->Hours() - ks->map()->focus()->ra()->Hours() );
00572 
00573     ks->map()->setOldFocus( ks->map()->focus() );
00574     ks->map()->oldfocus()->setAz( ks->map()->focus()->az()->Degrees() );
00575     ks->map()->oldfocus()->setAlt( ks->map()->focus()->alt()->Degrees() );
00576 
00577     // check zoom in/out buttons
00578     if ( Options::zoomFactor() >= MAXZOOM ) ks->actionCollection()->action("zoom_in")->setEnabled( false );
00579     if ( Options::zoomFactor() <= MINZOOM ) ks->actionCollection()->action("zoom_out")->setEnabled( false );
00580 
00581     kapp->dcopClient()->resume();
00582 }

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