kdepreferencesdialog.cpp
来自「celestia源代码」· C++ 代码 · 共 746 行 · 第 1/3 页
CPP
746 行
QVBox* keyBindings = addVBoxPage(i18n("Key Bindings"), i18n("Key Bindings"), KGlobal::iconLoader()->loadIcon("key_bindings", KIcon::NoGroup)); keyChooser = new KKeyChooser(((KMainWindow*)parent)->actionCollection(), keyBindings, false); resize(550,400);}KdePreferencesDialog::~KdePreferencesDialog() {} void KdePreferencesDialog::setNow() { time_t date_t; time(&date_t); struct tm* tm; if (setTimezoneCombo->currentItem() != 0) { tm = localtime ( &date_t); } else { tm = gmtime ( &date_t); } YSpin->setValue(tm->tm_year + 1900); MSpin->setValue(tm->tm_mon + 1); DSpin->setValue(tm->tm_mday); hSpin->setValue(tm->tm_hour); mSpin->setValue(tm->tm_min); sSpin->setValue(tm->tm_sec);}void KdePreferencesDialog::ltSubstract() { double d; d = getTime(); Selection selection = appCore->getSimulation()->getSelection(); std::string sel_name; // LT-delay only for solar bodies && target-speed < 0.99 c if (selection.body() != 0 && (appCore->getSimulation()->getTargetSpeed() < 0.99 * astro::kilometersToMicroLightYears(astro::speedOfLight))) { sel_name = selection.body()->getName(); Vec3d v = selection.getPosition(d) - appCore->getSimulation()->getObserver().getPosition(); appCore->setLightDelayActive(!appCore->getLightDelayActive()); double dist = astro::lightYearsToKilometers(v.length()*1e-6); double lt = dist / astro::speedOfLight; if (appCore->getLightDelayActive()) d -= lt / 86400.; else d += lt / 86400.; setTime(d); }}void KdePreferencesDialog::setTime(double d) { if (setTimezoneCombo->currentItem() != 0 && d < 2465442 && d > 2415733) { time_t date_t = (int) astro::julianDateToSeconds( d - (float)astro::Date(1970, 1, 1) ); struct tm* tm; tm = localtime ( &date_t); YSpin->setValue(tm->tm_year + 1900); MSpin->setValue(tm->tm_mon + 1); DSpin->setValue(tm->tm_mday); hSpin->setValue(tm->tm_hour); mSpin->setValue(tm->tm_min); sSpin->setValue(tm->tm_sec); } else { astro::Date date(d); YSpin->setValue(date.year); MSpin->setValue(date.month); DSpin->setValue(date.day); hSpin->setValue(date.hour); mSpin->setValue(date.minute); sSpin->setValue(int(date.seconds)); }}double KdePreferencesDialog::getTime() const { double d; if (setTimezoneCombo->currentItem() == 0 || YSpin->value() < 1902 || YSpin->value() > 2037) { astro::Date date(0.0); date.year=YSpin->value(); date.month=MSpin->value(); date.day=DSpin->value(); date.hour=hSpin->value(); date.minute=mSpin->value(); date.seconds=float(sSpin->value()); d = (double) date; } else { struct tm time; time.tm_year = YSpin->value() - 1900; time.tm_mon = MSpin->value() - 1; time.tm_mday = DSpin->value(); time.tm_hour = hSpin->value(); time.tm_min = mSpin->value(); time.tm_sec = sSpin->value(); d = astro::secondsToJulianDate(mktime(&time)) + (double) astro::Date(1970, 1, 1); } return d;}void KdePreferencesDialog::slotOk() { slotApply(); accept();}void KdePreferencesDialog::slotCancel() { appCore->getRenderer()->setRenderFlags(savedRendererFlags); appCore->getRenderer()->setLabelMode(savedLabelMode); appCore->getRenderer()->setOrbitMask(savedOrbitMask); appCore->getRenderer()->setAmbientLightLevel(savedAmbientLightLevel/100.); appCore->getSimulation()->setFaintestVisible(savedFaintestVisible/100.); appCore->setHudDetail(savedHudDetail); appCore->getRenderer()->getGLContext()->setRenderPath((GLContext::GLRenderPath)savedRenderPath); appCore->setDistanceToScreen(savedDistanceToScreen); appCore->getSimulation()->getActiveObserver()->setLocationFilter(savedLocationFilter); appCore->getRenderer()->setMinimumFeatureSize(savedMinFeatureSize); reject();}void KdePreferencesDialog::slotApply() { savedRendererFlags = appCore->getRenderer()->getRenderFlags(); savedLabelMode = appCore->getRenderer()->getLabelMode(); savedAmbientLightLevel = int(appCore->getRenderer()->getAmbientLightLevel() * 100); savedFaintestVisible = int(appCore->getSimulation()->getFaintestVisible() * 100); savedHudDetail = appCore->getHudDetail(); savedDisplayLocalTime = appCore->getTimeZoneBias(); savedRenderPath = (int)appCore->getRenderer()->getGLContext()->getRenderPath(); savedDistanceToScreen = appCore->getDistanceToScreen(); savedLocationFilter = appCore->getSimulation()->getActiveObserver()->getLocationFilter(); savedMinFeatureSize = appCore->getRenderer()->getMinimumFeatureSize(); keyChooser->commitChanges(); KGlobal::config()->setGroup("ConfigureDialog"); KGlobal::config()->writeEntry("SetTimeTimeZoneLocal", setTimezoneCombo->currentItem()); KGlobal::config()->setGroup(0); if (timeHasChanged) { if (setTimezoneCombo->currentItem() == 0 || YSpin->value() < 1902 || YSpin->value() > 2037) { astro::Date date(0.0); date.year=YSpin->value(); date.month=MSpin->value(); date.day=DSpin->value(); date.hour=hSpin->value(); date.minute=mSpin->value(); date.seconds=float(sSpin->value()); appCore->getSimulation()->setTime((double) date); appCore->getSimulation()->update(0.0); } else { struct tm time; time.tm_year = YSpin->value() - 1900; time.tm_mon = MSpin->value() - 1; time.tm_mday = DSpin->value(); time.tm_hour = hSpin->value(); time.tm_min = mSpin->value(); time.tm_sec = sSpin->value(); appCore->getSimulation()->setTime(astro::secondsToJulianDate(mktime(&time)) + (double) astro::Date(1970, 1, 1)); appCore->getSimulation()->update(0.0); } }}void KdePreferencesDialog::slotTimeHasChanged() { timeHasChanged = true;}void KdePreferencesDialog::slotFaintestVisible(int m) { char buff[20]; parent->slotFaintestVisible(m / 100.); sprintf(buff, "%.2f", m / 100.); faintestLabel->setText(buff);}void KdePreferencesDialog::slotMinFeatureSize(int s) { char buff[20]; parent->slotMinFeatureSize(s); sprintf(buff, "%d", s); minFeatureSizeLabel->setText(buff);}void KdePreferencesDialog::slotAmbientLightLevel(int l) { char buff[20]; parent->slotAmbientLightLevel(l / 100.); sprintf(buff, "%.2f", l / 100.); ambientLabel->setText(buff);}void KdePreferencesDialog::slotRenderPath(int pathIdx) { int path=0, ipathIdx=0; while (ipathIdx != pathIdx) { ipathIdx++; do { path++; } while (!appCore->getRenderer()->getGLContext()->renderPathSupported((GLContext::GLRenderPath)path)); } appCore->getRenderer()->getGLContext()->setRenderPath((GLContext::GLRenderPath)path); setRenderPathLabel();}void KdePreferencesDialog::slotDistanceToScreen(int dts) { appCore->setDistanceToScreen(dts * 10);}void KdePreferencesDialog::setRenderPathLabel() { switch(appCore->getRenderer()->getGLContext()->getRenderPath()) { case GLContext::GLPath_Basic: renderPathLabel->setText(i18n("<b>Unextended OpenGL 1.1</b>")); break; case GLContext::GLPath_Multitexture: renderPathLabel->setText(i18n("<b>Multiple textures and the ARB_texenv_combine extension</b>")); break; case GLContext::GLPath_NvCombiner: renderPathLabel->setText(i18n("<b>NVIDIA combiners, no vertex programs</b>")); break; case GLContext::GLPath_DOT3_ARBVP: renderPathLabel->setText(i18n("<b>ARB_texenv_DOT3 extension, ARB_vertex_program extension</b>")); break; case GLContext::GLPath_NvCombiner_NvVP: renderPathLabel->setText(i18n("<b>NVIDIA Combiners, NV_vertex_program extension</b><br> " "provide bump mapping, ring shadows, and specular " "highlights on any Geforce or ATI Radeon graphics card, though " "NvCombiner ARBVP is a slightly better option for Geforce users")); break; case GLContext::GLPath_NvCombiner_ARBVP: renderPathLabel->setText(i18n("<b>NVIDIA Combiners, ARB_vertex_program extension</b>")); break; case GLContext::GLPath_ARBFP_ARBVP: renderPathLabel->setText(i18n("<b>ARB_fragment_program and ARB_vertex_program extensions</b><br>" "provide advanced effects on Geforce FX and Radeon 9700 cards")); break; case GLContext::GLPath_NV30: renderPathLabel->setText(i18n("<b>NV_fragment_program and ARB_vertex_program extensions</b>")); break; case GLContext::GLPath_GLSL: renderPathLabel->setText(i18n("<b>OpenGL 2.0 Shading Language</b>")); break; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?