New FoV handling

ver1_5_1
Christophe Teyssier 2003-06-03 21:49:54 +00:00
parent 7cfc5cb4c9
commit eda0d8df99
5 changed files with 36 additions and 1 deletions

View File

@ -117,6 +117,12 @@ KdeApp::KdeApp(QWidget *parent, const char *name) : KMainWindow(parent, name)
restoreWindowSize(conf);
conf->setGroup(0);
KGlobal::config()->setGroup("Preferences");
if (KGlobal::config()->hasKey("DistanceToScreen"))
{
appCore->setDistanceToScreen(KGlobal::config()->readNumEntry("DistanceToScreen"));
}
if (bookmarkBar->isHidden()) ((KToggleAction*)actionCollection()->action("showBookmarkBar"))->setChecked(false);
else ((KToggleAction*)actionCollection()->action("showBookmarkBar"))->setChecked(true);
@ -517,6 +523,7 @@ bool KdeApp::queryExit() {
conf->writeEntry("FramesVisible", appCore->getFramesVisible());
conf->writeEntry("ActiveFrameVisible", appCore->getActiveFrameVisible());
conf->writeEntry("SyncTime", appCore->getSimulation()->getSyncTime());
conf->writeEntry("DistanceToScreen", appCore->getDistanceToScreen());
conf->setGroup(0);
actionCollection()->writeShortcutSettings("Shortcuts", conf);
openRecent->saveEntries(KGlobal::config());

View File

@ -25,6 +25,7 @@
#include <celengine/starbrowser.h>
#include <kmainwindow.h>
#include <kconfig.h>
#include <qpaintdevicemetrics.h>
#ifndef DEBUG
# define G_DISABLE_ASSERT
@ -44,6 +45,7 @@
#include "kdeapp.h"
#include <math.h>
KdeGlWidget::KdeGlWidget( QWidget* parent, const char* name, CelestiaCore* core )
: QGLWidget( parent, name )
@ -177,10 +179,17 @@ void KdeGlWidget::initializeGL()
}
KGlobal::config()->setGroup(0);
QPaintDeviceMetrics pdm(this);
appCore->setScreenDpi(pdm.logicalDpiY());
}
void KdeGlWidget::resizeGL( int w, int h )
{
/* QPaintDeviceMetrics pdm(this);
double fov = 2 * atan(h / (pdm.logicalDpiY() / 25.4) / 2. / 400.);
appCore->getSimulation()->getActiveObserver()->setFOV(fov);
*/
appCore->resize(w, h);
}

View File

@ -191,6 +191,15 @@ KdePreferencesDialog::KdePreferencesDialog(QWidget* parent, CelestiaCore* core)
infoTextCombo->setCurrentItem(savedHudDetail);
((KdeApp*)parent)->connect(infoTextCombo, SIGNAL(activated(int)), SLOT(slotHudDetail(int)));
QGroupBox* fovGroup = new QGroupBox(2, Qt::Horizontal, i18n("Automatic FOV"), vbox1);
new QLabel(i18n("Screen DPI: "), fovGroup);
new QLabel(QString::number(appCore->getScreenDpi(), 10), fovGroup);
new QLabel(i18n("Viewing Distance (cm): "), fovGroup);
dtsSpin = new QSpinBox(10, 300, 1, fovGroup);
savedDistanceToScreen = appCore->getDistanceToScreen();
dtsSpin->setValue(savedDistanceToScreen / 10);
connect(dtsSpin, SIGNAL(valueChanged(int)), SLOT(slotDistanceToScreen(int)));
// Time page
timeHasChanged = false;
QVBox* timeFrame = addVBoxPage(i18n("Date/Time"), i18n("Date/Time"),
@ -458,6 +467,7 @@ void KdePreferencesDialog::slotCancel() {
appCore->getSimulation()->setFaintestVisible(savedFaintestVisible/100.);
appCore->setHudDetail(savedHudDetail);
appCore->getRenderer()->getGLContext()->setRenderPath((GLContext::GLRenderPath)savedRenderPath);
appCore->setDistanceToScreen(savedDistanceToScreen);
reject();
}
@ -470,6 +480,7 @@ void KdePreferencesDialog::slotApply() {
savedHudDetail = appCore->getHudDetail();
savedDisplayLocalTime = appCore->getTimeZoneBias();
savedRenderPath = (int)appCore->getRenderer()->getGLContext()->getRenderPath();
savedDistanceToScreen = appCore->getDistanceToScreen();
keyChooser->commitChanges();
@ -535,6 +546,10 @@ void KdePreferencesDialog::slotRenderPath(int pathIdx) {
setRenderPathLabel();
}
void KdePreferencesDialog::slotDistanceToScreen(int dts) {
appCore->setDistanceToScreen(dts * 10);
}
void KdePreferencesDialog::setRenderPathLabel() {
switch(appCore->getRenderer()->getGLContext()->getRenderPath()) {
case GLContext::GLPath_Basic:

View File

@ -44,7 +44,7 @@ public slots:
void slotAmbientLightLevel(int l);
void slotFaintestVisible(int m);
void slotRenderPath(int);
void slotDistanceToScreen(int);
protected:
CelestiaCore* appCore;
@ -59,6 +59,7 @@ protected:
int savedHudDetail;
int savedDisplayLocalTime;
int savedRenderPath;
int savedDistanceToScreen;
bool timeHasChanged;
@ -68,6 +69,8 @@ protected:
QSpinBox *hSpin, *mSpin, *sSpin;
QSpinBox *dtsSpin;
QComboBox *renderPathCombo;
QLabel* renderPathLabel;
QLabel* ambientLabel, *faintestLabel;

View File

@ -401,6 +401,7 @@ void Url::goTo()
case Relative:
sim->setFrame(ref);
sim->getActiveObserver()->setFOV(degToRad(fieldOfView));
appCore->setZoomFromFOV();
sim->setTimeScale(timeScale);
appCore->setLightDelayActive(lightTimeDelay);