00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <fstream>
00019 #include <sstream>
00020
00021 #include <qpushbutton.h>
00022 #include <qslider.h>
00023 #include <qlayout.h>
00024 #include <qframe.h>
00025 #include <qgrid.h>
00026 #include <qvbox.h>
00027 #include <qcheckbox.h>
00028 #include <qvgroupbox.h>
00029 #include <qlabel.h>
00030 #include <qclipboard.h>
00031 #include <qregexp.h>
00032 #include <qpalette.h>
00033 #include <qfont.h>
00034 #include <qlineedit.h>
00035 #include <qvalidator.h>
00036
00037 #include <qmenubar.h>
00038 #include <qpopupmenu.h>
00039 #include <qapplication.h>
00040 #include <qkeycode.h>
00041 #include <qtimer.h>
00042 #include <qimage.h>
00043 #include <kaction.h>
00044 #include <kstdaction.h>
00045 #include <kmenubar.h>
00046 #include <kedittoolbar.h>
00047 #include <kkeydialog.h>
00048 #include <klocale.h>
00049 #include <kconfig.h>
00050 #include <qtextedit.h>
00051 #include <klineeditdlg.h>
00052
00053 #include <qdatetime.h>
00054 #include <kshortcut.h>
00055 #include <klocale.h>
00056 #include <kfiledialog.h>
00057 #include <kmessagebox.h>
00058 #include <kurl.h>
00059 #include <krun.h>
00060 #include <kurldrag.h>
00061 #include <kstdaccel.h>
00062 #include <kpopupmenu.h>
00063 #include <kcelbookmarkmenu.h>
00064 #include <kbookmarkbar.h>
00065 #include <kcelbookmarkmanager.h>
00066 #include <kdeversion.h>
00067
00068 #if KDE_VERSION >= 0x030200
00069 #include <ksplashscreen.h>
00070 #endif
00071
00072 #include "kdeglwidget.h"
00073 #include "kdeapp.h"
00074 #include "kdepreferencesdialog.h"
00075 #include "celengine/cmdparser.h"
00076 #include "url.h"
00077 #include "celestialbrowser.h"
00078 #include "eclipsefinderdlg.h"
00079 #include "selectionpopup.h"
00080 #include "celsplashscreen.h"
00081
00082 #include "celengine/glext.h"
00083
00084 #define MENUMAXSIZE 100
00085
00086
00087 KdeApp* KdeApp::app=0;
00088
00089 KBookmarkManager* KCelBookmarkManager::s_bookmarkManager;
00090
00091 static uint32 FilterOtherLocations = ~(Location::City |
00092 Location::Observatory |
00093 Location::LandingSite |
00094 Location::Crater |
00095 Location::Mons |
00096 Location::Terra |
00097 Location::Vallis |
00098 Location::Mare);
00099
00100 KdeApp::KdeApp(std::string config, std::string dir, std::vector<std::string> extrasDirs, bool fullscreen, bool disableSplash) : KMainWindow(0, 0)
00101 {
00102 #if KDE_VERSION >= 0x030200
00103 CelSplashScreen *splash = NULL;
00104 if (!disableSplash) {
00105 QStringList splashDirs = KGlobal::dirs()->findDirs("appdata", "splash");
00106 QStringList images;
00107 srandom(time(NULL));
00108 for(QStringList::iterator i = splashDirs.begin(); i != splashDirs.end(); ++i) {
00109 QDir d(*i);
00110 d.setFilter(QDir::Files);
00111 QStringList splashImages = d.entryList().grep(QRegExp("\\.(jpg|png)$", FALSE));
00112 for(QStringList::iterator j = splashImages.begin(); j != splashImages.end(); ++j) {
00113 images.append(*i + *j);
00114 }
00115 }
00116
00117 if (images.size() > 0) {
00118 int index = (int)(random()*1./RAND_MAX*images.size());
00119 splash = new CelSplashScreen(images[index], this);
00120 } else {
00121 KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n("Something seems to be wrong with your installation of Celestia. The splash screen directory couldn't be found. \nStart-up will continue, but Celestia will probably be missing some data files and may not work correctly, please check your installation."));
00122 }
00123 }
00124 #endif
00125
00126 appCore=new CelestiaCore();
00127 if (appCore == NULL)
00128 {
00129 cerr << "Out of memory.\n";
00130 exit(1);
00131 }
00132
00133 kdewatcher = new KdeWatcher(appCore, this);
00134
00135 renderer = appCore->getRenderer();
00136 sim = appCore->getSimulation();
00137
00138 app=this;
00139 appCore->setContextMenuCallback(&KdeApp::popupMenu);
00140 appCore->setAlerter(new KdeAlerter(this));
00141
00142 setAcceptDrops(true);
00143
00144
00145 if ( (dir.length() > 1 ? chdir(dir.c_str()):chdir(CONFIG_DATA_DIR)) == -1)
00146 {
00147 ::std::cout << "Cannot chdir to '" << CONFIG_DATA_DIR << "', probably due to improper installation" << ::std::endl;
00148 exit(1);
00149 }
00150 glWidget = new KdeGlWidget( this, "kdeglwidget", appCore);
00151 string* altConfig = config.length() > 0 ? &config : NULL;
00152 #if KDE_VERSION >= 0x030200
00153 if (!appCore->initSimulation(altConfig, &extrasDirs, splash))
00154 #else
00155 if (!appCore->initSimulation(altConfig, &extrasDirs))
00156 #endif
00157 {
00158 exit(1);
00159 }
00160
00161 setCentralWidget(glWidget);
00162 initActions();
00163
00164 glWidget->setFocus();
00165
00166 resize(640,480);
00167 setAutoSaveSettings("MainWindow");
00168 KConfig* conf = kapp->config();
00169 applyMainWindowSettings(conf, "MainWindow");
00170 conf->setGroup("MainWindow");
00171 restoreWindowSize(conf);
00172 conf->setGroup(0);
00173 if (fullscreen) slotFullScreen();
00174
00175 KGlobal::config()->setGroup("Preferences");
00176 if (KGlobal::config()->hasKey("DistanceToScreen"))
00177 {
00178 appCore->setDistanceToScreen(KGlobal::config()->readNumEntry("DistanceToScreen"));
00179 }
00180
00181
00182 if (conf->hasGroup("Shortcuts"))
00183 actionCollection()->readShortcutSettings("Shortcuts", conf);
00184
00185 if (toolBar()->isHidden()) toggleToolbar->setChecked(false);
00186 if (menuBar()->isHidden()) toggleMenubar->setChecked(false);
00187
00188 #if KDE_VERSION >= 0x030200
00189 if (splash != NULL) {
00190 splash->finish(this);
00191 delete splash;
00192 }
00193 #endif
00194
00195
00196
00197 QTimer *t = new QTimer( dynamic_cast<QObject *>(this) );
00198 QObject::connect( t, SIGNAL(timeout()), SLOT(celestia_tick()) );
00199 t->start( 0, FALSE );
00200
00201 }
00202
00203 void KdeApp::setStartURL(KURL url) {
00204 if (url.protocol() == "cel") {
00205 appCore->setStartURL(url.url().latin1());
00206 }
00207 if (url.protocol() == "file") {
00208 appCore->setStartURL(url.path().latin1());
00209 }
00210 }
00211
00212 void KdeApp::goToURL(const KURL& url) {
00213 if (url.protocol() == "cel") {
00214 appCore->addToHistory();
00215 appCore->goToUrl(url.prettyURL().latin1());
00216 }
00217 if (url.protocol() == "file") {
00218 appCore->addToHistory();
00219 slotOpenFileURL(url);
00220 }
00221 }
00222
00223 void KdeApp::openBookmarkURL(const QString& _url) {
00224 KURL url(_url);
00225 appCore->addToHistory();
00226 appCore->goToUrl(url.prettyURL().latin1());
00227 }
00228
00229 Url KdeApp::currentUrl(Url::UrlType type) const {
00230 return Url(appCore, type);
00231 }
00232
00233 QString KdeApp::currentIcon() const {
00234 QDateTime now = QDateTime::currentDateTime();
00235 QString iconName = QString::fromLatin1("favicons/celestia_") + now.toString("yyyyMMddhhmmsszzz");
00236 QString iconFilename = locateLocal("cache", iconName) + ".png";
00237
00238 QImage grabedImage = glWidget->grabFrameBuffer();
00239 int width=grabedImage.width(), height=grabedImage.height();
00240 if (width > height) {
00241 grabedImage.copy((width - height)/2, 0, height, height).smoothScale(64,64).save(iconFilename, "PNG");
00242 } else {
00243 grabedImage.copy(0, (height - width)/2, width, width).smoothScale(64,64).save(iconFilename, "PNG");
00244 }
00245
00246 return iconName;
00247 }
00248
00249 void KdeWatcher::notifyChange(CelestiaCore * core, int property)
00250 {
00251 if ((property & (CelestiaCore::RenderFlagsChanged|
00252 CelestiaCore::LabelFlagsChanged|
00253 CelestiaCore::TimeZoneChanged)))
00254 kdeapp->resyncMenus();
00255 if (property & CelestiaCore::AmbientLightChanged)
00256 kdeapp->resyncAmbient();
00257 if (property & CelestiaCore::FaintestChanged)
00258 kdeapp->resyncFaintest();
00259 if (property & CelestiaCore::VerbosityLevelChanged)
00260 kdeapp->resyncVerbosity();
00261 if (property & CelestiaCore::HistoryChanged)
00262 kdeapp->resyncHistory();
00263
00264 if (property == CelestiaCore::TextEnterModeChanged) {
00265 static std::vector<KAction*> actions;
00266 if (kdeapp->appCore->getTextEnterMode() != CelestiaCore::KbNormal) {
00267 for (unsigned int n=0; n < kdeapp->getActionCollection()->count(); n++) {
00268 if (kdeapp->getActionCollection()->action(n)->shortcut().count() > 0
00269 && (kdeapp->getActionCollection()->action(n)->shortcut().seq(0).key(0).modFlags()
00270 & (KKey::CTRL | KKey::ALT | KKey::WIN )) == 0 ) {
00271 actions.push_back(kdeapp->getActionCollection()->action(n));
00272 kdeapp->getActionCollection()->action(n)->setEnabled(false);
00273 }
00274 }
00275 } else {
00276 for (std::vector<KAction*>::iterator n=actions.begin(); n<actions.end(); n++) {
00277 (*n)->setEnabled(true);
00278 }
00279 actions.clear();
00280 }
00281 }
00282 }
00283
00284 void KdeApp::resyncHistory() {
00285 std::vector<Url> history=appCore->getHistory();
00286 std::vector<Url>::size_type i=appCore->getHistoryCurrent();
00287
00288 if (i >= history.size()-1) {
00289 action("go_forward")->setEnabled(false);
00290 } else {
00291 action("go_forward")->setEnabled(true);
00292 }
00293 if (i == 0) {
00294 action("go_back")->setEnabled(false);
00295 } else {
00296 action("go_back")->setEnabled(true);
00297 }
00298 }
00299
00300 void KdeApp::resyncMenus() {
00301 int rFlags = renderer->getRenderFlags();
00302 int orbitMask = renderer->getOrbitMask();
00303 ((KToggleAction*)action("showStars"))->setChecked(rFlags & Renderer::ShowStars);
00304 ((KToggleAction*)action("showPlanets"))->setChecked(rFlags & Renderer::ShowPlanets);
00305 ((KToggleAction*)action("showGalaxies"))->setChecked(rFlags & Renderer::ShowGalaxies);
00306 ((KToggleAction*)action("showPartialTrajectories"))->setChecked(rFlags & Renderer::ShowPartialTrajectories);
00307 ((KToggleAction*)action("showNebulae"))->setChecked(rFlags & Renderer::ShowNebulae);
00308 ((KToggleAction*)action("showOpenClusters"))->setChecked(rFlags & Renderer::ShowOpenClusters);
00309 ((KToggleAction*)action("showDiagrams"))->setChecked(rFlags & Renderer::ShowDiagrams);
00310 ((KToggleAction*)action("showCloudMaps"))->setChecked(rFlags & Renderer::ShowCloudMaps);
00311 ((KToggleAction*)action("showOrbits"))->setChecked(rFlags & Renderer::ShowOrbits);
00312 ((KToggleAction*)action("showAsteroidOrbits"))->setChecked(orbitMask & Body::Asteroid);
00313 ((KToggleAction*)action("showCometOrbits"))->setChecked(orbitMask & Body::Comet);
00314 ((KToggleAction*)action("showMoonOrbits"))->setChecked(orbitMask & Body::Moon);
00315 ((KToggleAction*)action("showPlanetOrbits"))->setChecked(orbitMask & Body::Planet);
00316 ((KToggleAction*)action("showSpacecraftOrbits"))->setChecked(orbitMask & Body::Spacecraft);
00317 ((KToggleAction*)action("showCelestialSphere"))->setChecked(rFlags & Renderer::ShowCelestialSphere);
00318 ((KToggleAction*)action("showNightMaps"))->setChecked(rFlags & Renderer::ShowNightMaps);
00319 ((KToggleAction*)action("showMarkers"))->setChecked(rFlags & Renderer::ShowMarkers);
00320 ((KToggleAction*)action("showAtmospheres"))->setChecked(rFlags & Renderer::ShowAtmospheres);
00321 ((KToggleAction*)action("showSmoothLines"))->setChecked(rFlags & Renderer::ShowSmoothLines);
00322 ((KToggleAction*)action("showEclipseShadows"))->setChecked(rFlags & Renderer::ShowEclipseShadows);
00323 ((KToggleAction*)action("showRingShadows"))->setChecked(rFlags & Renderer::ShowRingShadows);
00324 ((KToggleAction*)action("showBoundaries"))->setChecked(rFlags & Renderer::ShowBoundaries);
00325 ((KToggleAction*)action("showAutoMag"))->setChecked(rFlags & Renderer::ShowAutoMag);
00326 ((KToggleAction*)action("showCometTails"))->setChecked(rFlags & Renderer::ShowCometTails);
00327
00328 int lMode = renderer->getLabelMode();
00329 ((KToggleAction*)action("showStarLabels"))->setChecked(lMode & Renderer::StarLabels);
00330 ((KToggleAction*)action("showPlanetLabels"))->setChecked(lMode & Renderer::PlanetLabels);
00331 ((KToggleAction*)action("showMoonLabels"))->setChecked(lMode & Renderer::MoonLabels);
00332 ((KToggleAction*)action("showCometLabels"))->setChecked(lMode & Renderer::CometLabels);
00333 ((KToggleAction*)action("showConstellationLabels"))->setChecked(lMode & Renderer::ConstellationLabels);
00334 ((KToggleAction*)action("showI18nConstellationLabels"))->setChecked(!(lMode & Renderer::I18nConstellationLabels));
00335 ((KToggleAction*)action("showGalaxyLabels"))->setChecked(lMode & Renderer::GalaxyLabels);
00336 ((KToggleAction*)action("showNebulaLabels"))->setChecked(lMode & Renderer::NebulaLabels);
00337 ((KToggleAction*)action("showOpenClusterLabels"))->setChecked(lMode & Renderer::OpenClusterLabels);
00338 ((KToggleAction*)action("showAsteroidLabels"))->setChecked(lMode & Renderer::AsteroidLabels);
00339 ((KToggleAction*)action("showSpacecraftLabels"))->setChecked(lMode & Renderer::SpacecraftLabels);
00340 ((KToggleAction*)action("showLocationLabels"))->setChecked(lMode & Renderer::LocationLabels);
00341
00342 switch (renderer->getGLContext()->getRenderPath()) {
00343 case GLContext::GLPath_Basic:
00344 ((KToggleAction*)action("renderPathBasic"))->setChecked(true);
00345 break;
00346 case GLContext::GLPath_Multitexture:
00347 ((KToggleAction*)action("renderPathMultitexture"))->setChecked(true);
00348 break;
00349 case GLContext::GLPath_NvCombiner:
00350 ((KToggleAction*)action("renderPathNvCombiner"))->setChecked(true);
00351 break;
00352 case GLContext::GLPath_DOT3_ARBVP:
00353 ((KToggleAction*)action("renderPathDOT3ARBVP"))->setChecked(true);
00354 break;
00355 case GLContext::GLPath_NvCombiner_NvVP:
00356 ((KToggleAction*)action("renderPathNvCombinerNvVP"))->setChecked(true);
00357 break;
00358 case GLContext::GLPath_NvCombiner_ARBVP:
00359 ((KToggleAction*)action("renderPathNvCombinerARBVP"))->setChecked(true);
00360 break;
00361 case GLContext::GLPath_ARBFP_ARBVP:
00362 ((KToggleAction*)action("renderPathARBFPARBVP"))->setChecked(true);
00363 break;
00364 case GLContext::GLPath_NV30:
00365 ((KToggleAction*)action("renderPathNV30"))->setChecked(true);
00366 break;
00367 case GLContext::GLPath_GLSL:
00368 ((KToggleAction*)action("renderPathGLSL"))->setChecked(true);
00369 break;
00370 }
00371 }
00372
00373 void KdeApp::resyncAmbient() {
00374 }
00375 void KdeApp::resyncFaintest() {
00376 }
00377 void KdeApp::resyncVerbosity() {
00378 }
00379
00380 void KdeApp::initActions()
00381 {
00382 KStdAction::open(this, SLOT(slotFileOpen()), actionCollection());
00383 openRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection());
00384 openRecent->loadEntries(KGlobal::config());
00385 connect(openRecent, SIGNAL(urlSelected(const KURL&)), SLOT(slotOpenFileURL(const KURL&)));
00386
00387 KStdAction::quit(this, SLOT(slotClose()), actionCollection());
00388 KStdAction::configureToolbars( this, SLOT( slotConfigureToolbars() ), actionCollection() );
00389
00390 new KAction(i18n("Go to &URL..."), 0, ALT + Key_G, this, SLOT(slotGoTo()), actionCollection(), "go_to");
00391 new KAction(i18n("Go to &Long/Lat..."), 0, ALT + Key_L, this, SLOT(slotGoToLongLat()), actionCollection(), "go_to_long_lat");
00392
00393 backAction = new KToolBarPopupAction( i18n("&Back"), "back",
00394 KStdAccel::key(KStdAccel::Back), this, SLOT( slotBack() ),
00395 actionCollection(), KStdAction::stdName( KStdAction::Back ) );
00396 forwardAction = new KToolBarPopupAction( i18n("&Forward"), "forward",
00397 KStdAccel::key(KStdAccel::Forward), this, SLOT( slotForward() ),
00398 actionCollection(), KStdAction::stdName( KStdAction::Forward ) );
00399 connect( backAction->popupMenu(), SIGNAL( aboutToShow() ), SLOT( slotBackAboutToShow() ) );
00400 connect( backAction->popupMenu(), SIGNAL( activated( int ) ), SLOT( slotBackActivated( int ) ) );
00401 connect( forwardAction->popupMenu(), SIGNAL( aboutToShow() ), SLOT( slotForwardAboutToShow() ) );
00402 connect( forwardAction->popupMenu(), SIGNAL( activated( int ) ), SLOT( slotForwardActivated( int ) ) );
00403 new KAction(i18n("Home"), "gohome", CTRL + Key_Home, this, SLOT(slotHome()), actionCollection(), "home");
00404 action("go_forward")->setEnabled(false);
00405 action("go_back")->setEnabled(false);
00406
00407 KStdAction::zoomIn(this, SLOT(slotZoomIn()), actionCollection());
00408 KStdAction::zoomOut(this, SLOT(slotZoomOut()), actionCollection());
00409
00410 KActionMenu *bookmarks = new KActionMenu( i18n("Bookmarks"), "bookmark", actionCollection(), "bookmarks" );
00411 new KCelBookmarkMenu( KCelBookmarkManager::self(), this,
00412 bookmarks->popupMenu(), actionCollection(), true, true );
00413
00414
00415 KStdAction::preferences(this, SLOT(slotPreferences()), actionCollection());
00416 KStdAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
00417 KStdAction::keyBindings(this, SLOT(slotKeyBindings()), actionCollection());
00418
00419 KShortcut fullscreen_shortcut(CTRL + Key_F);
00420 fullscreen_shortcut.append(KKeySequence(QKeySequence(ALT + Key_Return)));
00421
00422 new KAction(i18n("Full Screen"), "window_fullscreen", fullscreen_shortcut, this, SLOT(slotFullScreen()), actionCollection(), "fullScreen");
00423 KShortcut copy_url_shortcut(CTRL + Key_C);
00424 copy_url_shortcut.append(KKeySequence(QKeySequence(CTRL + Key_Insert)));
00425
00426 new KAction(i18n("Copy URL"), "edit_copy", copy_url_shortcut, this, SLOT(slotCopyUrl()), actionCollection(), "copyUrl");
00427
00428
00429 new KAction(i18n("Set Time..."), "kalarm", ALT + Key_T, this, SLOT(slotSetTime()), actionCollection(), "setTime");
00430 new KAction(i18n("Set Time to Now"), "player_eject", Key_Exclam, this, SLOT(slotSetTimeNow()), actionCollection(), "setTimeNow");
00431 new KAction(i18n("Accelerate Time"), "1uparrow", Key_L, this, SLOT(slotAccelerateTime()), actionCollection(), "accelerateTime");
00432 new KAction(i18n("Decelerate Time"), "1downarrow", Key_K, this, SLOT(slotSlowDownTime()), actionCollection(), "slowDownTime");
00433 new KAction(i18n("Pause Time"), "player_pause", Key_Space, this, SLOT(slotPauseTime()), actionCollection(), "pauseTime");
00434 new KAction(i18n("Reverse Time"), "reload", Key_J, this, SLOT(slotReverseTime()), actionCollection(), "reverseTime");
00435
00436 new KAction(i18n("Split View Vertically"), "view_top_bottom", CTRL + Key_R, this, SLOT(slotSplitH()), actionCollection(), "splitH");
00437 new KAction(i18n("Split View Horizontally"), "view_left_right", CTRL + Key_U, this, SLOT(slotSplitV()), actionCollection(), "splitV");
00438 new KAction(i18n("Cycle View"), "rotate_cw", Key_Tab, this, SLOT(slotCycleView()), actionCollection(), "cycleView");
00439 new KAction(i18n("Single View"), "view_remove", CTRL + Key_D, this, SLOT(slotSingleView()), actionCollection(), "singleView");
00440 new KAction(i18n("Delete View"), "view_remove", Key_Delete, this, SLOT(slotDeleteView()), actionCollection(), "deleteView");
00441 KToggleAction* framesVisible = new KToggleAction(i18n("Frames Visible"), 0, 0, this, SLOT(slotToggleFramesVisible()), actionCollection(), "framesVisible");
00442 KGlobal::config()->setGroup("Preferences");
00443 if (KGlobal::config()->hasKey("FramesVisible"))
00444 {
00445 bool visible = KGlobal::config()->readBoolEntry("FramesVisible");
00446 framesVisible->setChecked(visible);
00447 appCore->setFramesVisible(visible);
00448 }
00449 else
00450 {
00451 framesVisible->setChecked(appCore->getFramesVisible());
00452 }
00453
00454 KToggleAction* activeFrameVisible = new KToggleAction(i18n("Active Frame Visible"), 0, 0, this, SLOT(slotToggleActiveFrameVisible()), actionCollection(), "activeFrameVisible");
00455 if (KGlobal::config()->hasKey("ActiveFrameVisible"))
00456 {
00457 bool visible = KGlobal::config()->readBoolEntry("ActiveFrameVisible");
00458 activeFrameVisible->setChecked(visible);
00459 appCore->setActiveFrameVisible(visible);
00460 }
00461 else
00462 {
00463 activeFrameVisible->setChecked(appCore->getActiveFrameVisible());
00464 }
00465
00466 KToggleAction* timeSync = new KToggleAction(i18n("Synchronize Time"), 0, 0, this, SLOT(slotToggleSyncTime()), actionCollection(), "syncTime");
00467 if (KGlobal::config()->hasKey("SyncTime"))
00468 {
00469 bool sync = KGlobal::config()->readBoolEntry("SyncTime");
00470 timeSync->setChecked(sync);
00471 appCore->getSimulation()->setSyncTime(sync);
00472 }
00473 else
00474 {
00475 timeSync->setChecked(appCore->getSimulation()->getSyncTime());
00476 }
00477
00478 new KAction(i18n("Alt-Azimuth Mode"), 0, ALT + Key_F, this, SLOT(slotAltAzMode()), actionCollection(), "altAzMode");
00479 new KAction(i18n("Go To Surface"), 0, CTRL + Key_G, this, SLOT(slotGoToSurface()), actionCollection(), "goToSurface");
00480
00481 new KAction(i18n("Celestial Browser"), 0, ALT + Key_C, this, SLOT(slotCelestialBrowser()), actionCollection(), "celestialBrowser");
00482 new KAction(i18n("Eclipse Finder"), 0, ALT + Key_E, this, SLOT(slotEclipseFinder()), actionCollection(), "eclipseFinder");
00483
00484 int rFlags, lMode, oMask;
00485 uint32 lFilter;
00486 bool isLocal = true;
00487 if (KGlobal::config()->hasKey("RendererFlags"))
00488 rFlags = KGlobal::config()->readNumEntry("RendererFlags");
00489 else rFlags = appCore->getRenderer()->getRenderFlags();
00490
00491 if (KGlobal::config()->hasKey("LabelMode"))
00492 lMode = KGlobal::config()->readNumEntry("LabelMode");
00493 else lMode = appCore->getRenderer()->getLabelMode();
00494
00495 if (KGlobal::config()->hasKey("LocationFilter"))
00496 lFilter = KGlobal::config()->readUnsignedNumEntry("LocationFilter");
00497 else lFilter = appCore->getSimulation()->getActiveObserver()->getLocationFilter();
00498 appCore->getSimulation()->getActiveObserver()->setLocationFilter(lFilter);
00499
00500 oMask = appCore->getRenderer()->getOrbitMask();
00501
00502 if (KGlobal::config()->hasKey("TimeZoneBias"))
00503 isLocal = (KGlobal::config()->readNumEntry("TimeZoneBias") != 0);
00504
00506
00507 KToggleAction* showStars = new KToggleAction(i18n("Show Stars"), 0, this, SLOT(slotShowStars()), actionCollection(), "showStars");
00508 showStars->setChecked(rFlags & Renderer::ShowStars);
00509
00510 KToggleAction* showPlanets = new KToggleAction(i18n("Show Planets"), 0, this, SLOT(slotShowPlanets()), actionCollection(), "showPlanets");
00511 showPlanets->setChecked(rFlags & Renderer::ShowPlanets);
00512
00513 KToggleAction* showGalaxies = new KToggleAction(i18n("Show Galaxies"), Key_U, this, SLOT(slotShowGalaxies()), actionCollection(), "showGalaxies");
00514 showGalaxies->setChecked(rFlags & Renderer::ShowGalaxies);
00515
00516 KToggleAction* showPartialTrajectories = new KToggleAction(i18n("Show Partial Trajectories"), 0, this, SLOT(slotShowPartialTrajectories()), actionCollection(), "showPartialTrajectories");
00517 showPartialTrajectories->setChecked(rFlags & Renderer::ShowPartialTrajectories);
00518
00519 KToggleAction* showNebulae = new KToggleAction(i18n("Show Nebulae"), Key_AsciiCircum, this, SLOT(slotShowNebulae()), actionCollection(), "showNebulae");
00520 showNebulae->setChecked(rFlags & Renderer::ShowNebulae);
00521
00522 KToggleAction* showOpenClusters = new KToggleAction(i18n("Show Open Clusters"), 0, this, SLOT(slotShowOpenClusters()), actionCollection(), "showOpenClusters");
00523 showOpenClusters->setChecked(rFlags & Renderer::ShowOpenClusters);
00524
00525 KToggleAction* showDiagrams = new KToggleAction(i18n("Show Constellations"), Key_Slash, this, SLOT(slotShowDiagrams()), actionCollection(), "showDiagrams");
00526 showDiagrams->setChecked(rFlags & Renderer::ShowDiagrams);
00527
00528 KToggleAction* showCloudMaps = new KToggleAction(i18n("Show CloudMaps"), Key_I, this, SLOT(slotShowCloudMaps()), actionCollection(), "showCloudMaps");
00529 showCloudMaps->setChecked(rFlags & Renderer::ShowCloudMaps);
00530
00531 KToggleAction* showOrbits = new KToggleAction(i18n("Show Orbits"), Key_O, this, SLOT(slotShowOrbits()), actionCollection(), "showOrbits");
00532 showOrbits->setChecked(rFlags & Renderer::ShowOrbits);
00533
00534 KToggleAction* showAsteroidOrbits = new KToggleAction(i18n("Show Asteroid Orbits"), 0, this, SLOT(slotShowAsteroidOrbits()), actionCollection(), "showAsteroidOrbits");
00535 showAsteroidOrbits->setChecked(oMask & Body::Asteroid);
00536
00537 KToggleAction* showCometOrbits = new KToggleAction(i18n("Show Comet Orbits"), 0, this, SLOT(slotShowCometOrbits()), actionCollection(), "showCometOrbits");
00538 showCometOrbits->setChecked(oMask & Body::Comet);
00539
00540 KToggleAction* showMoonOrbits = new KToggleAction(i18n("Show Moon Orbits"), 0, this, SLOT(slotShowMoonOrbits()), actionCollection(), "showMoonOrbits");
00541 showMoonOrbits->setChecked(oMask & Body::Moon);
00542
00543 KToggleAction* showPlanetOrbits = new KToggleAction(i18n("Show Planet Orbits"), 0, this, SLOT(slotShowPlanetOrbits()), actionCollection(), "showPlanetOrbits");
00544 showPlanetOrbits->setChecked(oMask & Body::Planet);
00545
00546 KToggleAction* showSpacecraftOrbits = new KToggleAction(i18n("Show Spacecraft Orbits"), 0, this, SLOT(slotShowSpacecraftOrbits()), actionCollection(), "showSpacecraftOrbits");
00547 showSpacecraftOrbits->setChecked(oMask & Body::Spacecraft);
00548
00549 KToggleAction* showCelestialSphere = new KToggleAction(i18n("Show Celestial Grid"), Key_Semicolon, this, SLOT(slotShowCelestialSphere()), actionCollection(), "showCelestialSphere");
00550 showCelestialSphere->setChecked(rFlags & Renderer::ShowCelestialSphere);
00551
00552 KToggleAction* showNightMaps = new KToggleAction(i18n("Show Night Side Lights"), CTRL + Key_L, this, SLOT(slotShowNightMaps()), actionCollection(), "showNightMaps");
00553 showNightMaps->setChecked(rFlags & Renderer::ShowNightMaps);
00554
00555 KToggleAction* showMarkers = new KToggleAction(i18n("Show Markers"), CTRL + Key_K, this, SLOT(slotShowMarkers()), actionCollection(), "showMarkers");
00556 showMarkers->setChecked(rFlags & Renderer::ShowMarkers);
00557
00558 KToggleAction* showAtmospheres = new KToggleAction(i18n("Show Atmospheres"), CTRL + Key_A, this, SLOT(slotShowAtmospheres()), actionCollection(), "showAtmospheres");
00559 showAtmospheres->setChecked(rFlags & Renderer::ShowAtmospheres);
00560
00561 KToggleAction* showSmoothLines = new KToggleAction(i18n("Show Smooth Orbit Lines"), CTRL + Key_X, this, SLOT(slotShowSmoothLines()), actionCollection(), "showSmoothLines");
00562 showSmoothLines->setChecked(rFlags & Renderer::ShowSmoothLines);
00563
00564 KToggleAction* showEclipseShadows = new KToggleAction(i18n("Show Eclipse Shadows"), CTRL + Key_E, this, SLOT(slotShowEclipseShadows()), actionCollection(), "showEclipseShadows");
00565 showEclipseShadows->setChecked(rFlags & Renderer::ShowEclipseShadows);
00566
00567 new KAction(i18n("Cycle Star Mode"), CTRL + Key_S, this, SLOT(slotCycleStarMode()), actionCollection(), "cycleStarMode");
00568
00569 KToggleAction* showRingShadows = new KToggleAction(i18n("Show Ring Shadows"), 0, this, SLOT(slotShowRingShadows()), actionCollection(), "showRingShadows");
00570 showRingShadows->setChecked(rFlags & Renderer::ShowRingShadows);
00571
00572 KToggleAction* showBoundaries = new KToggleAction(i18n("Show Boundaries"), CTRL + Key_B, this, SLOT(slotShowBoundaries()), actionCollection(), "showBoundaries");
00573 showBoundaries->setChecked(rFlags & Renderer::ShowBoundaries);
00574
00575 new KToggleAction(i18n("Auto Magnitudes"), CTRL + Key_Y, this, SLOT(slotShowAutoMag()), actionCollection(), "showAutoMag");
00576 showBoundaries->setChecked(rFlags & Renderer::ShowAutoMag);
00577
00578 KToggleAction* showCometTails = new KToggleAction(i18n("Show Comet Tails"), CTRL + Key_T, this, SLOT(slotShowCometTails()), actionCollection(), "showCometTails");
00579 showCometTails->setChecked(rFlags & Renderer::ShowCometTails);
00580
00581 KToggleAction* showStarLabels = new KToggleAction(i18n("Show Star Labels"), Key_B, this, SLOT(slotShowStarLabels()), actionCollection(), "showStarLabels");
00582 showStarLabels->setChecked(lMode & Renderer::StarLabels);
00583
00585
00586 KToggleAction* showPlanetLabels = new KToggleAction(i18n("Show Planet Labels"), Key_P, this, SLOT(slotShowPlanetLabels()), actionCollection(), "showPlanetLabels");
00587 showPlanetLabels->setChecked(lMode & Renderer::PlanetLabels);
00588
00589 KToggleAction* showMoonLabels = new KToggleAction(i18n("Show Moon Labels"), Key_M, this, SLOT(slotShowMoonLabels()), actionCollection(), "showMoonLabels");
00590 showMoonLabels->setChecked(lMode & Renderer::MoonLabels);
00591
00592 KToggleAction* showCometLabels = new KToggleAction(i18n("Show Comet Labels"), SHIFT + Key_W, this, SLOT(slotShowCometLabels()), actionCollection(), "showCometLabels");
00593 showMoonLabels->setChecked(lMode & Renderer::CometLabels);
00594
00595 KToggleAction* showConstellationLabels = new KToggleAction(i18n("Show Constellation Labels"), Key_Equal, this, SLOT(slotShowConstellationLabels()), actionCollection(), "showConstellationLabels");
00596 showConstellationLabels->setChecked(lMode & Renderer::ConstellationLabels);
00597
00598 KToggleAction* showI18nConstellationLabels = new KToggleAction(i18n("Constellation Labels in Latin"), 0, this, SLOT(slotShowI18nConstellationLabels()), actionCollection(), "showI18nConstellationLabels");
00599 showI18nConstellationLabels->setChecked(!(lMode & Renderer::I18nConstellationLabels));
00600
00601 KToggleAction* showGalaxyLabels = new KToggleAction(i18n("Show Galaxy Labels"), Key_E, this, SLOT(slotShowGalaxyLabels()), actionCollection(), "showGalaxyLabels");
00602 showGalaxyLabels->setChecked(lMode & Renderer::GalaxyLabels);
00603
00604 KToggleAction* showNebulaLabels = new KToggleAction(i18n("Show Nebula Labels"), 0, this, SLOT(slotShowNebulaLabels()), actionCollection(), "showNebulaLabels");
00605 showNebulaLabels->setChecked(lMode & Renderer::NebulaLabels);
00606
00607 KToggleAction* showOpenClusterLabels = new KToggleAction(i18n("Show Open Cluster Labels"), 0, this, SLOT(slotShowOpenClusterLabels()), actionCollection(), "showOpenClusterLabels");
00608 showOpenClusterLabels->setChecked(lMode & Renderer::OpenClusterLabels);
00609
00610 KToggleAction* showAsteroidLabels = new KToggleAction(i18n("Show Asteroid Labels"), Key_W, this, SLOT(slotShowAsteroidLabels()), actionCollection(), "showAsteroidLabels");
00611 showAsteroidLabels->setChecked(lMode & Renderer::AsteroidLabels);
00612
00613 KToggleAction* showSpacecraftLabels = new KToggleAction(i18n("Show Spacecraft Labels"), Key_N, this, SLOT(slotShowSpacecraftLabels()), actionCollection(), "showSpacecraftLabels");
00614 showSpacecraftLabels->setChecked(lMode & Renderer::SpacecraftLabels);
00615
00616 KToggleAction* showLocationLabels = new KToggleAction(i18n("Show Location Labels"), Key_Ampersand, this, SLOT(slotShowLocationLabels()), actionCollection(), "showLocationLabels");
00617 showLocationLabels->setChecked(lMode & Renderer::LocationLabels);
00618
00619 KToggleAction* displayLocalTime = new KToggleAction(i18n("Display Local Time"), ALT + Key_U, this, SLOT(slotDisplayLocalTime()), actionCollection(), "displayLocalTime");
00620 displayLocalTime->setChecked(isLocal);
00621
00623
00624 KToggleAction* showCityLocations = new KToggleAction(i18n("Show City Locations"), 0, this, SLOT(slotShowCityLocations()), actionCollection(), "showCityLocations");
00625 showCityLocations->setChecked(lFilter & Location::City);
00626
00627 KToggleAction* showObservatoryLocations = new KToggleAction(i18n("Show Observatory Locations"), 0, this, SLOT(slotShowObservatoryLocations()), actionCollection(), "showObservatoryLocations");
00628 showObservatoryLocations->setChecked(lFilter & Location::Observatory);
00629
00630 KToggleAction* showLandingSiteLocations = new KToggleAction(i18n("Show Landing Sites Locations"), 0, this, SLOT(slotShowLandingSiteLocations()), actionCollection(), "showLandingSiteLocations");
00631 showLandingSiteLocations->setChecked(lFilter & Location::LandingSite);
00632
00633 KToggleAction* showCraterLocations = new KToggleAction(i18n("Show Crater Locations"), 0, this, SLOT(slotShowCraterLocations()), actionCollection(), "showCraterLocations");
00634 showCraterLocations->setChecked(lFilter & Location::Crater);
00635
00636 KToggleAction* showMonsLocations = new KToggleAction(i18n("Show Mons Locations"), 0, this, SLOT(slotShowMonsLocations()), actionCollection(), "showMonsLocations");
00637 showMonsLocations->setChecked(lFilter & Location::Mons);
00638
00639 KToggleAction* showTerraLocations = new KToggleAction(i18n("Show Terra Locations"), 0, this, SLOT(slotShowTerraLocations()), actionCollection(), "showTerraLocations");
00640 showTerraLocations->setChecked(lFilter & Location::Terra);
00641
00642 KToggleAction* showVallisLocations = new KToggleAction(i18n("Show Vallis Locations"), 0, this, SLOT(slotShowVallisLocations()), actionCollection(), "showVallisLocations");
00643 showVallisLocations->setChecked(lFilter & Location::Vallis);
00644
00645 KToggleAction* showMareLocations = new KToggleAction(i18n("Show Mare Locations"), 0, this, SLOT(slotShowMareLocations()), actionCollection(), "showMareLocations");
00646 showMareLocations->setChecked(lFilter & Location::Mare);
00647
00648 KToggleAction* showOtherLocations = new KToggleAction(i18n("Show Other Locations"), 0, this, SLOT(slotShowOtherLocations()), actionCollection(), "showOtherLocations");
00649 showOtherLocations->setChecked(lFilter & FilterOtherLocations);
00651
00652 new KToggleAction(i18n("Wireframe Mode"), CTRL + Key_W, this, SLOT(slotWireframeMode()), actionCollection(), "wireframeMode");
00653
00654 new KAction(i18n("Center on Orbit"), SHIFT + Key_C, this, SLOT(slotCenterCO()), actionCollection(), "centerCO");
00655
00656
00657 KToggleAction *renderPath = 0;
00658 renderPath = new KToggleAction(i18n("Basic"), 0, this, SLOT(slotSetRenderPathBasic()), actionCollection(), "renderPathBasic");
00659 renderPath->setExclusiveGroup("renderPath");
00660 renderPath = new KToggleAction(i18n("Multitexture"), 0, this, SLOT(slotSetRenderPathMultitexture()), actionCollection(), "renderPathMultitexture");
00661 renderPath->setExclusiveGroup("renderPath");
00662 renderPath = new KToggleAction(i18n("NvCombiners"), 0, this, SLOT(slotSetRenderPathNvCombiner()), actionCollection(), "renderPathNvCombiner");
00663 renderPath->setExclusiveGroup("renderPath");
00664 renderPath = new KToggleAction(i18n("DOT3 ARBVP"), 0, this, SLOT(slotSetRenderPathDOT3ARBVP()), actionCollection(), "renderPathDOT3ARBVP");
00665 renderPath->setExclusiveGroup("renderPath");
00666 renderPath = new KToggleAction(i18n("NvCombiner NvVP"), 0, this, SLOT(slotSetRenderPathNvCombinerNvVP()), actionCollection(), "renderPathNvCombinerNvVP");
00667 renderPath->setExclusiveGroup("renderPath");
00668 renderPath = new KToggleAction(i18n("NvCombiner ARBVP"), 0, this, SLOT(slotSetRenderPathNvCombinerARBVP()), actionCollection(), "renderPathNvCombinerARBVP");
00669 renderPath->setExclusiveGroup("renderPath");
00670 renderPath = new KToggleAction(i18n("ARBFP ARBVP"), 0, this, SLOT(slotSetRenderPathARBFPARBVP()), actionCollection(), "renderPathARBFPARBVP");
00671 renderPath->setExclusiveGroup("renderPath");
00672 renderPath = new KToggleAction(i18n("NV30"), 0, this, SLOT(slotSetRenderPathNV30()), actionCollection(), "renderPathNV30");
00673 renderPath->setExclusiveGroup("renderPath");
00674 renderPath = new KToggleAction(i18n("OpenGL 2.0"), 0, this, SLOT(slotSetRenderPathGLSL()), actionCollection(), "renderPathGLSL");
00675 renderPath->setExclusiveGroup("renderPath");
00676 new KAction(i18n("Cycle OpenGL Render Path"), "reload", CTRL + Key_V, this, SLOT(slotCycleRenderPath()), actionCollection(), "cycleRenderPath");
00677
00678 new KAction(i18n("Grab Image"), "filesave", Key_F10, this, SLOT(slotGrabImage()), actionCollection(), "grabImage");
00679
00680 new KAction(i18n("OpenGL info"), 0, this, SLOT(slotOpenGLInfo()),
00681 actionCollection(), "opengl_info");
00682
00683 toggleMenubar=KStdAction::showMenubar(this, SLOT(slotToggleMenubar()), actionCollection());
00684 toggleToolbar=KStdAction::showToolbar(this, SLOT(slotToggleToolbar()), actionCollection());
00685
00686 new KToggleAction(i18n("Show Bookmark Toolbar"), 0, this,
00687 SLOT(slotShowBookmarkBar()), actionCollection(), "showBookmarkBar");
00688
00689 createGUI();
00690
00691 bookmarkBarActionCollection = new KActionCollection( this );
00692 bookmarkBarActionCollection->setHighlightingEnabled( true );
00693
00694 bookmarkBar = 0;
00695 initBookmarkBar();
00696 }
00697
00698 void KdeApp::initBookmarkBar() {
00699 KToolBar *bar = new KToolBar(this, QMainWindow::Top, true, "bookmarkBar");
00700
00701 if (bookmarkBar) delete bookmarkBar;
00702 bookmarkBar = new KBookmarkBar( KCelBookmarkManager::self(), this, bar, bookmarkBarActionCollection, 0, "bookmarkBar");
00703 if (bar->count() == 0) bar->hide();
00704
00705 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00706
00707 if (bar->isHidden()) ((KToggleAction*)actionCollection()->action("showBookmarkBar"))->setChecked(false);
00708 else ((KToggleAction*)actionCollection()->action("showBookmarkBar"))->setChecked(true);
00709 }
00710
00711
00712 bool KdeApp::queryExit() {
00713 KConfig* conf = kapp->config();
00714 saveMainWindowSettings(conf, "MainWindow");
00715 conf->setGroup("MainWindow");
00716 saveWindowSize(conf);
00717 conf->setGroup("Preferences");
00718 conf->writeEntry("RendererFlags", appCore->getRenderer()->getRenderFlags());
00719 conf->writeEntry("OrbitMask", appCore->getRenderer()->getOrbitMask());
00720 conf->writeEntry("LabelMode", appCore->getRenderer()->getLabelMode());
00721 conf->writeEntry("AmbientLightLevel", appCore->getRenderer()->getAmbientLightLevel());
00722 conf->writeEntry("FaintestVisible", appCore->getSimulation()->getFaintestVisible());
00723 conf->writeEntry("HudDetail", appCore->getHudDetail());
00724 conf->writeEntry("TimeZoneBias", appCore->getTimeZoneBias());
00725 conf->writeEntry("RenderPath", appCore->getRenderer()->getGLContext()->getRenderPath());
00726 conf->writeEntry("FramesVisible", appCore->getFramesVisible());
00727 conf->writeEntry("ActiveFrameVisible", appCore->getActiveFrameVisible());
00728 conf->writeEntry("SyncTime", appCore->getSimulation()->getSyncTime());
00729 conf->writeEntry("DistanceToScreen", appCore->getDistanceToScreen());
00730 conf->writeEntry("LocationFilter", appCore->getSimulation()->getActiveObserver()->getLocationFilter());
00731 conf->writeEntry("MinFeatureSize", appCore->getRenderer()->getMinimumFeatureSize());
00732 conf->setGroup(0);
00733 actionCollection()->writeShortcutSettings("Shortcuts", conf);
00734 openRecent->saveEntries(KGlobal::config());
00735 return true;
00736 }
00737
00738 bool KdeApp::queryClose() {
00739 KConfig* conf = kapp->config();
00740 saveMainWindowSettings(conf, "MainWindow");
00741 conf->setGroup("MainWindow");
00742 saveWindowSize(conf);
00743 conf->setGroup("Preferences");
00744 conf->writeEntry("RendererFlags", appCore->getRenderer()->getRenderFlags());
00745 conf->setGroup(0);
00746 return true;
00747 }
00748
00749
00750 void KdeApp::slotNull() {
00751
00752 }
00753
00754 void KdeApp::slotFullScreen() {
00755 static bool isFullScreen=false;
00756
00757 if (isFullScreen) {
00758 showNormal();
00759 action("fullScreen")->setIcon("window_fullscreen");
00760 } else {
00761 showFullScreen();
00762 action("fullScreen")->setIcon("window_nofullscreen");
00763 }
00764 isFullScreen = !isFullScreen;
00765 }
00766
00767 void KdeApp::slotHome() {
00768 appCore->charEntered('h');
00769 appCore->charEntered('g');
00770 }
00771
00772 void KdeApp::slotClose() {
00773 close();
00774 }
00775
00776 void KdeApp::slotZoomIn() {
00777 appCore->charEntered(',');
00778 }
00779
00780 void KdeApp::slotZoomOut() {
00781 appCore->charEntered('.');
00782 }
00783
00784 void KdeApp::slotToggleToolbar() {
00785 if (toolBar()->isVisible()) toolBar()->hide();
00786 else toolBar()->show();
00787 }
00788
00789 void KdeApp::slotToggleMenubar() {
00790 if (menuBar()->isVisible()) menuBar()->hide();
00791 else menuBar()->show();
00792 }
00793
00794 void KdeApp::slotToggleFramesVisible() {
00795 appCore->setFramesVisible(!appCore->getFramesVisible());
00796 }
00797
00798 void KdeApp::slotToggleActiveFrameVisible() {
00799 appCore->setActiveFrameVisible(!appCore->getActiveFrameVisible());
00800 }
00801
00802 void KdeApp::slotToggleSyncTime() {
00803 appCore->getSimulation()->setSyncTime(!appCore->getSimulation()->getSyncTime());
00804 }
00805
00806 void KdeApp::slotConfigureToolbars()
00807 {
00808 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00809 KEditToolbar dlg(actionCollection());
00810 connect( &dlg, SIGNAL(newToolbarConfig()), this, SLOT(slotNewToolbarConfig()));
00811 if (dlg.exec())
00812 {
00813 createGUI();
00814 initBookmarkBar();
00815 }
00816 }
00817
00818 void KdeApp::slotNewToolbarConfig()
00819 {
00820
00821 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00822 }
00823
00824 void KdeApp::slotKeyBindings()
00825 {
00826 KKeyDialog dlg(false, this);
00827 dlg.insert(actionCollection());
00828 if (dlg.exec()) {
00829 dlg.commitChanges();
00830 }
00831 }
00832
00833 void KdeApp::slotFileOpen()
00834 {
00835 #ifdef CELX
00836 QString fileOpen = KFileDialog::getOpenFileName(0, "*.cel *.celx");
00837 #else
00838 QString fileOpen = KFileDialog::getOpenFileName(0, "*.cel");
00839 #endif
00840 if (fileOpen == "") return;
00841
00842 slotOpenFileURL(KURL(fileOpen));
00843 }
00844
00845 void KdeApp::slotOpenFileURL(const KURL& url) {
00846 QString file = url.directory(false) + url.fileName();
00847
00848 #ifdef CELX
00849 if (file.right(5).compare(QString(".celx")) == 0) {
00850 openRecent->addURL(url);
00851 appCore->cancelScript();
00852 appCore->runScript(file.latin1());
00853 return;
00854 }
00855 #endif
00856
00857 ifstream scriptfile(file.latin1());
00858 if (!scriptfile.good()) {
00859 KMessageBox::error(this, "Error opening script file " + file);
00860 return;
00861 } else {
00862 CommandParser parser(scriptfile);
00863 CommandSequence* script = parser.parse();
00864 if (script == NULL) {
00865 const vector<string>* errors = parser.getErrors();
00866 const char* errorMsg = "";
00867 if (errors->size() > 0)
00868 errorMsg = (*errors)[0].c_str();
00869 KMessageBox::error(this, "Errors in script file " + file + "\n" + errorMsg);
00870 return;
00871 } else {
00872 openRecent->addURL(url);
00873 appCore->cancelScript();
00874 appCore->runScript(script);
00875 }
00876 }
00877 }
00878
00879
00880 QString KdeApp::getOpenGLInfo() {
00881
00882 char* vendor = (char*) glGetString(GL_VENDOR);
00883 char* render = (char*) glGetString(GL_RENDERER);
00884 char* version = (char*) glGetString(GL_VERSION);
00885 char* ext = (char*) glGetString(GL_EXTENSIONS);
00886 QString s;
00887 s = "Vendor : ";
00888 if (vendor != NULL)
00889 s += vendor;
00890 s += "\n";
00891
00892 s += "Renderer : ";
00893 if (render != NULL)
00894 s += render;
00895 s += "\n";
00896
00897 s += "Version : ";
00898 if (version != NULL)
00899 s += version;
00900 s += "\n";
00901
00902 char buf[100];
00903 GLint simTextures = 1;
00904 if (ExtensionSupported("GL_ARB_multitexture"))
00905 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &simTextures);
00906 sprintf(buf, "Max simultaneous textures: %d\n", simTextures);
00907 s += buf;
00908
00909 GLint maxTextureSize = 0;
00910 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
00911 sprintf(buf, "Max texture size: %d\n\n", maxTextureSize);
00912 s += buf;
00913
00914 s += "Supported Extensions:\n ";
00915 if (ext != NULL)
00916 {
00917 QString extString(ext);
00918 unsigned int pos = extString.find(' ', 0);
00919 while (pos != (unsigned int)string::npos)
00920 {
00921 extString.replace(pos, 1, "\n ");
00922 pos = extString.find(' ', pos+5);
00923 }
00924 s += extString;
00925 }
00926
00927 return s;
00928 }
00929
00930 void KdeApp::slotOpenGLInfo() {
00931 KDialogBase dlg(this, "openglinfo", true, i18n("OpenGL Info"), KDialogBase::Ok);
00932 QTextEdit edit(&dlg);
00933 edit.append(getOpenGLInfo());
00934 edit.setFocusPolicy(QWidget::NoFocus);
00935 dlg.setMainWidget(&edit);
00936 dlg.resize(400,430);
00937 dlg.exec();
00938 }
00939
00940 void KdeApp::slotPreferences() {
00941 KdePreferencesDialog dlg(this, appCore);
00942
00943 dlg.exec();
00944 resyncMenus();
00945 }
00946
00947 void KdeApp::slotSetTime() {
00948 KdePreferencesDialog dlg(this, appCore);
00949
00950 dlg.showPage(2);
00951 dlg.exec();
00952 }
00953
00954
00955 void KdeApp::slotFileOpenRecent(const KURL&)
00956 {
00957
00958 }
00959
00960 void KdeApp::slotReverseTime() {
00961 appCore->charEntered('j');
00962 }
00963
00964 void KdeApp::slotAccelerateTime() {
00965 appCore->charEntered('l');
00966 }
00967
00968 void KdeApp::slotPauseTime() {
00969 appCore->charEntered(' ');
00970 }
00971
00972 void KdeApp::slotSlowDownTime() {
00973 appCore->charEntered('k');
00974 }
00975
00976 void KdeApp::slotSetTimeNow() {
00977 time_t curtime=time(NULL);
00978 appCore->getSimulation()->setTime((double) curtime / 86400.0 + (double) astro::Date(1970, 1, 1));
00979 appCore->getSimulation()->update(0.0);
00980 }
00981
00982 void KdeApp::slotShowStars() {
00983 appCore->getRenderer()->setRenderFlags(
00984 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowStars);
00985 }
00986
00987 void KdeApp::slotShowPlanets() {
00988 appCore->getRenderer()->setRenderFlags(
00989 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowPlanets);
00990 }
00991
00992 void KdeApp::slotShowGalaxies() {
00993 appCore->getRenderer()->setRenderFlags(
00994 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowGalaxies);
00995 }
00996
00997 void KdeApp::slotShowPartialTrajectories() {
00998 appCore->getRenderer()->setRenderFlags(
00999 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowPartialTrajectories);
01000 }
01001
01002 void KdeApp::slotShowNebulae() {
01003 appCore->getRenderer()->setRenderFlags(
01004 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowNebulae);
01005 }
01006
01007 void KdeApp::slotShowOpenClusters() {
01008 appCore->getRenderer()->setRenderFlags(
01009 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowOpenClusters);
01010 }
01011
01012 void KdeApp::slotShowDiagrams() {
01013 appCore->getRenderer()->setRenderFlags(
01014 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowDiagrams);
01015 }
01016
01017 void KdeApp::slotShowCloudMaps() {
01018 appCore->getRenderer()->setRenderFlags(
01019 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowCloudMaps);
01020 }
01021
01022 void KdeApp::slotShowOrbits() {
01023 appCore->getRenderer()->setRenderFlags(
01024 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowOrbits);
01025 }
01026
01027 void KdeApp::slotShowAsteroidOrbits() {
01028 appCore->getRenderer()->setOrbitMask(
01029 appCore->getRenderer()->getOrbitMask() ^ Body::Asteroid);
01030 }
01031
01032 void KdeApp::slotShowCometOrbits() {
01033 appCore->getRenderer()->setOrbitMask(
01034 appCore->getRenderer()->getOrbitMask() ^ Body::Comet);
01035 }
01036
01037 void KdeApp::slotShowMoonOrbits() {
01038 appCore->getRenderer()->setOrbitMask(
01039 appCore->getRenderer()->getOrbitMask() ^ Body::Moon);
01040 }
01041
01042 void KdeApp::slotShowPlanetOrbits() {
01043 appCore->getRenderer()->setOrbitMask(
01044 appCore->getRenderer()->getOrbitMask() ^ Body::Planet);
01045 }
01046
01047 void KdeApp::slotShowSpacecraftOrbits() {
01048 appCore->getRenderer()->setOrbitMask(
01049 appCore->getRenderer()->getOrbitMask() ^ Body::Spacecraft);
01050 }
01051
01052 void KdeApp::slotShowCelestialSphere() {
01053 appCore->getRenderer()->setRenderFlags(
01054 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowCelestialSphere);
01055 }
01056
01057 void KdeApp::slotShowNightMaps() {
01058 appCore->getRenderer()->setRenderFlags(
01059 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowNightMaps);
01060 }
01061
01062 void KdeApp::slotShowMarkers() {
01063 appCore->charEntered('\013');
01064 }
01065
01066 void KdeApp::slotShowAtmospheres() {
01067 appCore->getRenderer()->setRenderFlags(
01068 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowAtmospheres);
01069 }
01070
01071 void KdeApp::slotShowSmoothLines() {
01072 appCore->getRenderer()->setRenderFlags(
01073 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowSmoothLines);
01074 }
01075
01076 void KdeApp::slotShowEclipseShadows() {
01077 appCore->getRenderer()->setRenderFlags(
01078 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowEclipseShadows);
01079 }
01080
01081 void KdeApp::slotCycleStarMode() {
01082 appCore->charEntered('\023');
01083 }
01084
01085 void KdeApp::slotShowRingShadows() {
01086 appCore->getRenderer()->setRenderFlags(
01087 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowRingShadows);
01088 }
01089
01090 void KdeApp::slotShowBoundaries() {
01091 appCore->getRenderer()->setRenderFlags(
01092 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowBoundaries);
01093 }
01094
01095 void KdeApp::slotShowAutoMag() {
01096 appCore->getRenderer()->setRenderFlags(
01097 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowAutoMag);
01098 }
01099
01100 void KdeApp::slotShowCometTails() {
01101 appCore->getRenderer()->setRenderFlags(
01102 appCore->getRenderer()->getRenderFlags() ^ Renderer::ShowCometTails);
01103 }
01104
01105 void KdeApp::slotShowStarLabels() {
01106 appCore->getRenderer()->setLabelMode(
01107 appCore->getRenderer()->getLabelMode() ^ Renderer::StarLabels);
01108 }
01109
01110 void KdeApp::slotShowPlanetLabels() {
01111 appCore->getRenderer()->setLabelMode(
01112 appCore->getRenderer()->getLabelMode() ^ Renderer::PlanetLabels);
01113 }
01114
01115 void KdeApp::slotShowMoonLabels() {
01116 appCore->getRenderer()->setLabelMode(
01117 appCore->getRenderer()->getLabelMode() ^ Renderer::MoonLabels);
01118 }
01119
01120 void KdeApp::slotShowCometLabels() {
01121 appCore->getRenderer()->setLabelMode(
01122 appCore->getRenderer()->getLabelMode() ^ Renderer::CometLabels);
01123 }
01124
01125 void KdeApp::slotShowConstellationLabels() {
01126 appCore->getRenderer()->setLabelMode(
01127 appCore->getRenderer()->getLabelMode() ^ Renderer::ConstellationLabels);
01128 }
01129
01130 void KdeApp::slotShowI18nConstellationLabels() {
01131 appCore->getRenderer()->setLabelMode(
01132 appCore->getRenderer()->getLabelMode() ^ Renderer::I18nConstellationLabels);
01133 }
01134
01135 void KdeApp::slotShowGalaxyLabels() {
01136 appCore->getRenderer()->setLabelMode(
01137 appCore->getRenderer()->getLabelMode() ^ Renderer::GalaxyLabels);
01138 }
01139
01140 void KdeApp::slotShowNebulaLabels() {
01141 appCore->getRenderer()->setLabelMode(
01142 appCore->getRenderer()->getLabelMode() ^ Renderer::NebulaLabels);
01143 }
01144
01145 void KdeApp::slotShowOpenClusterLabels() {
01146 appCore->getRenderer()->setLabelMode(
01147 appCore->getRenderer()->getLabelMode() ^ Renderer::OpenClusterLabels);
01148 }
01149
01150 void KdeApp::slotShowAsteroidLabels() {
01151 appCore->getRenderer()->setLabelMode(
01152 appCore->getRenderer()->getLabelMode() ^ Renderer::AsteroidLabels);
01153 }
01154
01155 void KdeApp::slotShowSpacecraftLabels() {
01156 appCore->getRenderer()->setLabelMode(
01157 appCore->getRenderer()->getLabelMode() ^ Renderer::SpacecraftLabels);
01158 }
01159
01160 void KdeApp::slotShowLocationLabels() {
01161 appCore->getRenderer()->setLabelMode(
01162 appCore->getRenderer()->getLabelMode() ^ Renderer::LocationLabels);
01163 }
01164
01165 void KdeApp::slotShowCityLocations() {
01166 Observer* obs = appCore->getSimulation()->getActiveObserver();
01167 int locationFilter = obs->getLocationFilter();
01168 obs->setLocationFilter(locationFilter ^ Location::City);
01169 }
01170
01171 void KdeApp::slotShowObservatoryLocations() {
01172 Observer* obs = appCore->getSimulation()->getActiveObserver();
01173 int locationFilter = obs->getLocationFilter();
01174 obs->setLocationFilter(locationFilter ^ Location::Observatory);
01175 }
01176
01177 void KdeApp::slotShowLandingSiteLocations() {
01178 Observer* obs = appCore->getSimulation()->getActiveObserver();
01179 int locationFilter = obs->getLocationFilter();
01180 obs->setLocationFilter(locationFilter ^ Location::LandingSite);
01181 }
01182
01183 void KdeApp::slotShowCraterLocations() {
01184 Observer* obs = appCore->getSimulation()->getActiveObserver();
01185 int locationFilter = obs->getLocationFilter();
01186 obs->setLocationFilter(locationFilter ^ Location::Crater);
01187 }
01188
01189 void KdeApp::slotShowMonsLocations() {
01190 Observer* obs = appCore->getSimulation()->getActiveObserver();
01191 int locationFilter = obs->getLocationFilter();
01192 obs->setLocationFilter(locationFilter ^ Location::Mons);
01193 }
01194
01195 void KdeApp::slotShowTerraLocations() {
01196 Observer* obs = appCore->getSimulation()->getActiveObserver();
01197 int locationFilter = obs->getLocationFilter();
01198 obs->setLocationFilter(locationFilter ^ Location::Terra);
01199 }
01200
01201 void KdeApp::slotShowVallisLocations() {
01202 Observer* obs = appCore->getSimulation()->getActiveObserver();
01203 int locationFilter = obs->getLocationFilter();
01204 obs->setLocationFilter(locationFilter ^ Location::Vallis);
01205 }
01206
01207 void KdeApp::slotShowMareLocations() {
01208 Observer* obs = appCore->getSimulation()->getActiveObserver();
01209 int locationFilter = obs->getLocationFilter();
01210 obs->setLocationFilter(locationFilter ^ Location::Mare);
01211 }
01212
01213 void KdeApp::slotShowOtherLocations() {
01214 Observer* obs = appCore->getSimulation()->getActiveObserver();
01215 int locationFilter = obs->getLocationFilter();
01216 obs->setLocationFilter(locationFilter ^ FilterOtherLocations);
01217 }
01218
01219 void KdeApp::slotMinFeatureSize(int size) {
01220 appCore->getRenderer()->setMinimumFeatureSize((float)size);
01221 }
01222
01223 void KdeApp::slotSplitH() {
01224 appCore->charEntered('\022');
01225 }
01226
01227 void KdeApp::slotSplitV() {
01228 appCore->charEntered('\025');
01229 }
01230
01231 void KdeApp::slotCycleView() {
01232 appCore->charEntered('\011');
01233 }
01234
01235 void KdeApp::slotAltAzMode() {
01236 appCore->charEntered('\006');
01237 }
01238
01239 void KdeApp::slotGoToSurface() {
01240 appCore->charEntered('\007');
01241 }
01242
01243 void KdeApp::slotSingleView() {
01244 appCore->charEntered('\004');
01245 }
01246
01247 void KdeApp::slotDeleteView() {
01248 appCore->charEntered(127);
01249 }
01250
01251 void KdeApp::slotAmbientLightLevel(float l) {
01252 appCore->getRenderer()->setAmbientLightLevel(l);
01253 }
01254
01255 void KdeApp::slotFaintestVisible(float m) {
01256 appCore->getSimulation()->setFaintestVisible(m);
01257 }
01258
01259 void KdeApp::slotHudDetail(int l) {
01260 appCore->setHudDetail(l);
01261 }
01262
01263 void KdeApp::slotDisplayLocalTime() {
01264 if (appCore->getTimeZoneBias()) {
01265 appCore->setTimeZoneBias(0);
01266 appCore->setTimeZoneName(i18n("UTC").latin1());
01267 } else {
01268 appCore->setTimeZoneBias(-timezone+3600*daylight);
01269 appCore->setTimeZoneName(tzname[daylight?0:1]);
01270 }
01271 }
01272
01273 void KdeApp::slotWireframeMode() {
01274 static bool mode = false;
01275 mode = !mode;
01276 renderer->setRenderMode(mode ? GL_LINE : GL_FILL);
01277 }
01278
01279 void KdeApp::slotCenterCO() {
01280 appCore->charEntered('C');
01281 }
01282
01283 void KdeApp::slotSetRenderPathBasic() {
01284 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_Basic)
01285 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_Basic);
01286 }
01287
01288 void KdeApp::slotSetRenderPathMultitexture() {
01289 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_Multitexture)
01290 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_Multitexture);
01291 }
01292
01293 void KdeApp::slotSetRenderPathNvCombiner() {
01294 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_NvCombiner)
01295 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_NvCombiner);
01296 }
01297 void KdeApp::slotSetRenderPathDOT3ARBVP() {
01298 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_DOT3_ARBVP)
01299 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_DOT3_ARBVP);
01300 }
01301 void KdeApp::slotSetRenderPathNvCombinerNvVP() {
01302 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_NvCombiner_NvVP)
01303 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_NvCombiner_NvVP);
01304 }
01305 void KdeApp::slotSetRenderPathNvCombinerARBVP() {
01306 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_NvCombiner_ARBVP)
01307 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_NvCombiner_ARBVP);
01308 }
01309 void KdeApp::slotSetRenderPathARBFPARBVP() {
01310 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_ARBFP_ARBVP)
01311 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_ARBFP_ARBVP);
01312 }
01313 void KdeApp::slotSetRenderPathNV30() {
01314 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_NV30)
01315 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_NV30);
01316 }
01317 void KdeApp::slotSetRenderPathGLSL() {
01318 if (appCore->getRenderer()->getGLContext()->getRenderPath() != GLContext::GLPath_GLSL)
01319 appCore->getRenderer()->getGLContext()->setRenderPath(GLContext::GLPath_GLSL);
01320 }
01321
01322 void KdeApp::slotCycleRenderPath() {
01323 appCore->charEntered('\026');
01324 }
01325
01326 void KdeApp::slotGrabImage() {
01327 QString saveAsName = KFileDialog::getSaveFileName(0, "*.png");
01328 if (saveAsName != "") {
01329 QImage grabedImage = glWidget->grabFrameBuffer();
01330 grabedImage.save(saveAsName, "PNG");
01331 }
01332 }
01333
01334 void KdeApp::slotShowBookmarkBar() {
01335 KToolBar * bar = static_cast<KToolBar *>( child( "bookmarkBar", "KToolBar" ) );
01336 if (bar->isVisible()) bar->hide();
01337 else bar->show();
01338 }
01339
01340 void KdeApp::slotBack() {
01341 appCore->back();
01342 }
01343
01344 void KdeApp::slotForward() {
01345 appCore->forward();
01346 }
01347
01348 void KdeApp::slotCopyUrl() {
01349 Url url(appCore);
01350 static QClipboard *cb = QApplication::clipboard();
01351 cb->setText(url.getAsString().c_str());
01352 }
01353
01354 void KdeApp::slotGoTo() {
01355 KLineEditDlg dlg(i18n("Enter URL"), "", this);
01356
01357 if (dlg.exec()) {
01358 appCore->addToHistory();
01359 appCore->goToUrl(dlg.text().latin1());
01360 }
01361 }
01362
01363 void KdeApp::slotGoToLongLat() {
01364 LongLatDialog dlg(this, appCore);
01365
01366 dlg.exec();
01367 }
01368
01369 void KdeApp::dragEnterEvent(QDragEnterEvent* event) {
01370 KURL::List urls;
01371 event->accept(KURLDrag::canDecode(event) && KURLDrag::decode(event, urls) && urls.first().protocol() == "cel");
01372 }
01373
01374 void KdeApp::dropEvent(QDropEvent* event) {
01375 KURL::List urls;
01376 if (KURLDrag::decode(event, urls) && urls.first().protocol() == "cel") {
01377 appCore->addToHistory();
01378 appCore->goToUrl(urls.first().url().latin1());
01379 }
01380 }
01381
01382 void KdeApp::slotBackAboutToShow() {
01383 int i;
01384 KPopupMenu* menu = backAction->popupMenu();
01385 std::vector<Url>::size_type current = appCore->getHistoryCurrent();
01386 int pos;
01387 std::vector<Url> history = appCore->getHistory();
01388
01389 menu->clear();
01390 for (i=0, pos = current - 1 ; pos >= 0 && i < 15 ; pos--, i++) {
01391 menu->insertItem(QString(history[pos].getName().c_str()), pos);
01392 }
01393 }
01394
01395 void KdeApp::slotBackActivated(int i) {
01396 appCore->setHistoryCurrent(i);
01397 }
01398
01399 void KdeApp::slotForwardAboutToShow() {
01400 int i;
01401 KPopupMenu* menu = forwardAction->popupMenu();
01402 std::vector<Url>::size_type current = appCore->getHistoryCurrent();
01403 std::vector<Url>::size_type pos;
01404 std::vector<Url> history = appCore->getHistory();
01405
01406 menu->clear();
01407 for (i=0, pos = current + 1 ; pos < history.size() && i < 15 ; pos++, i++) {
01408 menu->insertItem(QString(history[pos].getName().c_str()), pos);
01409 }
01410 }
01411
01412 void KdeApp::slotForwardActivated(int i) {
01413 appCore->setHistoryCurrent(i);
01414 }
01415
01416 void KdeApp::slotCelestialBrowser() {
01417 static CelestialBrowser *cb = new CelestialBrowser(this, appCore);
01418
01419 cb->show();
01420 cb->showNormal();
01421 cb->setActiveWindow();
01422 cb->raise();
01423 }
01424
01425 void KdeApp::slotEclipseFinder() {
01426 static EclipseFinderDlg *ef = new EclipseFinderDlg(this, appCore);
01427
01428 ef->show();
01429 ef->showNormal();
01430 ef->setActiveWindow();
01431 ef->raise();
01432 }
01433
01434 void KdeApp::popupMenu(float x, float y, Selection sel) {
01435 SelectionPopup popup(app, app->appCore, sel);
01436 popup.init();
01437 int id = popup.exec(app->glWidget->mapToGlobal(QPoint(int(x),int(y))));
01438 popup.process(id);
01439 }
01440
01441 LongLatDialog::LongLatDialog(QWidget* parent, CelestiaCore* appCore) :
01442 KDialogBase(parent, "long_lat", true, "Go to Long/Lat"), appCore(appCore)
01443 {
01444 QGrid* grid = makeGridMainWidget(3, Qt::Horizontal);
01445
01446
01447 QLabel* objLab = new QLabel(i18n("Object: "), grid);
01448 objLab->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01449 objEdit = new QLineEdit(grid);
01450 new QLabel("", grid);
01451
01452 QLabel* longLab = new QLabel(i18n("Longitude: "), grid);
01453 longLab->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01454 longEdit = new QLineEdit(grid);
01455 longEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01456 longEdit->setValidator(new QDoubleValidator(0, 180, 3, longEdit));
01457 longSign = new QComboBox( grid );
01458 longSign->insertItem(i18n("East", "E"));
01459 longSign->insertItem(i18n("West", "W"));
01460
01461 QLabel* latLab = new QLabel(i18n("Latitude: "), grid);
01462 latLab->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01463 latEdit = new QLineEdit(grid);
01464 latEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01465 latEdit->setValidator(new QDoubleValidator(0, 90, 3, latEdit));
01466 latSign = new QComboBox( grid );
01467 latSign->insertItem(i18n("North", "N"));
01468 latSign->insertItem(i18n("South", "S"));
01469
01470 QLabel* altLab = new QLabel(i18n("Altitude: "), grid);
01471 altLab->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01472 altEdit = new QLineEdit(grid);
01473 altEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
01474 altEdit->setValidator(new QDoubleValidator(altEdit));
01475 new QLabel(i18n("km"), grid);
01476
01477 double distance, longitude, latitude;
01478 appCore->getSimulation()->getSelectionLongLat(distance, longitude, latitude);
01479
01480 if (longitude < 0) {
01481 longitude = -longitude;
01482 longSign->setCurrentItem(1);
01483 }
01484 if (latitude < 0) {
01485 latitude = -latitude;
01486 latSign->setCurrentItem(1);
01487 }
01488
01489 Selection selection = appCore->getSimulation()->getSelection();
01490 QString objName(selection.getName().c_str());
01491 objEdit->setText(objName.mid(objName.findRev('/') + 1));
01492
01493 latEdit->setText(QString("%1").arg(latitude, 0, 'f', 3));
01494 longEdit->setText(QString("%1").arg(longitude, 0, 'f', 3));
01495 altEdit->setText(QString("%1").arg(distance - selection.radius(), 0, 'f', 0));
01496
01497 }
01498
01499 void LongLatDialog::slotCancel() {
01500 reject();
01501 }
01502
01503 void LongLatDialog::slotOk() {
01504 slotApply();
01505 accept();
01506 }KdeAlerter alerter;
01507
01508
01509 void LongLatDialog::slotApply() {
01510 Simulation* appSim = appCore->getSimulation();
01511 Selection sel = appSim->findObjectFromPath(objEdit->text().latin1());
01512 if (!sel.empty())
01513 {
01514 appSim->setSelection(sel);
01515 appSim->follow();
01516
01517 double altitude = altEdit->text().toDouble();
01518 if (altitude < 0.020) altitude = .020;
01519 double distance = altitude + sel.radius();
01520 distance = astro::kilometersToLightYears(distance);
01521
01522 double longitude = longEdit->text().toDouble();
01523 if (longSign->currentItem() == 1) {
01524 longitude = -longitude;
01525 }
01526
01527 double latitude = latEdit->text().toDouble();
01528 if (latSign->currentItem() == 1) {
01529 latitude = -latitude;
01530 }
01531
01532 appSim->gotoSelectionLongLat(5.0,
01533 distance,
01534 degToRad(longitude),
01535 degToRad(latitude),
01536 Vec3f(0, 1, 0));
01537 }
01538 }
01539
01540 KdeAlerter::KdeAlerter(QWidget* _parent) : parent(_parent)
01541 {}
01542
01543 void KdeAlerter::fatalError(const std::string& err)
01544 {
01545 KMessageBox::detailedError(parent, i18n("Celestia encountered an error while processing your script"), QString(err.c_str()));
01546 }
01547