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

Stellarium / stellarium / 13260145531

11 Feb 2025 09:41AM UTC coverage: 12.127% (+0.03%) from 12.101%
13260145531

Pull #3751

github

10110111
Restore deleted additional SC files
Pull Request #3751: Switch skycultures to the new format

14613 of 120497 relevant lines covered (12.13%)

18620.19 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
#include "StelActionMgr.hpp"
31

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

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

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

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

53
        addAction("actionToggle_Selected_Object_Pointer", N_("Miscellaneous"), N_("Toggle visibility of pointers for selected objects"), "objectPointerVisibility", "");
×
54
}
×
55

56
StelObject::InfoStringGroup StelObjectMgr::getCustomInfoStrings()
×
57
{
58
        QSettings* conf = StelApp::getInstance().getSettings();
×
59
        StelObject::InfoStringGroup infoTextFilters = StelObject::InfoStringGroup(StelObject::None);
×
60

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

112
        return infoTextFilters;
×
113
}
114

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

123
        objModulesMap.insert(m->objectName(), m->getName());
×
124

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

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

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

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

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

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

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

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

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

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

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

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

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

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

464
        // Field of view for a searchRadiusPixel pixel diameter circle on User's screen (which may not be the same on scaled display)
465
        const double fov_around = core->getMovementMgr()->getCurrentFov()/qMin(prj->getViewportWidth(), prj->getViewportHeight()) * searchRadiusPixel * core->getCurrentStelProjectorParams().devicePixelsPerPixel;
×
466

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

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

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

506
        return sobj;
×
507
}
×
508

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

528
                return cleverFind(core, v);
×
529
        }
530
        return StelObjectP();
×
531
}
×
532

533
/*************************************************************************
534
 Notify that we want to unselect any object
535
*************************************************************************/
536
void StelObjectMgr::unSelect(void)
×
537
{
538
        if(!lastSelectedObjects.isEmpty())
×
539
        {
540
                lastSelectedObjects.clear();
×
541
                emit selectedObjectChanged(StelModule::RemoveFromSelection);
×
542
        }
543
}
×
544

545
/*************************************************************************
546
 Notify that we want to select the given object
547
*************************************************************************/
548
bool StelObjectMgr::setSelectedObject(const StelObjectP obj, StelModule::StelModuleSelectAction action)
×
549
{
550
        if (!obj)
×
551
        {
552
                unSelect();
×
553
                return false;
×
554
        }
555

556
        // An object has been found
557
        QList<StelObjectP> objs;
×
558
        objs.push_back(obj);
×
559
        return setSelectedObject(objs, action);
×
560
}
×
561

562
/*************************************************************************
563
 Notify that we want to select the given objects
564
*************************************************************************/
565
bool StelObjectMgr::setSelectedObject(const QList<StelObjectP>& objs, StelModule::StelModuleSelectAction action)
×
566
{
567
        if (action==StelModule::AddToSelection)
×
568
                lastSelectedObjects.append(objs);
×
569
        else
570
                lastSelectedObjects = objs;
×
571
        emit selectedObjectChanged(action);
×
572
        return true;
×
573
}
574

575
/*************************************************************************
576
 Return the list objects of type "type" which was recently selected by
577
  the user
578
*************************************************************************/
579
QList<StelObjectP> StelObjectMgr::getSelectedObject(const QString& type) const
×
580
{
581
        QList<StelObjectP> result;
×
582
        for (const auto& obj : lastSelectedObjects)
×
583
        {
584
                if (obj->getType() == type)
×
585
                        result.push_back(obj);
×
586
        }
587
        return result;
×
588
}
×
589

590
/*****************************************************************************************
591
 Find and return the list of at most maxNbItem objects auto-completing passed object name
592
*******************************************************************************************/
593
QStringList StelObjectMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
×
594
{
595
        QStringList result;
×
596
        if (maxNbItem <= 0)
×
597
                return result;
×
598

599
        // For all StelObjectmodules..
600
        for (const auto* m : objectsModules)
×
601
        {
602
                // Get matching object for this module
603
                QStringList matchingObj = m->listMatchingObjects(objPrefix, maxNbItem, useStartOfWords);
×
604
                result += matchingObj;
×
605
        }
×
606

607
        result.sort();
×
608
        return result;
×
609
}
×
610

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

649
        return result;
×
650
}
×
651

652
QMap<QString, QString> StelObjectMgr::objectModulesMap() const
×
653
{
654
        return objModulesMap;
×
655
}
656

657
QVariantMap StelObjectMgr::getObjectInfo(const StelObjectP obj)
×
658
{
659
        QVariantMap map;
×
660
        if (!obj)
×
661
        {
662
                qDebug() << "getObjectInfo WARNING - object not found";
×
663
                map.insert("found", false);
×
664
        }
665
        else
666
        {
667
                map=obj->getInfoMap(StelApp::getInstance().getCore());
×
668
                map.insert("found", true);
×
669
        }
670
        return map;
×
671
}
×
672

673

674

675
void StelObjectMgr::setExtraInfoString(const StelObject::InfoStringGroup& flags, const QString &str)
×
676
{
677
        extraInfoStrings.remove(flags); // delete all entries with these flags
×
678
        if (!str.isEmpty())
×
679
                extraInfoStrings.insert(flags, str);
×
680
}
×
681
void StelObjectMgr::addToExtraInfoString(const StelObject::InfoStringGroup &flags, const QString &str)
×
682
{
683
        // Avoid insertion of full duplicates!
684
        if (!extraInfoStrings.contains(flags, str))
×
685
                extraInfoStrings.insert(flags, str);
×
686
}
×
687

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

707
void StelObjectMgr::removeExtraInfoStrings(const StelObject::InfoStringGroup& flags)
×
708
{
709
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
710
        QMutableMultiMapIterator<StelObject::InfoStringGroup, QString> i(extraInfoStrings);
×
711
#else
712
        QMutableMapIterator<StelObject::InfoStringGroup, QString> i(extraInfoStrings);
713
#endif
714
        while (i.hasNext())
×
715
        {
716
                i.next();
×
717
                if (i.key() & flags)
×
718
                        i.remove();
×
719
        }
720
}
×
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