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

Stellarium / stellarium / 13476741827

22 Feb 2025 09:27PM UTC coverage: 12.077% (-0.004%) from 12.081%
13476741827

push

github

gzotti
Allow excluding names from unwanted references
- also allows supporting more than one nebula aet.
- Docfixes
- SUG: describe how to do that

0 of 44 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

14615 of 121016 relevant lines covered (12.08%)

16770.37 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 setName(const NebulaP& nebula, const QString& specificName)
×
60
{
61
        const auto currentName = nebula->getEnglishName();
×
62
        if (currentName.isEmpty()) // Set native name of DSO
×
63
                nebula->setProperName(specificName);
×
64
        else if (currentName != specificName) // Add traditional (well-known?) name of DSO as alias
×
65
                nebula->addNameAlias(specificName);
×
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.
NEW
415
        const QString nebulaSetName=conf->value("astro/nebula_set", "default").toString();
×
416

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

NEW
449
        loadNebulaSet(nebulaSetName);
×
450

451
        updateI18n();
×
452

453
        StelApp *app = &StelApp::getInstance();
×
454
        connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
×
455
        connect(&app->getSkyCultureMgr(), &StelSkyCultureMgr::currentSkyCultureChanged, this, &NebulaMgr::updateSkyCulture);
×
456
        GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
×
457

458
        addAction("actionShow_Nebulas", N_("Display Options"), N_("Deep-sky objects"), "flagHintDisplayed", "D", "N");
×
459
        addAction("actionSet_Nebula_TypeFilterUsage", N_("Display Options"), N_("Toggle DSO type filter"), "flagTypeFiltersUsage");
×
460
}
×
461

462
void NebulaMgr::selectAllCatalogs()
×
463
{
464
        setCatalogFilters(Nebula::CatAll);
×
465
}
×
466

467
void NebulaMgr::selectStandardCatalogs()
×
468
{
469
        Nebula::CatalogGroup catalogs = Nebula::CatNone;
×
470
        catalogs |= Nebula::CatNGC;
×
471
        catalogs |= Nebula::CatIC;
×
472
        catalogs |= Nebula::CatM;
×
473
        setCatalogFilters(catalogs);
×
474
}
×
475

476
void NebulaMgr::selectNoneCatalogs()
×
477
{
478
        setCatalogFilters(Nebula::CatNone);
×
479
}
×
480

481
void NebulaMgr::loadCatalogFilters()
×
482
{
483
        QSettings* conf = StelApp::getInstance().getSettings();
×
484
        Q_ASSERT(conf);
×
485

486
        Nebula::CatalogGroup catalogFilters = Nebula::CatalogGroup(Nebula::CatNone);
×
487

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

551
        // NB: nebula set loaded inside setter of catalog filter
552
        setCatalogFilters(int(catalogFilters));
×
553
}
×
554

555
void NebulaMgr::storeCatalogFilters()
×
556
{
557
        QSettings* conf = StelApp::getInstance().getSettings();
×
558
        Q_ASSERT(conf);
×
559

560
        // view dialog / DSO tag settings
561
        const Nebula::CatalogGroup cflags = static_cast<Nebula::CatalogGroup>(getCatalogFilters());
×
562

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

597
struct DrawNebulaFuncObject
598
{
599
        DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPainter* p, StelCore* aCore, bool acheckMaxMagHints)
×
600
                : maxMagHints(amaxMagHints)
×
601
                , maxMagLabels(amaxMagLabels)
×
602
                , sPainter(p)
×
603
                , core(aCore)
×
604
                , checkMaxMagHints(acheckMaxMagHints)
×
605
        {
606
                angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPerRadAtCenter()*M_180_PIf;
×
607
        }
×
608
        void operator()(StelRegionObject* obj)
×
609
        {
610
                if (checkMaxMagHints)
×
611
                        return;
×
612

613
                Nebula* n = static_cast<Nebula*>(obj);
×
614
                float mag=n->getVisibilityLevelByMagnitude();
×
615

616
                StelSkyDrawer *drawer = core->getSkyDrawer();
×
617
                // filter out DSOs which are too dim to be seen (e.g. for bino observers)
618
                if ((drawer->getFlagNebulaMagnitudeLimit()) && (mag > static_cast<float>(drawer->getCustomNebulaMagnitudeLimit())))
×
619
                        return;
×
620

621
                if (!n->objectInDisplayedCatalog())
×
622
                        return;
×
623

624
                if (n->flagShowOnlyNamedDSO && n->getEnglishName().isEmpty())
×
625
                        return;
×
626

627
                if (!n->objectInAllowedSizeRangeLimits())
×
628
                        return;
×
629

630
                if (n->majorAxisSize>angularSizeLimit || n->majorAxisSize==0.f || mag <= maxMagHints)
×
631
                {
632
                        sPainter->getProjector()->project(n->getJ2000EquatorialPos(core),n->XY);
×
633
                        n->drawLabel(*sPainter, maxMagLabels);
×
634
                        n->drawHints(*sPainter, maxMagHints, core);
×
635
                        n->drawOutlines(*sPainter, maxMagHints);
×
636
                }
637
        }
638
        float maxMagHints;
639
        float maxMagLabels;
640
        StelPainter* sPainter;
641
        StelCore* core;
642
        float angularSizeLimit;
643
        bool checkMaxMagHints;
644
};
645

646
void NebulaMgr::setCatalogFilters(int cflags)
×
647
{
648
        if(cflags != static_cast<int>(Nebula::catalogFilters))
×
649
        {
650
                Nebula::catalogFilters = static_cast<Nebula::CatalogGroup>(cflags);
×
651
                emit catalogFiltersChanged(cflags);
×
652
        }
653
}
×
654

655
void NebulaMgr::setTypeFilters(int tflags)
×
656
{
657
        if(tflags != static_cast<int>(Nebula::typeFilters))
×
658
        {
659
                Nebula::typeFilters = static_cast<Nebula::TypeGroup>(tflags);
×
660
                emit typeFiltersChanged(tflags);
×
661
        }
662
}
×
663

664
void NebulaMgr::setFlagSurfaceBrightnessUsage(const bool usage)
×
665
{
666
        if (usage!=Nebula::surfaceBrightnessUsage)
×
667
        {
668
                Nebula::surfaceBrightnessUsage=usage;
×
669
                StelApp::immediateSave("astro/flag_surface_brightness_usage", Nebula::surfaceBrightnessUsage);
×
670
                emit flagSurfaceBrightnessUsageChanged(usage);
×
671
        }
672
}
×
673

674
bool NebulaMgr::getFlagSurfaceBrightnessUsage(void) const
×
675
{
676
        return Nebula::surfaceBrightnessUsage;
×
677
}
678

679
void NebulaMgr::setFlagSurfaceBrightnessArcsecUsage(const bool usage)
×
680
{
681
        if (usage!=Nebula::flagUseArcsecSurfaceBrightness)
×
682
        {
683
                Nebula::flagUseArcsecSurfaceBrightness=usage;
×
684
                StelApp::immediateSave("gui/flag_surface_brightness_arcsec", Nebula::flagUseArcsecSurfaceBrightness);
×
685
                emit flagSurfaceBrightnessArcsecUsageChanged(usage);
×
686
        }
687
}
×
688

689
bool NebulaMgr::getFlagSurfaceBrightnessArcsecUsage(void) const
×
690
{
691
        return Nebula::flagUseArcsecSurfaceBrightness;
×
692
}
693

694
void NebulaMgr::setFlagSurfaceBrightnessShortNotationUsage(const bool usage)
×
695
{
696
        if (usage!=Nebula::flagUseShortNotationSurfaceBrightness)
×
697
        {
698
                Nebula::flagUseShortNotationSurfaceBrightness=usage;
×
699
                StelApp::immediateSave("gui/flag_surface_brightness_short", Nebula::flagUseShortNotationSurfaceBrightness);
×
700
                emit flagSurfaceBrightnessShortNotationUsageChanged(usage);
×
701
        }
702
}
×
703

704
bool NebulaMgr::getFlagSurfaceBrightnessShortNotationUsage(void) const
×
705
{
706
        return Nebula::flagUseShortNotationSurfaceBrightness;
×
707
}
708

709
void NebulaMgr::setFlagSizeLimitsUsage(const bool usage)
×
710
{
711
        if (usage!=Nebula::flagUseSizeLimits)
×
712
        {
713
                Nebula::flagUseSizeLimits=usage;
×
714
                StelApp::immediateSave("astro/flag_size_limits_usage", Nebula::flagUseSizeLimits);
×
715
                emit flagSizeLimitsUsageChanged(usage);
×
716
        }
717
}
×
718

719
bool NebulaMgr::getFlagSizeLimitsUsage(void) const
×
720
{
721
        return Nebula::flagUseSizeLimits;
×
722
}
723

724
void NebulaMgr::setFlagUseTypeFilters(const bool b)
×
725
{
726
        if (Nebula::flagUseTypeFilters!=b)
×
727
        {
728
                Nebula::flagUseTypeFilters=b;
×
729
                StelApp::immediateSave("astro/flag_use_type_filter", Nebula::flagUseTypeFilters);
×
730
                emit flagUseTypeFiltersChanged(b);
×
731
        }
732
}
×
733

734
bool NebulaMgr::getFlagUseTypeFilters(void) const
×
735
{
736
        return Nebula::flagUseTypeFilters;
×
737
}
738

739
void NebulaMgr::setLabelsAmount(double a)
×
740
{
741
        if((a-labelsAmount) != 0.)
×
742
        {
743
                labelsAmount=a;
×
744
                StelApp::immediateSave("astro/nebula_labels_amount", labelsAmount);
×
745
                emit labelsAmountChanged(a);
×
746
        }
747
}
×
748

749
double NebulaMgr::getLabelsAmount(void) const
×
750
{
751
        return labelsAmount;
×
752
}
753

754
void NebulaMgr::setHintsAmount(double f)
×
755
{
756
        if((hintsAmount-f) != 0.)
×
757
        {
758
                hintsAmount = f;
×
759
                StelApp::immediateSave("astro/nebula_hints_amount", hintsAmount);
×
760
                emit hintsAmountChanged(f);
×
761
        }
762
}
×
763

764
double NebulaMgr::getHintsAmount(void) const
×
765
{
766
        return hintsAmount;
×
767
}
768

769
void NebulaMgr::setLabelsBrightness(double b)
×
770
{
771
        if (b!=labelsBrightness)
×
772
        {
773
                labelsBrightness = b;
×
774
                StelApp::immediateSave("astro/nebula_labels_brightness", labelsBrightness);
×
775
                emit labelsBrightnessChanged(b);
×
776
        }
777
}
×
778

779
double NebulaMgr::getLabelsBrightness(void) const
×
780
{
781
        return labelsBrightness;
×
782
}
783

784
void NebulaMgr::setHintsBrightness(double b)
×
785
{
786
        if (b!=hintsBrightness)
×
787
        {
788
                hintsBrightness = b;
×
789
                StelApp::immediateSave("astro/nebula_hints_brightness", hintsBrightness);
×
790
                emit hintsBrightnessChanged(b);
×
791
        }
792
}
×
793

794
double NebulaMgr::getHintsBrightness(void) const
×
795
{
796
        return hintsBrightness;
×
797
}
798

799

800
void NebulaMgr::setMinSizeLimit(double s)
×
801
{
802
        if((Nebula::minSizeLimit-s) != 0.)
×
803
        {
804
                Nebula::minSizeLimit = s;
×
805
                StelApp::immediateSave("astro/size_limit_min", Nebula::minSizeLimit);
×
806
                emit minSizeLimitChanged(s);
×
807
        }
808
}
×
809

810
double NebulaMgr::getMinSizeLimit() const
×
811
{
812
        return Nebula::minSizeLimit;
×
813
}
814

815
void NebulaMgr::setMaxSizeLimit(double s)
×
816
{
817
        if((Nebula::maxSizeLimit-s) != 0.)
×
818
        {
819
                Nebula::maxSizeLimit = s;
×
820
                StelApp::immediateSave("astro/size_limit_max", Nebula::maxSizeLimit);
×
821
                emit maxSizeLimitChanged(s);
×
822
        }
823
}
×
824

825
double NebulaMgr::getMaxSizeLimit() const
×
826
{
827
        return Nebula::maxSizeLimit;
×
828
}
829

830
float NebulaMgr::computeMaxMagHint(const StelSkyDrawer* skyDrawer) const
×
831
{
832
        return skyDrawer->getLimitMagnitude()*1.2f-2.f+static_cast<float>(hintsAmount *1.)-2.f;
×
833
}
834

835
// Draw all the Nebulae and call drawing the pointer if needed
836
void NebulaMgr::draw(StelCore* core)
×
837
{
838
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
839
        StelPainter sPainter(prj);
×
840
        sPainter.setFont(nebulaFont);
×
841

842
        if(hintsFader.getInterstate()>0.f)
×
843
        {
844
                static StelSkyDrawer* skyDrawer = core->getSkyDrawer();
×
845

846
                Nebula::hintsBrightness  = hintsFader.getInterstate()*flagShow.getInterstate()*static_cast<float>(hintsBrightness);
×
847
                Nebula::labelsBrightness = hintsFader.getInterstate()*flagShow.getInterstate()*static_cast<float>(labelsBrightness);
×
848

849
                // Use a 4 degree margin (esp. for wide outlines)
850
                const float margin = 4.f*M_PI_180f*prj->getPixelPerRadAtCenter();
×
851
                const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, margin);
×
852

853
                // Print all the nebulae of all the selected zones
854
                float maxMagHints  = computeMaxMagHint(skyDrawer);
×
855
                float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+static_cast<float>(labelsAmount*1.2)-2.f;
×
856
                DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core, hintsFader.getInterstate()<=0.f);
×
857
                nebGrid.processIntersectingPointInRegions(p.data(), func);
×
858
        }
×
859

860
        static StelObjectMgr *som=GETSTELMODULE(StelObjectMgr);
×
861
        if (som->getFlagSelectedObjectPointer())
×
862
                drawPointer(core, sPainter);
×
863
}
×
864

865
void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter)
×
866
{
867
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
868

869
        const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
870
        if (!newSelected.empty())
×
871
        {
872
                const StelObjectP obj = newSelected[0];
×
873
                Vec3d pos=obj->getJ2000EquatorialPos(core);
×
874

875
                // Compute 2D pos and return if outside screen
876
                if (!prj->projectInPlace(pos)) return;
×
877
                sPainter.setColor(0.4f,0.5f,0.8f);
×
878

879
                texPointer->bind();
×
880

881
                sPainter.setBlending(true);
×
882

883
                // Size on screen
884
                float screenRd = static_cast<float>(obj->getAngularRadius(core))*M_PI_180f*prj->getPixelPerRadAtCenter();
×
885
                if (screenRd>120.f) // avoid oversized marker
×
886
                        screenRd = 120.f;
×
887

888
                if (Nebula::drawHintProportional)
×
889
                        screenRd*=1.2f;
×
890
                screenRd+=20.f + 10.f*std::sin(3.f * static_cast<float>(StelApp::getInstance().getAnimationTime()));
×
891
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, 90);
×
892
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, 0);
×
893
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, -90);
×
894
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, -180);
×
895
        }
×
896
}
×
897

898
// Search by name
899
NebulaP NebulaMgr::searchForCommonName(const QString& name)
×
900
{
901
        QString uname = name.toUpper();
×
902

903
        if (const auto it = commonNameMap.find(uname); it != commonNameMap.end())
×
NEW
904
                return *&(it->nebula);
×
905

906
        return searchByDesignation(uname);
×
907
}
×
908

909
void NebulaMgr::loadNebulaSet(const QString& setName)
×
910
{
911
        QString srcCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.txt");
×
912
        QString dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog-" + StellariumDSOCatalogVersion + ".dat");
×
913
        if (dsoCatalogPath.isEmpty()) // Extended edition is not exist, let's try find standard edition
×
914
                dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.dat");
×
915
        QString dsoOutlinesPath        = StelFileMgr::findFile("nebulae/" + setName + "/outlines.dat");
×
916
        QString dsoDiscoveryPath = StelFileMgr::findFile("nebulae/" + setName + "/discovery.dat");
×
917
        QString dsoNamesPath = StelFileMgr::findFile("nebulae/" + setName + "/names.dat");
×
918

919
        dsoArray.clear();
×
920
        dsoIndex.clear();
×
921
        nebGrid.clear();
×
922

923
        if (flagConverter)
×
924
        {
925
                if (!srcCatalogPath.isEmpty())
×
926
                        convertDSOCatalog(srcCatalogPath, StelFileMgr::findFile("nebulae/" + setName + "/catalog.pack", StelFileMgr::New), flagDecimalCoordinates);
×
927
                else
928
                        qWarning() << "ERROR converting catalogue, because source data set does not exist for " << setName;
×
929
        }
930

931
        if (dsoCatalogPath.isEmpty())
×
932
        {
933
                qWarning() << "ERROR while loading deep-sky catalog data set " << setName;
×
934
                return;
×
935
        }
936

937
        loadDSOCatalog(dsoCatalogPath);
×
938

939
        if (dsoNamesPath.isEmpty())
×
940
        {
941
                qWarning().noquote() << "ERROR while loading deep-sky names data set" << setName;
×
942
        }
943
        else
944
        {
945
                loadDSONames(dsoNamesPath);
×
946
        }
947

948
        if (!dsoOutlinesPath.isEmpty())
×
949
                loadDSOOutlines(dsoOutlinesPath);
×
950

951
        if (!dsoDiscoveryPath.isEmpty())
×
952
                loadDSODiscoveryData(dsoDiscoveryPath);
×
953
}
×
954

955
// Look for a nebula by XYZ coords
956
NebulaP NebulaMgr::search(const Vec3d& apos)
×
957
{
958
        Vec3d pos(apos);
×
959
        pos.normalize();
×
960
        NebulaP plusProche;
×
961
        double anglePlusProche=0.0;
×
962
        for (const auto& n : std::as_const(dsoArray))
×
963
        {
964
                if (n->XYZ*pos>anglePlusProche)
×
965
                {
966
                        anglePlusProche=n->XYZ*pos;
×
967
                        plusProche=n;
×
968
                }
969
        }
970
        if (anglePlusProche>0.999) // object within ~2.5 degrees
×
971
        {
972
                return plusProche;
×
973
        }
974
        else return NebulaP();
×
975
}
×
976

977

978
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov, const StelCore*) const
×
979
{
980
        QList<StelObjectP> result;
×
981
        if (!getFlagShow())
×
982
                return result;
×
983

984
        Vec3d v(av);
×
985
        v.normalize();
×
986
        const double cosLimFov = cos(limitFov * M_PI/180.);
×
987
        Vec3d equPos;
×
988
        for (const auto& n : std::as_const(dsoArray))
×
989
        {
990
                equPos = n->XYZ;
×
991
                equPos.normalize();
×
992
                if (equPos*v >= cosLimFov)
×
993
                {
994
                        result.push_back(qSharedPointerCast<StelObject>(n));
×
995
                }
996
        }
997
        return result;
×
998
}
×
999

1000
NebulaP NebulaMgr::searchDSO(unsigned int DSO) const
×
1001
{
1002
        if (dsoIndex.contains(DSO))
×
1003
                return dsoIndex[DSO];
×
1004
        return NebulaP();
×
1005
}
1006

1007

1008
NebulaP NebulaMgr::searchM(unsigned int M) const
×
1009
{
1010
        for (const auto& n : dsoArray)
×
1011
                if (n->M_nb == M)
×
1012
                        return n;
×
1013
        return NebulaP();
×
1014
}
1015

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1128
NebulaP NebulaMgr::searchCed(QString Ced) const
×
1129
{
1130
        Ced = Ced.trimmed();
×
1131
        for (const auto& n : dsoArray)
×
1132
                if (n->Ced_nb.compare(Ced, Qt::CaseInsensitive))
×
1133
                        return n;
×
1134
        return NebulaP();
×
1135
}
1136

1137
NebulaP NebulaMgr::searchArp(unsigned int Arp) const
×
1138
{
1139
        for (const auto& n : dsoArray)
×
1140
                if (n->Arp_nb == Arp)
×
1141
                        return n;
×
1142
        return NebulaP();
×
1143
}
1144

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

1153
NebulaP NebulaMgr::searchPK(QString PK) const
×
1154
{
1155
        PK = PK.trimmed();
×
1156
        for (const auto& n : dsoArray)
×
1157
                if (n->PK_nb.compare(PK, Qt::CaseInsensitive) == 0)
×
1158
                        return n;
×
1159
        return NebulaP();
×
1160
}
1161

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

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

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

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

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

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

1216
NebulaP NebulaMgr::searchDWB(unsigned int DWB) const
×
1217
{
1218
        for (const auto& n : dsoArray)
×
1219
                if (n->DWB_nb == DWB)
×
1220
                        return n;
×
1221
        return NebulaP();
×
1222
}
1223

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

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

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

1248
QString NebulaMgr::getLatestSelectedDSODesignation() const
×
1249
{
1250
        QString result = "";
×
1251

1252
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1253
        if (!selected.empty())
×
1254
        {
1255
                for (const auto& n : dsoArray)
×
1256
                        if (n==selected[0])
×
1257
                                result = n->getDSODesignation(); // Get designation for latest selected DSO
×
1258
        }
1259

1260
        return result;
×
1261
}
×
1262

1263
QString NebulaMgr::getLatestSelectedDSODesignationWIC() const
×
1264
{
1265
        QString result = "";
×
1266

1267
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1268
        if (!selected.empty())
×
1269
        {
1270
                for (const auto& n : dsoArray)
×
1271
                        if (n==selected[0])
×
1272
                                result = n->getDSODesignationWIC(); // Get designation for latest selected DSO
×
1273
        }
1274

1275
        return result;
×
1276
}
×
1277

1278
void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bool decimal=false)
×
1279
{
1280
        QFile dsoIn(in);
×
1281
        if (!dsoIn.open(QIODevice::ReadOnly | QIODevice::Text))
×
1282
                return;
×
1283

1284
        QFile dsoOut(out);
×
1285
        if (!dsoOut.open(QIODevice::WriteOnly))
×
1286
        {
1287
                qDebug() << "Error converting DSO data! Cannot open file" << QDir::toNativeSeparators(out);
×
1288
                return;
×
1289
        }
1290

1291
        int totalRecords=0;
×
1292
        QString record;
×
1293
        while (!dsoIn.atEnd())
×
1294
        {
1295
                dsoIn.readLine();
×
1296
                ++totalRecords;
×
1297
        }
1298

1299
        // rewind the file to the start
1300
        dsoIn.seek(0);
×
1301

1302
        QDataStream dsoOutStream(&dsoOut);
×
1303
        dsoOutStream.setVersion(QDataStream::Qt_5_2);
×
1304

1305
        int readOk = 0;                                // how many records were read without problems
×
1306
        while (!dsoIn.atEnd())
×
1307
        {
1308
                record = QString::fromUtf8(dsoIn.readLine());
×
1309

1310
                static const QRegularExpression version("ersion\\s+([\\d\\.]+)\\s+(\\w+)");
×
1311
                QRegularExpressionMatch versionMatch;
×
1312
                int vp = record.indexOf(version, 0, &versionMatch);
×
1313
                if (vp!=-1) // Version of catalog, a first line!
×
1314
                        dsoOutStream << versionMatch.captured(1).trimmed() << versionMatch.captured(2).trimmed();
×
1315

1316
                // skip comments
1317
                if (record.startsWith("//") || record.startsWith("#"))
×
1318
                {
1319
                        --totalRecords;
×
1320
                        continue;
×
1321
                }
1322

1323
                if (!record.isEmpty())
×
1324
                {
1325
                        #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
1326
                        QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1327
                        #else
1328
                        QStringList list=record.split("\t", QString::KeepEmptyParts);
1329
                        #endif
1330

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

1380
                        float raRad, decRad;
1381
                        if (decimal)
×
1382
                        {
1383
                                // Convert from deg to rad
1384
                                raRad        = ra.toFloat() *M_PI_180f;
×
1385
                                decRad        = dec.toFloat()*M_PI_180f;
×
1386
                        }
1387
                        else
1388
                        {
1389
                                QStringList raLst;
×
1390
                                if (ra.contains(":"))
×
1391
                                        raLst        = ra.split(":");
×
1392
                                else
1393
                                        raLst        = ra.split(" ");
×
1394

1395
                                QStringList decLst;
×
1396
                                if (dec.contains(":"))
×
1397
                                        decLst = dec.split(":");
×
1398
                                else
1399
                                        decLst = dec.split(" ");
×
1400

1401
                                raRad        = raLst.at(0).toFloat() + raLst.at(1).toFloat()/60.f + raLst.at(2).toFloat()/3600.f;
×
1402
                                decRad        = qAbs(decLst.at(0).toFloat()) + decLst.at(1).toFloat()/60.f + decLst.at(2).toFloat()/3600.f;
×
1403
                                if (dec.startsWith("-")) decRad *= -1.f;
×
1404

1405
                                raRad  *= M_PIf/12.f;        // Convert from hours to rad
×
1406
                                decRad *= M_PIf/180.f;    // Convert from deg to rad
×
1407
                        }
×
1408

1409
                        majorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1410
                        minorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1411

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

1509
                        Nebula::NebulaType nType=oTypesHash.value(oType.toUpper(), Nebula::NebUnknown);
×
1510
                        if (nType == Nebula::NebUnknown)
×
1511
                                qDebug() << "Record with ID" << id <<"has unknown type of object:" << oType;
×
1512

1513
                        ++readOk;
×
1514

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

1528
bool NebulaMgr::loadDSOCatalog(const QString &filename)
×
1529
{
1530
        QFile in(filename);
×
1531
        if (!in.open(QIODevice::ReadOnly))
×
1532
                return false;
×
1533

1534
        qInfo().noquote() << "Loading DSO data ...";
×
1535

1536
        // Let's begin use gzipped data
1537
        QDataStream ins(StelUtils::uncompress(in.readAll()));
×
1538
        ins.setVersion(QDataStream::Qt_5_2);
×
1539

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

1573
                        dsoArray.append(e);
×
1574
                        nebGrid.insert(qSharedPointerCast<StelRegionObject>(e));
×
1575
                        if (e->DSO_nb!=0)
×
1576
                                dsoIndex.insert(e->DSO_nb, e);
×
1577
                }
×
1578
                ++totalRecords;
×
1579
        }
1580
        in.close();
×
1581
        qInfo().noquote() << "Loaded" << --totalRecords << "DSO records";
×
1582
        return true;
×
1583
}
×
1584

1585
bool NebulaMgr::loadDSONames(const QString &filename)
×
1586
{
1587
        qInfo() << "Loading DSO name data ...";
×
1588

1589
        defaultNameMap.clear();
×
1590

1591
        QFile dsoNameFile(filename);
×
1592
        if (!dsoNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1593
        {
1594
                qWarning().noquote() << "DSO name data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1595
                return false;
×
1596
        }
1597

1598
        // Read the names of the deep-sky objects
1599
        QString name, record, ref, cdes;
×
1600
        QStringList nodata;
×
1601
        nodata.clear();
×
1602
        int totalRecords=0;
×
1603
        int readOk=0;
×
1604
        unsigned int nb;
1605
        NebulaP e;
×
1606
        static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1607
        while (!dsoNameFile.atEnd())
×
1608
        {
1609
                record = QString::fromUtf8(dsoNameFile.readLine());
×
1610
                if (commentRx.match(record).hasMatch())
×
1611
                        continue;
×
1612

1613
                totalRecords++;
×
1614

1615
                // bytes 1 - 5, designator for catalogue (prefix)
1616
                ref  = record.left(5).trimmed();
×
1617
                // bytes 6 -20, identificator for object in the catalog
1618
                cdes = record.mid(5, 15).trimmed().toUpper();
×
1619
                // bytes 21-80, proper name of the object (translatable)
1620
                name = record.mid(21).trimmed(); // Let gets the name with trimmed whitespaces
×
1621

1622
                nb = cdes.toUInt();
×
1623

1624
                static const QStringList catalogs = {
1625
                        "IC",    "M",   "C",  "CR",  "MEL",   "B", "SH2", "VDB", "RCW",  "LDN",
1626
                        "LBN", "NGC", "PGC", "UGC",  "CED", "ARP",  "VV",  "PK", "PNG", "SNRG",
1627
                        "ACO", "HCG", "ESO", "VDBH", "DWB", "TR", "ST", "RU", "DBHA"};
×
1628

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

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

1744
                                        //qDebug() << "References for object " << e->getDSODesignation() << "as" << propName << ":" << refList;
NEW
1745
                                        accept=refList.isEmpty(); // if we don't have a reference list, we must accept it.
×
1746
                                }
1747
                                // Now refList contains the DSO's reference strings.
1748
                                // Compare with the list of unwantedReferences and accept only "allowed" ones.
NEW
1749
                                if (!accept)
×
1750
                                {
1751
                                        //refList.removeAll()
1752

NEW
1753
                                        foreach(QString str, refList)
×
1754
                                        {
NEW
1755
                                                if (unwantedReferences.contains(str))
×
1756
                                                {
NEW
1757
                                                        qDebug() << "Unwanted reference" << str << "detected for DSO name" << propName;
×
NEW
1758
                                                        refList.removeOne(str);
×
1759
                                                }
NEW
1760
                                        }
×
1761
                                        // Now it's inverse: if there are still references, we use the name.
NEW
1762
                                        accept=!refList.isEmpty();
×
1763
                                }
1764

NEW
1765
                                if (accept)
×
1766
                                {
NEW
1767
                                        defaultNameMap[e].push_back(propName);
×
NEW
1768
                                        NebulaWithReferences nr = {e, refList };
×
NEW
1769
                                        commonNameMap[propName.toUpper()] = nr;  // add with reduced refList.
×
NEW
1770
                                }
×
1771
                        }
×
1772
                        readOk++;
×
1773
                }
×
1774
                else
1775
                        nodata.append(QString("%1 %2").arg(ref.trimmed(), cdes.trimmed()));
×
1776
        }
1777
        dsoNameFile.close();
×
1778
        qInfo().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO name records successfully";
×
1779

1780
        int err = nodata.size();
×
1781
        if (err>0)
×
1782
                qWarning().noquote() << "No position data for" << err << "objects:" << nodata.join(", ");
×
1783

1784
        return true;
×
1785
}
×
1786

1787
bool NebulaMgr::loadDSODiscoveryData(const QString &filename)
×
1788
{
1789
        qInfo() << "Loading DSO discovery data ...";
×
1790
        QFile dsoDiscoveryFile(filename);
×
1791
        if (!dsoDiscoveryFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1792
        {
1793
                qWarning().noquote() << "DSO discovery data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1794
                return false;
×
1795
        }
1796

1797
        int readOk = 0;
×
1798
        int totalRecords = 0;
×
1799
        QString record, dso, dYear, dName;
×
1800
        NebulaP e;
×
1801
        while (!dsoDiscoveryFile.atEnd())
×
1802
        {
1803
                record = QString::fromUtf8(dsoDiscoveryFile.readLine());
×
1804
                if (record.startsWith("//") || record.startsWith("#") || record.isEmpty())
×
1805
                        continue;
×
1806

1807
                totalRecords++;
×
1808
                #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
1809
                QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1810
                #else
1811
                QStringList list=record.split("\t", QString::KeepEmptyParts);
1812
                #endif
1813

1814
                dso        = list.at(0).trimmed();
×
1815
                dYear        = list.at(1).trimmed();
×
1816
                dName        = list.at(2).trimmed();
×
1817

1818
                e = searchForCommonName(dso);
×
1819
                if (e.isNull()) // maybe this is inner number of DSO
×
1820
                        e = searchDSO(dso.toUInt());
×
1821

1822
                if (!e.isNull())
×
1823
                {
1824
                        e->setDiscoveryData(dName, dYear);
×
1825
                        readOk++;
×
1826
                }
1827
        }
×
1828
        dsoDiscoveryFile.close();
×
1829
        qInfo().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO discovery records successfully";
×
1830
        return true;
×
1831
}
×
1832

1833
bool NebulaMgr::loadDSOOutlines(const QString &filename)
×
1834
{
1835
        qInfo() << "Loading DSO outline data ...";
×
1836
        QFile dsoOutlineFile(filename);
×
1837
        if (!dsoOutlineFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1838
        {
1839
                qWarning().noquote() << "DSO outline data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1840
                return false;
×
1841
        }
1842

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

1860
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
1861
                // bytes 1 - 8, RA
1862
                RA = record.first(8).toDouble();
×
1863
                // bytes 9 -18, DE
1864
                DE = record.sliced(9, 10).toDouble();
×
1865
#else
1866
                // bytes 1 - 8, RA
1867
                RA = record.leftRef(8).toDouble();
1868
                // bytes 9 -18, DE
1869
                DE = record.midRef(9, 10).toDouble();
1870
#endif
1871
                // bytes 19-25, command
1872
                command = record.mid(19, 7).trimmed();
×
1873
                // bytes 26, designation of DSO
1874
                dso = record.mid(26).trimmed();
×
1875

1876
                RA*=M_PI/12.;     // Convert from hours to rad
×
1877
                DE*=M_PI/180.;    // Convert from deg to rad
×
1878

1879
                if (command.contains("start", Qt::CaseInsensitive))
×
1880
                {
1881
                        outline.clear();
×
1882
                        e = searchForCommonName(dso);
×
1883
                        if (e.isNull()) // maybe this is inner number of DSO
×
1884
                                e = searchDSO(dso.toUInt());
×
1885

1886
                        point.first  = RA;
×
1887
                        point.second = DE;
×
1888
                        outline.append(point);
×
1889
                        fpoint = point;
×
1890
                }
1891

1892
                if (command.contains("vertex", Qt::CaseInsensitive))
×
1893
                {
1894
                        point.first  = RA;
×
1895
                        point.second = DE;
×
1896
                        outline.append(point);
×
1897
                }
1898

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

1906
                        if (!e.isNull())
×
1907
                        {
1908
                                points = new std::vector<Vec3d>;
×
1909
                                for (i = 0; i < outline.size(); i++)
×
1910
                                {
1911
                                        // Calc the Cartesian coord with RA and DE
1912
                                        point = outline.at(i);
×
1913
                                        StelUtils::spheToRect(point.first, point.second, XYZ);
×
1914
                                        points->push_back(XYZ);
×
1915
                                }
1916

1917
                                e->outlineSegments.push_back(points);
×
1918
                        }
1919
                        readOk++;
×
1920
                }
1921
        }
1922
        dsoOutlineFile.close();
×
1923
        qInfo().noquote() << "Loaded" << readOk << "DSO outline records successfully";
×
1924
        return true;
×
1925
}
×
1926

1927
void NebulaMgr::updateSkyCulture(const StelSkyCulture& skyCulture)
×
1928
{
1929
        for (const auto& n : std::as_const(dsoArray))
×
1930
                n->removeAllNames();
×
1931

1932
        if (skyCulture.fallbackToInternationalNames)
×
1933
        {
1934
                for (auto it = commonNameMap.begin(); it != commonNameMap.end(); ++it)
×
NEW
1935
                        setName(it.value().nebula, it.key());
×
1936
        }
1937

1938
        int numLoaded = 0;
×
1939
        if (!skyCulture.names.isEmpty())
×
1940
                numLoaded = loadCultureSpecificNames(skyCulture.names);
×
1941

1942
        if (numLoaded)
×
1943
        {
1944
                qInfo().noquote() << "Loaded" << numLoaded << "culture-specific DSO names";
×
1945
        }
1946
        else
1947
        {
1948
                for (auto it = defaultNameMap.begin(); it != defaultNameMap.end(); ++it)
×
1949
                        for (const auto& name : it.value())
×
1950
                                setName(it.key(), name);
×
1951

1952
        }
1953

1954
        updateI18n();
×
1955
}
×
1956

1957
int NebulaMgr::loadCultureSpecificNames(const QJsonObject& data)
×
1958
{
1959
        int loadedTotal = 0;
×
1960
        for (auto it = data.begin(); it != data.end(); ++it)
×
1961
        {
1962
                const auto key = it.key();
×
1963
                const auto specificNames = it->toArray();
×
1964

1965
                if (key.startsWith("HIP "))
×
1966
                {
1967
                        // skip since it's a star
1968
                }
1969
                else if (key.startsWith("NAME "))
×
1970
                {
1971
                        // FIXME: this is a kludge for the discrepancy between stellarium-skycultures database
1972
                        // and Stellarium's internal database. Maybe we should make use of the former and drop
1973
                        // the latter instead of doing this name translation.
1974
                        auto name = key.mid(5);
×
1975
                        static const QHash<QString, QString> renamer{
1976
                                {"Beehive Cluster" , "Beehive"           },
1977
                                {"Carina Nebula"   , "Eta Carinae Nebula"},
1978
                                {u8"ω Cen Cluster" , "Omega Centauri"    },
1979
                        };
×
1980
                        if (const auto it = renamer.find(name); it != renamer.end())
×
1981
                                name = it.value();
×
1982
                        loadCultureSpecificNameForNamedObject(it.value().toArray(), name);
×
1983
                }
×
1984
                else if (const NebulaP n = searchByDesignation(key))
×
1985
                {
1986
                        for (const auto& entry : specificNames)
×
1987
                        {
1988
                                for (const char*const nameType : {"english", "native"})
×
1989
                                {
1990
                                        const auto specificName = entry.toObject()[nameType].toString();
×
1991
                                        if (specificName.isEmpty())
×
1992
                                                continue;
×
1993
                                        setName(n, specificName);
×
1994
                                        ++loadedTotal;
×
1995
                                }
×
1996
                        }
1997
                }
×
1998
        }
×
1999
        return loadedTotal;
×
2000
}
×
2001

2002
void NebulaMgr::loadCultureSpecificNameForNamedObject(const QJsonArray& data, const QString& commonName)
×
2003
{
2004
        const auto commonNameIndexIt = commonNameMap.find(commonName.toUpper());
×
2005
        if (commonNameIndexIt == commonNameMap.end())
×
2006
        {
2007
                // This may actually not even be a nebula, so we shouldn't emit any warning, just return
2008
                return;
×
2009
        }
2010

2011
        for (const auto& entry : data)
×
2012
        {
2013
                const auto specificName = entry.toObject()["english"].toString();
×
2014
                if (specificName.isEmpty()) continue;
×
2015

2016
                // TODO: Filter away unwanted sources per-skyculture!
2017
                // For now, just accept as before.
NEW
2018
                setName(commonNameIndexIt.value().nebula, specificName);
×
UNCOV
2019
        }
×
2020
}
2021

2022
void NebulaMgr::updateI18n()
×
2023
{
2024
        const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
×
2025
        for (const auto& n : std::as_const(dsoArray))
×
2026
                n->translateName(trans);
×
2027
}
×
2028

2029

2030
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
2031
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
×
2032
{
2033
        QString objw = nameI18n.toUpper();
×
2034

2035
        // Search by common names
2036
        for (const auto& n : std::as_const(dsoArray))
×
2037
        {
2038
                QString objwcap = n->nameI18.toUpper();
×
2039
                if (objwcap==objw)
×
2040
                        return qSharedPointerCast<StelObject>(n);
×
2041
        }
×
2042

2043
        // Search by aliases of common names
2044
        for (const auto& n : std::as_const(dsoArray))
×
2045
        {
2046
                for (auto &objwcapa : n->nameI18Aliases)
×
2047
                {
2048
                        if (objwcapa.toUpper()==objw)
×
2049
                                return qSharedPointerCast<StelObject>(n);
×
2050
                }
2051
        }
2052

2053
        // Search by designation
2054
        NebulaP n = searchByDesignation(objw);
×
2055
        return qSharedPointerCast<StelObject>(n);
×
2056
}
×
2057

2058

2059
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
2060
StelObjectP NebulaMgr::searchByName(const QString& name) const
×
2061
{
2062
        QString objw = name.toUpper();
×
2063

2064
        // Search by common names
2065
        for (const auto& n : dsoArray)
×
2066
        {
2067
                QString objwcap = n->englishName.toUpper();
×
2068
                if (objwcap==objw)
×
2069
                        return qSharedPointerCast<StelObject>(n);
×
2070
        }
×
2071

2072
        if (getFlagAdditionalNames())
×
2073
        {
2074
                // Search by aliases of common names
2075
                for (const auto& n : dsoArray)
×
2076
                {
2077
                        for (auto &objwcapa : n->englishAliases)
×
2078
                        {
2079
                                if (objwcapa.toUpper()==objw)
×
2080
                                        return qSharedPointerCast<StelObject>(n);
×
2081
                        }
2082
                }
2083
        }
2084

2085
        // Search by designation
2086
        NebulaP n = searchByDesignation(objw);
×
2087
        return qSharedPointerCast<StelObject>(n);
×
2088
}
×
2089

2090
//! Return the matching Nebula object's pointer if exists or Q_NULLPTR
2091
//! TODO Decide whether empty StelObjectP or Q_NULLPTR is the better return type and select the same for both.
2092
NebulaP NebulaMgr::searchByDesignation(const QString &designation) const
×
2093
{
2094
        NebulaP n;
×
2095
        QString uname = designation.toUpper();
×
2096
        // If no match found, try search by catalog reference
2097
        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+)$");
×
2098
        QRegularExpressionMatch catNumMatch=catNumRx.match(uname);
×
2099
        if (catNumMatch.hasMatch())
×
2100
        {
2101
                QString cat = catNumMatch.captured(1);
×
2102
                unsigned int num = catNumMatch.captured(2).toUInt();
×
2103
                if (cat == "M") n = searchM(num);
×
2104
                if (cat == "NGC") n = searchNGC(num);
×
2105
                if (cat == "IC") n = searchIC(num);
×
2106
                if (cat == "C") n = searchC(num);
×
2107
                if (cat == "B") n = searchB(num);
×
2108
                if (cat == "VDB-HA") n = searchVdBHa(num);
×
2109
                if (cat == "VDB") n = searchVdB(num);
×
2110
                if (cat == "RCW") n = searchRCW(num);
×
2111
                if (cat == "LDN") n = searchLDN(num);
×
2112
                if (cat == "LBN") n = searchLBN(num);
×
2113
                if (cat == "CR") n = searchCr(num);
×
2114
                if (cat == "MEL") n = searchMel(num);
×
2115
                if (cat == "PGC") n = searchPGC(num);
×
2116
                if (cat == "UGC") n = searchUGC(num);
×
2117
                if (cat == "ARP") n = searchArp(num);
×
2118
                if (cat == "VV") n = searchVV(num);
×
2119
                if (cat == "DWB") n = searchDWB(num);
×
2120
                if (cat == "TR" || cat == "TRUMPLER") n = searchTr(num);
×
2121
                if (cat == "ST" || cat == "STOCK") n = searchSt(num);
×
2122
                if (cat == "RU" || cat == "RUPRECHT") n = searchRu(num);
×
2123
        }
×
2124
        static const QRegularExpression dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$");
×
2125
        QRegularExpressionMatch dCatNumMatch=dCatNumRx.match(uname);
×
2126
        if (dCatNumMatch.hasMatch())
×
2127
        {
2128
                QString dcat = dCatNumMatch.captured(1);
×
2129
                unsigned int dnum = dCatNumMatch.captured(2).toUInt();
×
2130

2131
                if (dcat == "SH") n = searchSh2(dnum);
×
2132
        }
×
2133
        static const QRegularExpression sCatNumRx("^(CED|PK|ACO|ABELL|HCG|ESO|VDBH)\\s*(.+)$");
×
2134
        QRegularExpressionMatch sCatNumMatch=sCatNumRx.match(uname);
×
2135
        if (sCatNumMatch.hasMatch())
×
2136
        {
2137
                QString cat = sCatNumMatch.captured(1);
×
2138
                QString num = sCatNumMatch.captured(2).trimmed();
×
2139

2140
                if (cat == "CED") n = searchCed(num);
×
2141
                if (cat == "PK") n = searchPK(num);
×
2142
                if (cat == "ACO" || cat == "ABELL") n = searchACO(num);
×
2143
                if (cat == "HCG") n = searchHCG(num);
×
2144
                if (cat == "ESO") n = searchESO(num);
×
2145
                if (cat == "VDBH") n = searchVdBH(num);
×
2146
        }
×
2147
        static const QRegularExpression gCatNumRx("^(PN|SNR)\\s*G(.+)$");
×
2148
        QRegularExpressionMatch gCatNumMatch=gCatNumRx.match(uname);
×
2149
        if (gCatNumMatch.hasMatch())
×
2150
        {
2151
                QString cat = gCatNumMatch.captured(1);
×
2152
                QString num = gCatNumMatch.captured(2).trimmed();
×
2153

2154
                if (cat == "PN") n = searchPNG(num);
×
2155
                if (cat == "SNR") n = searchSNRG(num);
×
2156
        }
×
2157

2158
        return n;
×
2159
}
×
2160

2161
//! Find and return the list of at most maxNbItem objects auto-completing the passed object name
2162
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
×
2163
{
2164
        QStringList result;
×
2165
        if (maxNbItem <= 0)
×
2166
                return result;
×
2167

2168
        QString objw = objPrefix.toUpper();
×
2169

2170
        // Search by Messier objects number (possible formats are "M31" or "M 31")
2171
        if (objw.size()>=1 && objw.at(0)=='M' && objw.left(3)!="MEL")
×
2172
        {
2173
                for (const auto& n : dsoArray)
×
2174
                {
2175
                        if (n->M_nb==0) continue;
×
2176
                        QString constw = QString("M%1").arg(n->M_nb);
×
2177
                        QString constws = constw.mid(0, objw.size());
×
2178
                        if (constws.toUpper()==objw)
×
2179
                        {
2180
                                result << constws;
×
2181
                                continue;        // Prevent adding both forms for name
×
2182
                        }
2183
                        constw = QString("M %1").arg(n->M_nb);
×
2184
                        constws = constw.mid(0, objw.size());
×
2185
                        if (constws.toUpper()==objw)
×
2186
                                result << constw;
×
2187
                }
×
2188
        }
2189

2190
        // Search by Melotte objects number (possible formats are "Mel31" or "Mel 31")
2191
        if (objw.size()>=1 && objw.left(3)=="MEL")
×
2192
        {
2193
                for (const auto& n : dsoArray)
×
2194
                {
2195
                        if (n->Mel_nb==0) continue;
×
2196
                        QString constw = QString("Mel%1").arg(n->Mel_nb);
×
2197
                        QString constws = constw.mid(0, objw.size());
×
2198
                        QString constws2 = QString("Melotte%1").arg(n->Mel_nb).mid(0, objw.size());
×
2199
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2200
                        {
2201
                                result << constws;
×
2202
                                continue;        // Prevent adding both forms for name
×
2203
                        }
2204
                        constw = QString("Mel %1").arg(n->Mel_nb);
×
2205
                        constws = constw.mid(0, objw.size());
×
2206
                        constws2 = QString("Melotte %1").arg(n->Mel_nb).mid(0, objw.size());
×
2207
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2208
                                result << constw;
×
2209
                }
×
2210
        }
2211

2212
        // Search by IC objects number (possible formats are "IC466" or "IC 466")
2213
        if (objw.size()>=1 && objw.left(2)=="IC")
×
2214
        {
2215
                for (const auto& n : dsoArray)
×
2216
                {
2217
                        if (n->IC_nb==0) continue;
×
2218
                        QString constw = QString("IC%1").arg(n->IC_nb);
×
2219
                        QString constws = constw.mid(0, objw.size());
×
2220
                        if (constws.toUpper()==objw)
×
2221
                        {
2222
                                result << constws;
×
2223
                                continue;        // Prevent adding both forms for name
×
2224
                        }
2225
                        constw = QString("IC %1").arg(n->IC_nb);
×
2226
                        constws = constw.mid(0, objw.size());
×
2227
                        if (constws.toUpper()==objw)
×
2228
                                result << constw;
×
2229
                }
×
2230
        }
2231

2232
        // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
2233
        for (const auto& n : dsoArray)
×
2234
        {
2235
                if (n->NGC_nb==0) continue;
×
2236
                QString constw = QString("NGC%1").arg(n->NGC_nb);
×
2237
                QString constws = constw.mid(0, objw.size());
×
2238
                if (constws.toUpper()==objw)
×
2239
                {
2240
                        result << constws;
×
2241
                        continue;
×
2242
                }
2243
                constw = QString("NGC %1").arg(n->NGC_nb);
×
2244
                constws = constw.mid(0, objw.size());
×
2245
                if (constws.toUpper()==objw)
×
2246
                        result << constw;
×
2247
        }
×
2248

2249
        // Search by PGC object numbers (possible formats are "PGC31" or "PGC 31")
2250
        if (objw.size()>=1 && objw.left(3)=="PGC")
×
2251
        {
2252
                for (const auto& n : dsoArray)
×
2253
                {
2254
                        if (n->PGC_nb==0) continue;
×
2255
                        QString constw = QString("PGC%1").arg(n->PGC_nb);
×
2256
                        QString constws = constw.mid(0, objw.size());
×
2257
                        if (constws.toUpper()==objw)
×
2258
                        {
2259
                                result << constws;        // Prevent adding both forms for name
×
2260
                                continue;
×
2261
                        }
2262
                        constw = QString("PGC %1").arg(n->PGC_nb);
×
2263
                        constws = constw.mid(0, objw.size());
×
2264
                        if (constws.toUpper()==objw)
×
2265
                                result << constw;
×
2266
                }
×
2267
        }
2268

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

2289
        // Search by Caldwell objects number (possible formats are "C31" or "C 31")
2290
        if (objw.size()>=1 && objw.at(0)=='C' && objw.left(2)!="CR" && objw.left(2)!="CE")
×
2291
        {
2292
                for (const auto& n : dsoArray)
×
2293
                {
2294
                        if (n->C_nb==0) continue;
×
2295
                        QString constw = QString("C%1").arg(n->C_nb);
×
2296
                        QString constws = constw.mid(0, objw.size());
×
2297
                        if (constws.toUpper()==objw)
×
2298
                        {
2299
                                result << constws;
×
2300
                                continue;        // Prevent adding both forms for name
×
2301
                        }
2302
                        constw = QString("C %1").arg(n->C_nb);
×
2303
                        constws = constw.mid(0, objw.size());
×
2304
                        if (constws.toUpper()==objw)
×
2305
                                result << constw;
×
2306
                }
×
2307
        }
2308

2309
        // Search by Collinder objects number (possible formats are "Cr31" or "Cr 31")
2310
        if (objw.size()>=1 && (objw.left(2)=="CR" || objw.left(9)=="COLLINDER"))
×
2311
        {
2312
                for (const auto& n : dsoArray)
×
2313
                {
2314
                        if (n->Cr_nb==0) continue;
×
2315
                        QString constw = QString("Cr%1").arg(n->Cr_nb);
×
2316
                        QString constws = constw.mid(0, objw.size());
×
2317
                        QString constws2 = QString("Collinder%1").arg(n->Cr_nb).mid(0, objw.size());
×
2318
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2319
                        {
2320
                                result << constws;
×
2321
                                continue;        // Prevent adding both forms for name
×
2322
                        }
2323
                        constw = QString("Cr %1").arg(n->Cr_nb);
×
2324
                        constws = constw.mid(0, objw.size());
×
2325
                        constws2 = QString("Collinder %1").arg(n->Cr_nb).mid(0, objw.size());
×
2326
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2327
                                result << constw;
×
2328
                }
×
2329
        }
2330

2331
        // Search by Ced objects number (possible formats are "Ced31" or "Ced 31")
2332
        if (objw.size()>=1 && objw.left(3)=="CED")
×
2333
        {
2334
                for (const auto& n : dsoArray)
×
2335
                {
2336
                        if (n->Ced_nb.isEmpty()) continue;
×
2337
                        QString constw = QString("Ced%1").arg(n->Ced_nb);
×
2338
                        QString constws = constw.mid(0, objw.size());
×
2339
                        if (constws.toUpper()==objw)
×
2340
                        {
2341
                                result << constws;
×
2342
                                continue;        // Prevent adding both forms for name
×
2343
                        }
2344
                        constw = QString("Ced %1").arg(n->Ced_nb);
×
2345
                        constws = constw.mid(0, objw.size());
×
2346
                        if (constws.toUpper()==objw)
×
2347
                                result << constw;
×
2348
                }
×
2349
        }
2350

2351
        // Search by Barnard objects number (possible formats are "B31" or "B 31")
2352
        if (objw.size()>=1 && objw.at(0)=='B')
×
2353
        {
2354
                for (const auto& n : dsoArray)
×
2355
                {
2356
                        if (n->B_nb==0) continue;
×
2357
                        QString constw = QString("B%1").arg(n->B_nb);
×
2358
                        QString constws = constw.mid(0, objw.size());
×
2359
                        if (constws.toUpper()==objw)
×
2360
                        {
2361
                                result << constws;
×
2362
                                continue;        // Prevent adding both forms for name
×
2363
                        }
2364
                        constw = QString("B %1").arg(n->B_nb);
×
2365
                        constws = constw.mid(0, objw.size());
×
2366
                        if (constws.toUpper()==objw)
×
2367
                                result << constw;
×
2368
                }
×
2369
        }
2370

2371
        // Search by Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31")
2372
        if (objw.size()>=1 && objw.left(2)=="SH")
×
2373
        {
2374
                for (const auto& n : dsoArray)
×
2375
                {
2376
                        if (n->Sh2_nb==0) continue;
×
2377
                        QString constw = QString("SH2-%1").arg(n->Sh2_nb);
×
2378
                        QString constws = constw.mid(0, objw.size());
×
2379
                        if (constws.toUpper()==objw)
×
2380
                        {
2381
                                result << constws;
×
2382
                                continue;        // Prevent adding both forms for name
×
2383
                        }
2384
                        constw = QString("SH 2-%1").arg(n->Sh2_nb);
×
2385
                        constws = constw.mid(0, objw.size());
×
2386
                        if (constws.toUpper()==objw)
×
2387
                                result << constw;
×
2388
                }
×
2389
        }
2390

2391
        // Search by van den Bergh objects number (possible formats are "vdB31" or "vdB 31")
2392
        if (objw.size()>=1 && objw.left(3)=="VDB" && objw.left(6)!="VDB-HA" && objw.left(4)!="VDBH")
×
2393
        {
2394
                for (const auto& n : dsoArray)
×
2395
                {
2396
                        if (n->VdB_nb==0) continue;
×
2397
                        QString constw = QString("vdB%1").arg(n->VdB_nb);
×
2398
                        QString constws = constw.mid(0, objw.size());
×
2399
                        if (constws.toUpper()==objw)
×
2400
                        {
2401
                                result << constws;
×
2402
                                continue;        // Prevent adding both forms for name
×
2403
                        }
2404
                        constw = QString("vdB %1").arg(n->VdB_nb);
×
2405
                        constws = constw.mid(0, objw.size());
×
2406
                        if (constws.toUpper()==objw)
×
2407
                                result << constw;
×
2408
                }
×
2409
        }
2410

2411
        // Search by RCW objects number (possible formats are "RCW31" or "RCW 31")
2412
        if (objw.size()>=1 && objw.left(3)=="RCW")
×
2413
        {
2414
                for (const auto& n : dsoArray)
×
2415
                {
2416
                        if (n->RCW_nb==0) continue;
×
2417
                        QString constw = QString("RCW%1").arg(n->RCW_nb);
×
2418
                        QString constws = constw.mid(0, objw.size());
×
2419
                        if (constws.toUpper()==objw)
×
2420
                        {
2421
                                result << constws;
×
2422
                                continue;        // Prevent adding both forms for name
×
2423
                        }
2424
                        constw = QString("RCW %1").arg(n->RCW_nb);
×
2425
                        constws = constw.mid(0, objw.size());
×
2426
                        if (constws.toUpper()==objw)
×
2427
                                result << constw;
×
2428
                }
×
2429
        }
2430

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

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

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

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

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

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

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

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

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

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

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

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

2673
        // Search by Tr (Trumpler) objects number
2674
        if (objw.size()>=1 && (objw.left(8)=="TRUMPLER" || objw.left(2)=="TR"))
×
2675
        {
2676
                for (const auto& n : dsoArray)
×
2677
                {
2678
                        if (n->Tr_nb==0) continue;
×
2679
                        QString constw = QString("Tr%1").arg(n->Tr_nb);
×
2680
                        QString constws = constw.mid(0, objw.size());
×
2681
                        QString constws2 = QString("Trumpler%1").arg(n->Tr_nb).mid(0, objw.size());
×
2682
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2683
                        {
2684
                                result << constws;
×
2685
                                continue;        // Prevent adding both forms for name
×
2686
                        }
2687
                        constw = QString("Tr %1").arg(n->Tr_nb);
×
2688
                        constws = constw.mid(0, objw.size());
×
2689
                        constws2 = QString("Trumpler %1").arg(n->Tr_nb).mid(0, objw.size());
×
2690
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2691
                                result << constw;
×
2692
                }
×
2693
        }
2694

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

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

2739
        // Search by van den Bergh-Hagen Catalogue objects number
2740
        if (objw.size()>=1 && objw.left(6)=="VDB-HA")
×
2741
        {
2742
                for (const auto& n : dsoArray)
×
2743
                {
2744
                        if (n->VdBHa_nb==0) continue;
×
2745
                        QString constw = QString("vdB-Ha%1").arg(n->VdBHa_nb);
×
2746
                        QString constws = constw.mid(0, objw.size());
×
2747
                        if (constws.toUpper()==objw)
×
2748
                        {
2749
                                result << constws;
×
2750
                                continue;        // Prevent adding both forms for name
×
2751
                        }
2752
                        constw = QString("vdB-Ha %1").arg(n->VdBHa_nb);
×
2753
                        constws = constw.mid(0, objw.size());
×
2754
                        if (constws.toUpper()==objw)
×
2755
                                result << constw;
×
2756
                }
×
2757
        }
2758

2759
        // Search by common names and aliases
2760
        QStringList names;
×
2761
        for (const auto& n : dsoArray)
×
2762
        {
2763
                names.append(n->nameI18);
×
2764
                names.append(n->englishName);
×
2765
                if (getFlagAdditionalNames())
×
2766
                {
2767
                        QStringList nameList = n->nameI18Aliases;
×
2768
                        for (const auto &name : nameList)
×
2769
                                names.append(name);
×
2770

2771
                        nameList = n->englishAliases;
×
2772
                        for (const auto &name : std::as_const(nameList))
×
2773
                                names.append(name);
×
2774
                }
×
2775
        }
2776

2777
        QString fullMatch = "";
×
2778
        for (const auto& name : std::as_const(names))
×
2779
        {
2780
                if (!matchObjectName(name, objPrefix, useStartOfWords))
×
2781
                        continue;
×
2782

2783
                if (name==objPrefix)
×
2784
                        fullMatch = name;
×
2785
                else
2786
                        result.append(name);
×
2787
        }
2788

2789
        result.sort();
×
2790
        if (!fullMatch.isEmpty())
×
2791
                result.prepend(fullMatch);
×
2792

2793
        if (result.size() > maxNbItem)
×
2794
                result.erase(result.begin() + maxNbItem, result.end());
×
2795

2796
        return result;
×
2797
}
×
2798

2799
QStringList NebulaMgr::listAllObjects(bool inEnglish) const
×
2800
{
2801
        QStringList result;
×
2802
        for (const auto& n : dsoArray)
×
2803
        {
2804
                if (!n->getEnglishName().isEmpty())
×
2805
                {
2806
                        if (inEnglish)
×
2807
                                result << n->getEnglishName();
×
2808
                        else
2809
                                result << n->getNameI18n();
×
2810
                }
2811
        }
2812
        return result;
×
2813
}
×
2814

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

2992
        result.removeDuplicates();
×
2993
        return result;
×
2994
}
×
2995

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

3266
        return dso;
×
3267
}
×
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