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

Stellarium / stellarium / 15291801018

28 May 2025 04:52AM UTC coverage: 11.931% (-0.02%) from 11.951%
15291801018

push

github

alex-w
Added new set of navigational stars (XIX century)

0 of 6 new or added lines in 2 files covered. (0.0%)

14124 existing lines in 74 files now uncovered.

14635 of 122664 relevant lines covered (11.93%)

18291.42 hits per line

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

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

22
// class used to manage groups of Nebulas
23

24
#include "StelApp.hpp"
25
#include "NebulaList.hpp"
26
#include "NebulaMgr.hpp"
27
#include "Nebula.hpp"
28
#include "StelTexture.hpp"
29
#include "StelUtils.hpp"
30
#include "StelMainView.hpp"
31
#include "StelSkyDrawer.hpp"
32
#include "StelTranslator.hpp"
33
#include "StelTextureMgr.hpp"
34
#include "StelObjectMgr.hpp"
35
#include "StelLocaleMgr.hpp"
36
#include "StelSkyCultureMgr.hpp"
37
#include "StelFileMgr.hpp"
38
#include "StelModuleMgr.hpp"
39
#include "StelCore.hpp"
40
#include "StelPainter.hpp"
41

42
#include <vector>
43
#include <QDebug>
44
#include <QFile>
45
#include <QSettings>
46
#include <QString>
47
#include <QStringList>
48
#include <QRegularExpression>
49
#include <QDir>
50
#include <QMessageBox>
51

52
// Define version of valid Stellarium DSO Catalog
53
// This number must be incremented each time the content or file format of the stars catalogs change
54
const QString NebulaMgr::StellariumDSOCatalogVersion = QStringLiteral("3.20");
55

56
namespace
57
{
58

59
void addEnglishOrAliasName(const NebulaP& nebula, const QString& name)
×
60
{
61
        const QString &currentName = nebula->getEnglishName();
×
62
        if (currentName.isEmpty()) // Set native name of DSO
×
63
                nebula->setEnglishName(name);
×
64
        else if (currentName != name) // Add traditional (well-known?) name of DSO as alias
×
65
                nebula->addNameAlias(name);
×
66
}
×
67

68
}
69

70
void NebulaMgr::setLabelsColor(const Vec3f& c) {Nebula::labelColor = c; emit labelsColorChanged(c);}
×
71
const Vec3f NebulaMgr::getLabelsColor(void) const {return Nebula::labelColor;}
×
72
void NebulaMgr::setCirclesColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebUnknown, c); emit circlesColorChanged(c); }
×
73
const Vec3f NebulaMgr::getCirclesColor(void) const {return Nebula::hintColorMap.value(Nebula::NebUnknown);}
×
74
void NebulaMgr::setRegionsColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebRegion, c); emit regionsColorChanged(c); }
×
75
const Vec3f NebulaMgr::getRegionsColor(void) const {return Nebula::hintColorMap.value(Nebula::NebRegion);}
×
76
void NebulaMgr::setGalaxyColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebGx, c); Nebula::hintColorMap.insert(Nebula::NebPartOfGx, c); emit galaxiesColorChanged(c); }
×
77
const Vec3f NebulaMgr::getGalaxyColor(void) const {return Nebula::hintColorMap.value(Nebula::NebGx);}
×
78
void NebulaMgr::setRadioGalaxyColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebRGx, c); emit radioGalaxiesColorChanged(c); }
×
79
const Vec3f NebulaMgr::getRadioGalaxyColor(void) const {return Nebula::hintColorMap.value(Nebula::NebRGx);}
×
80
void NebulaMgr::setActiveGalaxyColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebAGx, c); emit activeGalaxiesColorChanged(c); }
×
81
const Vec3f NebulaMgr::getActiveGalaxyColor(void) const {return Nebula::hintColorMap.value(Nebula::NebAGx);}
×
82
void NebulaMgr::setInteractingGalaxyColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebIGx, c); emit interactingGalaxiesColorChanged(c); }
×
83
const Vec3f NebulaMgr::getInteractingGalaxyColor(void) const {return Nebula::hintColorMap.value(Nebula::NebIGx);}
×
84
void NebulaMgr::setQuasarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebQSO, c); emit quasarsColorChanged(c); }
×
85
const Vec3f NebulaMgr::getQuasarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebQSO);}
×
86
void NebulaMgr::setNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebN, c); Nebula::hintColorMap.insert(Nebula::NebCn, c); emit nebulaeColorChanged(c); }
×
87
const Vec3f NebulaMgr::getNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebN);}
×
88
void NebulaMgr::setPlanetaryNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebPn, c); emit planetaryNebulaeColorChanged(c);}
×
89
const Vec3f NebulaMgr::getPlanetaryNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebPn);}
×
90
void NebulaMgr::setReflectionNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebRn, c); emit reflectionNebulaeColorChanged(c);}
×
91
const Vec3f NebulaMgr::getReflectionNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebRn);}
×
92
void NebulaMgr::setBipolarNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebBn, c); emit bipolarNebulaeColorChanged(c);}
×
93
const Vec3f NebulaMgr::getBipolarNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebBn);}
×
94
void NebulaMgr::setEmissionNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebEn, c); emit emissionNebulaeColorChanged(c);}
×
95
const Vec3f NebulaMgr::getEmissionNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebEn);}
×
96
void NebulaMgr::setDarkNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebDn, c); emit darkNebulaeColorChanged(c);}
×
97
const Vec3f NebulaMgr::getDarkNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebDn);}
×
98
void NebulaMgr::setHydrogenRegionColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebHII, c); emit hydrogenRegionsColorChanged(c);}
×
99
const Vec3f NebulaMgr::getHydrogenRegionColor(void) const {return Nebula::hintColorMap.value(Nebula::NebHII);}
×
100
void NebulaMgr::setSupernovaRemnantColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSNR, c); emit supernovaRemnantsColorChanged(c);}
×
101
const Vec3f NebulaMgr::getSupernovaRemnantColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSNR);}
×
102
void NebulaMgr::setSupernovaCandidateColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSNC, c); emit supernovaCandidatesColorChanged(c);}
×
103
const Vec3f NebulaMgr::getSupernovaCandidateColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSNC);}
×
104
void NebulaMgr::setSupernovaRemnantCandidateColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSNRC, c); emit supernovaRemnantCandidatesColorChanged(c);}
×
105
const Vec3f NebulaMgr::getSupernovaRemnantCandidateColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSNRC);}
×
106
void NebulaMgr::setInterstellarMatterColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebISM, c); emit interstellarMatterColorChanged(c);}
×
107
const Vec3f NebulaMgr::getInterstellarMatterColor(void) const {return Nebula::hintColorMap.value(Nebula::NebISM);}
×
108
void NebulaMgr::setClusterColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebCl, c); emit clustersColorChanged(c);}
×
109
const Vec3f NebulaMgr::getClusterColor(void) const {return Nebula::hintColorMap.value(Nebula::NebCl);}
×
110
void NebulaMgr::setOpenClusterColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebOc, c); emit openClustersColorChanged(c);}
×
111
const Vec3f NebulaMgr::getOpenClusterColor(void) const {return Nebula::hintColorMap.value(Nebula::NebOc);}
×
112
void NebulaMgr::setGlobularClusterColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebGc, c); emit globularClustersColorChanged(c);}
×
113
const Vec3f NebulaMgr::getGlobularClusterColor(void) const {return Nebula::hintColorMap.value(Nebula::NebGc);}
×
114
void NebulaMgr::setStellarAssociationColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSA, c); emit stellarAssociationsColorChanged(c);}
×
115
const Vec3f NebulaMgr::getStellarAssociationColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSA);}
×
116
void NebulaMgr::setStarCloudColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSC, c); emit starCloudsColorChanged(c);}
×
117
const Vec3f NebulaMgr::getStarCloudColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSC);}
×
118
void NebulaMgr::setEmissionObjectColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebEMO, c); emit emissionObjectsColorChanged(c);}
×
119
const Vec3f NebulaMgr::getEmissionObjectColor(void) const {return Nebula::hintColorMap.value(Nebula::NebEMO);}
×
120
void NebulaMgr::setBlLacObjectColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebBLL, c); emit blLacObjectsColorChanged(c);}
×
121
const Vec3f NebulaMgr::getBlLacObjectColor(void) const {return Nebula::hintColorMap.value(Nebula::NebBLL);}
×
122
void NebulaMgr::setBlazarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebBLA, c); emit blazarsColorChanged(c);}
×
123
const Vec3f NebulaMgr::getBlazarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebBLA);}
×
124
void NebulaMgr::setMolecularCloudColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebMolCld, c); emit molecularCloudsColorChanged(c);}
×
125
const Vec3f NebulaMgr::getMolecularCloudColor(void) const {return Nebula::hintColorMap.value(Nebula::NebMolCld);}
×
126
void NebulaMgr::setYoungStellarObjectColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebYSO, c); emit youngStellarObjectsColorChanged(c);}
×
127
const Vec3f NebulaMgr::getYoungStellarObjectColor(void) const {return Nebula::hintColorMap.value(Nebula::NebYSO);}
×
128
void NebulaMgr::setPossibleQuasarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebPossQSO, c); emit possibleQuasarsColorChanged(c);}
×
129
const Vec3f NebulaMgr::getPossibleQuasarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebPossQSO);}
×
130
void NebulaMgr::setPossiblePlanetaryNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebPossPN, c); emit possiblePlanetaryNebulaeColorChanged(c);}
×
131
const Vec3f NebulaMgr::getPossiblePlanetaryNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebPossPN);}
×
132
void NebulaMgr::setProtoplanetaryNebulaColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebPPN, c); emit protoplanetaryNebulaeColorChanged(c);}
×
133
const Vec3f NebulaMgr::getProtoplanetaryNebulaColor(void) const {return Nebula::hintColorMap.value(Nebula::NebPPN);}
×
134
void NebulaMgr::setStarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebStar, c); emit starsColorChanged(c);}
×
135
const Vec3f NebulaMgr::getStarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebStar);}
×
136
void NebulaMgr::setSymbioticStarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebSymbioticStar, c); emit symbioticStarsColorChanged(c);}
×
137
const Vec3f NebulaMgr::getSymbioticStarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebSymbioticStar);}
×
138
void NebulaMgr::setEmissionLineStarColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebEmissionLineStar, c); emit emissionLineStarsColorChanged(c);}
×
139
const Vec3f NebulaMgr::getEmissionLineStarColor(void) const {return Nebula::hintColorMap.value(Nebula::NebEmissionLineStar);}
×
140
void NebulaMgr::setGalaxyClusterColor(const Vec3f& c) {Nebula::hintColorMap.insert(Nebula::NebGxCl, c); emit galaxyClustersColorChanged(c);}
×
141
const Vec3f NebulaMgr::getGalaxyClusterColor(void) const {return Nebula::hintColorMap.value(Nebula::NebGxCl);}
×
142

143
bool NebulaMgr::getHintsProportional(void) const {return Nebula::drawHintProportional;}
×
144
void NebulaMgr::setHintsProportional(const bool proportional)
×
145
{
146
        if(Nebula::drawHintProportional!=proportional)
×
147
        {
148
                Nebula::drawHintProportional=proportional;
×
149
                StelApp::immediateSave("astro/flag_nebula_hints_proportional", proportional);
×
150
                emit hintsProportionalChanged(proportional);
×
151
        }
152
}
×
153

154
bool NebulaMgr::getDesignationUsage(void) const {return Nebula::designationUsage; }
×
155
void NebulaMgr::setDesignationUsage(const bool flag)
×
156
{
157
        if(Nebula::designationUsage!=flag)
×
158
        {
159
                Nebula::designationUsage=flag;
×
160
                StelApp::immediateSave("astro/flag_dso_designation_usage", flag);
×
161
                emit designationUsageChanged(flag);
×
162
        }
163
}
×
164
bool NebulaMgr::getFlagAdditionalNames(void) const {return Nebula::flagShowAdditionalNames;}
×
165
void NebulaMgr::setFlagAdditionalNames(const bool flag)
×
166
{
167
        if(Nebula::flagShowAdditionalNames!=flag)
×
168
        {
169
                Nebula::flagShowAdditionalNames=flag;
×
170
                StelApp::immediateSave("astro/flag_dso_additional_names", flag);
×
171
                emit flagAdditionalNamesDisplayedChanged(flag);
×
172
        }
173
}
×
174

175
bool NebulaMgr::getFlagOutlines(void) const {return Nebula::flagUseOutlines;}
×
176
void NebulaMgr::setFlagOutlines(const bool flag)
×
177
{
178
        if(Nebula::flagUseOutlines!=flag)
×
179
        {
180
                Nebula::flagUseOutlines=flag;
×
181
                StelApp::immediateSave("astro/flag_dso_outlines_usage", flag);
×
182
                emit flagOutlinesDisplayedChanged(flag);
×
183
        }
184
}
×
185

186
bool NebulaMgr::getFlagShowOnlyNamedDSO(void) const {return Nebula::flagShowOnlyNamedDSO; }
×
187
void NebulaMgr::setFlagShowOnlyNamedDSO(const bool flag)
×
188
{
189
        if(Nebula::flagShowOnlyNamedDSO!=flag)
×
190
        {
191
                Nebula::flagShowOnlyNamedDSO=flag;
×
192
                StelApp::immediateSave("astro/flag_dso_show_only_named", flag);
×
193
                emit flagShowOnlyNamedDSOChanged(flag);
×
194
        }
195
}
×
196

197
NebulaMgr::NebulaMgr(void) : StelObjectModule()
×
198
        , nebGrid(200)
×
199
        , hintsAmount(0)
×
200
        , labelsAmount(0)
×
201
        , hintsBrightness(1.0)
×
202
        , labelsBrightness(1.0)
×
203
        , flagConverter(false)
×
204
        , flagDecimalCoordinates(true)
×
205
{
206
        setObjectName("NebulaMgr");
×
207
}
×
208

209
NebulaMgr::~NebulaMgr()
×
210
{
211
        Nebula::texRegion = StelTextureSP();
×
212
        Nebula::texPointElement = StelTextureSP();
×
213
        Nebula::texPlanetaryNebula = StelTextureSP();
×
214
}
×
215

216
/*************************************************************************
217
 Reimplementation of the getCallOrder method
218
*************************************************************************/
219
double NebulaMgr::getCallOrder(StelModuleActionName actionName) const
×
220
{
221
        if (actionName==StelModule::ActionDraw)
×
222
                return StelApp::getInstance().getModuleMgr().getModule("MilkyWay")->getCallOrder(actionName)+10;
×
223
        return 0;
×
224
}
225

226
// read from stream
227
void NebulaMgr::init()
×
228
{
229
        QSettings* conf = StelApp::getInstance().getSettings();
×
230
        Q_ASSERT(conf);
×
231

232
        nebulaFont.setPixelSize(StelApp::getInstance().getScreenFontSize());
×
233
        connect(&StelApp::getInstance(), SIGNAL(screenFontSizeChanged(int)), SLOT(setFontSizeFromApp(int)));
×
234
    auto& texMan = StelApp::getInstance().getTextureManager();
×
235
        // Load dashed shape texture
236
        Nebula::texRegion                = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_reg.png");
×
237
        // Load open cluster marker texture
238
        Nebula::texPointElement                = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_point_elem.png");
×
239
        // Load planetary nebula marker texture
240
        Nebula::texPlanetaryNebula        = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_pnb.png");
×
241
        // Load pointer texture
242
        texPointer = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png");
×
243

244
        setFlagShow(conf->value("astro/flag_nebula",true).toBool());
×
245
        setFlagHints(conf->value("astro/flag_nebula_name",false).toBool());
×
246
        setHintsAmount(conf->value("astro/nebula_hints_amount", 3.0).toDouble());
×
247
        setLabelsAmount(conf->value("astro/nebula_labels_amount", 3.0).toDouble());
×
248
        setHintsProportional(conf->value("astro/flag_nebula_hints_proportional", false).toBool());
×
249
        setFlagOutlines(conf->value("astro/flag_dso_outlines_usage", false).toBool());
×
250
        setFlagAdditionalNames(conf->value("astro/flag_dso_additional_names",true).toBool());
×
251
        setDesignationUsage(conf->value("astro/flag_dso_designation_usage", false).toBool());
×
252
        setFlagSurfaceBrightnessUsage(conf->value("astro/flag_surface_brightness_usage", false).toBool());
×
253
        setFlagSurfaceBrightnessArcsecUsage(conf->value("gui/flag_surface_brightness_arcsec", false).toBool());
×
254
        setFlagSurfaceBrightnessShortNotationUsage(conf->value("gui/flag_surface_brightness_short", false).toBool());
×
255
        setFlagShowOnlyNamedDSO(conf->value("astro/flag_dso_show_only_named", false).toBool());
×
256

257
        setFlagSizeLimitsUsage(conf->value("astro/flag_size_limits_usage", false).toBool());
×
258
        setMinSizeLimit(conf->value("astro/size_limit_min", 1.0).toDouble());
×
259
        setMaxSizeLimit(conf->value("astro/size_limit_max", 600.0).toDouble());
×
260

261
        // Load colors from config file
262
        // Upgrade config keys
263
        if (conf->contains("color/nebula_label_color"))
×
264
        {
265
                conf->setValue("color/dso_label_color", conf->value("color/nebula_label_color", "0.4,0.3,0.5").toString());
×
266
                conf->remove("color/nebula_label_color");
×
267
        }
268
        if (conf->contains("color/nebula_circle_color"))
×
269
        {
270
                conf->setValue("color/dso_circle_color", conf->value("color/nebula_circle_color", "0.8,0.8,0.1").toString());
×
271
                conf->remove("color/nebula_circle_color");
×
272
        }
273
        if (conf->contains("color/nebula_galaxy_color"))
×
274
        {
275
                conf->setValue("color/dso_galaxy_color", conf->value("color/nebula_galaxy_color", "1.0,0.2,0.2").toString());
×
276
                conf->remove("color/nebula_galaxy_color");
×
277
        }
278
        if (conf->contains("color/nebula_radioglx_color"))
×
279
        {
280
                conf->setValue("color/dso_radio_galaxy_color", conf->value("color/nebula_radioglx_color", "0.3,0.3,0.3").toString());
×
281
                conf->remove("color/nebula_radioglx_color");
×
282
        }
283
        if (conf->contains("color/nebula_activeglx_color"))
×
284
        {
285
                conf->setValue("color/dso_active_galaxy_color", conf->value("color/nebula_activeglx_color", "1.0,0.5,0.2").toString());
×
286
                conf->remove("color/nebula_activeglx_color");
×
287
        }
288
        if (conf->contains("color/nebula_intglx_color"))
×
289
        {
290
                conf->setValue("color/dso_interacting_galaxy_color", conf->value("color/nebula_intglx_color", "0.2,0.5,1.0").toString());
×
291
                conf->remove("color/nebula_intglx_color");
×
292
        }
293
        if (conf->contains("color/nebula_brightneb_color"))
×
294
        {
295
                conf->setValue("color/dso_nebula_color", conf->value("color/nebula_brightneb_color", "0.1,1.0,0.1").toString());
×
296
                conf->remove("color/nebula_brightneb_color");
×
297
        }
298
        if (conf->contains("color/nebula_darkneb_color"))
×
299
        {
300
                conf->setValue("color/dso_dark_nebula_color", conf->value("color/nebula_darkneb_color", "0.3,0.3,0.3").toString());
×
301
                conf->remove("color/nebula_darkneb_color");
×
302
        }
303
        if (conf->contains("color/nebula_hregion_color"))
×
304
        {
305
                conf->setValue("color/dso_hydrogen_region_color", conf->value("color/nebula_hregion_color", "0.1,1.0,0.1").toString());
×
306
                conf->remove("color/nebula_hregion_color");
×
307
        }
308
        if (conf->contains("color/nebula_snr_color"))
×
309
        {
310
                conf->setValue("color/dso_supernova_remnant_color", conf->value("color/nebula_snr_color", "0.1,1.0,0.1").toString());
×
311
                conf->remove("color/nebula_snr_color");
×
312
        }
313
        if (conf->contains("color/nebula_cluster_color"))
×
314
        {
315
                conf->setValue("color/dso_cluster_color", conf->value("color/nebula_cluster_color", "0.8,0.8,0.1").toString());
×
316
                conf->remove("color/nebula_cluster_color");
×
317
        }
318

319
        // Set colors for markers
320
        setLabelsBrightness(conf->value("astro/nebula_labels_brightness", "1.0").toDouble());
×
321
        setHintsBrightness(conf->value("astro/nebula_hints_brightness", "1.0").toDouble());
×
322
        setLabelsColor(Vec3f(conf->value("color/dso_label_color", "0.2,0.6,0.7").toString()));
×
323
        setCirclesColor(Vec3f(conf->value("color/dso_circle_color", "1.0,0.7,0.2").toString()));
×
324
        setRegionsColor(Vec3f(conf->value("color/dso_region_color", "0.7,0.7,0.2").toString()));
×
325

326
        QString defaultGalaxyColor = conf->value("color/dso_galaxy_color", "1.0,0.2,0.2").toString();
×
327
        setGalaxyColor(           Vec3f(defaultGalaxyColor));
×
328
        setRadioGalaxyColor(      Vec3f(conf->value("color/dso_radio_galaxy_color", "0.3,0.3,0.3").toString()));
×
329
        setActiveGalaxyColor(     Vec3f(conf->value("color/dso_active_galaxy_color", "1.0,0.5,0.2").toString()));
×
330
        setInteractingGalaxyColor(Vec3f(conf->value("color/dso_interacting_galaxy_color", "0.2,0.5,1.0").toString()));
×
331
        setGalaxyClusterColor(    Vec3f(conf->value("color/dso_galaxy_cluster_color", "0.2,0.8,1.0").toString()));
×
332
        setQuasarColor(           Vec3f(conf->value("color/dso_quasar_color", defaultGalaxyColor).toString()));
×
333
        setPossibleQuasarColor(   Vec3f(conf->value("color/dso_possible_quasar_color", defaultGalaxyColor).toString()));
×
334
        setBlLacObjectColor(      Vec3f(conf->value("color/dso_bl_lac_color", defaultGalaxyColor).toString()));
×
335
        setBlazarColor(           Vec3f(conf->value("color/dso_blazar_color", defaultGalaxyColor).toString()));
×
336

337
        QString defaultNebulaColor = conf->value("color/dso_nebula_color", "0.1,1.0,0.1").toString();
×
338
        setNebulaColor(                   Vec3f(defaultNebulaColor));
×
339
        setPlanetaryNebulaColor(          Vec3f(conf->value("color/dso_planetary_nebula_color", defaultNebulaColor).toString()));
×
340
        setReflectionNebulaColor(         Vec3f(conf->value("color/dso_reflection_nebula_color", defaultNebulaColor).toString()));
×
341
        setBipolarNebulaColor(            Vec3f(conf->value("color/dso_bipolar_nebula_color", defaultNebulaColor).toString()));
×
342
        setEmissionNebulaColor(           Vec3f(conf->value("color/dso_emission_nebula_color", defaultNebulaColor).toString()));
×
343
        setDarkNebulaColor(               Vec3f(conf->value("color/dso_dark_nebula_color", "0.3,0.3,0.3").toString()));
×
344
        setHydrogenRegionColor(           Vec3f(conf->value("color/dso_hydrogen_region_color", defaultNebulaColor).toString()));
×
345
        setSupernovaRemnantColor(         Vec3f(conf->value("color/dso_supernova_remnant_color", defaultNebulaColor).toString()));
×
346
        setSupernovaCandidateColor(       Vec3f(conf->value("color/dso_supernova_candidate_color", defaultNebulaColor).toString()));
×
347
        setSupernovaRemnantCandidateColor(Vec3f(conf->value("color/dso_supernova_remnant_cand_color", defaultNebulaColor).toString()));
×
348
        setInterstellarMatterColor(       Vec3f(conf->value("color/dso_interstellar_matter_color", defaultNebulaColor).toString()));
×
349
        setMolecularCloudColor(           Vec3f(conf->value("color/dso_molecular_cloud_color", defaultNebulaColor).toString()));
×
350
        setPossiblePlanetaryNebulaColor(  Vec3f(conf->value("color/dso_possible_planetary_nebula_color", defaultNebulaColor).toString()));
×
351
        setProtoplanetaryNebulaColor(     Vec3f(conf->value("color/dso_protoplanetary_nebula_color", defaultNebulaColor).toString()));
×
352

353
        QString defaultClusterColor = conf->value("color/dso_cluster_color", "1.0,1.0,0.1").toString();
×
354
        setClusterColor(           Vec3f(defaultClusterColor));
×
355
        setOpenClusterColor(       Vec3f(conf->value("color/dso_open_cluster_color", defaultClusterColor).toString()));
×
356
        setGlobularClusterColor(   Vec3f(conf->value("color/dso_globular_cluster_color", defaultClusterColor).toString()));
×
357
        setStellarAssociationColor(Vec3f(conf->value("color/dso_stellar_association_color", defaultClusterColor).toString()));
×
358
        setStarCloudColor(         Vec3f(conf->value("color/dso_star_cloud_color", defaultClusterColor).toString()));
×
359

360
        QString defaultStellarColor = conf->value("color/dso_star_color", "1.0,0.7,0.2").toString();
×
361
        setStarColor(              Vec3f(defaultStellarColor));
×
362
        setSymbioticStarColor(     Vec3f(conf->value("color/dso_symbiotic_star_color", defaultStellarColor).toString()));
×
363
        setEmissionLineStarColor(  Vec3f(conf->value("color/dso_emission_star_color", defaultStellarColor).toString()));
×
364
        setEmissionObjectColor(    Vec3f(conf->value("color/dso_emission_object_color", defaultStellarColor).toString()));
×
365
        setYoungStellarObjectColor(Vec3f(conf->value("color/dso_young_stellar_object_color", defaultStellarColor).toString()));
×
366

367
        // Test that all nebula types have colors!
368
        QMetaEnum nType=QMetaEnum::fromType<Nebula::NebulaType>();
×
369
        for(int t=0; t<nType.keyCount(); t++)
×
370
        {
371
                if (!Nebula::hintColorMap.contains(static_cast<Nebula::NebulaType>(nType.value(t))))
×
372
                                qDebug() << "No color assigned to Nebula Type " << nType.key(t) << ". Please report as bug!";
×
373
        }
374

375
        // for DSO converter (for developers!)
376
        flagConverter = conf->value("devel/convert_dso_catalog", false).toBool();
×
377
        flagDecimalCoordinates = conf->value("devel/convert_dso_decimal_coord", true).toBool();
×
378

379
        setFlagUseTypeFilters(conf->value("astro/flag_use_type_filter", false).toBool());
×
380

381
        loadCatalogFilters();
×
382

383
        Nebula::TypeGroup typeFilters = Nebula::TypeGroup(Nebula::TypeNone);
×
384

385
        conf->beginGroup("dso_type_filters");
×
386
        if (conf->value("flag_show_galaxies", true).toBool())
×
387
                typeFilters        |= Nebula::TypeGalaxies;
×
388
        if (conf->value("flag_show_active_galaxies", true).toBool())
×
389
                typeFilters        |= Nebula::TypeActiveGalaxies;
×
390
        if (conf->value("flag_show_interacting_galaxies", true).toBool())
×
391
                typeFilters        |= Nebula::TypeInteractingGalaxies;
×
392
        if (conf->value("flag_show_open_clusters", true).toBool())
×
393
                typeFilters        |= Nebula::TypeOpenStarClusters;
×
394
        if (conf->value("flag_show_globular_clusters", true).toBool())
×
395
                typeFilters        |= Nebula::TypeGlobularStarClusters;
×
396
        if (conf->value("flag_show_bright_nebulae", true).toBool())
×
397
                typeFilters        |= Nebula::TypeBrightNebulae;
×
398
        if (conf->value("flag_show_dark_nebulae", true).toBool())
×
399
                typeFilters        |= Nebula::TypeDarkNebulae;
×
400
        if (conf->value("flag_show_planetary_nebulae", true).toBool())
×
401
                typeFilters        |= Nebula::TypePlanetaryNebulae;
×
402
        if (conf->value("flag_show_hydrogen_regions", true).toBool())
×
403
                typeFilters        |= Nebula::TypeHydrogenRegions;
×
404
        if (conf->value("flag_show_supernova_remnants", true).toBool())
×
405
                typeFilters        |= Nebula::TypeSupernovaRemnants;
×
406
        if (conf->value("flag_show_galaxy_clusters", true).toBool())
×
407
                typeFilters        |= Nebula::TypeGalaxyClusters;
×
408
        if (conf->value("flag_show_other", true).toBool())
×
409
                typeFilters        |= Nebula::TypeOther;
×
410
        conf->endGroup();
×
411

412
        setTypeFilters(typeFilters);
×
413

414
        // specify which sets get loaded at start time.
415
        const QString nebulaSetName=conf->value("astro/nebula_set", "default").toString();
×
416

417
        // Load the list of unwanted references.
418
        const QString allSetsUnwantedRefsRaw = conf->value("astro/nebula_exclude_references").toString(); // Later: read this from config.ini. Syntax: "setName:unrefA,unrefB,..."
×
419
        QString allUnwantedReferencesFromOneSetRaw;
×
420
        if (allSetsUnwantedRefsRaw.contains(';'))
×
421
        {
422
                // full specification: SetA:refA,refB;SetB:refC
423
#if (QT_VERSION>=QT_VERSION_CHECK(5,14,0))
424
                QStringList allSetsUnwantedRefs=allSetsUnwantedRefsRaw.split(';', Qt::SkipEmptyParts);
×
425
#else
426
                QStringList allSetsUnwantedRefs=allSetsUnwantedRefsRaw.split(';', QString::SkipEmptyParts);
427
#endif
428
                foreach (const QString &entry, allSetsUnwantedRefs)
×
429
                {
430
                        QStringList oneSetList=entry.split(':');
×
431
                        if (oneSetList.length()==2 && oneSetList.at(0)==nebulaSetName)
×
432
                        {
433
                                allUnwantedReferencesFromOneSetRaw=oneSetList.at(1); // Now this has the packed list without nebulaSet name
×
434
                                break;
×
435
                        }
436
                }
×
437
                if (allUnwantedReferencesFromOneSetRaw.isEmpty())
×
438
                {
439
                        qInfo() << "NebulaMgr: FYI: No references found to be excluded for set" << nebulaSetName;
×
440
                }
441
        }
×
442
        else if (allSetsUnwantedRefsRaw.contains(':'))
×
443
        {
444
                // Presumably only a packed list for default nebulaSet.
445
                allUnwantedReferencesFromOneSetRaw=allSetsUnwantedRefsRaw.section(':', 1, 1);
×
446
        }
447
        else
448
                allUnwantedReferencesFromOneSetRaw=allSetsUnwantedRefsRaw;
×
449
        // At this point allUnwantedReferencesFromOneSetRaw is assumed to be a comma-separated list for the current nebulaSet.
450
#if (QT_VERSION>=QT_VERSION_CHECK(5,14,0))
451
        unwantedReferences=allUnwantedReferencesFromOneSetRaw.split(',', Qt::SkipEmptyParts);
×
452
#else
453
        unwantedReferences=allUnwantedReferencesFromOneSetRaw.split(',', QString::SkipEmptyParts);
454
#endif
455
        if (!unwantedReferences.isEmpty()) // Do not show unwanted references when they does not defined
×
456
                qInfo() << "NebulaMgr: Unwanted References:" << unwantedReferences;
×
457

458
        loadNebulaSet(nebulaSetName);
×
459

460
        updateI18n();
×
461

462
        StelApp *app = &StelApp::getInstance();
×
463
        connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
×
464
        connect(&app->getSkyCultureMgr(), &StelSkyCultureMgr::currentSkyCultureChanged, this, &NebulaMgr::updateSkyCulture);
×
465
        GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
×
466

467
        addAction("actionShow_Nebulas", N_("Display Options"), N_("Deep-sky objects"), "flagHintDisplayed", "D", "N");
×
468
        addAction("actionSet_Nebula_TypeFilterUsage", N_("Display Options"), N_("Toggle DSO type filter"), "flagTypeFiltersUsage");
×
469
}
×
470

471
void NebulaMgr::selectAllCatalogs()
×
472
{
473
        setCatalogFilters(Nebula::CatAll);
×
474
}
×
475

476
void NebulaMgr::selectStandardCatalogs()
×
477
{
478
        Nebula::CatalogGroup catalogs = Nebula::CatNone;
×
479
        catalogs |= Nebula::CatNGC;
×
480
        catalogs |= Nebula::CatIC;
×
481
        catalogs |= Nebula::CatM;
×
482
        setCatalogFilters(catalogs);
×
483
}
×
484

485
void NebulaMgr::selectNoneCatalogs()
×
486
{
487
        setCatalogFilters(Nebula::CatNone);
×
488
}
×
489

490
void NebulaMgr::loadCatalogFilters()
×
491
{
492
        QSettings* conf = StelApp::getInstance().getSettings();
×
493
        Q_ASSERT(conf);
×
494

495
        Nebula::CatalogGroup catalogFilters = Nebula::CatalogGroup(Nebula::CatNone);
×
496

497
        conf->beginGroup("dso_catalog_filters");
×
498
        if (conf->value("flag_show_ngc", true).toBool())
×
499
                catalogFilters        |= Nebula::CatNGC;
×
500
        if (conf->value("flag_show_ic", true).toBool())
×
501
                catalogFilters        |= Nebula::CatIC;
×
502
        if (conf->value("flag_show_m", true).toBool())
×
503
                catalogFilters        |= Nebula::CatM;
×
504
        if (conf->value("flag_show_c", false).toBool())
×
505
                catalogFilters        |= Nebula::CatC;
×
506
        if (conf->value("flag_show_b", false).toBool())
×
507
                catalogFilters        |= Nebula::CatB;
×
508
        if (conf->value("flag_show_sh2", false).toBool())
×
509
                catalogFilters        |= Nebula::CatSh2;
×
510
        if (conf->value("flag_show_vdb", false).toBool())
×
511
                catalogFilters        |= Nebula::CatVdB;
×
512
        if (conf->value("flag_show_lbn", false).toBool())
×
513
                catalogFilters        |= Nebula::CatLBN;
×
514
        if (conf->value("flag_show_ldn", false).toBool())
×
515
                catalogFilters        |= Nebula::CatLDN;
×
516
        if (conf->value("flag_show_rcw", false).toBool())
×
517
                catalogFilters        |= Nebula::CatRCW;
×
518
        if (conf->value("flag_show_cr", false).toBool())
×
519
                catalogFilters        |= Nebula::CatCr;
×
520
        if (conf->value("flag_show_mel", false).toBool())
×
521
                catalogFilters        |= Nebula::CatMel;
×
522
        if (conf->value("flag_show_pgc", false).toBool())
×
523
                catalogFilters        |= Nebula::CatPGC;
×
524
        if (conf->value("flag_show_ced", false).toBool())
×
525
                catalogFilters        |= Nebula::CatCed;
×
526
        if (conf->value("flag_show_ugc", false).toBool())
×
527
                catalogFilters        |= Nebula::CatUGC;
×
528
        if (conf->value("flag_show_arp", false).toBool())
×
529
                catalogFilters        |= Nebula::CatArp;
×
530
        if (conf->value("flag_show_vv", false).toBool())
×
531
                catalogFilters        |= Nebula::CatVV;
×
532
        if (conf->value("flag_show_pk", false).toBool())
×
533
                catalogFilters        |= Nebula::CatPK;
×
534
        if (conf->value("flag_show_png", false).toBool())
×
535
                catalogFilters        |= Nebula::CatPNG;
×
536
        if (conf->value("flag_show_snrg", false).toBool())
×
537
                catalogFilters        |= Nebula::CatSNRG;
×
538
        if (conf->value("flag_show_aco", false).toBool())
×
539
                catalogFilters        |= Nebula::CatACO;
×
540
        if (conf->value("flag_show_hcg", false).toBool())
×
541
                catalogFilters        |= Nebula::CatHCG;
×
542
        if (conf->value("flag_show_eso", false).toBool())
×
543
                catalogFilters        |= Nebula::CatESO;
×
544
        if (conf->value("flag_show_vdbh", false).toBool())
×
545
                catalogFilters        |= Nebula::CatVdBH;
×
546
        if (conf->value("flag_show_dwb", false).toBool())
×
547
                catalogFilters        |= Nebula::CatDWB;
×
548
        if (conf->value("flag_show_tr", false).toBool())
×
549
                catalogFilters        |= Nebula::CatTr;
×
550
        if (conf->value("flag_show_st", false).toBool())
×
551
                catalogFilters        |= Nebula::CatSt;
×
552
        if (conf->value("flag_show_ru", false).toBool())
×
553
                catalogFilters        |= Nebula::CatRu;
×
554
        if (conf->value("flag_show_vdbha", false).toBool())
×
555
                catalogFilters        |= Nebula::CatVdBHa;
×
556
        if (conf->value("flag_show_other", true).toBool())
×
557
                catalogFilters        |= Nebula::CatOther;
×
558
        conf->endGroup();
×
559

560
        // NB: nebula set loaded inside setter of catalog filter
561
        setCatalogFilters(int(catalogFilters));
×
562
}
×
563

564
void NebulaMgr::storeCatalogFilters()
×
565
{
566
        QSettings* conf = StelApp::getInstance().getSettings();
×
567
        Q_ASSERT(conf);
×
568

569
        // view dialog / DSO tag settings
570
        const Nebula::CatalogGroup cflags = static_cast<Nebula::CatalogGroup>(getCatalogFilters());
×
571

572
        conf->beginGroup("dso_catalog_filters");
×
573
        conf->setValue("flag_show_ngc",                static_cast<bool>(cflags & Nebula::CatNGC));
×
574
        conf->setValue("flag_show_ic",                static_cast<bool>(cflags & Nebula::CatIC));
×
575
        conf->setValue("flag_show_m",                static_cast<bool>(cflags & Nebula::CatM));
×
576
        conf->setValue("flag_show_c",                static_cast<bool>(cflags & Nebula::CatC));
×
577
        conf->setValue("flag_show_b",                static_cast<bool>(cflags & Nebula::CatB));
×
578
        conf->setValue("flag_show_vdb",                static_cast<bool>(cflags & Nebula::CatVdB));
×
579
        conf->setValue("flag_show_sh2",                static_cast<bool>(cflags & Nebula::CatSh2));
×
580
        conf->setValue("flag_show_rcw",                static_cast<bool>(cflags & Nebula::CatRCW));
×
581
        conf->setValue("flag_show_lbn",                static_cast<bool>(cflags & Nebula::CatLBN));
×
582
        conf->setValue("flag_show_ldn",                static_cast<bool>(cflags & Nebula::CatLDN));
×
583
        conf->setValue("flag_show_cr",                static_cast<bool>(cflags & Nebula::CatCr));
×
584
        conf->setValue("flag_show_mel",                static_cast<bool>(cflags & Nebula::CatMel));
×
585
        conf->setValue("flag_show_ced",                static_cast<bool>(cflags & Nebula::CatCed));
×
586
        conf->setValue("flag_show_pgc",                static_cast<bool>(cflags & Nebula::CatPGC));
×
587
        conf->setValue("flag_show_ugc",                static_cast<bool>(cflags & Nebula::CatUGC));
×
588
        conf->setValue("flag_show_arp",                static_cast<bool>(cflags & Nebula::CatArp));
×
589
        conf->setValue("flag_show_vv",                static_cast<bool>(cflags & Nebula::CatVV));
×
590
        conf->setValue("flag_show_pk",                static_cast<bool>(cflags & Nebula::CatPK));
×
591
        conf->setValue("flag_show_png",                static_cast<bool>(cflags & Nebula::CatPNG));
×
592
        conf->setValue("flag_show_snrg",                static_cast<bool>(cflags & Nebula::CatSNRG));
×
593
        conf->setValue("flag_show_aco",                static_cast<bool>(cflags & Nebula::CatACO));
×
594
        conf->setValue("flag_show_hcg",                static_cast<bool>(cflags & Nebula::CatHCG));
×
595
        conf->setValue("flag_show_eso",                static_cast<bool>(cflags & Nebula::CatESO));
×
596
        conf->setValue("flag_show_vdbh",                static_cast<bool>(cflags & Nebula::CatVdBH));
×
597
        conf->setValue("flag_show_dwb",                static_cast<bool>(cflags & Nebula::CatDWB));
×
598
        conf->setValue("flag_show_tr",                static_cast<bool>(cflags & Nebula::CatTr));
×
599
        conf->setValue("flag_show_st",                static_cast<bool>(cflags & Nebula::CatSt));
×
600
        conf->setValue("flag_show_ru",                static_cast<bool>(cflags & Nebula::CatRu));
×
601
        conf->setValue("flag_show_vdbha",        static_cast<bool>(cflags & Nebula::CatVdBHa));
×
602
        conf->setValue("flag_show_other",                static_cast<bool>(cflags & Nebula::CatOther));
×
603
        conf->endGroup();
×
604
}
×
605

606
struct DrawNebulaFuncObject
607
{
608
        DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPainter* p, StelCore* aCore, bool acheckMaxMagHints)
×
609
                : maxMagHints(amaxMagHints)
×
610
                , maxMagLabels(amaxMagLabels)
×
611
                , sPainter(p)
×
612
                , core(aCore)
×
613
                , checkMaxMagHints(acheckMaxMagHints)
×
614
        {
615
                angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPerRadAtCenter()*M_180_PIf;
×
616
        }
×
617
        void operator()(StelRegionObject* obj)
×
618
        {
619
                if (checkMaxMagHints)
×
620
                        return;
×
621

622
                Nebula* n = static_cast<Nebula*>(obj);
×
623
                if (!n->objectInDisplayedCatalog())
×
UNCOV
624
                        return;
×
625

UNCOV
626
                if (n->flagShowOnlyNamedDSO && n->getEnglishName().isEmpty() && n->culturalNames.isEmpty())
×
627
                        return;
×
628

UNCOV
629
                if (!n->objectInAllowedSizeRangeLimits())
×
630
                        return;
×
631

UNCOV
632
                float mag=n->getVisibilityLevelByMagnitude();
×
633
                StelSkyDrawer *drawer = core->getSkyDrawer();
×
634
                // filter out DSOs which are too dim to be seen (e.g. for bino observers)
UNCOV
635
                if ((drawer->getFlagNebulaMagnitudeLimit()) && (mag > static_cast<float>(drawer->getCustomNebulaMagnitudeLimit())))
×
636
                        return;
×
637

UNCOV
638
                if (n->majorAxisSize>angularSizeLimit || n->majorAxisSize==0.f || mag <= maxMagHints)
×
639
                {
UNCOV
640
                        sPainter->getProjector()->project(n->getJ2000EquatorialPos(core),n->XY);
×
641
                        n->drawLabel(*sPainter, maxMagLabels);
×
642
                        n->drawHints(*sPainter, maxMagHints, core);
×
643
                        n->drawOutlines(*sPainter, maxMagHints);
×
644
                }
645
        }
646
        float maxMagHints;
647
        float maxMagLabels;
648
        StelPainter* sPainter;
649
        StelCore* core;
650
        float angularSizeLimit;
651
        bool checkMaxMagHints;
652
};
653

UNCOV
654
void NebulaMgr::setCatalogFilters(int cflags)
×
655
{
UNCOV
656
        if(cflags != static_cast<int>(Nebula::catalogFilters))
×
657
        {
UNCOV
658
                Nebula::catalogFilters = static_cast<Nebula::CatalogGroup>(cflags);
×
659
                emit catalogFiltersChanged(cflags);
×
660
        }
UNCOV
661
}
×
662

UNCOV
663
void NebulaMgr::setTypeFilters(int tflags)
×
664
{
UNCOV
665
        if(tflags != static_cast<int>(Nebula::typeFilters))
×
666
        {
UNCOV
667
                Nebula::typeFilters = static_cast<Nebula::TypeGroup>(tflags);
×
668
                emit typeFiltersChanged(tflags);
×
669
        }
UNCOV
670
}
×
671

UNCOV
672
void NebulaMgr::setFlagSurfaceBrightnessUsage(const bool usage)
×
673
{
UNCOV
674
        if (usage!=Nebula::surfaceBrightnessUsage)
×
675
        {
UNCOV
676
                Nebula::surfaceBrightnessUsage=usage;
×
677
                StelApp::immediateSave("astro/flag_surface_brightness_usage", Nebula::surfaceBrightnessUsage);
×
678
                emit flagSurfaceBrightnessUsageChanged(usage);
×
679
        }
UNCOV
680
}
×
681

UNCOV
682
bool NebulaMgr::getFlagSurfaceBrightnessUsage(void) const
×
683
{
UNCOV
684
        return Nebula::surfaceBrightnessUsage;
×
685
}
686

UNCOV
687
void NebulaMgr::setFlagSurfaceBrightnessArcsecUsage(const bool usage)
×
688
{
UNCOV
689
        if (usage!=Nebula::flagUseArcsecSurfaceBrightness)
×
690
        {
UNCOV
691
                Nebula::flagUseArcsecSurfaceBrightness=usage;
×
692
                StelApp::immediateSave("gui/flag_surface_brightness_arcsec", Nebula::flagUseArcsecSurfaceBrightness);
×
693
                emit flagSurfaceBrightnessArcsecUsageChanged(usage);
×
694
        }
UNCOV
695
}
×
696

UNCOV
697
bool NebulaMgr::getFlagSurfaceBrightnessArcsecUsage(void) const
×
698
{
UNCOV
699
        return Nebula::flagUseArcsecSurfaceBrightness;
×
700
}
701

UNCOV
702
void NebulaMgr::setFlagSurfaceBrightnessShortNotationUsage(const bool usage)
×
703
{
UNCOV
704
        if (usage!=Nebula::flagUseShortNotationSurfaceBrightness)
×
705
        {
UNCOV
706
                Nebula::flagUseShortNotationSurfaceBrightness=usage;
×
707
                StelApp::immediateSave("gui/flag_surface_brightness_short", Nebula::flagUseShortNotationSurfaceBrightness);
×
708
                emit flagSurfaceBrightnessShortNotationUsageChanged(usage);
×
709
        }
UNCOV
710
}
×
711

UNCOV
712
bool NebulaMgr::getFlagSurfaceBrightnessShortNotationUsage(void) const
×
713
{
UNCOV
714
        return Nebula::flagUseShortNotationSurfaceBrightness;
×
715
}
716

UNCOV
717
void NebulaMgr::setFlagSizeLimitsUsage(const bool usage)
×
718
{
UNCOV
719
        if (usage!=Nebula::flagUseSizeLimits)
×
720
        {
UNCOV
721
                Nebula::flagUseSizeLimits=usage;
×
722
                StelApp::immediateSave("astro/flag_size_limits_usage", Nebula::flagUseSizeLimits);
×
723
                emit flagSizeLimitsUsageChanged(usage);
×
724
        }
UNCOV
725
}
×
726

UNCOV
727
bool NebulaMgr::getFlagSizeLimitsUsage(void) const
×
728
{
UNCOV
729
        return Nebula::flagUseSizeLimits;
×
730
}
731

UNCOV
732
void NebulaMgr::setFlagUseTypeFilters(const bool b)
×
733
{
UNCOV
734
        if (Nebula::flagUseTypeFilters!=b)
×
735
        {
UNCOV
736
                Nebula::flagUseTypeFilters=b;
×
737
                StelApp::immediateSave("astro/flag_use_type_filter", Nebula::flagUseTypeFilters);
×
738
                emit flagUseTypeFiltersChanged(b);
×
739
        }
UNCOV
740
}
×
741

UNCOV
742
bool NebulaMgr::getFlagUseTypeFilters(void) const
×
743
{
UNCOV
744
        return Nebula::flagUseTypeFilters;
×
745
}
746

UNCOV
747
void NebulaMgr::setLabelsAmount(double a)
×
748
{
UNCOV
749
        if((a-labelsAmount) != 0.)
×
750
        {
UNCOV
751
                labelsAmount=a;
×
752
                StelApp::immediateSave("astro/nebula_labels_amount", labelsAmount);
×
753
                emit labelsAmountChanged(a);
×
754
        }
UNCOV
755
}
×
756

UNCOV
757
double NebulaMgr::getLabelsAmount(void) const
×
758
{
UNCOV
759
        return labelsAmount;
×
760
}
761

UNCOV
762
void NebulaMgr::setHintsAmount(double f)
×
763
{
UNCOV
764
        if((hintsAmount-f) != 0.)
×
765
        {
UNCOV
766
                hintsAmount = f;
×
767
                StelApp::immediateSave("astro/nebula_hints_amount", hintsAmount);
×
768
                emit hintsAmountChanged(f);
×
769
        }
UNCOV
770
}
×
771

UNCOV
772
double NebulaMgr::getHintsAmount(void) const
×
773
{
UNCOV
774
        return hintsAmount;
×
775
}
776

UNCOV
777
void NebulaMgr::setLabelsBrightness(double b)
×
778
{
UNCOV
779
        if (b!=labelsBrightness)
×
780
        {
UNCOV
781
                labelsBrightness = b;
×
782
                StelApp::immediateSave("astro/nebula_labels_brightness", labelsBrightness);
×
783
                emit labelsBrightnessChanged(b);
×
784
        }
UNCOV
785
}
×
786

UNCOV
787
double NebulaMgr::getLabelsBrightness(void) const
×
788
{
UNCOV
789
        return labelsBrightness;
×
790
}
791

UNCOV
792
void NebulaMgr::setHintsBrightness(double b)
×
793
{
UNCOV
794
        if (b!=hintsBrightness)
×
795
        {
UNCOV
796
                hintsBrightness = b;
×
797
                StelApp::immediateSave("astro/nebula_hints_brightness", hintsBrightness);
×
798
                emit hintsBrightnessChanged(b);
×
799
        }
UNCOV
800
}
×
801

UNCOV
802
double NebulaMgr::getHintsBrightness(void) const
×
803
{
UNCOV
804
        return hintsBrightness;
×
805
}
806

807

UNCOV
808
void NebulaMgr::setMinSizeLimit(double s)
×
809
{
UNCOV
810
        if((Nebula::minSizeLimit-s) != 0.)
×
811
        {
UNCOV
812
                Nebula::minSizeLimit = s;
×
813
                StelApp::immediateSave("astro/size_limit_min", Nebula::minSizeLimit);
×
814
                emit minSizeLimitChanged(s);
×
815
        }
UNCOV
816
}
×
817

UNCOV
818
double NebulaMgr::getMinSizeLimit() const
×
819
{
UNCOV
820
        return Nebula::minSizeLimit;
×
821
}
822

UNCOV
823
void NebulaMgr::setMaxSizeLimit(double s)
×
824
{
UNCOV
825
        if((Nebula::maxSizeLimit-s) != 0.)
×
826
        {
UNCOV
827
                Nebula::maxSizeLimit = s;
×
828
                StelApp::immediateSave("astro/size_limit_max", Nebula::maxSizeLimit);
×
829
                emit maxSizeLimitChanged(s);
×
830
        }
UNCOV
831
}
×
832

UNCOV
833
double NebulaMgr::getMaxSizeLimit() const
×
834
{
UNCOV
835
        return Nebula::maxSizeLimit;
×
836
}
837

UNCOV
838
float NebulaMgr::computeMaxMagHint(const StelSkyDrawer* skyDrawer) const
×
839
{
UNCOV
840
        return skyDrawer->getLimitMagnitude()*1.2f-2.f+static_cast<float>(hintsAmount *1.)-2.f;
×
841
}
842

843
// Draw all the Nebulae and call drawing the pointer if needed
UNCOV
844
void NebulaMgr::draw(StelCore* core)
×
845
{
UNCOV
846
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
847
        StelPainter sPainter(prj);
×
848
        sPainter.setFont(nebulaFont);
×
849

UNCOV
850
        if(hintsFader.getInterstate()>0.f)
×
851
        {
UNCOV
852
                static StelSkyDrawer* skyDrawer = core->getSkyDrawer();
×
853

UNCOV
854
                Nebula::hintsBrightness  = hintsFader.getInterstate()*flagShow.getInterstate()*static_cast<float>(hintsBrightness);
×
855
                Nebula::labelsBrightness = hintsFader.getInterstate()*flagShow.getInterstate()*static_cast<float>(labelsBrightness);
×
856

857
                // Use a 4 degree margin (esp. for wide outlines)
UNCOV
858
                const float margin = 4.f*M_PI_180f*prj->getPixelPerRadAtCenter();
×
859
                const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, margin);
×
860

861
                // Print all the nebulae of all the selected zones
UNCOV
862
                float maxMagHints  = computeMaxMagHint(skyDrawer);
×
863
                float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+static_cast<float>(labelsAmount*1.2)-2.f;
×
864
                DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core, hintsFader.getInterstate()<=0.f);
×
865
                nebGrid.processIntersectingPointInRegions(p.data(), func);
×
866
        }
×
867

UNCOV
868
        static StelObjectMgr *som=GETSTELMODULE(StelObjectMgr);
×
869
        if (som->getFlagSelectedObjectPointer())
×
870
                drawPointer(core, sPainter);
×
871
}
×
872

UNCOV
873
void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter)
×
874
{
UNCOV
875
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
876

UNCOV
877
        const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
878
        if (!newSelected.empty())
×
879
        {
UNCOV
880
                const StelObjectP obj = newSelected[0];
×
881
                Vec3d pos=obj->getJ2000EquatorialPos(core);
×
882

883
                // Compute 2D pos and return if outside screen
UNCOV
884
                if (!prj->projectInPlace(pos)) return;
×
885
                sPainter.setColor(0.4f,0.5f,0.8f);
×
886

UNCOV
887
                texPointer->bind();
×
888

UNCOV
889
                sPainter.setBlending(true);
×
890

891
                // Size on screen
UNCOV
892
                float screenRd = static_cast<float>(obj->getAngularRadius(core))*M_PI_180f*prj->getPixelPerRadAtCenter();
×
893
                if (screenRd>120.f) // avoid oversized marker
×
894
                        screenRd = 120.f;
×
895

UNCOV
896
                if (Nebula::drawHintProportional)
×
897
                        screenRd*=1.2f;
×
898
                screenRd+=20.f + 10.f*std::sin(3.f * static_cast<float>(StelApp::getInstance().getAnimationTime()));
×
899
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, 90);
×
900
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, 0);
×
901
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, -90);
×
902
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, -180);
×
903
        }
×
904
}
×
905

906
// Search by name
UNCOV
907
NebulaP NebulaMgr::searchForCommonName(const QString& name)
×
908
{
UNCOV
909
        QString uname = name.toUpper();
×
910

UNCOV
911
        if (const auto it = commonNameIndex.find(uname); it != commonNameIndex.end())
×
912
                return (it->nebula);
×
913

UNCOV
914
        return searchByDesignation(uname);
×
915
}
×
916

UNCOV
917
void NebulaMgr::loadNebulaSet(const QString& setName)
×
918
{
UNCOV
919
        QString srcCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.txt");
×
920
        QString dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog-" + StellariumDSOCatalogVersion + ".dat");
×
921
        if (dsoCatalogPath.isEmpty()) // Extended edition is not exist, let's try find standard edition
×
922
                dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.dat");
×
923
        QString dsoOutlinesPath        = StelFileMgr::findFile("nebulae/" + setName + "/outlines.dat");
×
924
        QString dsoDiscoveryPath = StelFileMgr::findFile("nebulae/" + setName + "/discovery.dat");
×
925
        QString dsoNamesPath = StelFileMgr::findFile("nebulae/" + setName + "/names.dat");
×
926

UNCOV
927
        dsoArray.clear();
×
928
        dsoIndex.clear();
×
929
        nebGrid.clear();
×
930

UNCOV
931
        if (flagConverter)
×
932
        {
UNCOV
933
                if (!srcCatalogPath.isEmpty())
×
934
                        convertDSOCatalog(srcCatalogPath, StelFileMgr::findFile("nebulae/" + setName + "/catalog.pack", StelFileMgr::New), flagDecimalCoordinates);
×
935
                else
UNCOV
936
                        qWarning() << "ERROR converting catalogue, because source data set does not exist for " << setName;
×
937
        }
938

UNCOV
939
        if (dsoCatalogPath.isEmpty())
×
940
        {
UNCOV
941
                qWarning() << "ERROR while loading deep-sky catalog data set " << setName;
×
942
                return;
×
943
        }
944

UNCOV
945
        loadDSOCatalog(dsoCatalogPath);
×
946

UNCOV
947
        if (dsoNamesPath.isEmpty())
×
948
        {
UNCOV
949
                qWarning().noquote() << "ERROR while loading deep-sky names data set" << setName;
×
950
        }
951
        else
952
        {
UNCOV
953
                loadDSONames(dsoNamesPath);
×
954
        }
955

UNCOV
956
        if (!dsoOutlinesPath.isEmpty())
×
957
                loadDSOOutlines(dsoOutlinesPath);
×
958

UNCOV
959
        if (!dsoDiscoveryPath.isEmpty())
×
960
                loadDSODiscoveryData(dsoDiscoveryPath);
×
961
}
×
962

963
// Look for a nebula by XYZ coords
UNCOV
964
NebulaP NebulaMgr::search(const Vec3d& apos)
×
965
{
UNCOV
966
        Vec3d pos(apos);
×
967
        pos.normalize();
×
968
        NebulaP plusProche;
×
969
        double anglePlusProche=0.0;
×
970
        for (const auto& n : std::as_const(dsoArray))
×
971
        {
UNCOV
972
                if (n->XYZ*pos>anglePlusProche)
×
973
                {
UNCOV
974
                        anglePlusProche=n->XYZ*pos;
×
975
                        plusProche=n;
×
976
                }
977
        }
UNCOV
978
        if (anglePlusProche>0.999) // object within ~2.5 degrees
×
979
        {
UNCOV
980
                return plusProche;
×
981
        }
UNCOV
982
        else return NebulaP();
×
983
}
×
984

985

UNCOV
986
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov, const StelCore*) const
×
987
{
UNCOV
988
        QList<StelObjectP> result;
×
989
        if (!getFlagShow())
×
990
                return result;
×
991

UNCOV
992
        Vec3d v(av);
×
993
        v.normalize();
×
994
        const double cosLimFov = cos(limitFov * M_PI/180.);
×
995
        Vec3d equPos;
×
996
        for (const auto& n : std::as_const(dsoArray))
×
997
        {
UNCOV
998
                equPos = n->XYZ;
×
999
                equPos.normalize();
×
1000
                if (equPos*v >= cosLimFov)
×
1001
                {
UNCOV
1002
                        result.push_back(qSharedPointerCast<StelObject>(n));
×
1003
                }
1004
        }
UNCOV
1005
        return result;
×
1006
}
×
1007

UNCOV
1008
NebulaP NebulaMgr::searchDSO(unsigned int DSO) const
×
1009
{
UNCOV
1010
        if (dsoIndex.contains(DSO))
×
1011
                return dsoIndex[DSO];
×
1012
        return NebulaP();
×
1013
}
1014

1015

UNCOV
1016
NebulaP NebulaMgr::searchM(unsigned int M) const
×
1017
{
UNCOV
1018
        for (const auto& n : dsoArray)
×
1019
                if (n->M_nb == M)
×
1020
                        return n;
×
1021
        return NebulaP();
×
1022
}
1023

UNCOV
1024
NebulaP NebulaMgr::searchNGC(unsigned int NGC) const
×
1025
{
UNCOV
1026
        for (const auto& n : dsoArray)
×
1027
                if (n->NGC_nb == NGC)
×
1028
                        return n;
×
1029
        return NebulaP();
×
1030
}
1031

UNCOV
1032
NebulaP NebulaMgr::searchIC(unsigned int IC) const
×
1033
{
UNCOV
1034
        for (const auto& n : dsoArray)
×
1035
                if (n->IC_nb == IC)
×
1036
                        return n;
×
1037
        return NebulaP();
×
1038
}
1039

UNCOV
1040
NebulaP NebulaMgr::searchC(unsigned int C) const
×
1041
{
UNCOV
1042
        for (const auto& n : dsoArray)
×
1043
                if (n->C_nb == C)
×
1044
                        return n;
×
1045
        return NebulaP();
×
1046
}
1047

UNCOV
1048
NebulaP NebulaMgr::searchB(unsigned int B) const
×
1049
{
UNCOV
1050
        for (const auto& n : dsoArray)
×
1051
                if (n->B_nb == B)
×
1052
                        return n;
×
1053
        return NebulaP();
×
1054
}
1055

UNCOV
1056
NebulaP NebulaMgr::searchSh2(unsigned int Sh2) const
×
1057
{
UNCOV
1058
        for (const auto& n : dsoArray)
×
1059
                if (n->Sh2_nb == Sh2)
×
1060
                        return n;
×
1061
        return NebulaP();
×
1062
}
1063

UNCOV
1064
NebulaP NebulaMgr::searchVdB(unsigned int VdB) const
×
1065
{
UNCOV
1066
        for (const auto& n : dsoArray)
×
1067
                if (n->VdB_nb == VdB)
×
1068
                        return n;
×
1069
        return NebulaP();
×
1070
}
1071

UNCOV
1072
NebulaP NebulaMgr::searchVdBHa(unsigned int VdBHa) const
×
1073
{
UNCOV
1074
        for (const auto& n : dsoArray)
×
1075
                if (n->VdBHa_nb == VdBHa)
×
1076
                        return n;
×
1077
        return NebulaP();
×
1078
}
1079

UNCOV
1080
NebulaP NebulaMgr::searchRCW(unsigned int RCW) const
×
1081
{
UNCOV
1082
        for (const auto& n : dsoArray)
×
1083
                if (n->RCW_nb == RCW)
×
1084
                        return n;
×
1085
        return NebulaP();
×
1086
}
1087

UNCOV
1088
NebulaP NebulaMgr::searchLDN(unsigned int LDN) const
×
1089
{
UNCOV
1090
        for (const auto& n : dsoArray)
×
1091
                if (n->LDN_nb == LDN)
×
1092
                        return n;
×
1093
        return NebulaP();
×
1094
}
1095

UNCOV
1096
NebulaP NebulaMgr::searchLBN(unsigned int LBN) const
×
1097
{
UNCOV
1098
        for (const auto& n : dsoArray)
×
1099
                if (n->LBN_nb == LBN)
×
1100
                        return n;
×
1101
        return NebulaP();
×
1102
}
1103

UNCOV
1104
NebulaP NebulaMgr::searchCr(unsigned int Cr) const
×
1105
{
UNCOV
1106
        for (const auto& n : dsoArray)
×
1107
                if (n->Cr_nb == Cr)
×
1108
                        return n;
×
1109
        return NebulaP();
×
1110
}
1111

UNCOV
1112
NebulaP NebulaMgr::searchMel(unsigned int Mel) const
×
1113
{
UNCOV
1114
        for (const auto& n : dsoArray)
×
1115
                if (n->Mel_nb == Mel)
×
1116
                        return n;
×
1117
        return NebulaP();
×
1118
}
1119

UNCOV
1120
NebulaP NebulaMgr::searchPGC(unsigned int PGC) const
×
1121
{
UNCOV
1122
        for (const auto& n : dsoArray)
×
1123
                if (n->PGC_nb == PGC)
×
1124
                        return n;
×
1125
        return NebulaP();
×
1126
}
1127

UNCOV
1128
NebulaP NebulaMgr::searchUGC(unsigned int UGC) const
×
1129
{
UNCOV
1130
        for (const auto& n : dsoArray)
×
1131
                if (n->UGC_nb == UGC)
×
1132
                        return n;
×
1133
        return NebulaP();
×
1134
}
1135

UNCOV
1136
NebulaP NebulaMgr::searchCed(QString Ced) const
×
1137
{
UNCOV
1138
        Ced = Ced.trimmed();
×
1139
        for (const auto& n : dsoArray)
×
1140
                if (n->Ced_nb.compare(Ced, Qt::CaseInsensitive) == 0)
×
1141
                        return n;
×
1142
        return NebulaP();
×
1143
}
1144

UNCOV
1145
NebulaP NebulaMgr::searchArp(unsigned int Arp) const
×
1146
{
UNCOV
1147
        for (const auto& n : dsoArray)
×
1148
                if (n->Arp_nb == Arp)
×
1149
                        return n;
×
1150
        return NebulaP();
×
1151
}
1152

UNCOV
1153
NebulaP NebulaMgr::searchVV(unsigned int VV) const
×
1154
{
UNCOV
1155
        for (const auto& n : dsoArray)
×
1156
                if (n->VV_nb == VV)
×
1157
                        return n;
×
1158
        return NebulaP();
×
1159
}
1160

UNCOV
1161
NebulaP NebulaMgr::searchPK(QString PK) const
×
1162
{
UNCOV
1163
        PK = PK.trimmed();
×
1164
        for (const auto& n : dsoArray)
×
1165
                if (n->PK_nb.compare(PK, Qt::CaseInsensitive) == 0)
×
1166
                        return n;
×
1167
        return NebulaP();
×
1168
}
1169

UNCOV
1170
NebulaP NebulaMgr::searchPNG(QString PNG) const
×
1171
{
UNCOV
1172
        PNG = PNG.trimmed();
×
1173
        for (const auto& n : dsoArray)
×
1174
                if (n->PNG_nb.compare(PNG, Qt::CaseInsensitive) == 0)
×
1175
                        return n;
×
1176
        return NebulaP();
×
1177
}
1178

UNCOV
1179
NebulaP NebulaMgr::searchSNRG(QString SNRG) const
×
1180
{
UNCOV
1181
        SNRG = SNRG.trimmed();
×
1182
        for (const auto& n : dsoArray)
×
1183
                if (n->SNRG_nb.compare(SNRG, Qt::CaseInsensitive) == 0)
×
1184
                        return n;
×
1185
        return NebulaP();
×
1186
}
1187

UNCOV
1188
NebulaP NebulaMgr::searchACO(QString ACO) const
×
1189
{
UNCOV
1190
        ACO = ACO.trimmed();
×
1191
        for (const auto& n : dsoArray)
×
1192
                if (n->ACO_nb.compare(ACO, Qt::CaseInsensitive) == 0)
×
1193
                        return n;
×
1194
        return NebulaP();
×
1195
}
1196

UNCOV
1197
NebulaP NebulaMgr::searchHCG(QString HCG) const
×
1198
{
UNCOV
1199
        HCG = HCG.trimmed();
×
1200
        for (const auto& n : dsoArray)
×
1201
                if (n->HCG_nb.compare(HCG, Qt::CaseInsensitive) == 0)
×
1202
                        return n;
×
1203
        return NebulaP();
×
1204
}
1205

UNCOV
1206
NebulaP NebulaMgr::searchESO(QString ESO) const
×
1207
{
UNCOV
1208
        ESO = ESO.trimmed();
×
1209
        for (const auto& n : dsoArray)
×
1210
                if (n->ESO_nb.compare(ESO, Qt::CaseInsensitive) == 0)
×
1211
                        return n;
×
1212
        return NebulaP();
×
1213
}
1214

UNCOV
1215
NebulaP NebulaMgr::searchVdBH(QString VdBH) const
×
1216
{
UNCOV
1217
        VdBH = VdBH.trimmed();
×
1218
        for (const auto& n : dsoArray)
×
1219
                if (n->VdBH_nb.compare(VdBH, Qt::CaseInsensitive) == 0)
×
1220
                        return n;
×
1221
        return NebulaP();
×
1222
}
1223

UNCOV
1224
NebulaP NebulaMgr::searchDWB(unsigned int DWB) const
×
1225
{
UNCOV
1226
        for (const auto& n : dsoArray)
×
1227
                if (n->DWB_nb == DWB)
×
1228
                        return n;
×
1229
        return NebulaP();
×
1230
}
1231

UNCOV
1232
NebulaP NebulaMgr::searchTr(unsigned int Tr) const
×
1233
{
UNCOV
1234
        for (const auto& n : dsoArray)
×
1235
                if (n->Tr_nb == Tr)
×
1236
                        return n;
×
1237
        return NebulaP();
×
1238
}
1239

UNCOV
1240
NebulaP NebulaMgr::searchSt(unsigned int St) const
×
1241
{
UNCOV
1242
        for (const auto& n : dsoArray)
×
1243
                if (n->St_nb == St)
×
1244
                        return n;
×
1245
        return NebulaP();
×
1246
}
1247

UNCOV
1248
NebulaP NebulaMgr::searchRu(unsigned int Ru) const
×
1249
{
UNCOV
1250
        for (const auto& n : dsoArray)
×
1251
                if (n->Ru_nb == Ru)
×
1252
                        return n;
×
1253
        return NebulaP();
×
1254
}
1255

UNCOV
1256
QString NebulaMgr::getLatestSelectedDSODesignation() const
×
1257
{
UNCOV
1258
        QString result = "";
×
1259

UNCOV
1260
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1261
        if (!selected.empty())
×
1262
        {
UNCOV
1263
                for (const auto& n : dsoArray)
×
1264
                        if (n==selected[0])
×
1265
                                result = n->getDSODesignation(); // Get designation for latest selected DSO
×
1266
        }
1267

UNCOV
1268
        return result;
×
1269
}
×
1270

UNCOV
1271
QString NebulaMgr::getLatestSelectedDSODesignationWIC() const
×
1272
{
UNCOV
1273
        QString result = "";
×
1274

UNCOV
1275
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1276
        if (!selected.empty())
×
1277
        {
UNCOV
1278
                for (const auto& n : dsoArray)
×
1279
                        if (n==selected[0])
×
1280
                                result = n->getDSODesignationWIC(); // Get designation for latest selected DSO
×
1281
        }
1282

UNCOV
1283
        return result;
×
1284
}
×
1285

UNCOV
1286
void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bool decimal=false)
×
1287
{
UNCOV
1288
        QFile dsoIn(in);
×
1289
        if (!dsoIn.open(QIODevice::ReadOnly | QIODevice::Text))
×
1290
                return;
×
1291

UNCOV
1292
        QFile dsoOut(out);
×
1293
        if (!dsoOut.open(QIODevice::WriteOnly))
×
1294
        {
UNCOV
1295
                qDebug() << "Error converting DSO data! Cannot open file" << QDir::toNativeSeparators(out);
×
1296
                return;
×
1297
        }
1298

UNCOV
1299
        int totalRecords=0;
×
1300
        QString record;
×
1301
        while (!dsoIn.atEnd())
×
1302
        {
UNCOV
1303
                dsoIn.readLine();
×
1304
                ++totalRecords;
×
1305
        }
1306

1307
        // rewind the file to the start
UNCOV
1308
        dsoIn.seek(0);
×
1309

UNCOV
1310
        QDataStream dsoOutStream(&dsoOut);
×
1311
        dsoOutStream.setVersion(QDataStream::Qt_5_2);
×
1312

UNCOV
1313
        int readOk = 0;                                // how many records were read without problems
×
1314
        while (!dsoIn.atEnd())
×
1315
        {
UNCOV
1316
                record = QString::fromUtf8(dsoIn.readLine());
×
1317

UNCOV
1318
                static const QRegularExpression version("ersion\\s+([\\d\\.]+)\\s+(\\w+)");
×
1319
                QRegularExpressionMatch versionMatch;
×
1320
                int vp = record.indexOf(version, 0, &versionMatch);
×
1321
                if (vp!=-1) // Version of catalog, a first line!
×
1322
                        dsoOutStream << versionMatch.captured(1).trimmed() << versionMatch.captured(2).trimmed();
×
1323

1324
                // skip comments
UNCOV
1325
                if (record.startsWith("//") || record.startsWith("#"))
×
1326
                {
UNCOV
1327
                        --totalRecords;
×
1328
                        continue;
×
1329
                }
1330

UNCOV
1331
                if (!record.isEmpty())
×
1332
                {
1333
                        #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
UNCOV
1334
                        QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1335
                        #else
1336
                        QStringList list=record.split("\t", QString::KeepEmptyParts);
1337
                        #endif
1338

UNCOV
1339
                        int id                 = list.at(0).toInt();    // ID (inner identification number)
×
1340
                        QString ra             = list.at(1).trimmed();
×
1341
                        QString dec            = list.at(2).trimmed();
×
1342
                        float bMag             = list.at(3).toFloat();  // B magnitude
×
1343
                        float vMag             = list.at(4).toFloat();  // V magnitude
×
1344
                        QString oType          = list.at(5).trimmed();  // Object type
×
1345
                        QString mType          = list.at(6).trimmed();  // Morphological type of object
×
1346
                        float majorAxisSize    = list.at(7).toFloat();  // major axis size (arcmin)
×
1347
                        float minorAxisSize    = list.at(8).toFloat();  // minor axis size (arcmin)
×
1348
                        int orientationAngle   = list.at(9).toInt();    // orientation angle (degrees)
×
1349
                        float z                = list.at(10).toFloat(); // redshift
×
1350
                        float zErr             = list.at(11).toFloat(); // error of redshift
×
1351
                        float plx              = list.at(12).toFloat(); // parallax (mas)
×
1352
                        float plxErr           = list.at(13).toFloat(); // error of parallax (mas)
×
1353
                        float dist             = list.at(14).toFloat(); // distance (Mpc for galaxies, kpc for other objects)
×
1354
                        float distErr          = list.at(15).toFloat(); // distance error (Mpc for galaxies, kpc for other objects)
×
1355
                        // -----------------------------------------------
1356
                        // cross-identification data
1357
                        // -----------------------------------------------
UNCOV
1358
                        int NGC                = list.at(16).toInt();   // NGC number
×
1359
                        int IC                 = list.at(17).toInt();   // IC number
×
1360
                        int M                  = list.at(18).toInt();   // M number
×
1361
                        int C                  = list.at(19).toInt();   // C number
×
1362
                        int B                  = list.at(20).toInt();   // B number
×
1363
                        int Sh2                = list.at(21).toInt();   // Sh2 number
×
1364
                        int VdB                = list.at(22).toInt();   // VdB number
×
1365
                        int RCW                = list.at(23).toInt();   // RCW number
×
1366
                        int LDN                = list.at(24).toInt();   // LDN number
×
1367
                        int LBN                = list.at(25).toInt();   // LBN number
×
1368
                        int Cr                 = list.at(26).toInt();   // Cr number (alias: Col)
×
1369
                        int Mel                = list.at(27).toInt();   // Mel number
×
1370
                        int PGC                = list.at(28).toInt();   // PGC number (subset)
×
1371
                        int UGC                = list.at(29).toInt();   // UGC number (subset)
×
1372
                        QString Ced            = list.at(30).trimmed();        // Ced number
×
1373
                        int Arp                = list.at(31).toInt();   // Arp number
×
1374
                        int VV                 = list.at(32).toInt();   // VV number
×
1375
                        QString PK             = list.at(33).trimmed(); // PK number
×
1376
                        QString PNG            = list.at(34).trimmed(); // PN G number
×
1377
                        QString SNRG           = list.at(35).trimmed(); // SNR G number
×
1378
                        QString ACO            = list.at(36).trimmed(); // ACO number
×
1379
                        QString HCG            = list.at(37).trimmed(); // HCG number
×
1380
                        QString ESO            = list.at(38).trimmed(); // ESO number
×
1381
                        QString VdBH           = list.at(39).trimmed(); // VdBH number
×
1382
                        int DWB                = list.at(40).toInt();   // DWB number
×
1383
                        int Tr                 = list.at(41).toInt();   // Tr number
×
1384
                        int St                 = list.at(42).toInt();   // St number
×
1385
                        int Ru                 = list.at(43).toInt();   // Ru number
×
1386
                        int VdBHa              = list.at(44).toInt();   // VdB-Ha number
×
1387

1388
                        float raRad, decRad;
UNCOV
1389
                        if (decimal)
×
1390
                        {
1391
                                // Convert from deg to rad
UNCOV
1392
                                raRad        = ra.toFloat() *M_PI_180f;
×
1393
                                decRad        = dec.toFloat()*M_PI_180f;
×
1394
                        }
1395
                        else
1396
                        {
UNCOV
1397
                                QStringList raLst;
×
1398
                                if (ra.contains(":"))
×
1399
                                        raLst        = ra.split(":");
×
1400
                                else
UNCOV
1401
                                        raLst        = ra.split(" ");
×
1402

UNCOV
1403
                                QStringList decLst;
×
1404
                                if (dec.contains(":"))
×
1405
                                        decLst = dec.split(":");
×
1406
                                else
UNCOV
1407
                                        decLst = dec.split(" ");
×
1408

UNCOV
1409
                                raRad        = raLst.at(0).toFloat() + raLst.at(1).toFloat()/60.f + raLst.at(2).toFloat()/3600.f;
×
1410
                                decRad        = qAbs(decLst.at(0).toFloat()) + decLst.at(1).toFloat()/60.f + decLst.at(2).toFloat()/3600.f;
×
1411
                                if (dec.startsWith("-")) decRad *= -1.f;
×
1412

UNCOV
1413
                                raRad  *= M_PIf/12.f;        // Convert from hours to rad
×
1414
                                decRad *= M_PIf/180.f;    // Convert from deg to rad
×
1415
                        }
×
1416

UNCOV
1417
                        majorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1418
                        minorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1419

1420
                        // Warning: Hyades and LMC has visual magnitude less than 1.0 (0.5^m and 0.9^m)
UNCOV
1421
                        if (bMag <= 0.f) bMag = 99.f;
×
1422
                        if (vMag <= 0.f) vMag = 99.f;
×
1423
                        static const QHash<QString, Nebula::NebulaType> oTypesHash({
UNCOV
1424
                                { "G"   , Nebula::NebGx  },
×
1425
                                { "GX"  , Nebula::NebGx  },
×
1426
                                { "GC"  , Nebula::NebGc  },
×
1427
                                { "OC"  , Nebula::NebOc  },
×
1428
                                { "NB"  , Nebula::NebN   },
×
1429
                                { "PN"  , Nebula::NebPn  },
×
1430
                                { "DN"  , Nebula::NebDn  },
×
1431
                                { "RN"  , Nebula::NebRn  },
×
1432
                                { "C+N" , Nebula::NebCn  },
×
1433
                                { "RNE" , Nebula::NebRn  },
×
1434
                                { "HII" , Nebula::NebHII },
×
1435
                                { "SNR" , Nebula::NebSNR },
×
1436
                                { "BN"  , Nebula::NebBn  },
×
1437
                                { "EN"  , Nebula::NebEn  },
×
1438
                                { "SA"  , Nebula::NebSA  },
×
1439
                                { "SC"  , Nebula::NebSC  },
×
1440
                                { "CL"  , Nebula::NebCl  },
×
1441
                                { "IG"  , Nebula::NebIGx },
×
1442
                                { "RG"  , Nebula::NebRGx },
×
1443
                                { "AGX" , Nebula::NebAGx },
×
1444
                                { "QSO" , Nebula::NebQSO },
×
1445
                                { "ISM" , Nebula::NebISM },
×
1446
                                { "EMO" , Nebula::NebEMO },
×
1447
                                { "GNE" , Nebula::NebHII },
×
1448
                                { "RAD" , Nebula::NebISM },
×
1449
                                { "LIN" , Nebula::NebAGx },// LINER-type active galaxies
×
1450
                                { "BLL" , Nebula::NebBLL },
×
1451
                                { "BLA" , Nebula::NebBLA },
×
1452
                                { "MOC" , Nebula::NebMolCld },
×
1453
                                { "YSO" , Nebula::NebYSO },
×
1454
                                { "Q?"  , Nebula::NebPossQSO },
×
1455
                                { "PN?" , Nebula::NebPossPN },
×
1456
                                { "*"   , Nebula::NebStar},
×
1457
                                { "SFR" , Nebula::NebMolCld },
×
1458
                                { "IR"  , Nebula::NebDn  },
×
1459
                                { "**"  , Nebula::NebStar},
×
1460
                                { "MUL" , Nebula::NebStar},
×
1461
                                { "PPN" , Nebula::NebPPN },
×
1462
                                { "GIG" , Nebula::NebIGx },
×
1463
                                { "OPC" , Nebula::NebOc  },
×
1464
                                { "MGR" , Nebula::NebSA  },
×
1465
                                { "IG2" , Nebula::NebIGx },
×
1466
                                { "IG3" , Nebula::NebIGx },
×
1467
                                { "SY*" , Nebula::NebSymbioticStar},
×
1468
                                { "PA*" , Nebula::NebPPN },
×
1469
                                { "CV*" , Nebula::NebStar},
×
1470
                                { "Y*?" , Nebula::NebYSO },
×
1471
                                { "CGB" , Nebula::NebISM },
×
1472
                                { "SNRG", Nebula::NebSNR },
×
1473
                                { "Y*O" , Nebula::NebYSO },
×
1474
                                { "SR*" , Nebula::NebStar},
×
1475
                                { "EM*" , Nebula::NebEmissionLineStar },
×
1476
                                { "AB*" , Nebula::NebStar },
×
1477
                                { "MI*" , Nebula::NebStar },
×
1478
                                { "MI?" , Nebula::NebStar },
×
1479
                                { "TT*" , Nebula::NebStar },
×
1480
                                { "WR*" , Nebula::NebStar },
×
1481
                                { "C*"  , Nebula::NebEmissionLineStar },
×
1482
                                { "WD*" , Nebula::NebStar },
×
1483
                                { "EL*" , Nebula::NebStar },
×
1484
                                { "NL*" , Nebula::NebStar },
×
1485
                                { "NO*" , Nebula::NebStar },
×
1486
                                { "HS*" , Nebula::NebStar },
×
1487
                                { "LP*" , Nebula::NebStar },
×
1488
                                { "OH*" , Nebula::NebStar },
×
1489
                                { "S?R" , Nebula::NebStar },
×
1490
                                { "IR*" , Nebula::NebStar },
×
1491
                                { "POC" , Nebula::NebMolCld },
×
1492
                                { "PNB" , Nebula::NebPn   },
×
1493
                                { "GXCL", Nebula::NebGxCl },
×
1494
                                { "AL*" , Nebula::NebStar },
×
1495
                                { "PR*" , Nebula::NebStar },
×
1496
                                { "RS*" , Nebula::NebStar },
×
1497
                                { "S*B" , Nebula::NebStar },
×
1498
                                { "SN?" , Nebula::NebSNC  },
×
1499
                                { "SR?" , Nebula::NebSNRC },
×
1500
                                { "DNE" , Nebula::NebDn   },
×
1501
                                { "RG*" , Nebula::NebStar },
×
1502
                                { "PSR" , Nebula::NebSNR  },
×
1503
                                { "HH"  , Nebula::NebISM  },
×
1504
                                { "V*"  , Nebula::NebStar },
×
1505
                                { "*IN" , Nebula::NebCn   },
×
1506
                                { "SN*" , Nebula::NebStar },
×
1507
                                { "PA?" , Nebula::NebPPN  },
×
1508
                                { "BUB" , Nebula::NebISM  },
×
1509
                                { "CLG" , Nebula::NebGxCl },
×
1510
                                { "POG" , Nebula::NebPartOfGx },
×
1511
                                { "CGG" , Nebula::NebGxCl },
×
1512
                                { "SCG" , Nebula::NebGxCl },
×
1513
                                { "REG" , Nebula::NebRegion },
×
1514
                                { "?" , Nebula::NebUnknown }
×
1515
                        });
×
1516

UNCOV
1517
                        Nebula::NebulaType nType=oTypesHash.value(oType.toUpper(), Nebula::NebUnknown);
×
1518
                        if (nType == Nebula::NebUnknown)
×
1519
                                qDebug() << "Record with ID" << id <<"has unknown type of object:" << oType;
×
1520

UNCOV
1521
                        ++readOk;
×
1522

UNCOV
1523
                        dsoOutStream << id << raRad << decRad << bMag << vMag << static_cast<unsigned int>(nType) << mType << majorAxisSize << minorAxisSize
×
1524
                                     << orientationAngle << z << zErr << plx << plxErr << dist  << distErr << NGC << IC << M << C
×
1525
                                     << B << Sh2 << VdB << RCW  << LDN << LBN << Cr << Mel << PGC << UGC << Ced << Arp << VV << PK
×
1526
                                     << PNG << SNRG << ACO << HCG << ESO << VdBH << DWB << Tr << St << Ru << VdBHa;
×
1527
                }
×
1528
        }
×
1529
        dsoIn.close();
×
1530
        dsoOut.flush();
×
1531
        dsoOut.close();
×
1532
        qInfo().noquote() << "Converted" << readOk << "/" << totalRecords << "DSO records";
×
1533
        qInfo().noquote() << "[...] Please use 'gzip -nc catalog.pack > catalog.dat' to pack the catalog.";
×
1534
}
×
1535

UNCOV
1536
bool NebulaMgr::loadDSOCatalog(const QString &filename)
×
1537
{
UNCOV
1538
        QFile in(filename);
×
1539
        if (!in.open(QIODevice::ReadOnly))
×
1540
                return false;
×
1541

UNCOV
1542
        qInfo().noquote() << "Loading DSO data ...";
×
1543

1544
        // Let's begin use gzipped data
UNCOV
1545
        QDataStream ins(StelUtils::uncompress(in.readAll()));
×
1546
        ins.setVersion(QDataStream::Qt_5_2);
×
1547

UNCOV
1548
        QString version = "", edition= "";
×
1549
        int totalRecords=0;
×
1550
        while (!ins.atEnd())
×
1551
        {
UNCOV
1552
                if (totalRecords==0) // Read the version of catalog
×
1553
                {
UNCOV
1554
                        ins >> version >> edition;
×
1555
                        if (version.isEmpty())
×
1556
                                version = "3.1"; // The first version of extended edition of the catalog
×
1557
                        if (edition.isEmpty())
×
1558
                                edition = "unknown";
×
1559
                        qInfo().noquote() << "[...]" << QString("Stellarium DSO Catalog, version %1 (%2 edition)").arg(version, edition);
×
1560
                        if (StelUtils::compareVersions(version, StellariumDSOCatalogVersion)!=0)
×
1561
                        {
UNCOV
1562
                                ++totalRecords;
×
1563
                                qWarning().noquote() << "Mismatch of DSO catalog version (" << version << ")! The expected version is" << StellariumDSOCatalogVersion;
×
1564
                                qWarning().noquote() << "See section 5.5 of the User Guide and install the right version of the catalog!";
×
1565
                                QMessageBox::warning(&StelMainView::getInstance(), q_("Attention!"),
×
1566
                                                     QString("%1. %2: %3 - %4: %5. %6").arg(q_("DSO catalog version mismatch"),
×
1567
                                                                                            q_("Found"),
×
1568
                                                                                            version,
UNCOV
1569
                                                                                            q_("Expected"),
×
1570
                                                                                            StellariumDSOCatalogVersion,
UNCOV
1571
                                                                                            q_("See Logfile for instructions.")), QMessageBox::Ok);
×
1572
                                break;
×
1573
                        }
1574
                }
1575
                else
1576
                {
1577
                        // Create a new Nebula record
UNCOV
1578
                        NebulaP e = NebulaP(new Nebula);
×
1579
                        e->readDSO(ins);
×
1580

UNCOV
1581
                        dsoArray.append(e);
×
1582
                        nebGrid.insert(qSharedPointerCast<StelRegionObject>(e));
×
1583
                        if (e->DSO_nb!=0)
×
1584
                                dsoIndex.insert(e->DSO_nb, e);
×
1585
                }
×
1586
                ++totalRecords;
×
1587
        }
UNCOV
1588
        in.close();
×
1589
        qInfo().noquote() << "Loaded" << --totalRecords << "DSO records";
×
1590
        return true;
×
1591
}
×
1592

UNCOV
1593
bool NebulaMgr::loadDSONames(const QString &filename)
×
1594
{
UNCOV
1595
        qInfo() << "Loading DSO name data ...";
×
1596

UNCOV
1597
        commonNameMap.clear();
×
1598

UNCOV
1599
        QFile dsoNameFile(filename);
×
1600
        if (!dsoNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1601
        {
UNCOV
1602
                qWarning().noquote() << "DSO name data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1603
                return false;
×
1604
        }
1605

1606
        // Read the names of the deep-sky objects
UNCOV
1607
        QString name, record, ref, cdes;
×
1608
        QStringList nodata;
×
1609
        nodata.clear();
×
1610
        int totalRecords=0;
×
1611
        int readOk=0;
×
1612
        unsigned int nb;
UNCOV
1613
        NebulaP e;
×
1614
        static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1615
        while (!dsoNameFile.atEnd())
×
1616
        {
UNCOV
1617
                record = QString::fromUtf8(dsoNameFile.readLine());
×
1618
                if (commentRx.match(record).hasMatch())
×
1619
                        continue;
×
1620

UNCOV
1621
                totalRecords++;
×
1622

1623
                // bytes 1 - 5, designator for catalogue (prefix)
UNCOV
1624
                ref  = record.left(5).trimmed();
×
1625
                // bytes 6 -20, identificator for object in the catalog
UNCOV
1626
                cdes = record.mid(5, 15).trimmed().toUpper();
×
1627
                // bytes 21-80, proper name of the object (translatable)
UNCOV
1628
                name = record.mid(21).trimmed(); // Let gets the name with trimmed whitespaces
×
1629

UNCOV
1630
                nb = cdes.toUInt();
×
1631

1632
                static const QStringList catalogs = {
1633
                        "IC",    "M",   "C",  "CR",  "MEL",   "B", "SH2", "VDB", "RCW",  "LDN",
1634
                        "LBN", "NGC", "PGC", "UGC",  "CED", "ARP",  "VV",  "PK", "PNG", "SNRG",
UNCOV
1635
                        "ACO", "HCG", "ESO", "VDBH", "DWB", "TR", "ST", "RU", "DBHA"};
×
1636

UNCOV
1637
                switch (catalogs.indexOf(ref.toUpper()))
×
1638
                {
UNCOV
1639
                        case 0:
×
1640
                                e = searchIC(nb);
×
1641
                                break;
×
1642
                        case 1:
×
1643
                                e = searchM(nb);
×
1644
                                break;
×
1645
                        case 2:
×
1646
                                e = searchC(nb);
×
1647
                                break;
×
1648
                        case 3:
×
1649
                                e = searchCr(nb);
×
1650
                                break;
×
1651
                        case 4:
×
1652
                                e = searchMel(nb);
×
1653
                                break;
×
1654
                        case 5:
×
1655
                                e = searchB(nb);
×
1656
                                break;
×
1657
                        case 6:
×
1658
                                e = searchSh2(nb);
×
1659
                                break;
×
1660
                        case 7:
×
1661
                                e = searchVdB(nb);
×
1662
                                break;
×
1663
                        case 8:
×
1664
                                e = searchRCW(nb);
×
1665
                                break;
×
1666
                        case 9:
×
1667
                                e = searchLDN(nb);
×
1668
                                break;
×
1669
                        case 10:
×
1670
                                e = searchLBN(nb);
×
1671
                                break;
×
1672
                        case 11:
×
1673
                                e = searchNGC(nb);
×
1674
                                break;
×
1675
                        case 12:
×
1676
                                e = searchPGC(nb);
×
1677
                                break;
×
1678
                        case 13:
×
1679
                                e = searchUGC(nb);
×
1680
                                break;
×
1681
                        case 14:
×
1682
                                e = searchCed(cdes);
×
1683
                                break;
×
1684
                        case 15:
×
1685
                                e = searchArp(nb);
×
1686
                                break;
×
1687
                        case 16:
×
1688
                                e = searchVV(nb);
×
1689
                                break;
×
1690
                        case 17:
×
1691
                                e = searchPK(cdes);
×
1692
                                break;
×
1693
                        case 18:
×
1694
                                e = searchPNG(cdes);
×
1695
                                break;
×
1696
                        case 19:
×
1697
                                e = searchSNRG(cdes);
×
1698
                                break;
×
1699
                        case 20:
×
1700
                                e = searchACO(cdes);
×
1701
                                break;
×
1702
                        case 21:
×
1703
                                e = searchHCG(cdes);
×
1704
                                break;
×
1705
                        case 22:
×
1706
                                e = searchESO(cdes);
×
1707
                                break;
×
1708
                        case 23:
×
1709
                                e = searchVdBH(cdes);
×
1710
                                break;
×
1711
                        case 24:
×
1712
                                e = searchDWB(nb);
×
1713
                                break;
×
1714
                        case 25:
×
1715
                                e = searchTr(nb);
×
1716
                                break;
×
1717
                        case 26:
×
1718
                                e = searchSt(nb);
×
1719
                                break;
×
1720
                        case 27:
×
1721
                                e = searchRu(nb);
×
1722
                                break;
×
1723
                        case 28:
×
1724
                                e = searchVdBHa(nb);
×
1725
                                break;
×
1726
                        default:
×
1727
                                e = searchDSO(nb);
×
1728
                                break;
×
1729
                }
1730

UNCOV
1731
                if (!e.isNull())
×
1732
                {
UNCOV
1733
                        static const QRegularExpression transRx("_[(]\"(.*)\"[)](\\s*#.*)?"); // optional comments after name.
×
1734
                        QRegularExpressionMatch transMatch=transRx.match(name);
×
1735
                        if (transMatch.hasMatch())
×
1736
                        {
UNCOV
1737
                                QString propName = transMatch.captured(1).trimmed();
×
1738
                                // TODO: Check if name is in the unwanted list and then don't include.
UNCOV
1739
                                QString refs = transMatch.captured(2).trimmed(); // a null string should not complain.
×
1740
                                QStringList refList;
×
1741
                                bool accept=refs.isNull(); // if we don't have a reference, we must accept it.
×
1742
                                if (!accept)
×
1743
                                {
UNCOV
1744
                                        refs=refs.right(refs.length()-1); // Chop off # sign. Use slice after switch to Qt6!
×
1745
                                        refList=refs.split(",");
×
1746
                                        // trim all sub-strings
UNCOV
1747
                                        for (int i=0; i<refList.length(); ++i)
×
1748
                                        {
UNCOV
1749
                                                refList[i]=refList.at(i).trimmed();
×
1750
                                        }
1751

1752
                                        //qDebug() << "References for object " << e->getDSODesignation() << "as" << propName << ":" << refList;
UNCOV
1753
                                        accept=refList.isEmpty(); // if we don't have a reference list, we must accept it.
×
1754
                                }
1755
                                // Now refList contains the DSO's reference strings.
1756
                                // Compare with the list of unwantedReferences and accept only "allowed" ones.
UNCOV
1757
                                if (!accept)
×
1758
                                {
1759
                                        //refList.removeAll()
1760

UNCOV
1761
                                        foreach(QString str, refList)
×
1762
                                        {
UNCOV
1763
                                                if (unwantedReferences.contains(str))
×
1764
                                                {
1765
                                                        //qDebug() << "Unwanted reference" << str << "detected for DSO name" << propName;
UNCOV
1766
                                                        refList.removeOne(str);
×
1767
                                                }
UNCOV
1768
                                        }
×
1769
                                        // Now it's inverse: if there are still references, we use the name.
UNCOV
1770
                                        accept=!refList.isEmpty();
×
1771
                                }
1772

UNCOV
1773
                                if (accept)
×
1774
                                {
UNCOV
1775
                                        commonNameMap[e].push_back(propName);
×
1776
                                        NebulaWithReferences nr = {e, refList };
×
1777
                                        commonNameIndex[propName.toUpper()] = nr;  // add with reduced refList.
×
1778
                                }
×
1779
                        }
×
1780
                        readOk++;
×
1781
                }
×
1782
                else
UNCOV
1783
                        nodata.append(QString("%1 %2").arg(ref.trimmed(), cdes.trimmed()));
×
1784
        }
UNCOV
1785
        dsoNameFile.close();
×
1786
        qInfo().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO name records successfully";
×
1787

UNCOV
1788
        int err = nodata.size();
×
1789
        if (err>0)
×
1790
                qWarning().noquote() << "No position data for" << err << "objects:" << nodata.join(", ");
×
1791

UNCOV
1792
        return true;
×
1793
}
×
1794

UNCOV
1795
bool NebulaMgr::loadDSODiscoveryData(const QString &filename)
×
1796
{
UNCOV
1797
        qInfo() << "Loading DSO discovery data ...";
×
1798
        QFile dsoDiscoveryFile(filename);
×
1799
        if (!dsoDiscoveryFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1800
        {
UNCOV
1801
                qWarning().noquote() << "DSO discovery data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1802
                return false;
×
1803
        }
1804

UNCOV
1805
        int readOk = 0;
×
1806
        int totalRecords = 0;
×
1807
        QString record, dso, dYear, dName;
×
1808
        NebulaP e;
×
1809
        while (!dsoDiscoveryFile.atEnd())
×
1810
        {
UNCOV
1811
                record = QString::fromUtf8(dsoDiscoveryFile.readLine());
×
1812
                if (record.startsWith("//") || record.startsWith("#") || record.isEmpty())
×
1813
                        continue;
×
1814

UNCOV
1815
                totalRecords++;
×
1816
                #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
UNCOV
1817
                QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1818
                #else
1819
                QStringList list=record.split("\t", QString::KeepEmptyParts);
1820
                #endif
1821

UNCOV
1822
                dso        = list.at(0).trimmed();
×
1823
                dYear        = list.at(1).trimmed();
×
1824
                dName        = list.at(2).trimmed();
×
1825

UNCOV
1826
                e = searchForCommonName(dso);
×
1827
                if (e.isNull()) // maybe this is inner number of DSO
×
1828
                        e = searchDSO(dso.toUInt());
×
1829

UNCOV
1830
                if (!e.isNull())
×
1831
                {
UNCOV
1832
                        e->setDiscoveryData(dName, dYear);
×
1833
                        readOk++;
×
1834
                }
UNCOV
1835
        }
×
1836
        dsoDiscoveryFile.close();
×
1837
        qInfo().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO discovery records successfully";
×
1838
        return true;
×
1839
}
×
1840

UNCOV
1841
bool NebulaMgr::loadDSOOutlines(const QString &filename)
×
1842
{
UNCOV
1843
        qInfo() << "Loading DSO outline data ...";
×
1844
        QFile dsoOutlineFile(filename);
×
1845
        if (!dsoOutlineFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1846
        {
UNCOV
1847
                qWarning().noquote() << "DSO outline data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1848
                return false;
×
1849
        }
1850

1851
        double RA, DE;
UNCOV
1852
        int i, readOk = 0;
×
1853
        Vec3d XYZ;
×
1854
        std::vector<Vec3d> *points = Q_NULLPTR;
×
1855
        typedef QPair<double, double> coords;
UNCOV
1856
        coords point, fpoint;
×
1857
        QVector<coords> outline;
×
1858
        QString record, command, dso;
×
1859
        NebulaP e;
×
1860
        // Read the outlines data of the DSO
UNCOV
1861
        static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1862
        while (!dsoOutlineFile.atEnd())
×
1863
        {
UNCOV
1864
                record = QString::fromUtf8(dsoOutlineFile.readLine());
×
1865
                if (commentRx.match(record).hasMatch())
×
1866
                        continue;
×
1867

1868
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
1869
                // bytes 1 - 8, RA
UNCOV
1870
                RA = record.first(8).toDouble();
×
1871
                // bytes 9 -18, DE
UNCOV
1872
                DE = record.sliced(9, 10).toDouble();
×
1873
#else
1874
                // bytes 1 - 8, RA
1875
                RA = record.leftRef(8).toDouble();
1876
                // bytes 9 -18, DE
1877
                DE = record.midRef(9, 10).toDouble();
1878
#endif
1879
                // bytes 19-25, command
UNCOV
1880
                command = record.mid(19, 7).trimmed();
×
1881
                // bytes 26, designation of DSO
UNCOV
1882
                dso = record.mid(26).trimmed();
×
1883

UNCOV
1884
                RA*=M_PI/12.;     // Convert from hours to rad
×
1885
                DE*=M_PI/180.;    // Convert from deg to rad
×
1886

UNCOV
1887
                if (command.contains("start", Qt::CaseInsensitive))
×
1888
                {
UNCOV
1889
                        outline.clear();
×
1890
                        e = searchForCommonName(dso);
×
1891
                        if (e.isNull()) // maybe this is inner number of DSO
×
1892
                                e = searchDSO(dso.toUInt());
×
1893

UNCOV
1894
                        point.first  = RA;
×
1895
                        point.second = DE;
×
1896
                        outline.append(point);
×
1897
                        fpoint = point;
×
1898
                }
1899

UNCOV
1900
                if (command.contains("vertex", Qt::CaseInsensitive))
×
1901
                {
UNCOV
1902
                        point.first  = RA;
×
1903
                        point.second = DE;
×
1904
                        outline.append(point);
×
1905
                }
1906

UNCOV
1907
                if (command.contains("end", Qt::CaseInsensitive))
×
1908
                {
UNCOV
1909
                        point.first  = RA;
×
1910
                        point.second = DE;
×
1911
                        outline.append(point);
×
1912
                        outline.append(fpoint);
×
1913

UNCOV
1914
                        if (!e.isNull())
×
1915
                        {
UNCOV
1916
                                points = new std::vector<Vec3d>;
×
1917
                                for (i = 0; i < outline.size(); i++)
×
1918
                                {
1919
                                        // Calc the Cartesian coord with RA and DE
UNCOV
1920
                                        point = outline.at(i);
×
1921
                                        StelUtils::spheToRect(point.first, point.second, XYZ);
×
1922
                                        points->push_back(XYZ);
×
1923
                                }
1924

UNCOV
1925
                                e->outlineSegments.push_back(points);
×
1926
                        }
UNCOV
1927
                        readOk++;
×
1928
                }
1929
        }
UNCOV
1930
        dsoOutlineFile.close();
×
1931
        qInfo().noquote() << "Loaded" << readOk << "DSO outline records successfully";
×
1932
        return true;
×
1933
}
×
1934

UNCOV
1935
void NebulaMgr::updateSkyCulture(const StelSkyCulture& skyCulture)
×
1936
{
UNCOV
1937
        for (const auto& n : std::as_const(dsoArray))
×
1938
                n->removeAllNames();
×
1939

1940

1941
        int numLoaded = 0;
×
UNCOV
1942
        if (!skyCulture.names.isEmpty())
×
1943
                numLoaded = loadCultureSpecificNames(skyCulture.names);
×
1944

UNCOV
1945
        if (numLoaded)
×
1946
        {
1947
                qInfo().noquote() << "Loaded" << numLoaded << "culture-specific DSO names";
×
1948
        }
1949

1950
        // Shall we still use common names if a skycultures has no own DSO names?
1951
        if (numLoaded==0 || skyCulture.fallbackToInternationalNames)
×
1952
        {
1953
                for (auto it = commonNameMap.cbegin(); it != commonNameMap.cend(); ++it)
×
UNCOV
1954
                        for (const auto& name : it.value())
×
UNCOV
1955
                                addEnglishOrAliasName(it.key(), name);
×
1956
        }
1957

1958
        updateI18n();
×
1959
}
×
1960

UNCOV
1961
int NebulaMgr::loadCultureSpecificNames(const QJsonObject& data)
×
1962
{
1963
        const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
×
1964

1965
        for (const auto& n : std::as_const(dsoArray))
×
UNCOV
1966
                n->culturalNames.clear();
×
1967

1968
        int loadedTotal = 0;
×
UNCOV
1969
        for (auto it = data.begin(); it != data.end(); ++it)
×
1970
        {
1971
                const auto key = it.key();
×
UNCOV
1972
                const auto specificNames = it->toArray();
×
1973

UNCOV
1974
                if (key.startsWith("HIP "))
×
1975
                {
1976
                        // skip since it's a star
1977
                }
UNCOV
1978
                else if (key.startsWith("NAME "))
×
1979
                {
1980
                        // FIXME: this is a kludge for the discrepancy between stellarium-skycultures database
1981
                        // and Stellarium's internal database. Maybe we should make use of the former and drop
1982
                        // the latter instead of doing this name translation.
UNCOV
1983
                        auto name = key.mid(5);
×
1984
                        static const QHash<QString, QString> renamer{
1985
                                {"Beehive Cluster" , "Beehive"           },
1986
                                {"Carina Nebula"   , "Eta Carinae Nebula"},
1987
                                {u8"ω Cen Cluster" , "Omega Centauri"    },
1988
                        };
×
1989
                        if (const auto it = renamer.find(name); it != renamer.end())
×
1990
                                name = it.value();
×
1991
                        loadCultureSpecificNameForNamedObject(it.value().toArray(), name);
×
1992
                }
×
UNCOV
1993
                else if (const NebulaP n = searchByDesignation(key))
×
1994
                {
UNCOV
1995
                        for (const auto& entry : specificNames)
×
1996
                        {
UNCOV
1997
                                QJsonObject json=entry.toObject();
×
1998
                                StelObject::CulturalName cName;
×
1999
                                cName.native          = json["native"].toString().trimmed();
×
2000
                                cName.pronounce       = json["pronounce"].toString().trimmed();
×
2001
                                cName.pronounceI18n   = trans.qtranslate(json["pronounce"].toString(), json["context"].toString());
×
2002
                                cName.transliteration = json["transliteration"].toString().trimmed();
×
2003
                                cName.translated      = json["english"].toString().trimmed();
×
UNCOV
2004
                                cName.translatedI18n  = trans.qtranslate(json["english"].toString(), json["context"].toString());
×
2005
                                cName.IPA             = json["IPA"].toString().trimmed();
×
2006

2007
                                n->addCulturalName(cName);
×
2008
                                ++loadedTotal;
×
UNCOV
2009
                        }
×
2010
                }
×
UNCOV
2011
        }
×
2012
        return loadedTotal;
×
2013
}
×
2014

2015
// Add names from data to the object locatable by commonname
2016
void NebulaMgr::loadCultureSpecificNameForNamedObject(const QJsonArray& data, const QString& commonName)
×
2017
{
UNCOV
2018
        const auto commonNameIndexIt = commonNameIndex.find(commonName.toUpper());
×
2019
        if (commonNameIndexIt == commonNameIndex.end())
×
2020
        {
2021
                // This may actually not even be a nebula, so we shouldn't emit any warning, just return
2022
                return;
×
2023
        }
2024

UNCOV
2025
        for (const auto& entry : data)
×
2026
        {
2027
                //// TODO: Filter away unwanted sources per-skyculture!
2028
                //// For now, just accept as before.
2029
                //setName(commonNameIndexIt.value().nebula, specificName);
2030

UNCOV
2031
                QJsonObject json=entry.toObject();
×
2032
                StelObject::CulturalName cName;
×
2033
                cName.native          = json["native"].toString().trimmed();
×
2034
                cName.pronounce       = json["pronounce"].toString().trimmed();
×
2035
                cName.pronounceI18n   = qc_(json["pronounce"].toString(), json["context"].toString()); // TODO: Clarify if context is available
×
UNCOV
2036
                cName.transliteration = json["transliteration"].toString().trimmed();
×
UNCOV
2037
                cName.translated      = json["english"].toString().trimmed();
×
UNCOV
2038
                cName.translatedI18n  = qc_(json["english"].toString(), json["context"].toString()); // TODO: Clarify if context is available
×
2039
                cName.IPA             = json["IPA"].toString().trimmed();
×
2040

2041
                commonNameIndexIt.value().nebula->addCulturalName(cName);
×
UNCOV
2042
        }
×
2043
}
2044

UNCOV
2045
void NebulaMgr::updateI18n()
×
2046
{
2047
        const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
×
2048
        for (const auto& n : std::as_const(dsoArray))
×
2049
                n->translateName(trans);
×
UNCOV
2050
}
×
2051

2052

2053
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
2054
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
×
2055
{
2056
        const QString nameI18nUpper = nameI18n.toUpper();
×
2057

2058
        // Search by common names
UNCOV
2059
        for (const auto& n : std::as_const(dsoArray))
×
2060
        {
UNCOV
2061
                if (n->nameI18.toUpper() == nameI18nUpper)
×
2062
                        return qSharedPointerCast<StelObject>(n);
×
2063
        }
2064

2065
        // Search by aliases of common names
UNCOV
2066
        for (const auto& n : std::as_const(dsoArray))
×
2067
        {
2068
                for (auto &nameI18Alias : n->nameI18Aliases)
×
2069
                {
2070
                        if (nameI18Alias.toUpper()==nameI18nUpper)
×
UNCOV
2071
                                return qSharedPointerCast<StelObject>(n);
×
2072
                }
2073
        }
2074

2075
        // Search by designation
2076
        NebulaP n = searchByDesignation(nameI18nUpper);
×
2077
        return qSharedPointerCast<StelObject>(n);
×
2078
}
×
2079

2080

2081
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
UNCOV
2082
StelObjectP NebulaMgr::searchByName(const QString& name) const
×
2083
{
UNCOV
2084
        const QString nameUpper = name.toUpper();
×
2085

2086
        // Search by common names
2087
        for (const auto& n : dsoArray)
×
2088
        {
UNCOV
2089
                if (n->englishName.toUpper()==nameUpper)
×
UNCOV
2090
                        return qSharedPointerCast<StelObject>(n);
×
2091
        }
2092

UNCOV
2093
        if (getFlagAdditionalNames())
×
2094
        {
2095
                // Search by aliases of common names
2096
                for (const auto& n : dsoArray)
×
2097
                {
UNCOV
2098
                        for (auto &englishAlias : n->englishAliases)
×
2099
                        {
2100
                                if (englishAlias.toUpper()==nameUpper)
×
UNCOV
2101
                                        return qSharedPointerCast<StelObject>(n);
×
2102
                        }
2103
                }
2104
        }
2105

2106
        // Search by designation
2107
        NebulaP n = searchByDesignation(nameUpper);
×
UNCOV
2108
        return qSharedPointerCast<StelObject>(n);
×
2109
}
×
2110

2111
//! Return the matching Nebula object's pointer if exists or Q_NULLPTR
2112
//! TODO Decide whether empty StelObjectP or Q_NULLPTR is the better return type and select the same for both.
2113
NebulaP NebulaMgr::searchByDesignation(const QString &designation) const
×
2114
{
2115
        NebulaP n;
×
2116
        QString designationUpper = designation.toUpper();
×
2117
        // If no match found, try search by catalog reference
2118
        static const QRegularExpression catNumRx("^(M|NGC|IC|C|B|VDB|RCW|LDN|LBN|CR|MEL|PGC|UGC|ARP|VV|DWB|TR|TRUMPLER|ST|STOCK|RU|RUPRECHT|VDB-HA)\\s*(\\d+)$");
×
2119
        QRegularExpressionMatch catNumMatch=catNumRx.match(designationUpper);
×
2120
        if (catNumMatch.hasMatch())
×
2121
        {
2122
                QString cat = catNumMatch.captured(1);
×
2123
                unsigned int num = catNumMatch.captured(2).toUInt();
×
2124
                if (cat == "M") n = searchM(num);
×
2125
                if (cat == "NGC") n = searchNGC(num);
×
2126
                if (cat == "IC") n = searchIC(num);
×
2127
                if (cat == "C") n = searchC(num);
×
2128
                if (cat == "B") n = searchB(num);
×
2129
                if (cat == "VDB-HA") n = searchVdBHa(num);
×
2130
                if (cat == "VDB") n = searchVdB(num);
×
2131
                if (cat == "RCW") n = searchRCW(num);
×
2132
                if (cat == "LDN") n = searchLDN(num);
×
2133
                if (cat == "LBN") n = searchLBN(num);
×
2134
                if (cat == "CR") n = searchCr(num);
×
UNCOV
2135
                if (cat == "MEL") n = searchMel(num);
×
2136
                if (cat == "PGC") n = searchPGC(num);
×
2137
                if (cat == "UGC") n = searchUGC(num);
×
UNCOV
2138
                if (cat == "ARP") n = searchArp(num);
×
2139
                if (cat == "VV") n = searchVV(num);
×
2140
                if (cat == "DWB") n = searchDWB(num);
×
2141
                if (cat == "TR" || cat == "TRUMPLER") n = searchTr(num);
×
2142
                if (cat == "ST" || cat == "STOCK") n = searchSt(num);
×
2143
                if (cat == "RU" || cat == "RUPRECHT") n = searchRu(num);
×
UNCOV
2144
        }
×
2145
        static const QRegularExpression dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$");
×
2146
        QRegularExpressionMatch dCatNumMatch=dCatNumRx.match(designationUpper);
×
UNCOV
2147
        if (dCatNumMatch.hasMatch())
×
2148
        {
2149
                QString dcat = dCatNumMatch.captured(1);
×
2150
                unsigned int dnum = dCatNumMatch.captured(2).toUInt();
×
2151

2152
                if (dcat == "SH") n = searchSh2(dnum);
×
2153
        }
×
2154
        static const QRegularExpression sCatNumRx("^(CED|PK|ACO|ABELL|HCG|ESO|VDBH)\\s*(.+)$");
×
2155
        QRegularExpressionMatch sCatNumMatch=sCatNumRx.match(designationUpper);
×
2156
        if (sCatNumMatch.hasMatch())
×
2157
        {
UNCOV
2158
                QString cat = sCatNumMatch.captured(1);
×
2159
                QString num = sCatNumMatch.captured(2).trimmed();
×
2160

UNCOV
2161
                if (cat == "CED") n = searchCed(num);
×
2162
                if (cat == "PK") n = searchPK(num);
×
2163
                if (cat == "ACO" || cat == "ABELL") n = searchACO(num);
×
2164
                if (cat == "HCG") n = searchHCG(num);
×
UNCOV
2165
                if (cat == "ESO") n = searchESO(num);
×
2166
                if (cat == "VDBH") n = searchVdBH(num);
×
2167
        }
×
UNCOV
2168
        static const QRegularExpression gCatNumRx("^(PN|SNR)\\s*G(.+)$");
×
UNCOV
2169
        QRegularExpressionMatch gCatNumMatch=gCatNumRx.match(designationUpper);
×
2170
        if (gCatNumMatch.hasMatch())
×
2171
        {
2172
                QString cat = gCatNumMatch.captured(1);
×
2173
                QString num = gCatNumMatch.captured(2).trimmed();
×
2174

UNCOV
2175
                if (cat == "PN") n = searchPNG(num);
×
2176
                if (cat == "SNR") n = searchSNRG(num);
×
UNCOV
2177
        }
×
2178

2179
        return n;
×
UNCOV
2180
}
×
2181

2182
//! Find and return the list of at most maxNbItem objects auto-completing the passed object name
2183
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
×
2184
{
2185
        QStringList result;
×
2186
        if (maxNbItem <= 0)
×
UNCOV
2187
                return result;
×
2188

2189
        QString objUpper = objPrefix.toUpper();
×
2190

2191
        // Search by Messier objects number (possible formats are "M31" or "M 31")
2192
        if (objUpper.size()>=1 && objUpper.at(0)=='M' && objUpper.left(3)!="MEL")
×
2193
        {
2194
                for (const auto& n : dsoArray)
×
2195
                {
UNCOV
2196
                        if (n->M_nb==0) continue;
×
UNCOV
2197
                        QString constw = QString("M%1").arg(n->M_nb);
×
UNCOV
2198
                        QString constws = constw.mid(0, objUpper.size());
×
2199
                        if (constws.toUpper()==objUpper)
×
2200
                        {
2201
                                result << constws;
×
UNCOV
2202
                                continue;        // Prevent adding both forms for name
×
2203
                        }
2204
                        constw = QString("M %1").arg(n->M_nb);
×
2205
                        constws = constw.mid(0, objUpper.size());
×
2206
                        if (constws.toUpper()==objUpper)
×
2207
                                result << constw;
×
UNCOV
2208
                }
×
2209
        }
2210

2211
        // Search by Melotte objects number (possible formats are "Mel31" or "Mel 31")
2212
        if (objUpper.size()>=1 && objUpper.left(3)=="MEL")
×
2213
        {
2214
                for (const auto& n : dsoArray)
×
2215
                {
2216
                        if (n->Mel_nb==0) continue;
×
2217
                        QString constw = QString("Mel%1").arg(n->Mel_nb);
×
UNCOV
2218
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2219
                        QString constws2 = QString("Melotte%1").arg(n->Mel_nb).mid(0, objUpper.size());
×
UNCOV
2220
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2221
                        {
UNCOV
2222
                                result << constws;
×
2223
                                continue;        // Prevent adding both forms for name
×
2224
                        }
2225
                        constw = QString("Mel %1").arg(n->Mel_nb);
×
2226
                        constws = constw.mid(0, objUpper.size());
×
2227
                        constws2 = QString("Melotte %1").arg(n->Mel_nb).mid(0, objUpper.size());
×
2228
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
UNCOV
2229
                                result << constw;
×
2230
                }
×
2231
        }
2232

2233
        // Search by IC objects number (possible formats are "IC466" or "IC 466")
2234
        if (objUpper.size()>=1 && objUpper.left(2)=="IC")
×
2235
        {
2236
                for (const auto& n : dsoArray)
×
2237
                {
UNCOV
2238
                        if (n->IC_nb==0) continue;
×
UNCOV
2239
                        QString constw = QString("IC%1").arg(n->IC_nb);
×
UNCOV
2240
                        QString constws = constw.mid(0, objUpper.size());
×
2241
                        if (constws.toUpper()==objUpper)
×
2242
                        {
2243
                                result << constws;
×
2244
                                continue;        // Prevent adding both forms for name
×
2245
                        }
2246
                        constw = QString("IC %1").arg(n->IC_nb);
×
UNCOV
2247
                        constws = constw.mid(0, objUpper.size());
×
2248
                        if (constws.toUpper()==objUpper)
×
2249
                                result << constw;
×
UNCOV
2250
                }
×
2251
        }
2252

2253
        // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
2254
        for (const auto& n : dsoArray)
×
2255
        {
UNCOV
2256
                if (n->NGC_nb==0) continue;
×
UNCOV
2257
                QString constw = QString("NGC%1").arg(n->NGC_nb);
×
2258
                QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2259
                if (constws.toUpper()==objUpper)
×
2260
                {
UNCOV
2261
                        result << constws;
×
2262
                        continue;
×
2263
                }
2264
                constw = QString("NGC %1").arg(n->NGC_nb);
×
2265
                constws = constw.mid(0, objUpper.size());
×
UNCOV
2266
                if (constws.toUpper()==objUpper)
×
2267
                        result << constw;
×
2268
        }
×
2269

2270
        // Search by PGC object numbers (possible formats are "PGC31" or "PGC 31")
2271
        if (objUpper.size()>=1 && objUpper.left(3)=="PGC")
×
2272
        {
2273
                for (const auto& n : dsoArray)
×
2274
                {
UNCOV
2275
                        if (n->PGC_nb==0) continue;
×
UNCOV
2276
                        QString constw = QString("PGC%1").arg(n->PGC_nb);
×
UNCOV
2277
                        QString constws = constw.mid(0, objUpper.size());
×
2278
                        if (constws.toUpper()==objUpper)
×
2279
                        {
2280
                                result << constws;        // Prevent adding both forms for name
×
UNCOV
2281
                                continue;
×
2282
                        }
2283
                        constw = QString("PGC %1").arg(n->PGC_nb);
×
2284
                        constws = constw.mid(0, objUpper.size());
×
2285
                        if (constws.toUpper()==objUpper)
×
UNCOV
2286
                                result << constw;
×
2287
                }
×
2288
        }
2289

2290
        // Search by UGC object numbers (possible formats are "UGC31" or "UGC 31")
2291
        if (objUpper.size()>=1 && objUpper.left(3)=="UGC")
×
2292
        {
2293
                for (const auto& n : dsoArray)
×
2294
                {
UNCOV
2295
                        if (n->UGC_nb==0) continue;
×
UNCOV
2296
                        QString constw = QString("UGC%1").arg(n->UGC_nb);
×
UNCOV
2297
                        QString constws = constw.mid(0, objUpper.size());
×
2298
                        if (constws.toUpper()==objUpper)
×
2299
                        {
2300
                                result << constws;
×
UNCOV
2301
                                continue;        // Prevent adding both forms for name
×
2302
                        }
2303
                        constw = QString("UGC %1").arg(n->UGC_nb);
×
2304
                        constws = constw.mid(0, objUpper.size());
×
2305
                        if (constws.toUpper()==objUpper)
×
UNCOV
2306
                                result << constw;
×
2307
                }
×
2308
        }
2309

2310
        // Search by Caldwell objects number (possible formats are "C31" or "C 31")
2311
        if (objUpper.size()>=1 && objUpper.at(0)=='C' && objUpper.left(2)!="CR" && objUpper.left(2)!="CE")
×
2312
        {
2313
                for (const auto& n : dsoArray)
×
2314
                {
UNCOV
2315
                        if (n->C_nb==0) continue;
×
UNCOV
2316
                        QString constw = QString("C%1").arg(n->C_nb);
×
UNCOV
2317
                        QString constws = constw.mid(0, objUpper.size());
×
2318
                        if (constws.toUpper()==objUpper)
×
2319
                        {
2320
                                result << constws;
×
UNCOV
2321
                                continue;        // Prevent adding both forms for name
×
2322
                        }
2323
                        constw = QString("C %1").arg(n->C_nb);
×
2324
                        constws = constw.mid(0, objUpper.size());
×
2325
                        if (constws.toUpper()==objUpper)
×
2326
                                result << constw;
×
UNCOV
2327
                }
×
2328
        }
2329

2330
        // Search by Collinder objects number (possible formats are "Cr31" or "Cr 31")
2331
        if (objUpper.size()>=1 && (objUpper.left(2)=="CR" || objUpper.left(9)=="COLLINDER"))
×
2332
        {
2333
                for (const auto& n : dsoArray)
×
2334
                {
2335
                        if (n->Cr_nb==0) continue;
×
2336
                        QString constw = QString("Cr%1").arg(n->Cr_nb);
×
UNCOV
2337
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2338
                        QString constws2 = QString("Collinder%1").arg(n->Cr_nb).mid(0, objUpper.size());
×
UNCOV
2339
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2340
                        {
UNCOV
2341
                                result << constws;
×
2342
                                continue;        // Prevent adding both forms for name
×
2343
                        }
2344
                        constw = QString("Cr %1").arg(n->Cr_nb);
×
2345
                        constws = constw.mid(0, objUpper.size());
×
2346
                        constws2 = QString("Collinder %1").arg(n->Cr_nb).mid(0, objUpper.size());
×
2347
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
UNCOV
2348
                                result << constw;
×
2349
                }
×
2350
        }
2351

2352
        // Search by Ced objects number (possible formats are "Ced31" or "Ced 31")
2353
        if (objUpper.size()>=1 && objUpper.left(3)=="CED")
×
2354
        {
2355
                for (const auto& n : dsoArray)
×
2356
                {
UNCOV
2357
                        if (n->Ced_nb.isEmpty()) continue;
×
UNCOV
2358
                        QString constw = QString("Ced%1").arg(n->Ced_nb);
×
UNCOV
2359
                        QString constws = constw.mid(0, objUpper.size());
×
2360
                        if (constws.toUpper()==objUpper)
×
2361
                        {
2362
                                result << constws;
×
UNCOV
2363
                                continue;        // Prevent adding both forms for name
×
2364
                        }
2365
                        constw = QString("Ced %1").arg(n->Ced_nb);
×
2366
                        constws = constw.mid(0, objUpper.size());
×
2367
                        if (constws.toUpper()==objUpper)
×
UNCOV
2368
                                result << constw;
×
2369
                }
×
2370
        }
2371

2372
        // Search by Barnard objects number (possible formats are "B31" or "B 31")
2373
        if (objUpper.size()>=1 && objUpper.at(0)=='B')
×
2374
        {
2375
                for (const auto& n : dsoArray)
×
2376
                {
UNCOV
2377
                        if (n->B_nb==0) continue;
×
UNCOV
2378
                        QString constw = QString("B%1").arg(n->B_nb);
×
UNCOV
2379
                        QString constws = constw.mid(0, objUpper.size());
×
2380
                        if (constws.toUpper()==objUpper)
×
2381
                        {
2382
                                result << constws;
×
UNCOV
2383
                                continue;        // Prevent adding both forms for name
×
2384
                        }
2385
                        constw = QString("B %1").arg(n->B_nb);
×
2386
                        constws = constw.mid(0, objUpper.size());
×
2387
                        if (constws.toUpper()==objUpper)
×
UNCOV
2388
                                result << constw;
×
2389
                }
×
2390
        }
2391

2392
        // Search by Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31")
2393
        if (objUpper.size()>=1 && objUpper.left(2)=="SH")
×
2394
        {
2395
                for (const auto& n : dsoArray)
×
2396
                {
UNCOV
2397
                        if (n->Sh2_nb==0) continue;
×
UNCOV
2398
                        QString constw = QString("SH2-%1").arg(n->Sh2_nb);
×
UNCOV
2399
                        QString constws = constw.mid(0, objUpper.size());
×
2400
                        if (constws.toUpper()==objUpper)
×
2401
                        {
2402
                                result << constws;
×
UNCOV
2403
                                continue;        // Prevent adding both forms for name
×
2404
                        }
2405
                        constw = QString("SH 2-%1").arg(n->Sh2_nb);
×
2406
                        constws = constw.mid(0, objUpper.size());
×
2407
                        if (constws.toUpper()==objUpper)
×
UNCOV
2408
                                result << constw;
×
2409
                }
×
2410
        }
2411

2412
        // Search by van den Bergh objects number (possible formats are "vdB31" or "vdB 31")
2413
        if (objUpper.size()>=1 && objUpper.left(3)=="VDB" && objUpper.left(6)!="VDB-HA" && objUpper.left(4)!="VDBH")
×
2414
        {
2415
                for (const auto& n : dsoArray)
×
2416
                {
UNCOV
2417
                        if (n->VdB_nb==0) continue;
×
UNCOV
2418
                        QString constw = QString("vdB%1").arg(n->VdB_nb);
×
UNCOV
2419
                        QString constws = constw.mid(0, objUpper.size());
×
2420
                        if (constws.toUpper()==objUpper)
×
2421
                        {
2422
                                result << constws;
×
UNCOV
2423
                                continue;        // Prevent adding both forms for name
×
2424
                        }
2425
                        constw = QString("vdB %1").arg(n->VdB_nb);
×
2426
                        constws = constw.mid(0, objUpper.size());
×
2427
                        if (constws.toUpper()==objUpper)
×
UNCOV
2428
                                result << constw;
×
2429
                }
×
2430
        }
2431

2432
        // Search by RCW objects number (possible formats are "RCW31" or "RCW 31")
2433
        if (objUpper.size()>=1 && objUpper.left(3)=="RCW")
×
2434
        {
2435
                for (const auto& n : dsoArray)
×
2436
                {
UNCOV
2437
                        if (n->RCW_nb==0) continue;
×
UNCOV
2438
                        QString constw = QString("RCW%1").arg(n->RCW_nb);
×
UNCOV
2439
                        QString constws = constw.mid(0, objUpper.size());
×
2440
                        if (constws.toUpper()==objUpper)
×
2441
                        {
2442
                                result << constws;
×
UNCOV
2443
                                continue;        // Prevent adding both forms for name
×
2444
                        }
2445
                        constw = QString("RCW %1").arg(n->RCW_nb);
×
2446
                        constws = constw.mid(0, objUpper.size());
×
2447
                        if (constws.toUpper()==objUpper)
×
UNCOV
2448
                                result << constw;
×
2449
                }
×
2450
        }
2451

2452
        // Search by LDN objects number (possible formats are "LDN31" or "LDN 31")
2453
        if (objUpper.size()>=1 && objUpper.left(3)=="LDN")
×
2454
        {
2455
                for (const auto& n : dsoArray)
×
2456
                {
UNCOV
2457
                        if (n->LDN_nb==0) continue;
×
UNCOV
2458
                        QString constw = QString("LDN%1").arg(n->LDN_nb);
×
UNCOV
2459
                        QString constws = constw.mid(0, objUpper.size());
×
2460
                        if (constws.toUpper()==objUpper)
×
2461
                        {
2462
                                result << constws;
×
UNCOV
2463
                                continue;        // Prevent adding both forms for name
×
2464
                        }
2465
                        constw = QString("LDN %1").arg(n->LDN_nb);
×
2466
                        constws = constw.mid(0, objUpper.size());
×
2467
                        if (constws.toUpper()==objUpper)
×
UNCOV
2468
                                result << constw;
×
2469
                }
×
2470
        }
2471

2472
        // Search by LBN objects number (possible formats are "LBN31" or "LBN 31")
2473
        if (objUpper.size()>=1 && objUpper.left(3)=="LBN")
×
2474
        {
2475
                for (const auto& n : dsoArray)
×
2476
                {
UNCOV
2477
                        if (n->LBN_nb==0) continue;
×
UNCOV
2478
                        QString constw = QString("LBN%1").arg(n->LBN_nb);
×
UNCOV
2479
                        QString constws = constw.mid(0, objUpper.size());
×
2480
                        if (constws.toUpper()==objUpper)
×
2481
                        {
2482
                                result << constws;
×
UNCOV
2483
                                continue;        // Prevent adding both forms for name
×
2484
                        }
2485
                        constw = QString("LBN %1").arg(n->LBN_nb);
×
2486
                        constws = constw.mid(0, objUpper.size());
×
2487
                        if (constws.toUpper()==objUpper)
×
UNCOV
2488
                                result << constw;
×
2489
                }
×
2490
        }
2491

2492
        // Search by Arp objects number
2493
        if (objUpper.size()>=1 && objUpper.left(3)=="ARP")
×
2494
        {
2495
                for (const auto& n : dsoArray)
×
2496
                {
UNCOV
2497
                        if (n->Arp_nb==0) continue;
×
UNCOV
2498
                        QString constw = QString("Arp%1").arg(n->Arp_nb);
×
UNCOV
2499
                        QString constws = constw.mid(0, objUpper.size());
×
2500
                        if (constws.toUpper()==objUpper)
×
2501
                        {
2502
                                result << constws;
×
UNCOV
2503
                                continue;        // Prevent adding both forms for name
×
2504
                        }
2505
                        constw = QString("Arp %1").arg(n->Arp_nb);
×
2506
                        constws = constw.mid(0, objUpper.size());
×
2507
                        if (constws.toUpper()==objUpper)
×
UNCOV
2508
                                result << constw;
×
2509
                }
×
2510
        }
2511

2512
        // Search by VV objects number
2513
        if (objUpper.size()>=1 && objUpper.left(2)=="VV")
×
2514
        {
2515
                for (const auto& n : dsoArray)
×
2516
                {
UNCOV
2517
                        if (n->VV_nb==0) continue;
×
UNCOV
2518
                        QString constw = QString("VV%1").arg(n->VV_nb);
×
UNCOV
2519
                        QString constws = constw.mid(0, objUpper.size());
×
2520
                        if (constws.toUpper()==objUpper)
×
2521
                        {
2522
                                result << constws;
×
UNCOV
2523
                                continue;        // Prevent adding both forms for name
×
2524
                        }
2525
                        constw = QString("VV %1").arg(n->VV_nb);
×
2526
                        constws = constw.mid(0, objUpper.size());
×
2527
                        if (constws.toUpper()==objUpper)
×
UNCOV
2528
                                result << constw;
×
2529
                }
×
2530
        }
2531

2532
        // Search by PK objects number
2533
        if (objUpper.size()>=1 && objUpper.left(2)=="PK")
×
2534
        {
2535
                for (const auto& n : dsoArray)
×
2536
                {
UNCOV
2537
                        if (n->PK_nb.isEmpty()) continue;
×
UNCOV
2538
                        QString constw = QString("PK%1").arg(n->PK_nb);
×
UNCOV
2539
                        QString constws = constw.mid(0, objUpper.size());
×
2540
                        if (constws.toUpper()==objUpper)
×
2541
                        {
2542
                                result << constws;
×
UNCOV
2543
                                continue;        // Prevent adding both forms for name
×
2544
                        }
2545
                        constw = QString("PK %1").arg(n->PK_nb);
×
2546
                        constws = constw.mid(0, objUpper.size());
×
2547
                        if (constws.toUpper()==objUpper)
×
UNCOV
2548
                                result << constw;
×
2549
                }
×
2550
        }
2551

2552
        // Search by PN G objects number
2553
        if (objUpper.size()>=1 && objUpper.left(2)=="PN")
×
2554
        {
2555
                for (const auto& n : dsoArray)
×
2556
                {
UNCOV
2557
                        if (n->PNG_nb.isEmpty()) continue;
×
UNCOV
2558
                        QString constw = QString("PNG%1").arg(n->PNG_nb);
×
UNCOV
2559
                        QString constws = constw.mid(0, objUpper.size());
×
2560
                        if (constws.toUpper()==objUpper)
×
2561
                        {
2562
                                result << constws;
×
UNCOV
2563
                                continue;        // Prevent adding both forms for name
×
2564
                        }
2565
                        constw = QString("PN G%1").arg(n->PNG_nb);
×
2566
                        constws = constw.mid(0, objUpper.size());
×
2567
                        if (constws.toUpper()==objUpper)
×
UNCOV
2568
                                result << constw;
×
2569
                }
×
2570
        }
2571

2572
        // Search by SNR G objects number
2573
        if (objUpper.size()>=1 && objUpper.left(3)=="SNR")
×
2574
        {
2575
                for (const auto& n : dsoArray)
×
2576
                {
UNCOV
2577
                        if (n->SNRG_nb.isEmpty()) continue;
×
UNCOV
2578
                        QString constw = QString("SNRG%1").arg(n->SNRG_nb);
×
UNCOV
2579
                        QString constws = constw.mid(0, objUpper.size());
×
2580
                        if (constws.toUpper()==objUpper)
×
2581
                        {
2582
                                result << constws;
×
UNCOV
2583
                                continue;        // Prevent adding both forms for name
×
2584
                        }
2585
                        constw = QString("SNR G%1").arg(n->SNRG_nb);
×
2586
                        constws = constw.mid(0, objUpper.size());
×
2587
                        if (constws.toUpper()==objUpper)
×
2588
                                result << constw;
×
UNCOV
2589
                }
×
2590
        }
2591

2592
        // Search by ACO (Abell) objects number
2593
        if (objUpper.size()>=1 && (objUpper.left(5)=="ABELL" || objUpper.left(3)=="ACO"))
×
2594
        {
2595
                for (const auto& n : dsoArray)
×
2596
                {
2597
                        if (n->ACO_nb.isEmpty()) continue;
×
2598
                        QString constw = QString("Abell%1").arg(n->ACO_nb);
×
UNCOV
2599
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2600
                        QString constws2 = QString("ACO%1").arg(n->ACO_nb).mid(0, objUpper.size());
×
UNCOV
2601
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2602
                        {
UNCOV
2603
                                result << constws;
×
2604
                                continue;        // Prevent adding both forms for name
×
2605
                        }
2606
                        constw = QString("Abell %1").arg(n->ACO_nb);
×
2607
                        constws = constw.mid(0, objUpper.size());
×
2608
                        constws2 = QString("ACO %1").arg(n->ACO_nb).mid(0, objUpper.size());
×
2609
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
UNCOV
2610
                                result << constw;
×
2611
                }
×
2612
        }
2613

2614
        // Search by HCG objects number
2615
        if (objUpper.size()>=1 && objUpper.left(3)=="HCG")
×
2616
        {
2617
                for (const auto& n : dsoArray)
×
2618
                {
UNCOV
2619
                        if (n->HCG_nb.isEmpty()) continue;
×
UNCOV
2620
                        QString constw = QString("HCG%1").arg(n->HCG_nb);
×
UNCOV
2621
                        QString constws = constw.mid(0, objUpper.size());
×
2622
                        if (constws.toUpper()==objUpper)
×
2623
                        {
2624
                                result << constws;
×
UNCOV
2625
                                continue;        // Prevent adding both forms for name
×
2626
                        }
2627
                        constw = QString("HCG %1").arg(n->HCG_nb);
×
2628
                        constws = constw.mid(0, objUpper.size());
×
2629
                        if (constws.toUpper()==objUpper)
×
UNCOV
2630
                                result << constw;
×
2631
                }
×
2632
        }
2633

2634
        // Search by ESO objects number
2635
        if (objUpper.size()>=1 && objUpper.left(3)=="ESO")
×
2636
        {
2637
                for (const auto& n : dsoArray)
×
2638
                {
UNCOV
2639
                        if (n->ESO_nb.isEmpty()) continue;
×
UNCOV
2640
                        QString constw = QString("ESO%1").arg(n->ESO_nb);
×
UNCOV
2641
                        QString constws = constw.mid(0, objUpper.size());
×
2642
                        if (constws.toUpper()==objUpper)
×
2643
                        {
2644
                                result << constws;
×
UNCOV
2645
                                continue;        // Prevent adding both forms for name
×
2646
                        }
2647
                        constw = QString("ESO %1").arg(n->ESO_nb);
×
2648
                        constws = constw.mid(0, objUpper.size());
×
2649
                        if (constws.toUpper()==objUpper)
×
UNCOV
2650
                                result << constw;
×
2651
                }
×
2652
        }
2653

2654
        // Search by VdBH objects number
2655
        if (objUpper.size()>=1 && objUpper.left(4)=="VDBH")
×
2656
        {
2657
                for (const auto& n : dsoArray)
×
2658
                {
UNCOV
2659
                        if (n->VdBH_nb.isEmpty()) continue;
×
UNCOV
2660
                        QString constw = QString("vdBH%1").arg(n->VdBH_nb);
×
UNCOV
2661
                        QString constws = constw.mid(0, objUpper.size());
×
2662
                        if (constws.toUpper()==objUpper)
×
2663
                        {
2664
                                result << constws;
×
UNCOV
2665
                                continue;        // Prevent adding both forms for name
×
2666
                        }
2667
                        constw = QString("vdBH %1").arg(n->VdBH_nb);
×
2668
                        constws = constw.mid(0, objUpper.size());
×
2669
                        if (constws.toUpper()==objUpper)
×
UNCOV
2670
                                result << constw;
×
2671
                }
×
2672
        }
2673

2674
        // Search by DWB objects number
2675
        if (objUpper.size()>=1 && objUpper.left(3)=="DWB")
×
2676
        {
2677
                for (const auto& n : dsoArray)
×
2678
                {
UNCOV
2679
                        if (n->DWB_nb==0) continue;
×
UNCOV
2680
                        QString constw = QString("DWB%1").arg(n->DWB_nb);
×
UNCOV
2681
                        QString constws = constw.mid(0, objUpper.size());
×
2682
                        if (constws.toUpper()==objUpper)
×
2683
                        {
2684
                                result << constws;
×
UNCOV
2685
                                continue;        // Prevent adding both forms for name
×
2686
                        }
2687
                        constw = QString("DWB %1").arg(n->DWB_nb);
×
2688
                        constws = constw.mid(0, objUpper.size());
×
2689
                        if (constws.toUpper()==objUpper)
×
2690
                                result << constw;
×
UNCOV
2691
                }
×
2692
        }
2693

2694
        // Search by Tr (Trumpler) objects number
2695
        if (objUpper.size()>=1 && (objUpper.left(8)=="TRUMPLER" || objUpper.left(2)=="TR"))
×
2696
        {
2697
                for (const auto& n : dsoArray)
×
2698
                {
2699
                        if (n->Tr_nb==0) continue;
×
2700
                        QString constw = QString("Tr%1").arg(n->Tr_nb);
×
UNCOV
2701
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2702
                        QString constws2 = QString("Trumpler%1").arg(n->Tr_nb).mid(0, objUpper.size());
×
UNCOV
2703
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2704
                        {
UNCOV
2705
                                result << constws;
×
2706
                                continue;        // Prevent adding both forms for name
×
2707
                        }
2708
                        constw = QString("Tr %1").arg(n->Tr_nb);
×
2709
                        constws = constw.mid(0, objUpper.size());
×
2710
                        constws2 = QString("Trumpler %1").arg(n->Tr_nb).mid(0, objUpper.size());
×
2711
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2712
                                result << constw;
×
UNCOV
2713
                }
×
2714
        }
2715

2716
        // Search by St (Stock) objects number
2717
        if (objUpper.size()>=1 && (objUpper.left(5)=="STOCK" || objUpper.left(2)=="ST"))
×
2718
        {
2719
                for (const auto& n : dsoArray)
×
2720
                {
2721
                        if (n->St_nb==0) continue;
×
2722
                        QString constw = QString("St%1").arg(n->St_nb);
×
UNCOV
2723
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2724
                        QString constws2 = QString("Stock%1").arg(n->St_nb).mid(0, objUpper.size());
×
UNCOV
2725
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2726
                        {
UNCOV
2727
                                result << constws;
×
2728
                                continue;        // Prevent adding both forms for name
×
2729
                        }
2730
                        constw = QString("St %1").arg(n->St_nb);
×
2731
                        constws = constw.mid(0, objUpper.size());
×
2732
                        constws2 = QString("Stock %1").arg(n->St_nb).mid(0, objUpper.size());
×
2733
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2734
                                result << constw;
×
UNCOV
2735
                }
×
2736
        }
2737

2738
        // Search by Ru (Ruprecht) objects number
2739
        if (objUpper.size()>=1 && (objUpper.left(8)=="RUPRECHT" || objUpper.left(2)=="RU"))
×
2740
        {
2741
                for (const auto& n : dsoArray)
×
2742
                {
2743
                        if (n->Ru_nb==0) continue;
×
2744
                        QString constw = QString("Ru%1").arg(n->Ru_nb);
×
UNCOV
2745
                        QString constws = constw.mid(0, objUpper.size());
×
UNCOV
2746
                        QString constws2 = QString("Ruprecht%1").arg(n->Ru_nb).mid(0, objUpper.size());
×
UNCOV
2747
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
2748
                        {
UNCOV
2749
                                result << constws;
×
2750
                                continue;        // Prevent adding both forms for name
×
2751
                        }
2752
                        constw = QString("Ru %1").arg(n->Ru_nb);
×
2753
                        constws = constw.mid(0, objUpper.size());
×
2754
                        constws2 = QString("Ruprecht %1").arg(n->Ru_nb).mid(0, objUpper.size());
×
2755
                        if (constws.toUpper()==objUpper || constws2.toUpper()==objUpper)
×
UNCOV
2756
                                result << constw;
×
2757
                }
×
2758
        }
2759

2760
        // Search by van den Bergh-Hagen Catalogue objects number
2761
        if (objUpper.size()>=1 && objUpper.left(6)=="VDB-HA")
×
2762
        {
2763
                for (const auto& n : dsoArray)
×
2764
                {
UNCOV
2765
                        if (n->VdBHa_nb==0) continue;
×
UNCOV
2766
                        QString constw = QString("vdB-Ha%1").arg(n->VdBHa_nb);
×
UNCOV
2767
                        QString constws = constw.mid(0, objUpper.size());
×
2768
                        if (constws.toUpper()==objUpper)
×
2769
                        {
UNCOV
2770
                                result << constws;
×
2771
                                continue;        // Prevent adding both forms for name
×
2772
                        }
2773
                        constw = QString("vdB-Ha %1").arg(n->VdBHa_nb);
×
UNCOV
2774
                        constws = constw.mid(0, objUpper.size());
×
2775
                        if (constws.toUpper()==objUpper)
×
2776
                                result << constw;
×
2777
                }
×
2778
        }
2779

2780
        // Search by common names and aliases
2781
        QStringList names;
×
2782
        for (const auto& n : dsoArray)
×
2783
        {
UNCOV
2784
                names.append(n->nameI18);
×
2785
                names.append(n->englishName);
×
2786
                if (getFlagAdditionalNames())
×
2787
                {
2788
                        names.append(n->nameI18Aliases);
×
2789
                        names.append(n->englishAliases);
×
2790
                }
2791
        }
2792

UNCOV
2793
        QString fullMatch = "";
×
2794
        for (const auto& name : std::as_const(names))
×
2795
        {
UNCOV
2796
                if (!matchObjectName(name, objPrefix, useStartOfWords))
×
2797
                        continue;
×
2798

2799
                if (name==objPrefix)
×
UNCOV
2800
                        fullMatch = name;
×
2801
                else
2802
                        result.append(name);
×
2803
        }
2804

2805
        result.sort();
×
UNCOV
2806
        if (!fullMatch.isEmpty())
×
2807
                result.prepend(fullMatch);
×
2808

2809
        if (result.size() > maxNbItem)
×
2810
                result.erase(result.begin() + maxNbItem, result.end());
×
2811

2812
        return result;
×
UNCOV
2813
}
×
2814

2815
QStringList NebulaMgr::listAllObjects(bool inEnglish) const
×
2816
{
2817
        QStringList result;
×
UNCOV
2818
        for (const auto& n : dsoArray)
×
2819
        {
2820
                if (!n->getEnglishName().isEmpty())
×
2821
                {
UNCOV
2822
                        if (inEnglish)
×
2823
                                result << n->getEnglishName();
×
2824
                        else
2825
                                result << n->getNameI18n();
×
2826
                }
2827
        }
UNCOV
2828
        return result;
×
2829
}
×
2830

UNCOV
2831
QStringList NebulaMgr::listAllObjectsByType(const QString &objType, bool inEnglish) const
×
2832
{
UNCOV
2833
        QStringList result;
×
2834
        int type = objType.toInt();
×
UNCOV
2835
        switch (type)
×
2836
        {
2837
                case 0: // Bright galaxies?
×
UNCOV
2838
                        for (const auto& n : dsoArray)
×
2839
                        {
UNCOV
2840
                                if (n->nType==type && qMin(n->vMag, n->bMag)<=10.f)
×
2841
                                {
2842
                                        if (!n->getEnglishName().isEmpty())
×
2843
                                        {
UNCOV
2844
                                                if (inEnglish)
×
2845
                                                        result << n->getEnglishName();
×
2846
                                                else
2847
                                                        result << n->getNameI18n();
×
2848
                                        }
2849
                                        else
2850
                                                result << n->getDSODesignationWIC();
×
2851
                                }
2852
                        }
2853
                        break;
×
2854
                case 100: // Messier Catalogue?
×
2855
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2856
                                result << QString("M%1").arg(n->M_nb);
×
2857
                        break;
×
2858
                case 101: // Caldwell Catalogue?
×
2859
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2860
                                result << QString("C%1").arg(n->C_nb);
×
2861
                        break;
×
2862
                case 102: // Barnard Catalogue?
×
2863
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2864
                                result << QString("B %1").arg(n->B_nb);
×
2865
                        break;
×
2866
                case 103: // Sharpless Catalogue?
×
2867
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2868
                                result << QString("SH 2-%1").arg(n->Sh2_nb);
×
2869
                        break;
×
2870
                case 104: // van den Bergh Catalogue
×
2871
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2872
                                result << QString("vdB %1").arg(n->VdB_nb);
×
2873
                        break;
×
2874
                case 105: // RCW Catalogue
×
2875
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2876
                                result << QString("RCW %1").arg(n->RCW_nb);
×
2877
                        break;
×
2878
                case 106: // Collinder Catalogue
×
2879
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2880
                                result << QString("Cr %1").arg(n->Cr_nb);
×
2881
                        break;
×
2882
                case 107: // Melotte Catalogue
×
2883
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2884
                                result << QString("Mel %1").arg(n->Mel_nb);
×
2885
                        break;
×
2886
                case 108: // New General Catalogue
×
2887
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2888
                                result << QString("NGC %1").arg(n->NGC_nb);
×
2889
                        break;
×
2890
                case 109: // Index Catalogue
×
2891
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2892
                                result << QString("IC %1").arg(n->IC_nb);
×
2893
                        break;
×
2894
                case 110: // Lynds' Catalogue of Bright Nebulae
×
2895
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2896
                                result << QString("LBN %1").arg(n->LBN_nb);
×
2897
                        break;
×
2898
                case 111: // Lynds' Catalogue of Dark Nebulae
×
2899
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2900
                                result << QString("LDN %1").arg(n->LDN_nb);
×
2901
                        break;
×
2902
                case 114: // Cederblad Catalog
×
2903
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2904
                                result << QString("Ced %1").arg(n->Ced_nb);
×
2905
                        break;
×
2906
                case 115: // Atlas of Peculiar Galaxies (Arp)
×
2907
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2908
                                result << QString("Arp %1").arg(n->Arp_nb);
×
2909
                        break;
×
2910
                case 116: // The Catalogue of Interacting Galaxies by Vorontsov-Velyaminov (VV)
×
2911
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2912
                                result << QString("VV %1").arg(n->VV_nb);
×
2913
                        break;
×
2914
                case 117: // Catalogue of Galactic Planetary Nebulae (PK)
×
2915
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2916
                                result << QString("PK %1").arg(n->PK_nb);
×
2917
                        break;
×
2918
                case 118: // Strasbourg-ESO Catalogue of Galactic Planetary Nebulae by Acker et. al. (PN G)
×
2919
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2920
                                result << QString("PN G%1").arg(n->PNG_nb);
×
2921
                        break;
×
2922
                case 119: // A catalogue of Galactic supernova remnants by Green (SNR G)
×
2923
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2924
                                result << QString("SNR G%1").arg(n->SNRG_nb);
×
2925
                        break;
×
2926
                case 120: // A Catalog of Rich Clusters of Galaxies by Abell et. al. (Abell (ACO))
×
2927
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2928
                                result << QString("Abell %1").arg(n->ACO_nb);
×
2929
                        break;
×
2930
                case 121: // Hickson Compact Group by Hickson et. al. (HCG)
×
2931
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2932
                                result << QString("HCG %1").arg(n->HCG_nb);
×
2933
                        break;
×
2934
                case 122: // ESO/Uppsala Survey of the ESO(B) Atlas (ESO)
×
2935
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2936
                                result << QString("ESO %1").arg(n->ESO_nb);
×
2937
                        break;
×
2938
                case 123: // Catalogue of southern stars embedded in nebulosity (vdBH)
×
2939
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2940
                                result << QString("vdBH %1").arg(n->VdBH_nb);
×
2941
                        break;
×
2942
                case 124: // Catalogue and distances of optically visible H II regions (DWB)
×
2943
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2944
                                result << QString("DWB %1").arg(n->DWB_nb);
×
2945
                        break;
×
2946
                case 125: // Trumpler Catalogue (Tr)
×
2947
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2948
                                result << QString("Tr %1").arg(n->Tr_nb);
×
2949
                        break;
×
2950
                case 126: // Stock Catalogue (St)
×
2951
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2952
                                result << QString("St %1").arg(n->St_nb);
×
2953
                        break;
×
2954
                case 127: // Ruprecht Catalogue (Ru)
×
UNCOV
2955
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2956
                                result << QString("Ru %1").arg(n->Ru_nb);
×
2957
                        break;
×
2958
                case 128: // van den Bergh-Hagen Catalogue (VdB-Ha)
×
UNCOV
2959
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2960
                                result << QString("vdB-Ha %1").arg(n->VdBHa_nb);
×
UNCOV
2961
                        break;
×
2962
                case 150: // Dwarf galaxies [see NebulaList.hpp]
×
2963
                {
2964
                        for (unsigned int i = 0; i < sizeof(DWARF_GALAXIES) / sizeof(DWARF_GALAXIES[0]); i++)
×
UNCOV
2965
                                result << QString("PGC %1").arg(DWARF_GALAXIES[i]);
×
2966
                        break;
×
2967
                }
2968
                case 151: // Herschel 400 Catalogue [see NebulaList.hpp]
×
2969
                {
2970
                        for (unsigned int i = 0; i < sizeof(H400_LIST) / sizeof(H400_LIST[0]); i++)
×
2971
                                result << QString("NGC %1").arg(H400_LIST[i]);
×
UNCOV
2972
                        break;
×
2973
                }
UNCOV
2974
                case 152: // Jack Bennett's deep sky catalogue [see NebulaList.hpp]
×
2975
                {
2976
                        for (unsigned int i = 0; i < sizeof(BENNETT_LIST) / sizeof(BENNETT_LIST[0]); i++)
×
2977
                                result << QString("NGC %1").arg(BENNETT_LIST[i]);
×
UNCOV
2978
                        result << "Mel 105" << "IC 1459";
×
2979
                        break;
×
2980
                }
2981
                case 153: // James Dunlop's deep sky catalogue [see NebulaList.hpp]
×
2982
                {
2983
                        for (unsigned int i = 0; i < sizeof(DUNLOP_LIST) / sizeof(DUNLOP_LIST[0]); i++)
×
UNCOV
2984
                                result << QString("NGC %1").arg(DUNLOP_LIST[i]);
×
2985
                        break;
×
2986
                }
2987
                default:
×
2988
                {
UNCOV
2989
                        for (const auto& n : dsoArray)
×
2990
                        {
UNCOV
2991
                                if (n->nType==type)
×
2992
                                {
2993
                                        if (!n->getEnglishName().isEmpty())
×
2994
                                        {
UNCOV
2995
                                                if (inEnglish)
×
2996
                                                        result << n->getEnglishName();
×
2997
                                                else
UNCOV
2998
                                                        result << n->getNameI18n();
×
2999
                                        }
3000
                                        else
3001
                                                result << n->getDSODesignationWIC();
×
3002
                                }
3003
                        }
3004
                        break;
×
3005
                }
3006
        }
3007

3008
        result.removeDuplicates();
×
UNCOV
3009
        return result;
×
3010
}
×
3011

UNCOV
3012
const QList<NebulaP> NebulaMgr::getDeepSkyObjectsByType(const QString &objType) const
×
3013
{
3014
        QList<NebulaP> dso;
×
UNCOV
3015
        int type = objType.toInt();
×
3016
        switch (type)
×
3017
        {
3018
                case 100: // Messier Catalogue?
×
UNCOV
3019
                        for (const auto& n : dsoArray)
×
3020
                        {
3021
                                if (n->M_nb>0)
×
UNCOV
3022
                                        dso.append(n);
×
3023
                        }
3024
                        break;
×
3025
                case 101: // Caldwell Catalogue?
×
UNCOV
3026
                        for (const auto& n : dsoArray)
×
3027
                        {
3028
                                if (n->C_nb>0)
×
UNCOV
3029
                                        dso.append(n);
×
3030
                        }
3031
                        break;
×
3032
                case 102: // Barnard Catalogue?
×
UNCOV
3033
                        for (const auto& n : dsoArray)
×
3034
                        {
3035
                                if (n->B_nb>0)
×
UNCOV
3036
                                        dso.append(n);
×
3037
                        }
3038
                        break;
×
3039
                case 103: // Sharpless Catalogue?
×
UNCOV
3040
                        for (const auto& n : dsoArray)
×
3041
                        {
3042
                                if (n->Sh2_nb>0)
×
UNCOV
3043
                                        dso.append(n);
×
3044
                        }
3045
                        break;
×
3046
                case 104: // van den Bergh Catalogue
×
UNCOV
3047
                        for (const auto& n : dsoArray)
×
3048
                        {
3049
                                if (n->VdB_nb>0)
×
UNCOV
3050
                                        dso.append(n);
×
3051
                        }
3052
                        break;
×
3053
                case 105: // RCW Catalogue
×
UNCOV
3054
                        for (const auto& n : dsoArray)
×
3055
                        {
3056
                                if (n->RCW_nb>0)
×
UNCOV
3057
                                        dso.append(n);
×
3058
                        }
3059
                        break;
×
3060
                case 106: // Collinder Catalogue
×
UNCOV
3061
                        for (const auto& n : dsoArray)
×
3062
                        {
3063
                                if (n->Cr_nb>0)
×
UNCOV
3064
                                        dso.append(n);
×
3065
                        }
3066
                        break;
×
3067
                case 107: // Melotte Catalogue
×
UNCOV
3068
                        for (const auto& n : dsoArray)
×
3069
                        {
3070
                                if (n->Mel_nb>0)
×
UNCOV
3071
                                        dso.append(n);
×
3072
                        }
3073
                        break;
×
3074
                case 108: // New General Catalogue
×
UNCOV
3075
                        for (const auto& n : dsoArray)
×
3076
                        {
3077
                                if (n->NGC_nb>0)
×
UNCOV
3078
                                        dso.append(n);
×
3079
                        }
3080
                        break;
×
3081
                case 109: // Index Catalogue
×
UNCOV
3082
                        for (const auto& n : dsoArray)
×
3083
                        {
3084
                                if (n->IC_nb>0)
×
UNCOV
3085
                                        dso.append(n);
×
3086
                        }
3087
                        break;
×
3088
                case 110: // Lynds' Catalogue of Bright Nebulae
×
UNCOV
3089
                        for (const auto& n : dsoArray)
×
3090
                        {
3091
                                if (n->LBN_nb>0)
×
UNCOV
3092
                                        dso.append(n);
×
3093
                        }
3094
                        break;
×
3095
                case 111: // Lynds' Catalogue of Dark Nebulae
×
UNCOV
3096
                        for (const auto& n : dsoArray)
×
3097
                        {
3098
                                if (n->LDN_nb>0)
×
UNCOV
3099
                                        dso.append(n);
×
3100
                        }
3101
                        break;
×
3102
                case 112: // Principal Galaxy Catalog
×
UNCOV
3103
                        for (const auto& n : dsoArray)
×
3104
                        {
3105
                                if (n->PGC_nb>0)
×
UNCOV
3106
                                        dso.append(n);
×
3107
                        }
3108
                        break;
×
3109
                case 113: // The Uppsala General Catalogue of Galaxies
×
UNCOV
3110
                        for (const auto& n : dsoArray)
×
3111
                        {
3112
                                if (n->UGC_nb>0)
×
UNCOV
3113
                                        dso.append(n);
×
3114
                        }
3115
                        break;
×
3116
                case 114: // Cederblad Catalog
×
UNCOV
3117
                        for (const auto& n : dsoArray)
×
3118
                        {
3119
                                if (!n->Ced_nb.isEmpty())
×
UNCOV
3120
                                        dso.append(n);
×
3121
                        }
3122
                        break;
×
3123
                case 115: // Atlas of Peculiar Galaxies (Arp)
×
UNCOV
3124
                        for (const auto& n : dsoArray)
×
3125
                        {
3126
                                if (n->Arp_nb>0)
×
UNCOV
3127
                                        dso.append(n);
×
3128
                        }
3129
                        break;
×
3130
                case 116: // The Catalogue of Interacting Galaxies by Vorontsov-Velyaminov (VV)
×
UNCOV
3131
                        for (const auto& n : dsoArray)
×
3132
                        {
3133
                                if (n->VV_nb>0)
×
UNCOV
3134
                                        dso.append(n);
×
3135
                        }
3136
                        break;
×
3137
                case 117: // Catalogue of Galactic Planetary Nebulae (PK)
×
UNCOV
3138
                        for (const auto& n : dsoArray)
×
3139
                        {
3140
                                if (!n->PK_nb.isEmpty())
×
UNCOV
3141
                                        dso.append(n);
×
3142
                        }
3143
                        break;
×
3144
                case 118: // Strasbourg-ESO Catalogue of Galactic Planetary Nebulae by Acker et. al. (PN G)
×
UNCOV
3145
                        for (const auto& n : dsoArray)
×
3146
                        {
3147
                                if (!n->PNG_nb.isEmpty())
×
UNCOV
3148
                                        dso.append(n);
×
3149
                        }
3150
                        break;
×
3151
                case 119: // A catalogue of Galactic supernova remnants by Green (SNR G)
×
UNCOV
3152
                        for (const auto& n : dsoArray)
×
3153
                        {
3154
                                if (!n->SNRG_nb.isEmpty())
×
UNCOV
3155
                                        dso.append(n);
×
3156
                        }
3157
                        break;
×
3158
                case 120: // A Catalog of Rich Clusters of Galaxies by Abell et. al. (ACO)
×
UNCOV
3159
                        for (const auto& n : dsoArray)
×
3160
                        {
3161
                                if (!n->ACO_nb.isEmpty())
×
UNCOV
3162
                                        dso.append(n);
×
3163
                        }
3164
                        break;
×
3165
                case 121: // Hickson Compact Group by Hickson et. al. (HCG)
×
UNCOV
3166
                        for (const auto& n : dsoArray)
×
3167
                        {
3168
                                if (!n->HCG_nb.isEmpty())
×
UNCOV
3169
                                        dso.append(n);
×
3170
                        }
3171
                        break;
×
3172
                case 122: // ESO/Uppsala Survey of the ESO(B) Atlas (ESO)
×
UNCOV
3173
                        for (const auto& n : dsoArray)
×
3174
                        {
3175
                                if (!n->ESO_nb.isEmpty())
×
UNCOV
3176
                                        dso.append(n);
×
3177
                        }
3178
                        break;
×
3179
                case 123: // Catalogue of southern stars embedded in nebulosity (VdBH)
×
UNCOV
3180
                        for (const auto& n : dsoArray)
×
3181
                        {
3182
                                if (!n->VdBH_nb.isEmpty())
×
UNCOV
3183
                                        dso.append(n);
×
3184
                        }
3185
                        break;
×
3186
                case 124: // Catalogue and distances of optically visible H II regions (DWB)
×
UNCOV
3187
                        for (const auto& n : dsoArray)
×
3188
                        {
3189
                                if (n->DWB_nb > 0)
×
UNCOV
3190
                                        dso.append(n);
×
3191
                        }
3192
                        break;
×
3193
                case 125: // Trumpler Catalogue (Tr)
×
UNCOV
3194
                        for (const auto& n : dsoArray)
×
3195
                        {
3196
                                if (n->Tr_nb > 0)
×
UNCOV
3197
                                        dso.append(n);
×
3198
                        }
3199
                        break;
×
3200
                case 126: // Stock Catalogue (St)
×
UNCOV
3201
                        for (const auto& n : dsoArray)
×
3202
                        {
3203
                                if (n->St_nb > 0)
×
UNCOV
3204
                                        dso.append(n);
×
3205
                        }
3206
                        break;
×
3207
                case 127: // Ruprecht Catalogue (Ru)
×
UNCOV
3208
                        for (const auto& n : dsoArray)
×
3209
                        {
3210
                                if (n->Ru_nb > 0)
×
UNCOV
3211
                                        dso.append(n);
×
3212
                        }
3213
                        break;
×
UNCOV
3214
                case 128: // van den Bergh-Hagen Catalogue (VdB-Ha)
×
3215
                        for (const auto& n : dsoArray)
×
3216
                        {
UNCOV
3217
                                if (n->VdBHa_nb > 0)
×
3218
                                        dso.append(n);
×
3219
                        }
3220
                        break;
×
UNCOV
3221
                case 150: // Dwarf galaxies [see NebulaList.hpp]
×
3222
                {
3223
                        NebulaP ds;
×
3224
                        for (unsigned int i = 0; i < sizeof(DWARF_GALAXIES) / sizeof(DWARF_GALAXIES[0]); i++)
×
3225
                        {
3226
                                ds = searchPGC(DWARF_GALAXIES[i]);
×
3227
                                if (!ds.isNull())
×
UNCOV
3228
                                        dso.append(ds);
×
3229
                        }
3230
                        break;
×
3231
                }
×
UNCOV
3232
                case 151: // Herschel 400 Catalogue [see NebulaList.hpp]
×
3233
                {
3234
                        NebulaP ds;
×
3235
                        for (unsigned int i = 0; i < sizeof(H400_LIST) / sizeof(H400_LIST[0]); i++)
×
3236
                        {
3237
                                ds = searchNGC(H400_LIST[i]);
×
3238
                                if (!ds.isNull())
×
UNCOV
3239
                                        dso.append(ds);
×
3240
                        }
3241
                        break;
×
3242
                }
×
UNCOV
3243
                case 152: // Jack Bennett's deep sky catalogue [see NebulaList.hpp]
×
3244
                {
3245
                        NebulaP ds;
×
3246
                        for (unsigned int i = 0; i < sizeof(BENNETT_LIST) / sizeof(BENNETT_LIST[0]); i++)
×
3247
                        {
3248
                                ds = searchNGC(BENNETT_LIST[i]);
×
3249
                                if (!ds.isNull())
×
3250
                                        dso.append(ds);
×
3251
                        }
3252
                        ds = searchMel(105);
×
UNCOV
3253
                        if (!ds.isNull())
×
3254
                                dso.append(ds);
×
3255
                        ds = searchIC(1459);
×
UNCOV
3256
                        if (!ds.isNull())
×
3257
                                dso.append(ds);
×
3258
                        break;
×
3259
                }
×
UNCOV
3260
                case 153: // James Dunlop's deep sky catalogue [see NebulaList.hpp]
×
3261
                {
3262
                        NebulaP ds;
×
3263
                        for (unsigned int i = 0; i < sizeof(DUNLOP_LIST) / sizeof(DUNLOP_LIST[0]); i++)
×
3264
                        {
3265
                                ds = searchNGC(DUNLOP_LIST[i]);
×
UNCOV
3266
                                if (!ds.isNull())
×
3267
                                        dso.append(ds);
×
3268
                        }
UNCOV
3269
                        break;
×
3270
                }
×
UNCOV
3271
                default:
×
3272
                {
UNCOV
3273
                        for (const auto& n : dsoArray)
×
3274
                        {
3275
                                if (n->nType==type)
×
UNCOV
3276
                                        dso.append(n);
×
3277
                        }
UNCOV
3278
                        break;
×
3279
                }
3280
        }
3281

UNCOV
3282
        return dso;
×
UNCOV
3283
}
×
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