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 PointerCoordinates::draw(StelCore *core) { if (!isEnabled()) return; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto); StelPainter sPainter(prj); sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f); font.setPixelSize(getFontSize()); sPainter.setFont(font); QPoint p = StelMainView::getInstance().getMousePos(); // get screen coordinates of mouse cursor Vec3d mousePosition; float wh = prj->getViewportWidth()/2.; // get half of width of the screen float hh = prj->getViewportHeight()/2.; // get half of height of the screen float mx = p.x()-wh; // point 0 in center of the screen, axis X directed to right float my = p.y()-hh; // point 0 in center of the screen, axis Y directed to bottom // calculate position of mouse cursor via position of center of the screen (and invert axis Y) // If coordinates are invalid, don't draw them. bool coordsValid=false; coordsValid = prj->unProject(prj->getViewportPosX()+wh+mx, prj->getViewportPosY()+hh+1-my, mousePosition); { // Nick Fedoseev patch Vec3d win; prj->project(mousePosition,win); float dx = prj->getViewportPosX()+wh+mx - win.v[0]; float dy = prj->getViewportPosY()+hh+1-my - win.v[1]; coordsValid = prj->unProject(prj->getViewportPosX()+wh+mx+dx, prj->getViewportPosY()+hh+1-my+dy, mousePosition); } if (!coordsValid) return; bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees(); bool useSouthAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage(); QString coordsSystem, cxt, cyt; double cx, cy; switch (getCurrentCoordinateSystem()) { case RaDecJ2000: { StelUtils::rectToSphe(&cx,&cy,mousePosition); // Calculate RA/DE (J2000.0) and show it... coordsSystem = qc_("RA/Dec (J2000.0)", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(cx, 5, false, true); cyt = StelUtils::radToDecDegStr(cy); } else { cxt = StelUtils::radToHmsStr(cx, true); cyt = StelUtils::radToDmsStr(cy, true); } break; } case RaDec: { StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEqu(mousePosition)); // Calculate RA/DE and show it... coordsSystem = qc_("RA/Dec", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(cx, 5, false, true); cyt = StelUtils::radToDecDegStr(cy); } else { cxt = StelUtils::radToHmsStr(cx, true); cyt = StelUtils::radToDmsStr(cy, true); } break; } case AltAzi: { StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(mousePosition, StelCore::RefractionAuto)); float direction = 3.; // N is zero, E is 90 degrees if (useSouthAzimuth) direction = 2.; cy = direction*M_PI - cy; if (cy > M_PI*2) cy -= M_PI*2; coordsSystem = qc_("Az/Alt", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(cy); cyt = StelUtils::radToDecDegStr(cx); } else { cxt = StelUtils::radToDmsStr(cy); cyt = StelUtils::radToDmsStr(cx); } break; } case Galactic: { StelUtils::rectToSphe(&cx,&cy,core->j2000ToGalactic(mousePosition)); // Calculate galactic position and show it... coordsSystem = qc_("Gal. Long/Lat", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(cx); cyt = StelUtils::radToDecDegStr(cy); } else { cxt = StelUtils::radToDmsStr(cx, true); cyt = StelUtils::radToDmsStr(cy, true); } break; } case Ecliptic: { double lambda, beta; StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEqu(mousePosition)); StelUtils::equToEcl(cx, cy, core->getCurrentPlanet()->getRotObliquity(core->getJDE()), &lambda, &beta); // Calculate ecliptic position and show it... if (lambda<0) lambda+=2.0*M_PI; coordsSystem = qc_("Ecl. Long/Lat", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(lambda); cyt = StelUtils::radToDecDegStr(beta); } else { cxt = StelUtils::radToDmsStr(lambda, true); cyt = StelUtils::radToDmsStr(beta, true); } break; } case EclipticJ2000: { double lambda, beta; StelUtils::rectToSphe(&cx,&cy, mousePosition); StelUtils::equToEcl(cx, cy, core->getCurrentPlanet()->getRotObliquity(2451545.0), &lambda, &beta); // Calculate ecliptic position and show it... if (lambda<0) lambda+=2.0*M_PI; coordsSystem = qc_("Ecl. Long/Lat (J2000.0)", "abbreviated in the plugin"); if (withDecimalDegree) { cxt = StelUtils::radToDecDegStr(lambda); cyt = StelUtils::radToDecDegStr(beta); } else { cxt = StelUtils::radToDmsStr(lambda, true); cyt = StelUtils::radToDmsStr(beta, true); } break; } case HourAngle: { Vec3d v = core->j2000ToAltAz(mousePosition, StelCore::RefractionAuto); StelUtils::rectToSphe(&cx,&cy,Mat4d::zrotation(-core->getLocalSiderealTime())*core->altAzToEquinoxEqu(v, StelCore::RefractionOff)); cx = 2.*M_PI-cx; coordsSystem = qc_("HA/Dec", "abbreviated in the plugin"); if (withDecimalDegree) { double ha_sidereal = cx*12/M_PI; if (ha_sidereal>24.) ha_sidereal -= 24.; cxt = QString("%1h").arg(ha_sidereal, 0, 'f', 5); cyt = StelUtils::radToDecDegStr(cy); } else { cxt = StelUtils::radToHmsStr(cx); cyt = StelUtils::radToDmsStr(cy); } break; } } QString coordsText = QString("%1: %2/%3").arg(coordsSystem).arg(cxt).arg(cyt); sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordinatesPlace(coordsText).second, coordsText); }
void SearchDialog::populateCoordinateAxis() { bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();; bool xnormal = true; ui->AxisXSpinBox->setDecimals(2); ui->AxisYSpinBox->setDecimals(2); switch (getCurrentCoordinateSystem()) { case equatorialJ2000: case equatorial: { ui->AxisXLabel->setText(q_("Right ascension")); ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::HMSLetters); ui->AxisXSpinBox->setPrefixType(AngleSpinBox::Normal); ui->AxisYLabel->setText(q_("Declination")); ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->AxisYSpinBox->setPrefixType(AngleSpinBox::NormalPlus); xnormal = true; break; } case horizontal: { ui->AxisXLabel->setText(q_("Azimuth")); ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbolsUnsigned); ui->AxisXSpinBox->setPrefixType(AngleSpinBox::NormalPlus); ui->AxisYLabel->setText(q_("Altitude")); ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->AxisYSpinBox->setPrefixType(AngleSpinBox::NormalPlus); xnormal = false; break; } case ecliptic: case eclipticJ2000: case galactic: { ui->AxisXLabel->setText(q_("Longitude")); ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbolsUnsigned); ui->AxisXSpinBox->setPrefixType(AngleSpinBox::NormalPlus); ui->AxisYLabel->setText(q_("Latitude")); ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->AxisYSpinBox->setPrefixType(AngleSpinBox::NormalPlus); xnormal = false; break; } } if (withDecimalDegree) { ui->AxisXSpinBox->setDecimals(5); ui->AxisYSpinBox->setDecimals(5); ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DecimalDeg); ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DecimalDeg); ui->AxisXSpinBox->setPrefixType(AngleSpinBox::NormalPlus); } else { if (xnormal) ui->AxisXSpinBox->setPrefixType(AngleSpinBox::Normal); } }
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); }