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

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

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

14842 of 126472 relevant lines covered (11.74%)

21617.74 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
        ui->labelToday->setText(localeMgr->getPrintableDateLocal(core->getJD()));
×
203
        ui->labelDayBegin->setText(dayBegin);
×
204
        ui->labelDayEnd->setText(dayEnd);
×
205
        ui->labelDayDuration->setText(dayDuration);
×
206
        ui->labelCivilTwilightBegin->setText(civilTwilightBegin);
×
207
        ui->labelCivilTwilightEnd->setText(civilTwilightEnd);
×
208
        ui->labelCivilTwilightDuration->setText(civilTwilightDuration);
×
209
        ui->labelNauticalTwilightBegin->setText(nauticalTwilightBegin);
×
210
        ui->labelNauticalTwilightEnd->setText(nauticalTwilightEnd);
×
211
        ui->labelNauticalTwilightDuration->setText(nauticalTwilightDuration);
×
212
        ui->labelAstronomicalTwilightBegin->setText(astronomicalTwilightBegin);
×
213
        ui->labelAstronomicalTwilightEnd->setText(astronomicalTwilightEnd);
×
214
        ui->labelAstronomicalTwilightDuration->setText(astronomicalTwilightDuration);
×
215
        ui->labelMoonRise->setText(moonrise);
×
216
        ui->labelMoonSet->setText(moonset);
×
217

218
        // tooltips
219
        // TRANSLATORS: full phrase is "XX° below the horizon"
220
        QString belowHorizon = q_("below the horizon");
×
221
        ui->labelCivilTwilight->setToolTip(QString("6° %1").arg(belowHorizon));
×
222
        ui->labelNauticalTwilight->setToolTip(QString("12° %1").arg(belowHorizon));
×
223
        ui->labelAstronomicalTwilight->setToolTip(QString("18° %1").arg(belowHorizon));
×
224
}
×
225

226
void NavStarsWindow::populateNavigationalStarsSets()
×
227
{
228
        Q_ASSERT(ui->nsSetComboBox);
×
229

230
        QComboBox* nsSets = ui->nsSetComboBox;
×
231

232
        //Save the current selection to be restored later
233
        nsSets->blockSignals(true);
×
234
        int index = nsSets->currentIndex();
×
235
        QVariant selectedNsSetId = nsSets->itemData(index);
×
236
        nsSets->clear();
×
237

238
        // TRANSLATORS: Part of full phrase: Anglo-American set of navigational stars
239
        nsSets->addItem(q_("Anglo-American"), "AngloAmerican");
×
240
        // TRANSLATORS: Part of full phrase: French set of navigational stars
241
        nsSets->addItem(q_("French"), "French");
×
242
        // TRANSLATORS: Part of full phrase: Russian set of navigational stars
243
        nsSets->addItem(q_("Russian"), "Russian");
×
244
        // TRANSLATORS: Part of full phrase: Soviet aviation set of navigational stars
245
        nsSets->addItem(q_("Soviet aviation"), "USSRAvia");        
×
246
        // TRANSLATORS: Part of full phrase: German set of navigational stars
247
        nsSets->addItem(q_("German"), "German");
×
248

249
        // TRANSLATORS: Part of full phrase: Voskhod and Soyuz manned space programs set of navigational stars
250
        nsSets->addItem(q_("Voskhod and Soyuz manned space programs"), "USSRSpace");
×
251
        // TRANSLATORS: Part of full phrase: Apollo space program set of navigational stars
252
        nsSets->addItem(q_("Apollo space program"), "Apollo");
×
253
        
254
        // Telescope alignment stars
255
        nsSets->addItem("Gemini APS", "GeminiAPS");
×
256
        nsSets->addItem("Meade LX200", "MeadeLX200");
×
257
        nsSets->addItem("Meade ETX", "MeadeETX");
×
258
        nsSets->addItem("Meade Autostar #494", "MeadeAS494");
×
259
        nsSets->addItem("Meade Autostar #497", "MeadeAS497");
×
260
        nsSets->addItem("Celestron NexStar", "CelestronNS");
×
261
        nsSets->addItem("Skywatcher SynScan", "SkywatcherSS");
×
262
        nsSets->addItem("Vixen Starbook", "VixenSB");
×
263
        nsSets->addItem("Argo Navis", "ArgoNavis");
×
264
        nsSets->addItem("Sky Commander DSC", "SkyCommander");
×
265

266
        //Restore the selection
267
        index = nsSets->findData(selectedNsSetId, Qt::UserRole, Qt::MatchCaseSensitive);
×
268
        nsSets->setCurrentIndex(index);
×
269
        nsSets->blockSignals(false);
×
270
}
×
271

272
void NavStarsWindow::setNavigationalStarsSet(int nsSetID)
×
273
{
274
        QString currentNsSetID = ui->nsSetComboBox->itemData(nsSetID).toString();
×
275
        ns->setCurrentNavigationalStarsSetKey(currentNsSetID);
×
276
        populateNavigationalStarsSetDescription();
×
277
}
×
278

279
void NavStarsWindow::populateNavigationalStarsSetDescription(void)
×
280
{
281
        ui->nsSetDescription->setText(ns->getCurrentNavigationalStarsSetDescription());
×
282
}
×
283

284
void NavStarsWindow::setAboutHtml(void)
×
285
{
286
        QString html = "<html><head></head><body>";
×
287
        html += "<h2>" + q_("Navigational Stars Plug-in") + "</h2><table width=\"90%\">";
×
288
        html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</strong></td><td>" + NAVSTARS_PLUGIN_VERSION + "</td></tr>";
×
289
        html += "<tr><td><strong>" + q_("License") + ":</strong></td><td>" + NAVSTARS_PLUGIN_LICENSE + "</td></tr>";
×
290
        html += "<tr><td rowspan='2'><strong>" + q_("Authors") + ":</strong></td><td>Alexander Wolf</td></tr>";
×
291
        html += "<tr><td>Andy Kirkham &lt;kirkham.andy@gmail.com&gt;</td></tr>";
×
292
        html += "</table>";
×
293

294
        html += "<p>" + q_("This plugin marks navigational stars from a selected set.") + "</p>";
×
295
        html += "<p/>";
×
296

297
        html += "<p>";
×
298
        html += q_("Additional information fields can be displayed by selecting \"Information &gt; Additional coordinates (from plugins)\"");
×
299
        html += "</p>";
×
300

301
        html += "<p>";
×
302
        html += q_("These fields are:");
×
303
        html += "<ul>";
×
304
        html += "<li>" + q_("GHA%1: The Greenwich Hour Angle of the first point of Aries.").arg("&#9800;") + "</li>";
×
305
        html += "<li>" + q_("SHA: Sidereal Hour Angle of the navigation star.") + "</li>";
×
306
        html += "<li>" + q_("LHA: The observer's Local Hour Angle to the navigation star.") + "</li>";
×
307
        //! 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.
308
        html += "<li>" + q_("GP: GHA/DEC: The navigation star's ground point as Greenwich Hour Angle and Declination.") + "</li>";        
×
309
        //! TRANSLATORS: In Celestial Navigation "AP" is Assumed Position, a point close by where the observer knows themselves to be. For example, from dead reckoning.
310
        html += "<li>" + q_("AP: LAT/LON: The observer's Assumed Position as geodetic latitude and longitude.") + "</li>";
×
311
        //! 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.
312
        html += "<li>" + q_("Hc/Zn: The calculated height (altitude) and computed azimuth of navigation star, seen from AP.") + "</li>";
×
313
        html += "</ul></p>";
×
314

315
        html += "<p>";
×
316
        html += q_("The user has two different view options selected by \"Show information as a tabulated list\".");
×
317
        html += "</p>";
×
318

319
        html += "<p>";
×
320
        html += q_("When 'tabulated list' is selected the fields more closely follow the <em>The Nautical Almanac</em> format:");
×
321
        html += "<ul>";
×
322

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

342
        html += "<p>";
×
343
        html += q_("For further information please refer to the Stellarium User Guide.");
×
344
        html += "</p>";
×
345

346
        html += StelApp::getInstance().getModuleMgr().getStandardSupportLinksInfo("Navigational Stars plugin");
×
347
        html += "</body></html>";
×
348

349
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
350
        if(gui!=Q_NULLPTR)
×
351
        {
352
                QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
×
353
                ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet);
×
354
        }
×
355

356
        ui->aboutTextBrowser->setHtml(html);
×
357
}
×
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