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

Stellarium / stellarium / 4853788370

pending completion
4853788370

push

github

Alexander V. Wolf
Special patch for John Simple

3 of 3 new or added lines in 3 files covered. (100.0%)

14729 of 125046 relevant lines covered (11.78%)

20166.5 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 "StelSkyDrawer.hpp"
31
#include "StelTranslator.hpp"
32
#include "StelTextureMgr.hpp"
33
#include "StelObjectMgr.hpp"
34
#include "StelLocaleMgr.hpp"
35
#include "StelSkyCultureMgr.hpp"
36
#include "StelFileMgr.hpp"
37
#include "StelModuleMgr.hpp"
38
#include "StelCore.hpp"
39
#include "StelPainter.hpp"
40

41
#include <algorithm>
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
static const QString StellariumDSOCatalogVersion = "3.19";
55

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

137
NebulaMgr::NebulaMgr(void) : StelObjectModule()
×
138
        , nebGrid(200)
×
139
        , hintsAmount(0)
×
140
        , labelsAmount(0)
×
141
        , flagConverter(false)
×
142
        , flagDecimalCoordinates(true)
×
143
{
144
        setObjectName("NebulaMgr");
×
145
}
×
146

147
NebulaMgr::~NebulaMgr()
×
148
{
149
        Nebula::texRegion = StelTextureSP();
×
150
        Nebula::texPointElement = StelTextureSP();
×
151
        Nebula::texPlanetaryNebula = StelTextureSP();
×
152
}
×
153

154
/*************************************************************************
155
 Reimplementation of the getCallOrder method
156
*************************************************************************/
157
double NebulaMgr::getCallOrder(StelModuleActionName actionName) const
×
158
{
159
        if (actionName==StelModule::ActionDraw)
×
160
                return StelApp::getInstance().getModuleMgr().getModule("MilkyWay")->getCallOrder(actionName)+10;
×
161
        return 0;
×
162
}
163

164
// read from stream
165
void NebulaMgr::init()
×
166
{
167
        QSettings* conf = StelApp::getInstance().getSettings();
×
168
        Q_ASSERT(conf);
×
169

170
        nebulaFont.setPixelSize(StelApp::getInstance().getScreenFontSize());
×
171
        connect(&StelApp::getInstance(), SIGNAL(screenFontSizeChanged(int)), SLOT(setFontSizeFromApp(int)));
×
172
    auto& texMan = StelApp::getInstance().getTextureManager();
×
173
        // Load dashed shape texture
174
        Nebula::texRegion                = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_reg.png");
×
175
        // Load open cluster marker texture
176
        Nebula::texPointElement                = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_point_elem.png");
×
177
        // Load planetary nebula marker texture
178
        Nebula::texPlanetaryNebula        = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_pnb.png");
×
179
        // Load pointer texture
180
        texPointer = texMan.createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png");
×
181

182
        setFlagShow(conf->value("astro/flag_nebula",true).toBool());
×
183
        setFlagHints(conf->value("astro/flag_nebula_name",false).toBool());
×
184
        setHintsAmount(conf->value("astro/nebula_hints_amount", 3.0).toDouble());
×
185
        setLabelsAmount(conf->value("astro/nebula_labels_amount", 3.0).toDouble());
×
186
        setHintsProportional(conf->value("astro/flag_nebula_hints_proportional", false).toBool());
×
187
        setFlagOutlines(conf->value("astro/flag_dso_outlines_usage", false).toBool());
×
188
        setFlagAdditionalNames(conf->value("astro/flag_dso_additional_names",true).toBool());
×
189
        setDesignationUsage(conf->value("astro/flag_dso_designation_usage", false).toBool());
×
190
        setFlagSurfaceBrightnessUsage(conf->value("astro/flag_surface_brightness_usage", false).toBool());
×
191
        setFlagSurfaceBrightnessArcsecUsage(conf->value("gui/flag_surface_brightness_arcsec", false).toBool());
×
192
        setFlagSurfaceBrightnessShortNotationUsage(conf->value("gui/flag_surface_brightness_short", false).toBool());
×
193

194
        setFlagSizeLimitsUsage(conf->value("astro/flag_size_limits_usage", false).toBool());
×
195
        setMinSizeLimit(conf->value("astro/size_limit_min", 1.0).toDouble());
×
196
        setMaxSizeLimit(conf->value("astro/size_limit_max", 600.0).toDouble());
×
197

198
        // Load colors from config file
199
        // Upgrade config keys
200
        if (conf->contains("color/nebula_label_color"))
×
201
        {
202
                conf->setValue("color/dso_label_color", conf->value("color/nebula_label_color", "0.4,0.3,0.5").toString());
×
203
                conf->remove("color/nebula_label_color");
×
204
        }
205
        if (conf->contains("color/nebula_circle_color"))
×
206
        {
207
                conf->setValue("color/dso_circle_color", conf->value("color/nebula_circle_color", "0.8,0.8,0.1").toString());
×
208
                conf->remove("color/nebula_circle_color");
×
209
        }
210
        if (conf->contains("color/nebula_galaxy_color"))
×
211
        {
212
                conf->setValue("color/dso_galaxy_color", conf->value("color/nebula_galaxy_color", "1.0,0.2,0.2").toString());
×
213
                conf->remove("color/nebula_galaxy_color");
×
214
        }
215
        if (conf->contains("color/nebula_radioglx_color"))
×
216
        {
217
                conf->setValue("color/dso_radio_galaxy_color", conf->value("color/nebula_radioglx_color", "0.3,0.3,0.3").toString());
×
218
                conf->remove("color/nebula_radioglx_color");
×
219
        }
220
        if (conf->contains("color/nebula_activeglx_color"))
×
221
        {
222
                conf->setValue("color/dso_active_galaxy_color", conf->value("color/nebula_activeglx_color", "1.0,0.5,0.2").toString());
×
223
                conf->remove("color/nebula_activeglx_color");
×
224
        }
225
        if (conf->contains("color/nebula_intglx_color"))
×
226
        {
227
                conf->setValue("color/dso_interacting_galaxy_color", conf->value("color/nebula_intglx_color", "0.2,0.5,1.0").toString());
×
228
                conf->remove("color/nebula_intglx_color");
×
229
        }
230
        if (conf->contains("color/nebula_brightneb_color"))
×
231
        {
232
                conf->setValue("color/dso_nebula_color", conf->value("color/nebula_brightneb_color", "0.1,1.0,0.1").toString());
×
233
                conf->remove("color/nebula_brightneb_color");
×
234
        }
235
        if (conf->contains("color/nebula_darkneb_color"))
×
236
        {
237
                conf->setValue("color/dso_dark_nebula_color", conf->value("color/nebula_darkneb_color", "0.3,0.3,0.3").toString());
×
238
                conf->remove("color/nebula_darkneb_color");
×
239
        }
240
        if (conf->contains("color/nebula_hregion_color"))
×
241
        {
242
                conf->setValue("color/dso_hydrogen_region_color", conf->value("color/nebula_hregion_color", "0.1,1.0,0.1").toString());
×
243
                conf->remove("color/nebula_hregion_color");
×
244
        }
245
        if (conf->contains("color/nebula_snr_color"))
×
246
        {
247
                conf->setValue("color/dso_supernova_remnant_color", conf->value("color/nebula_snr_color", "0.1,1.0,0.1").toString());
×
248
                conf->remove("color/nebula_snr_color");
×
249
        }
250
        if (conf->contains("color/nebula_cluster_color"))
×
251
        {
252
                conf->setValue("color/dso_cluster_color", conf->value("color/nebula_cluster_color", "0.8,0.8,0.1").toString());
×
253
                conf->remove("color/nebula_cluster_color");
×
254
        }
255

256
        // Set colors for markers
257
        setLabelsColor(Vec3f(conf->value("color/dso_label_color", "0.2,0.6,0.7").toString()));
×
258
        setCirclesColor(Vec3f(conf->value("color/dso_circle_color", "1.0,0.7,0.2").toString()));
×
259
        setRegionsColor(Vec3f(conf->value("color/dso_region_color", "0.7,0.7,0.2").toString()));
×
260

261
        QString defaultGalaxyColor = conf->value("color/dso_galaxy_color", "1.0,0.2,0.2").toString();
×
262
        setGalaxyColor(           Vec3f(defaultGalaxyColor));
×
263
        setRadioGalaxyColor(      Vec3f(conf->value("color/dso_radio_galaxy_color", "0.3,0.3,0.3").toString()));
×
264
        setActiveGalaxyColor(     Vec3f(conf->value("color/dso_active_galaxy_color", "1.0,0.5,0.2").toString()));
×
265
        setInteractingGalaxyColor(Vec3f(conf->value("color/dso_interacting_galaxy_color", "0.2,0.5,1.0").toString()));
×
266
        setGalaxyClusterColor(    Vec3f(conf->value("color/dso_galaxy_cluster_color", "0.2,0.8,1.0").toString()));
×
267
        setQuasarColor(           Vec3f(conf->value("color/dso_quasar_color", defaultGalaxyColor).toString()));
×
268
        setPossibleQuasarColor(   Vec3f(conf->value("color/dso_possible_quasar_color", defaultGalaxyColor).toString()));
×
269
        setBlLacObjectColor(      Vec3f(conf->value("color/dso_bl_lac_color", defaultGalaxyColor).toString()));
×
270
        setBlazarColor(           Vec3f(conf->value("color/dso_blazar_color", defaultGalaxyColor).toString()));
×
271

272
        QString defaultNebulaColor = conf->value("color/dso_nebula_color", "0.1,1.0,0.1").toString();
×
273
        setNebulaColor(                   Vec3f(defaultNebulaColor));
×
274
        setPlanetaryNebulaColor(          Vec3f(conf->value("color/dso_planetary_nebula_color", defaultNebulaColor).toString()));
×
275
        setReflectionNebulaColor(         Vec3f(conf->value("color/dso_reflection_nebula_color", defaultNebulaColor).toString()));
×
276
        setBipolarNebulaColor(            Vec3f(conf->value("color/dso_bipolar_nebula_color", defaultNebulaColor).toString()));
×
277
        setEmissionNebulaColor(           Vec3f(conf->value("color/dso_emission_nebula_color", defaultNebulaColor).toString()));
×
278
        setDarkNebulaColor(               Vec3f(conf->value("color/dso_dark_nebula_color", "0.3,0.3,0.3").toString()));
×
279
        setHydrogenRegionColor(           Vec3f(conf->value("color/dso_hydrogen_region_color", defaultNebulaColor).toString()));
×
280
        setSupernovaRemnantColor(         Vec3f(conf->value("color/dso_supernova_remnant_color", defaultNebulaColor).toString()));
×
281
        setSupernovaCandidateColor(       Vec3f(conf->value("color/dso_supernova_candidate_color", defaultNebulaColor).toString()));
×
282
        setSupernovaRemnantCandidateColor(Vec3f(conf->value("color/dso_supernova_remnant_cand_color", defaultNebulaColor).toString()));
×
283
        setInterstellarMatterColor(       Vec3f(conf->value("color/dso_interstellar_matter_color", defaultNebulaColor).toString()));
×
284
        setMolecularCloudColor(           Vec3f(conf->value("color/dso_molecular_cloud_color", defaultNebulaColor).toString()));
×
285
        setPossiblePlanetaryNebulaColor(  Vec3f(conf->value("color/dso_possible_planetary_nebula_color", defaultNebulaColor).toString()));
×
286
        setProtoplanetaryNebulaColor(     Vec3f(conf->value("color/dso_protoplanetary_nebula_color", defaultNebulaColor).toString()));
×
287

288
        QString defaultClusterColor = conf->value("color/dso_cluster_color", "1.0,1.0,0.1").toString();
×
289
        setClusterColor(           Vec3f(defaultClusterColor));
×
290
        setOpenClusterColor(       Vec3f(conf->value("color/dso_open_cluster_color", defaultClusterColor).toString()));
×
291
        setGlobularClusterColor(   Vec3f(conf->value("color/dso_globular_cluster_color", defaultClusterColor).toString()));
×
292
        setStellarAssociationColor(Vec3f(conf->value("color/dso_stellar_association_color", defaultClusterColor).toString()));
×
293
        setStarCloudColor(         Vec3f(conf->value("color/dso_star_cloud_color", defaultClusterColor).toString()));
×
294

295
        QString defaultStellarColor = conf->value("color/dso_star_color", "1.0,0.7,0.2").toString();
×
296
        setStarColor(              Vec3f(defaultStellarColor));
×
297
        setSymbioticStarColor(     Vec3f(conf->value("color/dso_symbiotic_star_color", defaultStellarColor).toString()));
×
298
        setEmissionLineStarColor(  Vec3f(conf->value("color/dso_emission_star_color", defaultStellarColor).toString()));
×
299
        setEmissionObjectColor(    Vec3f(conf->value("color/dso_emission_object_color", defaultStellarColor).toString()));
×
300
        setYoungStellarObjectColor(Vec3f(conf->value("color/dso_young_stellar_object_color", defaultStellarColor).toString()));
×
301

302
        // for DSO convertor (for developers!)
303
        flagConverter = conf->value("devel/convert_dso_catalog", false).toBool();
×
304
        flagDecimalCoordinates = conf->value("devel/convert_dso_decimal_coord", true).toBool();
×
305

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

308
        loadCatalogFilters();
×
309

310
        Nebula::TypeGroup typeFilters = Nebula::TypeGroup(Nebula::TypeNone);
×
311

312
        conf->beginGroup("dso_type_filters");
×
313
        if (conf->value("flag_show_galaxies", true).toBool())
×
314
                typeFilters        |= Nebula::TypeGalaxies;
×
315
        if (conf->value("flag_show_active_galaxies", true).toBool())
×
316
                typeFilters        |= Nebula::TypeActiveGalaxies;
×
317
        if (conf->value("flag_show_interacting_galaxies", true).toBool())
×
318
                typeFilters        |= Nebula::TypeInteractingGalaxies;
×
319
        if (conf->value("flag_show_open_clusters", true).toBool())
×
320
                typeFilters        |= Nebula::TypeOpenStarClusters;
×
321
        if (conf->value("flag_show_globular_clusters", true).toBool())
×
322
                typeFilters        |= Nebula::TypeGlobularStarClusters;
×
323
        if (conf->value("flag_show_bright_nebulae", true).toBool())
×
324
                typeFilters        |= Nebula::TypeBrightNebulae;
×
325
        if (conf->value("flag_show_dark_nebulae", true).toBool())
×
326
                typeFilters        |= Nebula::TypeDarkNebulae;
×
327
        if (conf->value("flag_show_planetary_nebulae", true).toBool())
×
328
                typeFilters        |= Nebula::TypePlanetaryNebulae;
×
329
        if (conf->value("flag_show_hydrogen_regions", true).toBool())
×
330
                typeFilters        |= Nebula::TypeHydrogenRegions;
×
331
        if (conf->value("flag_show_supernova_remnants", true).toBool())
×
332
                typeFilters        |= Nebula::TypeSupernovaRemnants;
×
333
        if (conf->value("flag_show_galaxy_clusters", true).toBool())
×
334
                typeFilters        |= Nebula::TypeGalaxyClusters;
×
335
        if (conf->value("flag_show_other", true).toBool())
×
336
                typeFilters        |= Nebula::TypeOther;
×
337
        conf->endGroup();
×
338

339
        setTypeFilters(typeFilters);
×
340

341
        // TODO: mechanism to specify which sets get loaded at start time.
342
        // candidate methods:
343
        // 1. config file option (list of sets to load at startup)
344
        // 2. load all
345
        // 3. flag in nebula_textures.fab (yuk)
346
        // 4. info.ini file in each set containing a "load at startup" item
347
        // For now (0.9.0), just load the default set
348
        loadNebulaSet("default");
×
349

350
        updateI18n();
×
351

352
        StelApp *app = &StelApp::getInstance();
×
353
        connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
×
354
        connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QString)), this, SLOT(updateSkyCulture(const QString&)));
×
355
        GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
×
356

357
        addAction("actionShow_Nebulas", N_("Display Options"), N_("Deep-sky objects"), "flagHintDisplayed", "D", "N");
×
358
        addAction("actionSet_Nebula_TypeFilterUsage", N_("Display Options"), N_("Toggle DSO type filter"), "flagTypeFiltersUsage");
×
359
}
×
360

361
void NebulaMgr::selectAllCatalogs()
×
362
{
363
        setCatalogFilters(Nebula::CatAll);
×
364
}
×
365

366
void NebulaMgr::selectStandardCatalogs()
×
367
{
368
        Nebula::CatalogGroup catalogs = Nebula::CatNone;
×
369
        catalogs |= Nebula::CatNGC;
×
370
        catalogs |= Nebula::CatIC;
×
371
        catalogs |= Nebula::CatM;
×
372
        setCatalogFilters(catalogs);
×
373
}
×
374

375
void NebulaMgr::selectNoneCatalogs()
×
376
{
377
        setCatalogFilters(Nebula::CatNone);
×
378
}
×
379

380
void NebulaMgr::loadCatalogFilters()
×
381
{
382
        QSettings* conf = StelApp::getInstance().getSettings();
×
383
        Q_ASSERT(conf);
×
384

385
        Nebula::CatalogGroup catalogFilters = Nebula::CatalogGroup(Nebula::CatNone);
×
386

387
        conf->beginGroup("dso_catalog_filters");
×
388
        if (conf->value("flag_show_ngc", true).toBool())
×
389
                catalogFilters        |= Nebula::CatNGC;
×
390
        if (conf->value("flag_show_ic", true).toBool())
×
391
                catalogFilters        |= Nebula::CatIC;
×
392
        if (conf->value("flag_show_m", true).toBool())
×
393
                catalogFilters        |= Nebula::CatM;
×
394
        if (conf->value("flag_show_c", false).toBool())
×
395
                catalogFilters        |= Nebula::CatC;
×
396
        if (conf->value("flag_show_b", false).toBool())
×
397
                catalogFilters        |= Nebula::CatB;
×
398
        if (conf->value("flag_show_sh2", false).toBool())
×
399
                catalogFilters        |= Nebula::CatSh2;
×
400
        if (conf->value("flag_show_vdb", false).toBool())
×
401
                catalogFilters        |= Nebula::CatVdB;
×
402
        if (conf->value("flag_show_lbn", false).toBool())
×
403
                catalogFilters        |= Nebula::CatLBN;
×
404
        if (conf->value("flag_show_ldn", false).toBool())
×
405
                catalogFilters        |= Nebula::CatLDN;
×
406
        if (conf->value("flag_show_rcw", false).toBool())
×
407
                catalogFilters        |= Nebula::CatRCW;
×
408
        if (conf->value("flag_show_cr", false).toBool())
×
409
                catalogFilters        |= Nebula::CatCr;
×
410
        if (conf->value("flag_show_mel", false).toBool())
×
411
                catalogFilters        |= Nebula::CatMel;
×
412
        if (conf->value("flag_show_pgc", false).toBool())
×
413
                catalogFilters        |= Nebula::CatPGC;
×
414
        if (conf->value("flag_show_ced", false).toBool())
×
415
                catalogFilters        |= Nebula::CatCed;
×
416
        if (conf->value("flag_show_ugc", false).toBool())
×
417
                catalogFilters        |= Nebula::CatUGC;
×
418
        if (conf->value("flag_show_arp", false).toBool())
×
419
                catalogFilters        |= Nebula::CatArp;
×
420
        if (conf->value("flag_show_vv", false).toBool())
×
421
                catalogFilters        |= Nebula::CatVV;
×
422
        if (conf->value("flag_show_pk", false).toBool())
×
423
                catalogFilters        |= Nebula::CatPK;
×
424
        if (conf->value("flag_show_png", false).toBool())
×
425
                catalogFilters        |= Nebula::CatPNG;
×
426
        if (conf->value("flag_show_snrg", false).toBool())
×
427
                catalogFilters        |= Nebula::CatSNRG;
×
428
        if (conf->value("flag_show_aco", false).toBool())
×
429
                catalogFilters        |= Nebula::CatACO;
×
430
        if (conf->value("flag_show_hcg", false).toBool())
×
431
                catalogFilters        |= Nebula::CatHCG;
×
432
        if (conf->value("flag_show_eso", false).toBool())
×
433
                catalogFilters        |= Nebula::CatESO;
×
434
        if (conf->value("flag_show_vdbh", false).toBool())
×
435
                catalogFilters        |= Nebula::CatVdBH;
×
436
        if (conf->value("flag_show_dwb", false).toBool())
×
437
                catalogFilters        |= Nebula::CatDWB;
×
438
        if (conf->value("flag_show_tr", false).toBool())
×
439
                catalogFilters        |= Nebula::CatTr;
×
440
        if (conf->value("flag_show_st", false).toBool())
×
441
                catalogFilters        |= Nebula::CatSt;
×
442
        if (conf->value("flag_show_ru", false).toBool())
×
443
                catalogFilters        |= Nebula::CatRu;
×
444
        if (conf->value("flag_show_vdbha", false).toBool())
×
445
                catalogFilters        |= Nebula::CatVdBHa;
×
446
        if (conf->value("flag_show_other", true).toBool())
×
447
                catalogFilters        |= Nebula::CatOther;
×
448
        conf->endGroup();
×
449

450
        // NB: nebula set loaded inside setter of catalog filter
451
        setCatalogFilters(int(catalogFilters));
×
452
}
×
453

454
void NebulaMgr::storeCatalogFilters()
×
455
{
456
        QSettings* conf = StelApp::getInstance().getSettings();
×
457
        Q_ASSERT(conf);
×
458

459
        // view dialog / DSO tag settings
460
        const Nebula::CatalogGroup cflags = static_cast<Nebula::CatalogGroup>(getCatalogFilters());
×
461

462
        conf->beginGroup("dso_catalog_filters");
×
463
        conf->setValue("flag_show_ngc",                static_cast<bool>(cflags & Nebula::CatNGC));
×
464
        conf->setValue("flag_show_ic",                static_cast<bool>(cflags & Nebula::CatIC));
×
465
        conf->setValue("flag_show_m",                static_cast<bool>(cflags & Nebula::CatM));
×
466
        conf->setValue("flag_show_c",                static_cast<bool>(cflags & Nebula::CatC));
×
467
        conf->setValue("flag_show_b",                static_cast<bool>(cflags & Nebula::CatB));
×
468
        conf->setValue("flag_show_vdb",                static_cast<bool>(cflags & Nebula::CatVdB));
×
469
        conf->setValue("flag_show_sh2",                static_cast<bool>(cflags & Nebula::CatSh2));
×
470
        conf->setValue("flag_show_rcw",                static_cast<bool>(cflags & Nebula::CatRCW));
×
471
        conf->setValue("flag_show_lbn",                static_cast<bool>(cflags & Nebula::CatLBN));
×
472
        conf->setValue("flag_show_ldn",                static_cast<bool>(cflags & Nebula::CatLDN));
×
473
        conf->setValue("flag_show_cr",                static_cast<bool>(cflags & Nebula::CatCr));
×
474
        conf->setValue("flag_show_mel",                static_cast<bool>(cflags & Nebula::CatMel));
×
475
        conf->setValue("flag_show_ced",                static_cast<bool>(cflags & Nebula::CatCed));
×
476
        conf->setValue("flag_show_pgc",                static_cast<bool>(cflags & Nebula::CatPGC));
×
477
        conf->setValue("flag_show_ugc",                static_cast<bool>(cflags & Nebula::CatUGC));
×
478
        conf->setValue("flag_show_arp",                static_cast<bool>(cflags & Nebula::CatArp));
×
479
        conf->setValue("flag_show_vv",                static_cast<bool>(cflags & Nebula::CatVV));
×
480
        conf->setValue("flag_show_pk",                static_cast<bool>(cflags & Nebula::CatPK));
×
481
        conf->setValue("flag_show_png",                static_cast<bool>(cflags & Nebula::CatPNG));
×
482
        conf->setValue("flag_show_snrg",                static_cast<bool>(cflags & Nebula::CatSNRG));
×
483
        conf->setValue("flag_show_aco",                static_cast<bool>(cflags & Nebula::CatACO));
×
484
        conf->setValue("flag_show_hcg",                static_cast<bool>(cflags & Nebula::CatHCG));
×
485
        conf->setValue("flag_show_eso",                static_cast<bool>(cflags & Nebula::CatESO));
×
486
        conf->setValue("flag_show_vdbh",                static_cast<bool>(cflags & Nebula::CatVdBH));
×
487
        conf->setValue("flag_show_dwb",                static_cast<bool>(cflags & Nebula::CatDWB));
×
488
        conf->setValue("flag_show_tr",                static_cast<bool>(cflags & Nebula::CatTr));
×
489
        conf->setValue("flag_show_st",                static_cast<bool>(cflags & Nebula::CatSt));
×
490
        conf->setValue("flag_show_ru",                static_cast<bool>(cflags & Nebula::CatRu));
×
491
        conf->setValue("flag_show_vdbha",        static_cast<bool>(cflags & Nebula::CatVdBHa));
×
492
        conf->setValue("flag_show_other",                static_cast<bool>(cflags & Nebula::CatOther));
×
493
        conf->endGroup();
×
494
}
×
495

496
struct DrawNebulaFuncObject
497
{
498
        DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPainter* p, StelCore* aCore, bool acheckMaxMagHints)
×
499
                : maxMagHints(amaxMagHints)
×
500
                , maxMagLabels(amaxMagLabels)
×
501
                , sPainter(p)
×
502
                , core(aCore)
×
503
                , checkMaxMagHints(acheckMaxMagHints)
×
504
        {
505
                angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPerRadAtCenter()*M_180_PIf;
×
506
        }
×
507
        void operator()(StelRegionObject* obj)
×
508
        {
509
                if (checkMaxMagHints)
×
510
                        return;
×
511

512
                Nebula* n = static_cast<Nebula*>(obj);
×
513
                float mag=n->getVisibilityLevelByMagnitude();
×
514

515
                StelSkyDrawer *drawer = core->getSkyDrawer();
×
516
                // filter out DSOs which are too dim to be seen (e.g. for bino observers)
517
                if ((drawer->getFlagNebulaMagnitudeLimit()) && (mag > static_cast<float>(drawer->getCustomNebulaMagnitudeLimit())))
×
518
                        return;
×
519

520
                if (!n->objectInDisplayedCatalog())
×
521
                        return;
×
522

523
                if (!n->objectInAllowedSizeRangeLimits())
×
524
                        return;
×
525

526
                if (n->majorAxisSize>angularSizeLimit || n->majorAxisSize==0.f || mag <= maxMagHints)
×
527
                {
528
                        sPainter->getProjector()->project(n->getJ2000EquatorialPos(core),n->XY);
×
529
                        n->drawLabel(*sPainter, maxMagLabels);
×
530
                        n->drawHints(*sPainter, maxMagHints, core);
×
531
                        n->drawOutlines(*sPainter, maxMagHints);
×
532
                }
533
        }
534
        float maxMagHints;
535
        float maxMagLabels;
536
        StelPainter* sPainter;
537
        StelCore* core;
538
        float angularSizeLimit;
539
        bool checkMaxMagHints;
540
};
541

542
void NebulaMgr::setCatalogFilters(int cflags)
×
543
{
544
        if(cflags != static_cast<int>(Nebula::catalogFilters))
×
545
        {
546
                Nebula::catalogFilters = static_cast<Nebula::CatalogGroup>(cflags);
×
547
                emit catalogFiltersChanged(cflags);
×
548
        }
549
}
×
550

551
void NebulaMgr::setTypeFilters(int tflags)
×
552
{
553
        if(tflags != static_cast<int>(Nebula::typeFilters))
×
554
        {
555
                Nebula::typeFilters = static_cast<Nebula::TypeGroup>(tflags);
×
556
                emit typeFiltersChanged(tflags);
×
557
        }
558
}
×
559

560
void NebulaMgr::setFlagSurfaceBrightnessUsage(const bool usage)
×
561
{
562
        if (usage!=Nebula::surfaceBrightnessUsage)
×
563
        {
564
                Nebula::surfaceBrightnessUsage=usage;
×
565
                emit flagSurfaceBrightnessUsageChanged(usage);
×
566
        }
567
}
×
568

569
bool NebulaMgr::getFlagSurfaceBrightnessUsage(void) const
×
570
{
571
        return Nebula::surfaceBrightnessUsage;
×
572
}
573

574
void NebulaMgr::setFlagSurfaceBrightnessArcsecUsage(const bool usage)
×
575
{
576
        if (usage!=Nebula::flagUseArcsecSurfaceBrightness)
×
577
        {
578
                Nebula::flagUseArcsecSurfaceBrightness=usage;
×
579
                emit flagSurfaceBrightnessArcsecUsageChanged(usage);
×
580
        }
581
}
×
582

583
bool NebulaMgr::getFlagSurfaceBrightnessArcsecUsage(void) const
×
584
{
585
        return Nebula::flagUseArcsecSurfaceBrightness;
×
586
}
587

588
void NebulaMgr::setFlagSurfaceBrightnessShortNotationUsage(const bool usage)
×
589
{
590
        if (usage!=Nebula::flagUseShortNotationSurfaceBrightness)
×
591
        {
592
                Nebula::flagUseShortNotationSurfaceBrightness=usage;
×
593
                emit flagSurfaceBrightnessShortNotationUsageChanged(usage);
×
594
        }
595
}
×
596

597
bool NebulaMgr::getFlagSurfaceBrightnessShortNotationUsage(void) const
×
598
{
599
        return Nebula::flagUseShortNotationSurfaceBrightness;
×
600
}
601

602
void NebulaMgr::setFlagSizeLimitsUsage(const bool usage)
×
603
{
604
        if (usage!=Nebula::flagUseSizeLimits)
×
605
        {
606
                Nebula::flagUseSizeLimits=usage;
×
607
                emit flagSizeLimitsUsageChanged(usage);
×
608
        }
609
}
×
610

611
bool NebulaMgr::getFlagSizeLimitsUsage(void) const
×
612
{
613
        return Nebula::flagUseSizeLimits;
×
614
}
615

616
void NebulaMgr::setFlagUseTypeFilters(const bool b)
×
617
{
618
        if (Nebula::flagUseTypeFilters!=b)
×
619
        {
620
                Nebula::flagUseTypeFilters=b;
×
621
                emit flagUseTypeFiltersChanged(b);
×
622
        }
623
}
×
624

625
bool NebulaMgr::getFlagUseTypeFilters(void) const
×
626
{
627
        return Nebula::flagUseTypeFilters;
×
628
}
629

630
void NebulaMgr::setLabelsAmount(double a)
×
631
{
632
        if((a-labelsAmount) != 0.)
×
633
        {
634
                labelsAmount=a;
×
635
                emit labelsAmountChanged(a);
×
636
        }
637
}
×
638

639
double NebulaMgr::getLabelsAmount(void) const
×
640
{
641
        return labelsAmount;
×
642
}
643

644
void NebulaMgr::setHintsAmount(double f)
×
645
{
646
        if((hintsAmount-f) != 0.)
×
647
        {
648
                hintsAmount = f;
×
649
                emit hintsAmountChanged(f);
×
650
        }
651
}
×
652

653
double NebulaMgr::getHintsAmount(void) const
×
654
{
655
        return hintsAmount;
×
656
}
657

658
void NebulaMgr::setMinSizeLimit(double s)
×
659
{
660
        if((Nebula::minSizeLimit-s) != 0.)
×
661
        {
662
                Nebula::minSizeLimit = s;
×
663
                emit minSizeLimitChanged(s);
×
664
        }
665
}
×
666

667
double NebulaMgr::getMinSizeLimit() const
×
668
{
669
        return Nebula::minSizeLimit;
×
670
}
671

672
void NebulaMgr::setMaxSizeLimit(double s)
×
673
{
674
        if((Nebula::maxSizeLimit-s) != 0.)
×
675
        {
676
                Nebula::maxSizeLimit = s;
×
677
                emit maxSizeLimitChanged(s);
×
678
        }
679
}
×
680

681
double NebulaMgr::getMaxSizeLimit() const
×
682
{
683
        return Nebula::maxSizeLimit;
×
684
}
685

686
float NebulaMgr::computeMaxMagHint(const StelSkyDrawer* skyDrawer) const
×
687
{
688
        return skyDrawer->getLimitMagnitude()*1.2f-2.f+static_cast<float>(hintsAmount *1.)-2.f;
×
689
}
690

691
// Draw all the Nebulae
692
void NebulaMgr::draw(StelCore* core)
×
693
{
694
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
695
        StelPainter sPainter(prj);
×
696

697
        StelSkyDrawer* skyDrawer = core->getSkyDrawer();
×
698

699
        Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInterstate();
×
700

701
        sPainter.setBlending(true, GL_ONE, GL_ONE);
×
702

703
        // Use a 4 degree margin (esp. for wide outlines)
704
        const float margin = 4.f*M_PI_180f*prj->getPixelPerRadAtCenter();
×
705
        const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, margin);
×
706

707
        // Print all the nebulae of all the selected zones
708
        float maxMagHints  = computeMaxMagHint(skyDrawer);
×
709
        float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+static_cast<float>(labelsAmount*1.2)-2.f;
×
710
        sPainter.setFont(nebulaFont);
×
711
        DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core, hintsFader.getInterstate()<=0.f);
×
712
        nebGrid.processIntersectingPointInRegions(p.data(), func);
×
713

714
        if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
×
715
                drawPointer(core, sPainter);
×
716
}
×
717

718
void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter)
×
719
{
720
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
×
721

722
        const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
723
        if (!newSelected.empty())
×
724
        {
725
                const StelObjectP obj = newSelected[0];
×
726
                Vec3d pos=obj->getJ2000EquatorialPos(core);
×
727

728
                // Compute 2D pos and return if outside screen
729
                if (!prj->projectInPlace(pos)) return;
×
730
                sPainter.setColor(0.4f,0.5f,0.8f);
×
731

732
                texPointer->bind();
×
733

734
                sPainter.setBlending(true);
×
735

736
                // Size on screen
737
                float screenRd = static_cast<float>(obj->getAngularRadius(core))*M_PI_180f*prj->getPixelPerRadAtCenter();
×
738
                if (screenRd>120.f) // avoid oversized marker
×
739
                        screenRd = 120.f;
×
740

741
                if (Nebula::drawHintProportional)
×
742
                        screenRd*=1.2f;
×
743
                screenRd+=20.f + 10.f*std::sin(3.f * static_cast<float>(StelApp::getInstance().getAnimationTime()));
×
744
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, 90);
×
745
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])-screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, 0);
×
746
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])+screenRd*0.5f, 10, -90);
×
747
                sPainter.drawSprite2dMode(static_cast<float>(pos[0])+screenRd*0.5f, static_cast<float>(pos[1])-screenRd*0.5f, 10, -180);
×
748
        }
×
749
}
×
750

751
// Search by name
752
NebulaP NebulaMgr::search(const QString& name)
×
753
{
754
        QString uname = name.toUpper();
×
755

756
        for (const auto& n : qAsConst(dsoArray))
×
757
        {
758
                QString testName = n->getEnglishName().toUpper();
×
759
                if (testName==uname) return n;
×
760
        }
×
761

762
        return searchByDesignation(uname);
×
763
}
×
764

765
void NebulaMgr::loadNebulaSet(const QString& setName)
×
766
{
767
        QString srcCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.txt");
×
768
        QString dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog-" + StellariumDSOCatalogVersion + ".dat");
×
769
        if (dsoCatalogPath.isEmpty()) // Extended edition is not exist, let's try find standard edition
×
770
                dsoCatalogPath        = StelFileMgr::findFile("nebulae/" + setName + "/catalog.dat");
×
771
        QString dsoOutlinesPath        = StelFileMgr::findFile("nebulae/" + setName + "/outlines.dat");
×
772
        QString dsoDiscoveryPath = StelFileMgr::findFile("nebulae/" + setName + "/discovery.dat");
×
773

774
        dsoArray.clear();
×
775
        dsoIndex.clear();
×
776
        nebGrid.clear();
×
777

778
        if (flagConverter)
×
779
        {
780
                if (!srcCatalogPath.isEmpty())
×
781
                        convertDSOCatalog(srcCatalogPath, StelFileMgr::findFile("nebulae/" + setName + "/catalog.pack", StelFileMgr::New), flagDecimalCoordinates);
×
782
                else
783
                        qWarning() << "ERROR convert catalogue, because source data set does not exist for " << setName;
×
784
        }
785

786
        if (dsoCatalogPath.isEmpty())
×
787
        {
788
                qWarning() << "ERROR while loading deep-sky catalog data set " << setName;
×
789
                return;
×
790
        }
791

792
        loadDSOCatalog(dsoCatalogPath);
×
793

794
        if (!dsoOutlinesPath.isEmpty())
×
795
                loadDSOOutlines(dsoOutlinesPath);
×
796

797
        if (!dsoDiscoveryPath.isEmpty())
×
798
                loadDSODiscoveryData(dsoDiscoveryPath);
×
799
}
×
800

801
// Look for a nebula by XYZ coords
802
NebulaP NebulaMgr::search(const Vec3d& apos)
×
803
{
804
        Vec3d pos(apos);
×
805
        pos.normalize();
×
806
        NebulaP plusProche;
×
807
        double anglePlusProche=0.0;
×
808
        for (const auto& n : qAsConst(dsoArray))
×
809
        {
810
                if (n->XYZ*pos>anglePlusProche)
×
811
                {
812
                        anglePlusProche=n->XYZ*pos;
×
813
                        plusProche=n;
×
814
                }
815
        }
816
        if (anglePlusProche>0.999) // object within ~2.5 degrees
×
817
        {
818
                return plusProche;
×
819
        }
820
        else return NebulaP();
×
821
}
×
822

823

824
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov, const StelCore*) const
×
825
{
826
        QList<StelObjectP> result;
×
827
        if (!getFlagShow())
×
828
                return result;
×
829

830
        Vec3d v(av);
×
831
        v.normalize();
×
832
        const double cosLimFov = cos(limitFov * M_PI/180.);
×
833
        Vec3d equPos;
×
834
        for (const auto& n : qAsConst(dsoArray))
×
835
        {
836
                equPos = n->XYZ;
×
837
                equPos.normalize();
×
838
                if (equPos*v >= cosLimFov)
×
839
                {
840
                        result.push_back(qSharedPointerCast<StelObject>(n));
×
841
                }
842
        }
843
        return result;
×
844
}
×
845

846
NebulaP NebulaMgr::searchDSO(unsigned int DSO) const
×
847
{
848
        if (dsoIndex.contains(DSO))
×
849
                return dsoIndex[DSO];
×
850
        return NebulaP();
×
851
}
852

853

854
NebulaP NebulaMgr::searchM(unsigned int M) const
×
855
{
856
        for (const auto& n : dsoArray)
×
857
                if (n->M_nb == M)
×
858
                        return n;
×
859
        return NebulaP();
×
860
}
861

862
NebulaP NebulaMgr::searchNGC(unsigned int NGC) const
×
863
{
864
        for (const auto& n : dsoArray)
×
865
                if (n->NGC_nb == NGC)
×
866
                        return n;
×
867
        return NebulaP();
×
868
}
869

870
NebulaP NebulaMgr::searchIC(unsigned int IC) const
×
871
{
872
        for (const auto& n : dsoArray)
×
873
                if (n->IC_nb == IC)
×
874
                        return n;
×
875
        return NebulaP();
×
876
}
877

878
NebulaP NebulaMgr::searchC(unsigned int C) const
×
879
{
880
        for (const auto& n : dsoArray)
×
881
                if (n->C_nb == C)
×
882
                        return n;
×
883
        return NebulaP();
×
884
}
885

886
NebulaP NebulaMgr::searchB(unsigned int B) const
×
887
{
888
        for (const auto& n : dsoArray)
×
889
                if (n->B_nb == B)
×
890
                        return n;
×
891
        return NebulaP();
×
892
}
893

894
NebulaP NebulaMgr::searchSh2(unsigned int Sh2) const
×
895
{
896
        for (const auto& n : dsoArray)
×
897
                if (n->Sh2_nb == Sh2)
×
898
                        return n;
×
899
        return NebulaP();
×
900
}
901

902
NebulaP NebulaMgr::searchVdB(unsigned int VdB) const
×
903
{
904
        for (const auto& n : dsoArray)
×
905
                if (n->VdB_nb == VdB)
×
906
                        return n;
×
907
        return NebulaP();
×
908
}
909

910
NebulaP NebulaMgr::searchVdBHa(unsigned int VdBHa) const
×
911
{
912
        for (const auto& n : dsoArray)
×
913
                if (n->VdBHa_nb == VdBHa)
×
914
                        return n;
×
915
        return NebulaP();
×
916
}
917

918
NebulaP NebulaMgr::searchRCW(unsigned int RCW) const
×
919
{
920
        for (const auto& n : dsoArray)
×
921
                if (n->RCW_nb == RCW)
×
922
                        return n;
×
923
        return NebulaP();
×
924
}
925

926
NebulaP NebulaMgr::searchLDN(unsigned int LDN) const
×
927
{
928
        for (const auto& n : dsoArray)
×
929
                if (n->LDN_nb == LDN)
×
930
                        return n;
×
931
        return NebulaP();
×
932
}
933

934
NebulaP NebulaMgr::searchLBN(unsigned int LBN) const
×
935
{
936
        for (const auto& n : dsoArray)
×
937
                if (n->LBN_nb == LBN)
×
938
                        return n;
×
939
        return NebulaP();
×
940
}
941

942
NebulaP NebulaMgr::searchCr(unsigned int Cr) const
×
943
{
944
        for (const auto& n : dsoArray)
×
945
                if (n->Cr_nb == Cr)
×
946
                        return n;
×
947
        return NebulaP();
×
948
}
949

950
NebulaP NebulaMgr::searchMel(unsigned int Mel) const
×
951
{
952
        for (const auto& n : dsoArray)
×
953
                if (n->Mel_nb == Mel)
×
954
                        return n;
×
955
        return NebulaP();
×
956
}
957

958
NebulaP NebulaMgr::searchPGC(unsigned int PGC) const
×
959
{
960
        for (const auto& n : dsoArray)
×
961
                if (n->PGC_nb == PGC)
×
962
                        return n;
×
963
        return NebulaP();
×
964
}
965

966
NebulaP NebulaMgr::searchUGC(unsigned int UGC) const
×
967
{
968
        for (const auto& n : dsoArray)
×
969
                if (n->UGC_nb == UGC)
×
970
                        return n;
×
971
        return NebulaP();
×
972
}
973

974
NebulaP NebulaMgr::searchCed(QString Ced) const
×
975
{
976
        for (const auto& n : dsoArray)
×
977
                if (n->Ced_nb.trimmed().toUpper() == Ced.trimmed().toUpper())
×
978
                        return n;
×
979
        return NebulaP();
×
980
}
981

982
NebulaP NebulaMgr::searchArp(unsigned int Arp) const
×
983
{
984
        for (const auto& n : dsoArray)
×
985
                if (n->Arp_nb == Arp)
×
986
                        return n;
×
987
        return NebulaP();
×
988
}
989

990
NebulaP NebulaMgr::searchVV(unsigned int VV) const
×
991
{
992
        for (const auto& n : dsoArray)
×
993
                if (n->VV_nb == VV)
×
994
                        return n;
×
995
        return NebulaP();
×
996
}
997

998
NebulaP NebulaMgr::searchPK(QString PK) const
×
999
{
1000
        for (const auto& n : dsoArray)
×
1001
                if (n->PK_nb.trimmed().toUpper() == PK.trimmed().toUpper())
×
1002
                        return n;
×
1003
        return NebulaP();
×
1004
}
1005

1006
NebulaP NebulaMgr::searchPNG(QString PNG) const
×
1007
{
1008
        for (const auto& n : dsoArray)
×
1009
                if (n->PNG_nb.trimmed().toUpper() == PNG.trimmed().toUpper())
×
1010
                        return n;
×
1011
        return NebulaP();
×
1012
}
1013

1014
NebulaP NebulaMgr::searchSNRG(QString SNRG) const
×
1015
{
1016
        for (const auto& n : dsoArray)
×
1017
                if (n->SNRG_nb.trimmed().toUpper() == SNRG.trimmed().toUpper())
×
1018
                        return n;
×
1019
        return NebulaP();
×
1020
}
1021

1022
NebulaP NebulaMgr::searchACO(QString ACO) const
×
1023
{
1024
        for (const auto& n : dsoArray)
×
1025
                if (n->ACO_nb.trimmed().toUpper() == ACO.trimmed().toUpper())
×
1026
                        return n;
×
1027
        return NebulaP();
×
1028
}
1029

1030
NebulaP NebulaMgr::searchHCG(QString HCG) const
×
1031
{
1032
        for (const auto& n : dsoArray)
×
1033
                if (n->HCG_nb.trimmed().toUpper() == HCG.trimmed().toUpper())
×
1034
                        return n;
×
1035
        return NebulaP();
×
1036
}
1037

1038
NebulaP NebulaMgr::searchESO(QString ESO) const
×
1039
{
1040
        for (const auto& n : dsoArray)
×
1041
                if (n->ESO_nb.trimmed().toUpper() == ESO.trimmed().toUpper())
×
1042
                        return n;
×
1043
        return NebulaP();
×
1044
}
1045

1046
NebulaP NebulaMgr::searchVdBH(QString VdBH) const
×
1047
{
1048
        for (const auto& n : dsoArray)
×
1049
                if (n->VdBH_nb.trimmed().toUpper() == VdBH.trimmed().toUpper())
×
1050
                        return n;
×
1051
        return NebulaP();
×
1052
}
1053

1054
NebulaP NebulaMgr::searchDWB(unsigned int DWB) const
×
1055
{
1056
        for (const auto& n : dsoArray)
×
1057
                if (n->DWB_nb == DWB)
×
1058
                        return n;
×
1059
        return NebulaP();
×
1060
}
1061

1062
NebulaP NebulaMgr::searchTr(unsigned int Tr) const
×
1063
{
1064
        for (const auto& n : dsoArray)
×
1065
                if (n->Tr_nb == Tr)
×
1066
                        return n;
×
1067
        return NebulaP();
×
1068
}
1069

1070
NebulaP NebulaMgr::searchSt(unsigned int St) const
×
1071
{
1072
        for (const auto& n : dsoArray)
×
1073
                if (n->St_nb == St)
×
1074
                        return n;
×
1075
        return NebulaP();
×
1076
}
1077

1078
NebulaP NebulaMgr::searchRu(unsigned int Ru) const
×
1079
{
1080
        for (const auto& n : dsoArray)
×
1081
                if (n->Ru_nb == Ru)
×
1082
                        return n;
×
1083
        return NebulaP();
×
1084
}
1085

1086
QString NebulaMgr::getLatestSelectedDSODesignation() const
×
1087
{
1088
        QString result = "";
×
1089

1090
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1091
        if (!selected.empty())
×
1092
        {
1093
                for (const auto& n : dsoArray)
×
1094
                        if (n==selected[0])
×
1095
                                result = n->getDSODesignation(); // Get designation for latest selected DSO
×
1096
        }
1097

1098
        return result;
×
1099
}
×
1100

1101
QString NebulaMgr::getLatestSelectedDSODesignationWIC() const
×
1102
{
1103
        QString result = "";
×
1104

1105
        const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
×
1106
        if (!selected.empty())
×
1107
        {
1108
                for (const auto& n : dsoArray)
×
1109
                        if (n==selected[0])
×
1110
                                result = n->getDSODesignationWIC(); // Get designation for latest selected DSO
×
1111
        }
1112

1113
        return result;
×
1114
}
×
1115

1116
void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bool decimal=false)
×
1117
{
1118
        QFile dsoIn(in);
×
1119
        if (!dsoIn.open(QIODevice::ReadOnly | QIODevice::Text))
×
1120
                return;
×
1121

1122
        QFile dsoOut(out);
×
1123
        if (!dsoOut.open(QIODevice::WriteOnly))
×
1124
        {
1125
                qDebug() << "Error converting DSO data! Cannot open file" << QDir::toNativeSeparators(out);
×
1126
                return;
×
1127
        }
1128

1129
        int totalRecords=0;
×
1130
        QString record;
×
1131
        while (!dsoIn.atEnd())
×
1132
        {
1133
                dsoIn.readLine();
×
1134
                ++totalRecords;
×
1135
        }
1136

1137
        // rewind the file to the start
1138
        dsoIn.seek(0);
×
1139

1140
        QDataStream dsoOutStream(&dsoOut);
×
1141
        dsoOutStream.setVersion(QDataStream::Qt_5_2);
×
1142

1143
        int        id, orientationAngle, NGC, IC, M, C, B, Sh2, VdB, RCW, LDN, LBN, Cr, Mel, PGC, UGC, Arp, VV, DWB, Tr, St, Ru, VdBHa;
1144
        float        raRad, decRad, bMag, vMag, majorAxisSize, minorAxisSize, dist, distErr, z, zErr, plx, plxErr;
1145
        QString oType, mType, Ced, PK, PNG, SNRG, ACO, HCG, ESO, VdBH, ra, dec;
×
1146
        Nebula::NebulaType nType;
1147

1148
        int readOk = 0;                                // how many records were read without problems
×
1149
        while (!dsoIn.atEnd())
×
1150
        {
1151
                record = QString::fromUtf8(dsoIn.readLine());
×
1152

1153
                static const QRegularExpression version("ersion\\s+([\\d\\.]+)\\s+(\\w+)");
×
1154
                QRegularExpressionMatch versionMatch;
×
1155
                int vp = record.indexOf(version, 0, &versionMatch);
×
1156
                if (vp!=-1) // Version of catalog, a first line!
×
1157
                        dsoOutStream << versionMatch.captured(1).trimmed() << versionMatch.captured(2).trimmed();
×
1158

1159
                // skip comments
1160
                if (record.startsWith("//") || record.startsWith("#"))
×
1161
                {
1162
                        --totalRecords;
×
1163
                        continue;
×
1164
                }
1165

1166
                if (!record.isEmpty())
×
1167
                {
1168
                        #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
1169
                        QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1170
                        #else
1171
                        QStringList list=record.split("\t", QString::KeepEmptyParts);
1172
                        #endif
1173

1174
                        id                                = list.at(0).toInt();                // ID (inner identification number)
×
1175
                        ra                                = list.at(1).trimmed();
×
1176
                        dec                                = list.at(2).trimmed();
×
1177
                        bMag                        = list.at(3).toFloat();                // B magnitude
×
1178
                        vMag                        = list.at(4).toFloat();                // V magnitude
×
1179
                        oType                        = list.at(5).trimmed();                // Object type
×
1180
                        mType                        = list.at(6).trimmed();                // Morphological type of object
×
1181
                        majorAxisSize                = list.at(7).toFloat();                // major axis size (arcmin)
×
1182
                        minorAxisSize                = list.at(8).toFloat();                // minor axis size (arcmin)
×
1183
                        orientationAngle        = list.at(9).toInt();                // orientation angle (degrees)
×
1184
                        z                                = list.at(10).toFloat();        // redshift
×
1185
                        zErr                                = list.at(11).toFloat();        // error of redshift
×
1186
                        plx                                = list.at(12).toFloat();        // parallax (mas)
×
1187
                        plxErr                        = list.at(13).toFloat();        // error of parallax (mas)
×
1188
                        dist                                = list.at(14).toFloat();        // distance (Mpc for galaxies, kpc for other objects)
×
1189
                        distErr                        = list.at(15).toFloat();        // distance error (Mpc for galaxies, kpc for other objects)
×
1190
                        // -----------------------------------------------
1191
                        // cross-identification data
1192
                        // -----------------------------------------------
1193
                        NGC                                = list.at(16).toInt();                // NGC number
×
1194
                        IC                                = list.at(17).toInt();                // IC number
×
1195
                        M                                = list.at(18).toInt();                // M number
×
1196
                        C                                = list.at(19).toInt();                // C number
×
1197
                        B                                = list.at(20).toInt();                // B number
×
1198
                        Sh2                                = list.at(21).toInt();                // Sh2 number
×
1199
                        VdB                                = list.at(22).toInt();                // VdB number
×
1200
                        RCW                                = list.at(23).toInt();                // RCW number
×
1201
                        LDN                                = list.at(24).toInt();                // LDN number
×
1202
                        LBN                                = list.at(25).toInt();                // LBN number
×
1203
                        Cr                                = list.at(26).toInt();                // Cr number (alias: Col)
×
1204
                        Mel                                = list.at(27).toInt();                // Mel number
×
1205
                        PGC                                = list.at(28).toInt();                // PGC number (subset)
×
1206
                        UGC                                = list.at(29).toInt();                // UGC number (subset)
×
1207
                        Ced                                = list.at(30).trimmed();        // Ced number
×
1208
                        Arp                                = list.at(31).toInt();                // Arp number
×
1209
                        VV                                = list.at(32).toInt();                // VV number
×
1210
                        PK                                = list.at(33).trimmed();        // PK number
×
1211
                        PNG                                = list.at(34).trimmed();        // PN G number
×
1212
                        SNRG                        = list.at(35).trimmed();        // SNR G number
×
1213
                        ACO                                = list.at(36).trimmed();        // ACO number
×
1214
                        HCG                                = list.at(37).trimmed();        // HCG number
×
1215
                        ESO                                = list.at(38).trimmed();        // ESO number
×
1216
                        VdBH                        = list.at(39).trimmed();        // VdBH number
×
1217
                        DWB                                = list.at(40).toInt();                // DWB number
×
1218
                        Tr                                = list.at(41).toInt();                // Tr number
×
1219
                        St                                = list.at(42).toInt();                // St number
×
1220
                        Ru                                = list.at(43).toInt();                // Ru number
×
1221
                        VdBHa                        = list.at(44).toInt();                // VdB-Ha number
×
1222

1223
                        if (decimal)
×
1224
                        {
1225
                                // Convert from deg to rad
1226
                                raRad        = ra.toFloat() *M_PI_180f;
×
1227
                                decRad        = dec.toFloat()*M_PI_180f;
×
1228
                        }
1229
                        else
1230
                        {
1231
                                QStringList raLst;
×
1232
                                if (ra.contains(":"))
×
1233
                                        raLst        = ra.split(":");
×
1234
                                else
1235
                                        raLst        = ra.split(" ");
×
1236

1237
                                QStringList decLst;
×
1238
                                if (dec.contains(":"))
×
1239
                                        decLst = dec.split(":");
×
1240
                                else
1241
                                        decLst = dec.split(" ");
×
1242

1243
                                raRad        = raLst.at(0).toFloat() + raLst.at(1).toFloat()/60.f + raLst.at(2).toFloat()/3600.f;
×
1244
                                decRad        = qAbs(decLst.at(0).toFloat()) + decLst.at(1).toFloat()/60.f + decLst.at(2).toFloat()/3600.f;
×
1245
                                if (dec.startsWith("-")) decRad *= -1.f;
×
1246

1247
                                raRad  *= M_PIf/12.f;        // Convert from hours to rad
×
1248
                                decRad *= M_PIf/180.f;    // Convert from deg to rad
×
1249
                        }
×
1250

1251
                        majorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1252
                        minorAxisSize /= 60.f;        // Convert from arcmin to degrees
×
1253

1254
                        // Warning: Hyades and LMC has visual magnitude less than 1.0 (0.5^m and 0.9^m)
1255
                        if (bMag <= 0.f) bMag = 99.f;
×
1256
                        if (vMag <= 0.f) vMag = 99.f;
×
1257
                        // TODO: The map could be sorted by probability (number of total objects). More common objects at start...
1258
                        static const QMap<QString, Nebula::NebulaType> oTypesMap = {
1259
                                { "G"   , Nebula::NebGx  },
×
1260
                                { "GX"  , Nebula::NebGx  },
×
1261
                                { "GC"  , Nebula::NebGc  },
×
1262
                                { "OC"  , Nebula::NebOc  },
×
1263
                                { "NB"  , Nebula::NebN   },
×
1264
                                { "PN"  , Nebula::NebPn  },
×
1265
                                { "DN"  , Nebula::NebDn  },
×
1266
                                { "RN"  , Nebula::NebRn  },
×
1267
                                { "C+N" , Nebula::NebCn  },
×
1268
                                { "RNE" , Nebula::NebRn  },
×
1269
                                { "HII" , Nebula::NebHII },
×
1270
                                { "SNR" , Nebula::NebSNR },
×
1271
                                { "BN"  , Nebula::NebBn  },
×
1272
                                { "EN"  , Nebula::NebEn  },
×
1273
                                { "SA"  , Nebula::NebSA  },
×
1274
                                { "SC"  , Nebula::NebSC  },
×
1275
                                { "CL"  , Nebula::NebCl  },
×
1276
                                { "IG"  , Nebula::NebIGx },
×
1277
                                { "RG"  , Nebula::NebRGx },
×
1278
                                { "AGX" , Nebula::NebAGx },
×
1279
                                { "QSO" , Nebula::NebQSO },
×
1280
                                { "ISM" , Nebula::NebISM },
×
1281
                                { "EMO" , Nebula::NebEMO },
×
1282
                                { "GNE" , Nebula::NebHII },
×
1283
                                { "RAD" , Nebula::NebISM },
×
1284
                                { "LIN" , Nebula::NebAGx },// LINER-type active galaxies
×
1285
                                { "BLL" , Nebula::NebBLL },
×
1286
                                { "BLA" , Nebula::NebBLA },
×
1287
                                { "MOC" , Nebula::NebMolCld },
×
1288
                                { "YSO" , Nebula::NebYSO },
×
1289
                                { "Q?"  , Nebula::NebPossQSO },
×
1290
                                { "PN?" , Nebula::NebPossPN },
×
1291
                                { "*"   , Nebula::NebStar},
×
1292
                                { "SFR" , Nebula::NebMolCld },
×
1293
                                { "IR"  , Nebula::NebDn  },
×
1294
                                { "**"  , Nebula::NebStar},
×
1295
                                { "MUL" , Nebula::NebStar},
×
1296
                                { "PPN" , Nebula::NebPPN },
×
1297
                                { "GIG" , Nebula::NebIGx },
×
1298
                                { "OPC" , Nebula::NebOc  },
×
1299
                                { "MGR" , Nebula::NebSA  },
×
1300
                                { "IG2" , Nebula::NebIGx },
×
1301
                                { "IG3" , Nebula::NebIGx },
×
1302
                                { "SY*" , Nebula::NebSymbioticStar},
×
1303
                                { "PA*" , Nebula::NebPPN },
×
1304
                                { "CV*" , Nebula::NebStar},
×
1305
                                { "Y*?" , Nebula::NebYSO },
×
1306
                                { "CGB" , Nebula::NebISM },
×
1307
                                { "SNRG", Nebula::NebSNR },
×
1308
                                { "Y*O" , Nebula::NebYSO },
×
1309
                                { "SR*" , Nebula::NebStar},
×
1310
                                { "EM*" , Nebula::NebEmissionLineStar },
×
1311
                                { "AB*" , Nebula::NebStar },
×
1312
                                { "MI*" , Nebula::NebStar },
×
1313
                                { "MI?" , Nebula::NebStar },
×
1314
                                { "TT*" , Nebula::NebStar },
×
1315
                                { "WR*" , Nebula::NebStar },
×
1316
                                { "C*"  , Nebula::NebEmissionLineStar },
×
1317
                                { "WD*" , Nebula::NebStar },
×
1318
                                { "EL*" , Nebula::NebStar },
×
1319
                                { "NL*" , Nebula::NebStar },
×
1320
                                { "NO*" , Nebula::NebStar },
×
1321
                                { "HS*" , Nebula::NebStar },
×
1322
                                { "LP*" , Nebula::NebStar },
×
1323
                                { "OH*" , Nebula::NebStar },
×
1324
                                { "S?R" , Nebula::NebStar },
×
1325
                                { "IR*" , Nebula::NebStar },
×
1326
                                { "POC" , Nebula::NebMolCld },
×
1327
                                { "PNB" , Nebula::NebPn   },
×
1328
                                { "GXCL", Nebula::NebGxCl },
×
1329
                                { "AL*" , Nebula::NebStar },
×
1330
                                { "PR*" , Nebula::NebStar },
×
1331
                                { "RS*" , Nebula::NebStar },
×
1332
                                { "S*B" , Nebula::NebStar },
×
1333
                                { "SN?" , Nebula::NebSNC  },
×
1334
                                { "SR?" , Nebula::NebSNRC },
×
1335
                                { "DNE" , Nebula::NebDn   },
×
1336
                                { "RG*" , Nebula::NebStar },
×
1337
                                { "PSR" , Nebula::NebSNR  },
×
1338
                                { "HH"  , Nebula::NebISM  },
×
1339
                                { "V*"  , Nebula::NebStar },
×
1340
                                { "*IN"  , Nebula::NebCn },
×
1341
                                { "SN*"  , Nebula::NebStar },
×
1342
                                { "PA?" , Nebula::NebPPN  },
×
1343
                                { "BUB" , Nebula::NebISM  },
×
1344
                                { "CLG" , Nebula::NebGxCl },
×
1345
                                { "POG" , Nebula::NebPartOfGx },
×
1346
                                { "CGG" , Nebula::NebGxCl },
×
1347
                                { "SCG" , Nebula::NebGxCl },
×
1348
                                { "REG" , Nebula::NebRegion },
×
1349
                                { "?" , Nebula::NebUnknown }
×
1350
                        };
×
1351

1352
                        nType=oTypesMap.value(oType.toUpper(), Nebula::NebUnknown);
×
1353
                        if (nType == Nebula::NebUnknown)
×
1354
                                qDebug() << "Record with ID" << id <<"has unknown type of object:" << oType;
×
1355

1356
                        ++readOk;
×
1357

1358
                        dsoOutStream << id << raRad << decRad << bMag << vMag << static_cast<unsigned int>(nType) << mType << majorAxisSize << minorAxisSize
×
1359
                                     << orientationAngle << z << zErr << plx << plxErr << dist  << distErr << NGC << IC << M << C
×
1360
                                     << B << Sh2 << VdB << RCW  << LDN << LBN << Cr << Mel << PGC << UGC << Ced << Arp << VV << PK
×
1361
                                     << PNG << SNRG << ACO << HCG << ESO << VdBH << DWB << Tr << St << Ru << VdBHa;
×
1362
                }
×
1363
        }
×
1364
        dsoIn.close();
×
1365
        dsoOut.flush();
×
1366
        dsoOut.close();
×
1367
        qDebug().noquote() << "Converted" << readOk << "/" << totalRecords << "DSO records";
×
1368
        qDebug().noquote() << "[...] Please use 'gzip -nc catalog.pack > catalog.dat' to pack the catalog.";
×
1369
}
×
1370

1371
bool NebulaMgr::loadDSOCatalog(const QString &filename)
×
1372
{
1373
        QFile in(filename);
×
1374
        if (!in.open(QIODevice::ReadOnly))
×
1375
                return false;
×
1376

1377
        qDebug().noquote() << "Loading DSO data ...";
×
1378

1379
        // Let's begin use gzipped data
1380
        QDataStream ins(StelUtils::uncompress(in.readAll()));
×
1381
        ins.setVersion(QDataStream::Qt_5_2);
×
1382

1383
        QString version = "", edition= "";
×
1384
        int totalRecords=0;
×
1385
        while (!ins.atEnd())
×
1386
        {
1387
                if (totalRecords==0) // Read the version of catalog
×
1388
                {
1389
                        ins >> version >> edition;
×
1390
                        if (version.isEmpty())
×
1391
                                version = "3.1"; // The first version of extended edition of the catalog
×
1392
                        if (edition.isEmpty())
×
1393
                                edition = "unknown";
×
1394
                        qDebug().noquote() << "[...]" << QString("Stellarium DSO Catalog, version %1 (%2 edition)").arg(version, edition);
×
1395
                        if (StelUtils::compareVersions(version, StellariumDSOCatalogVersion)!=0)
×
1396
                        {
1397
                                ++totalRecords;
×
1398
                                qDebug().noquote() << "WARNING: Mismatch of DSO catalog version (" << version << ")! The expected version is" << StellariumDSOCatalogVersion;
×
1399
                                qDebug().noquote() << "         See section 5.5 of the User Guide and install the right version of the catalog!";
×
1400
                                QMessageBox::warning(Q_NULLPTR, q_("Attention!"), QString("%1. %2: %3 - %4: %5. %6").arg(q_("DSO catalog version mismatch"),  q_("Found"), version, q_("Expected"), StellariumDSOCatalogVersion, q_("See Logfile for instructions.")), QMessageBox::Ok);
×
1401
                                break;
×
1402
                        }
1403
                }
1404
                else
1405
                {
1406
                        // Create a new Nebula record
1407
                        NebulaP e = NebulaP(new Nebula);
×
1408
                        e->readDSO(ins);
×
1409

1410
                        dsoArray.append(e);
×
1411
                        nebGrid.insert(qSharedPointerCast<StelRegionObject>(e));
×
1412
                        if (e->DSO_nb!=0)
×
1413
                                dsoIndex.insert(e->DSO_nb, e);
×
1414
                }
×
1415
                ++totalRecords;
×
1416
        }
1417
        in.close();
×
1418
        qDebug().noquote() << "Loaded" << --totalRecords << "DSO records";
×
1419
        return true;
×
1420
}
×
1421

1422
bool NebulaMgr::loadDSONames(const QString &filename)
×
1423
{
1424
        qDebug() << "Loading DSO name data ...";
×
1425
        QFile dsoNameFile(filename);
×
1426
        if (!dsoNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1427
        {
1428
                qWarning().noquote() << "DSO name data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1429
                return false;
×
1430
        }
1431

1432
        // Read the names of the deep-sky objects
1433
        QString name, record, ref, cdes;
×
1434
        QStringList nodata;
×
1435
        nodata.clear();
×
1436
        int totalRecords=0;
×
1437
        int readOk=0;
×
1438
        unsigned int nb;
1439
        NebulaP e;
×
1440
        static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1441
        while (!dsoNameFile.atEnd())
×
1442
        {
1443
                record = QString::fromUtf8(dsoNameFile.readLine());
×
1444
                if (commentRx.match(record).hasMatch())
×
1445
                        continue;
×
1446

1447
                totalRecords++;
×
1448

1449
                // bytes 1 - 5, designator for catalogue (prefix)
1450
                ref  = record.left(5).trimmed();
×
1451
                // bytes 6 -20, identificator for object in the catalog
1452
                cdes = record.mid(5, 15).trimmed().toUpper();
×
1453
                // bytes 21-80, proper name of the object (translatable)
1454
                name = record.mid(21).trimmed(); // Let gets the name with trimmed whitespaces
×
1455

1456
                nb = cdes.toUInt();
×
1457

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

1463
                switch (catalogs.indexOf(ref.toUpper()))
×
1464
                {
1465
                        case 0:
×
1466
                                e = searchIC(nb);
×
1467
                                break;
×
1468
                        case 1:
×
1469
                                e = searchM(nb);
×
1470
                                break;
×
1471
                        case 2:
×
1472
                                e = searchC(nb);
×
1473
                                break;
×
1474
                        case 3:
×
1475
                                e = searchCr(nb);
×
1476
                                break;
×
1477
                        case 4:
×
1478
                                e = searchMel(nb);
×
1479
                                break;
×
1480
                        case 5:
×
1481
                                e = searchB(nb);
×
1482
                                break;
×
1483
                        case 6:
×
1484
                                e = searchSh2(nb);
×
1485
                                break;
×
1486
                        case 7:
×
1487
                                e = searchVdB(nb);
×
1488
                                break;
×
1489
                        case 8:
×
1490
                                e = searchRCW(nb);
×
1491
                                break;
×
1492
                        case 9:
×
1493
                                e = searchLDN(nb);
×
1494
                                break;
×
1495
                        case 10:
×
1496
                                e = searchLBN(nb);
×
1497
                                break;
×
1498
                        case 11:
×
1499
                                e = searchNGC(nb);
×
1500
                                break;
×
1501
                        case 12:
×
1502
                                e = searchPGC(nb);
×
1503
                                break;
×
1504
                        case 13:
×
1505
                                e = searchUGC(nb);
×
1506
                                break;
×
1507
                        case 14:
×
1508
                                e = searchCed(cdes);
×
1509
                                break;
×
1510
                        case 15:
×
1511
                                e = searchArp(nb);
×
1512
                                break;
×
1513
                        case 16:
×
1514
                                e = searchVV(nb);
×
1515
                                break;
×
1516
                        case 17:
×
1517
                                e = searchPK(cdes);
×
1518
                                break;
×
1519
                        case 18:
×
1520
                                e = searchPNG(cdes);
×
1521
                                break;
×
1522
                        case 19:
×
1523
                                e = searchSNRG(cdes);
×
1524
                                break;
×
1525
                        case 20:
×
1526
                                e = searchACO(cdes);
×
1527
                                break;
×
1528
                        case 21:
×
1529
                                e = searchHCG(cdes);
×
1530
                                break;
×
1531
                        case 22:
×
1532
                                e = searchESO(cdes);
×
1533
                                break;
×
1534
                        case 23:
×
1535
                                e = searchVdBH(cdes);
×
1536
                                break;
×
1537
                        case 24:
×
1538
                                e = searchDWB(nb);
×
1539
                                break;
×
1540
                        case 25:
×
1541
                                e = searchTr(nb);
×
1542
                                break;
×
1543
                        case 26:
×
1544
                                e = searchSt(nb);
×
1545
                                break;
×
1546
                        case 27:
×
1547
                                e = searchRu(nb);
×
1548
                                break;
×
1549
                        case 28:
×
1550
                                e = searchVdBHa(nb);
×
1551
                                break;
×
1552
                        default:
×
1553
                                e = searchDSO(nb);
×
1554
                                break;
×
1555
                }
1556

1557
                if (!e.isNull())
×
1558
                {
1559
                        static const QRegularExpression transRx("_[(]\"(.*)\"[)](\\s*#.*)?"); // optional comments after name.
×
1560
                        QRegularExpressionMatch transMatch=transRx.match(name);
×
1561
                        if (transMatch.hasMatch())
×
1562
                        {
1563
                                QString propName = transMatch.captured(1).trimmed();
×
1564
                                QString currName = e->getEnglishName();
×
1565
                                if (currName.isEmpty())
×
1566
                                        e->setProperName(propName);
×
1567
                                else if (currName!=propName)
×
1568
                                        e->addNameAlias(propName);
×
1569
                        }
×
1570
                        readOk++;
×
1571
                }
×
1572
                else
1573
                        nodata.append(QString("%1 %2").arg(ref.trimmed(), cdes.trimmed()));
×
1574
        }
1575
        dsoNameFile.close();
×
1576
        qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO name records successfully";
×
1577

1578
        int err = nodata.size();
×
1579
        if (err>0)
×
1580
                qDebug().noquote() << "WARNING - No position data for" << err << "objects:" << nodata.join(", ");
×
1581

1582
        return true;
×
1583
}
×
1584

1585
bool NebulaMgr::loadDSODiscoveryData(const QString &filename)
×
1586
{
1587
        qDebug() << "Loading DSO discovery data ...";
×
1588
        QFile dsoDiscoveryFile(filename);
×
1589
        if (!dsoDiscoveryFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1590
        {
1591
                qWarning().noquote() << "DSO discovery data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1592
                return false;
×
1593
        }
1594

1595
        int readOk = 0;
×
1596
        int totalRecords = 0;
×
1597
        QString record, dso, dYear, dName;
×
1598
        NebulaP e;
×
1599
        while (!dsoDiscoveryFile.atEnd())
×
1600
        {
1601
                record = QString::fromUtf8(dsoDiscoveryFile.readLine());
×
1602
                if (record.startsWith("//") || record.startsWith("#") || record.isEmpty())
×
1603
                        continue;
×
1604

1605
                totalRecords++;
×
1606
                #if (QT_VERSION>=QT_VERSION_CHECK(5, 14, 0))
1607
                QStringList list=record.split("\t", Qt::KeepEmptyParts);
×
1608
                #else
1609
                QStringList list=record.split("\t", QString::KeepEmptyParts);
1610
                #endif
1611

1612
                dso        = list.at(0).trimmed();
×
1613
                dYear        = list.at(1).trimmed();
×
1614
                dName        = list.at(2).trimmed();
×
1615

1616
                e = search(dso);
×
1617
                if (e.isNull()) // maybe this is inner number of DSO
×
1618
                        e = searchDSO(dso.toUInt());
×
1619

1620
                if (!e.isNull())
×
1621
                {
1622
                        e->setDiscoveryData(dName, dYear);
×
1623
                        readOk++;
×
1624
                }
1625
        }
×
1626
        dsoDiscoveryFile.close();
×
1627
        qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO discovery records successfully";
×
1628
        return true;
×
1629
}
×
1630

1631
bool NebulaMgr::loadDSOOutlines(const QString &filename)
×
1632
{
1633
        qDebug() << "Loading DSO outline data ...";
×
1634
        QFile dsoOutlineFile(filename);
×
1635
        if (!dsoOutlineFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1636
        {
1637
                qWarning().noquote() << "DSO outline data file" << QDir::toNativeSeparators(filename) << "not found.";
×
1638
                return false;
×
1639
        }
1640

1641
        double RA, DE;
1642
        int i, readOk = 0;
×
1643
        Vec3d XYZ;
×
1644
        std::vector<Vec3d> *points = Q_NULLPTR;
×
1645
        typedef QPair<double, double> coords;
1646
        coords point, fpoint;
×
1647
        QVector<coords> outline;
×
1648
        QString record, command, dso;
×
1649
        NebulaP e;
×
1650
        // Read the outlines data of the DSO
1651
        static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1652
        while (!dsoOutlineFile.atEnd())
×
1653
        {
1654
                record = QString::fromUtf8(dsoOutlineFile.readLine());
×
1655
                if (commentRx.match(record).hasMatch())
×
1656
                        continue;
×
1657

1658
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
1659
                // bytes 1 - 8, RA
1660
                RA = record.first(8).toDouble();
1661
                // bytes 9 -18, DE
1662
                DE = record.sliced(9, 10).toDouble();
1663
#else
1664
                // bytes 1 - 8, RA
1665
                RA = record.leftRef(8).toDouble();
×
1666
                // bytes 9 -18, DE
1667
                DE = record.midRef(9, 10).toDouble();
×
1668
#endif
1669
                // bytes 19-25, command
1670
                command = record.mid(19, 7).trimmed();
×
1671
                // bytes 26, designation of DSO
1672
                dso = record.mid(26).trimmed();
×
1673

1674
                RA*=M_PI/12.;     // Convert from hours to rad
×
1675
                DE*=M_PI/180.;    // Convert from deg to rad
×
1676

1677
                if (command.contains("start", Qt::CaseInsensitive))
×
1678
                {
1679
                        outline.clear();
×
1680
                        e = search(dso);
×
1681
                        if (e.isNull()) // maybe this is inner number of DSO
×
1682
                                e = searchDSO(dso.toUInt());
×
1683

1684
                        point.first  = RA;
×
1685
                        point.second = DE;
×
1686
                        outline.append(point);
×
1687
                        fpoint = point;
×
1688
                }
1689

1690
                if (command.contains("vertex", Qt::CaseInsensitive))
×
1691
                {
1692
                        point.first  = RA;
×
1693
                        point.second = DE;
×
1694
                        outline.append(point);
×
1695
                }
1696

1697
                if (command.contains("end", Qt::CaseInsensitive))
×
1698
                {
1699
                        point.first  = RA;
×
1700
                        point.second = DE;
×
1701
                        outline.append(point);
×
1702
                        outline.append(fpoint);
×
1703

1704
                        if (!e.isNull())
×
1705
                        {
1706
                                points = new std::vector<Vec3d>;
×
1707
                                for (i = 0; i < outline.size(); i++)
×
1708
                                {
1709
                                        // Calc the Cartesian coord with RA and DE
1710
                                        point = outline.at(i);
×
1711
                                        StelUtils::spheToRect(point.first, point.second, XYZ);
×
1712
                                        points->push_back(XYZ);
×
1713
                                }
1714

1715
                                e->outlineSegments.push_back(points);
×
1716
                        }
1717
                        readOk++;
×
1718
                }
1719
        }
1720
        dsoOutlineFile.close();
×
1721
        qDebug().noquote() << "Loaded" << readOk << "DSO outline records successfully";
×
1722
        return true;
×
1723
}
×
1724

1725
void NebulaMgr::updateSkyCulture(const QString& skyCultureDir)
×
1726
{
1727
        QString namesFile = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/dso_names.fab");
×
1728

1729
        for (const auto& n : qAsConst(dsoArray))
×
1730
                n->removeAllNames();
×
1731

1732
        if (namesFile.isEmpty())
×
1733
        {
1734
                QString setName = "default";
×
1735
                QString dsoNamesPath = StelFileMgr::findFile("nebulae/" + setName + "/names.dat");
×
1736
                if (dsoNamesPath.isEmpty())
×
1737
                {
1738
                        qWarning().noquote() << "ERROR while loading deep-sky names data set " << setName;
×
1739
                        return;
×
1740
                }
1741
                loadDSONames(dsoNamesPath);
×
1742
        }
×
1743
        else
1744
        {
1745
                // Open file
1746
                QFile dsoNamesFile(namesFile);
×
1747
                if (!dsoNamesFile.open(QIODevice::ReadOnly | QIODevice::Text))
×
1748
                {
1749
                        qDebug().noquote() << "Cannot open file" << QDir::toNativeSeparators(namesFile);
×
1750
                        return;
×
1751
                }
1752

1753
                // Now parse the file
1754
                // lines to ignore which start with a # or are empty
1755
                static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");
×
1756

1757
                // lines which look like records - we use the RE to extract the fields
1758
                // which will be available in recMatch.capturedTexts()
1759
                static const QRegularExpression recRx("^\\s*([\\w\\s\\-\\+\\.]+)\\s*\\|[_]*[(]\"(.*)\"[)]\\s*([\\,\\d\\s]*)");
×
1760

1761
                QString record, dsoId, nativeName;
×
1762
                int totalRecords=0;
×
1763
                int readOk=0;
×
1764
                int lineNumber=0;
×
1765
                while (!dsoNamesFile.atEnd())
×
1766
                {
1767
                        record = QString::fromUtf8(dsoNamesFile.readLine()).trimmed();
×
1768
                        lineNumber++;
×
1769

1770
                        // Skip comments
1771
                        if (commentRx.match(record).hasMatch())
×
1772
                                continue;
×
1773

1774
                        totalRecords++;
×
1775

1776
                        QRegularExpressionMatch recMatch=recRx.match(record);
×
1777
                        if (!recMatch.hasMatch())
×
1778
                        {
1779
                                qWarning().noquote() << "ERROR - cannot parse record at line" << lineNumber << "in native deep-sky object names file" << QDir::toNativeSeparators(namesFile);
×
1780
                        }
1781
                        else
1782
                        {
1783
                                dsoId = recMatch.captured(1).trimmed();
×
1784
                                nativeName = recMatch.captured(2).trimmed(); // Use translatable text
×
1785
                                NebulaP e = search(dsoId);
×
1786
                                if (!e.isNull()) // avoid crash
×
1787
                                {
1788
                                        QString currentName = e->getEnglishName();
×
1789
                                        if (currentName.isEmpty()) // Set native name of DSO
×
1790
                                                e->setProperName(nativeName);
×
1791
                                        else if (currentName!=nativeName) // Add traditional (well-known?) name of DSO as alias
×
1792
                                                e->addNameAlias(nativeName);
×
1793
                                }
×
1794
                                else
1795
                                        qWarning().noquote() << "ERROR - could NOT found DSO " << dsoId;
×
1796

1797
                                readOk++;
×
1798
                        }
×
1799
                }
×
1800
                dsoNamesFile.close();
×
1801
                qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "native names of deep-sky objects";
×
1802
        }
×
1803

1804
        updateI18n();
×
1805
}
×
1806

1807
void NebulaMgr::updateI18n()
×
1808
{
1809
        const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();
×
1810
        for (const auto& n : qAsConst(dsoArray))
×
1811
                n->translateName(trans);
×
1812
}
×
1813

1814

1815
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
1816
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
×
1817
{
1818
        QString objw = nameI18n.toUpper();
×
1819

1820
        // Search by common names
1821
        for (const auto& n : qAsConst(dsoArray))
×
1822
        {
1823
                QString objwcap = n->nameI18.toUpper();
×
1824
                if (objwcap==objw)
×
1825
                        return qSharedPointerCast<StelObject>(n);
×
1826
        }
×
1827

1828
        // Search by aliases of common names
1829
        for (const auto& n : qAsConst(dsoArray))
×
1830
        {
1831
                for (auto &objwcapa : n->nameI18Aliases)
×
1832
                {
1833
                        if (objwcapa.toUpper()==objw)
×
1834
                                return qSharedPointerCast<StelObject>(n);
×
1835
                }
1836
        }
1837

1838
        // Search by designation
1839
        NebulaP n = searchByDesignation(objw);
×
1840
        return qSharedPointerCast<StelObject>(n);
×
1841
}
×
1842

1843

1844
//! Return the matching Nebula object's pointer if exists or an "empty" StelObjectP
1845
StelObjectP NebulaMgr::searchByName(const QString& name) const
×
1846
{
1847
        QString objw = name.toUpper();
×
1848

1849
        // Search by common names
1850
        for (const auto& n : dsoArray)
×
1851
        {
1852
                QString objwcap = n->englishName.toUpper();
×
1853
                if (objwcap==objw)
×
1854
                        return qSharedPointerCast<StelObject>(n);
×
1855
        }
×
1856

1857
        if (getFlagAdditionalNames())
×
1858
        {
1859
                // Search by aliases of common names
1860
                for (const auto& n : dsoArray)
×
1861
                {
1862
                        for (auto &objwcapa : n->englishAliases)
×
1863
                        {
1864
                                if (objwcapa.toUpper()==objw)
×
1865
                                        return qSharedPointerCast<StelObject>(n);
×
1866
                        }
1867
                }
1868
        }
1869

1870
        // Search by designation
1871
        NebulaP n = searchByDesignation(objw);
×
1872
        return qSharedPointerCast<StelObject>(n);
×
1873
}
×
1874

1875
//! Return the matching Nebula object's pointer if exists or Q_NULLPTR
1876
//! TODO Decide whether empty StelObjectP or Q_NULLPTR is the better return type and select the same for both.
1877
NebulaP NebulaMgr::searchByDesignation(const QString &designation) const
×
1878
{
1879
        NebulaP n;
×
1880
        QString uname = designation.toUpper();
×
1881
        // If no match found, try search by catalog reference
1882
        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+)$");
×
1883
        QRegularExpressionMatch catNumMatch=catNumRx.match(uname);
×
1884
        if (catNumMatch.hasMatch())
×
1885
        {
1886
                QString cat = catNumMatch.captured(1);
×
1887
                unsigned int num = catNumMatch.captured(2).toUInt();
×
1888
                if (cat == "M") n = searchM(num);
×
1889
                if (cat == "NGC") n = searchNGC(num);
×
1890
                if (cat == "IC") n = searchIC(num);
×
1891
                if (cat == "C") n = searchC(num);
×
1892
                if (cat == "B") n = searchB(num);
×
1893
                if (cat == "VDB-HA") n = searchVdBHa(num);
×
1894
                if (cat == "VDB") n = searchVdB(num);
×
1895
                if (cat == "RCW") n = searchRCW(num);
×
1896
                if (cat == "LDN") n = searchLDN(num);
×
1897
                if (cat == "LBN") n = searchLBN(num);
×
1898
                if (cat == "CR") n = searchCr(num);
×
1899
                if (cat == "MEL") n = searchMel(num);
×
1900
                if (cat == "PGC") n = searchPGC(num);
×
1901
                if (cat == "UGC") n = searchUGC(num);
×
1902
                if (cat == "ARP") n = searchArp(num);
×
1903
                if (cat == "VV") n = searchVV(num);
×
1904
                if (cat == "DWB") n = searchDWB(num);
×
1905
                if (cat == "TR" || cat == "TRUMPLER") n = searchTr(num);
×
1906
                if (cat == "ST" || cat == "STOCK") n = searchSt(num);
×
1907
                if (cat == "RU" || cat == "RUPRECHT") n = searchRu(num);
×
1908
        }
×
1909
        static const QRegularExpression dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$");
×
1910
        QRegularExpressionMatch dCatNumMatch=dCatNumRx.match(uname);
×
1911
        if (dCatNumMatch.hasMatch())
×
1912
        {
1913
                QString dcat = dCatNumMatch.captured(1);
×
1914
                unsigned int dnum = dCatNumMatch.captured(2).toUInt();
×
1915

1916
                if (dcat == "SH") n = searchSh2(dnum);
×
1917
        }
×
1918
        static const QRegularExpression sCatNumRx("^(CED|PK|ACO|ABELL|HCG|ESO|VDBH)\\s*(.+)$");
×
1919
        QRegularExpressionMatch sCatNumMatch=sCatNumRx.match(uname);
×
1920
        if (sCatNumMatch.hasMatch())
×
1921
        {
1922
                QString cat = sCatNumMatch.captured(1);
×
1923
                QString num = sCatNumMatch.captured(2).trimmed();
×
1924

1925
                if (cat == "CED") n = searchCed(num);
×
1926
                if (cat == "PK") n = searchPK(num);
×
1927
                if (cat == "ACO" || cat == "ABELL") n = searchACO(num);
×
1928
                if (cat == "HCG") n = searchHCG(num);
×
1929
                if (cat == "ESO") n = searchESO(num);
×
1930
                if (cat == "VDBH") n = searchVdBH(num);
×
1931
        }
×
1932
        static const QRegularExpression gCatNumRx("^(PN|SNR)\\s*G(.+)$");
×
1933
        QRegularExpressionMatch gCatNumMatch=gCatNumRx.match(uname);
×
1934
        if (gCatNumMatch.hasMatch())
×
1935
        {
1936
                QString cat = gCatNumMatch.captured(1);
×
1937
                QString num = gCatNumMatch.captured(2).trimmed();
×
1938

1939
                if (cat == "PN") n = searchPNG(num);
×
1940
                if (cat == "SNR") n = searchSNRG(num);
×
1941
        }
×
1942

1943
        return n;
×
1944
}
×
1945

1946
//! Find and return the list of at most maxNbItem objects auto-completing the passed object name
1947
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
×
1948
{
1949
        QStringList result;
×
1950
        if (maxNbItem <= 0)
×
1951
                return result;
×
1952

1953
        QString objw = objPrefix.toUpper();
×
1954

1955
        // Search by Messier objects number (possible formats are "M31" or "M 31")
1956
        if (objw.size()>=1 && objw.at(0)=='M' && objw.left(3)!="MEL")
×
1957
        {
1958
                for (const auto& n : dsoArray)
×
1959
                {
1960
                        if (n->M_nb==0) continue;
×
1961
                        QString constw = QString("M%1").arg(n->M_nb);
×
1962
                        QString constws = constw.mid(0, objw.size());
×
1963
                        if (constws.toUpper()==objw)
×
1964
                        {
1965
                                result << constws;
×
1966
                                continue;        // Prevent adding both forms for name
×
1967
                        }
1968
                        constw = QString("M %1").arg(n->M_nb);
×
1969
                        constws = constw.mid(0, objw.size());
×
1970
                        if (constws.toUpper()==objw)
×
1971
                                result << constw;
×
1972
                }
×
1973
        }
1974

1975
        // Search by Melotte objects number (possible formats are "Mel31" or "Mel 31")
1976
        if (objw.size()>=1 && objw.left(3)=="MEL")
×
1977
        {
1978
                for (const auto& n : dsoArray)
×
1979
                {
1980
                        if (n->Mel_nb==0) continue;
×
1981
                        QString constw = QString("Mel%1").arg(n->Mel_nb);
×
1982
                        QString constws = constw.mid(0, objw.size());
×
1983
                        QString constws2 = QString("Melotte%1").arg(n->Mel_nb).mid(0, objw.size());
×
1984
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
1985
                        {
1986
                                result << constws;
×
1987
                                continue;        // Prevent adding both forms for name
×
1988
                        }
1989
                        constw = QString("Mel %1").arg(n->Mel_nb);
×
1990
                        constws = constw.mid(0, objw.size());
×
1991
                        constws2 = QString("Melotte %1").arg(n->Mel_nb).mid(0, objw.size());
×
1992
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
1993
                                result << constw;
×
1994
                }
×
1995
        }
1996

1997
        // Search by IC objects number (possible formats are "IC466" or "IC 466")
1998
        if (objw.size()>=1 && objw.left(2)=="IC")
×
1999
        {
2000
                for (const auto& n : dsoArray)
×
2001
                {
2002
                        if (n->IC_nb==0) continue;
×
2003
                        QString constw = QString("IC%1").arg(n->IC_nb);
×
2004
                        QString constws = constw.mid(0, objw.size());
×
2005
                        if (constws.toUpper()==objw)
×
2006
                        {
2007
                                result << constws;
×
2008
                                continue;        // Prevent adding both forms for name
×
2009
                        }
2010
                        constw = QString("IC %1").arg(n->IC_nb);
×
2011
                        constws = constw.mid(0, objw.size());
×
2012
                        if (constws.toUpper()==objw)
×
2013
                                result << constw;
×
2014
                }
×
2015
        }
2016

2017
        // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
2018
        for (const auto& n : dsoArray)
×
2019
        {
2020
                if (n->NGC_nb==0) continue;
×
2021
                QString constw = QString("NGC%1").arg(n->NGC_nb);
×
2022
                QString constws = constw.mid(0, objw.size());
×
2023
                if (constws.toUpper()==objw)
×
2024
                {
2025
                        result << constws;
×
2026
                        continue;
×
2027
                }
2028
                constw = QString("NGC %1").arg(n->NGC_nb);
×
2029
                constws = constw.mid(0, objw.size());
×
2030
                if (constws.toUpper()==objw)
×
2031
                        result << constw;
×
2032
        }
×
2033

2034
        // Search by PGC object numbers (possible formats are "PGC31" or "PGC 31")
2035
        if (objw.size()>=1 && objw.left(3)=="PGC")
×
2036
        {
2037
                for (const auto& n : dsoArray)
×
2038
                {
2039
                        if (n->PGC_nb==0) continue;
×
2040
                        QString constw = QString("PGC%1").arg(n->PGC_nb);
×
2041
                        QString constws = constw.mid(0, objw.size());
×
2042
                        if (constws.toUpper()==objw)
×
2043
                        {
2044
                                result << constws;        // Prevent adding both forms for name
×
2045
                                continue;
×
2046
                        }
2047
                        constw = QString("PGC %1").arg(n->PGC_nb);
×
2048
                        constws = constw.mid(0, objw.size());
×
2049
                        if (constws.toUpper()==objw)
×
2050
                                result << constw;
×
2051
                }
×
2052
        }
2053

2054
        // Search by UGC object numbers (possible formats are "UGC31" or "UGC 31")
2055
        if (objw.size()>=1 && objw.left(3)=="UGC")
×
2056
        {
2057
                for (const auto& n : dsoArray)
×
2058
                {
2059
                        if (n->UGC_nb==0) continue;
×
2060
                        QString constw = QString("UGC%1").arg(n->UGC_nb);
×
2061
                        QString constws = constw.mid(0, objw.size());
×
2062
                        if (constws.toUpper()==objw)
×
2063
                        {
2064
                                result << constws;
×
2065
                                continue;        // Prevent adding both forms for name
×
2066
                        }
2067
                        constw = QString("UGC %1").arg(n->UGC_nb);
×
2068
                        constws = constw.mid(0, objw.size());
×
2069
                        if (constws.toUpper()==objw)
×
2070
                                result << constw;
×
2071
                }
×
2072
        }
2073

2074
        // Search by Caldwell objects number (possible formats are "C31" or "C 31")
2075
        if (objw.size()>=1 && objw.at(0)=='C' && objw.left(2)!="CR" && objw.left(2)!="CE")
×
2076
        {
2077
                for (const auto& n : dsoArray)
×
2078
                {
2079
                        if (n->C_nb==0) continue;
×
2080
                        QString constw = QString("C%1").arg(n->C_nb);
×
2081
                        QString constws = constw.mid(0, objw.size());
×
2082
                        if (constws.toUpper()==objw)
×
2083
                        {
2084
                                result << constws;
×
2085
                                continue;        // Prevent adding both forms for name
×
2086
                        }
2087
                        constw = QString("C %1").arg(n->C_nb);
×
2088
                        constws = constw.mid(0, objw.size());
×
2089
                        if (constws.toUpper()==objw)
×
2090
                                result << constw;
×
2091
                }
×
2092
        }
2093

2094
        // Search by Collinder objects number (possible formats are "Cr31" or "Cr 31")
2095
        if (objw.size()>=1 && (objw.left(2)=="CR" || objw.left(9)=="COLLINDER"))
×
2096
        {
2097
                for (const auto& n : dsoArray)
×
2098
                {
2099
                        if (n->Cr_nb==0) continue;
×
2100
                        QString constw = QString("Cr%1").arg(n->Cr_nb);
×
2101
                        QString constws = constw.mid(0, objw.size());
×
2102
                        QString constws2 = QString("Collinder%1").arg(n->Cr_nb).mid(0, objw.size());
×
2103
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2104
                        {
2105
                                result << constws;
×
2106
                                continue;        // Prevent adding both forms for name
×
2107
                        }
2108
                        constw = QString("Cr %1").arg(n->Cr_nb);
×
2109
                        constws = constw.mid(0, objw.size());
×
2110
                        constws2 = QString("Collinder %1").arg(n->Cr_nb).mid(0, objw.size());
×
2111
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2112
                                result << constw;
×
2113
                }
×
2114
        }
2115

2116
        // Search by Ced objects number (possible formats are "Ced31" or "Ced 31")
2117
        if (objw.size()>=1 && objw.left(3)=="CED")
×
2118
        {
2119
                for (const auto& n : dsoArray)
×
2120
                {
2121
                        if (n->Ced_nb.isEmpty()) continue;
×
2122
                        QString constw = QString("Ced%1").arg(n->Ced_nb.trimmed());
×
2123
                        QString constws = constw.mid(0, objw.size());
×
2124
                        if (constws.toUpper()==objw)
×
2125
                        {
2126
                                result << constws;
×
2127
                                continue;        // Prevent adding both forms for name
×
2128
                        }
2129
                        constw = QString("Ced %1").arg(n->Ced_nb.trimmed());
×
2130
                        constws = constw.mid(0, objw.size());
×
2131
                        if (constws.toUpper()==objw)
×
2132
                                result << constw;
×
2133
                }
×
2134
        }
2135

2136
        // Search by Barnard objects number (possible formats are "B31" or "B 31")
2137
        if (objw.size()>=1 && objw.at(0)=='B')
×
2138
        {
2139
                for (const auto& n : dsoArray)
×
2140
                {
2141
                        if (n->B_nb==0) continue;
×
2142
                        QString constw = QString("B%1").arg(n->B_nb);
×
2143
                        QString constws = constw.mid(0, objw.size());
×
2144
                        if (constws.toUpper()==objw)
×
2145
                        {
2146
                                result << constws;
×
2147
                                continue;        // Prevent adding both forms for name
×
2148
                        }
2149
                        constw = QString("B %1").arg(n->B_nb);
×
2150
                        constws = constw.mid(0, objw.size());
×
2151
                        if (constws.toUpper()==objw)
×
2152
                                result << constw;
×
2153
                }
×
2154
        }
2155

2156
        // Search by Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31")
2157
        if (objw.size()>=1 && objw.left(2)=="SH")
×
2158
        {
2159
                for (const auto& n : dsoArray)
×
2160
                {
2161
                        if (n->Sh2_nb==0) continue;
×
2162
                        QString constw = QString("SH2-%1").arg(n->Sh2_nb);
×
2163
                        QString constws = constw.mid(0, objw.size());
×
2164
                        if (constws.toUpper()==objw)
×
2165
                        {
2166
                                result << constws;
×
2167
                                continue;        // Prevent adding both forms for name
×
2168
                        }
2169
                        constw = QString("SH 2-%1").arg(n->Sh2_nb);
×
2170
                        constws = constw.mid(0, objw.size());
×
2171
                        if (constws.toUpper()==objw)
×
2172
                                result << constw;
×
2173
                }
×
2174
        }
2175

2176
        // Search by van den Bergh objects number (possible formats are "vdB31" or "vdB 31")
2177
        if (objw.size()>=1 && objw.left(3)=="VDB" && objw.left(6)!="VDB-HA" && objw.left(4)!="VDBH")
×
2178
        {
2179
                for (const auto& n : dsoArray)
×
2180
                {
2181
                        if (n->VdB_nb==0) continue;
×
2182
                        QString constw = QString("vdB%1").arg(n->VdB_nb);
×
2183
                        QString constws = constw.mid(0, objw.size());
×
2184
                        if (constws.toUpper()==objw)
×
2185
                        {
2186
                                result << constws;
×
2187
                                continue;        // Prevent adding both forms for name
×
2188
                        }
2189
                        constw = QString("vdB %1").arg(n->VdB_nb);
×
2190
                        constws = constw.mid(0, objw.size());
×
2191
                        if (constws.toUpper()==objw)
×
2192
                                result << constw;
×
2193
                }
×
2194
        }
2195

2196
        // Search by RCW objects number (possible formats are "RCW31" or "RCW 31")
2197
        if (objw.size()>=1 && objw.left(3)=="RCW")
×
2198
        {
2199
                for (const auto& n : dsoArray)
×
2200
                {
2201
                        if (n->RCW_nb==0) continue;
×
2202
                        QString constw = QString("RCW%1").arg(n->RCW_nb);
×
2203
                        QString constws = constw.mid(0, objw.size());
×
2204
                        if (constws.toUpper()==objw)
×
2205
                        {
2206
                                result << constws;
×
2207
                                continue;        // Prevent adding both forms for name
×
2208
                        }
2209
                        constw = QString("RCW %1").arg(n->RCW_nb);
×
2210
                        constws = constw.mid(0, objw.size());
×
2211
                        if (constws.toUpper()==objw)
×
2212
                                result << constw;
×
2213
                }
×
2214
        }
2215

2216
        // Search by LDN objects number (possible formats are "LDN31" or "LDN 31")
2217
        if (objw.size()>=1 && objw.left(3)=="LDN")
×
2218
        {
2219
                for (const auto& n : dsoArray)
×
2220
                {
2221
                        if (n->LDN_nb==0) continue;
×
2222
                        QString constw = QString("LDN%1").arg(n->LDN_nb);
×
2223
                        QString constws = constw.mid(0, objw.size());
×
2224
                        if (constws.toUpper()==objw)
×
2225
                        {
2226
                                result << constws;
×
2227
                                continue;        // Prevent adding both forms for name
×
2228
                        }
2229
                        constw = QString("LDN %1").arg(n->LDN_nb);
×
2230
                        constws = constw.mid(0, objw.size());
×
2231
                        if (constws.toUpper()==objw)
×
2232
                                result << constw;
×
2233
                }
×
2234
        }
2235

2236
        // Search by LBN objects number (possible formats are "LBN31" or "LBN 31")
2237
        if (objw.size()>=1 && objw.left(3)=="LBN")
×
2238
        {
2239
                for (const auto& n : dsoArray)
×
2240
                {
2241
                        if (n->LBN_nb==0) continue;
×
2242
                        QString constw = QString("LBN%1").arg(n->LBN_nb);
×
2243
                        QString constws = constw.mid(0, objw.size());
×
2244
                        if (constws.toUpper()==objw)
×
2245
                        {
2246
                                result << constws;
×
2247
                                continue;        // Prevent adding both forms for name
×
2248
                        }
2249
                        constw = QString("LBN %1").arg(n->LBN_nb);
×
2250
                        constws = constw.mid(0, objw.size());
×
2251
                        if (constws.toUpper()==objw)
×
2252
                                result << constw;
×
2253
                }
×
2254
        }
2255

2256
        // Search by Arp objects number
2257
        if (objw.size()>=1 && objw.left(3)=="ARP")
×
2258
        {
2259
                for (const auto& n : dsoArray)
×
2260
                {
2261
                        if (n->Arp_nb==0) continue;
×
2262
                        QString constw = QString("Arp%1").arg(n->Arp_nb);
×
2263
                        QString constws = constw.mid(0, objw.size());
×
2264
                        if (constws.toUpper()==objw)
×
2265
                        {
2266
                                result << constws;
×
2267
                                continue;        // Prevent adding both forms for name
×
2268
                        }
2269
                        constw = QString("Arp %1").arg(n->Arp_nb);
×
2270
                        constws = constw.mid(0, objw.size());
×
2271
                        if (constws.toUpper()==objw)
×
2272
                                result << constw;
×
2273
                }
×
2274
        }
2275

2276
        // Search by VV objects number
2277
        if (objw.size()>=1 && objw.left(2)=="VV")
×
2278
        {
2279
                for (const auto& n : dsoArray)
×
2280
                {
2281
                        if (n->VV_nb==0) continue;
×
2282
                        QString constw = QString("VV%1").arg(n->VV_nb);
×
2283
                        QString constws = constw.mid(0, objw.size());
×
2284
                        if (constws.toUpper()==objw)
×
2285
                        {
2286
                                result << constws;
×
2287
                                continue;        // Prevent adding both forms for name
×
2288
                        }
2289
                        constw = QString("VV %1").arg(n->VV_nb);
×
2290
                        constws = constw.mid(0, objw.size());
×
2291
                        if (constws.toUpper()==objw)
×
2292
                                result << constw;
×
2293
                }
×
2294
        }
2295

2296
        // Search by PK objects number
2297
        if (objw.size()>=1 && objw.left(2)=="PK")
×
2298
        {
2299
                for (const auto& n : dsoArray)
×
2300
                {
2301
                        if (n->PK_nb.isEmpty()) continue;
×
2302
                        QString constw = QString("PK%1").arg(n->PK_nb.trimmed());
×
2303
                        QString constws = constw.mid(0, objw.size());
×
2304
                        if (constws.toUpper()==objw)
×
2305
                        {
2306
                                result << constws;
×
2307
                                continue;        // Prevent adding both forms for name
×
2308
                        }
2309
                        constw = QString("PK %1").arg(n->PK_nb.trimmed());
×
2310
                        constws = constw.mid(0, objw.size());
×
2311
                        if (constws.toUpper()==objw)
×
2312
                                result << constw;
×
2313
                }
×
2314
        }
2315

2316
        // Search by PN G objects number
2317
        if (objw.size()>=1 && objw.left(2)=="PN")
×
2318
        {
2319
                for (const auto& n : dsoArray)
×
2320
                {
2321
                        if (n->PNG_nb.isEmpty()) continue;
×
2322
                        QString constw = QString("PNG%1").arg(n->PNG_nb.trimmed());
×
2323
                        QString constws = constw.mid(0, objw.size());
×
2324
                        if (constws.toUpper()==objw)
×
2325
                        {
2326
                                result << constws;
×
2327
                                continue;        // Prevent adding both forms for name
×
2328
                        }
2329
                        constw = QString("PN G%1").arg(n->PNG_nb.trimmed());
×
2330
                        constws = constw.mid(0, objw.size());
×
2331
                        if (constws.toUpper()==objw)
×
2332
                                result << constw;
×
2333
                }
×
2334
        }
2335

2336
        // Search by SNR G objects number
2337
        if (objw.size()>=1 && objw.left(3)=="SNR")
×
2338
        {
2339
                for (const auto& n : dsoArray)
×
2340
                {
2341
                        if (n->SNRG_nb.isEmpty()) continue;
×
2342
                        QString constw = QString("SNRG%1").arg(n->SNRG_nb.trimmed());
×
2343
                        QString constws = constw.mid(0, objw.size());
×
2344
                        if (constws.toUpper()==objw)
×
2345
                        {
2346
                                result << constws;
×
2347
                                continue;        // Prevent adding both forms for name
×
2348
                        }
2349
                        constw = QString("SNR G%1").arg(n->SNRG_nb.trimmed());
×
2350
                        constws = constw.mid(0, objw.size());
×
2351
                        if (constws.toUpper()==objw)
×
2352
                                result << constw;
×
2353
                }
×
2354
        }
2355

2356
        // Search by ACO (Abell) objects number
2357
        if (objw.size()>=1 && (objw.left(5)=="ABELL" || objw.left(3)=="ACO"))
×
2358
        {
2359
                for (const auto& n : dsoArray)
×
2360
                {
2361
                        if (n->ACO_nb.isEmpty()) continue;
×
2362
                        QString constw = QString("Abell%1").arg(n->ACO_nb.trimmed());
×
2363
                        QString constws = constw.mid(0, objw.size());
×
2364
                        QString constws2 = QString("ACO%1").arg(n->ACO_nb.trimmed()).mid(0, objw.size());
×
2365
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2366
                        {
2367
                                result << constws;
×
2368
                                continue;        // Prevent adding both forms for name
×
2369
                        }
2370
                        constw = QString("Abell %1").arg(n->ACO_nb.trimmed());
×
2371
                        constws = constw.mid(0, objw.size());
×
2372
                        constws2 = QString("ACO %1").arg(n->ACO_nb.trimmed()).mid(0, objw.size());
×
2373
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2374
                                result << constw;
×
2375
                }
×
2376
        }
2377

2378
        // Search by HCG objects number
2379
        if (objw.size()>=1 && objw.left(3)=="HCG")
×
2380
        {
2381
                for (const auto& n : dsoArray)
×
2382
                {
2383
                        if (n->HCG_nb.isEmpty()) continue;
×
2384
                        QString constw = QString("HCG%1").arg(n->HCG_nb.trimmed());
×
2385
                        QString constws = constw.mid(0, objw.size());
×
2386
                        if (constws.toUpper()==objw)
×
2387
                        {
2388
                                result << constws;
×
2389
                                continue;        // Prevent adding both forms for name
×
2390
                        }
2391
                        constw = QString("HCG %1").arg(n->HCG_nb.trimmed());
×
2392
                        constws = constw.mid(0, objw.size());
×
2393
                        if (constws.toUpper()==objw)
×
2394
                                result << constw;
×
2395
                }
×
2396
        }
2397

2398
        // Search by ESO objects number
2399
        if (objw.size()>=1 && objw.left(3)=="ESO")
×
2400
        {
2401
                for (const auto& n : dsoArray)
×
2402
                {
2403
                        if (n->ESO_nb.isEmpty()) continue;
×
2404
                        QString constw = QString("ESO%1").arg(n->ESO_nb.trimmed());
×
2405
                        QString constws = constw.mid(0, objw.size());
×
2406
                        if (constws.toUpper()==objw)
×
2407
                        {
2408
                                result << constws;
×
2409
                                continue;        // Prevent adding both forms for name
×
2410
                        }
2411
                        constw = QString("ESO %1").arg(n->ESO_nb.trimmed());
×
2412
                        constws = constw.mid(0, objw.size());
×
2413
                        if (constws.toUpper()==objw)
×
2414
                                result << constw;
×
2415
                }
×
2416
        }
2417

2418
        // Search by VdBH objects number
2419
        if (objw.size()>=1 && objw.left(4)=="VDBH")
×
2420
        {
2421
                for (const auto& n : dsoArray)
×
2422
                {
2423
                        if (n->VdBH_nb.isEmpty()) continue;
×
2424
                        QString constw = QString("vdBH%1").arg(n->VdBH_nb.trimmed());
×
2425
                        QString constws = constw.mid(0, objw.size());
×
2426
                        if (constws.toUpper()==objw)
×
2427
                        {
2428
                                result << constws;
×
2429
                                continue;        // Prevent adding both forms for name
×
2430
                        }
2431
                        constw = QString("vdBH %1").arg(n->VdBH_nb.trimmed());
×
2432
                        constws = constw.mid(0, objw.size());
×
2433
                        if (constws.toUpper()==objw)
×
2434
                                result << constw;
×
2435
                }
×
2436
        }
2437

2438
        // Search by DWB objects number
2439
        if (objw.size()>=1 && objw.left(3)=="DWB")
×
2440
        {
2441
                for (const auto& n : dsoArray)
×
2442
                {
2443
                        if (n->DWB_nb==0) continue;
×
2444
                        QString constw = QString("DWB%1").arg(n->DWB_nb);
×
2445
                        QString constws = constw.mid(0, objw.size());
×
2446
                        if (constws.toUpper()==objw)
×
2447
                        {
2448
                                result << constws;
×
2449
                                continue;        // Prevent adding both forms for name
×
2450
                        }
2451
                        constw = QString("DWB %1").arg(n->DWB_nb);
×
2452
                        constws = constw.mid(0, objw.size());
×
2453
                        if (constws.toUpper()==objw)
×
2454
                                result << constw;
×
2455
                }
×
2456
        }
2457

2458
        // Search by Tr (Trumpler) objects number
2459
        if (objw.size()>=1 && (objw.left(8)=="TRUMPLER" || objw.left(2)=="TR"))
×
2460
        {
2461
                for (const auto& n : dsoArray)
×
2462
                {
2463
                        if (n->Tr_nb==0) continue;
×
2464
                        QString constw = QString("Tr%1").arg(n->Tr_nb);
×
2465
                        QString constws = constw.mid(0, objw.size());
×
2466
                        QString constws2 = QString("Trumpler%1").arg(n->Tr_nb).mid(0, objw.size());
×
2467
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2468
                        {
2469
                                result << constws;
×
2470
                                continue;        // Prevent adding both forms for name
×
2471
                        }
2472
                        constw = QString("Tr %1").arg(n->Tr_nb);
×
2473
                        constws = constw.mid(0, objw.size());
×
2474
                        constws2 = QString("Trumpler %1").arg(n->Tr_nb).mid(0, objw.size());
×
2475
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2476
                                result << constw;
×
2477
                }
×
2478
        }
2479

2480
        // Search by St (Stock) objects number
2481
        if (objw.size()>=1 && (objw.left(5)=="STOCK" || objw.left(2)=="ST"))
×
2482
        {
2483
                for (const auto& n : dsoArray)
×
2484
                {
2485
                        if (n->St_nb==0) continue;
×
2486
                        QString constw = QString("St%1").arg(n->St_nb);
×
2487
                        QString constws = constw.mid(0, objw.size());
×
2488
                        QString constws2 = QString("Stock%1").arg(n->St_nb).mid(0, objw.size());
×
2489
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2490
                        {
2491
                                result << constws;
×
2492
                                continue;        // Prevent adding both forms for name
×
2493
                        }
2494
                        constw = QString("St %1").arg(n->St_nb);
×
2495
                        constws = constw.mid(0, objw.size());
×
2496
                        constws2 = QString("Stock %1").arg(n->St_nb).mid(0, objw.size());
×
2497
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2498
                                result << constw;
×
2499
                }
×
2500
        }
2501

2502
        // Search by Ru (Ruprecht) objects number
2503
        if (objw.size()>=1 && (objw.left(8)=="RUPRECHT" || objw.left(2)=="RU"))
×
2504
        {
2505
                for (const auto& n : dsoArray)
×
2506
                {
2507
                        if (n->Ru_nb==0) continue;
×
2508
                        QString constw = QString("Ru%1").arg(n->Ru_nb);
×
2509
                        QString constws = constw.mid(0, objw.size());
×
2510
                        QString constws2 = QString("Ruprecht%1").arg(n->Ru_nb).mid(0, objw.size());
×
2511
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2512
                        {
2513
                                result << constws;
×
2514
                                continue;        // Prevent adding both forms for name
×
2515
                        }
2516
                        constw = QString("Ru %1").arg(n->Ru_nb);
×
2517
                        constws = constw.mid(0, objw.size());
×
2518
                        constws2 = QString("Ruprecht %1").arg(n->Ru_nb).mid(0, objw.size());
×
2519
                        if (constws.toUpper()==objw || constws2.toUpper()==objw)
×
2520
                                result << constw;
×
2521
                }
×
2522
        }
2523

2524
        // Search by van den Bergh-Hagen Catalogue objects number
2525
        if (objw.size()>=1 && objw.left(6)=="VDB-HA")
×
2526
        {
2527
                for (const auto& n : dsoArray)
×
2528
                {
2529
                        if (n->VdBHa_nb==0) continue;
×
2530
                        QString constw = QString("vdB-Ha%1").arg(n->VdBHa_nb);
×
2531
                        QString constws = constw.mid(0, objw.size());
×
2532
                        if (constws.toUpper()==objw)
×
2533
                        {
2534
                                result << constws;
×
2535
                                continue;        // Prevent adding both forms for name
×
2536
                        }
2537
                        constw = QString("vdB-Ha %1").arg(n->VdBHa_nb);
×
2538
                        constws = constw.mid(0, objw.size());
×
2539
                        if (constws.toUpper()==objw)
×
2540
                                result << constw;
×
2541
                }
×
2542
        }
2543

2544
        // Search by common names and aliases
2545
        QStringList names;
×
2546
        for (const auto& n : dsoArray)
×
2547
        {
2548
                names.append(n->nameI18);
×
2549
                names.append(n->englishName);
×
2550
                if (getFlagAdditionalNames())
×
2551
                {
2552
                        QStringList nameList = n->nameI18Aliases;
×
2553
                        for (const auto &name : nameList)
×
2554
                                names.append(name);
×
2555

2556
                        nameList = n->englishAliases;
×
2557
                        for (const auto &name : qAsConst(nameList))
×
2558
                                names.append(name);
×
2559
                }
×
2560
        }
2561

2562
        QString fullMatch = "";
×
2563
        for (const auto& name : qAsConst(names))
×
2564
        {
2565
                if (!matchObjectName(name, objPrefix, useStartOfWords))
×
2566
                        continue;
×
2567

2568
                if (name==objPrefix)
×
2569
                        fullMatch = name;
×
2570
                else
2571
                        result.append(name);
×
2572
        }
2573

2574
        result.sort();
×
2575
        if (!fullMatch.isEmpty())
×
2576
                result.prepend(fullMatch);
×
2577

2578
        if (result.size() > maxNbItem)
×
2579
                result.erase(result.begin() + maxNbItem, result.end());
×
2580

2581
        return result;
×
2582
}
×
2583

2584
QStringList NebulaMgr::listAllObjects(bool inEnglish) const
×
2585
{
2586
        QStringList result;
×
2587
        for (const auto& n : dsoArray)
×
2588
        {
2589
                if (!n->getEnglishName().isEmpty())
×
2590
                {
2591
                        if (inEnglish)
×
2592
                                result << n->getEnglishName();
×
2593
                        else
2594
                                result << n->getNameI18n();
×
2595
                }
2596
        }
2597
        return result;
×
2598
}
×
2599

2600
QStringList NebulaMgr::listAllObjectsByType(const QString &objType, bool inEnglish) const
×
2601
{
2602
        QStringList result;
×
2603
        int type = objType.toInt();
×
2604
        switch (type)
×
2605
        {
2606
                case 0: // Bright galaxies?
×
2607
                        for (const auto& n : dsoArray)
×
2608
                        {
2609
                                if (n->nType==type && qMin(n->vMag, n->bMag)<=10.f)
×
2610
                                {
2611
                                        if (!n->getEnglishName().isEmpty())
×
2612
                                        {
2613
                                                if (inEnglish)
×
2614
                                                        result << n->getEnglishName();
×
2615
                                                else
2616
                                                        result << n->getNameI18n();
×
2617
                                        }
2618
                                        else
2619
                                                result << n->getDSODesignationWIC();
×
2620
                                }
2621
                        }
2622
                        break;
×
2623
                case 100: // Messier Catalogue?
×
2624
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2625
                                result << QString("M%1").arg(n->M_nb);
×
2626
                        break;
×
2627
                case 101: // Caldwell Catalogue?
×
2628
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2629
                                result << QString("C%1").arg(n->C_nb);
×
2630
                        break;
×
2631
                case 102: // Barnard Catalogue?
×
2632
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2633
                                result << QString("B %1").arg(n->B_nb);
×
2634
                        break;
×
2635
                case 103: // Sharpless Catalogue?
×
2636
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2637
                                result << QString("SH 2-%1").arg(n->Sh2_nb);
×
2638
                        break;
×
2639
                case 104: // van den Bergh Catalogue
×
2640
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2641
                                result << QString("vdB %1").arg(n->VdB_nb);
×
2642
                        break;
×
2643
                case 105: // RCW Catalogue
×
2644
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2645
                                result << QString("RCW %1").arg(n->RCW_nb);
×
2646
                        break;
×
2647
                case 106: // Collinder Catalogue
×
2648
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2649
                                result << QString("Cr %1").arg(n->Cr_nb);
×
2650
                        break;
×
2651
                case 107: // Melotte Catalogue
×
2652
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2653
                                result << QString("Mel %1").arg(n->Mel_nb);
×
2654
                        break;
×
2655
                case 108: // New General Catalogue
×
2656
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2657
                                result << QString("NGC %1").arg(n->NGC_nb);
×
2658
                        break;
×
2659
                case 109: // Index Catalogue
×
2660
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2661
                                result << QString("IC %1").arg(n->IC_nb);
×
2662
                        break;
×
2663
                case 110: // Lynds' Catalogue of Bright Nebulae
×
2664
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2665
                                result << QString("LBN %1").arg(n->LBN_nb);
×
2666
                        break;
×
2667
                case 111: // Lynds' Catalogue of Dark Nebulae
×
2668
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2669
                                result << QString("LDN %1").arg(n->LDN_nb);
×
2670
                        break;
×
2671
                case 114: // Cederblad Catalog
×
2672
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2673
                                result << QString("Ced %1").arg(n->Ced_nb);
×
2674
                        break;
×
2675
                case 115: // Atlas of Peculiar Galaxies (Arp)
×
2676
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2677
                                result << QString("Arp %1").arg(n->Arp_nb);
×
2678
                        break;
×
2679
                case 116: // The Catalogue of Interacting Galaxies by Vorontsov-Velyaminov (VV)
×
2680
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2681
                                result << QString("VV %1").arg(n->VV_nb);
×
2682
                        break;
×
2683
                case 117: // Catalogue of Galactic Planetary Nebulae (PK)
×
2684
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2685
                                result << QString("PK %1").arg(n->PK_nb);
×
2686
                        break;
×
2687
                case 118: // Strasbourg-ESO Catalogue of Galactic Planetary Nebulae by Acker et. al. (PN G)
×
2688
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2689
                                result << QString("PN G%1").arg(n->PNG_nb);
×
2690
                        break;
×
2691
                case 119: // A catalogue of Galactic supernova remnants by Green (SNR G)
×
2692
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2693
                                result << QString("SNR G%1").arg(n->SNRG_nb);
×
2694
                        break;
×
2695
                case 120: // A Catalog of Rich Clusters of Galaxies by Abell et. al. (Abell (ACO))
×
2696
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2697
                                result << QString("Abell %1").arg(n->ACO_nb);
×
2698
                        break;
×
2699
                case 121: // Hickson Compact Group by Hickson et. al. (HCG)
×
2700
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2701
                                result << QString("HCG %1").arg(n->HCG_nb);
×
2702
                        break;
×
2703
                case 122: // ESO/Uppsala Survey of the ESO(B) Atlas (ESO)
×
2704
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2705
                                result << QString("ESO %1").arg(n->ESO_nb);
×
2706
                        break;
×
2707
                case 123: // Catalogue of southern stars embedded in nebulosity (vdBH)
×
2708
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2709
                                result << QString("vdBH %1").arg(n->VdBH_nb);
×
2710
                        break;
×
2711
                case 124: // Catalogue and distances of optically visible H II regions (DWB)
×
2712
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2713
                                result << QString("DWB %1").arg(n->DWB_nb);
×
2714
                        break;
×
2715
                case 125: // Trumpler Catalogue (Tr)
×
2716
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2717
                                result << QString("Tr %1").arg(n->Tr_nb);
×
2718
                        break;
×
2719
                case 126: // Stock Catalogue (St)
×
2720
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2721
                                result << QString("St %1").arg(n->St_nb);
×
2722
                        break;
×
2723
                case 127: // Ruprecht Catalogue (Ru)
×
2724
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2725
                                result << QString("Ru %1").arg(n->Ru_nb);
×
2726
                        break;
×
2727
                case 128: // van den Bergh-Hagen Catalogue (VdB-Ha)
×
2728
                        for (const auto& n : getDeepSkyObjectsByType(objType))
×
2729
                                result << QString("vdB-Ha %1").arg(n->VdBHa_nb);
×
2730
                        break;
×
2731
                case 150: // Dwarf galaxies [see NebulaList.hpp]
×
2732
                {
2733
                        for (unsigned int i = 0; i < sizeof(DWARF_GALAXIES) / sizeof(DWARF_GALAXIES[0]); i++)
×
2734
                                result << QString("PGC %1").arg(DWARF_GALAXIES[i]);
×
2735
                        break;
×
2736
                }
2737
                case 151: // Herschel 400 Catalogue [see NebulaList.hpp]
×
2738
                {
2739
                        for (unsigned int i = 0; i < sizeof(H400_LIST) / sizeof(H400_LIST[0]); i++)
×
2740
                                result << QString("NGC %1").arg(H400_LIST[i]);
×
2741
                        break;
×
2742
                }
2743
                case 152: // Jack Bennett's deep sky catalogue [see NebulaList.hpp]
×
2744
                {
2745
                        for (unsigned int i = 0; i < sizeof(BENNETT_LIST) / sizeof(BENNETT_LIST[0]); i++)
×
2746
                                result << QString("NGC %1").arg(BENNETT_LIST[i]);
×
2747
                        result << "Mel 105" << "IC 1459";
×
2748
                        break;
×
2749
                }
2750
                case 153: // James Dunlop's deep sky catalogue [see NebulaList.hpp]
×
2751
                {
2752
                        for (unsigned int i = 0; i < sizeof(DUNLOP_LIST) / sizeof(DUNLOP_LIST[0]); i++)
×
2753
                                result << QString("NGC %1").arg(DUNLOP_LIST[i]);
×
2754
                        break;
×
2755
                }
2756
                default:
×
2757
                {
2758
                        for (const auto& n : dsoArray)
×
2759
                        {
2760
                                if (n->nType==type)
×
2761
                                {
2762
                                        if (!n->getEnglishName().isEmpty())
×
2763
                                        {
2764
                                                if (inEnglish)
×
2765
                                                        result << n->getEnglishName();
×
2766
                                                else
2767
                                                        result << n->getNameI18n();
×
2768
                                        }
2769
                                        else
2770
                                                result << n->getDSODesignationWIC();
×
2771
                                }
2772
                        }
2773
                        break;
×
2774
                }
2775
        }
2776

2777
        result.removeDuplicates();
×
2778
        return result;
×
2779
}
×
2780

2781
const QList<NebulaP> NebulaMgr::getDeepSkyObjectsByType(const QString &objType) const
×
2782
{
2783
        QList<NebulaP> dso;
×
2784
        int type = objType.toInt();
×
2785
        switch (type)
×
2786
        {
2787
                case 100: // Messier Catalogue?
×
2788
                        for (const auto& n : dsoArray)
×
2789
                        {
2790
                                if (n->M_nb>0)
×
2791
                                        dso.append(n);
×
2792
                        }
2793
                        break;
×
2794
                case 101: // Caldwell Catalogue?
×
2795
                        for (const auto& n : dsoArray)
×
2796
                        {
2797
                                if (n->C_nb>0)
×
2798
                                        dso.append(n);
×
2799
                        }
2800
                        break;
×
2801
                case 102: // Barnard Catalogue?
×
2802
                        for (const auto& n : dsoArray)
×
2803
                        {
2804
                                if (n->B_nb>0)
×
2805
                                        dso.append(n);
×
2806
                        }
2807
                        break;
×
2808
                case 103: // Sharpless Catalogue?
×
2809
                        for (const auto& n : dsoArray)
×
2810
                        {
2811
                                if (n->Sh2_nb>0)
×
2812
                                        dso.append(n);
×
2813
                        }
2814
                        break;
×
2815
                case 104: // van den Bergh Catalogue
×
2816
                        for (const auto& n : dsoArray)
×
2817
                        {
2818
                                if (n->VdB_nb>0)
×
2819
                                        dso.append(n);
×
2820
                        }
2821
                        break;
×
2822
                case 105: // RCW Catalogue
×
2823
                        for (const auto& n : dsoArray)
×
2824
                        {
2825
                                if (n->RCW_nb>0)
×
2826
                                        dso.append(n);
×
2827
                        }
2828
                        break;
×
2829
                case 106: // Collinder Catalogue
×
2830
                        for (const auto& n : dsoArray)
×
2831
                        {
2832
                                if (n->Cr_nb>0)
×
2833
                                        dso.append(n);
×
2834
                        }
2835
                        break;
×
2836
                case 107: // Melotte Catalogue
×
2837
                        for (const auto& n : dsoArray)
×
2838
                        {
2839
                                if (n->Mel_nb>0)
×
2840
                                        dso.append(n);
×
2841
                        }
2842
                        break;
×
2843
                case 108: // New General Catalogue
×
2844
                        for (const auto& n : dsoArray)
×
2845
                        {
2846
                                if (n->NGC_nb>0)
×
2847
                                        dso.append(n);
×
2848
                        }
2849
                        break;
×
2850
                case 109: // Index Catalogue
×
2851
                        for (const auto& n : dsoArray)
×
2852
                        {
2853
                                if (n->IC_nb>0)
×
2854
                                        dso.append(n);
×
2855
                        }
2856
                        break;
×
2857
                case 110: // Lynds' Catalogue of Bright Nebulae
×
2858
                        for (const auto& n : dsoArray)
×
2859
                        {
2860
                                if (n->LBN_nb>0)
×
2861
                                        dso.append(n);
×
2862
                        }
2863
                        break;
×
2864
                case 111: // Lynds' Catalogue of Dark Nebulae
×
2865
                        for (const auto& n : dsoArray)
×
2866
                        {
2867
                                if (n->LDN_nb>0)
×
2868
                                        dso.append(n);
×
2869
                        }
2870
                        break;
×
2871
                case 112: // Principal Galaxy Catalog
×
2872
                        for (const auto& n : dsoArray)
×
2873
                        {
2874
                                if (n->PGC_nb>0)
×
2875
                                        dso.append(n);
×
2876
                        }
2877
                        break;
×
2878
                case 113: // The Uppsala General Catalogue of Galaxies
×
2879
                        for (const auto& n : dsoArray)
×
2880
                        {
2881
                                if (n->UGC_nb>0)
×
2882
                                        dso.append(n);
×
2883
                        }
2884
                        break;
×
2885
                case 114: // Cederblad Catalog
×
2886
                        for (const auto& n : dsoArray)
×
2887
                        {
2888
                                if (!n->Ced_nb.isEmpty())
×
2889
                                        dso.append(n);
×
2890
                        }
2891
                        break;
×
2892
                case 115: // Atlas of Peculiar Galaxies (Arp)
×
2893
                        for (const auto& n : dsoArray)
×
2894
                        {
2895
                                if (n->Arp_nb>0)
×
2896
                                        dso.append(n);
×
2897
                        }
2898
                        break;
×
2899
                case 116: // The Catalogue of Interacting Galaxies by Vorontsov-Velyaminov (VV)
×
2900
                        for (const auto& n : dsoArray)
×
2901
                        {
2902
                                if (n->VV_nb>0)
×
2903
                                        dso.append(n);
×
2904
                        }
2905
                        break;
×
2906
                case 117: // Catalogue of Galactic Planetary Nebulae (PK)
×
2907
                        for (const auto& n : dsoArray)
×
2908
                        {
2909
                                if (!n->PK_nb.isEmpty())
×
2910
                                        dso.append(n);
×
2911
                        }
2912
                        break;
×
2913
                case 118: // Strasbourg-ESO Catalogue of Galactic Planetary Nebulae by Acker et. al. (PN G)
×
2914
                        for (const auto& n : dsoArray)
×
2915
                        {
2916
                                if (!n->PNG_nb.isEmpty())
×
2917
                                        dso.append(n);
×
2918
                        }
2919
                        break;
×
2920
                case 119: // A catalogue of Galactic supernova remnants by Green (SNR G)
×
2921
                        for (const auto& n : dsoArray)
×
2922
                        {
2923
                                if (!n->SNRG_nb.isEmpty())
×
2924
                                        dso.append(n);
×
2925
                        }
2926
                        break;
×
2927
                case 120: // A Catalog of Rich Clusters of Galaxies by Abell et. al. (ACO)
×
2928
                        for (const auto& n : dsoArray)
×
2929
                        {
2930
                                if (!n->ACO_nb.isEmpty())
×
2931
                                        dso.append(n);
×
2932
                        }
2933
                        break;
×
2934
                case 121: // Hickson Compact Group by Hickson et. al. (HCG)
×
2935
                        for (const auto& n : dsoArray)
×
2936
                        {
2937
                                if (!n->HCG_nb.isEmpty())
×
2938
                                        dso.append(n);
×
2939
                        }
2940
                        break;
×
2941
                case 122: // ESO/Uppsala Survey of the ESO(B) Atlas (ESO)
×
2942
                        for (const auto& n : dsoArray)
×
2943
                        {
2944
                                if (!n->ESO_nb.isEmpty())
×
2945
                                        dso.append(n);
×
2946
                        }
2947
                        break;
×
2948
                case 123: // Catalogue of southern stars embedded in nebulosity (VdBH)
×
2949
                        for (const auto& n : dsoArray)
×
2950
                        {
2951
                                if (!n->VdBH_nb.isEmpty())
×
2952
                                        dso.append(n);
×
2953
                        }
2954
                        break;
×
2955
                case 124: // Catalogue and distances of optically visible H II regions (DWB)
×
2956
                        for (const auto& n : dsoArray)
×
2957
                        {
2958
                                if (n->DWB_nb > 0)
×
2959
                                        dso.append(n);
×
2960
                        }
2961
                        break;
×
2962
                case 125: // Trumpler Catalogue (Tr)
×
2963
                        for (const auto& n : dsoArray)
×
2964
                        {
2965
                                if (n->Tr_nb > 0)
×
2966
                                        dso.append(n);
×
2967
                        }
2968
                        break;
×
2969
                case 126: // Stock Catalogue (St)
×
2970
                        for (const auto& n : dsoArray)
×
2971
                        {
2972
                                if (n->St_nb > 0)
×
2973
                                        dso.append(n);
×
2974
                        }
2975
                        break;
×
2976
                case 127: // Ruprecht Catalogue (Ru)
×
2977
                        for (const auto& n : dsoArray)
×
2978
                        {
2979
                                if (n->Ru_nb > 0)
×
2980
                                        dso.append(n);
×
2981
                        }
2982
                        break;
×
2983
                case 128: // van den Bergh-Hagen Catalogue (VdB-Ha)
×
2984
                        for (const auto& n : dsoArray)
×
2985
                        {
2986
                                if (n->VdBHa_nb > 0)
×
2987
                                        dso.append(n);
×
2988
                        }
2989
                        break;
×
2990
                case 150: // Dwarf galaxies [see NebulaList.hpp]
×
2991
                {
2992
                        NebulaP ds;
×
2993
                        for (unsigned int i = 0; i < sizeof(DWARF_GALAXIES) / sizeof(DWARF_GALAXIES[0]); i++)
×
2994
                        {
2995
                                ds = searchPGC(DWARF_GALAXIES[i]);
×
2996
                                if (!ds.isNull())
×
2997
                                        dso.append(ds);
×
2998
                        }
2999
                        break;
×
3000
                }
×
3001
                case 151: // Herschel 400 Catalogue [see NebulaList.hpp]
×
3002
                {
3003
                        NebulaP ds;
×
3004
                        for (unsigned int i = 0; i < sizeof(H400_LIST) / sizeof(H400_LIST[0]); i++)
×
3005
                        {
3006
                                ds = searchNGC(H400_LIST[i]);
×
3007
                                if (!ds.isNull())
×
3008
                                        dso.append(ds);
×
3009
                        }
3010
                        break;
×
3011
                }
×
3012
                case 152: // Jack Bennett's deep sky catalogue [see NebulaList.hpp]
×
3013
                {
3014
                        NebulaP ds;
×
3015
                        for (unsigned int i = 0; i < sizeof(BENNETT_LIST) / sizeof(BENNETT_LIST[0]); i++)
×
3016
                        {
3017
                                ds = searchNGC(BENNETT_LIST[i]);
×
3018
                                if (!ds.isNull())
×
3019
                                        dso.append(ds);
×
3020
                        }
3021
                        ds = searchMel(105);
×
3022
                        if (!ds.isNull())
×
3023
                                dso.append(ds);
×
3024
                        ds = searchIC(1459);
×
3025
                        if (!ds.isNull())
×
3026
                                dso.append(ds);
×
3027
                        break;
×
3028
                }
×
3029
                case 153: // James Dunlop's deep sky catalogue [see NebulaList.hpp]
×
3030
                {
3031
                        NebulaP ds;
×
3032
                        for (unsigned int i = 0; i < sizeof(DUNLOP_LIST) / sizeof(DUNLOP_LIST[0]); i++)
×
3033
                        {
3034
                                ds = searchNGC(DUNLOP_LIST[i]);
×
3035
                                if (!ds.isNull())
×
3036
                                        dso.append(ds);
×
3037
                        }
3038
                        break;
×
3039
                }
×
3040
                default:
×
3041
                {
3042
                        for (const auto& n : dsoArray)
×
3043
                        {
3044
                                if (n->nType==type)
×
3045
                                        dso.append(n);
×
3046
                        }
3047
                        break;
×
3048
                }
3049
        }
3050

3051
        return dso;
×
3052
}
×
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