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

Stellarium / stellarium / 15291801018

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

push

github

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

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

14124 existing lines in 74 files now uncovered.

14635 of 122664 relevant lines covered (11.93%)

18291.42 hits per line

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

0.0
/plugins/NavStars/src/gui/NavStarsWindow.cpp
1
/*
2
 * Navigational Stars plug-in for Stellarium
3
 *
4
 * Copyright (C) 2016 Alexander Wolf
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
#include "NavStars.hpp"
21
#include "NavStarsWindow.hpp"
22
#include "ui_navStarsWindow.h"
23

24
#include "StelApp.hpp"
25
#include "StelCore.hpp"
26
#include "StelLocaleMgr.hpp"
27
#include "StelModule.hpp"
28
#include "StelModuleMgr.hpp"
29
#include "StelGui.hpp"
30
#include "SolarSystem.hpp"
31
#include "StelUtils.hpp"
32

33
#include <QComboBox>
34

35
NavStarsWindow::NavStarsWindow() : StelDialog("NavStars"), ns(Q_NULLPTR)
×
36
{
37
        ui = new Ui_navStarsWindowForm();
×
38
}
×
39

40
NavStarsWindow::~NavStarsWindow()
×
41
{
42
        delete ui;
×
43
}
×
44

45
void NavStarsWindow::retranslate()
×
46
{
47
        if (dialog)
×
48
        {
49
                ui->retranslateUi(dialog);
×
50
                setAboutHtml();
×
51
                populateNavigationalStarsSets();
×
52
                populateNavigationalStarsSetDescription();
×
53
                populateToday();
×
54
        }
55
}
×
56

57
void NavStarsWindow::createDialogContent()
×
58
{
59
        ns = GETSTELMODULE(NavStars);
×
60
        ui->setupUi(dialog);
×
61

62
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
×
63
        connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
×
64
        connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
65

66
        populateNavigationalStarsSets();
×
67
        populateNavigationalStarsSetDescription();
×
68
        QString currentNsSetKey = ns->getCurrentNavigationalStarsSetKey();
×
69
        int idx = ui->nsSetComboBox->findData(currentNsSetKey, Qt::UserRole, Qt::MatchCaseSensitive);
×
70
        if (idx==-1)
×
71
        {
72
                // Use AngloAmerican as default
73
                idx = ui->nsSetComboBox->findData(QVariant("AngloAmerican"), Qt::UserRole, Qt::MatchCaseSensitive);
×
74
        }
75
        ui->nsSetComboBox->setCurrentIndex(idx);
×
76
        connect(ui->nsSetComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setNavigationalStarsSet(int)));
×
77

78
        connectBoolProperty(ui->displayAtStartupCheckBox,        "NavStars.displayAtStartup");
×
79
        connectBoolProperty(ui->highlightWhenVisible,                "NavStars.highlightWhenVisible");
×
80
        connectBoolProperty(ui->limitInfoToNavStars,                "NavStars.limitInfoToNavStars");
×
81
        connectBoolProperty(ui->upperLimb,                        "NavStars.upperLimb");
×
82
        connectBoolProperty(ui->tabulatedDisplay,                "NavStars.tabulatedDisplay");
×
83
        connectBoolProperty(ui->showExtraDecimals,                "NavStars.showExtraDecimals");
×
84
        connectBoolProperty(ui->useUTCCheckBox,                        "NavStars.useUTCTime");
×
85

86
        connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(saveSettings()));        
×
87
        connect(ui->pushButtonReset, SIGNAL(clicked()), this, SLOT(resetSettings()));
×
88

89
        populateToday();
×
90
        connect(ui->refreshData, SIGNAL(clicked()), this, SLOT(populateToday()));
×
91
        StelCore* core = StelApp::getInstance().getCore();
×
92
        connect(core, SIGNAL(dateChanged()), this, SLOT(populateToday()));
×
93
        connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(populateToday()));
×
94

95
        // About tab
96
        setAboutHtml();
×
97
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
98
        if(gui!=Q_NULLPTR)
×
99
                ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
×
100
}
×
101

102
void NavStarsWindow::saveSettings()
×
103
{
104
        ns->saveConfiguration();
×
105
}
×
106

107
void NavStarsWindow::resetSettings()
×
108
{
109
        if (askConfirmation())
×
110
        {
111
                qDebug() << "[NavStars] restore defaults...";
×
112
                ns->restoreDefaultConfiguration();
×
113
        }
114
        else
115
                qDebug() << "[NavStars] restore defaults is canceled...";
×
116
}
×
117

118
void NavStarsWindow::populateToday()
×
119
{
120
        StelCore* core = StelApp::getInstance().getCore();
×
121
        const double utcShift = core->getUTCOffset(core->getJD()) / 24.; // Fix DST shift...
×
122
        StelLocaleMgr* localeMgr = &StelApp::getInstance().getLocaleMgr();
×
123
        PlanetP sun = GETSTELMODULE(SolarSystem)->getSun();
×
124
        double duration;
125
        QString moonrise, moonset, dayBegin, dayEnd, civilTwilightBegin, civilTwilightEnd, nauticalTwilightBegin,
×
126
                nauticalTwilightEnd, astronomicalTwilightBegin, astronomicalTwilightEnd, dayDuration,
×
127
                civilTwilightDuration, nauticalTwilightDuration, astronomicalTwilightDuration, dash = QChar(0x2014);
×
128

129
        // Moon
130
        Vec4d moon = GETSTELMODULE(SolarSystem)->getMoon()->getRTSTime(core, 0.);
×
131
        if (moon[3]==30 || moon[3]<0 || moon[3]>50) // no moonrise on current date
×
132
                moonrise = dash;
×
133
        else
134
                moonrise = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(moon[0]+utcShift), true);
×
135

136
        if (moon[3]==40 || moon[3]<0 || moon[3]>50) // no moonset on current date
×
137
                moonset = dash;
×
138
        else
139
                moonset = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(moon[2]+utcShift), true);
×
140

141
        // day
142
        Vec4d day = sun->getRTSTime(core, 0.);
×
143
        if (day[3]==0.)
×
144
        {
145
                dayBegin = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(day[0]+utcShift), true);
×
146
                dayEnd = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(day[2]+utcShift), true);
×
147
                duration = qAbs(day[2]-day[0])*24.;
×
148
        }
149
        else
150
        {
151
                dayBegin = dayEnd = dash;
×
152
                duration = (day[3]>99.) ? 24. : 0.;
×
153
        }
154
        dayDuration = StelUtils::hoursToHmsStr(duration, true);
×
155

156
        // civil twilight
157
        Vec4d civilTwilight = sun->getRTSTime(core, -6.);
×
158
        if (civilTwilight[3]==0.)
×
159
        {
160
                civilTwilightBegin = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(civilTwilight[0]+utcShift), true);
×
161
                civilTwilightEnd = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(civilTwilight[2]+utcShift), true);
×
162
                duration = qAbs(civilTwilight[2]-civilTwilight[0])*24.;
×
163
        }
164
        else
165
        {
166
                civilTwilightBegin = civilTwilightEnd = dash;
×
167
                duration = (civilTwilight[3]>99.) ? 24. : 0.;
×
168
        }
169
        civilTwilightDuration = StelUtils::hoursToHmsStr(duration, true);
×
170

171
        // nautical twilight
172
        Vec4d nauticalTwilight = sun->getRTSTime(core, -12.);
×
173
        if (nauticalTwilight[3]==0.)
×
174
        {
175
                nauticalTwilightBegin = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(nauticalTwilight[0]+utcShift), true);
×
176
                nauticalTwilightEnd = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(nauticalTwilight[2]+utcShift), true);
×
177
                duration = qAbs(nauticalTwilight[2]-nauticalTwilight[0])*24.;
×
178
        }
179
        else
180
        {
181
                nauticalTwilightBegin = nauticalTwilightEnd = dash;
×
182
                duration = (nauticalTwilight[3]>99.) ? 24. : 0.;
×
183
        }
184
        nauticalTwilightDuration = StelUtils::hoursToHmsStr(duration, true);
×
185

186
        // astronomical twilight
187
        Vec4d astronomicalTwilight = sun->getRTSTime(core, -18.);
×
188
        if (astronomicalTwilight[3]==0.)
×
189
        {
190
                astronomicalTwilightBegin = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(astronomicalTwilight[0]+utcShift), true);
×
191
                astronomicalTwilightEnd = StelUtils::hoursToHmsStr(StelUtils::getHoursFromJulianDay(astronomicalTwilight[2]+utcShift), true);
×
192
                duration = qAbs(astronomicalTwilight[2]-astronomicalTwilight[0])*24.;
×
193
        }
194
        else
195
        {
196
                astronomicalTwilightBegin = astronomicalTwilightEnd = dash;
×
197
                duration = (astronomicalTwilight[3]>99.) ? 24. : 0.;
×
198
        }
199
        astronomicalTwilightDuration = StelUtils::hoursToHmsStr(duration, true);
×
200

201
        // fill the data
202
        const double JD=core->getJD();
×
203
        ui->labelToday->setText(localeMgr->getPrintableDateLocal(JD, core->getUTCOffset(JD)));
×
204
        ui->labelDayBegin->setText(dayBegin);
×
205
        ui->labelDayEnd->setText(dayEnd);
×
206
        ui->labelDayDuration->setText(dayDuration);
×
207
        ui->labelCivilTwilightBegin->setText(civilTwilightBegin);
×
208
        ui->labelCivilTwilightEnd->setText(civilTwilightEnd);
×
209
        ui->labelCivilTwilightDuration->setText(civilTwilightDuration);
×
210
        ui->labelNauticalTwilightBegin->setText(nauticalTwilightBegin);
×
211
        ui->labelNauticalTwilightEnd->setText(nauticalTwilightEnd);
×
212
        ui->labelNauticalTwilightDuration->setText(nauticalTwilightDuration);
×
213
        ui->labelAstronomicalTwilightBegin->setText(astronomicalTwilightBegin);
×
214
        ui->labelAstronomicalTwilightEnd->setText(astronomicalTwilightEnd);
×
215
        ui->labelAstronomicalTwilightDuration->setText(astronomicalTwilightDuration);
×
216
        ui->labelMoonRise->setText(moonrise);
×
217
        ui->labelMoonSet->setText(moonset);
×
218

219
        // tooltips
220
        // TRANSLATORS: full phrase is "XX° below the horizon"
221
        QString belowHorizon = q_("below the horizon");
×
222
        ui->labelCivilTwilight->setToolTip(QString("6° %1").arg(belowHorizon));
×
223
        ui->labelNauticalTwilight->setToolTip(QString("12° %1").arg(belowHorizon));
×
224
        ui->labelAstronomicalTwilight->setToolTip(QString("18° %1").arg(belowHorizon));
×
225
        QString twilights = q_("The sum of the daytime duration and duration of morning and evening twilights");
×
226
        ui->labelCivilTwilightDuration->setToolTip(twilights);
×
227
        ui->labelNauticalTwilightDuration->setToolTip(twilights);
×
228
        ui->labelAstronomicalTwilightDuration->setToolTip(twilights);
×
229
}
×
230

231
void NavStarsWindow::populateNavigationalStarsSets()
×
232
{
233
        Q_ASSERT(ui->nsSetComboBox);
×
234

235
        QComboBox* nsSets = ui->nsSetComboBox;
×
236

237
        //Save the current selection to be restored later
238
        nsSets->blockSignals(true);
×
239
        int index = nsSets->currentIndex();
×
240
        QVariant selectedNsSetId = nsSets->itemData(index);
×
241
        nsSets->clear();
×
242

243
        // TRANSLATORS: Part of full phrase: Anglo-American set of navigational stars
244
        nsSets->addItem(q_("Anglo-American"), "AngloAmerican");
×
245
        // TRANSLATORS: Part of full phrase: French set of navigational stars
246
        nsSets->addItem(q_("French"), "French");
×
247
        // TRANSLATORS: Part of full phrase: British (XVIII century) set of navigational stars
248
        nsSets->addItem(q_("British (XVIII century)"), "British");
×
249
        // TRANSLATORS: Part of full phrase: British (XIX century) set of navigational stars
NEW
250
        nsSets->addItem(q_("British (XIX century)"), "Wrinkles");
×
251
        // TRANSLATORS: Part of full phrase: Russian set of navigational stars
252
        nsSets->addItem(q_("Russian"), "Russian");
×
253
        // TRANSLATORS: Part of full phrase: Soviet aviation set of navigational stars
254
        nsSets->addItem(q_("Soviet aviation"), "USSRAvia");        
×
255
        // TRANSLATORS: Part of full phrase: German set of navigational stars
256
        nsSets->addItem(q_("German"), "German");
×
257

258
        // TRANSLATORS: Part of full phrase: Voskhod and Soyuz manned space programs set of navigational stars
UNCOV
259
        nsSets->addItem(q_("Voskhod and Soyuz manned space programs"), "USSRSpace");
×
260
        // TRANSLATORS: Part of full phrase: Apollo space program set of navigational stars
261
        nsSets->addItem(q_("Apollo space program"), "Apollo");
×
262
        
263
        // Telescope alignment stars
UNCOV
264
        nsSets->addItem("Gemini APS", "GeminiAPS");
×
UNCOV
265
        nsSets->addItem("Meade LX200", "MeadeLX200");
×
266
        nsSets->addItem("Meade ETX", "MeadeETX");
×
267
        nsSets->addItem("Meade Autostar #494", "MeadeAS494");
×
268
        nsSets->addItem("Meade Autostar #497", "MeadeAS497");
×
269
        nsSets->addItem("Celestron NexStar", "CelestronNS");
×
270
        nsSets->addItem("Skywatcher SynScan", "SkywatcherSS");
×
271
        nsSets->addItem("Vixen Starbook", "VixenSB");
×
272
        nsSets->addItem("Argo Navis", "ArgoNavis");
×
273
        nsSets->addItem("Sky Commander DSC", "SkyCommander");
×
274

275
        //Restore the selection
UNCOV
276
        index = nsSets->findData(selectedNsSetId, Qt::UserRole, Qt::MatchCaseSensitive);
×
UNCOV
277
        nsSets->setCurrentIndex(index);
×
278
        nsSets->blockSignals(false);
×
279
}
×
280

281
void NavStarsWindow::setNavigationalStarsSet(int nsSetID)
×
282
{
283
        QString currentNsSetID = ui->nsSetComboBox->itemData(nsSetID).toString();
×
UNCOV
284
        ns->setCurrentNavigationalStarsSetKey(currentNsSetID);
×
285
        populateNavigationalStarsSetDescription();
×
286
}
×
287

288
void NavStarsWindow::populateNavigationalStarsSetDescription(void)
×
289
{
290
        ui->nsSetDescription->setText(ns->getCurrentNavigationalStarsSetDescription());
×
UNCOV
291
}
×
292

293
void NavStarsWindow::setAboutHtml(void)
×
294
{
295
        QString html = "<html><head></head><body>";
×
UNCOV
296
        html += "<h2>" + q_("Navigational Stars Plug-in") + "</h2><table class='layout' width=\"90%\">";
×
297
        html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</strong></td><td>" + NAVSTARS_PLUGIN_VERSION + "</td></tr>";
×
298
        html += "<tr><td><strong>" + q_("License") + ":</strong></td><td>" + NAVSTARS_PLUGIN_LICENSE + "</td></tr>";
×
299
        html += "<tr><td rowspan='2'><strong>" + q_("Authors") + ":</strong></td><td>Alexander Wolf</td></tr>";
×
300
        html += "<tr><td>Andy Kirkham &lt;kirkham.andy@gmail.com&gt;</td></tr>";
×
301
        html += "</table>";
×
302

303
        html += "<p>" + q_("This plugin marks navigational stars from a selected set.") + "</p>";
×
UNCOV
304
        html += "<p/>";
×
305

306
        html += "<p>";
×
UNCOV
307
        html += q_("Additional information fields can be displayed by selecting \"Information &gt; Additional coordinates (from plugins)\"");
×
308
        html += "</p>";
×
309

310
        html += "<p>";
×
UNCOV
311
        html += q_("These fields are:");
×
312
        html += "<ul>";
×
313
        html += "<li>" + q_("GHA%1: The Greenwich Hour Angle of the first point of Aries.").arg("&#9800;") + "</li>";
×
314
        html += "<li>" + q_("SHA: Sidereal Hour Angle of the navigation star.") + "</li>";
×
315
        html += "<li>" + q_("LHA: The observer's Local Hour Angle to the navigation star.") + "</li>";
×
316
        //! TRANSLATORS: In Celestial Navigation "GP" is Ground Point, astronomers often use "sub-point" which is the geodetic location of a point where the star is at zenith.
317
        html += "<li>" + q_("GP: GHA/DEC: The navigation star's ground point as Greenwich Hour Angle and Declination.") + "</li>";        
×
318
        //! TRANSLATORS: In Celestial Navigation "AP" is Assumed Position, a point close by where the observer knows themselves to be. For example, from dead reckoning.
319
        html += "<li>" + q_("AP: LAT/LON: The observer's Assumed Position as geodetic latitude and longitude.") + "</li>";
×
320
        //! TRANSLATORS: In Celestial Navigation Hc is "computed height" from the Nautical Almanac where "height" is altitude. Likewise, Zn is computed azimuth, as seen from the AP.
321
        html += "<li>" + q_("Hc/Zn: The calculated height (altitude) and computed azimuth of navigation star, seen from AP.") + "</li>";
×
UNCOV
322
        html += "</ul></p>";
×
323

324
        html += "<p>";
×
UNCOV
325
        html += q_("The user has two different view options selected by \"Show information as a tabulated list\".");
×
326
        html += "</p>";
×
327

328
        html += "<p>";
×
UNCOV
329
        html += q_("When 'tabulated list' is selected the fields more closely follow the <em>The Nautical Almanac</em> format:");
×
330
        html += "<ul>";
×
331

332
        //! TRANSLATORS: In Celestial Navigation "height" is used where astronomers would use "altitude", Ho Height Observed
UNCOV
333
        html += "<li>" + q_("Ho: Simulated observed altitude of navigation star using a sextant.") + "</li>";
×
UNCOV
334
        html += "<li>" + q_("GHA%1: The Greenwich Hour Angle of the first point of Aries.").arg("&#9800;") + "</li>";
×
335
        html += "<li>" + q_("LMST: Local mean sidereal time.") + "</li>";
×
336
        html += "<li>" + q_("SHA: Sidereal Hour Angle of navigation star.") + "</li>";
×
337
        //! TRANSLATORS: celestial coordinate system, declination.
338
        html += "<li>" + q_("DEC: The navigation star's declination.") + "</li>";
×
UNCOV
339
        html += "<li>" + q_("GHA: The navigation star's Greenwich Hour Angle.") + "</li>";
×
340
        html += "<li>" + q_("LHA: The observer's Local Hour Angle to the navigation star.") + "</li>";
×
341
        //! TRANSLATORS: Geodetic coordinate system, latitude.
342
        html += "<li>" + q_("LAT: The observer's geodetic latitude.") + "</li>";
×
343
        //! TRANSLATORS: Geodetic coordinate system, longitude.
344
        html += "<li>" + q_("LON: The observer's geodetic longitude.") + "</li>";
×
345
        //! TRANSLATORS: The process of Sight Reduction outputs computed values. Hc computed height (altitude) for the AP
346
        html += "<li>" + q_("Hc: The AP calculated height (altitude) of navigation star.") + "</li>";
×
347
        //! TRANSLATORS: The process of Sight Reduction outputs computed values. Zn computed azimuth
348
        html += "<li>" + q_("Zn: The AP calculated azimuth of navigation star.") + "</li>";
×
UNCOV
349
        html += "</ul></p>";
×
350

351
        html += "<p>";
×
UNCOV
352
        html += q_("For further information please refer to the Stellarium User Guide.");
×
353
        html += "</p>";
×
354

355
        html += StelApp::getInstance().getModuleMgr().getStandardSupportLinksInfo("Navigational Stars plugin");
×
UNCOV
356
        html += "</body></html>";
×
357

358
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
UNCOV
359
        if(gui!=Q_NULLPTR)
×
360
        {
361
                QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
×
UNCOV
362
                ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet);
×
363
        }
×
364

365
        ui->aboutTextBrowser->setHtml(html);
×
UNCOV
366
}
×
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