PointerCoordinates.cpp   PointerCoordinates.cpp 
skipping to change at line 25 skipping to change at line 25
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "SkyGui.hpp" #include "SkyGui.hpp"
#include "StelMainView.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "PointerCoordinates.hpp" #include "PointerCoordinates.hpp"
#include "PointerCoordinatesWindow.hpp" #include "PointerCoordinatesWindow.hpp"
skipping to change at line 119 skipping to change at line 120
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto);
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f); sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f);
font.setPixelSize(getFontSize()); font.setPixelSize(getFontSize());
sPainter.setFont(font); sPainter.setFont(font);
QPoint p = QCursor::pos(); // get screen coordinates of mouse cursor QPoint p = StelMainView::getInstance().getMousePos(); // get screen coordinates of mouse cursor
Vec3d mousePosition; Vec3d mousePosition;
float wh = prj->getViewportWidth()/2; // get half of width of the sc reen float wh = prj->getViewportWidth()/2; // get half of width of the sc reen
float hh = prj->getViewportHeight()/2; // get half of height 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 dire cted to right float mx = p.x()-wh; // point 0 in center of the screen, axis X dire cted to right
float my = p.y()-hh; // point 0 in center of the screen, axis Y dire cted to bottom float my = p.y()-hh; // point 0 in center of the screen, axis Y dire cted to bottom
// calculate position of mouse cursor via position of center of the screen (and invert axis Y) // calculate position of mouse cursor via position of center of the screen (and invert axis Y)
prj->unProject(prj->getViewportPosX()+wh+mx, prj->getViewportPosY()+ hh+1-my, mousePosition); 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];
prj->unProject(prj->getViewportPosX()+wh+mx+dx, prj->getViewportP
osY()+hh+1-my+dy, mousePosition);
}
bool withDecimalDegree = dynamic_cast<StelGui*>(StelApp::getInstance
().getGui())->getFlagShowDecimalDegrees();
QString coordsText; QString coordsSystem, cxt, cyt;
double cx, cy; double cx, cy;
switch (getCurrentCoordinateSystem()) switch (getCurrentCoordinateSystem())
{ {
case RaDecJ2000: case RaDecJ2000:
{ {
StelUtils::rectToSphe(&cx,&cy,mousePosition); // Cal culate RA/DE (J2000.0) and show it... StelUtils::rectToSphe(&cx,&cy,mousePosition); // Cal culate RA/DE (J2000.0) and show it...
coordsText = QString("%1: %2/%3") coordsSystem = qc_("RA/Dec (J2000.0)", "abbreviated
.arg(qc_("RA/Dec (J2000.0)", "abbrev in the plugin");
iated in the plugin")) if (withDecimalDegree)
.arg(StelUtils::radToHmsStr(cx, true {
)) cxt = StelUtils::radToDecDegStr(cx, 5, false
.arg(StelUtils::radToDmsStr(cy, true , true);
)); cyt = StelUtils::radToDecDegStr(cy);
}
else
{
cxt = StelUtils::radToHmsStr(cx, true);
cyt = StelUtils::radToDmsStr(cy, true);
}
break; break;
} }
case RaDec: case RaDec:
{ {
StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEq u(mousePosition)); // Calculate RA/DE and show it... StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEq u(mousePosition)); // Calculate RA/DE and show it...
coordsText = QString("%1: %2/%3") coordsSystem = qc_("RA/Dec", "abbreviated in the plu
.arg(qc_("RA/Dec", "abbreviated in t gin");
he plugin")) if (withDecimalDegree)
.arg(StelUtils::radToHmsStr(cx, true {
)) cxt = StelUtils::radToDecDegStr(cx, 5, false
.arg(StelUtils::radToDmsStr(cy, true , true);
)); cyt = StelUtils::radToDecDegStr(cy);
}
else
{
cxt = StelUtils::radToHmsStr(cx, true);
cyt = StelUtils::radToDmsStr(cy, true);
}
break; break;
} }
case AltAzi: case AltAzi:
{ {
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(mou sePosition, StelCore::RefractionAuto)); StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(mou sePosition, StelCore::RefractionAuto));
cy = 3.*M_PI - cy; // N is zero, E is 90 degrees cy = 3.*M_PI - cy; // N is zero, E is 90 degrees
if (cy > M_PI*2) if (cy > M_PI*2)
cy -= M_PI*2; cy -= M_PI*2;
coordsText = QString("%1: %2/%3") coordsSystem = qc_("Az/Alt", "abbreviated in the plu
.arg(qc_("Az/Alt", "abbreviated in t gin");
he plugin")) if (withDecimalDegree)
.arg(StelUtils::radToDmsStr(cy)) {
.arg(StelUtils::radToDmsStr(cx)); cxt = StelUtils::radToDecDegStr(cy);
cyt = StelUtils::radToDecDegStr(cx);
}
else
{
cxt = StelUtils::radToDmsStr(cy);
cyt = StelUtils::radToDmsStr(cx);
}
break; break;
} }
case Galactic: case Galactic:
{ {
StelUtils::rectToSphe(&cx,&cy,core->j2000ToGalactic( mousePosition)); // Calculate galactic position and show it... StelUtils::rectToSphe(&cx,&cy,core->j2000ToGalactic( mousePosition)); // Calculate galactic position and show it...
coordsText = QString("%1: %2/%3") coordsSystem = qc_("Gal. Long/Lat", "abbreviated in
.arg(qc_("Gal. Long/Lat", "abbreviat the plugin");
ed in the plugin")) if (withDecimalDegree)
.arg(StelUtils::radToDmsStr(cx, true {
)) cxt = StelUtils::radToDecDegStr(cx);
.arg(StelUtils::radToDmsStr(cy, true cyt = StelUtils::radToDecDegStr(cy);
)); }
else
{
cxt = StelUtils::radToDmsStr(cx, true);
cyt = StelUtils::radToDmsStr(cy, true);
}
break; break;
} }
case Ecliptic: case Ecliptic:
{ {
double lambda, beta; double lambda, beta;
StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEq u(mousePosition)); StelUtils::rectToSphe(&cx,&cy,core->j2000ToEquinoxEq u(mousePosition));
StelUtils::ctRadec2Ecl(cx, cy, GETSTELMODULE(SolarSy
stem)->getEarth()->getRotObliquity(core->getJDay()), &lambda, &beta); // Ca
lculate 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::ctRadec2Ecl(cx, cy, GETSTELMODULE(SolarSy stem)->getEarth()->getRotObliquity(2451545.0), &lambda, &beta); // Calculat e ecliptic position and show it... StelUtils::ctRadec2Ecl(cx, cy, GETSTELMODULE(SolarSy stem)->getEarth()->getRotObliquity(2451545.0), &lambda, &beta); // Calculat e ecliptic position and show it...
if (lambda<0) lambda+=2.0*M_PI; if (lambda<0) lambda+=2.0*M_PI;
coordsText = QString("%1: %2/%3") coordsSystem = qc_("Ecl. Long/Lat (J2000.0)", "abbre
.arg(qc_("Ecl. Long/Lat (J2000.0)", viated in the plugin");
"abbreviated in the plugin")) if (withDecimalDegree)
.arg(StelUtils::radToDmsStr(lambda, {
true)) cxt = StelUtils::radToDecDegStr(lambda);
.arg(StelUtils::radToDmsStr(beta, tr cyt = StelUtils::radToDecDegStr(beta);
ue)); }
else
{
cxt = StelUtils::radToDmsStr(lambda, true);
cyt = StelUtils::radToDmsStr(beta, true);
}
break; break;
} }
case HourAngle: case HourAngle:
{ {
Vec3d v = core->j2000ToAltAz(mousePosition, StelCore ::RefractionAuto); Vec3d v = core->j2000ToAltAz(mousePosition, StelCore ::RefractionAuto);
StelUtils::rectToSphe(&cx,&cy,Mat4d::zrotation(-core ->getLocalSiderealTime()+((core->getDeltaT(core->getJDay())/240.)*M_PI/180. ))*core->altAzToEquinoxEqu(v, StelCore::RefractionOff)); StelUtils::rectToSphe(&cx,&cy,Mat4d::zrotation(-core ->getLocalSiderealTime()+((core->getDeltaT(core->getJDay())/240.)*M_PI/180. ))*core->altAzToEquinoxEqu(v, StelCore::RefractionOff));
cx = 2.*M_PI-cx; cx = 2.*M_PI-cx;
coordsText = QString("%1: %2/%3") coordsSystem = qc_("HA/Dec", "abbreviated in the plu
.arg(qc_("HA/Dec", "abbreviated in t gin");
he plugin")) cxt = StelUtils::radToHmsStr(cx);
.arg(StelUtils::radToHmsStr(cx)) cyt = StelUtils::radToDmsStr(cy);
.arg(StelUtils::radToDmsStr(cy));
break; break;
} }
} }
QString coordsText = QString("%1: %2/%3").arg(coordsSystem).arg(cxt) .arg(cyt);
sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordina tesPlace(coordsText).second, coordsText); sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordina tesPlace(coordsText).second, coordsText);
} }
void PointerCoordinates::enableCoordinates(bool b) void PointerCoordinates::enableCoordinates(bool b)
{ {
flagShowCoordinates = b; flagShowCoordinates = b;
} }
double PointerCoordinates::getCallOrder(StelModuleActionName actionName) co nst double PointerCoordinates::getCallOrder(StelModuleActionName actionName) co nst
{ {
 End of changes. 12 change blocks. 
40 lines changed or deleted 102 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/