Merge lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap into lp:stellarium

Proposed by gzotti
Status: Merged
Merged at revision: 9161
Proposed branch: lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap
Merge into: lp:stellarium
Diff against target: 1262 lines (+615/-216)
27 files modified
cmake/stellarium.rc.cmake (+1/-1)
plugins/Exoplanets/src/Exoplanet.cpp (+20/-1)
plugins/Exoplanets/src/Exoplanet.hpp (+10/-1)
plugins/MeteorShowers/src/MeteorShower.cpp (+56/-1)
plugins/MeteorShowers/src/MeteorShower.hpp (+11/-1)
plugins/Novae/src/Nova.cpp (+21/-1)
plugins/Novae/src/Nova.hpp (+17/-7)
plugins/Pulsars/src/Pulsar.cpp (+23/-1)
plugins/Pulsars/src/Pulsar.hpp (+23/-3)
plugins/Quasars/src/Quasar.cpp (+12/-1)
plugins/Quasars/src/Quasar.hpp (+15/-3)
plugins/RemoteControl/src/ObjectService.cpp (+1/-2)
plugins/Satellites/src/Satellite.cpp (+84/-0)
plugins/Satellites/src/Satellite.hpp (+22/-1)
plugins/Supernovae/src/Supernova.cpp (+15/-1)
plugins/Supernovae/src/Supernova.hpp (+17/-3)
src/core/StelObject.cpp (+101/-0)
src/core/StelObject.hpp (+30/-0)
src/core/StelObjectMgr.cpp (+16/-0)
src/core/StelObjectMgr.hpp (+5/-0)
src/core/modules/Atmosphere.cpp (+1/-1)
src/core/modules/Comet.cpp (+8/-0)
src/core/modules/Comet.hpp (+6/-0)
src/core/modules/Planet.cpp (+27/-0)
src/core/modules/Planet.hpp (+19/-7)
src/scripting/StelMainScriptAPI.cpp (+36/-135)
src/scripting/StelMainScriptAPI.hpp (+18/-45)
To merge this branch: bzr merge lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
gzotti Needs Resubmitting
Review via email: mp+319316@code.launchpad.net

Description of the change

Allow extended per-type object info maps, most useful for scripting.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Please make names of keys are more consistent - for example:
------------
map.insert("range_km", range);
map.insert("RangeRate_km/s", rangeRate);
------------
Plus keys, like "speed_km/s" is very strange.

Compare it to original format of key: azimuth-geometric.

The list of possible keys is necessary also in description of methods (the doxygen format).

I see inconsistency in filing of types - please compare:
-------------
map.insert("type", q_("meteor shower"));
-------------
and
-------------
map.insert("type", "artificial satellite");
-------------

And obvious that all translatable values should be given to users in two format - English and localized (see keys "name" and "localized-name" in original code).

review: Needs Fixing
9164. By gzotti

Added more doxygen, changed a few key names.

Revision history for this message
gzotti (georg-zotti) wrote :

Key name format is rather arbitrary as long as there is no reference documentation/guideline. I removed "km/s" types, which makes the tags harder to understand without docs IMHO.

Is it possible to dump such a map completely to script output, so that keys can be found more easily? (This should be added to the scripting API docs!)

name and localized-name are the only entries where un-/+translated makes sense. The map is mostly useful for scripting extensions.

I have added a basic implementation of the added tags into your various object catalog plugins.
I don't know exact details of object types for some plugins. Please add them. Some entries may have to be harmonized (RA/ra, ...) or even removed (position is already there)?

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Please read the comments in the code.

review: Needs Fixing
9165. By gzotti

Removed duplicate fields in AW's plugin object infomaps. Removed translations in InfoMap values. Remove Exoplanet detail lists in InfoMap.

Revision history for this message
gzotti (georg-zotti) wrote :

Done. More details can (and should) be adjusted anytime after merge when the principal function is seen OK.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) :
Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmake/stellarium.rc.cmake'
--- cmake/stellarium.rc.cmake 2016-05-31 16:54:06 +0000
+++ cmake/stellarium.rc.cmake 2017-03-09 14:02:12 +0000
@@ -11,7 +11,7 @@
11 BLOCK "040904B0" // Lang=English (United States, 0x0409, decimal 1033), CharSet=Unicode (0x04B0, decimal 1200).11 BLOCK "040904B0" // Lang=English (United States, 0x0409, decimal 1033), CharSet=Unicode (0x04B0, decimal 1200).
12 BEGIN12 BEGIN
13 VALUE "CompanyName", "Stellarium team\0"13 VALUE "CompanyName", "Stellarium team\0"
14 VALUE "FileDescription", "Stellarium is a free open source planetarium\0"14 VALUE "FileDescription", "Stellarium, the free open source planetarium\0"
15 VALUE "FileVersion", "@PACKAGE_VERSION@\0"15 VALUE "FileVersion", "@PACKAGE_VERSION@\0"
16 VALUE "LegalCopyright", "Copyright (C) @COPYRIGHT_YEARS@ Stellarium team\0"16 VALUE "LegalCopyright", "Copyright (C) @COPYRIGHT_YEARS@ Stellarium team\0"
17 VALUE "Info", "http://www.stellarium.org/\0"17 VALUE "Info", "http://www.stellarium.org/\0"
1818
=== modified file 'plugins/Exoplanets/src/Exoplanet.cpp'
--- plugins/Exoplanets/src/Exoplanet.cpp 2016-11-28 16:01:23 +0000
+++ plugins/Exoplanets/src/Exoplanet.cpp 2017-03-09 14:02:12 +0000
@@ -166,7 +166,7 @@
166 //166 //
167}167}
168168
169QVariantMap Exoplanet::getMap(void)169QVariantMap Exoplanet::getMap(void) const
170{170{
171 QVariantMap map;171 QVariantMap map;
172 map["designation"] = designation;172 map["designation"] = designation;
@@ -467,6 +467,25 @@
467 return str;467 return str;
468}468}
469469
470QVariantMap Exoplanet::getInfoMap(const StelCore *core) const
471{
472 QVariantMap map = StelObject::getInfoMap(core);
473
474 // Tentatively add a few more strings. Details are left to the plugin author.
475 if (!starProperName.isEmpty()) map["starProperName"] = starProperName;
476 map["distance"] = distance;
477 map["stype"] = stype;
478 map["smass"] = smass;
479 map["smetal"] = smetal;
480 // map["Vmag"] = Vmag; // maybe same as getVmagnitude?
481 map["sradius"] = sradius;
482 map["effectiveTemp"] = effectiveTemp;
483 map["hasHabitablePlanets"] = hasHabitableExoplanets;
484 map["type"] = "ExoplanetSystem"; // Replace default but confusing "Exoplanet" from class name.
485 // TODO: Maybe add number of habitables? Add details?
486 return map;
487}
488
470QString Exoplanet::getPlanetaryClassI18n(QString ptype) const489QString Exoplanet::getPlanetaryClassI18n(QString ptype) const
471{490{
472 QString result = "";491 QString result = "";
473492
=== modified file 'plugins/Exoplanets/src/Exoplanet.hpp'
--- plugins/Exoplanets/src/Exoplanet.hpp 2016-10-03 16:08:03 +0000
+++ plugins/Exoplanets/src/Exoplanet.hpp 2017-03-09 14:02:12 +0000
@@ -66,7 +66,7 @@
6666
67 //! Get a QVariantMap which describes the exoplanet. Could be used to67 //! Get a QVariantMap which describes the exoplanet. Could be used to
68 //! create a duplicate.68 //! create a duplicate.
69 QVariantMap getMap(void);69 QVariantMap getMap(void) const;
7070
71 //! Get the type of object71 //! Get the type of object
72 virtual QString getType(void) const72 virtual QString getType(void) const
@@ -80,6 +80,15 @@
80 //! @param core A pointer to the core80 //! @param core A pointer to the core
81 //! @flags a set of flags with information types to include.81 //! @flags a set of flags with information types to include.
82 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;82 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
83 //! Return a map like StelObject, but with a few extra tags also available in getMap().
84 //! - distance = distance in pc
85 //! - stype = Spectral type of star
86 //! - smass = Mass of star in Msun
87 //! - smetal = [Fe/H] of star
88 //! - sradius = Radius of star in Rsun
89 //! - effectiveTemp = Effective temperature of star in K
90 //! - hasHabitablePlanets (true/false)
91 virtual QVariantMap getInfoMap(const StelCore *core) const;
83 virtual Vec3f getInfoColor(void) const;92 virtual Vec3f getInfoColor(void) const;
84 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const93 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
85 {94 {
8695
=== modified file 'plugins/MeteorShowers/src/MeteorShower.cpp'
--- plugins/MeteorShowers/src/MeteorShower.cpp 2017-01-08 16:39:11 +0000
+++ plugins/MeteorShowers/src/MeteorShower.cpp 2017-03-09 14:02:12 +0000
@@ -476,7 +476,7 @@
476 return qRound(gaussian);476 return qRound(gaussian);
477}477}
478478
479QString MeteorShower::getSolarLongitude(QDate date) const479QString MeteorShower::getSolarLongitude(QDate date)
480{480{
481 //The number of days (positive or negative) since Greenwich noon,481 //The number of days (positive or negative) since Greenwich noon,
482 //Terrestrial Time, on 1 January 2000 (J2000.0)482 //Terrestrial Time, on 1 January 2000 (J2000.0)
@@ -632,3 +632,58 @@
632632
633 return str;633 return str;
634}634}
635
636QVariantMap MeteorShower::getInfoMap(const StelCore *core) const
637{
638 QVariantMap map = StelObject::getInfoMap(core);
639
640 if (enabled())
641 {
642 QString mstdata;
643 if (m_status == ACTIVE_GENERIC)
644 {
645 mstdata = "generic-data";
646 }
647 else if (m_status == ACTIVE_CONFIRMED)
648 {
649 mstdata = "confirmed-data";
650 }
651 else if (m_status == INACTIVE)
652 {
653 mstdata = "inactive";
654 }
655 map.insert("status", mstdata);
656
657 if (!m_showerID.toInt())
658 {
659 map.insert("id", m_showerID);
660 }
661 else
662 {
663 map.insert("id", "?");
664 }
665
666 map.insert("velocity", m_speed);
667 map.insert("population-index", m_pidx);
668 map.insert("parent", m_parentObj);
669
670 if(m_activity.zhr > 0)
671 {
672 map.insert("zhr-max", m_activity.zhr);
673 }
674 else
675 {
676 QString varStr="variable";
677 if(m_activity.variable.size() == 2)
678 {
679 varStr=QString("%1; %2-%3")
680 .arg("variable")
681 .arg(m_activity.variable.at(0))
682 .arg(m_activity.variable.at(1));
683 }
684 map.insert("zhr-max", varStr);
685 }
686 }
687
688 return map;
689}
635690
=== modified file 'plugins/MeteorShowers/src/MeteorShower.hpp'
--- plugins/MeteorShowers/src/MeteorShower.hpp 2015-08-29 02:37:17 +0000
+++ plugins/MeteorShowers/src/MeteorShower.hpp 2017-03-09 14:02:12 +0000
@@ -105,6 +105,16 @@
105 // Methods defined in StelObject class105 // Methods defined in StelObject class
106 //106 //
107 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;107 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
108 //! Return a map like StelObject, but with a few extra tags:
109 // TODO: Describe the fields!
110 //! - status
111 //! - id
112 //! - type (translated string "meteor shower")
113 //! - speed (km/s)
114 //! - pop-idx (population index)
115 //! - parent
116 //! - zhr-max (information string)
117 virtual QVariantMap getInfoMap(const StelCore *core) const;
108 virtual QString getType(void) const { return "MeteorShower"; }118 virtual QString getType(void) const { return "MeteorShower"; }
109 virtual QString getEnglishName(void) const { return m_designation.trimmed(); }119 virtual QString getEnglishName(void) const { return m_designation.trimmed(); }
110 virtual QString getNameI18n(void) const { return q_(m_designation.trimmed()); }120 virtual QString getNameI18n(void) const { return q_(m_designation.trimmed()); }
@@ -151,7 +161,7 @@
151 //! Gets the solar longitude for a specified date161 //! Gets the solar longitude for a specified date
152 //! @param date QDate162 //! @param date QDate
153 //! @return solar longitude in degree163 //! @return solar longitude in degree
154 QString getSolarLongitude(QDate date) const;164 static QString getSolarLongitude(QDate date);
155};165};
156166
157#endif /*_METEORSHOWER_HPP_*/167#endif /*_METEORSHOWER_HPP_*/
158168
=== modified file 'plugins/Novae/src/Nova.cpp'
--- plugins/Novae/src/Nova.cpp 2016-07-30 18:20:22 +0000
+++ plugins/Novae/src/Nova.cpp 2017-03-09 14:02:12 +0000
@@ -80,7 +80,7 @@
80 //80 //
81}81}
8282
83QVariantMap Nova::getMap(void)83QVariantMap Nova::getMap(void) const
84{84{
85 QVariantMap map;85 QVariantMap map;
86 map["designation"] = designation;86 map["designation"] = designation;
@@ -161,6 +161,26 @@
161 return str;161 return str;
162}162}
163163
164
165QVariantMap Nova::getInfoMap(const StelCore *core) const
166{
167 QVariantMap map = StelObject::getInfoMap(core);
168
169 map["designation"] = designation;
170 map["name"] = novaName;
171 map["nova-type"] = novaType;
172 map["max-magnitude"] = maxMagnitude;
173 map["min-magnitude"] = minMagnitude;
174 map["peakJD"] = peakJD;
175 map["m2"] = m2;
176 map["m3"] = m3;
177 map["m6"] = m6;
178 map["m9"] = m9;
179 map["distance"] = distance;
180
181 return map;
182}
183
164Vec3f Nova::getInfoColor(void) const184Vec3f Nova::getInfoColor(void) const
165{185{
166 return Vec3f(1.0, 1.0, 1.0);186 return Vec3f(1.0, 1.0, 1.0);
167187
=== modified file 'plugins/Novae/src/Nova.hpp'
--- plugins/Novae/src/Nova.hpp 2015-12-22 15:15:35 +0000
+++ plugins/Novae/src/Nova.hpp 2017-03-09 14:02:12 +0000
@@ -46,19 +46,29 @@
46 Nova(const QVariantMap& map);46 Nova(const QVariantMap& map);
47 ~Nova();47 ~Nova();
4848
49 //! Get a QVariantMap which describes the nova. Could be used to49 //! Get a QVariantMap which describes the nova. Could be used to create a duplicate.
50 //! create a duplicate.50 QVariantMap getMap(void) const;
51 QVariantMap getMap(void);
5251
53 virtual QString getType(void) const52 virtual QString getType(void) const {return "Nova";}
54 {
55 return "Nova";
56 }
5753
58 //! Get an HTML string to describe the object54 //! Get an HTML string to describe the object
59 //! @param core A pointer to the core55 //! @param core A pointer to the core
60 //! @flags a set of flags with information types to include.56 //! @flags a set of flags with information types to include.
61 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;57 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
58 //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
59 // TODO: Describe the entries!
60 //! - designation
61 //! - name
62 //! - nova-type
63 //! - max-magnitude
64 //! - min-magnitude
65 //! - peakJD
66 //! - m2
67 //! - m3
68 //! - m6
69 //! - m9
70 //! - distance
71 virtual QVariantMap getInfoMap(const StelCore *core) const;
62 virtual Vec3f getInfoColor(void) const;72 virtual Vec3f getInfoColor(void) const;
63 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const73 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
64 {74 {
6575
=== modified file 'plugins/Pulsars/src/Pulsar.cpp'
--- plugins/Pulsars/src/Pulsar.cpp 2016-11-28 14:24:21 +0000
+++ plugins/Pulsars/src/Pulsar.cpp 2017-03-09 14:02:12 +0000
@@ -111,7 +111,7 @@
111 //111 //
112}112}
113113
114QVariantMap Pulsar::getMap(void)114QVariantMap Pulsar::getMap(void) const
115{115{
116 QVariantMap map;116 QVariantMap map;
117 map["designation"] = designation;117 map["designation"] = designation;
@@ -268,6 +268,28 @@
268 return str;268 return str;
269}269}
270270
271QVariantMap Pulsar::getInfoMap(const StelCore *core) const
272{
273 QVariantMap map = StelObject::getInfoMap(core);
274
275 map["parallax"] = parallax;
276 map["bperiod"] = bperiod;
277 map["frequency"] = frequency;
278 map["pfrequency"] = pfrequency;
279 map["pderivative"] = pderivative;
280 map["dmeasure"] = dmeasure;
281 map["eccentricity"] = eccentricity;
282 map["period"] = period;
283 map["w50"] = w50;
284 map["s400"] = s400;
285 map["s600"] = s600;
286 map["s1400"] = s1400;
287 map["distance"] = distance;
288 map["glitch"] = glitch;
289 map["notes"] = notes;
290 return map;
291}
292
271Vec3f Pulsar::getInfoColor(void) const293Vec3f Pulsar::getInfoColor(void) const
272{294{
273 return Vec3f(1.0, 1.0, 1.0);295 return Vec3f(1.0, 1.0, 1.0);
274296
=== modified file 'plugins/Pulsars/src/Pulsar.hpp'
--- plugins/Pulsars/src/Pulsar.hpp 2015-05-30 19:56:47 +0000
+++ plugins/Pulsars/src/Pulsar.hpp 2017-03-09 14:02:12 +0000
@@ -46,9 +46,27 @@
46 Pulsar(const QVariantMap& map);46 Pulsar(const QVariantMap& map);
47 ~Pulsar();47 ~Pulsar();
4848
49 //! Get a QVariantMap which describes the pulsar. Could be used to49 //! Get a QVariantMap which describes the pulsar. Could be used to create a duplicate.
50 //! create a duplicate.50 // TODO: Add proper documentation of these fields!
51 QVariantMap getMap(void);51 //! - designation
52 //! - parallax
53 //! - bperiod
54 //! - frequency
55 //! - pfrequency
56 //! - pderivative
57 //! - dmeasure
58 //! - eccentricity
59 //! - RA
60 //! - DE
61 //! - period
62 //! - w50
63 //! - s400
64 //! - s600
65 //! - s1400
66 //! - distance
67 //! - glitch
68 //! - notes
69 QVariantMap getMap(void) const;
5270
53 //! Get the type of object71 //! Get the type of object
54 virtual QString getType(void) const72 virtual QString getType(void) const
@@ -62,6 +80,8 @@
62 //! @param core A pointer to the core80 //! @param core A pointer to the core
63 //! @flags a set of flags with information types to include.81 //! @flags a set of flags with information types to include.
64 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;82 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
83 //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(), except for designation, RA and DE fields.
84 virtual QVariantMap getInfoMap(const StelCore *core) const;
65 virtual Vec3f getInfoColor(void) const;85 virtual Vec3f getInfoColor(void) const;
66 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const86 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
67 {87 {
6888
=== modified file 'plugins/Quasars/src/Quasar.cpp'
--- plugins/Quasars/src/Quasar.cpp 2016-11-28 14:24:21 +0000
+++ plugins/Quasars/src/Quasar.cpp 2017-03-09 14:02:12 +0000
@@ -73,7 +73,7 @@
73 //73 //
74}74}
7575
76QVariantMap Quasar::getMap(void)76QVariantMap Quasar::getMap(void) const
77{77{
78 QVariantMap map;78 QVariantMap map;
79 map["designation"] = designation;79 map["designation"] = designation;
@@ -137,6 +137,17 @@
137 return str;137 return str;
138}138}
139139
140QVariantMap Quasar::getInfoMap(const StelCore *core) const
141{
142 QVariantMap map = StelObject::getInfoMap(core);
143
144 map["amag"] = AMagnitude;
145 map["bV"] = bV;
146 map["redshift"] = redshift;
147
148 return map;
149}
150
140Vec3f Quasar::getInfoColor(void) const151Vec3f Quasar::getInfoColor(void) const
141{152{
142 return Vec3f(1.0, 1.0, 1.0);153 return Vec3f(1.0, 1.0, 1.0);
143154
=== modified file 'plugins/Quasars/src/Quasar.hpp'
--- plugins/Quasars/src/Quasar.hpp 2016-07-30 18:20:22 +0000
+++ plugins/Quasars/src/Quasar.hpp 2017-03-09 14:02:12 +0000
@@ -46,9 +46,15 @@
46 Quasar(const QVariantMap& map);46 Quasar(const QVariantMap& map);
47 ~Quasar();47 ~Quasar();
4848
49 //! Get a QVariantMap which describes the Quasar. Could be used to49 //! Get a QVariantMap which describes the Quasar. Could be used to create a duplicate.
50 //! create a duplicate.50 //! - designation
51 QVariantMap getMap(void);51 //! - Vmag
52 //! - Amag
53 //! - bV
54 //! - RA
55 //! - DE
56 //! - z
57 QVariantMap getMap(void) const;
5258
53 virtual QString getType(void) const59 virtual QString getType(void) const
54 {60 {
@@ -61,6 +67,12 @@
61 //! @param core A pointer to the core67 //! @param core A pointer to the core
62 //! @flags a set of flags with information types to include.68 //! @flags a set of flags with information types to include.
63 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;69 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
70 //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
71 // TODO: Describe the fields.
72 //! - amag
73 //! - bV
74 //! - redshift
75 virtual QVariantMap getInfoMap(const StelCore *core) const;
64 virtual Vec3f getInfoColor(void) const;76 virtual Vec3f getInfoColor(void) const;
65 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const77 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
66 {78 {
6779
=== modified file 'plugins/RemoteControl/src/ObjectService.cpp'
--- plugins/RemoteControl/src/ObjectService.cpp 2017-02-04 14:15:20 +0000
+++ plugins/RemoteControl/src/ObjectService.cpp 2017-03-09 14:02:12 +0000
@@ -25,7 +25,6 @@
25#include "StelObjectMgr.hpp"25#include "StelObjectMgr.hpp"
26#include "StelTranslator.hpp"26#include "StelTranslator.hpp"
27#include "StelModuleMgr.hpp"27#include "StelModuleMgr.hpp"
28#include "StelMainScriptAPI.hpp"
29#include "StelObjectMgr.hpp"28#include "StelObjectMgr.hpp"
30#include "LandscapeMgr.hpp"29#include "LandscapeMgr.hpp"
3130
@@ -163,7 +162,7 @@
163 QJsonObject infoObj;162 QJsonObject infoObj;
164 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);163 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
165 StelObjectP obj = omgr->searchByName(name);164 StelObjectP obj = omgr->searchByName(name);
166 QVariantMap infoMap=StelMainScriptAPI::getObjectInfo(obj);165 QVariantMap infoMap=StelObjectMgr::getObjectInfo(obj);
167 QVariantMap::const_iterator i;166 QVariantMap::const_iterator i;
168 for (i=infoMap.constBegin(); i!=infoMap.constEnd(); ++i)167 for (i=infoMap.constBegin(); i!=infoMap.constEnd(); ++i)
169 infoObj.insert(i.key(), i.value().toString());168 infoObj.insert(i.key(), i.value().toString());
170169
=== modified file 'plugins/Satellites/src/Satellite.cpp'
--- plugins/Satellites/src/Satellite.cpp 2017-01-08 16:39:11 +0000
+++ plugins/Satellites/src/Satellite.cpp 2017-03-09 14:02:12 +0000
@@ -395,6 +395,90 @@
395 return str;395 return str;
396}396}
397397
398QVariantMap Satellite::getInfoMap(const StelCore *core) const
399{
400 QVariantMap map = StelObject::getInfoMap(core);
401
402 map.insert("description", QString(description).replace("\n", " - "));
403 map.insert("catalog", id);
404 if (!internationalDesignator.isEmpty())
405 map.insert("international-designator", internationalDesignator);
406
407 if (stdMag==99.f) // replace whatever has been computed
408 {
409 map.insert("vmag", "?");
410 map.insert("vmage", "?");
411 }
412
413 map.insert("range", range);
414 map.insert("rangerate", rangeRate);
415 map.insert("height", height);
416 map.insert("subpoint-lat", latLongSubPointPosition[0]);
417 map.insert("subpoint-long", latLongSubPointPosition[1]);
418 map.insert("TEME-km-X", position[0]);
419 map.insert("TEME-km-Y", position[1]);
420 map.insert("TEME-km-Z", position[2]);
421 map.insert("TEME-speed-X", velocity[0]);
422 map.insert("TEME-speed-Y", velocity[1]);
423 map.insert("TEME-speed-Z", velocity[2]);
424 if (sunReflAngle>0)
425 { // Iridium
426 map.insert("sun-reflection-angle", sunReflAngle);
427 }
428 map.insert("operational-status", getOperationalStatus());
429
430 //TODO: Move to a more prominent place.
431 QString visibilityState;
432 switch (visibility)
433 {
434 case RADAR_SUN:
435 visibilityState = "The satellite and the observer are in sunlight.";
436 break;
437 case VISIBLE:
438 visibilityState = "The satellite is visible.";
439 break;
440 case RADAR_NIGHT:
441 visibilityState = "The satellite is eclipsed.";
442 break;
443 case NOT_VISIBLE:
444 visibilityState = "The satellite is not visible";
445 break;
446 default:
447 break;
448 }
449 map.insert("visibility", visibilityState);
450 if (comms.size() > 0)
451 {
452 foreach(const CommLink &c, comms)
453 {
454 double dop = getDoppler(c.frequency);
455 double ddop = dop;
456 char sign;
457 if (dop<0.)
458 {
459 sign='-';
460 ddop*=-1;
461 }
462 else
463 sign='+';
464
465 QString commModDesc;
466 if (!c.modulation.isEmpty() && c.modulation != "") commModDesc=c.modulation;
467 if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(" ");
468 if (!c.description.isEmpty() && c.description != "") commModDesc.append(c.description);
469 if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(": ");
470 map.insertMulti("comm", QString("%1%2 MHz (%3%4 kHz)")
471 .arg(commModDesc)
472 .arg(c.frequency, 8, 'f', 5)
473 .arg(sign)
474 .arg(ddop, 6, 'f', 3));
475 }
476 }
477
478 return map;
479}
480
481
398Vec3d Satellite::getJ2000EquatorialPos(const StelCore* core) const482Vec3d Satellite::getJ2000EquatorialPos(const StelCore* core) const
399{483{
400 // Bugfix LP:1654331. I assume the elAzPosition has been computed without refraction! We must say this definitely.484 // Bugfix LP:1654331. I assume the elAzPosition has been computed without refraction! We must say this definitely.
401485
=== modified file 'plugins/Satellites/src/Satellite.hpp'
--- plugins/Satellites/src/Satellite.hpp 2016-11-21 20:20:20 +0000
+++ plugins/Satellites/src/Satellite.hpp 2017-03-09 14:02:12 +0000
@@ -131,8 +131,29 @@
131 //! Supported types for Satellite objects:131 //! Supported types for Satellite objects:
132 //! - Name: designation in large type with the description underneath132 //! - Name: designation in large type with the description underneath
133 //! - RaDecJ2000, RaDecOfDate, HourAngle, AltAzi133 //! - RaDecJ2000, RaDecOfDate, HourAngle, AltAzi
134 //! - Extra: range, rage rate and altitude of satellite above the Earth, comms frequencies, modulation types and so on.134 //! - Extra: range, range rate and altitude of satellite above the Earth, comms frequencies, modulation types and so on.
135 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;135 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
136 //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getInfoString().
137 //! - description
138 //! - catalog
139 //! - international-designator
140 //! - type
141 //! - range (distance in km)
142 //! - rangerate (distance change in km/s)
143 //! - height (height in km)
144 //! - subpoint-lat (latitude of subpoint, decimal degrees)
145 //! - subpoint-long (longitude of subpoint, decimal degrees)
146 //! - TEME-km-X
147 //! - TEME-km-Y
148 //! - TEME-km-Z
149 //! - TEME-speed-X
150 //! - TEME-speed-Y
151 //! - TEME-speed-Z
152 //! - sun-reflection-angle (if available)
153 //! - operational-status
154 //! - visibility (descriptive string)
155 //! - comm (Radio information, optional, if available. There may be several comm entries!)
156 virtual QVariantMap getInfoMap(const StelCore *core) const;
136 virtual Vec3f getInfoColor(void) const;157 virtual Vec3f getInfoColor(void) const;
137 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;158 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;
138 virtual float getVMagnitude(const StelCore* core) const;159 virtual float getVMagnitude(const StelCore* core) const;
139160
=== modified file 'plugins/Supernovae/src/Supernova.cpp'
--- plugins/Supernovae/src/Supernova.cpp 2016-12-10 15:11:36 +0000
+++ plugins/Supernovae/src/Supernova.cpp 2017-03-09 14:02:12 +0000
@@ -71,7 +71,7 @@
71 //71 //
72}72}
7373
74QVariantMap Supernova::getMap(void)74QVariantMap Supernova::getMap(void) const
75{75{
76 QVariantMap map;76 QVariantMap map;
77 map["designation"] = designation;77 map["designation"] = designation;
@@ -155,6 +155,20 @@
155 return str;155 return str;
156}156}
157157
158
159QVariantMap Supernova::getInfoMap(const StelCore *core) const
160{
161 QVariantMap map = StelObject::getInfoMap(core);
162
163 map["sntype"] = sntype;
164 map["max-magnitude"] = maxMagnitude;
165 map["peakJD"] = peakJD;
166 map["note"] = note;
167 map["distance"] = distance;
168
169 return map;
170}
171
158Vec3f Supernova::getInfoColor(void) const172Vec3f Supernova::getInfoColor(void) const
159{173{
160 return Vec3f(1.0, 1.0, 1.0);174 return Vec3f(1.0, 1.0, 1.0);
161175
=== modified file 'plugins/Supernovae/src/Supernova.hpp'
--- plugins/Supernovae/src/Supernova.hpp 2015-05-30 19:56:47 +0000
+++ plugins/Supernovae/src/Supernova.hpp 2017-03-09 14:02:12 +0000
@@ -46,9 +46,16 @@
46 Supernova(const QVariantMap& map);46 Supernova(const QVariantMap& map);
47 ~Supernova();47 ~Supernova();
4848
49 //! Get a QVariantMap which describes the supernova. Could be used to49 //! Get a QVariantMap which describes the supernova. Could be used to create a duplicate.
50 //! create a duplicate.50 //! - designation
51 QVariantMap getMap(void);51 //! - sntype
52 //! - maxMagnitude
53 //! - peakJD
54 //! - snra
55 //! - snde
56 //! - note
57 //! - distance
58 QVariantMap getMap(void) const;
5259
53 virtual QString getType(void) const60 virtual QString getType(void) const
54 {61 {
@@ -59,6 +66,13 @@
59 //! @param core A pointer to the core66 //! @param core A pointer to the core
60 //! @flags a set of flags with information types to include.67 //! @flags a set of flags with information types to include.
61 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;68 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
69 //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
70 //! - sntype
71 //! - max-magnitude
72 //! - peakJD
73 //! - note
74 //! - distance
75 virtual QVariantMap getInfoMap(const StelCore *core) const;
62 virtual Vec3f getInfoColor(void) const;76 virtual Vec3f getInfoColor(void) const;
63 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const77 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
64 {78 {
6579
=== modified file 'src/core/StelObject.cpp'
--- src/core/StelObject.cpp 2016-12-29 15:37:01 +0000
+++ src/core/StelObject.cpp 2017-03-09 14:02:12 +0000
@@ -318,3 +318,104 @@
318 }318 }
319}319}
320320
321QVariantMap StelObject::getInfoMap(const StelCore *core) const
322{
323 QVariantMap map;
324
325 Vec3d pos;
326 double ra, dec, alt, az, glong, glat;
327 bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage();
328
329 map.insert("type", getType());
330 // ra/dec
331 pos = getEquinoxEquatorialPos(core);
332 StelUtils::rectToSphe(&ra, &dec, pos);
333 map.insert("ra", ra*180./M_PI);
334 map.insert("dec", dec*180./M_PI);
335
336 // ra/dec in J2000
337 pos = getJ2000EquatorialPos(core);
338 StelUtils::rectToSphe(&ra, &dec, pos);
339 map.insert("raJ2000", ra*180./M_PI);
340 map.insert("decJ2000", dec*180./M_PI);
341
342 // apparent altitude/azimuth
343 pos = getAltAzPosApparent(core);
344 StelUtils::rectToSphe(&az, &alt, pos);
345 float direction = 3.; // N is zero, E is 90 degrees
346 if (useOldAzimuth)
347 direction = 2.;
348 az = direction*M_PI - az;
349 if (az > M_PI*2)
350 az -= M_PI*2;
351
352 map.insert("altitude", alt*180./M_PI);
353 map.insert("azimuth", az*180./M_PI);
354
355 // geometric altitude/azimuth
356 pos = getAltAzPosGeometric(core);
357 StelUtils::rectToSphe(&az, &alt, pos);
358 az = direction*M_PI - az;
359 if (az > M_PI*2)
360 az -= M_PI*2;
361
362 map.insert("altitude-geometric", alt*180./M_PI);
363 map.insert("azimuth-geometric", az*180./M_PI);
364
365 // galactic long/lat
366 pos = getGalacticPos(core);
367 StelUtils::rectToSphe(&glong, &glat, pos);
368 map.insert("glong", glong*180./M_PI);
369 map.insert("glat", glat*180./M_PI);
370
371 // supergalactic long/lat
372 pos = getSupergalacticPos(core);
373 StelUtils::rectToSphe(&glong, &glat, pos);
374 map.insert("sglong", glong*180./M_PI);
375 map.insert("sglat", glat*180./M_PI);
376
377 SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
378 double ra_equ, dec_equ, lambda, beta;
379 // J2000
380 double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
381 double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
382
383 // ecliptic longitude/latitude (J2000 frame)
384 StelUtils::rectToSphe(&ra_equ,&dec_equ, getJ2000EquatorialPos(core));
385 StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
386 if (lambda<0) lambda+=2.0*M_PI;
387 map.insert("elongJ2000", lambda*180./M_PI);
388 map.insert("elatJ2000", beta*180./M_PI);
389
390 if (QString("Earth Sun").contains(core->getCurrentLocation().planetName))
391 {
392 // ecliptic longitude/latitude
393 StelUtils::rectToSphe(&ra_equ,&dec_equ, getEquinoxEquatorialPos(core));
394 StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
395 if (lambda<0) lambda+=2.0*M_PI;
396 map.insert("elong", lambda*180./M_PI);
397 map.insert("elat", beta*180./M_PI);
398 }
399
400 // magnitude
401 map.insert("vmag", getVMagnitude(core));
402 map.insert("vmage", getVMagnitudeWithExtinction(core));
403
404 // angular size
405 double angularSize = 2.*getAngularSize(core)*M_PI/180.;
406 bool sign;
407 double deg;
408 StelUtils::radToDecDeg(angularSize, sign, deg);
409 if (!sign)
410 deg *= -1;
411 map.insert("size", angularSize);
412 map.insert("size-dd", deg);
413 map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
414 map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
415
416 // english name or designation & localized name
417 map.insert("name", getEnglishName());
418 map.insert("localized-name", getNameI18n());
419
420 return map;
421}
321422
=== modified file 'src/core/StelObject.hpp'
--- src/core/StelObject.hpp 2016-12-29 15:37:01 +0000
+++ src/core/StelObject.hpp 2017-03-09 14:02:12 +0000
@@ -99,6 +99,36 @@
99 //! @return an HTML string containing information about the StelObject.99 //! @return an HTML string containing information about the StelObject.
100 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags=StelObject::AllInfo) const = 0;100 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags=StelObject::AllInfo) const = 0;
101101
102 //! Return a key/value map with data about an object's position, magnitude and so on. Useful in a context like scripting.
103 //! Derived objects can add their own special information tags.
104 //! @param core the current StelCore
105 //! @return a map of object data. Keys:
106 //! - altitude : apparent altitude angle in decimal degrees
107 //! - azimuth : apparent azimuth angle in decimal degrees
108 //! - altitude-geometric : geometric altitude angle in decimal degrees
109 //! - azimuth-geometric : geometric azimuth angle in decimal degrees
110 //! - ra : right ascension angle (current date frame) in decimal degrees
111 //! - dec : declination angle (current date frame) in decimal degrees
112 //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees
113 //! - decJ2000 : declination angle (J2000 frame) in decimal degrees
114 //! - glong : galactic longitude in decimal degrees
115 //! - glat : galactic latitude in decimal degrees
116 //! - sglong : supergalactic longitude in decimal degrees
117 //! - sglat : supergalactic latitude in decimal degrees
118 //! - elong : ecliptic longitude in decimal degrees (on Earth only!)
119 //! - elat : ecliptic latitude in decimal degrees (on Earth only!)
120 //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees
121 //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees
122 //! - vmag : visual magnitude
123 //! - vmage : visual magnitude (after atmospheric extinction)
124 //! - size: angular size in radians
125 //! - size-dd : angular size in decimal degrees
126 //! - size-deg : angular size in decimal degrees (formatted string)
127 //! - size-dms : angular size in DMS format
128 //! - name : english name of the object
129 //! - localized-name : localized name
130 virtual QVariantMap getInfoMap(const StelCore *core) const;
131
102 //! Return object's type. It should be the name of the class.132 //! Return object's type. It should be the name of the class.
103 virtual QString getType() const = 0;133 virtual QString getType() const = 0;
104134
105135
=== modified file 'src/core/StelObjectMgr.cpp'
--- src/core/StelObjectMgr.cpp 2017-01-06 09:53:37 +0000
+++ src/core/StelObjectMgr.cpp 2017-03-09 14:02:12 +0000
@@ -374,3 +374,19 @@
374 }374 }
375 return result;375 return result;
376}376}
377
378QVariantMap StelObjectMgr::getObjectInfo(const StelObjectP obj)
379{
380 QVariantMap map;
381 if (!obj)
382 {
383 qDebug() << "getObjectInfo WARNING - object not found";
384 map.insert("found", false);
385 }
386 else
387 {
388 map=obj->getInfoMap(StelApp::getInstance().getCore());
389 map.insert("found", true);
390 }
391 return map;
392}
377393
=== modified file 'src/core/StelObjectMgr.hpp'
--- src/core/StelObjectMgr.hpp 2016-07-03 21:58:54 +0000
+++ src/core/StelObjectMgr.hpp 2017-03-09 14:02:12 +0000
@@ -132,6 +132,11 @@
132 //! Default to 1.132 //! Default to 1.
133 void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}133 void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
134134
135 //! Return a QMap of data about the object (calls obj->getInfoMap()).
136 //! If obj is valid, add an element ["found", true].
137 //! If obj is NULL, returns a 1-element map [["found", false]]
138 static QVariantMap getObjectInfo(const StelObjectP obj);
139
135signals:140signals:
136 //! Indicate that the selected StelObjects has changed.141 //! Indicate that the selected StelObjects has changed.
137 //! @param action define if the user requested that the objects are added to the selection or just replace it142 //! @param action define if the user requested that the objects are added to the selection or just replace it
138143
=== modified file 'src/core/modules/Atmosphere.cpp'
--- src/core/modules/Atmosphere.cpp 2016-11-28 14:24:21 +0000
+++ src/core/modules/Atmosphere.cpp 2017-03-09 14:02:12 +0000
@@ -381,7 +381,7 @@
381381
382 // And draw everything at once382 // And draw everything at once
383 indicesBuffer.bind();383 indicesBuffer.bind();
384 int shift=0;384 std::size_t shift=0;
385 for (int y=0;y<skyResolutionY;++y)385 for (int y=0;y<skyResolutionY;++y)
386 {386 {
387 sPainter.glFuncs()->glDrawElements(GL_TRIANGLE_STRIP, (skyResolutionX+1)*2, GL_UNSIGNED_SHORT, reinterpret_cast<void*>(shift));387 sPainter.glFuncs()->glDrawElements(GL_TRIANGLE_STRIP, (skyResolutionX+1)*2, GL_UNSIGNED_SHORT, reinterpret_cast<void*>(shift));
388388
=== modified file 'src/core/modules/Comet.cpp'
--- src/core/modules/Comet.cpp 2017-01-08 16:39:11 +0000
+++ src/core/modules/Comet.cpp 2017-03-09 14:02:12 +0000
@@ -272,6 +272,14 @@
272 return str;272 return str;
273}273}
274274
275QVariantMap Comet::getInfoMap(const StelCore *core) const
276{
277 QVariantMap map = StelObject::getInfoMap(core);
278 map.insert("tail-length-km", tailFactors[1]*AU);
279 map.insert("coma-diameter-km", tailFactors[0]*AU);
280
281 return map;
282}
275void Comet::setSemiMajorAxis(const double value)283void Comet::setSemiMajorAxis(const double value)
276{284{
277 semiMajorAxis = value;285 semiMajorAxis = value;
278286
=== modified file 'src/core/modules/Comet.hpp'
--- src/core/modules/Comet.hpp 2015-09-13 21:33:23 +0000
+++ src/core/modules/Comet.hpp 2017-03-09 14:02:12 +0000
@@ -33,6 +33,7 @@
33 2014-01: GZ: Parabolic tails appropriately scaled/rotated. Much is currently empirical, leaving room for physics-based improvements.33 2014-01: GZ: Parabolic tails appropriately scaled/rotated. Much is currently empirical, leaving room for physics-based improvements.
34 2014-08: GZ: speedup in case hundreds of comets are loaded.34 2014-08: GZ: speedup in case hundreds of comets are loaded.
35 2014-11: GZ: tail extinction, better brightness balance.35 2014-11: GZ: tail extinction, better brightness balance.
36 2017-03: GZ: added fields to infoMap
36 */37 */
37class Comet : public Planet38class Comet : public Planet
38{39{
@@ -72,6 +73,11 @@
72 //! \param flags a set of InfoStringGroup items to include in the return value.73 //! \param flags a set of InfoStringGroup items to include in the return value.
73 //! \return a QString containing an HMTL encoded description of the Comet.74 //! \return a QString containing an HMTL encoded description of the Comet.
74 virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const;75 virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const;
76 //! In addition to Planet::getInfoMap(), Comets provides estimates for
77 //! - tail-length-km
78 //! - coma-diameter-km
79 //! using the formula from Guide found by the GSoC2012 initiative at http://www.projectpluto.com/update7b.htm#comet_tail_formula
80 virtual QVariantMap getInfoMap(const StelCore *core) const;
75 //The Comet class inherits the "Planet" type because the SolarSystem class81 //The Comet class inherits the "Planet" type because the SolarSystem class
76 //was not designed to handle different types of objects.82 //was not designed to handle different types of objects.
77 //virtual QString getType() const {return "Comet";}83 //virtual QString getType() const {return "Comet";}
7884
=== modified file 'src/core/modules/Planet.cpp'
--- src/core/modules/Planet.cpp 2017-01-26 17:39:02 +0000
+++ src/core/modules/Planet.cpp 2017-03-09 14:02:12 +0000
@@ -442,6 +442,33 @@
442 return str;442 return str;
443}443}
444444
445QVariantMap Planet::getInfoMap(const StelCore *core) const
446{
447 QVariantMap map = StelObject::getInfoMap(core);
448
449 if (getEnglishName()!="Sun")
450 {
451 const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos();
452 map.insert("distance", getJ2000EquatorialPos(core).length());
453 double phase=getPhase(observerHelioPos);
454 map.insert("phase", phase);
455 map.insert("illumination", 100.*phase);
456 double phaseAngle = getPhaseAngle(observerHelioPos);
457 map.insert("phase-angle", phaseAngle);
458 map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle));
459 map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle));
460 double elongation = getElongation(observerHelioPos);
461 map.insert("elongation", elongation);
462 map.insert("elongation-dms", StelUtils::radToDmsStr(elongation));
463 map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation));
464 map.insert("type", getPlanetTypeString()); // replace existing "type=Planet" by something more detailed.
465 // TBD: Is there ANY reason to keep "type"="Planet" and add a "ptype"=getPlanetTypeString() field?
466 }
467
468 return map;
469}
470
471
445//! Get sky label (sky translation)472//! Get sky label (sky translation)
446QString Planet::getSkyLabel(const StelCore*) const473QString Planet::getSkyLabel(const StelCore*) const
447{474{
448475
=== modified file 'src/core/modules/Planet.hpp'
--- src/core/modules/Planet.hpp 2017-01-06 16:52:05 +0000
+++ src/core/modules/Planet.hpp 2017-03-09 14:02:12 +0000
@@ -153,6 +153,18 @@
153 //! @param flags a set of InfoStringGroup items to include in the return value.153 //! @param flags a set of InfoStringGroup items to include in the return value.
154 //! @return a QString containing an HMTL encoded description of the Planet.154 //! @return a QString containing an HMTL encoded description of the Planet.
155 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;155 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
156 //! In addition to the entries from StelObject::getInfoMap(), Planet objects provide
157 //! - distance
158 //! - phase (result of getPhase)
159 //! - illumination (=100*phase)
160 //! - phase-angle
161 //! - phase-angle-dms (formatted string)
162 //! - phase-angle-deg (formatted string)
163 //! - elongation
164 //! - elongation-dms (formatted string)
165 //! - elongation-deg (formatted string)
166 //! - type (object type description)
167 virtual QVariantMap getInfoMap(const StelCore *core) const;
156 virtual double getCloseViewFov(const StelCore* core) const;168 virtual double getCloseViewFov(const StelCore* core) const;
157 virtual double getSatellitesFov(const StelCore* core) const;169 virtual double getSatellitesFov(const StelCore* core) const;
158 virtual double getParentSatellitesFov(const StelCore* core) const;170 virtual double getParentSatellitesFov(const StelCore* core) const;
@@ -213,21 +225,21 @@
213225
214 const RotationElements &getRotationElements(void) const {return re;}226 const RotationElements &getRotationElements(void) const {return re;}
215227
216 // Compute the position in the parent Planet coordinate system228 //! Compute the position in the parent Planet coordinate system
217 void computePositionWithoutOrbits(const double dateJDE);229 void computePositionWithoutOrbits(const double dateJDE);
218 void computePosition(const double dateJDE);230 void computePosition(const double dateJDE);
219231
220 // Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate.232 //! Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate.
221 // This requires both flavours of JD in cases involving Earth.233 //! This requires both flavours of JD in cases involving Earth.
222 void computeTransMatrix(double JD, double JDE);234 void computeTransMatrix(double JD, double JDE);
223235
224 // Get the phase angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)236 //! Get the phase angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
225 double getPhaseAngle(const Vec3d& obsPos) const;237 double getPhaseAngle(const Vec3d& obsPos) const;
226 // Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)238 //! Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
227 double getElongation(const Vec3d& obsPos) const;239 double getElongation(const Vec3d& obsPos) const;
228 // Get the angular size of the spheroid of the planet (i.e. without the rings)240 //! Get the angular size of the spheroid of the planet (i.e. without the rings)
229 double getSpheroidAngularSize(const StelCore* core) const;241 double getSpheroidAngularSize(const StelCore* core) const;
230 // Get the planet phase for an observer at pos obsPos in heliocentric coordinates (in AU)242 //! Get the planet phase for an observer at pos obsPos in heliocentric coordinates (in AU)
231 float getPhase(const Vec3d& obsPos) const;243 float getPhase(const Vec3d& obsPos) const;
232244
233 // Set the orbital elements245 // Set the orbital elements
234246
=== modified file 'src/scripting/StelMainScriptAPI.cpp'
--- src/scripting/StelMainScriptAPI.cpp 2017-02-04 14:15:20 +0000
+++ src/scripting/StelMainScriptAPI.cpp 2017-03-09 14:02:12 +0000
@@ -711,6 +711,39 @@
711 StelApp::getInstance().getScriptMgr().output(s);711 StelApp::getInstance().getScriptMgr().output(s);
712}712}
713713
714//! print contents of a QVariantMap
715//! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo()
716QString StelMainScriptAPI::mapToString(const QVariantMap& map) const
717{
718 QString res = QString("[\n");
719 QList<QVariant::Type> simpleTypeList;
720 simpleTypeList.push_back(QVariant::Bool);
721 simpleTypeList.push_back(QVariant::Int);
722 simpleTypeList.push_back(QVariant::UInt);
723 simpleTypeList.push_back(QVariant::Double);
724
725 QVariantMap::const_iterator i=map.constBegin();
726 while (i != map.constEnd()){
727
728 if (i.value().type()==QMetaType::QString)
729 {
730 res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.key()).arg(i.value().toString()));
731 }
732 else if (simpleTypeList.contains(i.value().type()))
733 {
734 res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key()).arg(i.value().toString()));
735 }
736 else
737 {
738 res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg(i.key()).arg(i.value().typeName()).arg(i.value().toString()));
739 }
740
741 ++i;
742 }
743 res.append( QString("]\n"));
744 return res;
745}
746
714void StelMainScriptAPI::resetOutput(void) const747void StelMainScriptAPI::resetOutput(void) const
715{748{
716 StelApp::getInstance().getScriptMgr().resetOutput();749 StelApp::getInstance().getScriptMgr().resetOutput();
@@ -841,7 +874,7 @@
841 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);874 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
842 StelObjectP obj = omgr->searchByName(name);875 StelObjectP obj = omgr->searchByName(name);
843876
844 return StelMainScriptAPI::getObjectInfo(obj);877 return StelObjectMgr::getObjectInfo(obj);
845}878}
846879
847QVariantMap StelMainScriptAPI::getSelectedObjectInfo()880QVariantMap StelMainScriptAPI::getSelectedObjectInfo()
@@ -857,140 +890,8 @@
857890
858 StelObjectP obj = omgr->getSelectedObject()[0];891 StelObjectP obj = omgr->getSelectedObject()[0];
859892
860 return StelMainScriptAPI::getObjectInfo(obj);893 return StelObjectMgr::getObjectInfo(obj);
861}894}
862
863QVariantMap StelMainScriptAPI::getObjectInfo(const StelObjectP obj)
864{
865 QVariantMap map;
866 if (!obj)
867 {
868 debug("getObjectData WARNING - object not found");
869 map.insert("found", false);
870 return map;
871 }
872 else
873 {
874 map.insert("found", true);
875 }
876
877 // OK, object found. Let's go.
878 Vec3d pos;
879 double ra, dec, alt, az, glong, glat;
880 StelCore* core = StelApp::getInstance().getCore();
881 bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage();
882
883 // ra/dec
884 pos = obj->getEquinoxEquatorialPos(core);
885 StelUtils::rectToSphe(&ra, &dec, pos);
886 map.insert("ra", ra*180./M_PI);
887 map.insert("dec", dec*180./M_PI);
888
889 // ra/dec in J2000
890 pos = obj->getJ2000EquatorialPos(core);
891 StelUtils::rectToSphe(&ra, &dec, pos);
892 map.insert("raJ2000", ra*180./M_PI);
893 map.insert("decJ2000", dec*180./M_PI);
894
895 // apparent altitude/azimuth
896 pos = obj->getAltAzPosApparent(core);
897 StelUtils::rectToSphe(&az, &alt, pos);
898 float direction = 3.; // N is zero, E is 90 degrees
899 if (useOldAzimuth)
900 direction = 2.;
901 az = direction*M_PI - az;
902 if (az > M_PI*2)
903 az -= M_PI*2;
904
905 map.insert("altitude", alt*180./M_PI);
906 map.insert("azimuth", az*180./M_PI);
907
908 // geometric altitude/azimuth
909 pos = obj->getAltAzPosGeometric(core);
910 StelUtils::rectToSphe(&az, &alt, pos);
911 az = direction*M_PI - az;
912 if (az > M_PI*2)
913 az -= M_PI*2;
914
915 map.insert("altitude-geometric", alt*180./M_PI);
916 map.insert("azimuth-geometric", az*180./M_PI);
917
918 // galactic long/lat
919 pos = obj->getGalacticPos(core);
920 StelUtils::rectToSphe(&glong, &glat, pos);
921 map.insert("glong", glong*180./M_PI);
922 map.insert("glat", glat*180./M_PI);
923
924 // supergalactic long/lat
925 pos = obj->getSupergalacticPos(core);
926 StelUtils::rectToSphe(&glong, &glat, pos);
927 map.insert("sglong", glong*180./M_PI);
928 map.insert("sglat", glat*180./M_PI);
929
930 SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
931 double ra_equ, dec_equ, lambda, beta;
932 // J2000
933 double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
934 double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
935
936 // ecliptic longitude/latitude (J2000 frame)
937 StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getJ2000EquatorialPos(core));
938 StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
939 if (lambda<0) lambda+=2.0*M_PI;
940 map.insert("elongJ2000", lambda*180./M_PI);
941 map.insert("elatJ2000", beta*180./M_PI);
942
943 if (QString("Earth Sun").contains(core->getCurrentLocation().planetName))
944 {
945 // ecliptic longitude/latitude
946 StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getEquinoxEquatorialPos(core));
947 StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
948 if (lambda<0) lambda+=2.0*M_PI;
949 map.insert("elong", lambda*180./M_PI);
950 map.insert("elat", beta*180./M_PI);
951 }
952
953 // magnitude
954 map.insert("vmag", obj->getVMagnitude(core));
955 map.insert("vmage", obj->getVMagnitudeWithExtinction(core));
956
957 // angular size
958 double angularSize = 2.*obj->getAngularSize(core)*M_PI/180.;
959 bool sign;
960 double deg;
961 StelUtils::radToDecDeg(angularSize, sign, deg);
962 if (!sign)
963 deg *= -1;
964 map.insert("size", angularSize);
965 map.insert("size-dd", deg);
966 map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
967 map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
968
969 if (obj->getType().toLower()=="planet" && obj->getEnglishName()!="Sun")
970 {
971 SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
972 map.insert("distance", obj->getJ2000EquatorialPos(core).length());
973 double phase = ssmgr->getPhaseForPlanet(obj->getEnglishName());
974 map.insert("phase", phase);
975 map.insert("illumination", 100.*phase);
976 double phaseAngle = ssmgr->getPhaseAngleForPlanet(obj->getEnglishName());
977 map.insert("phase-angle", phaseAngle);
978 map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle));
979 map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle));
980 double elongation = ssmgr->getElongationForPlanet(obj->getEnglishName());
981 map.insert("elongation", elongation);
982 map.insert("elongation-dms", StelUtils::radToDmsStr(elongation));
983 map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation));
984 map.insert("ptype", ssmgr->getPlanetType(obj->getEnglishName()));
985 }
986
987 // english name or designation & localized name
988 map.insert("name", obj->getEnglishName());
989 map.insert("localized-name", obj->getNameI18n());
990
991 return map;
992}
993
994895
995void StelMainScriptAPI::clear(const QString& state)896void StelMainScriptAPI::clear(const QString& state)
996{897{
997898
=== modified file 'src/scripting/StelMainScriptAPI.hpp'
--- src/scripting/StelMainScriptAPI.hpp 2017-02-04 14:15:20 +0000
+++ src/scripting/StelMainScriptAPI.hpp 2017-03-09 14:02:12 +0000
@@ -173,62 +173,29 @@
173 //! - size-deg : angular size in decimal degrees (formatted string)173 //! - size-deg : angular size in decimal degrees (formatted string)
174 //! - size-dms : angular size in DMS format174 //! - size-dms : angular size in DMS format
175 //! - localized-name : localized name175 //! - localized-name : localized name
176 //! The returned map can contain other information. For example, Solar System objects add:
176 //! - distance : distance to object in AU (for Solar system objects only!)177 //! - distance : distance to object in AU (for Solar system objects only!)
177 //! - phase : phase of object (for Solar system objects only!)178 //! - phase : phase (illuminated fraction, 0..1) of object (for Solar system objects only!)
178 //! - illumination : phase of object in percentages (for Solar system objects only!)179 //! - illumination : phase of object in percent (0..100) (for Solar system objects only!)
179 //! - phase-angle : phase angle of object in radians (for Solar system objects only!)180 //! - phase-angle : phase angle of object in radians (for Solar system objects only!)
180 //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!)181 //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!)
181 //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!)182 //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!)
182 //! - elongation : elongation of object in radians (for Solar system objects only!)183 //! - elongation : elongation of object in radians (for Solar system objects only!)
183 //! - elongation-dms : elongation of object in DMS (for Solar system objects only!)184 //! - elongation-dms : elongation of object in DMS (for Solar system objects only!)
184 //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!)185 //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!)
185 //! - ptype : object type (for Solar system objects only!)186 //! Other StelObject derivates, also those defined in plugins, may add more,
187 //! these fields are documented in the respective classes, or simply try what you get:
188 //! You can print a complete set of entries into output with the following commands:
189 //! @code
190 //! map=core.getSelectedObjectInfo();
191 //! core.output(core.mapToString(map));
192 //! @endcode
186 QVariantMap getObjectInfo(const QString& name);193 QVariantMap getObjectInfo(const QString& name);
187194
188 //! Fetch a map with data about an latest selected object's position, magnitude and so on195 //! Fetch a map with data about the latest selected object's position, magnitude and so on
189 //! @return a map of object data. Keys:196 //! @return a map of object data. See description for getObjectInfo(const QString& name);
190 //! - altitude : apparent altitude angle in decimal degrees
191 //! - azimuth : apparent azimuth angle in decimal degrees
192 //! - altitude-geometric : geometric altitude angle in decimal degrees
193 //! - azimuth-geometric : geometric azimuth angle in decimal degrees
194 //! - ra : right ascension angle (current date frame) in decimal degrees
195 //! - dec : declination angle in (current date frame) decimal degrees
196 //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees
197 //! - decJ2000 : declination angle in (J2000 frame) decimal degrees
198 //! - glong : galactic longitude in decimal degrees
199 //! - glat : galactic latitude in decimal degrees
200 //! - sglong : supergalactic longitude in decimal degrees
201 //! - sglat : supergalactic latitude in decimal degrees
202 //! - elong : ecliptic longitude in decimal degrees (on Earth only!)
203 //! - elat : ecliptic latitude in decimal degrees (on Earth only!)
204 //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees
205 //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees
206 //! - vmag : visual magnitude
207 //! - vmage : visual magnitude (extincted)
208 //! - size: angular size in radians
209 //! - size-dd : angular size in decimal degrees
210 //! - size-deg : angular size in decimal degrees (formatted string)
211 //! - size-dms : angular size in DMS format
212 //! - name : english name
213 //! - localized-name : localized name
214 //! - distance : distance to object in AU (for Solar system objects only!)
215 //! - phase : phase of object (for Solar system objects only!)
216 //! - illumination : phase of object in percentages (for Solar system objects only!)
217 //! - phase-angle : phase angle of object in radians (for Solar system objects only!)
218 //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!)
219 //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!)
220 //! - elongation : elongation of object in radians (for Solar system objects only!)
221 //! - elongation-dms : elongation of object in DMS (for Solar system objects only!)
222 //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!)
223 //! - ptype : object type (for Solar system objects only!)
224 QVariantMap getSelectedObjectInfo();197 QVariantMap getSelectedObjectInfo();
225198
226public:
227 //! Called by getSelectedObjectInfo() and getObjectInfo(name). Not useful to be scriptable, not a slot!
228 //! The static method can be called more easily by other components.
229 static QVariantMap getObjectInfo(const StelObjectP obj);
230
231public slots:
232 //! Clear the display options, setting a "standard" view.199 //! Clear the display options, setting a "standard" view.
233 //! Preset states:200 //! Preset states:
234 //! - natural : azimuthal mount, atmosphere, landscape,201 //! - natural : azimuthal mount, atmosphere, landscape,
@@ -735,6 +702,12 @@
735 //! @param s the message to be displayed on the output file.702 //! @param s the message to be displayed on the output file.
736 void output(const QString& s) const;703 void output(const QString& s) const;
737704
705 //! print contents of a QVariantMap as []-delimited list of [ "key" = <value>] lists.
706 //! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo()
707 //! @note string values are surrounded with ", simple numeric types are printed as themselves.
708 //! @note More complicated value types like lists are only indicated by their type name. You must extract those (and their contents) yourself.
709 QString mapToString(const QVariantMap &map) const;
710
738 //! Reset (clear) output file711 //! Reset (clear) output file
739 void resetOutput(void) const;712 void resetOutput(void) const;
740713