PointerCoordinates.cpp   PointerCoordinates.cpp 
/* /*
* Pointer Coordinates plug-in for Stellarium * Pointer Coordinates plug-in for Stellarium
* *
* Copyright (C) 2014 Alexander Wolf * Copyright (C) 2014 Alexander Wolf
* Copyright (C) 2016 Georg Zotti (Constellation code)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 57 skipping to change at line 58
} }
StelPluginInfo PointerCoordinatesStelPluginInterface::getPluginInfo() const StelPluginInfo PointerCoordinatesStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(PointerCoordinates); Q_INIT_RESOURCE(PointerCoordinates);
StelPluginInfo info; StelPluginInfo info;
info.id = "PointerCoordinates"; info.id = "PointerCoordinates";
info.displayedName = N_("Pointer Coordinates"); info.displayedName = N_("Pointer Coordinates");
info.authors = "Alexander Wolf"; info.authors = "Alexander Wolf, Georg Zotti";
info.contact = "http://stellarium.org"; info.contact = "http://stellarium.org";
info.description = N_("This plugin shows the coordinates of the mous e pointer."); info.description = N_("This plugin shows the coordinates of the mous e pointer.");
info.version = POINTERCOORDINATES_PLUGIN_VERSION; info.version = POINTERCOORDINATES_PLUGIN_VERSION;
return info; return info;
} }
PointerCoordinates::PointerCoordinates() PointerCoordinates::PointerCoordinates()
: currentPlace(TopRight) : currentPlace(TopRight)
, currentCoordinateSystem(RaDecJ2000) , currentCoordinateSystem(RaDecJ2000)
, flagShowCoordinates(false) , flagShowCoordinates(false)
, flagEnableAtStartup(false) , flagEnableAtStartup(false)
, flagShowCoordinatesButton(false) , flagShowCoordinatesButton(false)
, flagShowConstellation(false)
, textColor(Vec3f(1,0.5,0)) , textColor(Vec3f(1,0.5,0))
, coordinatesPoint(Vec3d(0,0,0)) , coordinatesPoint(Vec3d(0,0,0))
, fontSize(14) , fontSize(14)
, toolbarButton(NULL) , toolbarButton(NULL)
{ {
setObjectName("PointerCoordinates"); setObjectName("PointerCoordinates");
mainWindow = new PointerCoordinatesWindow(); mainWindow = new PointerCoordinatesWindow();
StelApp &app = StelApp::getInstance(); StelApp &app = StelApp::getInstance();
conf = app.getSettings(); conf = app.getSettings();
gui = dynamic_cast<StelGui*>(app.getGui()); gui = dynamic_cast<StelGui*>(app.getGui());
skipping to change at line 102 skipping to change at line 104
restoreDefaultConfiguration(); restoreDefaultConfiguration();
} }
// populate settings from main config file. // populate settings from main config file.
loadConfiguration(); loadConfiguration();
addAction("actionShow_MousePointer_Coordinates", N_("Pointer Coordin ates"), N_("Show coordinates of the mouse pointer"), "enabled", ""); addAction("actionShow_MousePointer_Coordinates", N_("Pointer Coordin ates"), N_("Show coordinates of the mouse pointer"), "enabled", "");
enableCoordinates(getFlagEnableAtStartup()); enableCoordinates(getFlagEnableAtStartup());
setFlagShowCoordinatesButton(flagShowCoordinatesButton); setFlagShowCoordinatesButton(flagShowCoordinatesButton);
setFlagShowConstellation(flagShowConstellation);
} }
void PointerCoordinates::deinit() void PointerCoordinates::deinit()
{ {
// //
} }
void PointerCoordinates::draw(StelCore *core) void PointerCoordinates::draw(StelCore *core)
{ {
if (!isEnabled()) if (!isEnabled())
skipping to change at line 218 skipping to change at line 221
cxt = StelUtils::radToDecDegStr(cx); cxt = StelUtils::radToDecDegStr(cx);
cyt = StelUtils::radToDecDegStr(cy); cyt = StelUtils::radToDecDegStr(cy);
} }
else else
{ {
cxt = StelUtils::radToDmsStr(cx, true); cxt = StelUtils::radToDmsStr(cx, true);
cyt = StelUtils::radToDmsStr(cy, true); cyt = StelUtils::radToDmsStr(cy, true);
} }
break; break;
} }
case Supergalactic:
{
StelUtils::rectToSphe(&cx,&cy,core->j2000ToSupergala
ctic(mousePosition)); // Calculate supergalactic position and show it...
coordsSystem = qc_("Supergal. Long/Lat", "abbreviate
d 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: 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::equToEcl(cx, cy, core->getCurrentPlanet() ->getRotObliquity(core->getJDE()), &lambda, &beta); // Calculate ecliptic p osition and show it... StelUtils::equToEcl(cx, cy, core->getCurrentPlanet() ->getRotObliquity(core->getJDE()), &lambda, &beta); // Calculate ecliptic p osition and show it...
if (lambda<0) lambda+=2.0*M_PI; if (lambda<0) lambda+=2.0*M_PI;
coordsSystem = qc_("Ecl. Long/Lat", "abbreviated in the plugin"); coordsSystem = qc_("Ecl. Long/Lat", "abbreviated in the plugin");
if (withDecimalDegree) if (withDecimalDegree)
{ {
cxt = StelUtils::radToDecDegStr(lambda); cxt = StelUtils::radToDecDegStr(lambda);
skipping to change at line 280 skipping to change at line 299
} }
else else
{ {
cxt = StelUtils::radToHmsStr(cx); cxt = StelUtils::radToHmsStr(cx);
cyt = StelUtils::radToDmsStr(cy); cyt = StelUtils::radToDmsStr(cy);
} }
break; break;
} }
} }
QString coordsText = QString("%1: %2/%3").arg(coordsSystem).arg(cxt) QString constel;
.arg(cyt); if (flagShowConstellation)
{
constel=QString(" (%1)").arg(core->getIAUConstellation(mouse
Position));
}
QString coordsText = QString("%1: %2/%3%4").arg(coordsSystem).arg(cx
t).arg(cyt).arg(constel);
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)
{ {
if (b!=flagShowCoordinates) if (b!=flagShowCoordinates)
{ {
flagShowCoordinates = b; flagShowCoordinates = b;
emit flagCoordinatesVisibilityChanged(b); emit flagCoordinatesVisibilityChanged(b);
} }
skipping to change at line 336 skipping to change at line 360
conf->beginGroup("PointerCoordinates"); conf->beginGroup("PointerCoordinates");
setFlagEnableAtStartup(conf->value("enable_at_startup", false).toBoo l()); setFlagEnableAtStartup(conf->value("enable_at_startup", false).toBoo l());
textColor = StelUtils::strToVec3f(conf->value("text_color", "1,0.5,0 ").toString()); textColor = StelUtils::strToVec3f(conf->value("text_color", "1,0.5,0 ").toString());
setFontSize(conf->value("font_size", 14).toInt()); setFontSize(conf->value("font_size", 14).toInt());
flagShowCoordinatesButton = conf->value("flag_show_button", true).to Bool(); flagShowCoordinatesButton = conf->value("flag_show_button", true).to Bool();
setCurrentCoordinatesPlaceKey(conf->value("current_displaying_place" , "TopRight").toString()); setCurrentCoordinatesPlaceKey(conf->value("current_displaying_place" , "TopRight").toString());
setCurrentCoordinateSystemKey(conf->value("current_coordinate_system ", "RaDecJ2000").toString()); setCurrentCoordinateSystemKey(conf->value("current_coordinate_system ", "RaDecJ2000").toString());
QStringList cc = conf->value("custom_coordinates", "1,1").toString() .split(","); QStringList cc = conf->value("custom_coordinates", "1,1").toString() .split(",");
setCustomCoordinatesPlace(cc[0].toInt(), cc[1].toInt()); setCustomCoordinatesPlace(cc[0].toInt(), cc[1].toInt());
flagShowConstellation = conf->value("flag_show_constellation", false ).toBool();
conf->endGroup(); conf->endGroup();
} }
void PointerCoordinates::saveConfiguration(void) void PointerCoordinates::saveConfiguration(void)
{ {
conf->beginGroup("PointerCoordinates"); conf->beginGroup("PointerCoordinates");
conf->setValue("enable_at_startup", getFlagEnableAtStartup()); conf->setValue("enable_at_startup", getFlagEnableAtStartup());
conf->setValue("flag_show_button", getFlagShowCoordinatesButton()); conf->setValue("flag_show_button", getFlagShowCoordinatesButton());
conf->setValue("current_displaying_place", getCurrentCoordinatesPlac eKey()); conf->setValue("current_displaying_place", getCurrentCoordinatesPlac eKey());
conf->setValue("current_coordinate_system", getCurrentCoordinateSyst emKey()); conf->setValue("current_coordinate_system", getCurrentCoordinateSyst emKey());
QPair<int, int> cc = getCustomCoordinatesPlace(); QPair<int, int> cc = getCustomCoordinatesPlace();
conf->setValue("custom_coordinates", QString("%1,%2").arg(cc.first). arg(cc.second)); conf->setValue("custom_coordinates", QString("%1,%2").arg(cc.first). arg(cc.second));
//conf->setValue("text_color", "1,0.5,0"); //conf->setValue("text_color", "1,0.5,0");
conf->setValue("font_size", getFontSize()); conf->setValue("font_size", getFontSize());
conf->setValue("flag_show_constellation", getFlagShowConstellation() );
conf->endGroup(); conf->endGroup();
} }
void PointerCoordinates::setFlagShowCoordinatesButton(bool b) void PointerCoordinates::setFlagShowCoordinatesButton(bool b)
{ {
if (gui!=NULL) if (gui!=NULL)
{ {
if (b==true) { if (b==true) {
if (toolbarButton==NULL) { if (toolbarButton==NULL) {
 End of changes. 8 change blocks. 
3 lines changed or deleted 32 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/