ObservabilityDialog.cpp   ObservabilityDialog.cpp 
skipping to change at line 21 skipping to change at line 21
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "config.h"
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "ui_ObservabilityDialog.h" #include "ui_ObservabilityDialog.h"
#include "ObservabilityDialog.hpp" #include "ObservabilityDialog.hpp"
#include "Observability.hpp" #include "Observability.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
ObservabilityDialog::ObservabilityDialog() ObservabilityDialog::ObservabilityDialog()
{ {
ui = new Ui_ObservabilityDialog; ui = new Ui_ObservabilityDialog;
} }
ObservabilityDialog::~ObservabilityDialog() ObservabilityDialog::~ObservabilityDialog()
{ {
delete ui; delete ui;
} }
void ObservabilityDialog::retranslate() void ObservabilityDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
setAboutHtml(); setAboutHtml();
updateControls(); // Also re-translate the dynamic slider la bels
} }
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void ObservabilityDialog::createDialogContent() void ObservabilityDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
ui->tabs->setCurrentIndex(0); ui->tabs->setCurrentIndex(0);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL connect(&StelApp::getInstance(),
OT(retranslate())); SIGNAL(languageChanged()), this, SLOT(retranslate()));
Observability* plugin = GETSTELMODULE(Observability);
// Settings: // Settings:
connect(ui->Today, SIGNAL(stateChanged(int)), this, SLOT(setTodayFla
g(int))); // clicked() is called only when the user makes an input,
connect(ui->AcroCos, SIGNAL(stateChanged(int)), this, SLOT(setAcroCo // so we avoid an endless loop when setting the value in updateContr
sFlag(int))); ols().
connect(ui->Opposition, SIGNAL(stateChanged(int)), this, SLOT(setOpp connect(ui->todayCheckBox, SIGNAL(clicked(bool)),
ositionFlag(int))); plugin, SLOT(enableTodayField(bool)));
connect(ui->Goods, SIGNAL(stateChanged(int)), this, SLOT(setGoodDate connect(ui->acroCosCheckBox, SIGNAL(clicked(bool)),
sFlag(int))); plugin, SLOT(enableAcroCosField(bool)));
connect(ui->FullMoon, SIGNAL(stateChanged(int)), this, SLOT(setFullM connect(ui->oppositionCheckBox, SIGNAL(clicked(bool)),
oonFlag(int))); plugin, SLOT(enableOppositionField(bool)));
// connect(ui->Crescent, SIGNAL(stateChanged(int)), this, SLOT(setCresc connect(ui->goodNightsCheckBox, SIGNAL(clicked(bool)),
entMoonFlag(int))); plugin, SLOT(enableGoodNightsField(bool)));
// connect(ui->SuperMoon, SIGNAL(stateChanged(int)), this, SLOT(setSupe connect(ui->fullMoonCheckBox, SIGNAL(clicked(bool)),
rMoonFlag(int))); plugin, SLOT(enableFullMoonField(bool)));
connect(ui->Red, SIGNAL(sliderMoved(int)), this, SLOT(setRed(int))); connect(ui->redSlider, SIGNAL(sliderMoved(int)),
connect(ui->Green, SIGNAL(sliderMoved(int)), this, SLOT(setGreen(int this, SLOT(setColor()));
))); connect(ui->greenSlider, SIGNAL(sliderMoved(int)),
connect(ui->Blue, SIGNAL(sliderMoved(int)), this, SLOT(setBlue(int)) this, SLOT(setColor()));
); connect(ui->blueSlider, SIGNAL(sliderMoved(int)),
connect(ui->fontSize, SIGNAL(sliderMoved(int)), this, SLOT(setSize(i this, SLOT(setColor()));
nt)));
connect(ui->SunAltitude, SIGNAL(sliderMoved(int)), this, SLOT(setAlt // Isn't valueChanged() better? But then we'll have to block
itude(int))); // signlas when settting the slider values.
connect(ui->HorizAltitude, SIGNAL(sliderMoved(int)), this, SLOT(setH connect(ui->fontSize, SIGNAL(sliderMoved(int)),
orizon(int))); plugin, SLOT(setFontSize(int)));
connect(ui->sunAltitudeSlider, SIGNAL(sliderMoved(int)),
plugin, SLOT(setTwilightAltitude(int)));
connect(ui->sunAltitudeSlider, SIGNAL(sliderMoved(int)),
this, SLOT(updateAltitudeLabel(int)));
connect(ui->horizonAltitudeSlider, SIGNAL(sliderMoved(int)),
plugin, SLOT(setHorizonAltitude(int)));
connect(ui->horizonAltitudeSlider, SIGNAL(sliderMoved(int)),
this, SLOT(updateHorizonLabel(int)));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res connect(ui->restoreDefaultsButton, SIGNAL(clicked()),
toreDefaults())); plugin, SLOT(resetConfiguration()));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe // TODO: The plug-in should emit a signal when settings are changed.
ttings())); // This works, because slots are called in the order they were conne
cted.
connect(ui->restoreDefaultsButton, SIGNAL(clicked()),
this, SLOT(updateControls()));
connect(ui->saveSettingsButton, SIGNAL(clicked()),
plugin, SLOT(saveConfiguration()));
// About tab // About tab
setAboutHtml(); setAboutHtml();
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); if(gui!=NULL)
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> ui->aboutTextBrowser->document()->setDefaultStyleSheet(QStri
getStelStyle().htmlStyleSheet)); ng(gui->getStelStyle().htmlStyleSheet));
updateGuiFromSettings();
updateControls();
} }
void ObservabilityDialog::setAboutHtml(void) void ObservabilityDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Observability Plug-in") + "</h2><table width=\" 90%\">"; html += "<h2>" + q_("Observability Plug-in") + "</h2><table width=\" 90%\">";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + OBSERVABILITY_PLUGIN_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + OBSERVABILITY_PLUGIN_VERSION + "</td></tr>";
html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Ivan Marti-Vidal &lt;i.martividal@gmail.com&gt;</td></tr></table>"; html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Ivan Marti-Vidal &lt;i.martividal@gmail.com&gt;</td></tr></table>";
skipping to change at line 119 skipping to change at line 149
html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Acronycha l/Cosmical rise/set:")).arg(q_("The Acronychal rise (or set) of an object h appens when the object rises (or sets) just when the Sun sets (or rises), r espectively. The exact dates of these ephemeris depend on the Observer's lo cation. The dates between the Acronychal set and rise are those when the al titude of the celestial object uses to be high when the Sun is well below t he horizon (hence the object can be well observed). On the contrary, the Co smical rise (or set) happens when both, the object and the Sun, rise (or se t) simultaneously. It is obvious that the source is hardly observable (or n ot observable at all) in the dates between Cosmical set and rise.")); html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Acronycha l/Cosmical rise/set:")).arg(q_("The Acronychal rise (or set) of an object h appens when the object rises (or sets) just when the Sun sets (or rises), r espectively. The exact dates of these ephemeris depend on the Observer's lo cation. The dates between the Acronychal set and rise are those when the al titude of the celestial object uses to be high when the Sun is well below t he horizon (hence the object can be well observed). On the contrary, the Co smical rise (or set) happens when both, the object and the Sun, rise (or se t) simultaneously. It is obvious that the source is hardly observable (or n ot observable at all) in the dates between Cosmical set and rise."));
html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Largest S un separation:")).arg(q_("Happens when the angular separation between the S un and the celestial object are maximum. In most cases, this is equivalent to say that the Equatorial longitudes of the Sun and the object differ by 1 80 degrees, so the Sun is in opposition to the object. When an object is at its maximum possible angular separation from the Sun (no matter if it is a planet or a star), it culminates roughly at midnight, and on the darkest p ossible area of the Sky at that declination. Hence, that is the 'best' nigh t to observe a particular object.")); html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Largest S un separation:")).arg(q_("Happens when the angular separation between the S un and the celestial object are maximum. In most cases, this is equivalent to say that the Equatorial longitudes of the Sun and the object differ by 1 80 degrees, so the Sun is in opposition to the object. When an object is at its maximum possible angular separation from the Sun (no matter if it is a planet or a star), it culminates roughly at midnight, and on the darkest p ossible area of the Sky at that declination. Hence, that is the 'best' nigh t to observe a particular object."));
html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Nights wi th source above horizon:")).arg(q_("The program computes the range of dates when the celestial object is above the horizon at least during one moment of the night. By 'night', the program considers the time span when the Sun altitude is below that of the twilight (which can be set by the user; see a bove). When the objects are fixed on the sky (or are exterior planets), the range of observable epochs for the current year can have two possible form s: either a range from one date to another (e.g., 20 Jan to 15 Sep) or in t wo steps (from 1 Jan to a given date and from another date to 31 Dec). In t he first case, the first date (20 Jan in our example) shall be close to the so-called 'Heliacal rise of a star' and the second date (15 Sep in our exa mple) shall be close to the 'Heliacal set'. In the second case (e.g., a ran ge in the form 1 Jan to 20 May and 21 Sep to 31 Dec), the first date (20 Ma y in our example) would be close to the Heliacal set and the second one (21 Sep in our example) to the Heliacal rise. More exact equations to estimate the Heliacal rise/set of stars and planets (which will not depend on the m ere input of a twilight Sun elevation by the user) will be implemented in f uture versions of this plugin.")); html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Nights wi th source above horizon:")).arg(q_("The program computes the range of dates when the celestial object is above the horizon at least during one moment of the night. By 'night', the program considers the time span when the Sun altitude is below that of the twilight (which can be set by the user; see a bove). When the objects are fixed on the sky (or are exterior planets), the range of observable epochs for the current year can have two possible form s: either a range from one date to another (e.g., 20 Jan to 15 Sep) or in t wo steps (from 1 Jan to a given date and from another date to 31 Dec). In t he first case, the first date (20 Jan in our example) shall be close to the so-called 'Heliacal rise of a star' and the second date (15 Sep in our exa mple) shall be close to the 'Heliacal set'. In the second case (e.g., a ran ge in the form 1 Jan to 20 May and 21 Sep to 31 Dec), the first date (20 Ma y in our example) would be close to the Heliacal set and the second one (21 Sep in our example) to the Heliacal rise. More exact equations to estimate the Heliacal rise/set of stars and planets (which will not depend on the m ere input of a twilight Sun elevation by the user) will be implemented in f uture versions of this plugin."));
html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Full Moon :")).arg(q_("When the Moon is selected, the program can compute the exact c losest dates of the Moon's opposition to the Sun.")); html += QString("<tr><td>%1</td><td>%2</td></tr>").arg(q_("Full Moon :")).arg(q_("When the Moon is selected, the program can compute the exact c losest dates of the Moon's opposition to the Sun."));
html += "</table>"; html += "</table>";
html += "</body></html>"; html += "</body></html>";
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void ObservabilityDialog::restoreDefaults(void) void ObservabilityDialog::updateControls()
{ {
qDebug() << "Observability::restoreDefaults"; Observability* plugin = GETSTELMODULE(Observability);
GETSTELMODULE(Observability)->restoreDefaults();
GETSTELMODULE(Observability)->readSettingsFromConfig();
updateGuiFromSettings();
}
void ObservabilityDialog::updateGuiFromSettings(void) ui->todayCheckBox->setChecked(plugin->getShowFlags(1));
{ ui->acroCosCheckBox->setChecked(plugin->getShowFlags(2));
ui->Today->setChecked(GETSTELMODULE(Observability)->getShowFlags(1)) ui->goodNightsCheckBox->setChecked(plugin->getShowFlags(3));
; ui->oppositionCheckBox->setChecked(plugin->getShowFlags(4));
ui->AcroCos->setChecked(GETSTELMODULE(Observability)->getShowFlags(2 ui->fullMoonCheckBox->setChecked(plugin->getShowFlags(5));
));
ui->Goods->setChecked(GETSTELMODULE(Observability)->getShowFlags(3))
;
ui->Opposition->setChecked(GETSTELMODULE(Observability)->getShowFlag
s(4));
ui->FullMoon->setChecked(GETSTELMODULE(Observability)->getShowFlags(
5));
// ui->Crescent->setChecked(GETSTELMODULE(Observability)->getShowFlags( 6)); // ui->Crescent->setChecked(GETSTELMODULE(Observability)->getShowFlags( 6));
// ui->SuperMoon->setChecked(GETSTELMODULE(Observability)->getShowFlags (7)); // ui->SuperMoon->setChecked(GETSTELMODULE(Observability)->getShowFlags (7));
Vec3f currFont = GETSTELMODULE(Observability)->getFontColor(); Vec3f fontColor = plugin->getFontColor();
int Rv = (int)(100.*currFont[0]); int red = (int)(100.*fontColor[0]);
int Gv = (int)(100.*currFont[1]); int green = (int)(100.*fontColor[1]);
int Bv = (int)(100.*currFont[2]); int blue = (int)(100.*fontColor[2]);
ui->Red->setValue(Rv); ui->redSlider->setValue(red);
ui->Green->setValue(Gv); ui->greenSlider->setValue(green);
ui->Blue->setValue(Bv); ui->blueSlider->setValue(blue);
ui->fontSize->setValue(GETSTELMODULE(Observability)->getFontSize());
int SAlti = GETSTELMODULE(Observability)->getSunAltitude();
ui->SunAltitude->setValue(SAlti);
ui->AltiText->setText(QString("%1 -%2 %3").arg(q_("Sun altitude at t
wilight:")).arg(SAlti).arg(q_("deg.")));
SAlti = GETSTELMODULE(Observability)->getHorizAltitude();
ui->HorizAltitude->setValue(SAlti);
ui->HorizText->setText(QString("%1 %2 %3").arg(q_("Horizon altitude:
")).arg(SAlti).arg(q_("deg.")));
}
void ObservabilityDialog::saveSettings(void)
{
GETSTELMODULE(Observability)->saveSettingsToConfig();
}
void ObservabilityDialog::setTodayFlag(int checkState)
{
bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Observability)->setShow(1,b);
}
void ObservabilityDialog::setAcroCosFlag(int checkState)
{
bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Observability)->setShow(2,b);
}
void ObservabilityDialog::setGoodDatesFlag(int checkState)
{
bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Observability)->setShow(3,b);
}
void ObservabilityDialog::setOppositionFlag(int checkState) ui->fontSize->setValue(plugin->getFontSize());
{ int sunAltitude = plugin->getTwilightAltitude();
bool b = checkState != Qt::Unchecked; ui->sunAltitudeSlider->setValue(sunAltitude);
GETSTELMODULE(Observability)->setShow(4,b); updateAltitudeLabel(sunAltitude);
int horizonAltitude = plugin->getHorizonAltitude();
ui->horizonAltitudeSlider->setValue(horizonAltitude);
updateHorizonLabel(horizonAltitude);
} }
void ObservabilityDialog::setFullMoonFlag(int checkState) void ObservabilityDialog::setColor()
{ {
bool b = checkState != Qt::Unchecked; int red = ui->redSlider->value();
GETSTELMODULE(Observability)->setShow(5,b); int green = ui->greenSlider->value();
} int blue = ui->blueSlider->value();
//void ObservabilityDialog::setCrescentMoonFlag(int checkState)
//{
// bool b = checkState != Qt::Unchecked;
// GETSTELMODULE(Observability)->setShow(6,b);
//}
//void ObservabilityDialog::setSuperMoonFlag(int checkState) float fRed = (float)(red) / 100.;
//{ float fGreen = (float)(green) / 100.;
// bool b = checkState != Qt::Unchecked; float fBlue = (float)(blue) / 100.;
// GETSTELMODULE(Observability)->setShow(7,b);
//}
void ObservabilityDialog::setRed(int Value) Vec3f color(fRed, fGreen, fBlue);
{ GETSTELMODULE(Observability)->setFontColor(color);
GETSTELMODULE(Observability)->setFontColor(0,Value);
}
void ObservabilityDialog::setGreen(int Value)
{
GETSTELMODULE(Observability)->setFontColor(1,Value);
}
void ObservabilityDialog::setBlue(int Value)
{
GETSTELMODULE(Observability)->setFontColor(2,Value);
}
void ObservabilityDialog::setSize(int Value)
{
GETSTELMODULE(Observability)->setFontSize(Value);
} }
void ObservabilityDialog::setAltitude(int Value) void ObservabilityDialog::updateAltitudeLabel(int altitude)
{ {
ui->AltiText->setText(QString("%1 -%2 %3").arg(q_("Sun altitude at t // This allows translators to use their own conventions for degree s
wilight:")).arg(Value).arg(q_("deg."))); igns.
GETSTELMODULE(Observability)->setSunAltitude(Value); ui->sunAltitudeLabel->setText(q_("Sun altitude at twilight: %1 deg."
).arg(altitude));
} }
void ObservabilityDialog::setHorizon(int Value) void ObservabilityDialog::updateHorizonLabel(int horizon)
{ {
ui->HorizText->setText(QString("%1 %2 %3").arg(q_("Horizon altitude: // This allows translators to use their own conventions for degree s
")).arg(Value).arg(q_("deg."))); igns.
GETSTELMODULE(Observability)->setHorizAltitude(Value); ui->horizonAltitudeLabel->setText(q_("Horizon altitude: %1 deg.").ar
g(horizon));
} }
 End of changes. 21 change blocks. 
143 lines changed or deleted 95 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/