kdepreferencesdialog.cpp
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:40k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /***************************************************************************
  2.                           kdepreferencesdialog.cpp  -  description
  3.                              -------------------
  4.     begin                : Sun Jul 21 2002
  5.     copyright            : (C) 2002 by chris
  6.     email                : chris@tux.teyssier.org
  7.  ***************************************************************************/
  8. /***************************************************************************
  9.  *                                                                         *
  10.  *   This program is free software; you can redistribute it and/or modify  *
  11.  *   it under the terms of the GNU General Public License as published by  *
  12.  *   the Free Software Foundation; either version 2 of the License, or     *
  13.  *   (at your option) any later version.                                   *
  14.  *                                                                         *
  15.  ***************************************************************************/
  16. #include <qvbox.h>
  17. #include <kmainwindow.h>
  18. #include <kpushbutton.h>
  19. #include <qtextedit.h>
  20. #include <qcombobox.h>
  21. #include <klocale.h>
  22. #include <kconfig.h>
  23. #include <kiconloader.h>
  24. #include <qframe.h>
  25. #include <qgrid.h>
  26. #include <qcheckbox.h>
  27. #include <qvgroupbox.h>
  28. #include <qslider.h>
  29. #include <kkeydialog.h>
  30. #include <qspinbox.h>
  31. #include <qlabel.h>
  32. #include <qlayout.h>
  33. #include <qlineedit.h>
  34. #include <qvalidator.h>
  35. #include "kdeapp.h"
  36. #include "kdepreferencesdialog.h"
  37. #include "celengine/render.h"
  38. #include "celengine/glcontext.h"
  39. #include "celengine/astro.h"
  40. static uint32 FilterOtherLocations = ~(Location::City |
  41.                     Location::Observatory |
  42.                     Location::LandingSite |
  43.                     Location::Crater |
  44.                     Location::Mons |
  45.                     Location::Terra |
  46.                     Location::Vallis |
  47.                     Location::Mare);
  48. KdePreferencesDialog::KdePreferencesDialog(QWidget* parent, CelestiaCore* core) :
  49.     KDialogBase (KDialogBase::IconList, "",
  50.     KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel, KDialogBase::Ok,parent)
  51. {
  52.     setCaption(i18n("Celestia Preferences"));
  53.     appCore=core;
  54.     this->parent = (KdeApp*)parent;
  55.     // Render page
  56.     QGrid* renderFrame = addGridPage(2, Qt::Horizontal, i18n("Rendering"), i18n("Rendering"),
  57.         KGlobal::iconLoader()->loadIcon("configure", KIcon::NoGroup));
  58.     int renderFlags = appCore->getRenderer()->getRenderFlags();
  59.     savedRendererFlags = renderFlags;
  60.     KActionCollection* actionColl = ((KdeApp*)parent)->actionCollection();
  61.     QGroupBox* showGroup = new QGroupBox(1, Qt::Horizontal, i18n("Show"), renderFrame);
  62.     QCheckBox* showStarsCheck = new QCheckBox(i18n("Stars"), showGroup);
  63.     actionColl->action("showStars")->connect(showStarsCheck, SIGNAL(clicked()), SLOT(activate()));
  64.     showStarsCheck->setChecked(renderFlags & Renderer::ShowStars);
  65.     QCheckBox* showAutoMagCheck = new QCheckBox(i18n("Auto Magnitudes"), showGroup);
  66.     actionColl->action("showAutoMag")->connect(showAutoMagCheck, SIGNAL(clicked()), SLOT(activate()));
  67.     showAutoMagCheck->setChecked(renderFlags & Renderer::ShowAutoMag);
  68.     QCheckBox* showPlanetsCheck = new QCheckBox(i18n("Planets"), showGroup);
  69.     actionColl->action("showPlanets")->connect(showPlanetsCheck, SIGNAL(clicked()), SLOT(activate()));
  70.     showPlanetsCheck->setChecked(renderFlags & Renderer::ShowPlanets);
  71.     QCheckBox* showGalaxiesCheck = new QCheckBox(i18n("Galaxies"), showGroup);
  72.     actionColl->action("showGalaxies")->connect(showGalaxiesCheck, SIGNAL(clicked()), SLOT(activate()));
  73.     showGalaxiesCheck->setChecked(renderFlags & Renderer::ShowGalaxies);
  74.     QCheckBox* showNebulaeCheck = new QCheckBox(i18n("Nebulae"), showGroup);
  75.     actionColl->action("showNebulae")->connect(showNebulaeCheck, SIGNAL(clicked()), SLOT(activate()));
  76.     showNebulaeCheck->setChecked(renderFlags & Renderer::ShowNebulae);
  77.     QCheckBox* showOpenClustersCheck = new QCheckBox(i18n("Open Clusters"), showGroup);
  78.     actionColl->action("showOpenClusters")->connect(showOpenClustersCheck, SIGNAL(clicked()), SLOT(activate()));
  79.     showOpenClustersCheck->setChecked(renderFlags & Renderer::ShowOpenClusters);
  80.     QCheckBox* showAtmospheresCheck = new QCheckBox(i18n("Atmospheres"), showGroup);
  81.     actionColl->action("showAtmospheres")->connect(showAtmospheresCheck, SIGNAL(clicked()), SLOT(activate()));
  82.     showAtmospheresCheck->setChecked(renderFlags & Renderer::ShowAtmospheres);
  83.     QCheckBox* showCloudMapsCheck = new QCheckBox(i18n("Clouds"), showGroup);
  84.     actionColl->action("showCloudMaps")->connect(showCloudMapsCheck, SIGNAL(clicked()), SLOT(activate()));
  85.     showCloudMapsCheck->setChecked(renderFlags & Renderer::ShowCloudMaps);
  86.     QCheckBox* showCloudShadowsCheck = new QCheckBox(i18n("Cloud Shadows"), showGroup);
  87.     actionColl->action("showCloudShadows")->connect(showCloudShadowsCheck, SIGNAL(clicked()), SLOT(activate()));
  88.     showCloudShadowsCheck->setChecked(renderFlags & Renderer::ShowCloudShadows);
  89.     QCheckBox* showNightMapsCheck = new QCheckBox(i18n("Night Side Lights"), showGroup);
  90.     actionColl->action("showNightMaps")->connect(showNightMapsCheck, SIGNAL(clicked()), SLOT(activate()));
  91.     showNightMapsCheck->setChecked(renderFlags & Renderer::ShowNightMaps);
  92.     QCheckBox* showEclipseShadowsCheck = new QCheckBox(i18n("Eclipse Shadows"), showGroup);
  93.     actionColl->action("showEclipseShadows")->connect(showEclipseShadowsCheck, SIGNAL(clicked()), SLOT(activate()));
  94.     showEclipseShadowsCheck->setChecked(renderFlags & Renderer::ShowEclipseShadows);
  95.     QCheckBox* showCometTailsCheck = new QCheckBox(i18n("Comet Tails"), showGroup);
  96.     actionColl->action("showCometTails")->connect(showCometTailsCheck, SIGNAL(clicked()), SLOT(activate()));
  97.     showCometTailsCheck->setChecked(renderFlags & Renderer::ShowCometTails);
  98.     QCheckBox* showOrbitsCheck = new QCheckBox(i18n("Orbits"), showGroup);
  99.     actionColl->action("showOrbits")->connect(showOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  100.     showOrbitsCheck->setChecked(renderFlags & Renderer::ShowOrbits);
  101.     QCheckBox* showPartialTrajectoriesCheck = new QCheckBox(i18n("Partial Trajectories"), showGroup);
  102.     actionColl->action("showPartialTrajectories")->connect(showPartialTrajectoriesCheck, SIGNAL(clicked()), SLOT(activate()));
  103.     showPartialTrajectoriesCheck->setChecked(renderFlags & Renderer::ShowPartialTrajectories);
  104.     QCheckBox* showSmoothLinesCheck = new QCheckBox(i18n("Smooth Orbit Lines"), showGroup);
  105.     actionColl->action("showSmoothLines")->connect(showSmoothLinesCheck, SIGNAL(clicked()), SLOT(activate()));
  106.     showSmoothLinesCheck->setChecked(renderFlags & Renderer::ShowSmoothLines);
  107.     QCheckBox* showCelestialSphereCheck = new QCheckBox(i18n("Celestial Grid"), showGroup);
  108.     actionColl->action("showCelestialSphere")->connect(showCelestialSphereCheck, SIGNAL(clicked()), SLOT(activate()));
  109.     showCelestialSphereCheck->setChecked(renderFlags & Renderer::ShowCelestialSphere);
  110.     QCheckBox* showDiagramsCheck = new QCheckBox(i18n("Constellations"), showGroup);
  111.     actionColl->action("showDiagrams")->connect(showDiagramsCheck, SIGNAL(clicked()), SLOT(activate()));
  112.     showDiagramsCheck->setChecked(renderFlags & Renderer::ShowDiagrams);
  113.     QCheckBox* showMarkersCheck = new QCheckBox(i18n("Markers"), showGroup);
  114.     actionColl->action("showMarkers")->connect(showMarkersCheck, SIGNAL(clicked()), SLOT(activate()));
  115.     showMarkersCheck->setChecked(renderFlags & Renderer::ShowMarkers);
  116.     QCheckBox* showRingShadowsCheck = new QCheckBox(i18n("Ring Shadows"), showGroup);
  117.     actionColl->action("showRingShadows")->connect(showRingShadowsCheck, SIGNAL(clicked()), SLOT(activate()));
  118.     showRingShadowsCheck->setChecked(renderFlags & Renderer::ShowRingShadows);
  119.     QCheckBox* showBoundariesCheck = new QCheckBox(i18n("Constellation Boundaries"), showGroup);
  120.     actionColl->action("showBoundaries")->connect(showBoundariesCheck, SIGNAL(clicked()), SLOT(activate()));
  121.     showBoundariesCheck->setChecked(renderFlags & Renderer::ShowBoundaries);
  122.     QVBox* vbox1 = new QVBox(renderFrame);
  123.     int labelMode = appCore->getRenderer()->getLabelMode();
  124.     savedLabelMode = labelMode;
  125.     int orbitMask = appCore->getRenderer()->getOrbitMask();
  126.     savedOrbitMask = orbitMask;
  127.     QGroupBox* labelGroup = new QGroupBox(0, Qt::Horizontal, i18n("Orbits / Labels"), vbox1);
  128.     QGridLayout* labelGroupLayout = new QGridLayout( labelGroup->layout() );
  129.     labelGroupLayout->setAlignment( Qt::AlignTop );
  130.     QLabel* orbitsLabel = new QLabel(i18n("Orbits"), labelGroup);
  131.     labelGroupLayout->addWidget(orbitsLabel, 0, 0);
  132.     QLabel* labelsLabel = new QLabel(i18n("Labels"), labelGroup);
  133.     labelGroupLayout->addWidget(labelsLabel, 0, 1);
  134.     QCheckBox* showStarOrbitsCheck = new QCheckBox("", labelGroup);
  135.     actionColl->action("showStarOrbits")->connect(showStarOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  136.     showStarOrbitsCheck->setChecked(orbitMask & Body::Stellar);
  137.     labelGroupLayout->addWidget(showStarOrbitsCheck, 1, 0, Qt::AlignHCenter);
  138.     QCheckBox* showStarLabelsCheck = new QCheckBox(i18n("Stars"), labelGroup);
  139.     actionColl->action("showStarLabels")->connect(showStarLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  140.     showStarLabelsCheck->setChecked(labelMode & Renderer::StarLabels);
  141.     labelGroupLayout->addWidget(showStarLabelsCheck, 1, 1);
  142.     QCheckBox* showPlanetOrbitsCheck = new QCheckBox("", labelGroup);
  143.     actionColl->action("showPlanetOrbits")->connect(showPlanetOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  144.     showPlanetOrbitsCheck->setChecked(orbitMask & Body::Planet);
  145.     labelGroupLayout->addWidget(showPlanetOrbitsCheck, 3, 0, Qt::AlignHCenter);
  146.     QCheckBox* showPlanetLabelsCheck = new QCheckBox(i18n("Planets"), labelGroup);
  147.     actionColl->action("showPlanetLabels")->connect(showPlanetLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  148.     showPlanetLabelsCheck->setChecked(labelMode & Renderer::PlanetLabels);
  149.     labelGroupLayout->addWidget(showPlanetLabelsCheck, 3, 1);
  150.     QCheckBox* showMoonOrbitsCheck = new QCheckBox("", labelGroup);
  151.     actionColl->action("showMoonOrbits")->connect(showMoonOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  152.     showMoonOrbitsCheck->setChecked(orbitMask & Body::Moon);
  153.     labelGroupLayout->addWidget(showMoonOrbitsCheck, 4, 0, Qt::AlignHCenter);
  154.     QCheckBox* showMoonLabelsCheck = new QCheckBox(i18n("Moons"), labelGroup);
  155.     actionColl->action("showMoonLabels")->connect(showMoonLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  156.     showMoonLabelsCheck->setChecked(labelMode & Renderer::MoonLabels);
  157.     labelGroupLayout->addWidget(showMoonLabelsCheck, 4, 1);
  158.     QCheckBox* showCometOrbitsCheck = new QCheckBox("", labelGroup);
  159.     actionColl->action("showCometOrbits")->connect(showCometOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  160.     showCometOrbitsCheck->setChecked(orbitMask & Body::Comet);
  161.     labelGroupLayout->addWidget(showCometOrbitsCheck, 5, 0, Qt::AlignHCenter);
  162.     QCheckBox* showCometLabelsCheck = new QCheckBox(i18n("Comets"), labelGroup);
  163.     actionColl->action("showCometLabels")->connect(showCometLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  164.     showCometLabelsCheck->setChecked(labelMode & Renderer::CometLabels);
  165.     labelGroupLayout->addWidget(showCometLabelsCheck, 5, 1);
  166.     QCheckBox* showConstellationLabelsCheck = new QCheckBox(i18n("Constellations"), labelGroup);
  167.     actionColl->action("showConstellationLabels")->connect(showConstellationLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  168.     showConstellationLabelsCheck->setChecked(labelMode & Renderer::ConstellationLabels);
  169.     labelGroupLayout->addWidget(showConstellationLabelsCheck, 6, 1);
  170.     QCheckBox* showI18nConstellationLabelsCheck = new QCheckBox(i18n("Constellations in Latin"), labelGroup);
  171.     actionColl->action("showI18nConstellationLabels")->connect(showI18nConstellationLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  172.     showI18nConstellationLabelsCheck->setChecked(!(labelMode & Renderer::I18nConstellationLabels));
  173.     labelGroupLayout->addWidget(showI18nConstellationLabelsCheck, 7, 1);
  174.     QCheckBox* showGalaxyLabelsCheck = new QCheckBox(i18n("Galaxies"), labelGroup);
  175.     actionColl->action("showGalaxyLabels")->connect(showGalaxyLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  176.     showGalaxyLabelsCheck->setChecked(labelMode & Renderer::GalaxyLabels);
  177.     labelGroupLayout->addWidget(showGalaxyLabelsCheck, 8, 1);
  178.     QCheckBox* showNebulaLabelsCheck = new QCheckBox(i18n("Nebulae"), labelGroup);
  179.     actionColl->action("showNebulaLabels")->connect(showNebulaLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  180.     showNebulaLabelsCheck->setChecked(labelMode & Renderer::NebulaLabels);
  181.     labelGroupLayout->addWidget(showNebulaLabelsCheck, 9, 1);
  182.     QCheckBox* showOpenClusterLabelsCheck = new QCheckBox(i18n("Open Clusters"), labelGroup);
  183.     actionColl->action("showOpenClusterLabels")->connect(showOpenClusterLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  184.     showOpenClusterLabelsCheck->setChecked(labelMode & Renderer::OpenClusterLabels);
  185.     labelGroupLayout->addWidget(showOpenClusterLabelsCheck, 10, 1);
  186.     QCheckBox* showAsteroidOrbitsCheck = new QCheckBox("", labelGroup);
  187.     actionColl->action("showAsteroidOrbits")->connect(showAsteroidOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  188.     showAsteroidOrbitsCheck->setChecked(orbitMask & Body::Asteroid);
  189.     labelGroupLayout->addWidget(showAsteroidOrbitsCheck, 11, 0, Qt::AlignHCenter);
  190.     QCheckBox* showAsteroidLabelsCheck = new QCheckBox(i18n("Asteroids"), labelGroup);
  191.     actionColl->action("showAsteroidLabels")->connect(showAsteroidLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  192.     showAsteroidLabelsCheck->setChecked(labelMode & Renderer::AsteroidLabels);
  193.     labelGroupLayout->addWidget(showAsteroidLabelsCheck, 11, 1);
  194.     QCheckBox* showSpacecraftOrbitsCheck = new QCheckBox("", labelGroup);
  195.     actionColl->action("showSpacecraftOrbits")->connect(showSpacecraftOrbitsCheck, SIGNAL(clicked()), SLOT(activate()));
  196.     showSpacecraftOrbitsCheck->setChecked(orbitMask & Body::Spacecraft);
  197.     labelGroupLayout->addWidget(showSpacecraftOrbitsCheck, 12, 0, Qt::AlignHCenter);
  198.     QCheckBox* showSpacecraftLabelsCheck = new QCheckBox(i18n("Spacecrafts"), labelGroup);
  199.     actionColl->action("showSpacecraftLabels")->connect(showSpacecraftLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  200.     showSpacecraftLabelsCheck->setChecked(labelMode & Renderer::SpacecraftLabels);
  201.     labelGroupLayout->addWidget(showSpacecraftLabelsCheck, 12, 1);
  202.     QCheckBox* showLocationLabelsCheck = new QCheckBox(i18n("Locations"), labelGroup);
  203.     actionColl->action("showLocationLabels")->connect(showLocationLabelsCheck, SIGNAL(clicked()), SLOT(activate()));
  204.     showLocationLabelsCheck->setChecked(labelMode & Renderer::LocationLabels);
  205.     labelGroupLayout->addWidget(showLocationLabelsCheck, 13, 1);
  206.     QSpacerItem* spacer = new QSpacerItem( 151, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
  207.     labelGroupLayout->addItem( spacer, 0, 2 );
  208.     savedAmbientLightLevel = int(appCore->getRenderer()->getAmbientLightLevel() * 100);
  209.     QGroupBox* ambientLightGroup = new QGroupBox(1, Qt::Vertical, i18n("Ambient Light"), vbox1);
  210.     QSlider* ambientLightSlider = new QSlider(0, 25, 1, savedAmbientLightLevel, Qt::Horizontal, ambientLightGroup);
  211.     connect(ambientLightSlider, SIGNAL(valueChanged(int)), SLOT(slotAmbientLightLevel(int)));
  212.     ambientLabel = new QLabel(ambientLightGroup);
  213.     ambientLabel->setMinimumWidth(40);
  214.     ambientLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  215.     char buff[20];
  216.     sprintf(buff, "%.2f", savedAmbientLightLevel / 100.);
  217.     ambientLabel->setText(buff);
  218.     savedFaintestVisible = int(appCore->getSimulation()->getFaintestVisible() * 100);
  219.     QGroupBox* faintestVisibleGroup = new QGroupBox(1, Qt::Vertical, i18n("Limiting Magnitude"), vbox1);
  220.     QSlider* faintestVisibleSlider = new QSlider(1, 1200, 1, savedFaintestVisible, Qt::Horizontal, faintestVisibleGroup);
  221.     connect(faintestVisibleSlider, SIGNAL(valueChanged(int)), SLOT(slotFaintestVisible(int)));
  222.     faintestLabel = new QLabel(faintestVisibleGroup);
  223.     faintestLabel->setMinimumWidth(40);
  224.     faintestLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  225.     sprintf(buff, "%.2f", savedFaintestVisible / 100.);
  226.     faintestLabel->setText(buff);
  227.     QGroupBox* infoTextGroup = new QGroupBox(1, Qt::Vertical, i18n("Info Text"), vbox1);
  228.     new QLabel(i18n("Level: "), infoTextGroup);
  229.     QComboBox* infoTextCombo = new QComboBox(infoTextGroup);
  230.     infoTextCombo->insertItem(i18n("None"));
  231.     infoTextCombo->insertItem(i18n("Terse"));
  232.     infoTextCombo->insertItem(i18n("Verbose"));
  233.     savedHudDetail = appCore->getHudDetail();
  234.     infoTextCombo->setCurrentItem(savedHudDetail);
  235.     ((KdeApp*)parent)->connect(infoTextCombo, SIGNAL(activated(int)), SLOT(slotHudDetail(int)));
  236.     QGroupBox* textureGroup = new QGroupBox(1, Qt::Vertical, i18n("Textures"), vbox1);
  237.     new QLabel(i18n("Resolution: "), textureGroup);
  238.     QComboBox* textureResCombo = new QComboBox(textureGroup);
  239.     textureResCombo->insertItem(i18n("Low"));
  240.     textureResCombo->insertItem(i18n("Medium"));
  241.     textureResCombo->insertItem(i18n("High"));
  242.     savedTextureRes = appCore->getRenderer()->getResolution();
  243.     textureResCombo->setCurrentItem(savedTextureRes);
  244.     connect(textureResCombo, SIGNAL(activated(int)), SLOT(slotTextureRes(int)));
  245.     QGroupBox* fovGroup = new QGroupBox(2, Qt::Horizontal, i18n("Automatic FOV"), vbox1);
  246.     new QLabel(i18n("Screen DPI: "), fovGroup);
  247.     new QLabel(QString::number(appCore->getScreenDpi(), 10), fovGroup);
  248.     new QLabel(i18n("Viewing Distance (cm): "), fovGroup);
  249.     dtsSpin = new QSpinBox(10, 300, 1, fovGroup);
  250.     savedDistanceToScreen = appCore->getDistanceToScreen();
  251.     dtsSpin->setValue(savedDistanceToScreen / 10);
  252.     connect(dtsSpin, SIGNAL(valueChanged(int)), SLOT(slotDistanceToScreen(int)));
  253.     // Locations page
  254.     Observer* obs = appCore->getSimulation()->getActiveObserver();
  255.     savedLocationFilter = obs->getLocationFilter();
  256.     QFrame* locationsFrame = addPage(i18n("Locations"), i18n("Locations"),
  257.        KGlobal::iconLoader()->loadIcon("package_network", KIcon::NoGroup));
  258.     QVBoxLayout* locationsLayout = new QVBoxLayout( locationsFrame );
  259.     locationsLayout->setAutoAdd(TRUE);
  260.     locationsLayout->setAlignment(Qt::AlignTop);
  261.     QCheckBox* showCityLocationsCheck = new QCheckBox(i18n("Cities"), locationsFrame);
  262.     actionColl->action("showCityLocations")->connect(showCityLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  263.     showCityLocationsCheck->setChecked(savedLocationFilter & Location::City);
  264.     QCheckBox* showObservatoryLocationsCheck = new QCheckBox(i18n("Observatories"), locationsFrame);
  265.     actionColl->action("showObservatoryLocations")->connect(showObservatoryLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  266.     showObservatoryLocationsCheck->setChecked(savedLocationFilter & Location::Observatory);
  267.     QCheckBox* showLandingSiteLocationsCheck = new QCheckBox(i18n("Landing Sites"), locationsFrame);
  268.     actionColl->action("showLandingSiteLocations")->connect(showLandingSiteLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  269.     showLandingSiteLocationsCheck->setChecked(savedLocationFilter & Location::LandingSite);
  270.     QCheckBox* showCraterLocationsCheck = new QCheckBox(i18n("Craters"), locationsFrame);
  271.     actionColl->action("showCraterLocations")->connect(showCraterLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  272.     showCraterLocationsCheck->setChecked(savedLocationFilter & Location::Crater);
  273.     QCheckBox* showMonsLocationsCheck = new QCheckBox(i18n("Mons"), locationsFrame);
  274.     actionColl->action("showMonsLocations")->connect(showMonsLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  275.     showMonsLocationsCheck->setChecked(savedLocationFilter & Location::Mons);
  276.     QCheckBox* showTerraLocationsCheck = new QCheckBox(i18n("Terra"), locationsFrame);
  277.     actionColl->action("showTerraLocations")->connect(showTerraLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  278.     showTerraLocationsCheck->setChecked(savedLocationFilter & Location::Terra);
  279.     QCheckBox* showVallisLocationsCheck = new QCheckBox(i18n("Vallis"), locationsFrame);
  280.     actionColl->action("showVallisLocations")->connect(showVallisLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  281.     showVallisLocationsCheck->setChecked(savedLocationFilter & Location::Vallis);
  282.     QCheckBox* showMareLocationsCheck = new QCheckBox(i18n("Mare"), locationsFrame);
  283.     actionColl->action("showMareLocations")->connect(showMareLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  284.     showMareLocationsCheck->setChecked(savedLocationFilter & Location::Mare);
  285.     QCheckBox* showOtherLocationsCheck = new QCheckBox(i18n("Other"), locationsFrame);
  286.     actionColl->action("showOtherLocations")->connect(showOtherLocationsCheck, SIGNAL(clicked()), SLOT(activate()));
  287.     showOtherLocationsCheck->setChecked(savedLocationFilter & FilterOtherLocations);
  288.     QGroupBox* minFeatureSizeGroup = new QGroupBox(1, Qt::Vertical, i18n("Minimum Feature Size"), locationsFrame);
  289.     minFeatureSizeGroup->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
  290.     savedMinFeatureSize = (int)appCore->getRenderer()->getMinimumFeatureSize();
  291.     QSlider* minFeatureSizeSlider = new QSlider(1, 1000, 1, savedMinFeatureSize, Qt::Horizontal, minFeatureSizeGroup);
  292.     connect(minFeatureSizeSlider, SIGNAL(valueChanged(int)), SLOT(slotMinFeatureSize(int)));
  293.     minFeatureSizeLabel = new QLabel(minFeatureSizeGroup);
  294.     minFeatureSizeLabel->setMinimumWidth(40);
  295.     minFeatureSizeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  296.     sprintf(buff, "%d", savedMinFeatureSize);
  297.     minFeatureSizeLabel->setText(buff);
  298.     // Time page
  299.     timeHasChanged = false;
  300.     QVBox* timeFrame = addVBoxPage(i18n("Date/Time"), i18n("Date/Time"),
  301.         KGlobal::iconLoader()->loadIcon("clock", KIcon::NoGroup));
  302.     savedDisplayLocalTime = appCore->getTimeZoneBias();
  303.     QGroupBox* displayTimezoneGroup = new QGroupBox(1, Qt::Horizontal, i18n("Display"), timeFrame);
  304.     QHBox *hbox0 = new QHBox(displayTimezoneGroup);
  305.     new QLabel(i18n("Timezone: "), hbox0);
  306.     displayTimezoneCombo = new QComboBox(hbox0);
  307.     displayTimezoneCombo->insertItem(i18n("UTC"));
  308.     displayTimezoneCombo->insertItem(i18n("Local Time"));
  309.     displayTimezoneCombo->setCurrentItem((appCore->getTimeZoneBias()==0)?0:1);
  310.     ((KdeApp*)parent)->connect(displayTimezoneCombo, SIGNAL(activated(int)), SLOT(slotDisplayLocalTime()));
  311.     displayTimezoneGroup->addSpace(0);
  312.     QHBox *hbox1 = new QHBox(displayTimezoneGroup);
  313.     new QLabel(i18n("Format: "), hbox1);
  314.     QComboBox *timeFormatCombo = new QComboBox(hbox1);
  315.     timeFormatCombo->insertItem(i18n("Local Format"));
  316.     timeFormatCombo->insertItem("YYYY MMM DD HH:MM:SS TZ");
  317.     timeFormatCombo->insertItem("YYYY MMM DD HH:MM:SS Offset");
  318.     savedDateFormat = appCore->getDateFormat();
  319.     timeFormatCombo->setCurrentItem((int)savedDateFormat);
  320.     connect(timeFormatCombo, SIGNAL(activated(int)), SLOT(slotDateFormat(int)));
  321.     QGroupBox* setTimezoneGroup = new QGroupBox(1, Qt::Horizontal, i18n("Set"), timeFrame);
  322.     new QLabel(i18n("Local Time is only supported for dates between 1902 and 2037.n"), setTimezoneGroup);
  323.     QHBox *hbox2 = new QHBox(setTimezoneGroup);
  324.     new QLabel(i18n("Timezone: "), hbox2);
  325.     setTimezoneCombo = new QComboBox(hbox2);
  326.     setTimezoneCombo->insertItem(i18n("UTC"));
  327.     setTimezoneCombo->insertItem(i18n("Local Time"));
  328. //    setTimezoneCombo->setCurrentItem((appCore->getTimeZoneBias()==0)?0:1);
  329.     KGlobal::config()->setGroup("ConfigureDialog");
  330.     if (KGlobal::config()->hasKey("SetTimeTimeZoneLocal"))
  331.         setTimezoneCombo->setCurrentItem(KGlobal::config()->readNumEntry("SetTimeTimeZoneLocal"));
  332.     KGlobal::config()->setGroup(0);
  333.     connect(setTimezoneCombo, SIGNAL(activated(int)), SLOT(slotTimeHasChanged()));
  334.     QHBox *hboxdate = new QHBox(setTimezoneGroup);
  335.     QLabel* spacerdate1 = new QLabel(" ", hboxdate);
  336.     timeFrame->setStretchFactor(spacerdate1, 2);
  337.     YSpin = new QSpinBox(-1000000000, 1000000000, 1, hboxdate);
  338.     YSpin->setWrapping(true);
  339.     MSpin = new QSpinBox(1, 12, 1, hboxdate);
  340.     MSpin->setWrapping(true);
  341.     DSpin = new QSpinBox(1, 31, 1, hboxdate);
  342.     DSpin->setWrapping(true);
  343.     QLabel* spacerdate2 = new QLabel(" ", hboxdate);
  344.     timeFrame->setStretchFactor(spacerdate2, 2);
  345.     QVBox *vbox3 = new QVBox(setTimezoneGroup);
  346.     QHBox *hbox3 = new QHBox(vbox3);
  347.     QLabel* spacer1 = new QLabel(" ", hbox3);
  348.     hbox3->setStretchFactor(spacer1, 10);
  349.     hSpin = new QSpinBox(0, 23, 1, hbox3);
  350.     hSpin->setWrapping(true);
  351.     new QLabel(":", hbox3);
  352.     mSpin = new QSpinBox(0, 59, 1, hbox3);
  353.     mSpin->setWrapping(true);
  354.     new QLabel(":", hbox3);
  355.     sSpin = new QSpinBox(0, 59, 1, hbox3);
  356.     sSpin->setWrapping(true);
  357.     QLabel* spacer2 = new QLabel(" ", hbox3);
  358.     hbox3->setStretchFactor(spacer2, 10);
  359.     QLabel* spacer3 = new QLabel(" ", timeFrame);
  360.     timeFrame->setStretchFactor(spacer3, 2);
  361.     QHBox *hbox4 = new QHBox(setTimezoneGroup);
  362.     new QLabel(i18n("Julian Date: "), hbox4);
  363.     new QLabel(" ", hbox4);
  364.     julianDateEdit = new QLineEdit(hbox4);
  365.     QDoubleValidator *julianDateValidator = new QDoubleValidator(julianDateEdit);
  366.     julianDateEdit->setValidator(julianDateValidator);
  367.     julianDateEdit->setAlignment(Qt::AlignRight);
  368.     connect(julianDateEdit, SIGNAL(lostFocus()), SLOT(slotJDHasChanged()));
  369.     setTime(astro::TDBtoUTC(appCore->getSimulation()->getTime()));
  370.     connect(YSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  371.     connect(MSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  372.     connect(DSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  373.     connect(hSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  374.     connect(mSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  375.     connect(sSpin, SIGNAL(valueChanged(int)), SLOT(slotTimeHasChanged()));
  376.     KPushButton *nowButton = new KPushButton(setTimezoneGroup);
  377.     nowButton->setText(i18n("Now"));
  378.     QSizePolicy nowButtonSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
  379.     nowButton->setSizePolicy(nowButtonSizePolicy);
  380.     connect(nowButton, SIGNAL(clicked()), SLOT(setNow()));
  381.     Selection selection = appCore->getSimulation()->getSelection();
  382.     std::string sel_name;
  383.     if (selection.body() != 0) {
  384.         QHBox* ltBox = new QHBox(setTimezoneGroup);
  385.         char time[50];
  386.         sel_name = selection.body()->getName();
  387.         Vec3d v = selection.getPosition(appCore->getSimulation()->getTime()) -
  388.                   appCore->getSimulation()->getObserver().getPosition();
  389.         double dist = astro::lightYearsToKilometers(v.length()*1e-6);
  390.         double lt = dist / astro::speedOfLight;
  391.         long lt_h = (long)(lt / 3600);
  392.         int lt_m = (int)((lt - lt_h * 3600) / 60);
  393.         double lt_s = (lt - lt_h * 3600 - lt_m * 60);
  394.         if (lt_h == 0) snprintf(time, 50, "%d min %02.1f s", lt_m, lt_s);
  395.         else snprintf(time, 50, "%ld h %02d min %02.1f s", lt_h, lt_m, lt_s);
  396.         new QLabel(i18n("nSelection: " + QString(sel_name.c_str())
  397.         + QString("nLight Travel Time: %2").arg(time)), ltBox);
  398.         KPushButton *ltButton = new KPushButton(ltBox);
  399.         ltButton->setToggleButton(true);
  400.         if (!appCore->getLightDelayActive())
  401.             ltButton->setText(i18n("Include Light Travel Time"));
  402.         else
  403.             ltButton->setText(i18n("Ignore Light Travel Time "));
  404.         ltButton->setSizePolicy(nowButtonSizePolicy);
  405.         connect(ltButton, SIGNAL(clicked()), SLOT(ltSubstract()));
  406.     }
  407.     // OpenGL Page
  408.     QVBox* openGL = addVBoxPage(i18n("OpenGL"), i18n("OpenGL"),
  409.         KGlobal::iconLoader()->loadIcon("misc", KIcon::NoGroup));
  410.     renderPathCombo = new QComboBox(openGL);
  411.     savedRenderPath = (int)appCore->getRenderer()->getGLContext()->getRenderPath();
  412.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_Basic))
  413.         renderPathCombo->insertItem(i18n("Basic"));
  414.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_Multitexture))
  415.         renderPathCombo->insertItem(i18n("Multitexture"));
  416.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_NvCombiner))
  417.         renderPathCombo->insertItem(i18n("NvCombiners"));
  418.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_DOT3_ARBVP))
  419.         renderPathCombo->insertItem(i18n("DOT3 ARBVP"));
  420.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_NvCombiner_NvVP))
  421.         renderPathCombo->insertItem(i18n("NvCombiner NvVP"));
  422.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_NvCombiner_ARBVP))
  423.         renderPathCombo->insertItem(i18n("NvCombiner ARBVP"));
  424.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_ARBFP_ARBVP))
  425.         renderPathCombo->insertItem(i18n("ARBFP ARBVP"));
  426.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_NV30))
  427.         renderPathCombo->insertItem(i18n("NV30"));
  428.     if (appCore->getRenderer()->getGLContext()->renderPathSupported(GLContext::GLPath_GLSL))
  429.         renderPathCombo->insertItem(i18n("OpenGL 2.0"));
  430.     connect(renderPathCombo, SIGNAL(activated(int)), SLOT(slotRenderPath(int)));
  431.     {
  432.         int path=0, ipathIdx=0;
  433.         while (path != appCore->getRenderer()->getGLContext()->getRenderPath()) {
  434.             ipathIdx++;
  435.             do {
  436.                 path++;
  437.             } while (!appCore->getRenderer()->getGLContext()->renderPathSupported((GLContext::GLRenderPath)path));
  438.         }
  439.         renderPathCombo->setCurrentItem(ipathIdx);
  440.     }
  441.     renderPathLabel = new QLabel(openGL);
  442.     renderPathLabel->setTextFormat(Qt::RichText);
  443.     setRenderPathLabel();
  444.     QCheckBox* videoSyncCheck = new QCheckBox(i18n("Sync framerate to video refresh rate"), openGL);
  445.     actionColl->action("toggleVideoSync")->connect(videoSyncCheck, SIGNAL(clicked()), SLOT(activate()));
  446.     savedVideoSync = appCore->getRenderer()->getVideoSync();
  447.     videoSyncCheck->setChecked(savedVideoSync);
  448.     QTextEdit* edit = new QTextEdit(openGL);
  449.     edit->append(((KdeApp*)parent)->getOpenGLInfo());
  450.     edit->setFocusPolicy(QWidget::NoFocus);
  451.     edit->setCursorPosition(0, 0);
  452.     // Key bindings page
  453.     QVBox* keyBindings = addVBoxPage(i18n("Key Bindings"), i18n("Key Bindings"),
  454.         KGlobal::iconLoader()->loadIcon("key_bindings", KIcon::NoGroup));
  455.     keyChooser = new KKeyChooser(((KMainWindow*)parent)->actionCollection(), keyBindings, false);
  456.     resize(550,400);
  457. }
  458. KdePreferencesDialog::~KdePreferencesDialog() {
  459. }
  460. void KdePreferencesDialog::setNow() {
  461.     time_t date_t;
  462.     time(&date_t);
  463.     struct tm* tm;
  464.     if (setTimezoneCombo->currentItem() != 0) {
  465.         tm = localtime ( &date_t);
  466.     } else {
  467.         tm = gmtime ( &date_t);
  468.     }
  469.     YSpin->setValue(tm->tm_year + 1900);
  470.     MSpin->setValue(tm->tm_mon + 1);
  471.     DSpin->setValue(tm->tm_mday);
  472.     hSpin->setValue(tm->tm_hour);
  473.     mSpin->setValue(tm->tm_min);
  474.     sSpin->setValue(tm->tm_sec);
  475. }
  476. void KdePreferencesDialog::ltSubstract() {
  477.     double d;
  478.     d = getTime();
  479.     Selection selection = appCore->getSimulation()->getSelection();
  480.     std::string sel_name;
  481.     // LT-delay only for solar bodies && target-speed < 0.99 c
  482.     if (selection.body() != 0 &&
  483.         (appCore->getSimulation()->getTargetSpeed() < 0.99 *
  484.             astro::kilometersToMicroLightYears(astro::speedOfLight))) {
  485.         sel_name = selection.body()->getName();
  486.         Vec3d v = selection.getPosition(d) -
  487.                   appCore->getSimulation()->getObserver().getPosition();
  488.         appCore->setLightDelayActive(!appCore->getLightDelayActive());
  489.         double dist = astro::lightYearsToKilometers(v.length()*1e-6);
  490.         double lt = dist / astro::speedOfLight;
  491.         if (appCore->getLightDelayActive())
  492.         d -= lt / 86400.;
  493.         else
  494.             d += lt / 86400.;
  495.     setTime(d);
  496.     }
  497. }
  498. void KdePreferencesDialog::setTime(double d) {
  499.     if (setTimezoneCombo->currentItem() != 0 && d < 2465442 && d > 2415733) {
  500.         time_t date_t = (int) astro::julianDateToSeconds( d - (float)astro::Date(1970, 1, 1) );
  501.         struct tm* tm;
  502.         tm = localtime ( &date_t);
  503.         YSpin->setValue(tm->tm_year + 1900);
  504.         MSpin->setValue(tm->tm_mon + 1);
  505.         DSpin->setValue(tm->tm_mday);
  506.         hSpin->setValue(tm->tm_hour);
  507.         mSpin->setValue(tm->tm_min);
  508.         sSpin->setValue(tm->tm_sec);
  509.     } else {
  510.         astro::Date date(d);
  511.         YSpin->setValue(date.year);
  512.         MSpin->setValue(date.month);
  513.         DSpin->setValue(date.day);
  514.         hSpin->setValue(date.hour);
  515.         mSpin->setValue(date.minute);
  516.         sSpin->setValue(int(date.seconds));
  517.     }
  518.     QString jd;
  519.     julianDateEdit->setText(jd.setNum(d, 'f'));
  520. }
  521. double KdePreferencesDialog::getTime() const {
  522.     double d;
  523.     if (setTimezoneCombo->currentItem() == 0 || YSpin->value() < 1902 || YSpin->value() > 2037) {
  524.         astro::Date date(0.0);
  525.         date.year=YSpin->value();
  526.         date.month=MSpin->value();
  527.         date.day=DSpin->value();
  528.         date.hour=hSpin->value();
  529.         date.minute=mSpin->value();
  530.         date.seconds=float(sSpin->value());
  531.         d = (double) date;
  532.     } else {
  533.         struct tm time;
  534.         time.tm_year = YSpin->value() - 1900;
  535.         time.tm_mon = MSpin->value() - 1;
  536.         time.tm_mday = DSpin->value();
  537.         time.tm_hour = hSpin->value();
  538.         time.tm_min = mSpin->value();
  539.         time.tm_sec = sSpin->value();
  540.         d = astro::secondsToJulianDate(mktime(&time)) + (double) astro::Date(1970, 1, 1);
  541.     }
  542.     QString jd;
  543.     julianDateEdit->setText(jd.setNum(d, 'f'));
  544.     return d;
  545. }
  546. void KdePreferencesDialog::slotOk() {
  547.     slotApply();
  548.     accept();
  549. }
  550. void KdePreferencesDialog::slotCancel() {
  551.     appCore->getRenderer()->setRenderFlags(savedRendererFlags);
  552.     appCore->getRenderer()->setLabelMode(savedLabelMode);
  553.     appCore->getRenderer()->setOrbitMask(savedOrbitMask);
  554.     appCore->getRenderer()->setAmbientLightLevel(savedAmbientLightLevel/100.);
  555.     appCore->getSimulation()->setFaintestVisible(savedFaintestVisible/100.);
  556.     appCore->setHudDetail(savedHudDetail);
  557.     appCore->getRenderer()->getGLContext()->setRenderPath((GLContext::GLRenderPath)savedRenderPath);
  558.     appCore->setDistanceToScreen(savedDistanceToScreen);
  559.     appCore->getSimulation()->getActiveObserver()->setLocationFilter(savedLocationFilter);
  560.     appCore->getRenderer()->setMinimumFeatureSize(savedMinFeatureSize);
  561.     appCore->getRenderer()->setVideoSync(savedVideoSync);
  562.     appCore->getRenderer()->setResolution(savedTextureRes);
  563.     appCore->setDateFormat(savedDateFormat);
  564.     reject();
  565. }
  566. void KdePreferencesDialog::slotApply() {
  567.     savedRendererFlags = appCore->getRenderer()->getRenderFlags();
  568.     savedLabelMode = appCore->getRenderer()->getLabelMode();
  569.     savedAmbientLightLevel = int(appCore->getRenderer()->getAmbientLightLevel() * 100);
  570.     savedFaintestVisible = int(appCore->getSimulation()->getFaintestVisible() * 100);
  571.     savedHudDetail = appCore->getHudDetail();
  572.     savedDisplayLocalTime = appCore->getTimeZoneBias();
  573.     savedRenderPath = (int)appCore->getRenderer()->getGLContext()->getRenderPath();
  574.     savedDistanceToScreen = appCore->getDistanceToScreen();
  575.     savedLocationFilter = appCore->getSimulation()->getActiveObserver()->getLocationFilter();
  576.     savedMinFeatureSize = (int)appCore->getRenderer()->getMinimumFeatureSize();
  577.     savedVideoSync = appCore->getRenderer()->getVideoSync();
  578.     savedTextureRes = appCore->getRenderer()->getResolution();
  579.     savedDateFormat = appCore->getDateFormat();
  580.     keyChooser->commitChanges();
  581.     KGlobal::config()->setGroup("ConfigureDialog");
  582.     KGlobal::config()->writeEntry("SetTimeTimeZoneLocal", setTimezoneCombo->currentItem());
  583.     KGlobal::config()->setGroup(0);
  584.     if (timeHasChanged) {
  585.       if (setTimezoneCombo->currentItem() == 0 || YSpin->value() < 1902 || YSpin->value() > 2037) {
  586.         astro::Date date(0.0);
  587.         date.year=YSpin->value();
  588.         date.month=MSpin->value();
  589.         date.day=DSpin->value();
  590.         date.hour=hSpin->value();
  591.         date.minute=mSpin->value();
  592.         date.seconds=float(sSpin->value());
  593.         appCore->getSimulation()->setTime(astro::UTCtoTDB((double) date));
  594.         appCore->getSimulation()->update(0.0);
  595.       } else {
  596.         struct tm time;
  597.         time.tm_year = YSpin->value() - 1900;
  598.         time.tm_mon = MSpin->value() - 1;
  599.         time.tm_mday = DSpin->value();
  600.         time.tm_hour = hSpin->value();
  601.         time.tm_min = mSpin->value();
  602.         time.tm_sec = sSpin->value();
  603.         appCore->getSimulation()->setTime(astro::UTCtoTDB(astro::secondsToJulianDate(mktime(&time)) + (double) astro::Date(1970, 1, 1)));
  604.         appCore->getSimulation()->update(0.0);
  605.       }
  606.     }
  607. }
  608. void KdePreferencesDialog::slotTimeHasChanged() {
  609.     timeHasChanged = true;
  610.     getTime();
  611. }
  612. void KdePreferencesDialog::slotJDHasChanged() {
  613.     setTime(julianDateEdit->text().toDouble());
  614. }
  615. void KdePreferencesDialog::slotFaintestVisible(int m) {
  616.     char buff[20];
  617.     parent->slotFaintestVisible(m / 100.);
  618.     sprintf(buff, "%.2f", m / 100.);
  619.     faintestLabel->setText(buff);
  620. }
  621. void KdePreferencesDialog::slotMinFeatureSize(int s) {
  622.     char buff[20];
  623.     parent->slotMinFeatureSize(s);
  624.     sprintf(buff, "%d", s);
  625.     minFeatureSizeLabel->setText(buff);
  626. }
  627. void KdePreferencesDialog::slotAmbientLightLevel(int l) {
  628.     char buff[20];
  629.     parent->slotAmbientLightLevel(l / 100.);
  630.     sprintf(buff, "%.2f", l / 100.);
  631.     ambientLabel->setText(buff);
  632. }
  633. void KdePreferencesDialog::slotRenderPath(int pathIdx) {
  634.     int path=0, ipathIdx=0;
  635.     while (ipathIdx != pathIdx) {
  636.         ipathIdx++;
  637.         do {
  638.             path++;
  639.         } while (!appCore->getRenderer()->getGLContext()->renderPathSupported((GLContext::GLRenderPath)path));
  640.     }
  641.     appCore->getRenderer()->getGLContext()->setRenderPath((GLContext::GLRenderPath)path);
  642.     setRenderPathLabel();
  643. }
  644. void KdePreferencesDialog::slotDistanceToScreen(int dts) {
  645.     appCore->setDistanceToScreen(dts * 10);
  646. }
  647. void KdePreferencesDialog::slotTextureRes(int res) {
  648.     appCore->getRenderer()->setResolution(res);
  649. }
  650. void KdePreferencesDialog::slotDateFormat(int format) {
  651.     appCore->setDateFormat((astro::Date::Format)format);
  652. }
  653. void KdePreferencesDialog::setRenderPathLabel() {
  654.     switch(appCore->getRenderer()->getGLContext()->getRenderPath()) {
  655.     case GLContext::GLPath_Basic:
  656.         renderPathLabel->setText(i18n("<b>Unextended OpenGL 1.1</b>"));
  657.         break;
  658.     case GLContext::GLPath_Multitexture:
  659.         renderPathLabel->setText(i18n("<b>Multiple textures and the ARB_texenv_combine extension</b>"));
  660.         break;
  661.     case GLContext::GLPath_NvCombiner:
  662.         renderPathLabel->setText(i18n("<b>NVIDIA combiners, no vertex programs</b>"));
  663.         break;
  664.     case GLContext::GLPath_DOT3_ARBVP:
  665.         renderPathLabel->setText(i18n("<b>ARB_texenv_DOT3 extension, ARB_vertex_program extension</b>"));
  666.         break;
  667.     case GLContext::GLPath_NvCombiner_NvVP:
  668.         renderPathLabel->setText(i18n("<b>NVIDIA Combiners, NV_vertex_program extension</b><br> "
  669.                                       "provide bump mapping, ring shadows, and specular "
  670.                                       "highlights on any Geforce or ATI Radeon graphics card, though "
  671.                                       "NvCombiner ARBVP is a slightly better option for Geforce users"));
  672.         break;
  673.     case GLContext::GLPath_NvCombiner_ARBVP:
  674.         renderPathLabel->setText(i18n("<b>NVIDIA Combiners, ARB_vertex_program extension</b>"));
  675.         break;
  676.     case GLContext::GLPath_ARBFP_ARBVP:
  677.         renderPathLabel->setText(i18n("<b>ARB_fragment_program and ARB_vertex_program extensions</b><br>"
  678.                                       "provide advanced effects on Geforce FX and Radeon 9700 cards"));
  679.         break;
  680.     case GLContext::GLPath_NV30:
  681.         renderPathLabel->setText(i18n("<b>NV_fragment_program and ARB_vertex_program extensions</b>"));
  682.         break;
  683.     case GLContext::GLPath_GLSL:
  684.         renderPathLabel->setText(i18n("<b>OpenGL 2.0 Shading Language</b>"));
  685.         break;
  686.     }
  687. }