void MeteorShowersMgr::init() { loadTextures(); m_meteorShowers = new MeteorShowers(this); m_configDialog = new MSConfigDialog(this); m_searchDialog = new MSSearchDialog(this); createActions(); loadConfig(); // timer to hide the alert messages m_messageTimer = new QTimer(this); m_messageTimer->setSingleShot(true); m_messageTimer->setInterval(9000); m_messageTimer->stop(); connect(m_messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout())); // MeteorShowers directory QString userDir = StelFileMgr::getUserDir() + "/modules/MeteorShowers"; StelFileMgr::makeSureDirExistsAndIsWritable(userDir); // Loads the JSON catalog m_catalogPath = userDir + "/showers.json"; if (!loadCatalog(m_catalogPath)) { displayMessage(q_("The current catalog of Meteor Showers is invalid!"), "#bb0000"); restoreDefaultCatalog(m_catalogPath); } // Sets up the download manager m_downloadMgr = new QNetworkAccessManager(this); connect(m_downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(updateFinished(QNetworkReply*))); // every 5 min, check if it's time to update QTimer* updateTimer = new QTimer(this); updateTimer->setInterval(300000); connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates())); updateTimer->start(); checkForUpdates(); // always check if we are on Earth StelCore* core = StelApp::getInstance().getCore(); m_onEarth = core->getCurrentPlanet().data()->getEnglishName() == "Earth"; connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(locationChanged(StelLocation))); // enable at startup? setEnablePlugin(getEnableAtStartup()); }
void SearchDialog::manualPositionChanged() { ui->completionLabel->clearValues(); StelCore* core = StelApp::getInstance().getCore(); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); Vec3d pos; switch (getCurrentCoordinateSystem()) { case equatorialJ2000: { StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians(), ui->AxisYSpinBox->valueRadians(), pos); break; } case equatorial: { StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians(), ui->AxisYSpinBox->valueRadians(), pos); pos = core->equinoxEquToJ2000(pos); break; } case horizontal: { double cx; cx = 3.*M_PI - ui->AxisXSpinBox->valueRadians(); // N is zero, E is 90 degrees if (cx > M_PI*2) cx -= M_PI*2; StelUtils::spheToRect(cx, ui->AxisYSpinBox->valueRadians(), pos); pos = core->altAzToJ2000(pos); break; } case galactic: { StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians(), ui->AxisYSpinBox->valueRadians(), pos); pos = core->galacticToJ2000(pos); break; } case eclipticJ2000: { double ra, dec; StelUtils::eclToEqu(ui->AxisXSpinBox->valueRadians(), ui->AxisYSpinBox->valueRadians(), core->getCurrentPlanet()->getRotObliquity(2451545.0), &ra, &dec); StelUtils::spheToRect(ra, dec, pos); break; } case ecliptic: { double ra, dec; StelUtils::eclToEqu(ui->AxisXSpinBox->valueRadians(), ui->AxisYSpinBox->valueRadians(), core->getCurrentPlanet()->getRotObliquity(core->getJDE()), &ra, &dec); StelUtils::spheToRect(ra, dec, pos); pos = core->equinoxEquToJ2000(pos); break; } } mvmgr->setFlagTracking(false); mvmgr->moveToJ2000(pos, 0.05); }
void SearchDialog::manualPositionChanged() { ui->completionLabel->clearValues(); StelCore* core = StelApp::getInstance().getCore(); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); Vec3d pos; Vec3d aimUp; double spinLong=ui->AxisXSpinBox->valueRadians(); double spinLat=ui->AxisYSpinBox->valueRadians(); // Since 0.15: proper handling of aimUp vector. This does not depend on the searched coordinate system, but on the MovementManager's C.S. // However, if those are identical, we have a problem when we want to look right into the pole. (e.g. zenith), which requires a special up vector. // aimUp depends on MovementMgr::MountMode mvmgr->mountMode! mvmgr->setViewUpVector(Vec3d(0., 0., 1.)); aimUp=mvmgr->getViewUpVectorJ2000(); StelMovementMgr::MountMode mountMode=mvmgr->getMountMode(); switch (getCurrentCoordinateSystem()) { case equatorialJ2000: { StelUtils::spheToRect(spinLong, spinLat, pos); if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(spinLat)> (0.9*M_PI/2.0)) ) { // make up vector more stable. // Strictly mount should be in a new J2000 mode, but this here also stabilizes searching J2000 coordinates. mvmgr->setViewUpVector(Vec3d(-cos(spinLong), -sin(spinLong), 0.) * (spinLat>0. ? 1. : -1. )); aimUp=mvmgr->getViewUpVectorJ2000(); } break; } case equatorial: { StelUtils::spheToRect(spinLong, spinLat, pos); pos = core->equinoxEquToJ2000(pos); if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(spinLat)> (0.9*M_PI/2.0)) ) { // make up vector more stable. mvmgr->setViewUpVector(Vec3d(-cos(spinLong), -sin(spinLong), 0.) * (spinLat>0. ? 1. : -1. )); aimUp=mvmgr->getViewUpVectorJ2000(); } break; } case horizontal: { double cx; cx = 3.*M_PI - spinLong; // N is zero, E is 90 degrees if (cx > 2.*M_PI) cx -= 2.*M_PI; StelUtils::spheToRect(cx, spinLat, pos); pos = core->altAzToJ2000(pos); if ( (mountMode==StelMovementMgr::MountAltAzimuthal) && (fabs(spinLat)> (0.9*M_PI/2.0)) ) { // make up vector more stable. mvmgr->setViewUpVector(Vec3d(-cos(cx), -sin(cx), 0.) * (spinLat>0. ? 1. : -1. )); aimUp=mvmgr->getViewUpVectorJ2000(); } break; } case galactic: { StelUtils::spheToRect(spinLong, spinLat, pos); pos = core->galacticToJ2000(pos); if ( (mountMode==StelMovementMgr::MountGalactic) && (fabs(spinLat)> (0.9*M_PI/2.0)) ) { // make up vector more stable. mvmgr->setViewUpVector(Vec3d(-cos(spinLong), -sin(spinLong), 0.) * (spinLat>0. ? 1. : -1. )); aimUp=mvmgr->getViewUpVectorJ2000(); } break; } case eclipticJ2000: { double ra, dec; StelUtils::eclToEqu(spinLong, spinLat, core->getCurrentPlanet()->getRotObliquity(2451545.0), &ra, &dec); StelUtils::spheToRect(ra, dec, pos); break; } case ecliptic: { double ra, dec; StelUtils::eclToEqu(spinLong, spinLat, core->getCurrentPlanet()->getRotObliquity(core->getJDE()), &ra, &dec); StelUtils::spheToRect(ra, dec, pos); pos = core->equinoxEquToJ2000(pos); break; } } mvmgr->setFlagTracking(false); mvmgr->moveToJ2000(pos, aimUp, 0.05); }