• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 3996069357

pending completion
3996069357

push

github

Ruslan Kabatsayev
Shorten some lines

5 of 5 new or added lines in 1 file covered. (100.0%)

14663 of 124076 relevant lines covered (11.82%)

22035.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/StelObjectMgr.cpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2007 Fabien Chereau
4
 * Copyright (C) 2016 Marcos Cardinot
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
19
 */
20

21
#include "StelApp.hpp"
22
#include "StelObjectMgr.hpp"
23
#include "StelObjectModule.hpp"
24
#include "StelCore.hpp"
25
#include "StelUtils.hpp"
26
#include "StelProjector.hpp"
27
#include "StelMovementMgr.hpp"
28
#include "StelSkyDrawer.hpp"
29
#include "Planet.hpp"
30

31
#include <QMouseEvent>
32
#include <QString>
33
#include <QDebug>
34
#include <QStringList>
35
#include <QSettings>
36

37
StelObjectMgr::StelObjectMgr() : objectPointerVisibility(true), searchRadiusPixel(25.), distanceWeight(1.f)
×
38
{
39
        setObjectName("StelObjectMgr");
×
40
}
×
41

42
StelObjectMgr::~StelObjectMgr()
×
43
{
44
}
×
45

46
void StelObjectMgr::init()
×
47
{
48
        QSettings* conf = StelApp::getInstance().getSettings();
×
49
        Q_ASSERT(conf);
×
50
        setFlagSelectedObjectPointer(conf->value("viewing/flag_show_selection_marker", true).toBool());
×
51
}
×
52

53
StelObject::InfoStringGroup StelObjectMgr::getCustomInfoStrings()
×
54
{
55
        QSettings* conf = StelApp::getInstance().getSettings();
×
56
        StelObject::InfoStringGroup infoTextFilters = StelObject::InfoStringGroup(StelObject::None);
×
57

58
        conf->beginGroup("custom_selected_info");
×
59
        if (conf->value("flag_show_name", false).toBool())
×
60
                infoTextFilters |= StelObject::Name;
×
61
        if (conf->value("flag_show_catalognumber", false).toBool())
×
62
                infoTextFilters |= StelObject::CatalogNumber;
×
63
        if (conf->value("flag_show_magnitude", false).toBool())
×
64
                infoTextFilters |= StelObject::Magnitude;
×
65
        if (conf->value("flag_show_absolutemagnitude", false).toBool())
×
66
                infoTextFilters |= StelObject::AbsoluteMagnitude;
×
67
        if (conf->value("flag_show_radecj2000", false).toBool())
×
68
                infoTextFilters |= StelObject::RaDecJ2000;
×
69
        if (conf->value("flag_show_radecofdate", false).toBool())
×
70
                infoTextFilters |= StelObject::RaDecOfDate;
×
71
        if (conf->value("flag_show_hourangle", false).toBool())
×
72
                infoTextFilters |= StelObject::HourAngle;
×
73
        if (conf->value("flag_show_altaz", false).toBool())
×
74
                infoTextFilters |= StelObject::AltAzi;
×
75
        if (conf->value("flag_show_elongation", false).toBool())
×
76
                infoTextFilters |= StelObject::Elongation;
×
77
        if (conf->value("flag_show_distance", false).toBool())
×
78
                infoTextFilters |= StelObject::Distance;
×
79
        if (conf->value("flag_show_velocity", false).toBool())
×
80
                infoTextFilters |= StelObject::Velocity;
×
81
        if (conf->value("flag_show_propermotion", false).toBool())
×
82
                infoTextFilters |= StelObject::ProperMotion;
×
83
        if (conf->value("flag_show_size", false).toBool())
×
84
                infoTextFilters |= StelObject::Size;
×
85
        if (conf->value("flag_show_extra", false).toBool())
×
86
                infoTextFilters |= StelObject::Extra;
×
87
        if (conf->value("flag_show_type", false).toBool())
×
88
                infoTextFilters |= StelObject::ObjectType;
×
89
        if (conf->value("flag_show_galcoord", false).toBool())
×
90
                infoTextFilters |= StelObject::GalacticCoord;
×
91
        if (conf->value("flag_show_supergalcoord", false).toBool())
×
92
                infoTextFilters |= StelObject::SupergalacticCoord;
×
93
        if (conf->value("flag_show_othercoord", false).toBool())
×
94
                infoTextFilters |= StelObject::OtherCoord;
×
95
        if (conf->value("flag_show_eclcoordofdate", false).toBool())
×
96
                infoTextFilters |= StelObject::EclipticCoordOfDate;
×
97
        if (conf->value("flag_show_eclcoordj2000", false).toBool())
×
98
                infoTextFilters |= StelObject::EclipticCoordJ2000;
×
99
        if (conf->value("flag_show_constellation", false).toBool())
×
100
                infoTextFilters |= StelObject::IAUConstellation;
×
101
        if (conf->value("flag_show_sidereal_time", false).toBool())
×
102
                infoTextFilters |= StelObject::SiderealTime;
×
103
        if (conf->value("flag_show_rts_time", false).toBool())
×
104
                infoTextFilters |= StelObject::RTSTime;
×
105
        if (conf->value("flag_show_solar_lunar", false).toBool())
×
106
            infoTextFilters |= StelObject::SolarLunarPosition;
×
107
        conf->endGroup();
×
108

109
        return infoTextFilters;
×
110
}
111

112
/*************************************************************************
113
 Add a new StelObject manager into the list of supported modules.
114
*************************************************************************/
115
void StelObjectMgr::registerStelObjectMgr(StelObjectModule* m)
×
116
{
117
        objectsModules.push_back(m);
×
118
        typeToModuleMap.insert(m->getStelObjectType(),m);
×
119

120
        objModulesMap.insert(m->objectName(), m->getName());
×
121

122
        //TODO: there should probably be a better way to specify the sub-types instead of hardcoding them here
123

124
        // Celestial objects from Solar system by type
125
        if (m->objectName()=="SolarSystem")
×
126
        {
127
                objModulesMap["SolarSystem:planet"] = "Planets";
×
128
                objModulesMap["SolarSystem:moon"] = "Moons";
×
129
                objModulesMap["SolarSystem:asteroid"] = "Asteroids";
×
130
                objModulesMap["SolarSystem:comet"] = "Comets";
×
131
                objModulesMap["SolarSystem:plutino"] = "Plutinos";
×
132
                objModulesMap["SolarSystem:cubewano"] = "Cubewanos";
×
133
                objModulesMap["SolarSystem:dwarf planet"] = "Dwarf planets";
×
134
                objModulesMap["SolarSystem:scattered disc object"] = "Scattered disc objects";
×
135
                objModulesMap["SolarSystem:Oort cloud object"] = "Oort cloud objects";
×
136
                objModulesMap["SolarSystem:sednoid"] = "Sednoids";
×
137
                objModulesMap["SolarSystem:interstellar object"] = "Interstellar objects";
×
138
                objModulesMap["SolarSystem:artificial"] = "Artificial objects";
×
139
        }
140
        // Deep-sky objects by type + amateur catalogues
141
        if (m->objectName()=="NebulaMgr")
×
142
        {
143
                objModulesMap["NebulaMgr:0"] = "Bright galaxies";
×
144
                objModulesMap["NebulaMgr:1"] = "Active galaxies";
×
145
                objModulesMap["NebulaMgr:2"] = "Radio galaxies";
×
146
                objModulesMap["NebulaMgr:3"] = "Interacting galaxies";
×
147
                objModulesMap["NebulaMgr:4"] = "Bright quasars";
×
148
                objModulesMap["NebulaMgr:5"] = "Star clusters";
×
149
                objModulesMap["NebulaMgr:6"] = "Open star clusters";
×
150
                objModulesMap["NebulaMgr:7"] = "Globular star clusters";
×
151
                objModulesMap["NebulaMgr:8"] = "Stellar associations";
×
152
                objModulesMap["NebulaMgr:9"] = "Star clouds";
×
153
                objModulesMap["NebulaMgr:10"] = "Nebulae";
×
154
                objModulesMap["NebulaMgr:11"] = "Planetary nebulae";
×
155
                objModulesMap["NebulaMgr:12"] = "Dark nebulae";
×
156
                objModulesMap["NebulaMgr:13"] = "Reflection nebulae";
×
157
                objModulesMap["NebulaMgr:14"] = "Bipolar nebulae";
×
158
                objModulesMap["NebulaMgr:15"] = "Emission nebulae";
×
159
                objModulesMap["NebulaMgr:16"] = "Clusters associated with nebulosity";
×
160
                objModulesMap["NebulaMgr:17"] = "HII regions";
×
161
                objModulesMap["NebulaMgr:18"] = "Supernova remnants";
×
162
                objModulesMap["NebulaMgr:19"] = "Interstellar matter";
×
163
                objModulesMap["NebulaMgr:20"] = "Emission objects";
×
164
                objModulesMap["NebulaMgr:21"] = "BL Lac objects";
×
165
                objModulesMap["NebulaMgr:22"] = "Blazars";
×
166
                objModulesMap["NebulaMgr:23"] = "Molecular Clouds";
×
167
                objModulesMap["NebulaMgr:24"] = "Young Stellar Objects";
×
168
                objModulesMap["NebulaMgr:25"] = "Possible Quasars";
×
169
                objModulesMap["NebulaMgr:26"] = "Possible Planetary Nebulae";
×
170
                objModulesMap["NebulaMgr:27"] = "Protoplanetary Nebulae";
×
171
                objModulesMap["NebulaMgr:29"] = "Symbiotic stars";
×
172
                objModulesMap["NebulaMgr:30"] = "Emission-line stars";
×
173
                objModulesMap["NebulaMgr:31"] = "Supernova candidates";
×
174
                objModulesMap["NebulaMgr:32"] = "Supernova remnant candidates";
×
175
                objModulesMap["NebulaMgr:33"] = "Clusters of galaxies";                
×
176
                objModulesMap["NebulaMgr:35"] = "Regions of the sky";
×
177
                objModulesMap["NebulaMgr:100"] = "Messier Catalogue";
×
178
                objModulesMap["NebulaMgr:101"] = "Caldwell Catalogue";
×
179
                objModulesMap["NebulaMgr:102"] = "Barnard Catalogue";
×
180
                objModulesMap["NebulaMgr:103"] = "Sharpless Catalogue";
×
181
                objModulesMap["NebulaMgr:104"] = "van den Bergh Catalogue";
×
182
                objModulesMap["NebulaMgr:105"] = "The Catalogue of Rodgers, Campbell, and Whiteoak";
×
183
                objModulesMap["NebulaMgr:106"] = "Collinder Catalogue";
×
184
                objModulesMap["NebulaMgr:107"] = "Melotte Catalogue";
×
185
                objModulesMap["NebulaMgr:108"] = "New General Catalogue";
×
186
                objModulesMap["NebulaMgr:109"] = "Index Catalogue";
×
187
                objModulesMap["NebulaMgr:110"] = "Lynds' Catalogue of Bright Nebulae";
×
188
                objModulesMap["NebulaMgr:111"] = "Lynds' Catalogue of Dark Nebulae";
×
189
                objModulesMap["NebulaMgr:112"] = "Principal Galaxy Catalog";
×
190
                objModulesMap["NebulaMgr:113"] = "The Uppsala General Catalogue of Galaxies";
×
191
                objModulesMap["NebulaMgr:114"] = "Cederblad Catalog";
×
192
                objModulesMap["NebulaMgr:115"] = "The Catalogue of Peculiar Galaxies";
×
193
                objModulesMap["NebulaMgr:116"] = "The Catalogue of Interacting Galaxies";
×
194
                objModulesMap["NebulaMgr:117"] = "The Catalogue of Galactic Planetary Nebulae";
×
195
                objModulesMap["NebulaMgr:118"] = "The Strasbourg-ESO Catalogue of Galactic Planetary Nebulae";
×
196
                objModulesMap["NebulaMgr:119"] = "A catalogue of Galactic supernova remnants";
×
197
                objModulesMap["NebulaMgr:120"] = "A Catalog of Rich Clusters of Galaxies";
×
198
                objModulesMap["NebulaMgr:121"] = "Hickson Compact Group";                
×
199
                objModulesMap["NebulaMgr:122"] = "ESO/Uppsala Survey of the ESO(B) Atlas";
×
200
                objModulesMap["NebulaMgr:123"] = "Catalogue of southern stars embedded in nebulosity";
×
201
                objModulesMap["NebulaMgr:124"] = "Catalogue and distances of optically visible H II regions";
×
202
                objModulesMap["NebulaMgr:125"] = "Trumpler Catalogue";
×
203
                objModulesMap["NebulaMgr:126"] = "Stock Catalogue";
×
204
                objModulesMap["NebulaMgr:127"] = "Ruprecht Catalogue";
×
205
                objModulesMap["NebulaMgr:128"] = "van den Bergh-Hagen Catalogue";
×
206
                objModulesMap["NebulaMgr:150"] = "Dwarf galaxies";
×
207
                objModulesMap["NebulaMgr:151"] = "Herschel 400 Catalogue";
×
208
                objModulesMap["NebulaMgr:152"] = "Jack Bennett's deep sky catalogue";
×
209
                objModulesMap["NebulaMgr:153"] = "James Dunlop's southern deep sky catalogue";
×
210
        }
211
        // Interesting stars
212
        if (m->objectName()=="StarMgr")
×
213
        {
214
                objModulesMap["StarMgr:0"] = "Interesting double stars";
×
215
                objModulesMap["StarMgr:1"] = "Interesting variable stars";
×
216
                objModulesMap["StarMgr:2"] = "Bright double stars";
×
217
                objModulesMap["StarMgr:3"] = "Bright variable stars";
×
218
                objModulesMap["StarMgr:4"] = "Bright stars with high proper motion";
×
219
                objModulesMap["StarMgr:5"] = "Variable stars: Algol-type eclipsing systems";
×
220
                objModulesMap["StarMgr:6"] = "Variable stars: the classical cepheids";
×
221
                objModulesMap["StarMgr:7"] = "Bright carbon stars";
×
222
                objModulesMap["StarMgr:8"] = "Bright barium stars";
×
223
        }
224
        // Nomenclature...
225
        if (m->objectName()=="NomenclatureMgr")
×
226
        {
227
                // list of types
228
                objModulesMap["NomenclatureMgr:1"]  = "Geological features: albedo features";
×
229
                objModulesMap["NomenclatureMgr:2"]  = "Geological features: arcūs";
×
230
                objModulesMap["NomenclatureMgr:3"]  = "Geological features: astra";
×
231
                objModulesMap["NomenclatureMgr:4"]  = "Geological features: catenae";
×
232
                objModulesMap["NomenclatureMgr:5"]  = "Geological features: cavi";
×
233
                objModulesMap["NomenclatureMgr:6"]  = "Geological features: chaoses";
×
234
                objModulesMap["NomenclatureMgr:7"]  = "Geological features: chasmata";
×
235
                objModulesMap["NomenclatureMgr:8"]  = "Geological features: colles";
×
236
                objModulesMap["NomenclatureMgr:9"]  = "Geological features: coronae";
×
237
                objModulesMap["NomenclatureMgr:10"] = "Geological features: craters";
×
238
                objModulesMap["NomenclatureMgr:11"] = "Geological features: dorsa";
×
239
                objModulesMap["NomenclatureMgr:12"] = "Geological features: eruptive centers";
×
240
                objModulesMap["NomenclatureMgr:13"] = "Geological features: faculae";
×
241
                objModulesMap["NomenclatureMgr:14"] = "Geological features: farra";
×
242
                objModulesMap["NomenclatureMgr:15"] = "Geological features: flexūs";
×
243
                objModulesMap["NomenclatureMgr:16"] = "Geological features: fluctūs";
×
244
                objModulesMap["NomenclatureMgr:17"] = "Geological features: flumina";
×
245
                objModulesMap["NomenclatureMgr:18"] = "Geological features: freta";
×
246
                objModulesMap["NomenclatureMgr:19"] = "Geological features: fossae";
×
247
                objModulesMap["NomenclatureMgr:20"] = "Geological features: insulae";
×
248
                objModulesMap["NomenclatureMgr:21"] = "Geological features: labēs";
×
249
                objModulesMap["NomenclatureMgr:22"] = "Geological features: labyrinthi";
×
250
                objModulesMap["NomenclatureMgr:23"] = "Geological features: lacunae";
×
251
                objModulesMap["NomenclatureMgr:24"] = "Geological features: lacūs";
×
252
                objModulesMap["NomenclatureMgr:25"] = "Geological features: large ringed features";
×
253
                objModulesMap["NomenclatureMgr:26"] = "Geological features: lineae";
×
254
                objModulesMap["NomenclatureMgr:27"] = "Geological features: lingulae";
×
255
                objModulesMap["NomenclatureMgr:28"] = "Geological features: maculae";
×
256
                objModulesMap["NomenclatureMgr:29"] = "Geological features: maria";
×
257
                objModulesMap["NomenclatureMgr:30"] = "Geological features: mensae";
×
258
                objModulesMap["NomenclatureMgr:31"] = "Geological features: montes";
×
259
                objModulesMap["NomenclatureMgr:32"] = "Geological features: oceani";
×
260
                objModulesMap["NomenclatureMgr:33"] = "Geological features: paludes";
×
261
                objModulesMap["NomenclatureMgr:34"] = "Geological features: paterae";
×
262
                objModulesMap["NomenclatureMgr:35"] = "Geological features: planitiae";
×
263
                objModulesMap["NomenclatureMgr:36"] = "Geological features: plana";
×
264
                objModulesMap["NomenclatureMgr:37"] = "Geological features: plumes";
×
265
                objModulesMap["NomenclatureMgr:38"] = "Geological features: promontoria";
×
266
                objModulesMap["NomenclatureMgr:39"] = "Geological features: regiones";
×
267
                objModulesMap["NomenclatureMgr:40"] = "Geological features: rimae";
×
268
                objModulesMap["NomenclatureMgr:41"] = "Geological features: rupēs";
×
269
                objModulesMap["NomenclatureMgr:42"] = "Geological features: scopuli";
×
270
                objModulesMap["NomenclatureMgr:43"] = "Geological features: serpentes";
×
271
                objModulesMap["NomenclatureMgr:44"] = "Geological features: sulci";
×
272
                objModulesMap["NomenclatureMgr:45"] = "Geological features: sinūs";
×
273
                objModulesMap["NomenclatureMgr:46"] = "Geological features: terrae";
×
274
                objModulesMap["NomenclatureMgr:47"] = "Geological features: tholi";
×
275
                objModulesMap["NomenclatureMgr:48"] = "Geological features: undae";
×
276
                objModulesMap["NomenclatureMgr:49"] = "Geological features: valles";
×
277
                objModulesMap["NomenclatureMgr:50"] = "Geological features: vastitates";
×
278
                objModulesMap["NomenclatureMgr:51"] = "Geological features: virgae";
×
279
                objModulesMap["NomenclatureMgr:52"] = "Geological features: landing sites";
×
280
                objModulesMap["NomenclatureMgr:53"] = "Geological features: lenticulae";
×
281
                objModulesMap["NomenclatureMgr:54"] = "Geological features: reticula";
×
282
                objModulesMap["NomenclatureMgr:56"] = "Geological features: tesserae";
×
283
                objModulesMap["NomenclatureMgr:57"] = "Geological features: saxa";
×
284
                // list of celestial bodies (alphabetical sorting)
285
                objModulesMap["NomenclatureMgr:Amalthea"]   = "Named geological features of Amalthea";
×
286
                objModulesMap["NomenclatureMgr:Ariel"]      = "Named geological features of Ariel";
×
287
                objModulesMap["NomenclatureMgr:Callisto"]   = "Named geological features of Callisto";
×
288
                objModulesMap["NomenclatureMgr:Ceres"]      = "Named geological features of Ceres";
×
289
                objModulesMap["NomenclatureMgr:Charon"]     = "Named geological features of Charon";
×
290
                objModulesMap["NomenclatureMgr:Dactyl"]     = "Named geological features of Dactyl";
×
291
                objModulesMap["NomenclatureMgr:Deimos"]     = "Named geological features of Deimos";
×
292
                objModulesMap["NomenclatureMgr:Dione"]      = "Named geological features of Dione";
×
293
                objModulesMap["NomenclatureMgr:Enceladus"]  = "Named geological features of Enceladus";
×
294
                objModulesMap["NomenclatureMgr:Epimetheus"] = "Named geological features of Epimetheus";
×
295
                objModulesMap["NomenclatureMgr:Eros"]       = "Named geological features of Eros";
×
296
                objModulesMap["NomenclatureMgr:Europa"]     = "Named geological features of Europa";
×
297
                objModulesMap["NomenclatureMgr:Ganymede"]   = "Named geological features of Ganymede";
×
298
                objModulesMap["NomenclatureMgr:Gaspra"]     = "Named geological features of Gaspra";
×
299
                objModulesMap["NomenclatureMgr:Hyperion"]   = "Named geological features of Hyperion";
×
300
                objModulesMap["NomenclatureMgr:Iapetus"]    = "Named geological features of Iapetus";
×
301
                objModulesMap["NomenclatureMgr:Ida"]        = "Named geological features of Ida";
×
302
                objModulesMap["NomenclatureMgr:Io"]         = "Named geological features of Io";
×
303
                objModulesMap["NomenclatureMgr:Itokawa"]    = "Named geological features of Itokawa";
×
304
                objModulesMap["NomenclatureMgr:Janus"]      = "Named geological features of Janus";
×
305
                objModulesMap["NomenclatureMgr:Lutetia"]    = "Named geological features of Lutetia";
×
306
                objModulesMap["NomenclatureMgr:Mars"]       = "Named geological features of Mars";
×
307
                objModulesMap["NomenclatureMgr:Mathilde"]   = "Named geological features of Mathilde";
×
308
                objModulesMap["NomenclatureMgr:Mercury"]    = "Named geological features of Mercury";
×
309
                objModulesMap["NomenclatureMgr:Mimas"]      = "Named geological features of Mimas";
×
310
                objModulesMap["NomenclatureMgr:Miranda"]    = "Named geological features of Miranda";
×
311
                objModulesMap["NomenclatureMgr:Moon"]       = "Named geological features of the Moon";
×
312
                objModulesMap["NomenclatureMgr:Oberon"]     = "Named geological features of Oberon";
×
313
                objModulesMap["NomenclatureMgr:Phobos"]     = "Named geological features of Phobos";
×
314
                objModulesMap["NomenclatureMgr:Phoebe"]     = "Named geological features of Phoebe";
×
315
                objModulesMap["NomenclatureMgr:Pluto"]      = "Named geological features of Pluto";
×
316
                objModulesMap["NomenclatureMgr:Proteus"]    = "Named geological features of Proteus";
×
317
                objModulesMap["NomenclatureMgr:Puck"]       = "Named geological features of Puck";
×
318
                objModulesMap["NomenclatureMgr:Rhea"]       = "Named geological features of Rhea";
×
319
                objModulesMap["NomenclatureMgr:Ryugu"]      = "Named geological features of Ryugu";
×
320
                objModulesMap["NomenclatureMgr:Steins"]     = "Named geological features of Steins";
×
321
                objModulesMap["NomenclatureMgr:Tethys"]     = "Named geological features of Tethys";
×
322
                objModulesMap["NomenclatureMgr:Thebe"]      = "Named geological features of Thebe";
×
323
                objModulesMap["NomenclatureMgr:Titania"]    = "Named geological features of Titania";
×
324
                objModulesMap["NomenclatureMgr:Titan"]      = "Named geological features of Titan";
×
325
                objModulesMap["NomenclatureMgr:Triton"]     = "Named geological features of Triton";
×
326
                objModulesMap["NomenclatureMgr:Umbriel"]    = "Named geological features of Umbriel";
×
327
                objModulesMap["NomenclatureMgr:Venus"]      = "Named geological features of Venus";
×
328
                objModulesMap["NomenclatureMgr:Vesta"]      = "Named geological features of Vesta";
×
329
        }
330
}
×
331

332
StelObjectP StelObjectMgr::searchByNameI18n(const QString &name) const
×
333
{
334
        StelObjectP rval;
×
335
        for (const auto* m : objectsModules)
×
336
        {
337
                rval = m->searchByNameI18n(name);
×
338
                if (rval)
×
339
                        return rval;
×
340
        }
341
        return rval;
×
342
}
×
343

344
StelObjectP StelObjectMgr::searchByNameI18n(const QString &name, const QString &objType) const
×
345
{
346
        StelObjectP rval;
×
347
        for (const auto* m : objectsModules)
×
348
        {
349
                if (m->getStelObjectType()==objType)
×
350
                {
351
                        rval = m->searchByNameI18n(name);
×
352
                        if (rval)
×
353
                                return rval;
×
354
                }
355
        }
356
        return rval;
×
357
}
×
358

359
//! Find any kind of object by its standard program name
360
StelObjectP StelObjectMgr::searchByName(const QString &name) const
×
361
{
362
        StelObjectP rval;
×
363
        for (const auto* m : objectsModules)
×
364
        {
365
                rval = m->searchByName(name);
×
366
                if (rval)
×
367
                        return rval;
×
368
        }
369
        return rval;
×
370
}
×
371

372
StelObjectP StelObjectMgr::searchByName(const QString &name, const QString &objType) const
×
373
{
374
        StelObjectP rval;
×
375
        for (const auto* m : objectsModules)
×
376
        {
377
                if (m->getStelObjectType()==objType)
×
378
                {
379
                        rval = m->searchByName(name);
×
380
                        if (rval)
×
381
                                return rval;
×
382
                }
383
        }
384
        return rval;
×
385
}
×
386

387
StelObjectP StelObjectMgr::searchByID(const QString &type, const QString &id) const
×
388
{
389
        auto it = typeToModuleMap.constFind(type);
×
390
        if(it!=typeToModuleMap.constEnd())
×
391
        {
392
                return (*it)->searchByID(id);
×
393
        }
394
        qWarning()<<"StelObject type"<<type<<"unknown";
×
395
        return Q_NULLPTR;
×
396
}
397

398
//! Find and select an object from its translated name
399
//! @param nameI18n the case sensitive object translated name
400
//! @return true if an object was found with the passed name
401
bool StelObjectMgr::findAndSelectI18n(const QString &nameI18n, StelModule::StelModuleSelectAction action)
×
402
{
403
        // Then look for another object
404
        StelObjectP obj = searchByNameI18n(nameI18n);
×
405
        if (!obj)
×
406
                return false;
×
407
        else
408
                return setSelectedObject(obj, action);
×
409
}
×
410

411
bool StelObjectMgr::findAndSelectI18n(const QString &name, const QString &objtype, StelModule::StelModuleSelectAction action)
×
412
{
413
        // Then look for another object
414
        StelObjectP obj = searchByNameI18n(name, objtype);
×
415
        if (!obj)
×
416
                return false;
×
417
        else
418
                return setSelectedObject(obj, action);
×
419
}
×
420

421
//! Find and select an object from its standard program name
422
bool StelObjectMgr::findAndSelect(const QString &name, StelModule::StelModuleSelectAction action)
×
423
{
424
        // Then look for another object
425
        StelObjectP obj = searchByName(name);
×
426
        if (!obj)
×
427
                return false;
×
428
        else
429
                return setSelectedObject(obj, action);
×
430
}
×
431

432
bool StelObjectMgr::findAndSelect(const QString &name, const QString &objtype, StelModule::StelModuleSelectAction action)
×
433
{
434
        // Then look for another object
435
        StelObjectP obj = searchByName(name, objtype);
×
436
        if (!obj)
×
437
                return false;
×
438
        else
439
                return setSelectedObject(obj, action);
×
440
}
×
441

442
//! Find and select an object near given equatorial J2000 position
443
bool StelObjectMgr::findAndSelect(const StelCore* core, const Vec3d& pos, StelModule::StelModuleSelectAction action)
×
444
{
445
        StelObjectP tempselect = cleverFind(core, pos);
×
446
        return setSelectedObject(tempselect, action);
×
447
}
×
448

449
//! Find and select an object near given screen position
450
bool StelObjectMgr::findAndSelect(const StelCore* core, int x, int y, StelModule::StelModuleSelectAction action)
×
451
{
452
        StelObjectP tempselect = cleverFind(core, x, y);
×
453
        return setSelectedObject(tempselect, action);
×
454
}
×
455

456
// Find an object in a "clever" way, v in J2000 frame (no aberration!)
457
StelObjectP StelObjectMgr::cleverFind(const StelCore* core, const Vec3d& v) const
×
458
{
459
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
460

461
        // Field of view for a searchRadiusPixel pixel diameter circle on screen
462
        const double fov_around = core->getMovementMgr()->getCurrentFov()/qMin(prj->getViewportWidth(), prj->getViewportHeight()) * searchRadiusPixel;
×
463

464
        // Collect the objects inside the range
465
        // TODO: normalize v here, and just Q_ASSERT normalized state in the submodules' searchAround() calls.
466
        QList<StelObjectP> candidates;
×
467
        for (const auto* m : objectsModules)
×
468
                candidates += m->searchAround(v, fov_around, core);
×
469

470
        // This should be exactly the sky's limit magnitude, else visible stars cannot be clicked, or suppressed stars can be found.
471
        const float limitMag = core->getSkyDrawer()->getFlagStarMagnitudeLimit() ?
×
472
                                static_cast<float>(core->getSkyDrawer()->getCustomStarMagnitudeLimit()) :
×
473
                                core->getSkyDrawer()->getLimitMagnitude();
×
474
        QList<StelObjectP> tmp;
×
475
        for (const auto& obj : qAsConst(candidates))
×
476
        {
477
                if (obj->getSelectPriority(core)<=limitMag)
×
478
                        tmp.append(obj);
×
479
        }
480
        candidates = tmp;
×
481
        
482
        // Now select the object minimizing the function y = distance(in pixel) + magnitude
483
        Vec3d winpos;
×
484
        prj->project(v, winpos);
×
485
        const double xpos = winpos[0];
×
486
        const double ypos = winpos[1];
×
487

488
        StelObjectP sobj;
×
489
        float best_object_value = 100000.f;
×
490
        for (const auto& obj : qAsConst(candidates))
×
491
        {
492
                prj->project(obj->getJ2000EquatorialPos(core), winpos);
×
493
                float distance = static_cast<float>(std::sqrt((xpos-winpos[0])*(xpos-winpos[0]) + (ypos-winpos[1])*(ypos-winpos[1])))*distanceWeight;
×
494
                float priority =  obj->getSelectPriority(core);
×
495
                // qDebug() << (*iter).getShortInfoString(core) << ": " << priority << " " << distance;
496
                if (distance + priority < best_object_value)
×
497
                {
498
                        best_object_value = distance + priority;
×
499
                        sobj = obj;
×
500
                }
501
        }
502

503
        return sobj;
×
504
}
×
505

506
/*************************************************************************
507
 Find in a "clever" way an object from its screen position
508
 If aberration is corrected, we must compute mean J2000 from the clicked position
509
 because all cleverfind() is supposed to work with mean J2000 positions.
510
 With aberration clause, stars/DSO are found, without the planet moons are found.
511
*************************************************************************/
512
StelObjectP StelObjectMgr::cleverFind(const StelCore* core, int x, int y) const
×
513
{
514
        Vec3d v;
×
515
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
516
        if (prj->unProject(x,y,v))
×
517
        {
518
                // Nick Fedoseev patch: improve click match for refracted coordinates
519
                Vec3d win;
×
520
                prj->project(v,win);
×
521
                const double dx = x - win.v[0];
×
522
                const double dy = y - win.v[1];
×
523
                prj->unProject(x+dx, y+dy, v);
×
524

525
                // Apply annual aberration (backwards). Explan. Suppl. 2013, (7.38)
526
                Vec3d v2000(v);
×
527
                if (core->getUseAberration())
×
528
                {
529
                        v2000.normalize(); // just to be sure...
×
530
                        Vec3d vel=core->getCurrentPlanet()->getHeliocentricEclipticVelocity();
×
531
                        StelCore::matVsop87ToJ2000.transfo(vel);
×
532
                        vel*=core->getAberrationFactor() * (AU/(86400.0*SPEED_OF_LIGHT));
×
533
                        v2000-=vel;
×
534
                        v2000.normalize();
×
535
                }
536
                return cleverFind(core, v2000);
×
537
        }
538
        return StelObjectP();
×
539
}
×
540

541
/*************************************************************************
542
 Notify that we want to unselect any object
543
*************************************************************************/
544
void StelObjectMgr::unSelect(void)
×
545
{
546
        if(!lastSelectedObjects.isEmpty())
×
547
        {
548
                lastSelectedObjects.clear();
×
549
                emit selectedObjectChanged(StelModule::RemoveFromSelection);
×
550
        }
551
}
×
552

553
/*************************************************************************
554
 Notify that we want to select the given object
555
*************************************************************************/
556
bool StelObjectMgr::setSelectedObject(const StelObjectP obj, StelModule::StelModuleSelectAction action)
×
557
{
558
        if (!obj)
×
559
        {
560
                unSelect();
×
561
                return false;
×
562
        }
563

564
        // An object has been found
565
        QList<StelObjectP> objs;
×
566
        objs.push_back(obj);
×
567
        return setSelectedObject(objs, action);
×
568
}
×
569

570
/*************************************************************************
571
 Notify that we want to select the given objects
572
*************************************************************************/
573
bool StelObjectMgr::setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action)
×
574
{
575
        if (action==StelModule::AddToSelection)
×
576
                lastSelectedObjects.append(objs);
×
577
        else
578
                lastSelectedObjects = objs;
×
579
        emit selectedObjectChanged(action);
×
580
        return true;
×
581
}
582

583
/*************************************************************************
584
 Return the list objects of type "type" which was recently selected by
585
  the user
586
*************************************************************************/
587
QList<StelObjectP> StelObjectMgr::getSelectedObject(const QString& type) const
×
588
{
589
        QList<StelObjectP> result;
×
590
        for (const auto& obj : lastSelectedObjects)
×
591
        {
592
                if (obj->getType() == type)
×
593
                        result.push_back(obj);
×
594
        }
595
        return result;
×
596
}
×
597

598
/*****************************************************************************************
599
 Find and return the list of at most maxNbItem objects auto-completing passed object name
600
*******************************************************************************************/
601
QStringList StelObjectMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
×
602
{
603
        QStringList result;
×
604
        if (maxNbItem <= 0)
×
605
                return result;
×
606

607
        // For all StelObjectmodules..
608
        for (const auto* m : objectsModules)
×
609
        {
610
                // Get matching object for this module
611
                QStringList matchingObj = m->listMatchingObjects(objPrefix, maxNbItem, useStartOfWords);
×
612
                result += matchingObj;
×
613
        }
×
614

615
        result.sort();
×
616
        return result;
×
617
}
×
618

619
QStringList StelObjectMgr::listAllModuleObjects(const QString &moduleId, bool inEnglish) const
×
620
{
621
        // search for module
622
        StelObjectModule* module = Q_NULLPTR;
×
623
        QStringList result;
×
624
        QString objModule, objType;
×
625
        bool subSet = false;
×
626
        if (moduleId.contains(":"))
×
627
        {
628
                subSet = true;
×
629
                #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
630
                QStringList list = moduleId.split(":", Qt::SkipEmptyParts);
×
631
                #else
632
                QStringList list = moduleId.split(":", QString::SkipEmptyParts);
633
                #endif
634
                objModule = list.at(0);
×
635
                objType = list.at(1);
×
636
        }
×
637
        else
638
                objModule = moduleId;
×
639
        for (auto* m : objectsModules)
×
640
        {
641
                if (m->objectName() == objModule)
×
642
                {
643
                        module = m;
×
644
                        break;
×
645
                }
646
        }
647
        if (module == Q_NULLPTR)
×
648
        {
649
                qWarning() << "Can't find module with id " << objModule;
×
650
                return QStringList();
×
651
        }
652
        if (subSet)
×
653
                result = module->listAllObjectsByType(objType, inEnglish);
×
654
        else
655
                result = module->listAllObjects(inEnglish);
×
656

657
        return result;
×
658
}
×
659

660
QMap<QString, QString> StelObjectMgr::objectModulesMap() const
×
661
{
662
        return objModulesMap;
×
663
}
664

665
QVariantMap StelObjectMgr::getObjectInfo(const StelObjectP obj)
×
666
{
667
        QVariantMap map;
×
668
        if (!obj)
×
669
        {
670
                qDebug() << "getObjectInfo WARNING - object not found";
×
671
                map.insert("found", false);
×
672
        }
673
        else
674
        {
675
                map=obj->getInfoMap(StelApp::getInstance().getCore());
×
676
                map.insert("found", true);
×
677
        }
678
        return map;
×
679
}
×
680

681

682

683
void StelObjectMgr::setExtraInfoString(const StelObject::InfoStringGroup& flags, const QString &str)
×
684
{
685
        extraInfoStrings.remove(flags); // delete all entries with these flags
×
686
        if (str.length()>0)
×
687
                extraInfoStrings.insert(flags, str);
×
688
}
×
689
void StelObjectMgr::addToExtraInfoString(const StelObject::InfoStringGroup &flags, const QString &str)
×
690
{
691
        // Avoid insertion of full duplicates!
692
        if (!extraInfoStrings.contains(flags, str))
×
693
                extraInfoStrings.insert(flags, str);
×
694
}
×
695

696
QStringList StelObjectMgr::getExtraInfoStrings(const StelObject::InfoStringGroup& flags) const
×
697
{
698
        QStringList list;
×
699
        QMultiMap<StelObject::InfoStringGroup, QString>::const_iterator i = extraInfoStrings.constBegin();
×
700
        while (i != extraInfoStrings.constEnd())
×
701
        {
702
                if (i.key() & flags)
×
703
                {
704
                        QString val=i.value();
×
705
                        if (flags&StelObject::DebugAid)
×
706
                                val.prepend("DEBUG: ");
×
707
                        // For unclear reasons the sequence of entries can be preserved by *pre*pending in the returned list.
708
                        list.prepend(val);
×
709
                }
×
710
                ++i;
×
711
        }
712
        return list;
×
713
}
×
714

715
void StelObjectMgr::removeExtraInfoStrings(const StelObject::InfoStringGroup& flags)
×
716
{
717
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
718
        QMutableMultiMapIterator<StelObject::InfoStringGroup, QString> i(extraInfoStrings);
719
#else
720
        QMutableMapIterator<StelObject::InfoStringGroup, QString> i(extraInfoStrings);
×
721
#endif
722
        while (i.hasNext())
×
723
        {
724
                i.next();
×
725
                if (i.key() & flags)
×
726
                        i.remove();
×
727
        }
728
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc