1 /*
2  * ArchaeoLines plug-in for Stellarium
3  *
4  * Copyright (C) 2014 Georg Zotti
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 <QRegularExpression>
21 
22 #include "ArchaeoLines.hpp"
23 #include "ArchaeoLinesDialog.hpp"
24 #include "ui_archaeoLinesDialog.h"
25 
26 #include "ArchaeoLinesDialogLocations.hpp"
27 
28 #include "StelApp.hpp"
29 #include "StelLocaleMgr.hpp"
30 #include "StelModule.hpp"
31 #include "StelModuleMgr.hpp"
32 #include "StelMainView.hpp"
33 #include "StelOpenGL.hpp"
34 #include "AngleSpinBox.hpp"
35 
ArchaeoLinesDialog()36 ArchaeoLinesDialog::ArchaeoLinesDialog()
37 	: StelDialog("ArchaeoLines")
38 	, al(Q_NULLPTR)
39 {
40 	ui = new Ui_archaeoLinesDialog();
41 	locationsDialog = new ArchaeoLinesDialogLocations();
42 }
43 
~ArchaeoLinesDialog()44 ArchaeoLinesDialog::~ArchaeoLinesDialog()
45 {
46 	delete locationsDialog; locationsDialog=Q_NULLPTR;
47 	delete ui;              ui=Q_NULLPTR;
48 }
49 
retranslate()50 void ArchaeoLinesDialog::retranslate()
51 {
52 	if (dialog)
53 	{
54 		ui->retranslateUi(dialog);
55 		setAboutHtml();
56 	}
57 }
58 
createDialogContent()59 void ArchaeoLinesDialog::createDialogContent()
60 {
61 	al = GETSTELMODULE(ArchaeoLines);
62 	ui->setupUi(dialog);
63 
64 	// Kinetic scrolling
65 	kineticScrollingList << ui->aboutTextBrowser;
66 	StelGui* gui= static_cast<StelGui*>(StelApp::getInstance().getGui());
67 	enableKineticScrolling(gui->getFlagUseKineticScrolling());
68 	connect(gui, SIGNAL(flagUseKineticScrollingChanged(bool)), this, SLOT(enableKineticScrolling(bool)));
69 
70 	connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
71 	connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
72 	connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
73 
74 	connectIntProperty(ui->lineWidthSpinBox, "ArchaeoLines.lineWidth");
75 
76 	connectBoolProperty(ui->equinoxCheckBox,         "ArchaeoLines.flagShowEquinox");
77 	connectBoolProperty(ui->solsticesCheckBox,       "ArchaeoLines.flagShowSolstices");
78 	connectBoolProperty(ui->crossquarterCheckBox,    "ArchaeoLines.flagShowCrossquarters");
79 	connectBoolProperty(ui->majorStandstillCheckBox, "ArchaeoLines.flagShowMajorStandstills");
80 	connectBoolProperty(ui->minorStandstillCheckBox, "ArchaeoLines.flagShowMinorStandstills");
81 	connectBoolProperty(ui->polarCirclesCheckBox,    "ArchaeoLines.flagShowPolarCircles");
82 	connectBoolProperty(ui->zenithPassageCheckBox,   "ArchaeoLines.flagShowZenithPassage");
83 	connectBoolProperty(ui->nadirPassageCheckBox,    "ArchaeoLines.flagShowNadirPassage");
84 	connectBoolProperty(ui->selectedObjectCheckBox,  "ArchaeoLines.flagShowSelectedObject");
85 	connectBoolProperty(ui->selectedObjectAzimuthCheckBox,    "ArchaeoLines.flagShowSelectedObjectAzimuth");
86 	connectBoolProperty(ui->selectedObjectHourAngleCheckBox,  "ArchaeoLines.flagShowSelectedObjectHourAngle");
87 	connectBoolProperty(ui->currentSunCheckBox,      "ArchaeoLines.flagShowCurrentSun");
88 	connectBoolProperty(ui->currentMoonCheckBox,     "ArchaeoLines.flagShowCurrentMoon");
89 
90 	connectIntProperty(ui->currentPlanetComboBox, "ArchaeoLines.enumShowCurrentPlanet");
91 
92 	ui->geographicLocation1LatitudeDoubleSpinBox->setPrefixType(AngleSpinBox::Latitude);
93 	ui->geographicLocation1LatitudeDoubleSpinBox->setMinimum(-90., true);
94 	ui->geographicLocation1LatitudeDoubleSpinBox->setMaximum(90., true);
95 	ui->geographicLocation1LatitudeDoubleSpinBox->setWrapping(false);
96 	ui->geographicLocation2LatitudeDoubleSpinBox->setPrefixType(AngleSpinBox::Latitude);
97 	ui->geographicLocation2LatitudeDoubleSpinBox->setMinimum(-90., true);
98 	ui->geographicLocation2LatitudeDoubleSpinBox->setMaximum(90., true);
99 	ui->geographicLocation2LatitudeDoubleSpinBox->setWrapping(false);
100 	ui->geographicLocation1LongitudeDoubleSpinBox->setPrefixType(AngleSpinBox::Longitude);
101 	ui->geographicLocation1LongitudeDoubleSpinBox->setMinimum(-180., true);
102 	ui->geographicLocation1LongitudeDoubleSpinBox->setMaximum(180., true);
103 	ui->geographicLocation1LongitudeDoubleSpinBox->setWrapping(true);
104 	ui->geographicLocation2LongitudeDoubleSpinBox->setPrefixType(AngleSpinBox::Longitude);
105 	ui->geographicLocation2LongitudeDoubleSpinBox->setMinimum(-180., true);
106 	ui->geographicLocation2LongitudeDoubleSpinBox->setMaximum(180., true);
107 	ui->geographicLocation2LongitudeDoubleSpinBox->setWrapping(true);
108 	ui->customAzimuth1DoubleSpinBox->setPrefixType(AngleSpinBox::Normal);
109 	ui->customAzimuth1DoubleSpinBox->setMinimum(0., true);
110 	ui->customAzimuth1DoubleSpinBox->setMaximum(360., true);
111 	ui->customAzimuth1DoubleSpinBox->setWrapping(true);
112 	ui->customAzimuth2DoubleSpinBox->setPrefixType(AngleSpinBox::Normal);
113 	ui->customAzimuth2DoubleSpinBox->setMinimum(0., true);
114 	ui->customAzimuth2DoubleSpinBox->setMaximum(360., true);
115 	ui->customAzimuth2DoubleSpinBox->setWrapping(true);
116 	ui->customAltitude1DoubleSpinBox->setPrefixType(AngleSpinBox::Normal);
117 	ui->customAltitude1DoubleSpinBox->setMinimum(-90., true);
118 	ui->customAltitude1DoubleSpinBox->setMaximum( 90., true);
119 	ui->customAltitude1DoubleSpinBox->setWrapping(false);
120 	ui->customAltitude2DoubleSpinBox->setPrefixType(AngleSpinBox::Normal);
121 	ui->customAltitude2DoubleSpinBox->setMinimum(-90., true);
122 	ui->customAltitude2DoubleSpinBox->setMaximum( 90., true);
123 	ui->customAltitude2DoubleSpinBox->setWrapping(false);
124 	ui->customDeclination1DoubleSpinBox->setPrefixType(AngleSpinBox::NormalPlus);
125 	ui->customDeclination1DoubleSpinBox->setMinimum(-90., true);
126 	ui->customDeclination1DoubleSpinBox->setMaximum(90., true);
127 	ui->customDeclination1DoubleSpinBox->setWrapping(false);
128 	ui->customDeclination2DoubleSpinBox->setPrefixType(AngleSpinBox::NormalPlus);
129 	ui->customDeclination2DoubleSpinBox->setMinimum(-90., true);
130 	ui->customDeclination2DoubleSpinBox->setMaximum(90., true);
131 	ui->customDeclination2DoubleSpinBox->setWrapping(false);
132 
133 	// TBD: Store a decimal/DMS selection property separately?
134 	setDisplayFormatForSpins(StelApp::getInstance().getFlagShowDecimalDegrees());
135 	connect(&StelApp::getInstance(), SIGNAL(flagShowDecimalDegreesChanged(bool)), this, SLOT(setDisplayFormatForSpins(bool)));
136 
137 	connect(ui->geographicLocation1PickPushButton, &QPushButton::clicked, [=](){locationsDialog->setVisible(true); locationsDialog->setModalContext(1);});
138 	connect(ui->geographicLocation2PickPushButton, &QPushButton::clicked, [=](){locationsDialog->setVisible(true); locationsDialog->setModalContext(2);});
139 
140 	connectBoolProperty(ui->geographicLocation1CheckBox,                 "ArchaeoLines.flagShowGeographicLocation1");
141 	connectBoolProperty(ui->geographicLocation2CheckBox,                 "ArchaeoLines.flagShowGeographicLocation2");
142 	connectDoubleProperty(ui->geographicLocation1LongitudeDoubleSpinBox, "ArchaeoLines.geographicLocation1Longitude");
143 	connectDoubleProperty(ui->geographicLocation1LatitudeDoubleSpinBox,  "ArchaeoLines.geographicLocation1Latitude");
144 	connectDoubleProperty(ui->geographicLocation2LongitudeDoubleSpinBox, "ArchaeoLines.geographicLocation2Longitude");
145 	connectDoubleProperty(ui->geographicLocation2LatitudeDoubleSpinBox,  "ArchaeoLines.geographicLocation2Latitude");
146 	connectStringProperty(ui->geographicLocation1LineEdit,               "ArchaeoLines.geographicLocation1Label");
147 	connectStringProperty(ui->geographicLocation2LineEdit,               "ArchaeoLines.geographicLocation2Label");
148 
149 	connectBoolProperty(ui->customAzimuth1CheckBox,        "ArchaeoLines.flagShowCustomAzimuth1");
150 	connectBoolProperty(ui->customAzimuth2CheckBox,        "ArchaeoLines.flagShowCustomAzimuth2");
151 	connectDoubleProperty(ui->customAzimuth1DoubleSpinBox, "ArchaeoLines.customAzimuth1");
152 	connectDoubleProperty(ui->customAzimuth2DoubleSpinBox, "ArchaeoLines.customAzimuth2");
153 	connectStringProperty(ui->customAzimuth1LineEdit,      "ArchaeoLines.customAzimuth1Label");
154 	connectStringProperty(ui->customAzimuth2LineEdit,      "ArchaeoLines.customAzimuth2Label");
155 
156 	connectBoolProperty(ui->customAltitude1CheckBox,        "ArchaeoLines.flagShowCustomAltitude1");
157 	connectBoolProperty(ui->customAltitude2CheckBox,        "ArchaeoLines.flagShowCustomAltitude2");
158 	connectDoubleProperty(ui->customAltitude1DoubleSpinBox, "ArchaeoLines.customAltitude1");
159 	connectDoubleProperty(ui->customAltitude2DoubleSpinBox, "ArchaeoLines.customAltitude2");
160 	connectStringProperty(ui->customAltitude1LineEdit,      "ArchaeoLines.customAltitude1Label");
161 	connectStringProperty(ui->customAltitude2LineEdit,      "ArchaeoLines.customAltitude2Label");
162 
163 	connectBoolProperty(ui->customDeclination1CheckBox,        "ArchaeoLines.flagShowCustomDeclination1");
164 	connectBoolProperty(ui->customDeclination2CheckBox,        "ArchaeoLines.flagShowCustomDeclination2");
165 	connectDoubleProperty(ui->customDeclination1DoubleSpinBox, "ArchaeoLines.customDeclination1");
166 	connectDoubleProperty(ui->customDeclination2DoubleSpinBox, "ArchaeoLines.customDeclination2");
167 	connectStringProperty(ui->customDeclination1LineEdit,      "ArchaeoLines.customDeclination1Label");
168 	connectStringProperty(ui->customDeclination2LineEdit,      "ArchaeoLines.customDeclination2Label");
169 
170 	connectColorButton(ui->equinoxColorToolButton,                 "ArchaeoLines.equinoxColor",                 "ArchaeoLines/color_equinox");
171 	connectColorButton(ui->solsticesColorToolButton,               "ArchaeoLines.solsticesColor",               "ArchaeoLines/color_solstices");
172 	connectColorButton(ui->crossquarterColorToolButton,            "ArchaeoLines.crossquartersColor",           "ArchaeoLines/color_crossquarters");
173 	connectColorButton(ui->majorStandstillColorToolButton,         "ArchaeoLines.majorStandstillColor",         "ArchaeoLines/color_major_standstill");
174 	connectColorButton(ui->minorStandstillColorToolButton,         "ArchaeoLines.minorStandstillColor",         "ArchaeoLines/color_minor_standstill");
175 	connectColorButton(ui->polarCirclesColorToolButton,            "ArchaeoLines.polarCirclesColor",            "ArchaeoLines/color_polar_circles");
176 	connectColorButton(ui->zenithPassageColorToolButton,           "ArchaeoLines.zenithPassageColor",           "ArchaeoLines/color_zenith_passage");
177 	connectColorButton(ui->nadirPassageColorToolButton,            "ArchaeoLines.nadirPassageColor",            "ArchaeoLines/color_nadir_passage");
178 	connectColorButton(ui->selectedObjectColorToolButton,          "ArchaeoLines.selectedObjectColor",          "ArchaeoLines/color_selected_object");
179 	connectColorButton(ui->selectedObjectAzimuthColorToolButton,   "ArchaeoLines.selectedObjectAzimuthColor",   "ArchaeoLines/color_selected_object_azimuth");
180 	connectColorButton(ui->selectedObjectHourAngleColorToolButton, "ArchaeoLines.selectedObjectHourAngleColor", "ArchaeoLines/color_selected_object_hour_angle");
181 	connectColorButton(ui->currentSunColorToolButton,              "ArchaeoLines.currentSunColor",              "ArchaeoLines/color_current_sun");
182 	connectColorButton(ui->currentMoonColorToolButton,             "ArchaeoLines.currentMoonColor",             "ArchaeoLines/color_current_moon");
183 	connectColorButton(ui->currentPlanetColorToolButton,           "ArchaeoLines.currentPlanetColor",           "ArchaeoLines/color_current_planet");
184 	connectColorButton(ui->geographicLocation1ColorToolButton,     "ArchaeoLines.geographicLocation1Color",     "ArchaeoLines/color_geographic_location_1");
185 	connectColorButton(ui->geographicLocation2ColorToolButton,     "ArchaeoLines.geographicLocation2Color",     "ArchaeoLines/color_geographic_location_2");
186 	connectColorButton(ui->customAzimuth1ColorToolButton,          "ArchaeoLines.customAzimuth1Color",          "ArchaeoLines/color_custom_azimuth_1");
187 	connectColorButton(ui->customAzimuth2ColorToolButton,          "ArchaeoLines.customAzimuth2Color",          "ArchaeoLines/color_custom_azimuth_2");
188 	connectColorButton(ui->customAltitude1ColorToolButton,         "ArchaeoLines.customAltitude1Color",         "ArchaeoLines/color_custom_altitude_1");
189 	connectColorButton(ui->customAltitude2ColorToolButton,         "ArchaeoLines.customAltitude2Color",         "ArchaeoLines/color_custom_altitude_2");
190 	connectColorButton(ui->customDeclination1ColorToolButton,      "ArchaeoLines.customDeclination1Color",      "ArchaeoLines/color_custom_declination_1");
191 	connectColorButton(ui->customDeclination2ColorToolButton,      "ArchaeoLines.customDeclination2Color",      "ArchaeoLines/color_custom_declination_2");
192 
193 	connect(ui->customAzimuth1PushButton,     SIGNAL(clicked()), this, SLOT(assignCustomAzimuth1FromSelection()));
194 	connect(ui->customAzimuth2PushButton,     SIGNAL(clicked()), this, SLOT(assignCustomAzimuth2FromSelection()));
195 	connect(ui->customAltitude1PushButton,    SIGNAL(clicked()), this, SLOT(assignCustomAltitude1FromSelection()));
196 	connect(ui->customAltitude2PushButton,    SIGNAL(clicked()), this, SLOT(assignCustomAltitude2FromSelection()));
197 	connect(ui->customDeclination1PushButton, SIGNAL(clicked()), this, SLOT(assignCustomDeclination1FromSelection()));
198 	connect(ui->customDeclination2PushButton, SIGNAL(clicked()), this, SLOT(assignCustomDeclination2FromSelection()));
199 
200 	connect(ui->restoreDefaultsButton,   SIGNAL(clicked()), this, SLOT(resetArchaeoLinesSettings()));
201 	connect(ui->restoreDefaultsButtonCL, SIGNAL(clicked()), this, SLOT(resetArchaeoLinesSettings()));
202 
203 	setAboutHtml();
204 }
205 
setAboutHtml(void)206 void ArchaeoLinesDialog::setAboutHtml(void)
207 {
208 	// Regexp to replace {text} with an HTML link.
209 	QRegularExpression a_rx("[{]([^{]*)[}]");
210 
211 	QString html = "<html><head></head><body>";
212 	html += "<h2>" + q_("ArchaeoLines Plug-in") + "</h2><table width=\"90%\">";
213 	html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</strong></td><td>" + ARCHAEOLINES_PLUGIN_VERSION + "</td></tr>";
214 	html += "<tr><td><strong>" + q_("License") + ":</strong></td><td>" + ARCHAEOLINES_PLUGIN_LICENSE + "</td></tr>";
215 	html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Georg Zotti</td></tr>";
216 	//html += "<tr><td><strong>" + q_("Contributors") + ":</strong></td><td> List with br separators </td></tr>";
217 	html += "</table>";
218 
219 	html += "<p>" + q_("The ArchaeoLines plugin displays any combination of declination arcs most relevant to archaeo- or ethnoastronomical studies.") + "</p>";
220 	html += "<ul><li>" + q_("Declinations of equinoxes (i.e. equator) and the solstices") + "</li>";
221 	html += "<li>" + q_("Declinations of the crossquarter days (days right between solstices and equinoxes)") + "</li>";
222 	html += "<li>" + q_("Declinations of the Major Lunar Standstills") + "</li>";
223 	html += "<li>" + q_("Declinations of the Minor Lunar Standstills") + "</li>";
224 	html += "<li>" + q_("Declination of the Polar circles") + "</li>";
225 	html += "<li>" + q_("Declination of the Zenith passage") + "</li>";
226 	html += "<li>" + q_("Declination of the Nadir passage") + "</li>";
227 	html += "<li>" + q_("Declination of the currently selected object") + "</li>";
228 	html += "<li>" + q_("Azimuth of the currently selected object") + "</li>";
229 	html += "<li>" + q_("Hour Angle of the currently selected object") + "</li>";
230 	html += "<li>" + q_("Current declination of the sun") + "</li>";
231 	html += "<li>" + q_("Current declination of the moon") + "</li>";
232 	html += "<li>" + q_("Current declination of a naked-eye planet") + "</li></ul>";
233 	html += "<p>" + q_("The lunar lines include horizon parallax effects. "
234 			   "There are two lines each drawn, for maximum and minimum distance of the moon. "
235 			   "Note that declination of the moon at the major standstill can exceed the "
236 			   "indicated limits if it is high in the sky due to parallax effects.") + "</p>";
237 	html += "<p>" + q_("Some religions, most notably Islam, adhere to a practice of observing a prayer direction towards a particular location. "
238 			   "Azimuth lines for two locations can be shown. Default locations are Mecca (Kaaba) and Jerusalem, "
239 			   "but you can select locations from Stellarium's locations list or enter arbitrary locations. "
240 			   "The directions are computed based on spherical trigonometry on a spherical Earth.") + "</p>";
241 	html += "<p>" + q_("In addition, up to two lines each with arbitrary azimuth, altitude and declination lines with custom label can be shown.") + "</p>";
242 
243 	html += "<h3>" + q_("Publications") + "</h3>";
244 	html += "<p>"  + q_("If you use this plugin in your publications, please cite:") + "</p>";
245 	html += "<ul>";
246 	html += "<li>" + QString("{Georg Zotti: Open Source Virtual Archaeoastronomy}. Mediterranean Archaeology and Archaeometry, Vol. 16, No 4 (2016), pp. 17-24.")
247 			.toHtmlEscaped().replace(a_rx, "<a href=\"http://maajournal.com/Issues/2016/Vol16-4/Full3.pdf\">\\1</a>") + "</li>";
248 	html += "<li>" + QString("{Georg Zotti, Susanne M. Hoffmann, Alexander Wolf, Fabien Chéreau, Guillaume Chéreau: The simulated sky: Stellarium for cultural astronomy research.} Journal for Skyscape Archaeology, 6.2, 2021, pp. 221-258.")
249 			     .toHtmlEscaped().replace(a_rx, "<a href=\"https://doi.org/10.1558/jsa.17822\">\\1</a>") + "</li>";
250 	html += "</ul>";
251 
252 	html += StelApp::getInstance().getModuleMgr().getStandardSupportLinksInfo("ArchaeoLines plugin");
253 
254 	html += "</body></html>";
255 
256 	StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
257 	if(gui!=Q_NULLPTR)
258 	{
259 		QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
260 		ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet);
261 	}
262 
263 	ui->aboutTextBrowser->setHtml(html);
264 }
265 
266 
resetArchaeoLinesSettings()267 void ArchaeoLinesDialog::resetArchaeoLinesSettings()
268 {
269 	if (askConfirmation())
270 	{
271 		qDebug() << "[ArchaeoLines] restore defaults...";
272 		al->restoreDefaultSettings();
273 		ui->geographicLocation1LineEdit->setText(al->getLineLabel(ArchaeoLine::GeographicLocation1));
274 		ui->geographicLocation2LineEdit->setText(al->getLineLabel(ArchaeoLine::GeographicLocation2));
275 		ui->customAzimuth1LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomAzimuth1));
276 		ui->customAzimuth2LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomAzimuth2));
277 		ui->customAltitude1LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomAltitude1));
278 		ui->customAltitude2LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomAltitude2));
279 		ui->customDeclination1LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomDeclination1));
280 		ui->customDeclination2LineEdit->setText(al->getLineLabel(ArchaeoLine::CustomDeclination2));
281 	}
282 	else
283 		qDebug() << "[ArchaeoLines] restore defaults is canceled...";
284 }
285 
setDisplayFormatForSpins(bool flagDecimalDegrees)286 void ArchaeoLinesDialog::setDisplayFormatForSpins(bool flagDecimalDegrees)
287 {
288 	int places = 2;
289 	AngleSpinBox::DisplayFormat format = AngleSpinBox::DMSSymbols;
290 	if (flagDecimalDegrees)
291 	{
292 		places = 6;
293 		format = AngleSpinBox::DecimalDeg;
294 	}
295 	const QList<AngleSpinBox *> list={ui->geographicLocation1LatitudeDoubleSpinBox,  ui->geographicLocation2LatitudeDoubleSpinBox,
296 					  ui->geographicLocation1LongitudeDoubleSpinBox, ui->geographicLocation2LongitudeDoubleSpinBox,
297 					  ui->customAzimuth1DoubleSpinBox,               ui->customAzimuth2DoubleSpinBox,
298 					  ui->customAltitude1DoubleSpinBox,              ui->customAltitude2DoubleSpinBox,
299 					  ui->customDeclination1DoubleSpinBox,           ui->customDeclination2DoubleSpinBox};
300 	QList<AngleSpinBox *>::const_iterator i;
301 	for (i=list.constBegin(); i!=list.constEnd(); ++i)
302 	{
303 		(*i)->setDecimals(places);
304 		(*i)->setDisplayFormat(format);
305 	}
306 }
307 
assignCustomAzimuth1FromSelection()308 void ArchaeoLinesDialog::assignCustomAzimuth1FromSelection()
309 {
310 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
311 	if (!mgr->getWasSelected())
312 		return;
313 
314 	StelCore *core=StelApp::getInstance().getCore();
315 	StelObjectP sel=mgr->getSelectedObject().at(0);
316 	Vec3d altAz=sel->getAltAzPosAuto(core);
317 	double az, alt;
318 	StelUtils::rectToSphe(&az, &alt, altAz);
319 	az=M_PI-az;
320 	al->setCustomAzimuth1(az*M_180_PI);
321 	al->setCustomAzimuth1Label(sel->getNameI18n());
322 	al->showCustomAzimuth1(true);
323 }
assignCustomAzimuth2FromSelection()324 void ArchaeoLinesDialog::assignCustomAzimuth2FromSelection()
325 {
326 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
327 	if (!mgr->getWasSelected())
328 		return;
329 
330 	StelCore *core=StelApp::getInstance().getCore();
331 	StelObjectP sel=mgr->getSelectedObject().at(0);
332 	Vec3d altAz=sel->getAltAzPosAuto(core);
333 	double az, alt;
334 	StelUtils::rectToSphe(&az, &alt, altAz);
335 	az=M_PI-az;
336 	al->setCustomAzimuth2(az*M_180_PI);
337 	al->setCustomAzimuth2Label(sel->getNameI18n());
338 	al->showCustomAzimuth2(true);
339 }
assignCustomAltitude1FromSelection()340 void ArchaeoLinesDialog::assignCustomAltitude1FromSelection()
341 {
342 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
343 	if (!mgr->getWasSelected())
344 		return;
345 
346 	StelCore *core=StelApp::getInstance().getCore();
347 	StelObjectP sel=mgr->getSelectedObject().at(0);
348 	Vec3d altAz=sel->getAltAzPosAuto(core);
349 	double az, alt;
350 	StelUtils::rectToSphe(&az, &alt, altAz);
351 	al->setCustomAltitude1(alt*M_180_PI);
352 	al->setCustomAltitude1Label(sel->getNameI18n());
353 	al->showCustomAltitude1(true);
354 }
assignCustomAltitude2FromSelection()355 void ArchaeoLinesDialog::assignCustomAltitude2FromSelection()
356 {
357 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
358 	if (!mgr->getWasSelected())
359 		return;
360 
361 	StelCore *core=StelApp::getInstance().getCore();
362 	StelObjectP sel=mgr->getSelectedObject().at(0);
363 	Vec3d altAz=sel->getAltAzPosAuto(core);
364 	double az, alt;
365 	StelUtils::rectToSphe(&az, &alt, altAz);
366 	al->setCustomAltitude2(alt*M_180_PI);
367 	al->setCustomAltitude2Label(sel->getNameI18n());
368 	al->showCustomAltitude2(true);
369 }
assignCustomDeclination1FromSelection()370 void ArchaeoLinesDialog::assignCustomDeclination1FromSelection()
371 {
372 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
373 	if (!mgr->getWasSelected())
374 		return;
375 
376 	StelCore *core=StelApp::getInstance().getCore();
377 	StelObjectP sel=mgr->getSelectedObject().at(0);
378 	Vec3d eq=sel->getEquinoxEquatorialPos(core);
379 	double ra, dec;
380 	StelUtils::rectToSphe(&ra, &dec, eq);
381 	al->setCustomDeclination1(dec*M_180_PI);
382 	al->setCustomDeclination1Label(sel->getNameI18n());
383 	al->showCustomDeclination1(true);
384 }
assignCustomDeclination2FromSelection()385 void ArchaeoLinesDialog::assignCustomDeclination2FromSelection()
386 {
387 	StelObjectMgr *mgr=GETSTELMODULE(StelObjectMgr);
388 	if (!mgr->getWasSelected())
389 		return;
390 
391 	StelCore *core=StelApp::getInstance().getCore();
392 	StelObjectP sel=mgr->getSelectedObject().at(0);
393 	Vec3d eq=sel->getEquinoxEquatorialPos(core);
394 	double ra, dec;
395 	StelUtils::rectToSphe(&ra, &dec, eq);
396 	al->setCustomDeclination2(dec*M_180_PI);
397 	al->setCustomDeclination2Label(sel->getNameI18n());
398 	al->showCustomDeclination2(true);
399 }
400 
401 
402 // Notes/Observations by GZ in 2015-04 with Qt5.4.0/MinGW on Windows7SP1.
403 // (1) There are issues in calling the QColorPanel that seem to be related to QTBUG-35302,
404 // although it was reportedly fixed at least for X11 in Qt5.3.0.
405 // On Win7 with NVidia Geforce and Win8.1 on Radeon, the color panel hides behind the Stellarium main window if set to fullscreen.
406 // On Win7 with Intel HD4600, and various Linuces, no problem is seen, the color panel is right on top of the fullscreen main window.
407 // It seems not to depend on MinGW vs. MSVC builds, but on details in GPU drivers and Qt.
408 
409 // (2) Likely another bug in QColorDialog: If you choose one of the preconfigured colors (left half),
410 // on next change of that color it will have toggled one high bit of one component.
411 // On next change, it will be toggled again.
412 // If you configure a color from the right color field, all is OK (unless you "hit" a preconfigured color in the right field).
413