Merge lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap into lp:stellarium
- gz_fix-ObjectInfoMap
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexander Wolf | Approve | ||
gzotti | Needs Resubmitting | ||
Review via email: mp+319316@code.launchpad.net |
Commit message
Description of the change
Allow extended per-type object info maps, most useful for scripting.
gzotti (georg-zotti) wrote : | # |
Key name format is rather arbitrary as long as there is no reference documentation/
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)?
Alexander Wolf (alexwolf) wrote : | # |
Please read the comments in the code.
gzotti (georg-zotti) wrote : | # |
Done. More details can (and should) be adjusted anytime after merge when the principal function is seen OK.
Alexander Wolf (alexwolf) : | # |
Alexander Wolf (alexwolf) : | # |
Preview Diff
1 | === modified file 'cmake/stellarium.rc.cmake' | |||
2 | --- cmake/stellarium.rc.cmake 2016-05-31 16:54:06 +0000 | |||
3 | +++ cmake/stellarium.rc.cmake 2017-03-09 14:02:12 +0000 | |||
4 | @@ -11,7 +11,7 @@ | |||
5 | 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). |
6 | 12 | BEGIN | 12 | BEGIN |
7 | 13 | VALUE "CompanyName", "Stellarium team\0" | 13 | VALUE "CompanyName", "Stellarium team\0" |
9 | 14 | VALUE "FileDescription", "Stellarium is a free open source planetarium\0" | 14 | VALUE "FileDescription", "Stellarium, the free open source planetarium\0" |
10 | 15 | VALUE "FileVersion", "@PACKAGE_VERSION@\0" | 15 | VALUE "FileVersion", "@PACKAGE_VERSION@\0" |
11 | 16 | VALUE "LegalCopyright", "Copyright (C) @COPYRIGHT_YEARS@ Stellarium team\0" | 16 | VALUE "LegalCopyright", "Copyright (C) @COPYRIGHT_YEARS@ Stellarium team\0" |
12 | 17 | VALUE "Info", "http://www.stellarium.org/\0" | 17 | VALUE "Info", "http://www.stellarium.org/\0" |
13 | 18 | 18 | ||
14 | === modified file 'plugins/Exoplanets/src/Exoplanet.cpp' | |||
15 | --- plugins/Exoplanets/src/Exoplanet.cpp 2016-11-28 16:01:23 +0000 | |||
16 | +++ plugins/Exoplanets/src/Exoplanet.cpp 2017-03-09 14:02:12 +0000 | |||
17 | @@ -166,7 +166,7 @@ | |||
18 | 166 | // | 166 | // |
19 | 167 | } | 167 | } |
20 | 168 | 168 | ||
22 | 169 | QVariantMap Exoplanet::getMap(void) | 169 | QVariantMap Exoplanet::getMap(void) const |
23 | 170 | { | 170 | { |
24 | 171 | QVariantMap map; | 171 | QVariantMap map; |
25 | 172 | map["designation"] = designation; | 172 | map["designation"] = designation; |
26 | @@ -467,6 +467,25 @@ | |||
27 | 467 | return str; | 467 | return str; |
28 | 468 | } | 468 | } |
29 | 469 | 469 | ||
30 | 470 | QVariantMap Exoplanet::getInfoMap(const StelCore *core) const | ||
31 | 471 | { | ||
32 | 472 | QVariantMap map = StelObject::getInfoMap(core); | ||
33 | 473 | |||
34 | 474 | // Tentatively add a few more strings. Details are left to the plugin author. | ||
35 | 475 | if (!starProperName.isEmpty()) map["starProperName"] = starProperName; | ||
36 | 476 | map["distance"] = distance; | ||
37 | 477 | map["stype"] = stype; | ||
38 | 478 | map["smass"] = smass; | ||
39 | 479 | map["smetal"] = smetal; | ||
40 | 480 | // map["Vmag"] = Vmag; // maybe same as getVmagnitude? | ||
41 | 481 | map["sradius"] = sradius; | ||
42 | 482 | map["effectiveTemp"] = effectiveTemp; | ||
43 | 483 | map["hasHabitablePlanets"] = hasHabitableExoplanets; | ||
44 | 484 | map["type"] = "ExoplanetSystem"; // Replace default but confusing "Exoplanet" from class name. | ||
45 | 485 | // TODO: Maybe add number of habitables? Add details? | ||
46 | 486 | return map; | ||
47 | 487 | } | ||
48 | 488 | |||
49 | 470 | QString Exoplanet::getPlanetaryClassI18n(QString ptype) const | 489 | QString Exoplanet::getPlanetaryClassI18n(QString ptype) const |
50 | 471 | { | 490 | { |
51 | 472 | QString result = ""; | 491 | QString result = ""; |
52 | 473 | 492 | ||
53 | === modified file 'plugins/Exoplanets/src/Exoplanet.hpp' | |||
54 | --- plugins/Exoplanets/src/Exoplanet.hpp 2016-10-03 16:08:03 +0000 | |||
55 | +++ plugins/Exoplanets/src/Exoplanet.hpp 2017-03-09 14:02:12 +0000 | |||
56 | @@ -66,7 +66,7 @@ | |||
57 | 66 | 66 | ||
58 | 67 | //! Get a QVariantMap which describes the exoplanet. Could be used to | 67 | //! Get a QVariantMap which describes the exoplanet. Could be used to |
59 | 68 | //! create a duplicate. | 68 | //! create a duplicate. |
61 | 69 | QVariantMap getMap(void); | 69 | QVariantMap getMap(void) const; |
62 | 70 | 70 | ||
63 | 71 | //! Get the type of object | 71 | //! Get the type of object |
64 | 72 | virtual QString getType(void) const | 72 | virtual QString getType(void) const |
65 | @@ -80,6 +80,15 @@ | |||
66 | 80 | //! @param core A pointer to the core | 80 | //! @param core A pointer to the core |
67 | 81 | //! @flags a set of flags with information types to include. | 81 | //! @flags a set of flags with information types to include. |
68 | 82 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 82 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
69 | 83 | //! Return a map like StelObject, but with a few extra tags also available in getMap(). | ||
70 | 84 | //! - distance = distance in pc | ||
71 | 85 | //! - stype = Spectral type of star | ||
72 | 86 | //! - smass = Mass of star in Msun | ||
73 | 87 | //! - smetal = [Fe/H] of star | ||
74 | 88 | //! - sradius = Radius of star in Rsun | ||
75 | 89 | //! - effectiveTemp = Effective temperature of star in K | ||
76 | 90 | //! - hasHabitablePlanets (true/false) | ||
77 | 91 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
78 | 83 | virtual Vec3f getInfoColor(void) const; | 92 | virtual Vec3f getInfoColor(void) const; |
79 | 84 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const | 93 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const |
80 | 85 | { | 94 | { |
81 | 86 | 95 | ||
82 | === modified file 'plugins/MeteorShowers/src/MeteorShower.cpp' | |||
83 | --- plugins/MeteorShowers/src/MeteorShower.cpp 2017-01-08 16:39:11 +0000 | |||
84 | +++ plugins/MeteorShowers/src/MeteorShower.cpp 2017-03-09 14:02:12 +0000 | |||
85 | @@ -476,7 +476,7 @@ | |||
86 | 476 | return qRound(gaussian); | 476 | return qRound(gaussian); |
87 | 477 | } | 477 | } |
88 | 478 | 478 | ||
90 | 479 | QString MeteorShower::getSolarLongitude(QDate date) const | 479 | QString MeteorShower::getSolarLongitude(QDate date) |
91 | 480 | { | 480 | { |
92 | 481 | //The number of days (positive or negative) since Greenwich noon, | 481 | //The number of days (positive or negative) since Greenwich noon, |
93 | 482 | //Terrestrial Time, on 1 January 2000 (J2000.0) | 482 | //Terrestrial Time, on 1 January 2000 (J2000.0) |
94 | @@ -632,3 +632,58 @@ | |||
95 | 632 | 632 | ||
96 | 633 | return str; | 633 | return str; |
97 | 634 | } | 634 | } |
98 | 635 | |||
99 | 636 | QVariantMap MeteorShower::getInfoMap(const StelCore *core) const | ||
100 | 637 | { | ||
101 | 638 | QVariantMap map = StelObject::getInfoMap(core); | ||
102 | 639 | |||
103 | 640 | if (enabled()) | ||
104 | 641 | { | ||
105 | 642 | QString mstdata; | ||
106 | 643 | if (m_status == ACTIVE_GENERIC) | ||
107 | 644 | { | ||
108 | 645 | mstdata = "generic-data"; | ||
109 | 646 | } | ||
110 | 647 | else if (m_status == ACTIVE_CONFIRMED) | ||
111 | 648 | { | ||
112 | 649 | mstdata = "confirmed-data"; | ||
113 | 650 | } | ||
114 | 651 | else if (m_status == INACTIVE) | ||
115 | 652 | { | ||
116 | 653 | mstdata = "inactive"; | ||
117 | 654 | } | ||
118 | 655 | map.insert("status", mstdata); | ||
119 | 656 | |||
120 | 657 | if (!m_showerID.toInt()) | ||
121 | 658 | { | ||
122 | 659 | map.insert("id", m_showerID); | ||
123 | 660 | } | ||
124 | 661 | else | ||
125 | 662 | { | ||
126 | 663 | map.insert("id", "?"); | ||
127 | 664 | } | ||
128 | 665 | |||
129 | 666 | map.insert("velocity", m_speed); | ||
130 | 667 | map.insert("population-index", m_pidx); | ||
131 | 668 | map.insert("parent", m_parentObj); | ||
132 | 669 | |||
133 | 670 | if(m_activity.zhr > 0) | ||
134 | 671 | { | ||
135 | 672 | map.insert("zhr-max", m_activity.zhr); | ||
136 | 673 | } | ||
137 | 674 | else | ||
138 | 675 | { | ||
139 | 676 | QString varStr="variable"; | ||
140 | 677 | if(m_activity.variable.size() == 2) | ||
141 | 678 | { | ||
142 | 679 | varStr=QString("%1; %2-%3") | ||
143 | 680 | .arg("variable") | ||
144 | 681 | .arg(m_activity.variable.at(0)) | ||
145 | 682 | .arg(m_activity.variable.at(1)); | ||
146 | 683 | } | ||
147 | 684 | map.insert("zhr-max", varStr); | ||
148 | 685 | } | ||
149 | 686 | } | ||
150 | 687 | |||
151 | 688 | return map; | ||
152 | 689 | } | ||
153 | 635 | 690 | ||
154 | === modified file 'plugins/MeteorShowers/src/MeteorShower.hpp' | |||
155 | --- plugins/MeteorShowers/src/MeteorShower.hpp 2015-08-29 02:37:17 +0000 | |||
156 | +++ plugins/MeteorShowers/src/MeteorShower.hpp 2017-03-09 14:02:12 +0000 | |||
157 | @@ -105,6 +105,16 @@ | |||
158 | 105 | // Methods defined in StelObject class | 105 | // Methods defined in StelObject class |
159 | 106 | // | 106 | // |
160 | 107 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 107 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
161 | 108 | //! Return a map like StelObject, but with a few extra tags: | ||
162 | 109 | // TODO: Describe the fields! | ||
163 | 110 | //! - status | ||
164 | 111 | //! - id | ||
165 | 112 | //! - type (translated string "meteor shower") | ||
166 | 113 | //! - speed (km/s) | ||
167 | 114 | //! - pop-idx (population index) | ||
168 | 115 | //! - parent | ||
169 | 116 | //! - zhr-max (information string) | ||
170 | 117 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
171 | 108 | virtual QString getType(void) const { return "MeteorShower"; } | 118 | virtual QString getType(void) const { return "MeteorShower"; } |
172 | 109 | virtual QString getEnglishName(void) const { return m_designation.trimmed(); } | 119 | virtual QString getEnglishName(void) const { return m_designation.trimmed(); } |
173 | 110 | virtual QString getNameI18n(void) const { return q_(m_designation.trimmed()); } | 120 | virtual QString getNameI18n(void) const { return q_(m_designation.trimmed()); } |
174 | @@ -151,7 +161,7 @@ | |||
175 | 151 | //! Gets the solar longitude for a specified date | 161 | //! Gets the solar longitude for a specified date |
176 | 152 | //! @param date QDate | 162 | //! @param date QDate |
177 | 153 | //! @return solar longitude in degree | 163 | //! @return solar longitude in degree |
179 | 154 | QString getSolarLongitude(QDate date) const; | 164 | static QString getSolarLongitude(QDate date); |
180 | 155 | }; | 165 | }; |
181 | 156 | 166 | ||
182 | 157 | #endif /*_METEORSHOWER_HPP_*/ | 167 | #endif /*_METEORSHOWER_HPP_*/ |
183 | 158 | 168 | ||
184 | === modified file 'plugins/Novae/src/Nova.cpp' | |||
185 | --- plugins/Novae/src/Nova.cpp 2016-07-30 18:20:22 +0000 | |||
186 | +++ plugins/Novae/src/Nova.cpp 2017-03-09 14:02:12 +0000 | |||
187 | @@ -80,7 +80,7 @@ | |||
188 | 80 | // | 80 | // |
189 | 81 | } | 81 | } |
190 | 82 | 82 | ||
192 | 83 | QVariantMap Nova::getMap(void) | 83 | QVariantMap Nova::getMap(void) const |
193 | 84 | { | 84 | { |
194 | 85 | QVariantMap map; | 85 | QVariantMap map; |
195 | 86 | map["designation"] = designation; | 86 | map["designation"] = designation; |
196 | @@ -161,6 +161,26 @@ | |||
197 | 161 | return str; | 161 | return str; |
198 | 162 | } | 162 | } |
199 | 163 | 163 | ||
200 | 164 | |||
201 | 165 | QVariantMap Nova::getInfoMap(const StelCore *core) const | ||
202 | 166 | { | ||
203 | 167 | QVariantMap map = StelObject::getInfoMap(core); | ||
204 | 168 | |||
205 | 169 | map["designation"] = designation; | ||
206 | 170 | map["name"] = novaName; | ||
207 | 171 | map["nova-type"] = novaType; | ||
208 | 172 | map["max-magnitude"] = maxMagnitude; | ||
209 | 173 | map["min-magnitude"] = minMagnitude; | ||
210 | 174 | map["peakJD"] = peakJD; | ||
211 | 175 | map["m2"] = m2; | ||
212 | 176 | map["m3"] = m3; | ||
213 | 177 | map["m6"] = m6; | ||
214 | 178 | map["m9"] = m9; | ||
215 | 179 | map["distance"] = distance; | ||
216 | 180 | |||
217 | 181 | return map; | ||
218 | 182 | } | ||
219 | 183 | |||
220 | 164 | Vec3f Nova::getInfoColor(void) const | 184 | Vec3f Nova::getInfoColor(void) const |
221 | 165 | { | 185 | { |
222 | 166 | return Vec3f(1.0, 1.0, 1.0); | 186 | return Vec3f(1.0, 1.0, 1.0); |
223 | 167 | 187 | ||
224 | === modified file 'plugins/Novae/src/Nova.hpp' | |||
225 | --- plugins/Novae/src/Nova.hpp 2015-12-22 15:15:35 +0000 | |||
226 | +++ plugins/Novae/src/Nova.hpp 2017-03-09 14:02:12 +0000 | |||
227 | @@ -46,19 +46,29 @@ | |||
228 | 46 | Nova(const QVariantMap& map); | 46 | Nova(const QVariantMap& map); |
229 | 47 | ~Nova(); | 47 | ~Nova(); |
230 | 48 | 48 | ||
234 | 49 | //! Get a QVariantMap which describes the nova. Could be used to | 49 | //! Get a QVariantMap which describes the nova. Could be used to create a duplicate. |
235 | 50 | //! create a duplicate. | 50 | QVariantMap getMap(void) const; |
233 | 51 | QVariantMap getMap(void); | ||
236 | 52 | 51 | ||
241 | 53 | virtual QString getType(void) const | 52 | virtual QString getType(void) const {return "Nova";} |
238 | 54 | { | ||
239 | 55 | return "Nova"; | ||
240 | 56 | } | ||
242 | 57 | 53 | ||
243 | 58 | //! Get an HTML string to describe the object | 54 | //! Get an HTML string to describe the object |
244 | 59 | //! @param core A pointer to the core | 55 | //! @param core A pointer to the core |
245 | 60 | //! @flags a set of flags with information types to include. | 56 | //! @flags a set of flags with information types to include. |
246 | 61 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 57 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
247 | 58 | //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(). | ||
248 | 59 | // TODO: Describe the entries! | ||
249 | 60 | //! - designation | ||
250 | 61 | //! - name | ||
251 | 62 | //! - nova-type | ||
252 | 63 | //! - max-magnitude | ||
253 | 64 | //! - min-magnitude | ||
254 | 65 | //! - peakJD | ||
255 | 66 | //! - m2 | ||
256 | 67 | //! - m3 | ||
257 | 68 | //! - m6 | ||
258 | 69 | //! - m9 | ||
259 | 70 | //! - distance | ||
260 | 71 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
261 | 62 | virtual Vec3f getInfoColor(void) const; | 72 | virtual Vec3f getInfoColor(void) const; |
262 | 63 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const | 73 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const |
263 | 64 | { | 74 | { |
264 | 65 | 75 | ||
265 | === modified file 'plugins/Pulsars/src/Pulsar.cpp' | |||
266 | --- plugins/Pulsars/src/Pulsar.cpp 2016-11-28 14:24:21 +0000 | |||
267 | +++ plugins/Pulsars/src/Pulsar.cpp 2017-03-09 14:02:12 +0000 | |||
268 | @@ -111,7 +111,7 @@ | |||
269 | 111 | // | 111 | // |
270 | 112 | } | 112 | } |
271 | 113 | 113 | ||
273 | 114 | QVariantMap Pulsar::getMap(void) | 114 | QVariantMap Pulsar::getMap(void) const |
274 | 115 | { | 115 | { |
275 | 116 | QVariantMap map; | 116 | QVariantMap map; |
276 | 117 | map["designation"] = designation; | 117 | map["designation"] = designation; |
277 | @@ -268,6 +268,28 @@ | |||
278 | 268 | return str; | 268 | return str; |
279 | 269 | } | 269 | } |
280 | 270 | 270 | ||
281 | 271 | QVariantMap Pulsar::getInfoMap(const StelCore *core) const | ||
282 | 272 | { | ||
283 | 273 | QVariantMap map = StelObject::getInfoMap(core); | ||
284 | 274 | |||
285 | 275 | map["parallax"] = parallax; | ||
286 | 276 | map["bperiod"] = bperiod; | ||
287 | 277 | map["frequency"] = frequency; | ||
288 | 278 | map["pfrequency"] = pfrequency; | ||
289 | 279 | map["pderivative"] = pderivative; | ||
290 | 280 | map["dmeasure"] = dmeasure; | ||
291 | 281 | map["eccentricity"] = eccentricity; | ||
292 | 282 | map["period"] = period; | ||
293 | 283 | map["w50"] = w50; | ||
294 | 284 | map["s400"] = s400; | ||
295 | 285 | map["s600"] = s600; | ||
296 | 286 | map["s1400"] = s1400; | ||
297 | 287 | map["distance"] = distance; | ||
298 | 288 | map["glitch"] = glitch; | ||
299 | 289 | map["notes"] = notes; | ||
300 | 290 | return map; | ||
301 | 291 | } | ||
302 | 292 | |||
303 | 271 | Vec3f Pulsar::getInfoColor(void) const | 293 | Vec3f Pulsar::getInfoColor(void) const |
304 | 272 | { | 294 | { |
305 | 273 | return Vec3f(1.0, 1.0, 1.0); | 295 | return Vec3f(1.0, 1.0, 1.0); |
306 | 274 | 296 | ||
307 | === modified file 'plugins/Pulsars/src/Pulsar.hpp' | |||
308 | --- plugins/Pulsars/src/Pulsar.hpp 2015-05-30 19:56:47 +0000 | |||
309 | +++ plugins/Pulsars/src/Pulsar.hpp 2017-03-09 14:02:12 +0000 | |||
310 | @@ -46,9 +46,27 @@ | |||
311 | 46 | Pulsar(const QVariantMap& map); | 46 | Pulsar(const QVariantMap& map); |
312 | 47 | ~Pulsar(); | 47 | ~Pulsar(); |
313 | 48 | 48 | ||
317 | 49 | //! Get a QVariantMap which describes the pulsar. Could be used to | 49 | //! Get a QVariantMap which describes the pulsar. Could be used to create a duplicate. |
318 | 50 | //! create a duplicate. | 50 | // TODO: Add proper documentation of these fields! |
319 | 51 | QVariantMap getMap(void); | 51 | //! - designation |
320 | 52 | //! - parallax | ||
321 | 53 | //! - bperiod | ||
322 | 54 | //! - frequency | ||
323 | 55 | //! - pfrequency | ||
324 | 56 | //! - pderivative | ||
325 | 57 | //! - dmeasure | ||
326 | 58 | //! - eccentricity | ||
327 | 59 | //! - RA | ||
328 | 60 | //! - DE | ||
329 | 61 | //! - period | ||
330 | 62 | //! - w50 | ||
331 | 63 | //! - s400 | ||
332 | 64 | //! - s600 | ||
333 | 65 | //! - s1400 | ||
334 | 66 | //! - distance | ||
335 | 67 | //! - glitch | ||
336 | 68 | //! - notes | ||
337 | 69 | QVariantMap getMap(void) const; | ||
338 | 52 | 70 | ||
339 | 53 | //! Get the type of object | 71 | //! Get the type of object |
340 | 54 | virtual QString getType(void) const | 72 | virtual QString getType(void) const |
341 | @@ -62,6 +80,8 @@ | |||
342 | 62 | //! @param core A pointer to the core | 80 | //! @param core A pointer to the core |
343 | 63 | //! @flags a set of flags with information types to include. | 81 | //! @flags a set of flags with information types to include. |
344 | 64 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 82 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
345 | 83 | //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(), except for designation, RA and DE fields. | ||
346 | 84 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
347 | 65 | virtual Vec3f getInfoColor(void) const; | 85 | virtual Vec3f getInfoColor(void) const; |
348 | 66 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const | 86 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const |
349 | 67 | { | 87 | { |
350 | 68 | 88 | ||
351 | === modified file 'plugins/Quasars/src/Quasar.cpp' | |||
352 | --- plugins/Quasars/src/Quasar.cpp 2016-11-28 14:24:21 +0000 | |||
353 | +++ plugins/Quasars/src/Quasar.cpp 2017-03-09 14:02:12 +0000 | |||
354 | @@ -73,7 +73,7 @@ | |||
355 | 73 | // | 73 | // |
356 | 74 | } | 74 | } |
357 | 75 | 75 | ||
359 | 76 | QVariantMap Quasar::getMap(void) | 76 | QVariantMap Quasar::getMap(void) const |
360 | 77 | { | 77 | { |
361 | 78 | QVariantMap map; | 78 | QVariantMap map; |
362 | 79 | map["designation"] = designation; | 79 | map["designation"] = designation; |
363 | @@ -137,6 +137,17 @@ | |||
364 | 137 | return str; | 137 | return str; |
365 | 138 | } | 138 | } |
366 | 139 | 139 | ||
367 | 140 | QVariantMap Quasar::getInfoMap(const StelCore *core) const | ||
368 | 141 | { | ||
369 | 142 | QVariantMap map = StelObject::getInfoMap(core); | ||
370 | 143 | |||
371 | 144 | map["amag"] = AMagnitude; | ||
372 | 145 | map["bV"] = bV; | ||
373 | 146 | map["redshift"] = redshift; | ||
374 | 147 | |||
375 | 148 | return map; | ||
376 | 149 | } | ||
377 | 150 | |||
378 | 140 | Vec3f Quasar::getInfoColor(void) const | 151 | Vec3f Quasar::getInfoColor(void) const |
379 | 141 | { | 152 | { |
380 | 142 | return Vec3f(1.0, 1.0, 1.0); | 153 | return Vec3f(1.0, 1.0, 1.0); |
381 | 143 | 154 | ||
382 | === modified file 'plugins/Quasars/src/Quasar.hpp' | |||
383 | --- plugins/Quasars/src/Quasar.hpp 2016-07-30 18:20:22 +0000 | |||
384 | +++ plugins/Quasars/src/Quasar.hpp 2017-03-09 14:02:12 +0000 | |||
385 | @@ -46,9 +46,15 @@ | |||
386 | 46 | Quasar(const QVariantMap& map); | 46 | Quasar(const QVariantMap& map); |
387 | 47 | ~Quasar(); | 47 | ~Quasar(); |
388 | 48 | 48 | ||
392 | 49 | //! Get a QVariantMap which describes the Quasar. Could be used to | 49 | //! Get a QVariantMap which describes the Quasar. Could be used to create a duplicate. |
393 | 50 | //! create a duplicate. | 50 | //! - designation |
394 | 51 | QVariantMap getMap(void); | 51 | //! - Vmag |
395 | 52 | //! - Amag | ||
396 | 53 | //! - bV | ||
397 | 54 | //! - RA | ||
398 | 55 | //! - DE | ||
399 | 56 | //! - z | ||
400 | 57 | QVariantMap getMap(void) const; | ||
401 | 52 | 58 | ||
402 | 53 | virtual QString getType(void) const | 59 | virtual QString getType(void) const |
403 | 54 | { | 60 | { |
404 | @@ -61,6 +67,12 @@ | |||
405 | 61 | //! @param core A pointer to the core | 67 | //! @param core A pointer to the core |
406 | 62 | //! @flags a set of flags with information types to include. | 68 | //! @flags a set of flags with information types to include. |
407 | 63 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 69 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
408 | 70 | //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(). | ||
409 | 71 | // TODO: Describe the fields. | ||
410 | 72 | //! - amag | ||
411 | 73 | //! - bV | ||
412 | 74 | //! - redshift | ||
413 | 75 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
414 | 64 | virtual Vec3f getInfoColor(void) const; | 76 | virtual Vec3f getInfoColor(void) const; |
415 | 65 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const | 77 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const |
416 | 66 | { | 78 | { |
417 | 67 | 79 | ||
418 | === modified file 'plugins/RemoteControl/src/ObjectService.cpp' | |||
419 | --- plugins/RemoteControl/src/ObjectService.cpp 2017-02-04 14:15:20 +0000 | |||
420 | +++ plugins/RemoteControl/src/ObjectService.cpp 2017-03-09 14:02:12 +0000 | |||
421 | @@ -25,7 +25,6 @@ | |||
422 | 25 | #include "StelObjectMgr.hpp" | 25 | #include "StelObjectMgr.hpp" |
423 | 26 | #include "StelTranslator.hpp" | 26 | #include "StelTranslator.hpp" |
424 | 27 | #include "StelModuleMgr.hpp" | 27 | #include "StelModuleMgr.hpp" |
425 | 28 | #include "StelMainScriptAPI.hpp" | ||
426 | 29 | #include "StelObjectMgr.hpp" | 28 | #include "StelObjectMgr.hpp" |
427 | 30 | #include "LandscapeMgr.hpp" | 29 | #include "LandscapeMgr.hpp" |
428 | 31 | 30 | ||
429 | @@ -163,7 +162,7 @@ | |||
430 | 163 | QJsonObject infoObj; | 162 | QJsonObject infoObj; |
431 | 164 | StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); | 163 | StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); |
432 | 165 | StelObjectP obj = omgr->searchByName(name); | 164 | StelObjectP obj = omgr->searchByName(name); |
434 | 166 | QVariantMap infoMap=StelMainScriptAPI::getObjectInfo(obj); | 165 | QVariantMap infoMap=StelObjectMgr::getObjectInfo(obj); |
435 | 167 | QVariantMap::const_iterator i; | 166 | QVariantMap::const_iterator i; |
436 | 168 | for (i=infoMap.constBegin(); i!=infoMap.constEnd(); ++i) | 167 | for (i=infoMap.constBegin(); i!=infoMap.constEnd(); ++i) |
437 | 169 | infoObj.insert(i.key(), i.value().toString()); | 168 | infoObj.insert(i.key(), i.value().toString()); |
438 | 170 | 169 | ||
439 | === modified file 'plugins/Satellites/src/Satellite.cpp' | |||
440 | --- plugins/Satellites/src/Satellite.cpp 2017-01-08 16:39:11 +0000 | |||
441 | +++ plugins/Satellites/src/Satellite.cpp 2017-03-09 14:02:12 +0000 | |||
442 | @@ -395,6 +395,90 @@ | |||
443 | 395 | return str; | 395 | return str; |
444 | 396 | } | 396 | } |
445 | 397 | 397 | ||
446 | 398 | QVariantMap Satellite::getInfoMap(const StelCore *core) const | ||
447 | 399 | { | ||
448 | 400 | QVariantMap map = StelObject::getInfoMap(core); | ||
449 | 401 | |||
450 | 402 | map.insert("description", QString(description).replace("\n", " - ")); | ||
451 | 403 | map.insert("catalog", id); | ||
452 | 404 | if (!internationalDesignator.isEmpty()) | ||
453 | 405 | map.insert("international-designator", internationalDesignator); | ||
454 | 406 | |||
455 | 407 | if (stdMag==99.f) // replace whatever has been computed | ||
456 | 408 | { | ||
457 | 409 | map.insert("vmag", "?"); | ||
458 | 410 | map.insert("vmage", "?"); | ||
459 | 411 | } | ||
460 | 412 | |||
461 | 413 | map.insert("range", range); | ||
462 | 414 | map.insert("rangerate", rangeRate); | ||
463 | 415 | map.insert("height", height); | ||
464 | 416 | map.insert("subpoint-lat", latLongSubPointPosition[0]); | ||
465 | 417 | map.insert("subpoint-long", latLongSubPointPosition[1]); | ||
466 | 418 | map.insert("TEME-km-X", position[0]); | ||
467 | 419 | map.insert("TEME-km-Y", position[1]); | ||
468 | 420 | map.insert("TEME-km-Z", position[2]); | ||
469 | 421 | map.insert("TEME-speed-X", velocity[0]); | ||
470 | 422 | map.insert("TEME-speed-Y", velocity[1]); | ||
471 | 423 | map.insert("TEME-speed-Z", velocity[2]); | ||
472 | 424 | if (sunReflAngle>0) | ||
473 | 425 | { // Iridium | ||
474 | 426 | map.insert("sun-reflection-angle", sunReflAngle); | ||
475 | 427 | } | ||
476 | 428 | map.insert("operational-status", getOperationalStatus()); | ||
477 | 429 | |||
478 | 430 | //TODO: Move to a more prominent place. | ||
479 | 431 | QString visibilityState; | ||
480 | 432 | switch (visibility) | ||
481 | 433 | { | ||
482 | 434 | case RADAR_SUN: | ||
483 | 435 | visibilityState = "The satellite and the observer are in sunlight."; | ||
484 | 436 | break; | ||
485 | 437 | case VISIBLE: | ||
486 | 438 | visibilityState = "The satellite is visible."; | ||
487 | 439 | break; | ||
488 | 440 | case RADAR_NIGHT: | ||
489 | 441 | visibilityState = "The satellite is eclipsed."; | ||
490 | 442 | break; | ||
491 | 443 | case NOT_VISIBLE: | ||
492 | 444 | visibilityState = "The satellite is not visible"; | ||
493 | 445 | break; | ||
494 | 446 | default: | ||
495 | 447 | break; | ||
496 | 448 | } | ||
497 | 449 | map.insert("visibility", visibilityState); | ||
498 | 450 | if (comms.size() > 0) | ||
499 | 451 | { | ||
500 | 452 | foreach(const CommLink &c, comms) | ||
501 | 453 | { | ||
502 | 454 | double dop = getDoppler(c.frequency); | ||
503 | 455 | double ddop = dop; | ||
504 | 456 | char sign; | ||
505 | 457 | if (dop<0.) | ||
506 | 458 | { | ||
507 | 459 | sign='-'; | ||
508 | 460 | ddop*=-1; | ||
509 | 461 | } | ||
510 | 462 | else | ||
511 | 463 | sign='+'; | ||
512 | 464 | |||
513 | 465 | QString commModDesc; | ||
514 | 466 | if (!c.modulation.isEmpty() && c.modulation != "") commModDesc=c.modulation; | ||
515 | 467 | if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(" "); | ||
516 | 468 | if (!c.description.isEmpty() && c.description != "") commModDesc.append(c.description); | ||
517 | 469 | if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(": "); | ||
518 | 470 | map.insertMulti("comm", QString("%1%2 MHz (%3%4 kHz)") | ||
519 | 471 | .arg(commModDesc) | ||
520 | 472 | .arg(c.frequency, 8, 'f', 5) | ||
521 | 473 | .arg(sign) | ||
522 | 474 | .arg(ddop, 6, 'f', 3)); | ||
523 | 475 | } | ||
524 | 476 | } | ||
525 | 477 | |||
526 | 478 | return map; | ||
527 | 479 | } | ||
528 | 480 | |||
529 | 481 | |||
530 | 398 | Vec3d Satellite::getJ2000EquatorialPos(const StelCore* core) const | 482 | Vec3d Satellite::getJ2000EquatorialPos(const StelCore* core) const |
531 | 399 | { | 483 | { |
532 | 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. |
533 | 401 | 485 | ||
534 | === modified file 'plugins/Satellites/src/Satellite.hpp' | |||
535 | --- plugins/Satellites/src/Satellite.hpp 2016-11-21 20:20:20 +0000 | |||
536 | +++ plugins/Satellites/src/Satellite.hpp 2017-03-09 14:02:12 +0000 | |||
537 | @@ -131,8 +131,29 @@ | |||
538 | 131 | //! Supported types for Satellite objects: | 131 | //! Supported types for Satellite objects: |
539 | 132 | //! - Name: designation in large type with the description underneath | 132 | //! - Name: designation in large type with the description underneath |
540 | 133 | //! - RaDecJ2000, RaDecOfDate, HourAngle, AltAzi | 133 | //! - RaDecJ2000, RaDecOfDate, HourAngle, AltAzi |
542 | 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. |
543 | 135 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const; | 135 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const; |
544 | 136 | //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getInfoString(). | ||
545 | 137 | //! - description | ||
546 | 138 | //! - catalog | ||
547 | 139 | //! - international-designator | ||
548 | 140 | //! - type | ||
549 | 141 | //! - range (distance in km) | ||
550 | 142 | //! - rangerate (distance change in km/s) | ||
551 | 143 | //! - height (height in km) | ||
552 | 144 | //! - subpoint-lat (latitude of subpoint, decimal degrees) | ||
553 | 145 | //! - subpoint-long (longitude of subpoint, decimal degrees) | ||
554 | 146 | //! - TEME-km-X | ||
555 | 147 | //! - TEME-km-Y | ||
556 | 148 | //! - TEME-km-Z | ||
557 | 149 | //! - TEME-speed-X | ||
558 | 150 | //! - TEME-speed-Y | ||
559 | 151 | //! - TEME-speed-Z | ||
560 | 152 | //! - sun-reflection-angle (if available) | ||
561 | 153 | //! - operational-status | ||
562 | 154 | //! - visibility (descriptive string) | ||
563 | 155 | //! - comm (Radio information, optional, if available. There may be several comm entries!) | ||
564 | 156 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
565 | 136 | virtual Vec3f getInfoColor(void) const; | 157 | virtual Vec3f getInfoColor(void) const; |
566 | 137 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const; | 158 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const; |
567 | 138 | virtual float getVMagnitude(const StelCore* core) const; | 159 | virtual float getVMagnitude(const StelCore* core) const; |
568 | 139 | 160 | ||
569 | === modified file 'plugins/Supernovae/src/Supernova.cpp' | |||
570 | --- plugins/Supernovae/src/Supernova.cpp 2016-12-10 15:11:36 +0000 | |||
571 | +++ plugins/Supernovae/src/Supernova.cpp 2017-03-09 14:02:12 +0000 | |||
572 | @@ -71,7 +71,7 @@ | |||
573 | 71 | // | 71 | // |
574 | 72 | } | 72 | } |
575 | 73 | 73 | ||
577 | 74 | QVariantMap Supernova::getMap(void) | 74 | QVariantMap Supernova::getMap(void) const |
578 | 75 | { | 75 | { |
579 | 76 | QVariantMap map; | 76 | QVariantMap map; |
580 | 77 | map["designation"] = designation; | 77 | map["designation"] = designation; |
581 | @@ -155,6 +155,20 @@ | |||
582 | 155 | return str; | 155 | return str; |
583 | 156 | } | 156 | } |
584 | 157 | 157 | ||
585 | 158 | |||
586 | 159 | QVariantMap Supernova::getInfoMap(const StelCore *core) const | ||
587 | 160 | { | ||
588 | 161 | QVariantMap map = StelObject::getInfoMap(core); | ||
589 | 162 | |||
590 | 163 | map["sntype"] = sntype; | ||
591 | 164 | map["max-magnitude"] = maxMagnitude; | ||
592 | 165 | map["peakJD"] = peakJD; | ||
593 | 166 | map["note"] = note; | ||
594 | 167 | map["distance"] = distance; | ||
595 | 168 | |||
596 | 169 | return map; | ||
597 | 170 | } | ||
598 | 171 | |||
599 | 158 | Vec3f Supernova::getInfoColor(void) const | 172 | Vec3f Supernova::getInfoColor(void) const |
600 | 159 | { | 173 | { |
601 | 160 | return Vec3f(1.0, 1.0, 1.0); | 174 | return Vec3f(1.0, 1.0, 1.0); |
602 | 161 | 175 | ||
603 | === modified file 'plugins/Supernovae/src/Supernova.hpp' | |||
604 | --- plugins/Supernovae/src/Supernova.hpp 2015-05-30 19:56:47 +0000 | |||
605 | +++ plugins/Supernovae/src/Supernova.hpp 2017-03-09 14:02:12 +0000 | |||
606 | @@ -46,9 +46,16 @@ | |||
607 | 46 | Supernova(const QVariantMap& map); | 46 | Supernova(const QVariantMap& map); |
608 | 47 | ~Supernova(); | 47 | ~Supernova(); |
609 | 48 | 48 | ||
613 | 49 | //! Get a QVariantMap which describes the supernova. Could be used to | 49 | //! Get a QVariantMap which describes the supernova. Could be used to create a duplicate. |
614 | 50 | //! create a duplicate. | 50 | //! - designation |
615 | 51 | QVariantMap getMap(void); | 51 | //! - sntype |
616 | 52 | //! - maxMagnitude | ||
617 | 53 | //! - peakJD | ||
618 | 54 | //! - snra | ||
619 | 55 | //! - snde | ||
620 | 56 | //! - note | ||
621 | 57 | //! - distance | ||
622 | 58 | QVariantMap getMap(void) const; | ||
623 | 52 | 59 | ||
624 | 53 | virtual QString getType(void) const | 60 | virtual QString getType(void) const |
625 | 54 | { | 61 | { |
626 | @@ -59,6 +66,13 @@ | |||
627 | 59 | //! @param core A pointer to the core | 66 | //! @param core A pointer to the core |
628 | 60 | //! @flags a set of flags with information types to include. | 67 | //! @flags a set of flags with information types to include. |
629 | 61 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; | 68 | virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const; |
630 | 69 | //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(). | ||
631 | 70 | //! - sntype | ||
632 | 71 | //! - max-magnitude | ||
633 | 72 | //! - peakJD | ||
634 | 73 | //! - note | ||
635 | 74 | //! - distance | ||
636 | 75 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
637 | 62 | virtual Vec3f getInfoColor(void) const; | 76 | virtual Vec3f getInfoColor(void) const; |
638 | 63 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const | 77 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const |
639 | 64 | { | 78 | { |
640 | 65 | 79 | ||
641 | === modified file 'src/core/StelObject.cpp' | |||
642 | --- src/core/StelObject.cpp 2016-12-29 15:37:01 +0000 | |||
643 | +++ src/core/StelObject.cpp 2017-03-09 14:02:12 +0000 | |||
644 | @@ -318,3 +318,104 @@ | |||
645 | 318 | } | 318 | } |
646 | 319 | } | 319 | } |
647 | 320 | 320 | ||
648 | 321 | QVariantMap StelObject::getInfoMap(const StelCore *core) const | ||
649 | 322 | { | ||
650 | 323 | QVariantMap map; | ||
651 | 324 | |||
652 | 325 | Vec3d pos; | ||
653 | 326 | double ra, dec, alt, az, glong, glat; | ||
654 | 327 | bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage(); | ||
655 | 328 | |||
656 | 329 | map.insert("type", getType()); | ||
657 | 330 | // ra/dec | ||
658 | 331 | pos = getEquinoxEquatorialPos(core); | ||
659 | 332 | StelUtils::rectToSphe(&ra, &dec, pos); | ||
660 | 333 | map.insert("ra", ra*180./M_PI); | ||
661 | 334 | map.insert("dec", dec*180./M_PI); | ||
662 | 335 | |||
663 | 336 | // ra/dec in J2000 | ||
664 | 337 | pos = getJ2000EquatorialPos(core); | ||
665 | 338 | StelUtils::rectToSphe(&ra, &dec, pos); | ||
666 | 339 | map.insert("raJ2000", ra*180./M_PI); | ||
667 | 340 | map.insert("decJ2000", dec*180./M_PI); | ||
668 | 341 | |||
669 | 342 | // apparent altitude/azimuth | ||
670 | 343 | pos = getAltAzPosApparent(core); | ||
671 | 344 | StelUtils::rectToSphe(&az, &alt, pos); | ||
672 | 345 | float direction = 3.; // N is zero, E is 90 degrees | ||
673 | 346 | if (useOldAzimuth) | ||
674 | 347 | direction = 2.; | ||
675 | 348 | az = direction*M_PI - az; | ||
676 | 349 | if (az > M_PI*2) | ||
677 | 350 | az -= M_PI*2; | ||
678 | 351 | |||
679 | 352 | map.insert("altitude", alt*180./M_PI); | ||
680 | 353 | map.insert("azimuth", az*180./M_PI); | ||
681 | 354 | |||
682 | 355 | // geometric altitude/azimuth | ||
683 | 356 | pos = getAltAzPosGeometric(core); | ||
684 | 357 | StelUtils::rectToSphe(&az, &alt, pos); | ||
685 | 358 | az = direction*M_PI - az; | ||
686 | 359 | if (az > M_PI*2) | ||
687 | 360 | az -= M_PI*2; | ||
688 | 361 | |||
689 | 362 | map.insert("altitude-geometric", alt*180./M_PI); | ||
690 | 363 | map.insert("azimuth-geometric", az*180./M_PI); | ||
691 | 364 | |||
692 | 365 | // galactic long/lat | ||
693 | 366 | pos = getGalacticPos(core); | ||
694 | 367 | StelUtils::rectToSphe(&glong, &glat, pos); | ||
695 | 368 | map.insert("glong", glong*180./M_PI); | ||
696 | 369 | map.insert("glat", glat*180./M_PI); | ||
697 | 370 | |||
698 | 371 | // supergalactic long/lat | ||
699 | 372 | pos = getSupergalacticPos(core); | ||
700 | 373 | StelUtils::rectToSphe(&glong, &glat, pos); | ||
701 | 374 | map.insert("sglong", glong*180./M_PI); | ||
702 | 375 | map.insert("sglat", glat*180./M_PI); | ||
703 | 376 | |||
704 | 377 | SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); | ||
705 | 378 | double ra_equ, dec_equ, lambda, beta; | ||
706 | 379 | // J2000 | ||
707 | 380 | double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0); | ||
708 | 381 | double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE()); | ||
709 | 382 | |||
710 | 383 | // ecliptic longitude/latitude (J2000 frame) | ||
711 | 384 | StelUtils::rectToSphe(&ra_equ,&dec_equ, getJ2000EquatorialPos(core)); | ||
712 | 385 | StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta); | ||
713 | 386 | if (lambda<0) lambda+=2.0*M_PI; | ||
714 | 387 | map.insert("elongJ2000", lambda*180./M_PI); | ||
715 | 388 | map.insert("elatJ2000", beta*180./M_PI); | ||
716 | 389 | |||
717 | 390 | if (QString("Earth Sun").contains(core->getCurrentLocation().planetName)) | ||
718 | 391 | { | ||
719 | 392 | // ecliptic longitude/latitude | ||
720 | 393 | StelUtils::rectToSphe(&ra_equ,&dec_equ, getEquinoxEquatorialPos(core)); | ||
721 | 394 | StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta); | ||
722 | 395 | if (lambda<0) lambda+=2.0*M_PI; | ||
723 | 396 | map.insert("elong", lambda*180./M_PI); | ||
724 | 397 | map.insert("elat", beta*180./M_PI); | ||
725 | 398 | } | ||
726 | 399 | |||
727 | 400 | // magnitude | ||
728 | 401 | map.insert("vmag", getVMagnitude(core)); | ||
729 | 402 | map.insert("vmage", getVMagnitudeWithExtinction(core)); | ||
730 | 403 | |||
731 | 404 | // angular size | ||
732 | 405 | double angularSize = 2.*getAngularSize(core)*M_PI/180.; | ||
733 | 406 | bool sign; | ||
734 | 407 | double deg; | ||
735 | 408 | StelUtils::radToDecDeg(angularSize, sign, deg); | ||
736 | 409 | if (!sign) | ||
737 | 410 | deg *= -1; | ||
738 | 411 | map.insert("size", angularSize); | ||
739 | 412 | map.insert("size-dd", deg); | ||
740 | 413 | map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5)); | ||
741 | 414 | map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true)); | ||
742 | 415 | |||
743 | 416 | // english name or designation & localized name | ||
744 | 417 | map.insert("name", getEnglishName()); | ||
745 | 418 | map.insert("localized-name", getNameI18n()); | ||
746 | 419 | |||
747 | 420 | return map; | ||
748 | 421 | } | ||
749 | 321 | 422 | ||
750 | === modified file 'src/core/StelObject.hpp' | |||
751 | --- src/core/StelObject.hpp 2016-12-29 15:37:01 +0000 | |||
752 | +++ src/core/StelObject.hpp 2017-03-09 14:02:12 +0000 | |||
753 | @@ -99,6 +99,36 @@ | |||
754 | 99 | //! @return an HTML string containing information about the StelObject. | 99 | //! @return an HTML string containing information about the StelObject. |
755 | 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; |
756 | 101 | 101 | ||
757 | 102 | //! Return a key/value map with data about an object's position, magnitude and so on. Useful in a context like scripting. | ||
758 | 103 | //! Derived objects can add their own special information tags. | ||
759 | 104 | //! @param core the current StelCore | ||
760 | 105 | //! @return a map of object data. Keys: | ||
761 | 106 | //! - altitude : apparent altitude angle in decimal degrees | ||
762 | 107 | //! - azimuth : apparent azimuth angle in decimal degrees | ||
763 | 108 | //! - altitude-geometric : geometric altitude angle in decimal degrees | ||
764 | 109 | //! - azimuth-geometric : geometric azimuth angle in decimal degrees | ||
765 | 110 | //! - ra : right ascension angle (current date frame) in decimal degrees | ||
766 | 111 | //! - dec : declination angle (current date frame) in decimal degrees | ||
767 | 112 | //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees | ||
768 | 113 | //! - decJ2000 : declination angle (J2000 frame) in decimal degrees | ||
769 | 114 | //! - glong : galactic longitude in decimal degrees | ||
770 | 115 | //! - glat : galactic latitude in decimal degrees | ||
771 | 116 | //! - sglong : supergalactic longitude in decimal degrees | ||
772 | 117 | //! - sglat : supergalactic latitude in decimal degrees | ||
773 | 118 | //! - elong : ecliptic longitude in decimal degrees (on Earth only!) | ||
774 | 119 | //! - elat : ecliptic latitude in decimal degrees (on Earth only!) | ||
775 | 120 | //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees | ||
776 | 121 | //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees | ||
777 | 122 | //! - vmag : visual magnitude | ||
778 | 123 | //! - vmage : visual magnitude (after atmospheric extinction) | ||
779 | 124 | //! - size: angular size in radians | ||
780 | 125 | //! - size-dd : angular size in decimal degrees | ||
781 | 126 | //! - size-deg : angular size in decimal degrees (formatted string) | ||
782 | 127 | //! - size-dms : angular size in DMS format | ||
783 | 128 | //! - name : english name of the object | ||
784 | 129 | //! - localized-name : localized name | ||
785 | 130 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
786 | 131 | |||
787 | 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. |
788 | 103 | virtual QString getType() const = 0; | 133 | virtual QString getType() const = 0; |
789 | 104 | 134 | ||
790 | 105 | 135 | ||
791 | === modified file 'src/core/StelObjectMgr.cpp' | |||
792 | --- src/core/StelObjectMgr.cpp 2017-01-06 09:53:37 +0000 | |||
793 | +++ src/core/StelObjectMgr.cpp 2017-03-09 14:02:12 +0000 | |||
794 | @@ -374,3 +374,19 @@ | |||
795 | 374 | } | 374 | } |
796 | 375 | return result; | 375 | return result; |
797 | 376 | } | 376 | } |
798 | 377 | |||
799 | 378 | QVariantMap StelObjectMgr::getObjectInfo(const StelObjectP obj) | ||
800 | 379 | { | ||
801 | 380 | QVariantMap map; | ||
802 | 381 | if (!obj) | ||
803 | 382 | { | ||
804 | 383 | qDebug() << "getObjectInfo WARNING - object not found"; | ||
805 | 384 | map.insert("found", false); | ||
806 | 385 | } | ||
807 | 386 | else | ||
808 | 387 | { | ||
809 | 388 | map=obj->getInfoMap(StelApp::getInstance().getCore()); | ||
810 | 389 | map.insert("found", true); | ||
811 | 390 | } | ||
812 | 391 | return map; | ||
813 | 392 | } | ||
814 | 377 | 393 | ||
815 | === modified file 'src/core/StelObjectMgr.hpp' | |||
816 | --- src/core/StelObjectMgr.hpp 2016-07-03 21:58:54 +0000 | |||
817 | +++ src/core/StelObjectMgr.hpp 2017-03-09 14:02:12 +0000 | |||
818 | @@ -132,6 +132,11 @@ | |||
819 | 132 | //! Default to 1. | 132 | //! Default to 1. |
820 | 133 | void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;} | 133 | void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;} |
821 | 134 | 134 | ||
822 | 135 | //! Return a QMap of data about the object (calls obj->getInfoMap()). | ||
823 | 136 | //! If obj is valid, add an element ["found", true]. | ||
824 | 137 | //! If obj is NULL, returns a 1-element map [["found", false]] | ||
825 | 138 | static QVariantMap getObjectInfo(const StelObjectP obj); | ||
826 | 139 | |||
827 | 135 | signals: | 140 | signals: |
828 | 136 | //! Indicate that the selected StelObjects has changed. | 141 | //! Indicate that the selected StelObjects has changed. |
829 | 137 | //! @param action define if the user requested that the objects are added to the selection or just replace it | 142 | //! @param action define if the user requested that the objects are added to the selection or just replace it |
830 | 138 | 143 | ||
831 | === modified file 'src/core/modules/Atmosphere.cpp' | |||
832 | --- src/core/modules/Atmosphere.cpp 2016-11-28 14:24:21 +0000 | |||
833 | +++ src/core/modules/Atmosphere.cpp 2017-03-09 14:02:12 +0000 | |||
834 | @@ -381,7 +381,7 @@ | |||
835 | 381 | 381 | ||
836 | 382 | // And draw everything at once | 382 | // And draw everything at once |
837 | 383 | indicesBuffer.bind(); | 383 | indicesBuffer.bind(); |
839 | 384 | int shift=0; | 384 | std::size_t shift=0; |
840 | 385 | for (int y=0;y<skyResolutionY;++y) | 385 | for (int y=0;y<skyResolutionY;++y) |
841 | 386 | { | 386 | { |
842 | 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)); |
843 | 388 | 388 | ||
844 | === modified file 'src/core/modules/Comet.cpp' | |||
845 | --- src/core/modules/Comet.cpp 2017-01-08 16:39:11 +0000 | |||
846 | +++ src/core/modules/Comet.cpp 2017-03-09 14:02:12 +0000 | |||
847 | @@ -272,6 +272,14 @@ | |||
848 | 272 | return str; | 272 | return str; |
849 | 273 | } | 273 | } |
850 | 274 | 274 | ||
851 | 275 | QVariantMap Comet::getInfoMap(const StelCore *core) const | ||
852 | 276 | { | ||
853 | 277 | QVariantMap map = StelObject::getInfoMap(core); | ||
854 | 278 | map.insert("tail-length-km", tailFactors[1]*AU); | ||
855 | 279 | map.insert("coma-diameter-km", tailFactors[0]*AU); | ||
856 | 280 | |||
857 | 281 | return map; | ||
858 | 282 | } | ||
859 | 275 | void Comet::setSemiMajorAxis(const double value) | 283 | void Comet::setSemiMajorAxis(const double value) |
860 | 276 | { | 284 | { |
861 | 277 | semiMajorAxis = value; | 285 | semiMajorAxis = value; |
862 | 278 | 286 | ||
863 | === modified file 'src/core/modules/Comet.hpp' | |||
864 | --- src/core/modules/Comet.hpp 2015-09-13 21:33:23 +0000 | |||
865 | +++ src/core/modules/Comet.hpp 2017-03-09 14:02:12 +0000 | |||
866 | @@ -33,6 +33,7 @@ | |||
867 | 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. |
868 | 34 | 2014-08: GZ: speedup in case hundreds of comets are loaded. | 34 | 2014-08: GZ: speedup in case hundreds of comets are loaded. |
869 | 35 | 2014-11: GZ: tail extinction, better brightness balance. | 35 | 2014-11: GZ: tail extinction, better brightness balance. |
870 | 36 | 2017-03: GZ: added fields to infoMap | ||
871 | 36 | */ | 37 | */ |
872 | 37 | class Comet : public Planet | 38 | class Comet : public Planet |
873 | 38 | { | 39 | { |
874 | @@ -72,6 +73,11 @@ | |||
875 | 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. |
876 | 73 | //! \return a QString containing an HMTL encoded description of the Comet. | 74 | //! \return a QString containing an HMTL encoded description of the Comet. |
877 | 74 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const; | 75 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const; |
878 | 76 | //! In addition to Planet::getInfoMap(), Comets provides estimates for | ||
879 | 77 | //! - tail-length-km | ||
880 | 78 | //! - coma-diameter-km | ||
881 | 79 | //! using the formula from Guide found by the GSoC2012 initiative at http://www.projectpluto.com/update7b.htm#comet_tail_formula | ||
882 | 80 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
883 | 75 | //The Comet class inherits the "Planet" type because the SolarSystem class | 81 | //The Comet class inherits the "Planet" type because the SolarSystem class |
884 | 76 | //was not designed to handle different types of objects. | 82 | //was not designed to handle different types of objects. |
885 | 77 | //virtual QString getType() const {return "Comet";} | 83 | //virtual QString getType() const {return "Comet";} |
886 | 78 | 84 | ||
887 | === modified file 'src/core/modules/Planet.cpp' | |||
888 | --- src/core/modules/Planet.cpp 2017-01-26 17:39:02 +0000 | |||
889 | +++ src/core/modules/Planet.cpp 2017-03-09 14:02:12 +0000 | |||
890 | @@ -442,6 +442,33 @@ | |||
891 | 442 | return str; | 442 | return str; |
892 | 443 | } | 443 | } |
893 | 444 | 444 | ||
894 | 445 | QVariantMap Planet::getInfoMap(const StelCore *core) const | ||
895 | 446 | { | ||
896 | 447 | QVariantMap map = StelObject::getInfoMap(core); | ||
897 | 448 | |||
898 | 449 | if (getEnglishName()!="Sun") | ||
899 | 450 | { | ||
900 | 451 | const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); | ||
901 | 452 | map.insert("distance", getJ2000EquatorialPos(core).length()); | ||
902 | 453 | double phase=getPhase(observerHelioPos); | ||
903 | 454 | map.insert("phase", phase); | ||
904 | 455 | map.insert("illumination", 100.*phase); | ||
905 | 456 | double phaseAngle = getPhaseAngle(observerHelioPos); | ||
906 | 457 | map.insert("phase-angle", phaseAngle); | ||
907 | 458 | map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle)); | ||
908 | 459 | map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle)); | ||
909 | 460 | double elongation = getElongation(observerHelioPos); | ||
910 | 461 | map.insert("elongation", elongation); | ||
911 | 462 | map.insert("elongation-dms", StelUtils::radToDmsStr(elongation)); | ||
912 | 463 | map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation)); | ||
913 | 464 | map.insert("type", getPlanetTypeString()); // replace existing "type=Planet" by something more detailed. | ||
914 | 465 | // TBD: Is there ANY reason to keep "type"="Planet" and add a "ptype"=getPlanetTypeString() field? | ||
915 | 466 | } | ||
916 | 467 | |||
917 | 468 | return map; | ||
918 | 469 | } | ||
919 | 470 | |||
920 | 471 | |||
921 | 445 | //! Get sky label (sky translation) | 472 | //! Get sky label (sky translation) |
922 | 446 | QString Planet::getSkyLabel(const StelCore*) const | 473 | QString Planet::getSkyLabel(const StelCore*) const |
923 | 447 | { | 474 | { |
924 | 448 | 475 | ||
925 | === modified file 'src/core/modules/Planet.hpp' | |||
926 | --- src/core/modules/Planet.hpp 2017-01-06 16:52:05 +0000 | |||
927 | +++ src/core/modules/Planet.hpp 2017-03-09 14:02:12 +0000 | |||
928 | @@ -153,6 +153,18 @@ | |||
929 | 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. |
930 | 154 | //! @return a QString containing an HMTL encoded description of the Planet. | 154 | //! @return a QString containing an HMTL encoded description of the Planet. |
931 | 155 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const; | 155 | virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const; |
932 | 156 | //! In addition to the entries from StelObject::getInfoMap(), Planet objects provide | ||
933 | 157 | //! - distance | ||
934 | 158 | //! - phase (result of getPhase) | ||
935 | 159 | //! - illumination (=100*phase) | ||
936 | 160 | //! - phase-angle | ||
937 | 161 | //! - phase-angle-dms (formatted string) | ||
938 | 162 | //! - phase-angle-deg (formatted string) | ||
939 | 163 | //! - elongation | ||
940 | 164 | //! - elongation-dms (formatted string) | ||
941 | 165 | //! - elongation-deg (formatted string) | ||
942 | 166 | //! - type (object type description) | ||
943 | 167 | virtual QVariantMap getInfoMap(const StelCore *core) const; | ||
944 | 156 | virtual double getCloseViewFov(const StelCore* core) const; | 168 | virtual double getCloseViewFov(const StelCore* core) const; |
945 | 157 | virtual double getSatellitesFov(const StelCore* core) const; | 169 | virtual double getSatellitesFov(const StelCore* core) const; |
946 | 158 | virtual double getParentSatellitesFov(const StelCore* core) const; | 170 | virtual double getParentSatellitesFov(const StelCore* core) const; |
947 | @@ -213,21 +225,21 @@ | |||
948 | 213 | 225 | ||
949 | 214 | const RotationElements &getRotationElements(void) const {return re;} | 226 | const RotationElements &getRotationElements(void) const {return re;} |
950 | 215 | 227 | ||
952 | 216 | // Compute the position in the parent Planet coordinate system | 228 | //! Compute the position in the parent Planet coordinate system |
953 | 217 | void computePositionWithoutOrbits(const double dateJDE); | 229 | void computePositionWithoutOrbits(const double dateJDE); |
954 | 218 | void computePosition(const double dateJDE); | 230 | void computePosition(const double dateJDE); |
955 | 219 | 231 | ||
958 | 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. |
959 | 221 | // This requires both flavours of JD in cases involving Earth. | 233 | //! This requires both flavours of JD in cases involving Earth. |
960 | 222 | void computeTransMatrix(double JD, double JDE); | 234 | void computeTransMatrix(double JD, double JDE); |
961 | 223 | 235 | ||
963 | 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) |
964 | 225 | double getPhaseAngle(const Vec3d& obsPos) const; | 237 | double getPhaseAngle(const Vec3d& obsPos) const; |
966 | 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) |
967 | 227 | double getElongation(const Vec3d& obsPos) const; | 239 | double getElongation(const Vec3d& obsPos) const; |
969 | 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) |
970 | 229 | double getSpheroidAngularSize(const StelCore* core) const; | 241 | double getSpheroidAngularSize(const StelCore* core) const; |
972 | 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) |
973 | 231 | float getPhase(const Vec3d& obsPos) const; | 243 | float getPhase(const Vec3d& obsPos) const; |
974 | 232 | 244 | ||
975 | 233 | // Set the orbital elements | 245 | // Set the orbital elements |
976 | 234 | 246 | ||
977 | === modified file 'src/scripting/StelMainScriptAPI.cpp' | |||
978 | --- src/scripting/StelMainScriptAPI.cpp 2017-02-04 14:15:20 +0000 | |||
979 | +++ src/scripting/StelMainScriptAPI.cpp 2017-03-09 14:02:12 +0000 | |||
980 | @@ -711,6 +711,39 @@ | |||
981 | 711 | StelApp::getInstance().getScriptMgr().output(s); | 711 | StelApp::getInstance().getScriptMgr().output(s); |
982 | 712 | } | 712 | } |
983 | 713 | 713 | ||
984 | 714 | //! print contents of a QVariantMap | ||
985 | 715 | //! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo() | ||
986 | 716 | QString StelMainScriptAPI::mapToString(const QVariantMap& map) const | ||
987 | 717 | { | ||
988 | 718 | QString res = QString("[\n"); | ||
989 | 719 | QList<QVariant::Type> simpleTypeList; | ||
990 | 720 | simpleTypeList.push_back(QVariant::Bool); | ||
991 | 721 | simpleTypeList.push_back(QVariant::Int); | ||
992 | 722 | simpleTypeList.push_back(QVariant::UInt); | ||
993 | 723 | simpleTypeList.push_back(QVariant::Double); | ||
994 | 724 | |||
995 | 725 | QVariantMap::const_iterator i=map.constBegin(); | ||
996 | 726 | while (i != map.constEnd()){ | ||
997 | 727 | |||
998 | 728 | if (i.value().type()==QMetaType::QString) | ||
999 | 729 | { | ||
1000 | 730 | res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.key()).arg(i.value().toString())); | ||
1001 | 731 | } | ||
1002 | 732 | else if (simpleTypeList.contains(i.value().type())) | ||
1003 | 733 | { | ||
1004 | 734 | res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key()).arg(i.value().toString())); | ||
1005 | 735 | } | ||
1006 | 736 | else | ||
1007 | 737 | { | ||
1008 | 738 | res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg(i.key()).arg(i.value().typeName()).arg(i.value().toString())); | ||
1009 | 739 | } | ||
1010 | 740 | |||
1011 | 741 | ++i; | ||
1012 | 742 | } | ||
1013 | 743 | res.append( QString("]\n")); | ||
1014 | 744 | return res; | ||
1015 | 745 | } | ||
1016 | 746 | |||
1017 | 714 | void StelMainScriptAPI::resetOutput(void) const | 747 | void StelMainScriptAPI::resetOutput(void) const |
1018 | 715 | { | 748 | { |
1019 | 716 | StelApp::getInstance().getScriptMgr().resetOutput(); | 749 | StelApp::getInstance().getScriptMgr().resetOutput(); |
1020 | @@ -841,7 +874,7 @@ | |||
1021 | 841 | StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); | 874 | StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); |
1022 | 842 | StelObjectP obj = omgr->searchByName(name); | 875 | StelObjectP obj = omgr->searchByName(name); |
1023 | 843 | 876 | ||
1025 | 844 | return StelMainScriptAPI::getObjectInfo(obj); | 877 | return StelObjectMgr::getObjectInfo(obj); |
1026 | 845 | } | 878 | } |
1027 | 846 | 879 | ||
1028 | 847 | QVariantMap StelMainScriptAPI::getSelectedObjectInfo() | 880 | QVariantMap StelMainScriptAPI::getSelectedObjectInfo() |
1029 | @@ -857,140 +890,8 @@ | |||
1030 | 857 | 890 | ||
1031 | 858 | StelObjectP obj = omgr->getSelectedObject()[0]; | 891 | StelObjectP obj = omgr->getSelectedObject()[0]; |
1032 | 859 | 892 | ||
1167 | 860 | return StelMainScriptAPI::getObjectInfo(obj); | 893 | return StelObjectMgr::getObjectInfo(obj); |
1168 | 861 | } | 894 | } |
1035 | 862 | |||
1036 | 863 | QVariantMap StelMainScriptAPI::getObjectInfo(const StelObjectP obj) | ||
1037 | 864 | { | ||
1038 | 865 | QVariantMap map; | ||
1039 | 866 | if (!obj) | ||
1040 | 867 | { | ||
1041 | 868 | debug("getObjectData WARNING - object not found"); | ||
1042 | 869 | map.insert("found", false); | ||
1043 | 870 | return map; | ||
1044 | 871 | } | ||
1045 | 872 | else | ||
1046 | 873 | { | ||
1047 | 874 | map.insert("found", true); | ||
1048 | 875 | } | ||
1049 | 876 | |||
1050 | 877 | // OK, object found. Let's go. | ||
1051 | 878 | Vec3d pos; | ||
1052 | 879 | double ra, dec, alt, az, glong, glat; | ||
1053 | 880 | StelCore* core = StelApp::getInstance().getCore(); | ||
1054 | 881 | bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage(); | ||
1055 | 882 | |||
1056 | 883 | // ra/dec | ||
1057 | 884 | pos = obj->getEquinoxEquatorialPos(core); | ||
1058 | 885 | StelUtils::rectToSphe(&ra, &dec, pos); | ||
1059 | 886 | map.insert("ra", ra*180./M_PI); | ||
1060 | 887 | map.insert("dec", dec*180./M_PI); | ||
1061 | 888 | |||
1062 | 889 | // ra/dec in J2000 | ||
1063 | 890 | pos = obj->getJ2000EquatorialPos(core); | ||
1064 | 891 | StelUtils::rectToSphe(&ra, &dec, pos); | ||
1065 | 892 | map.insert("raJ2000", ra*180./M_PI); | ||
1066 | 893 | map.insert("decJ2000", dec*180./M_PI); | ||
1067 | 894 | |||
1068 | 895 | // apparent altitude/azimuth | ||
1069 | 896 | pos = obj->getAltAzPosApparent(core); | ||
1070 | 897 | StelUtils::rectToSphe(&az, &alt, pos); | ||
1071 | 898 | float direction = 3.; // N is zero, E is 90 degrees | ||
1072 | 899 | if (useOldAzimuth) | ||
1073 | 900 | direction = 2.; | ||
1074 | 901 | az = direction*M_PI - az; | ||
1075 | 902 | if (az > M_PI*2) | ||
1076 | 903 | az -= M_PI*2; | ||
1077 | 904 | |||
1078 | 905 | map.insert("altitude", alt*180./M_PI); | ||
1079 | 906 | map.insert("azimuth", az*180./M_PI); | ||
1080 | 907 | |||
1081 | 908 | // geometric altitude/azimuth | ||
1082 | 909 | pos = obj->getAltAzPosGeometric(core); | ||
1083 | 910 | StelUtils::rectToSphe(&az, &alt, pos); | ||
1084 | 911 | az = direction*M_PI - az; | ||
1085 | 912 | if (az > M_PI*2) | ||
1086 | 913 | az -= M_PI*2; | ||
1087 | 914 | |||
1088 | 915 | map.insert("altitude-geometric", alt*180./M_PI); | ||
1089 | 916 | map.insert("azimuth-geometric", az*180./M_PI); | ||
1090 | 917 | |||
1091 | 918 | // galactic long/lat | ||
1092 | 919 | pos = obj->getGalacticPos(core); | ||
1093 | 920 | StelUtils::rectToSphe(&glong, &glat, pos); | ||
1094 | 921 | map.insert("glong", glong*180./M_PI); | ||
1095 | 922 | map.insert("glat", glat*180./M_PI); | ||
1096 | 923 | |||
1097 | 924 | // supergalactic long/lat | ||
1098 | 925 | pos = obj->getSupergalacticPos(core); | ||
1099 | 926 | StelUtils::rectToSphe(&glong, &glat, pos); | ||
1100 | 927 | map.insert("sglong", glong*180./M_PI); | ||
1101 | 928 | map.insert("sglat", glat*180./M_PI); | ||
1102 | 929 | |||
1103 | 930 | SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); | ||
1104 | 931 | double ra_equ, dec_equ, lambda, beta; | ||
1105 | 932 | // J2000 | ||
1106 | 933 | double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0); | ||
1107 | 934 | double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE()); | ||
1108 | 935 | |||
1109 | 936 | // ecliptic longitude/latitude (J2000 frame) | ||
1110 | 937 | StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getJ2000EquatorialPos(core)); | ||
1111 | 938 | StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta); | ||
1112 | 939 | if (lambda<0) lambda+=2.0*M_PI; | ||
1113 | 940 | map.insert("elongJ2000", lambda*180./M_PI); | ||
1114 | 941 | map.insert("elatJ2000", beta*180./M_PI); | ||
1115 | 942 | |||
1116 | 943 | if (QString("Earth Sun").contains(core->getCurrentLocation().planetName)) | ||
1117 | 944 | { | ||
1118 | 945 | // ecliptic longitude/latitude | ||
1119 | 946 | StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getEquinoxEquatorialPos(core)); | ||
1120 | 947 | StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta); | ||
1121 | 948 | if (lambda<0) lambda+=2.0*M_PI; | ||
1122 | 949 | map.insert("elong", lambda*180./M_PI); | ||
1123 | 950 | map.insert("elat", beta*180./M_PI); | ||
1124 | 951 | } | ||
1125 | 952 | |||
1126 | 953 | // magnitude | ||
1127 | 954 | map.insert("vmag", obj->getVMagnitude(core)); | ||
1128 | 955 | map.insert("vmage", obj->getVMagnitudeWithExtinction(core)); | ||
1129 | 956 | |||
1130 | 957 | // angular size | ||
1131 | 958 | double angularSize = 2.*obj->getAngularSize(core)*M_PI/180.; | ||
1132 | 959 | bool sign; | ||
1133 | 960 | double deg; | ||
1134 | 961 | StelUtils::radToDecDeg(angularSize, sign, deg); | ||
1135 | 962 | if (!sign) | ||
1136 | 963 | deg *= -1; | ||
1137 | 964 | map.insert("size", angularSize); | ||
1138 | 965 | map.insert("size-dd", deg); | ||
1139 | 966 | map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5)); | ||
1140 | 967 | map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true)); | ||
1141 | 968 | |||
1142 | 969 | if (obj->getType().toLower()=="planet" && obj->getEnglishName()!="Sun") | ||
1143 | 970 | { | ||
1144 | 971 | SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); | ||
1145 | 972 | map.insert("distance", obj->getJ2000EquatorialPos(core).length()); | ||
1146 | 973 | double phase = ssmgr->getPhaseForPlanet(obj->getEnglishName()); | ||
1147 | 974 | map.insert("phase", phase); | ||
1148 | 975 | map.insert("illumination", 100.*phase); | ||
1149 | 976 | double phaseAngle = ssmgr->getPhaseAngleForPlanet(obj->getEnglishName()); | ||
1150 | 977 | map.insert("phase-angle", phaseAngle); | ||
1151 | 978 | map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle)); | ||
1152 | 979 | map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle)); | ||
1153 | 980 | double elongation = ssmgr->getElongationForPlanet(obj->getEnglishName()); | ||
1154 | 981 | map.insert("elongation", elongation); | ||
1155 | 982 | map.insert("elongation-dms", StelUtils::radToDmsStr(elongation)); | ||
1156 | 983 | map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation)); | ||
1157 | 984 | map.insert("ptype", ssmgr->getPlanetType(obj->getEnglishName())); | ||
1158 | 985 | } | ||
1159 | 986 | |||
1160 | 987 | // english name or designation & localized name | ||
1161 | 988 | map.insert("name", obj->getEnglishName()); | ||
1162 | 989 | map.insert("localized-name", obj->getNameI18n()); | ||
1163 | 990 | |||
1164 | 991 | return map; | ||
1165 | 992 | } | ||
1166 | 993 | |||
1169 | 994 | 895 | ||
1170 | 995 | void StelMainScriptAPI::clear(const QString& state) | 896 | void StelMainScriptAPI::clear(const QString& state) |
1171 | 996 | { | 897 | { |
1172 | 997 | 898 | ||
1173 | === modified file 'src/scripting/StelMainScriptAPI.hpp' | |||
1174 | --- src/scripting/StelMainScriptAPI.hpp 2017-02-04 14:15:20 +0000 | |||
1175 | +++ src/scripting/StelMainScriptAPI.hpp 2017-03-09 14:02:12 +0000 | |||
1176 | @@ -173,62 +173,29 @@ | |||
1177 | 173 | //! - size-deg : angular size in decimal degrees (formatted string) | 173 | //! - size-deg : angular size in decimal degrees (formatted string) |
1178 | 174 | //! - size-dms : angular size in DMS format | 174 | //! - size-dms : angular size in DMS format |
1179 | 175 | //! - localized-name : localized name | 175 | //! - localized-name : localized name |
1180 | 176 | //! The returned map can contain other information. For example, Solar System objects add: | ||
1181 | 176 | //! - distance : distance to object in AU (for Solar system objects only!) | 177 | //! - distance : distance to object in AU (for Solar system objects only!) |
1184 | 177 | //! - phase : phase of object (for Solar system objects only!) | 178 | //! - phase : phase (illuminated fraction, 0..1) of object (for Solar system objects only!) |
1185 | 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!) |
1186 | 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!) |
1187 | 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!) |
1188 | 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!) |
1189 | 182 | //! - elongation : elongation of object in radians (for Solar system objects only!) | 183 | //! - elongation : elongation of object in radians (for Solar system objects only!) |
1190 | 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!) |
1191 | 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!) |
1193 | 185 | //! - ptype : object type (for Solar system objects only!) | 186 | //! Other StelObject derivates, also those defined in plugins, may add more, |
1194 | 187 | //! these fields are documented in the respective classes, or simply try what you get: | ||
1195 | 188 | //! You can print a complete set of entries into output with the following commands: | ||
1196 | 189 | //! @code | ||
1197 | 190 | //! map=core.getSelectedObjectInfo(); | ||
1198 | 191 | //! core.output(core.mapToString(map)); | ||
1199 | 192 | //! @endcode | ||
1200 | 186 | QVariantMap getObjectInfo(const QString& name); | 193 | QVariantMap getObjectInfo(const QString& name); |
1201 | 187 | 194 | ||
1238 | 188 | //! Fetch a map with data about an latest selected object's position, magnitude and so on | 195 | //! Fetch a map with data about the latest selected object's position, magnitude and so on |
1239 | 189 | //! @return a map of object data. Keys: | 196 | //! @return a map of object data. See description for getObjectInfo(const QString& name); |
1204 | 190 | //! - altitude : apparent altitude angle in decimal degrees | ||
1205 | 191 | //! - azimuth : apparent azimuth angle in decimal degrees | ||
1206 | 192 | //! - altitude-geometric : geometric altitude angle in decimal degrees | ||
1207 | 193 | //! - azimuth-geometric : geometric azimuth angle in decimal degrees | ||
1208 | 194 | //! - ra : right ascension angle (current date frame) in decimal degrees | ||
1209 | 195 | //! - dec : declination angle in (current date frame) decimal degrees | ||
1210 | 196 | //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees | ||
1211 | 197 | //! - decJ2000 : declination angle in (J2000 frame) decimal degrees | ||
1212 | 198 | //! - glong : galactic longitude in decimal degrees | ||
1213 | 199 | //! - glat : galactic latitude in decimal degrees | ||
1214 | 200 | //! - sglong : supergalactic longitude in decimal degrees | ||
1215 | 201 | //! - sglat : supergalactic latitude in decimal degrees | ||
1216 | 202 | //! - elong : ecliptic longitude in decimal degrees (on Earth only!) | ||
1217 | 203 | //! - elat : ecliptic latitude in decimal degrees (on Earth only!) | ||
1218 | 204 | //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees | ||
1219 | 205 | //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees | ||
1220 | 206 | //! - vmag : visual magnitude | ||
1221 | 207 | //! - vmage : visual magnitude (extincted) | ||
1222 | 208 | //! - size: angular size in radians | ||
1223 | 209 | //! - size-dd : angular size in decimal degrees | ||
1224 | 210 | //! - size-deg : angular size in decimal degrees (formatted string) | ||
1225 | 211 | //! - size-dms : angular size in DMS format | ||
1226 | 212 | //! - name : english name | ||
1227 | 213 | //! - localized-name : localized name | ||
1228 | 214 | //! - distance : distance to object in AU (for Solar system objects only!) | ||
1229 | 215 | //! - phase : phase of object (for Solar system objects only!) | ||
1230 | 216 | //! - illumination : phase of object in percentages (for Solar system objects only!) | ||
1231 | 217 | //! - phase-angle : phase angle of object in radians (for Solar system objects only!) | ||
1232 | 218 | //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!) | ||
1233 | 219 | //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!) | ||
1234 | 220 | //! - elongation : elongation of object in radians (for Solar system objects only!) | ||
1235 | 221 | //! - elongation-dms : elongation of object in DMS (for Solar system objects only!) | ||
1236 | 222 | //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!) | ||
1237 | 223 | //! - ptype : object type (for Solar system objects only!) | ||
1240 | 224 | QVariantMap getSelectedObjectInfo(); | 197 | QVariantMap getSelectedObjectInfo(); |
1241 | 225 | 198 | ||
1242 | 226 | public: | ||
1243 | 227 | //! Called by getSelectedObjectInfo() and getObjectInfo(name). Not useful to be scriptable, not a slot! | ||
1244 | 228 | //! The static method can be called more easily by other components. | ||
1245 | 229 | static QVariantMap getObjectInfo(const StelObjectP obj); | ||
1246 | 230 | |||
1247 | 231 | public slots: | ||
1248 | 232 | //! Clear the display options, setting a "standard" view. | 199 | //! Clear the display options, setting a "standard" view. |
1249 | 233 | //! Preset states: | 200 | //! Preset states: |
1250 | 234 | //! - natural : azimuthal mount, atmosphere, landscape, | 201 | //! - natural : azimuthal mount, atmosphere, landscape, |
1251 | @@ -735,6 +702,12 @@ | |||
1252 | 735 | //! @param s the message to be displayed on the output file. | 702 | //! @param s the message to be displayed on the output file. |
1253 | 736 | void output(const QString& s) const; | 703 | void output(const QString& s) const; |
1254 | 737 | 704 | ||
1255 | 705 | //! print contents of a QVariantMap as []-delimited list of [ "key" = <value>] lists. | ||
1256 | 706 | //! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo() | ||
1257 | 707 | //! @note string values are surrounded with ", simple numeric types are printed as themselves. | ||
1258 | 708 | //! @note More complicated value types like lists are only indicated by their type name. You must extract those (and their contents) yourself. | ||
1259 | 709 | QString mapToString(const QVariantMap &map) const; | ||
1260 | 710 | |||
1261 | 738 | //! Reset (clear) output file | 711 | //! Reset (clear) output file |
1262 | 739 | void resetOutput(void) const; | 712 | void resetOutput(void) const; |
1263 | 740 | 713 |
Please make names of keys are more consistent - for example: "range_ km", range); "RangeRate_ km/s", rangeRate);
------------
map.insert(
map.insert(
------------
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).