diff --git a/src/core/modules/SensorsMgr.cpp b/src/core/modules/SensorsMgr.cpp index a72d8a1..32c5ece 100644 --- a/src/core/modules/SensorsMgr.cpp +++ b/src/core/modules/SensorsMgr.cpp @@ -218,7 +218,7 @@ void SensorsMgr::update(double deltaTime) rot2d(&x, &y, -roll); rot2d(&y, &z, pitch); - float az = std::atan2(-x, z) - magd; // Magnetic declination correction (Cheng Xinlun, Apr 18, 2017) + float az = std::atan2(-x, z) - magd * 0.0174533; // Magnetic declination correction (Cheng Xinlun, Apr 18, 2017) StelUtils::spheToRect(az, pitch, viewDirection); mmgr->setViewDirectionJ2000(StelApp::getInstance().getCore()->altAzToJ2000(viewDirection)); } diff --git a/src/gui/AddRemoveLandscapesDialog.cpp b/src/gui/AddRemoveLandscapesDialog.cpp deleted file mode 100644 index eb99963..0000000 --- a/src/gui/AddRemoveLandscapesDialog.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Stellarium - * - * Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ -#include "AddRemoveLandscapesDialog.hpp" -#include "ui_addRemoveLandscapesDialog.h" - -#include "Dialog.hpp" -#include "LandscapeMgr.hpp" -#include "StelApp.hpp" -#include "StelModuleMgr.hpp" -#include "StelLocaleMgr.hpp" - -#include -#include -#include - -AddRemoveLandscapesDialog::AddRemoveLandscapesDialog() -{ - ui = new Ui_addRemoveLandscapesDialogForm; - landscapeManager = GETSTELMODULE(LandscapeMgr); - lastUsedDirectoryPath = QDir::homePath(); -} - -AddRemoveLandscapesDialog::~AddRemoveLandscapesDialog() -{ - delete ui; -} - -void AddRemoveLandscapesDialog::retranslate() -{ - if (dialog) - ui->retranslateUi(dialog); -} - -// Initialize the dialog widgets and connect the signals/slots -void AddRemoveLandscapesDialog::createDialogContent() -{ - ui->setupUi(dialog); - - //Signals and slots - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - connect(ui->pushButtonBrowseForArchive, SIGNAL(clicked()), this, SLOT(browseForArchiveClicked())); - connect(ui->listWidgetUserLandscapes, SIGNAL(currentRowChanged(int)), this, SLOT(updateSidePane(int))); - connect(ui->pushButtonRemove, SIGNAL(clicked()), this, SLOT(removeClicked())); - connect(ui->pushButtonMessageOK, SIGNAL(clicked()), this, SLOT(messageAcknowledged())); - - connect(landscapeManager, SIGNAL(landscapesChanged()), this, SLOT(populateLists())); - connect(landscapeManager, SIGNAL(errorUnableToOpen(QString)), this, SLOT(messageUnableToOpen(QString))); - connect(landscapeManager, SIGNAL(errorNotArchive()), this, SLOT(messageNotArchive())); - connect(landscapeManager, SIGNAL(errorNotUnique(QString)), this, SLOT(messageNotUnique(QString))); - connect(landscapeManager, SIGNAL(errorRemoveManually(QString)), this, SLOT(messageRemoveManually(QString))); - - ui->groupBoxMessage->setVisible(false); - - populateLists(); -} - -void AddRemoveLandscapesDialog::setVisible(bool v) -{ - StelDialog::setVisible(v); - //Make sure that every time when the dialog is displayed, the current - //landscape is selected in the list of user landscapes if it is in the list. - populateLists(); -} - -void AddRemoveLandscapesDialog::populateLists() -{ - ui->listWidgetUserLandscapes->clear(); - QStringList landscapes = landscapeManager->getUserLandscapeIDs(); - if (!landscapes.isEmpty()) - { - landscapes.sort(); - ui->listWidgetUserLandscapes->addItems(landscapes); - //If the current landscape is in the list of user landscapes, select its entry - if((ui->listWidgetUserLandscapes->findItems(landscapeManager->getCurrentLandscapeID(), Qt::MatchExactly).isEmpty())) - { - //If the current landscape is not in the list, simply select the first row - ui->listWidgetUserLandscapes->setCurrentRow(0); - } - else - { - ui->listWidgetUserLandscapes->setCurrentItem(ui->listWidgetUserLandscapes->findItems(landscapeManager->getCurrentLandscapeID(), Qt::MatchExactly).first()); - } - } - else - { - //Force disabling the side pane - updateSidePane(-1); - } -} - -void AddRemoveLandscapesDialog::browseForArchiveClicked() -{ - QString caption = q_("Select a ZIP archive that contains a Stellarium landscape"); - // TRANSLATORS: This string is displayed in the "Files of type:" drop-down list in the standard file selection dialog. - QString filter = q_("ZIP archives"); - filter += " (*.zip)"; - #ifdef Q_OS_MAC - //work-around for Qt bug - http://bugreports.qt.nokia.com/browse/QTBUG-16722 - QString sourceArchivePath = QFileDialog::getOpenFileName(NULL, caption, lastUsedDirectoryPath, filter, 0, QFileDialog::DontUseNativeDialog); - #else - QString sourceArchivePath = QFileDialog::getOpenFileName(NULL, caption, lastUsedDirectoryPath, filter); - #endif - bool useLandscape = ui->checkBoxUseLandscape->isChecked(); - if (!sourceArchivePath.isEmpty() && QFile::exists(sourceArchivePath)) - { - //Remember the last successfully used directory - lastUsedDirectoryPath = QFileInfo(sourceArchivePath).path(); - - QString newLandscapeID = landscapeManager->installLandscapeFromArchive(sourceArchivePath, useLandscape); - if(!newLandscapeID.isEmpty()) - { - //Show a message - QString successMessage = QString(q_("Landscape \"%1\" has been installed successfully.")).arg(newLandscapeID); - displayMessage(q_("Success"), successMessage); - - //Make the new landscape selected in the list - //populateLists(); //No longer needed after the migration to signals/slots - ui->listWidgetUserLandscapes->setCurrentItem((ui->listWidgetUserLandscapes->findItems(newLandscapeID, Qt::MatchExactly)).first()); - } - else - { - //If no error message has been displayed by the signal/slot mechanism, - //display a generic message. - if (!ui->groupBoxMessage->isVisible()) - { - //Show an error message - QString failureMessage = q_("No landscape was installed."); - displayMessage(q_("Error!"), failureMessage); - } - } - } -} - -void AddRemoveLandscapesDialog::removeClicked() -{ - QString landscapeID = ui->listWidgetUserLandscapes->currentItem()->data(0).toString(); - if(landscapeManager->removeLandscape(landscapeID)) - { - //populateLists();//No longer needed after the migration to signals/slots - QString successMessage = QString(q_("Landscape \"%1\" has been removed successfully.")).arg(landscapeID); - displayMessage(q_("Success"), successMessage); - } - else - { - //If no error message has been displayed by the signal/slot mechanism, - //display a generic message. - if (!ui->groupBoxMessage->isVisible()) - { - //Show an error message - //NB! This string is used elsewhere. Modify both to avoid two nearly identical translations. - QString failureMessage = q_("The selected landscape could not be (completely) removed."); - displayMessage(q_("Error!"), failureMessage); - } - } - -} - -void AddRemoveLandscapesDialog::updateSidePane(int newRow) -{ - bool displaySidePane = (newRow >= 0); - ui->labelLandscapeName->setVisible(displaySidePane); - ui->labelLandscapeSize->setVisible(displaySidePane); - ui->pushButtonRemove->setEnabled(displaySidePane); - ui->labelWarning->setEnabled(displaySidePane); - if (!displaySidePane) - return; - - QString landscapeID = ui->listWidgetUserLandscapes->item(newRow)->data(0).toString(); - //Name - ui->labelLandscapeName->setText("

"+landscapeManager->loadLandscapeName(landscapeID)+"

"); - //Size in MiB - double landscapeSize = landscapeManager->loadLandscapeSize(landscapeID) / (double)(1024*1024); - // TRANSLATORS: MiB = mebibytes (IEC 60027-2 standard for 2^20 bytes) - ui->labelLandscapeSize->setText(QString(q_("Size on disk: %1 MiB")).arg(landscapeSize, 0, 'f', 2)); -} - -void AddRemoveLandscapesDialog::messageAcknowledged() -{ - ui->groupBoxMessage->setVisible(false); - ui->groupBoxAdd->setVisible(true); - ui->groupBoxRemove->setVisible(true); - ui->labelMessage->clear(); - ui->groupBoxMessage->setTitle(QString()); -} - -void AddRemoveLandscapesDialog::displayMessage(QString title, QString message) -{ - ui->labelMessage->setText(message); - ui->groupBoxMessage->setTitle(title); - ui->groupBoxMessage->setVisible(true); - ui->groupBoxAdd->setVisible(false); - ui->groupBoxRemove->setVisible(false); -} - -void AddRemoveLandscapesDialog::messageUnableToOpen(QString path) -{ - QString failureMessage = q_("No landscape was installed."); - failureMessage.append(" "); - // TRANSLATORS: The parameter is a file/directory path that may be quite long. - failureMessage.append(q_("Stellarium cannot open for reading or writing %1").arg(path)); - displayMessage(q_("Error!"), failureMessage); -} - -void AddRemoveLandscapesDialog::messageNotArchive() -{ - QString failureMessage = q_("No landscape was installed.") + " " + q_("The selected file is not a ZIP archive or does not contain a Stellarium landscape."); - displayMessage(q_("Error!"), failureMessage); -} - -void AddRemoveLandscapesDialog::messageNotUnique(QString nameOrID) -{ - // TRANSLATORS: The parameter is the duplicate name or identifier. - QString nameMessage = q_("A landscape with the same name or identifier (%1) already exists.").arg(nameOrID); - QString failureMessage = q_("No landscape was installed.") + " " + nameMessage; - displayMessage(q_("Error!"), failureMessage); -} - -void AddRemoveLandscapesDialog::messageRemoveManually(QString path) -{ - //NB! This string is used elsewhere. Modify both to avoid two nearly identical translations. - QString failureMessage = q_("The selected landscape could not be (completely) removed."); - failureMessage.append(" "); - // TRANSLATORS: The parameter is a file/directory path that may be quite long. "It" refers to a landscape that can't be removed. - failureMessage.append(q_("You can remove it manually by deleting the following directory: %1").arg(path)); - displayMessage(q_("Error!"), failureMessage); -} diff --git a/src/gui/AddRemoveLandscapesDialog.hpp b/src/gui/AddRemoveLandscapesDialog.hpp deleted file mode 100644 index 5fafee2..0000000 --- a/src/gui/AddRemoveLandscapesDialog.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Stellarium - * - * Copyright (C) 2010 Bogdan Marinov (add/remove landscapes feature) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _ADDREMOVELANDSCAPESDIALOG_HPP_ -#define _ADDREMOVELANDSCAPESDIALOG_HPP_ - -#include -#include - -#include "StelDialog.hpp" - -class Ui_addRemoveLandscapesDialogForm; -class LandscapeMgr; - -//! @class AddRemoveLandscapesDialog -class AddRemoveLandscapesDialog : public StelDialog -{ - Q_OBJECT -public: - AddRemoveLandscapesDialog(); - virtual ~AddRemoveLandscapesDialog(); - -public slots: - void retranslate(); - //! This function overrides the non-virtual StelDialog::setVisible() - //! to allow the current landscape to be selected in the list of user - //! landscapes (if it is in the list) every time the dialog is displayed. - void setVisible(bool); - void populateLists(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots. - virtual void createDialogContent(); - Ui_addRemoveLandscapesDialogForm* ui; - -private slots: - void browseForArchiveClicked(); - void removeClicked(); - void updateSidePane(int newRow); - - //! Hides the message group box and returns to the "Add" group box. - //! Usually called by clicking the "OK" button in the message box. - void messageAcknowledged(); - - void messageUnableToOpen(QString path); - void messageNotArchive(); - void messageNotUnique(QString nameOrID); - void messageRemoveManually(QString path); - -private: - LandscapeMgr* landscapeManager; - - //! Path to the directory last used by QFileDialog in buttonAddClicked(). - //! Initialized with QDir::homePath() in Landscape(). (DOESN'T WORK!) - QString lastUsedDirectoryPath; - - //! Displays a message in place of the "Add" box. - //! Pressing the "OK" button in the message box calls messageAcknowledged(). - //! @param title the title of the QGroupBox that contains the message - //! @param message the text of the message itself - void displayMessage(QString title, QString message); -}; - -#endif // _ADDREMOVELANDSCAPESDIALOG_ diff --git a/src/gui/AngleSpinBox.cpp b/src/gui/AngleSpinBox.cpp deleted file mode 100644 index d8a0c73..0000000 --- a/src/gui/AngleSpinBox.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 Matthew Gates * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * - ***************************************************************************/ - -#include "AngleSpinBox.hpp" -#include "StelTranslator.hpp" -#include -#include -#include -#include -#include -#include - -AngleSpinBox::AngleSpinBox(QWidget* parent, DisplayFormat format, PrefixType prefix) - : QAbstractSpinBox(parent), - angleSpinBoxFormat(format), - currentPrefixType(prefix), - decimalPlaces(2), - radAngle(0.0) -{ - connect(this, SIGNAL(editingFinished()), this, SLOT(updateValue())); - formatText(); -} - -const QString AngleSpinBox::positivePrefix(PrefixType prefix) -{ - switch(prefix) - { - case NormalPlus: - return("+"); - break; - case Longitude: - return(q_("E ")); - break; - case Latitude: - return(q_("N ")); - break; - case Normal: - default: - return(""); - break; - } -} - -const QString AngleSpinBox::negativePrefix(PrefixType prefix) -{ - switch(prefix) - { - case NormalPlus: - return(QLocale().negativeSign()); - break; - case Longitude: - return(q_("W ")); - break; - case Latitude: - return(q_("S ")); - break; - case Normal: - default: - return(QLocale().negativeSign()); - break; - } -} - -AngleSpinBox::~AngleSpinBox() -{ -} - - -AngleSpinBox::AngleSpinboxSection AngleSpinBox::getCurrentSection() const -{ - int cusorPos = lineEdit()->cursorPosition(); - const QString str = lineEdit()->text(); - - int cPosMin = str.indexOf(QRegExp("[+-"+q_("N")+q_("S")+q_("E")+q_("W")+"]"), 0); - int cPosMax = cPosMin+1; - - if (cusorPos>=cPosMin && cusorPos cPosMin && cusorPos <= cPosMax) { - return SectionDegreesHours; - } - - cPosMin = cPosMax; - cPosMax = str.indexOf(QRegExp("[m']"), 0)+1; - if (cusorPos > cPosMin && cusorPos <= cPosMax) { - return SectionMinutes; - } - - cPosMin = cPosMax; - cPosMax = str.indexOf(QRegExp("[s\"]"), 0)+1; - if (cusorPos > cPosMin && cusorPos <= cPosMax) { - return SectionSeconds; - } - - return SectionNone; -} - -void AngleSpinBox::stepBy (int steps) -{ - const int cusorPos = lineEdit()->cursorPosition(); - const AngleSpinBox::AngleSpinboxSection sec = getCurrentSection(); - switch (sec) - { - case SectionPrefix: - { - radAngle = -radAngle; - break; - } - case SectionDegreesHours: - { - if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFormat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) - radAngle += M_PI/180.*steps; - else - radAngle += M_PI/12.*steps; - break; - } - case SectionMinutes: - { - if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFormat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) - radAngle += M_PI/180.*steps/60.; - else - radAngle += M_PI/12.*steps/60.; - break; - } - case SectionSeconds: - case SectionNone: - { - if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFormat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) - radAngle += M_PI/180.*steps/3600.; - else - radAngle += M_PI/12.*steps/3600.; - break; - } - default: - { - return; - } - } - formatText(); - lineEdit()->setCursorPosition(cusorPos); - emit(valueChanged()); -} - -QValidator::State AngleSpinBox::validate(QString& input, int& pos) const -{ - Q_UNUSED(pos); - QValidator::State state; - stringToDouble(input, &state); - return state; -} - -void AngleSpinBox::clear() -{ - radAngle = 0.0; - formatText(); - emit(valueChanged()); -} - -QAbstractSpinBox::StepEnabled AngleSpinBox::stepEnabled() const -{ - return (StepUpEnabled|StepDownEnabled); -} - -double AngleSpinBox::valueRadians() -{ - return radAngle; -} - -double AngleSpinBox::valueDegrees() -{ - return (radAngle*360.)/(2.*M_PI); -} - -double AngleSpinBox::stringToDouble(QString input, QValidator::State* state, PrefixType prefix) const -{ - if (prefix==Unknown) - { - prefix=currentPrefixType; - } - int sign=1; - if (input.startsWith(negativePrefix(prefix), Qt::CaseInsensitive)) - { - sign = -1; - input = input.mid(negativePrefix(prefix).length()); - } - else if (input.startsWith(positivePrefix(prefix), Qt::CaseInsensitive)) - { - sign = 1; - input = input.mid(positivePrefix(prefix).length()); - } - else if (input.startsWith("-", Qt::CaseInsensitive)) - { - sign = -1; - input = input.mid(1); - } - else if (input.startsWith("+", Qt::CaseInsensitive)) - { - sign = 1; - input = input.mid(1); - } - - QRegExp dmsRx("^\\s*(\\d+)\\s*[d\\x00b0](\\s*(\\d+(\\.\\d*)?)\\s*[m'](\\s*(\\d+(\\.\\d*)?)\\s*[s\"]\\s*)?)?$", - Qt::CaseInsensitive); - QRegExp hmsRx("^\\s*(\\d+)\\s*h(\\s*(\\d+(\\.\\d*)?)\\s*[m'](\\s*(\\d+(\\.\\d*)?)\\s*[s\"]\\s*)?)?$", - Qt::CaseInsensitive); - QRegExp decRx("^(\\d+(\\.\\d*)?)(\\s*[\\x00b0]\\s*)?$"); - QRegExp badRx("[^hdms0-9 \\x00b0'\"\\.]", Qt::CaseInsensitive); - - QValidator::State dummy; - if (state == NULL) - { - state = &dummy; - } - - if (dmsRx.exactMatch(input)) - { - double degree = dmsRx.capturedTexts().at(1).toDouble(); - double minute = dmsRx.capturedTexts().at(3).toDouble(); - double second = dmsRx.capturedTexts().at(6).toDouble(); - if (degree > 360.0 || degree < -360.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - if (minute > 60.0 || minute < 0.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - if (second > 60.0 || second < 0.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - *state = QValidator::Acceptable; - return (sign * (degree + (minute/60.0) + (second/3600.0))) * M_PI / 180.0; - } - else if (hmsRx.exactMatch(input)) - { - double hour = hmsRx.capturedTexts().at(1).toDouble(); - double minute = hmsRx.capturedTexts().at(3).toDouble(); - double second = hmsRx.capturedTexts().at(6).toDouble(); - if (hour >= 24.0 || hour < 0.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - if (minute > 60.0 || minute < 0.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - if (second > 60.0 || second < 0.0) - { - *state = QValidator::Invalid; - return 0.0; - } - - *state = QValidator::Acceptable; - return sign * (((360.0*hour/24.0) + (minute*15/60.0) + (second*15/3600.0)) * M_PI / 180.0); - } - else if (decRx.exactMatch(input)) - { - double dec = decRx.capturedTexts().at(1).toDouble(); - if (dec < 0.0 || dec > 360.0) - { - *state = QValidator::Invalid; - return 0.0; - } - else - { - *state = QValidator::Acceptable; - return sign * (dec * M_PI / 180.0); - } - } - else if (input.contains(badRx)) - { - *state = QValidator::Invalid; - return 0.0; - } - *state = QValidator::Intermediate; - return 0.0; -} - -void AngleSpinBox::updateValue(void) -{ - QValidator::State state; - double a = stringToDouble(lineEdit()->text(), &state); - if (state != QValidator::Acceptable) - return; - - if (radAngle == a) - return; - radAngle = a; - formatText(); - emit(valueChanged()); -} - -void AngleSpinBox::setRadians(double radians) -{ - radAngle = radians; - formatText(); -} - -void AngleSpinBox::setDegrees(double degrees) -{ - radAngle = degrees * M_PI/180.; - formatText(); -} - -void AngleSpinBox::formatText(void) -{ - switch (angleSpinBoxFormat) - { - case DMSLetters: - case DMSSymbols: - { - double angle = radAngle; - int d, m; - double s; - bool sign=true; - if (angle<0) - { - angle *= -1; - sign = false; - } - angle = fmod(angle,2.0*M_PI); - angle *= 180./M_PI; - - d = (int)angle; - m = (int)((angle - d)*60); - s = (angle-d)*3600-60*m; - - // we may have seconds as 60 and one less minute... - if (s > 60.0 - ::pow(10.0, -1 * (decimalPlaces+1))) - { - m+=1; - s-=60.0; - } - - // may have to carry to the degrees... - if (m >= 60) - { - d= (d+1) % 360; - m-=60; - } - - // fix when we have tiny tiny tiny values. - if (s < ::pow(10.0, -1 * (decimalPlaces+1))) - s= 0.0; - else if (s < 0.0 && 0.0 - ::pow(10.0, -1 * (decimalPlaces+1))) - s= 0.0; - - QString signInd = positivePrefix(currentPrefixType); - if (!sign) - signInd = negativePrefix(currentPrefixType); - - if (angleSpinBoxFormat == DMSLetters) - lineEdit()->setText(QString("%1%2d %3m %4s") - .arg(signInd).arg(d).arg(m).arg(s, 0, 'f', decimalPlaces, ' ')); - else - lineEdit()->setText(QString("%1%2%3 %4' %5\"") - .arg(signInd).arg(d).arg(QChar(176)).arg(m) - .arg(s, 0, 'f', decimalPlaces, ' ')); - break; - } - case HMSLetters: - case HMSSymbols: - { - unsigned int h, m; - double s; - double angle = radAngle; - angle = fmod(angle,2.0*M_PI); - if (angle < 0.0) angle += 2.0*M_PI; // range: [0..2.0*M_PI) - angle *= 12./M_PI; - h = (unsigned int)angle; - m = (unsigned int)((angle-h)*60); - s = (angle-h)*3600.-60.*m; - - // we may have seconds as 60 and one less minute... - if (s > 60.0 - ::pow(10.0, -1 * (decimalPlaces+1))) - { - m+=1; - s-=60.0; - } - - // may have to carry to the degrees... - if (m >= 60) - { - h = (h+1) % 24; - m-=60; - } - - // fix when we have tiny tiny tiny values. - if (s < ::pow(10.0, -1 * (decimalPlaces+1))) - s= 0.0; - else if (s < 0.0 && 0.0 - ::pow(10.0, -1 * (decimalPlaces+1))) - s= 0.0; - - if (angleSpinBoxFormat == HMSLetters) - lineEdit()->setText(QString("%1h %2m %3s") - .arg(h).arg(m).arg(s, 0, 'f', decimalPlaces, ' ')); - else - lineEdit()->setText(QString("%1h %2' %3\"") - .arg(h).arg(m).arg(s, 0, 'f', decimalPlaces, ' ')); - break; - } - case DecimalDeg: - { - double angle = radAngle; - QString signInd = positivePrefix(currentPrefixType); - - if (radAngle<0) - { - angle *= -1; - signInd = negativePrefix(currentPrefixType); - } - - lineEdit()->setText(QString("%1%2%3") - .arg(signInd) - .arg(fmod(angle * 180.0 / M_PI, 360.0), 0, 'f', decimalPlaces, ' ') - .arg(QChar(176))); - break; - } - default: - { - qWarning() << "AngleSpinBox::formatText - WARNING - unknown format" - << (int)(angleSpinBoxFormat); - break; - } - } -} - diff --git a/src/gui/AngleSpinBox.hpp b/src/gui/AngleSpinBox.hpp deleted file mode 100644 index 6ee42cd..0000000 --- a/src/gui/AngleSpinBox.hpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _ANGLESPINBOX_HPP_ -#define _ANGLESPINBOX_HPP_ - -#include -#include - -//! @class AngleSpinBox -//! A spin box for displaying/entering angular values. -//! This class can accept angles in various formats commonly used in astronomy -//! including decimal degrees, DMS and HMS. -class AngleSpinBox : public QAbstractSpinBox -{ - Q_OBJECT - -public: - //! @enum DisplayFormat - //! Used to decide how to display the angle. - enum DisplayFormat - { - DMSLetters, //!< Degrees, minutes and seconds, e.g. 180d 4m 8s - DMSSymbols, //!< Degrees, minutes and seconds, e.g. 180° 4' 8" - HMSLetters, //!< Hours, minutes and seconds, e.g. 12h 4m 6s - HMSSymbols, //!< Hours, minutes and seconds, e.g. 12h 4' 6s" - DecimalDeg //!< Decimal degrees, e.g. 180.06888 - }; - - //! @enum PrefixType - //! Determines how positive and negative values are indicated. - enum PrefixType - { - Normal, //!< negative values have '-' prefix - NormalPlus, //!< positive values have '+' prefix, negative values have '-' prefix. - Longitude, //!< positive values have 'E' prefix, negative values have 'W' prefix. - Latitude, //!< positive values have 'N' prefix, negative values have 'S' prefix. - Unknown - }; - - AngleSpinBox(QWidget* parent=0, DisplayFormat format=DMSSymbols, PrefixType prefix=Normal); - ~AngleSpinBox(); - - // QAbstractSpinBox virtual members - virtual void stepBy(int steps); - virtual QValidator::State validate(QString& input, int& pos) const; - - //! Get the angle held in the AngleSpinBox - //! @return the angle in radians - double valueRadians(); - //! Get the angle held in the AngleSpinBox - //! @return the angle in degrees - double valueDegrees(); - - //! Set the number of decimal places to express float values to (e.g. seconds in DMSLetters format). - //! @param places the number of decimal places to use. - void setDecimals(int places) { decimalPlaces = places; } - - //! Get the number of decimal places to express float values to (e.g. seconds in DMSLetters format). - //! @return the number of decimal places used. - int decimals() { return decimalPlaces; } - - //! Set the display format. - //! @param format the new format to use. - void setDisplayFormat(DisplayFormat format) { angleSpinBoxFormat=format; formatText(); } - - //! Get the current display format. - //! @return the current DisplayFormat. - DisplayFormat displayFormat() { return angleSpinBoxFormat; } - - //! Set the prefix type. - //! @param prefix the new prefix type to use. - void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; formatText(); } - - //! Get the current display format. - //! @return the current DisplayFormat. - PrefixType prefixType() { return currentPrefixType; } - -public slots: - //! Set the value to default 0 angle. - virtual void clear(); - - //! Set the value of the spin box in radians. - //! @param radians the value to set, in radians. - void setRadians(double radians); - - //! Set the value of the spin box in decimal degrees. - //! @param degrees the value to set, in decimal degrees. - void setDegrees(double degrees); - -signals: - //! Emitted when the value changes. - void valueChanged(); - -protected: - virtual StepEnabled stepEnabled() const; - -private slots: - //! Updates radAngle (internal representation of the angle) and calls formatText - void updateValue(void); - -private: - //! Convert a string value to an angle in radians. - //! This function can be used to validate a string as expressing an angle. Accepted - //! are any formats which the AngleSpinBox understands. - //! @param input the string value to be converted / validated. - //! @param state a pointer to a QValidator::State value which is set according to the validation. - //! @param prefix the kind of prefix to use for conversion. - //! @return the value of the angle expressed in input in radians. - double stringToDouble(QString input, QValidator::State* state, PrefixType prefix=Unknown) const; - - //! @enum AngleSpinboxSection - enum AngleSpinboxSection - { - SectionPrefix, //! Section of the S/W or E/W or +/- - SectionDegreesHours, //! Section of the degree or hours - SectionMinutes, //! Section of the minutes (of degree or of hours) - SectionSeconds, //! Section of the seconds (of degree or of hours) - SectionNone //! No matching section, e.g. between 2 sections - }; - - //! Get the current section in which the line edit cursor is. - AngleSpinboxSection getCurrentSection() const; - - //! Reformats the input according to the current value of angleSpinBoxFormat/ - //! This is called whenever an editingFinished() signal is emitted, - //! e.g. when RETURN is pressed. - void formatText(void); - - static const QString positivePrefix(PrefixType prefix); - static const QString negativePrefix(PrefixType prefix); - - DisplayFormat angleSpinBoxFormat; - PrefixType currentPrefixType; - int decimalPlaces; - double radAngle; - -}; - -#endif // _ANGLESPINBOX_HPP_ diff --git a/src/gui/AtmosphereDialog.cpp b/src/gui/AtmosphereDialog.cpp deleted file mode 100644 index a45351c..0000000 --- a/src/gui/AtmosphereDialog.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2011 Georg Zotti - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelSkyDrawer.hpp" -#include "AtmosphereDialog.hpp" -#include "ui_AtmosphereDialog.h" - -AtmosphereDialog::AtmosphereDialog() -{ - ui = new Ui_AtmosphereDialogForm; -} - -AtmosphereDialog::~AtmosphereDialog() -{ - delete ui; -} - -void AtmosphereDialog::retranslate() -{ - if (dialog) - ui->retranslateUi(dialog); -} - - -void AtmosphereDialog::createDialogContent() -{ - ui->setupUi(dialog); - - //Signals and slots - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - const StelSkyDrawer* skyDrawer = StelApp::getInstance().getCore()->getSkyDrawer(); - ui->pressureDoubleSpinBox->setValue(skyDrawer->getAtmospherePressure()); - connect(ui->pressureDoubleSpinBox, SIGNAL(valueChanged(double)), - skyDrawer, SLOT(setAtmospherePressure(double))); - ui->temperatureDoubleSpinBox->setValue(skyDrawer->getAtmosphereTemperature()); - connect(ui->temperatureDoubleSpinBox, SIGNAL(valueChanged(double)), - skyDrawer, SLOT(setAtmosphereTemperature(double))); - ui->extinctionDoubleSpinBox->setValue(skyDrawer->getExtinctionCoefficient()); - connect(ui->extinctionDoubleSpinBox, SIGNAL(valueChanged(double)), - skyDrawer, SLOT(setExtinctionCoefficient(double))); -} diff --git a/src/gui/AtmosphereDialog.hpp b/src/gui/AtmosphereDialog.hpp deleted file mode 100644 index f2af0dd..0000000 --- a/src/gui/AtmosphereDialog.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Stellarium - * - * Copyright (C) 2011 Georg Zotti (Refraction/Extinction feature) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - - -// GZ: Methods copied largely from AddRemoveLandscapesDialog - -#ifndef _ATMOSPHEREDIALOG_HPP_ -#define _ATMOSPHEREDIALOG_HPP_ - -#include -#include "StelDialog.hpp" -#include "RefractionExtinction.hpp" - -class Ui_AtmosphereDialogForm; - -class AtmosphereDialog : public StelDialog -{ - Q_OBJECT - -public: - AtmosphereDialog(); - virtual ~AtmosphereDialog(); - -public slots: - void retranslate(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots. - virtual void createDialogContent(); - Ui_AtmosphereDialogForm *ui; - -private: - Refraction *refraction; - Extinction *extinction; -}; - -#endif // _ATMOSPHEREDIALOG_HPP_ diff --git a/src/gui/AtmosphereDialog.ui b/src/gui/AtmosphereDialog.ui deleted file mode 100644 index 4d612ae..0000000 --- a/src/gui/AtmosphereDialog.ui +++ /dev/null @@ -1,251 +0,0 @@ - - - AtmosphereDialogForm - - - - 0 - 0 - 330 - 190 - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - Atmosphere Details - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - Refraction Settings - - - - 0 - - - - - - - Pressure (mbar): - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1500.000000000000000 - - - 1013.250000000000000 - - - - - - - - - - - Qt::ImhNone - - - Temperature (C): - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - -100.000000000000000 - - - 10.000000000000000 - - - - - - - - - - - - - - Extinction is the loss of star brightness due to Earth's atmosphere. It is given in mag/airmass, where airmass is number of atmospheres light has to pass. (zenith: 1; horizon: about 40) - - - Extinction Coefficient: - - - - - - - Use about 0.12 for superb mountaintops, 0.2 for good rural landscape, 0.35 for murky conditions. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3.000000000000000 - - - 0.010000000000000 - - - 0.220000000000000 - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - -
diff --git a/src/gui/ConfigurationDialog.cpp b/src/gui/ConfigurationDialog.cpp deleted file mode 100644 index be586f5..0000000 --- a/src/gui/ConfigurationDialog.cpp +++ /dev/null @@ -1,1177 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * Copyright (C) 2012 Timothy Reaves - * Copyright (C) 2012 Bogdan Marinov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "Dialog.hpp" -#include "ConfigurationDialog.hpp" -#include "CustomDeltaTEquationDialog.hpp" -#include "StelMainView.hpp" -#include "ui_configurationDialog.h" -#include "StelApp.hpp" -#include "StelFileMgr.hpp" -#include "StelCore.hpp" -#include "StelLocaleMgr.hpp" -#include "StelProjector.hpp" -#include "StelObjectMgr.hpp" -#include "StelActionMgr.hpp" -#include "StelProgressController.hpp" - -#include "StelCore.hpp" -#include "StelMovementMgr.hpp" -#include "StelModuleMgr.hpp" -#include "StelSkyDrawer.hpp" -#include "StelGui.hpp" -#include "StelGuiItems.hpp" -#include "StelLocation.hpp" -#include "LandscapeMgr.hpp" -#include "StelSkyCultureMgr.hpp" -#include "SolarSystem.hpp" -#include "MeteorMgr.hpp" -#include "ConstellationMgr.hpp" -#include "StarMgr.hpp" -#include "NebulaMgr.hpp" -#include "GridLinesMgr.hpp" -#include "MilkyWay.hpp" -#ifndef DISABLE_SCRIPTING -#include "StelScriptMgr.hpp" -#endif -#include "LabelMgr.hpp" -#include "ScreenImageMgr.hpp" -#include "SkyGui.hpp" -#include "StelJsonParser.hpp" -#include "StelTranslator.hpp" - -#include -#include -#include -#include -#include -#include - -ConfigurationDialog::ConfigurationDialog(StelGui* agui, QObject* parent) : StelDialog(parent), starCatalogDownloadReply(NULL), currentDownloadFile(NULL), progressBar(NULL), gui(agui) -{ - ui = new Ui_configurationDialogForm; - customDeltaTEquationDialog = NULL; - hasDownloadedStarCatalog = false; - isDownloadingStarCatalog = false; - savedProjectionType = StelApp::getInstance().getCore()->getCurrentProjectionType(); -} - -ConfigurationDialog::~ConfigurationDialog() -{ - delete ui; - ui = NULL; - delete customDeltaTEquationDialog; - customDeltaTEquationDialog = NULL; -} - -void ConfigurationDialog::retranslate() -{ - if (dialog) { - ui->retranslateUi(dialog); - - //Hack to shrink the tabs to optimal size after language change - //by causing the list items to be laid out again. - ui->stackListWidget->setWrapping(false); - updateTabBarListWidgetWidth(); - - //Initial FOV and direction on the "Main" page - updateConfigLabels(); - - //Star catalog download button and info - updateStarCatalogControlsText(); - - //Script information - //(trigger re-displaying the description of the current item) - #ifndef DISABLE_SCRIPTING - scriptSelectionChanged(ui->scriptListWidget->currentItem()->text()); - #endif - - //Plug-in information - populatePluginsList(); - - populateDeltaTAlgorithmsList(); - } -} - -void ConfigurationDialog::styleChanged() -{ - // Nothing for now -} - -void ConfigurationDialog::createDialogContent() -{ - const StelProjectorP proj = StelApp::getInstance().getCore()->getProjection(StelCore::FrameJ2000); - StelCore* core = StelApp::getInstance().getCore(); - - StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); - - ui->setupUi(dialog); - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - - // Set the main tab activated by default - ui->configurationStackedWidget->setCurrentIndex(0); - ui->stackListWidget->setCurrentRow(0); - - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - // Main tab - // Fill the language list widget from the available list - QString appLang = StelApp::getInstance().getLocaleMgr().getAppLanguage(); - QComboBox* cb = ui->programLanguageComboBox; - cb->clear(); - cb->addItems(StelTranslator::globalTranslator->getAvailableLanguagesNamesNative(StelFileMgr::getLocaleDir())); - cb->model()->sort(0); - QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang); - int lt = cb->findText(l2, Qt::MatchExactly); - if (lt == -1 && appLang.contains('_')) - { - l2 = appLang.left(appLang.indexOf('_')); - l2=StelTranslator::iso639_1CodeToNativeName(l2); - lt = cb->findText(l2, Qt::MatchExactly); - } - if (lt!=-1) - cb->setCurrentIndex(lt); - connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectLanguage(const QString&))); - - connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars())); - connect(ui->downloadCancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload())); - connect(ui->downloadRetryButton, SIGNAL(clicked()), this, SLOT(downloadStars())); - resetStarCatalogControls(); - - // Selected object info - if (gui->getInfoTextFilters() == StelObject::InfoStringGroup(0)) - { - ui->noSelectedInfoRadio->setChecked(true); - } - else if (gui->getInfoTextFilters() == StelObject::ShortInfo) - { - ui->briefSelectedInfoRadio->setChecked(true); - } - else if (gui->getInfoTextFilters() == StelObject::AllInfo) - { - ui->allSelectedInfoRadio->setChecked(true); - } - else - { - ui->customSelectedInfoRadio->setChecked(true); - } - updateSelectedInfoCheckBoxes(); - - connect(ui->noSelectedInfoRadio, SIGNAL(released()), this, SLOT(setNoSelectedInfo())); - connect(ui->allSelectedInfoRadio, SIGNAL(released()), this, SLOT(setAllSelectedInfo())); - connect(ui->briefSelectedInfoRadio, SIGNAL(released()), this, SLOT(setBriefSelectedInfo())); - connect(ui->buttonGroupDisplayedFields, SIGNAL(buttonClicked(int)), - this, SLOT(setSelectedInfoFromCheckBoxes())); - - // Navigation tab - // Startup time - if (core->getStartupTimeMode()=="actual") - ui->systemTimeRadio->setChecked(true); - else if (core->getStartupTimeMode()=="today") - ui->todayRadio->setChecked(true); - else - ui->fixedTimeRadio->setChecked(true); - connect(ui->systemTimeRadio, SIGNAL(clicked(bool)), this, SLOT(setStartupTimeMode())); - connect(ui->todayRadio, SIGNAL(clicked(bool)), this, SLOT(setStartupTimeMode())); - connect(ui->fixedTimeRadio, SIGNAL(clicked(bool)), this, SLOT(setStartupTimeMode())); - - ui->todayTimeSpinBox->setTime(core->getInitTodayTime()); - connect(ui->todayTimeSpinBox, SIGNAL(timeChanged(QTime)), core, SLOT(setInitTodayTime(QTime))); - ui->fixedDateTimeEdit->setMinimumDate(QDate(100,1,1)); - ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(core->getPresetSkyTime())); - connect(ui->fixedDateTimeEdit, SIGNAL(dateTimeChanged(QDateTime)), core, SLOT(setPresetSkyTime(QDateTime))); - - ui->enableKeysNavigationCheckBox->setChecked(mvmgr->getFlagEnableMoveKeys() || mvmgr->getFlagEnableZoomKeys()); - ui->enableMouseNavigationCheckBox->setChecked(mvmgr->getFlagEnableMouseNavigation()); - connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagEnableMoveKeys(bool))); - connect(ui->enableKeysNavigationCheckBox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagEnableZoomKeys(bool))); - connect(ui->enableMouseNavigationCheckBox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagEnableMouseNavigation(bool))); - connect(ui->fixedDateTimeCurrentButton, SIGNAL(clicked()), this, SLOT(setFixedDateTimeToCurrent())); - connect(ui->editShortcutsPushButton, SIGNAL(clicked()), - this, - SLOT(showShortcutsWindow())); - - // Delta-T - populateDeltaTAlgorithmsList(); - int idx = ui->deltaTAlgorithmComboBox->findData(core->getCurrentDeltaTAlgorithmKey(), Qt::UserRole, Qt::MatchCaseSensitive); - if (idx==-1) - { - // Use Espenak & Meeus (2006) as default - idx = ui->deltaTAlgorithmComboBox->findData(QVariant("EspenakMeeus"), Qt::UserRole, Qt::MatchCaseSensitive); - } - ui->deltaTAlgorithmComboBox->setCurrentIndex(idx); - connect(ui->deltaTAlgorithmComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setDeltaTAlgorithm(int))); - connect(ui->pushButtonCustomDeltaTEquationDialog, SIGNAL(clicked()), this, SLOT(showCustomDeltaTEquationDialog())); - - // Tools tab - ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); - Q_ASSERT(cmgr); - // XXX: to reintroduce. - // ui->sphericMirrorCheckbox->setChecked(StelMainView::getInstance().getStelAppGraphicsWidget()->getViewportEffect() == "sphericMirrorDistorter"); - connect(ui->sphericMirrorCheckbox, SIGNAL(toggled(bool)), this, SLOT(setSphericMirror(bool))); - ui->gravityLabelCheckbox->setChecked(proj->getFlagGravityLabels()); - connect(ui->gravityLabelCheckbox, SIGNAL(toggled(bool)), StelApp::getInstance().getCore(), SLOT(setFlagGravityLabels(bool))); - ui->selectSingleConstellationButton->setChecked(cmgr->getFlagIsolateSelected()); - connect(ui->selectSingleConstellationButton, SIGNAL(toggled(bool)), cmgr, SLOT(setFlagIsolateSelected(bool))); - ui->diskViewportCheckbox->setChecked(proj->getMaskType() == StelProjector::MaskDisk); - connect(ui->diskViewportCheckbox, SIGNAL(toggled(bool)), this, SLOT(setDiskViewport(bool))); - ui->autoZoomResetsDirectionCheckbox->setChecked(mvmgr->getFlagAutoZoomOutResetsDirection()); - connect(ui->autoZoomResetsDirectionCheckbox, SIGNAL(toggled(bool)), mvmgr, SLOT(setFlagAutoZoomOutResetsDirection(bool))); - - ui->showFlipButtonsCheckbox->setChecked(gui->getFlagShowFlipButtons()); - connect(ui->showFlipButtonsCheckbox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowFlipButtons(bool))); - - ui->showNebulaBgButtonCheckbox->setChecked(gui->getFlagShowNebulaBackgroundButton()); - connect(ui->showNebulaBgButtonCheckbox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowNebulaBackgroundButton(bool))); - - ui->mouseTimeoutCheckbox->setChecked(StelMainView::getInstance().getFlagCursorTimeout()); - ui->mouseTimeoutSpinBox->setValue(StelMainView::getInstance().getCursorTimeout()); - connect(ui->mouseTimeoutCheckbox, SIGNAL(clicked()), this, SLOT(cursorTimeOutChanged())); - connect(ui->mouseTimeoutCheckbox, SIGNAL(toggled(bool)), this, SLOT(cursorTimeOutChanged())); - connect(ui->mouseTimeoutSpinBox, SIGNAL(valueChanged(double)), this, SLOT(cursorTimeOutChanged(double))); - - connect(ui->setViewingOptionAsDefaultPushButton, SIGNAL(clicked()), this, SLOT(saveCurrentViewOptions())); - connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(setDefaultViewOptions())); - - ui->screenshotDirEdit->setText(StelFileMgr::getScreenshotDir()); - connect(ui->screenshotDirEdit, SIGNAL(textChanged(QString)), this, SLOT(selectScreenshotDir(QString))); - connect(ui->screenshotBrowseButton, SIGNAL(clicked()), this, SLOT(browseForScreenshotDir())); - - ui->invertScreenShotColorsCheckBox->setChecked(StelMainView::getInstance().getFlagInvertScreenShotColors()); - connect(ui->invertScreenShotColorsCheckBox, SIGNAL(toggled(bool)), &StelMainView::getInstance(), SLOT(setFlagInvertScreenShotColors(bool))); - - // script tab controls - #ifndef DISABLE_SCRIPTING - StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); - connect(ui->scriptListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(scriptSelectionChanged(const QString&))); - connect(ui->runScriptButton, SIGNAL(clicked()), this, SLOT(runScriptClicked())); - connect(ui->stopScriptButton, SIGNAL(clicked()), this, SLOT(stopScriptClicked())); - if (scriptMgr.scriptIsRunning()) - aScriptIsRunning(); - else - aScriptHasStopped(); - connect(&scriptMgr, SIGNAL(scriptRunning()), this, SLOT(aScriptIsRunning())); - connect(&scriptMgr, SIGNAL(scriptStopped()), this, SLOT(aScriptHasStopped())); - ui->scriptListWidget->setSortingEnabled(true); - populateScriptsList(); - connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(populateScriptsList())); - #endif - - // plugins control - connect(ui->pluginsListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(pluginsSelectionChanged(const QString&))); - connect(ui->pluginLoadAtStartupCheckBox, SIGNAL(stateChanged(int)), this, SLOT(loadAtStartupChanged(int))); - connect(ui->pluginConfigureButton, SIGNAL(clicked()), this, SLOT(pluginConfigureCurrentSelection())); - populatePluginsList(); - - updateConfigLabels(); - updateTabBarListWidgetWidth(); -} - -void ConfigurationDialog::selectLanguage(const QString& langName) -{ - QString code = StelTranslator::nativeNameToIso639_1Code(langName); - StelApp::getInstance().getLocaleMgr().setAppLanguage(code); - StelApp::getInstance().getLocaleMgr().setSkyLanguage(code); - StelMainView::getInstance().initTitleI18n(); -} - -void ConfigurationDialog::setStartupTimeMode() -{ - if (ui->systemTimeRadio->isChecked()) - StelApp::getInstance().getCore()->setStartupTimeMode("actual"); - else if (ui->todayRadio->isChecked()) - StelApp::getInstance().getCore()->setStartupTimeMode("today"); - else - StelApp::getInstance().getCore()->setStartupTimeMode("preset"); - - StelApp::getInstance().getCore()->setInitTodayTime(ui->todayTimeSpinBox->time()); - StelApp::getInstance().getCore()->setPresetSkyTime(ui->fixedDateTimeEdit->dateTime()); -} - -void ConfigurationDialog::showShortcutsWindow() -{ - StelAction* action = StelApp::getInstance().getStelActionManager()->findAction("actionShow_Shortcuts_Window_Global"); - if (action) - action->setChecked(true); -} - -void ConfigurationDialog::setDiskViewport(bool b) -{ - if (b) - StelApp::getInstance().getCore()->setMaskType(StelProjector::MaskDisk); - else - StelApp::getInstance().getCore()->setMaskType(StelProjector::MaskNone); -} - -void ConfigurationDialog::setSphericMirror(bool b) -{ - StelCore* core = StelApp::getInstance().getCore(); - if (b) - { - savedProjectionType = core->getCurrentProjectionType(); - core->setCurrentProjectionType(StelCore::ProjectionFisheye); - // XXX: to reintroduce - // StelMainView::getInstance().getStelAppGraphicsWidget()->setViewportEffect("sphericMirrorDistorter"); - } - else - { - core->setCurrentProjectionType((StelCore::ProjectionType)savedProjectionType); - // XXX: to reintroduce - // StelMainView::getInstance().getStelAppGraphicsWidget()->setViewportEffect("none"); - } -} - -void ConfigurationDialog::setNoSelectedInfo(void) -{ - gui->setInfoTextFilters(StelObject::InfoStringGroup(0)); - updateSelectedInfoCheckBoxes(); -} - -void ConfigurationDialog::setAllSelectedInfo(void) -{ - gui->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::AllInfo)); - updateSelectedInfoCheckBoxes(); -} - -void ConfigurationDialog::setBriefSelectedInfo(void) -{ - gui->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::ShortInfo)); - updateSelectedInfoCheckBoxes(); -} - -void ConfigurationDialog::setSelectedInfoFromCheckBoxes() -{ - // As this signal will be called when a checbox is toggled, - // change the general mode to Custom. - if (!ui->customSelectedInfoRadio->isChecked()) - ui->customSelectedInfoRadio->setChecked(true); - - StelObject::InfoStringGroup flags(0); - - if (ui->checkBoxName->isChecked()) - flags |= StelObject::Name; - if (ui->checkBoxCatalogNumbers->isChecked()) - flags |= StelObject::CatalogNumber; - if (ui->checkBoxVisualMag->isChecked()) - flags |= StelObject::Magnitude; - if (ui->checkBoxAbsoluteMag->isChecked()) - flags |= StelObject::AbsoluteMagnitude; - if (ui->checkBoxRaDecJ2000->isChecked()) - flags |= StelObject::RaDecJ2000; - if (ui->checkBoxRaDecOfDate->isChecked()) - flags |= StelObject::RaDecOfDate; - if (ui->checkBoxHourAngle->isChecked()) - flags |= StelObject::HourAngle; - if (ui->checkBoxAltAz->isChecked()) - flags |= StelObject::AltAzi; - if (ui->checkBoxDistance->isChecked()) - flags |= StelObject::Distance; - if (ui->checkBoxSize->isChecked()) - flags |= StelObject::Size; - if (ui->checkBoxExtra->isChecked()) - flags |= StelObject::Extra; - if (ui->checkBoxGalacticCoordinates->isChecked()) - flags |= StelObject::GalacticCoord; - if (ui->checkBoxType->isChecked()) - flags |= StelObject::Type; - - gui->setInfoTextFilters(flags); -} - - -void ConfigurationDialog::cursorTimeOutChanged() -{ - StelMainView::getInstance().setFlagCursorTimeout(ui->mouseTimeoutCheckbox->isChecked()); - StelMainView::getInstance().setCursorTimeout(ui->mouseTimeoutSpinBox->value()); -} - -void ConfigurationDialog::browseForScreenshotDir() -{ - QString oldScreenshorDir = StelFileMgr::getScreenshotDir(); - #ifdef Q_OS_MAC - //work-around for Qt bug - http://bugreports.qt.nokia.com/browse/QTBUG-16722 - QString newScreenshotDir = QFileDialog::getExistingDirectory(NULL, q_("Select screenshot directory"), oldScreenshorDir, QFileDialog::DontUseNativeDialog); - #else - QString newScreenshotDir = QFileDialog::getExistingDirectory(NULL, q_("Select screenshot directory"), oldScreenshorDir, QFileDialog::ShowDirsOnly); - #endif - - if (!newScreenshotDir.isEmpty()) { - // remove trailing slash - if (newScreenshotDir.right(1) == "/") - newScreenshotDir = newScreenshotDir.left(newScreenshotDir.length()-1); - - ui->screenshotDirEdit->setText(newScreenshotDir); - } -} - -void ConfigurationDialog::selectScreenshotDir(const QString& dir) -{ - try - { - StelFileMgr::setScreenshotDir(dir); - } - catch (std::runtime_error& e) - { - // nop - // this will happen when people are only half way through typing dirs - } -} - -// Save the current viewing option including landscape, location and sky culture -// This doesn't include the current viewing direction, time and FOV since those have specific controls -void ConfigurationDialog::saveCurrentViewOptions() -{ - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - Q_ASSERT(lmgr); - SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); - Q_ASSERT(ssmgr); - MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr); - Q_ASSERT(mmgr); - StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer(); - Q_ASSERT(skyd); - ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); - Q_ASSERT(cmgr); - StarMgr* smgr = GETSTELMODULE(StarMgr); - Q_ASSERT(smgr); - NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); - Q_ASSERT(nmgr); - GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr); - Q_ASSERT(glmgr); - StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); - Q_ASSERT(mvmgr); - - StelCore* core = StelApp::getInstance().getCore(); - const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000); - Q_ASSERT(proj); - - // view dialog / sky tab settings - conf->setValue("stars/absolute_scale", skyd->getAbsoluteStarScale()); - conf->setValue("stars/relative_scale", skyd->getRelativeStarScale()); - conf->setValue("stars/flag_star_twinkle", skyd->getFlagTwinkle()); - conf->setValue("stars/star_twinkle_amount", skyd->getTwinkleAmount()); - conf->setValue("astro/flag_star_magnitude_limit", - skyd->getFlagStarMagnitudeLimit()); - conf->setValue("astro/star_magnitude_limit", - skyd->getCustomStarMagnitudeLimit()); - conf->setValue("astro/flag_nebula_magnitude_limit", - skyd->getFlagNebulaMagnitudeLimit()); - conf->setValue("astro/nebula_magnitude_limit", - skyd->getCustomNebulaMagnitudeLimit()); - conf->setValue("viewing/use_luminance_adaptation", skyd->getFlagLuminanceAdaptation()); - conf->setValue("astro/flag_planets", ssmgr->getFlagPlanets()); - conf->setValue("astro/flag_planets_hints", ssmgr->getFlagHints()); - conf->setValue("astro/flag_planets_orbits", ssmgr->getFlagOrbits()); - conf->setValue("astro/flag_light_travel_time", ssmgr->getFlagLightTravelTime()); - conf->setValue("viewing/flag_moon_scaled", ssmgr->getFlagMoonScale()); - conf->setValue("astro/meteor_rate", mmgr->getZHR()); - conf->setValue("astro/milky_way_intensity", GETSTELMODULE(MilkyWay)->getIntensity()); - - // view dialog / markings tab settings - conf->setValue("viewing/flag_azimuthal_grid", glmgr->getFlagAzimuthalGrid()); - conf->setValue("viewing/flag_equatorial_grid", glmgr->getFlagEquatorGrid()); - conf->setValue("viewing/flag_equator_line", glmgr->getFlagEquatorLine()); - conf->setValue("viewing/flag_ecliptic_line", glmgr->getFlagEclipticLine()); - conf->setValue("viewing/flag_ecliptic_J2000_grid", glmgr->getFlagEclipticJ2000Grid()); - conf->setValue("viewing/flag_meridian_line", glmgr->getFlagMeridianLine()); - conf->setValue("viewing/flag_horizon_line", glmgr->getFlagHorizonLine()); - conf->setValue("viewing/flag_equatorial_J2000_grid", glmgr->getFlagEquatorJ2000Grid()); - conf->setValue("viewing/flag_galactic_grid", glmgr->getFlagGalacticGrid()); - conf->setValue("viewing/flag_galactic_plane_line", glmgr->getFlagGalacticPlaneLine()); - conf->setValue("viewing/flag_cardinal_points", lmgr->getFlagCardinalsPoints()); - conf->setValue("viewing/flag_constellation_drawing", cmgr->getFlagLines()); - conf->setValue("viewing/flag_constellation_name", cmgr->getFlagLabels()); - conf->setValue("viewing/flag_constellation_boundaries", cmgr->getFlagBoundaries()); - conf->setValue("viewing/flag_constellation_art", cmgr->getFlagArt()); - conf->setValue("viewing/flag_constellation_isolate_selected", cmgr->getFlagIsolateSelected()); - conf->setValue("viewing/flag_landscape_autoselection", lmgr->getFlagLandscapeAutoSelection()); - conf->setValue("viewing/constellation_art_intensity", cmgr->getArtIntensity()); - conf->setValue("viewing/flag_night", StelApp::getInstance().getVisionModeNight()); - conf->setValue("astro/flag_star_name", smgr->getFlagLabels()); - conf->setValue("stars/labels_amount", smgr->getLabelsAmount()); - conf->setValue("astro/flag_planets_labels", ssmgr->getFlagLabels()); - conf->setValue("astro/labels_amount", ssmgr->getLabelsAmount()); - conf->setValue("astro/nebula_hints_amount", nmgr->getHintsAmount()); - conf->setValue("astro/flag_nebula_name", nmgr->getFlagHints()); - conf->setValue("projection/type", core->getCurrentProjectionTypeKey()); - - // view dialog / landscape tab settings - lmgr->setDefaultLandscapeID(lmgr->getCurrentLandscapeID()); - conf->setValue("landscape/flag_landscape_sets_location", lmgr->getFlagLandscapeSetsLocation()); - conf->setValue("landscape/flag_landscape", lmgr->getFlagLandscape()); - conf->setValue("landscape/flag_atmosphere", lmgr->getFlagAtmosphere()); - conf->setValue("landscape/flag_brightness", lmgr->getFlagLandscapeNightBrightness()); - conf->setValue("landscape/flag_fog", lmgr->getFlagFog()); - conf->setValue("stars/init_bortle_scale", core->getSkyDrawer()->getBortleScale()); - conf->setValue("landscape/atmospheric_extinction_coefficient", core->getSkyDrawer()->getExtinctionCoefficient()); - conf->setValue("landscape/pressure_mbar", core->getSkyDrawer()->getAtmospherePressure()); - conf->setValue("landscape/temperature_C", core->getSkyDrawer()->getAtmosphereTemperature()); - - // view dialog / starlore tab - StelApp::getInstance().getSkyCultureMgr().setDefaultSkyCultureID(StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()); - - // Save default location - StelApp::getInstance().getCore()->setDefaultLocationID(core->getCurrentLocation().getID()); - - // configuration dialog / main tab - QString langName = StelApp::getInstance().getLocaleMgr().getAppLanguage(); - conf->setValue("localization/app_locale", StelTranslator::nativeNameToIso639_1Code(langName)); - langName = StelApp::getInstance().getLocaleMgr().getSkyLanguage(); - conf->setValue("localization/sky_locale", StelTranslator::nativeNameToIso639_1Code(langName)); - - // configuration dialog / selected object info tab - const StelObject::InfoStringGroup& flags = gui->getInfoTextFilters(); - if (flags == StelObject::InfoStringGroup(0)) - conf->setValue("gui/selected_object_info", "none"); - else if (flags == StelObject::InfoStringGroup(StelObject::ShortInfo)) - conf->setValue("gui/selected_object_info", "short"); - else if (flags == StelObject::InfoStringGroup(StelObject::AllInfo)) - conf->setValue("gui/selected_object_info", "all"); - else - { - conf->setValue("gui/selected_object_info", "custom"); - - conf->beginGroup("custom_selected_info"); - conf->setValue("flag_show_name", (bool) (flags & StelObject::Name)); - conf->setValue("flag_show_catalognumber", - (bool) (flags & StelObject::CatalogNumber)); - conf->setValue("flag_show_magnitude", - (bool) (flags & StelObject::Magnitude)); - conf->setValue("flag_show_absolutemagnitude", - (bool) (flags & StelObject::AbsoluteMagnitude)); - conf->setValue("flag_show_radecj2000", - (bool) (flags & StelObject::RaDecJ2000)); - conf->setValue("flag_show_radecofdate", - (bool) (flags & StelObject::RaDecOfDate)); - conf->setValue("flag_show_hourangle", - (bool) (flags & StelObject::HourAngle)); - conf->setValue("flag_show_altaz", - (bool) (flags & StelObject::AltAzi)); - conf->setValue("flag_show_distance", - (bool) (flags & StelObject::Distance)); - conf->setValue("flag_show_size", - (bool) (flags & StelObject::Size)); - conf->setValue("flag_show_extra", - (bool) (flags & StelObject::Extra)); - conf->setValue("flag_show_type", - (bool) (flags & StelObject::Type)); - conf->setValue("flag_show_galcoord", - (bool) (flags & StelObject::GalacticCoord)); - conf->endGroup(); - } - - // toolbar auto-hide status - conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideHorizontalButtonBar()); - conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVerticalButtonBar()); - conf->setValue("gui/flag_show_nebulae_background_button", gui->getFlagShowNebulaBackgroundButton()); - - mvmgr->setInitFov(mvmgr->getCurrentFov()); - mvmgr->setInitViewDirectionToCurrent(); - - // configuration dialog / navigation tab - conf->setValue("navigation/flag_enable_zoom_keys", mvmgr->getFlagEnableZoomKeys()); - conf->setValue("navigation/flag_enable_mouse_navigation", mvmgr->getFlagEnableMouseNavigation()); - conf->setValue("navigation/flag_enable_move_keys", mvmgr->getFlagEnableMoveKeys()); - conf->setValue("navigation/startup_time_mode", core->getStartupTimeMode()); - conf->setValue("navigation/today_time", core->getInitTodayTime()); - conf->setValue("navigation/preset_sky_time", core->getPresetSkyTime()); - conf->setValue("navigation/time_correction_algorithm", core->getCurrentDeltaTAlgorithmKey()); - conf->setValue("navigation/init_fov", mvmgr->getInitFov()); - if (mvmgr->getMountMode() == StelMovementMgr::MountAltAzimuthal) - conf->setValue("navigation/viewing_mode", "horizon"); - else - conf->setValue("navigation/viewing_mode", "equator"); - - - // configuration dialog / tools tab - conf->setValue("gui/flag_show_flip_buttons", gui->getFlagShowFlipButtons()); - // XXX: to reintroduce. - // conf->setValue("video/viewport_effect", StelMainView::getInstance().getStelAppGraphicsWidget()->getViewportEffect()); - conf->setValue("projection/viewport", StelProjector::maskTypeToString(proj->getMaskType())); - conf->setValue("viewing/flag_gravity_labels", proj->getFlagGravityLabels()); - conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->getFlagAutoZoomOutResetsDirection()); - conf->setValue("gui/flag_mouse_cursor_timeout", StelMainView::getInstance().getFlagCursorTimeout()); - conf->setValue("gui/mouse_cursor_timeout", StelMainView::getInstance().getCursorTimeout()); - - conf->setValue("main/screenshot_dir", StelFileMgr::getScreenshotDir()); - conf->setValue("main/invert_screenshots_colors", StelMainView::getInstance().getFlagInvertScreenShotColors()); - - // full screen and window size - conf->setValue("video/fullscreen", StelMainView::getInstance().isFullScreen()); - if (!StelMainView::getInstance().isFullScreen()) - { - QWidget& mainWindow = StelMainView::getInstance(); - conf->setValue("video/screen_w", mainWindow.size().width()); - conf->setValue("video/screen_h", mainWindow.size().height()); - conf->setValue("video/screen_x", mainWindow.x()); - conf->setValue("video/screen_y", mainWindow.y()); - } - - // clear the restore defaults flag if it is set. - conf->setValue("main/restore_defaults", false); - - updateConfigLabels(); -} - -void ConfigurationDialog::updateConfigLabels() -{ - ui->startupFOVLabel->setText(q_("Startup FOV: %1%2").arg(StelApp::getInstance().getCore()->getMovementMgr()->getCurrentFov()).arg(QChar(0x00B0))); - - double az, alt; - const Vec3d& v = GETSTELMODULE(StelMovementMgr)->getInitViewingDirection(); - StelUtils::rectToSphe(&az, &alt, v); - az = 3.*M_PI - az; // N is zero, E is 90 degrees - if (az > M_PI*2) - az -= M_PI*2; - ui->startupDirectionOfViewlabel->setText(q_("Startup direction of view Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt))); -} - -void ConfigurationDialog::setDefaultViewOptions() -{ - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - - conf->setValue("main/restore_defaults", true); -} - -void ConfigurationDialog::populatePluginsList() -{ - int prevSel = ui->pluginsListWidget->currentRow(); - ui->pluginsListWidget->clear(); - const QList pluginsList = StelApp::getInstance().getModuleMgr().getPluginsList(); - foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList) - { - QString label = q_(desc.info.displayedName); - QListWidgetItem* item = new QListWidgetItem(label); - item->setData(Qt::UserRole, desc.info.id); - ui->pluginsListWidget->addItem(item); - } - ui->pluginsListWidget->sortItems(Qt::AscendingOrder); - // If we had a valid previous selection (i.e. not first time we populate), restore it - if (prevSel >= 0 && prevSel < ui->pluginsListWidget->count()) - ui->pluginsListWidget->setCurrentRow(prevSel); - else - ui->pluginsListWidget->setCurrentRow(0); -} - -void ConfigurationDialog::pluginsSelectionChanged(const QString& s) -{ - const QList pluginsList = StelApp::getInstance().getModuleMgr().getPluginsList(); - foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList) - { - if (s==q_(desc.info.displayedName))//TODO: Use ID! - { - QString html = ""; - html += "

" + q_(desc.info.displayedName) + "

"; - QString d = desc.info.description; - d.replace("\n", "
"); - html += "

" + q_(d) + "

"; - html += "

" + q_("Authors") + ": " + desc.info.authors; - html += "
" + q_("Contact") + ": " + desc.info.contact; - html += "

"; - ui->pluginsInfoBrowser->setHtml(html); - ui->pluginLoadAtStartupCheckBox->setChecked(desc.loadAtStartup); - StelModule* pmod = StelApp::getInstance().getModuleMgr().getModule(desc.info.id, true); - if (pmod != NULL) - ui->pluginConfigureButton->setEnabled(pmod->configureGui(false)); - else - ui->pluginConfigureButton->setEnabled(false); - return; - } - } -} - -void ConfigurationDialog::pluginConfigureCurrentSelection() -{ - QString id = ui->pluginsListWidget->currentItem()->data(Qt::UserRole).toString(); - if (id.isEmpty()) - return; - - StelModuleMgr& moduleMgr = StelApp::getInstance().getModuleMgr(); - const QList pluginsList = moduleMgr.getPluginsList(); - foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList) - { - if (id == desc.info.id) - { - StelModule* pmod = moduleMgr.getModule(desc.info.id); - if (pmod != NULL) - { - pmod->configureGui(true); - } - return; - } - } -} - -void ConfigurationDialog::loadAtStartupChanged(int state) -{ - if (ui->pluginsListWidget->count() <= 0) - return; - - QString id = ui->pluginsListWidget->currentItem()->data(Qt::UserRole).toString(); - StelModuleMgr& moduleMgr = StelApp::getInstance().getModuleMgr(); - const QList pluginsList = moduleMgr.getPluginsList(); - foreach (const StelModuleMgr::PluginDescriptor& desc, pluginsList) - { - if (id == desc.info.id) - { - moduleMgr.setPluginLoadAtStartup(id, state == Qt::Checked); - break; - } - } -} - -#ifndef DISABLE_SCRIPTING -void ConfigurationDialog::populateScriptsList(void) -{ - int prevSel = ui->scriptListWidget->currentRow(); - StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); - ui->scriptListWidget->clear(); - ui->scriptListWidget->addItems(scriptMgr.getScriptList()); - // If we had a valid previous selection (i.e. not first time we populate), restore it - if (prevSel >= 0 && prevSel < ui->scriptListWidget->count()) - ui->scriptListWidget->setCurrentRow(prevSel); - else - ui->scriptListWidget->setCurrentRow(0); -} - -void ConfigurationDialog::scriptSelectionChanged(const QString& s) -{ - if (s.isEmpty()) - return; - StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); - //ui->scriptInfoBrowser->document()->setDefaultStyleSheet(QString(StelApp::getInstance().getCurrentStelStyle()->htmlStyleSheet)); - QString html = ""; - html += "

" + q_(scriptMgr.getName(s).trimmed()) + "

"; - QString d = scriptMgr.getDescription(s).trimmed(); - d.replace("\n", "
"); - d.replace(QRegExp("\\s{2,}"), " "); - html += "

" + q_(d) + "

"; - html += "

"; - if (!scriptMgr.getAuthor(s).trimmed().isEmpty()) - { - html += "" + q_("Author") + ": " + scriptMgr.getAuthor(s) + "
"; - } - if (!scriptMgr.getLicense(s).trimmed().isEmpty()) - { - html += "" + q_("License") + ": " + scriptMgr.getLicense(s); - } - html += "

"; - ui->scriptInfoBrowser->setHtml(html); -} - -void ConfigurationDialog::runScriptClicked(void) -{ - if (ui->closeWindowAtScriptRunCheckbox->isChecked()) - this->close(); - StelScriptMgr& scriptMgr = StelApp::getInstance().getScriptMgr(); - if (ui->scriptListWidget->currentItem()) - { - scriptMgr.runScript(ui->scriptListWidget->currentItem()->text()); - } -} - -void ConfigurationDialog::stopScriptClicked(void) -{ - StelApp::getInstance().getScriptMgr().stopScript(); -} - -void ConfigurationDialog::aScriptIsRunning(void) -{ - ui->scriptStatusLabel->setText(q_("Running script: ") + StelApp::getInstance().getScriptMgr().runningScriptId()); - ui->runScriptButton->setEnabled(false); - ui->stopScriptButton->setEnabled(true); -} - -void ConfigurationDialog::aScriptHasStopped(void) -{ - ui->scriptStatusLabel->setText(q_("Running script: [none]")); - ui->runScriptButton->setEnabled(true); - ui->stopScriptButton->setEnabled(false); -} -#endif - - -void ConfigurationDialog::setFixedDateTimeToCurrent(void) -{ - StelCore* core = StelApp::getInstance().getCore(); - double JD = core->getJDay(); - ui->fixedDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(JD+StelUtils::getGMTShiftFromQT(JD)/24-core->getDeltaT(JD)/86400)); - ui->fixedTimeRadio->setChecked(true); - setStartupTimeMode(); -} - - -void ConfigurationDialog::resetStarCatalogControls() -{ - const QVariantList& catalogConfig = GETSTELMODULE(StarMgr)->getCatalogsDescription(); - nextStarCatalogToDownload.clear(); - int idx=0; - foreach (const QVariant& catV, catalogConfig) - { - ++idx; - const QVariantMap& m = catV.toMap(); - const bool checked = m.value("checked").toBool(); - if (checked) - continue; - nextStarCatalogToDownload=m; - break; - } - - ui->downloadCancelButton->setVisible(false); - ui->downloadRetryButton->setVisible(false); - - if (idx > catalogConfig.size() && !hasDownloadedStarCatalog) - { - ui->getStarsButton->setVisible(false); - updateStarCatalogControlsText(); - return; - } - - ui->getStarsButton->setEnabled(true); - if (!nextStarCatalogToDownload.isEmpty()) - { - nextStarCatalogToDownloadIndex = idx; - starCatalogsCount = catalogConfig.size(); - updateStarCatalogControlsText(); - ui->getStarsButton->setVisible(true); - } - else - { - updateStarCatalogControlsText(); - ui->getStarsButton->setVisible(false); - } -} - -void ConfigurationDialog::updateStarCatalogControlsText() -{ - if (nextStarCatalogToDownload.isEmpty()) - { - //There are no more catalogs left? - if (hasDownloadedStarCatalog) - { - ui->downloadLabel->setText(q_("Finished downloading new star catalogs!\nRestart Stellarium to display them.")); - } - else - { - ui->downloadLabel->setText(q_("All available star catalogs have been installed.")); - } - } - else - { - QString text = QString(q_("Get catalog %1 of %2")) - .arg(nextStarCatalogToDownloadIndex) - .arg(starCatalogsCount); - ui->getStarsButton->setText(text); - - if (isDownloadingStarCatalog) - { - QString text = QString(q_("Downloading %1...\n(You can close this window.)")) - .arg(nextStarCatalogToDownload.value("id").toString()); - ui->downloadLabel->setText(text); - } - else - { - const QVariantList& magRange = nextStarCatalogToDownload.value("magRange").toList(); - ui->downloadLabel->setText(q_("Download size: %1MB\nStar count: %2 Million\nMagnitude range: %3 - %4") - .arg(nextStarCatalogToDownload.value("sizeMb").toString()) - .arg(nextStarCatalogToDownload.value("count").toString()) - .arg(magRange.first().toString()) - .arg(magRange.last().toString())); - } - } -} - -void ConfigurationDialog::cancelDownload(void) -{ - Q_ASSERT(currentDownloadFile); - Q_ASSERT(starCatalogDownloadReply); - qWarning() << "Aborting download"; - starCatalogDownloadReply->abort(); -} - -void ConfigurationDialog::newStarCatalogData() -{ - Q_ASSERT(currentDownloadFile); - Q_ASSERT(starCatalogDownloadReply); - Q_ASSERT(progressBar); - - int size = starCatalogDownloadReply->bytesAvailable(); - progressBar->setValue((float)progressBar->getValue()+(float)size/1024); - currentDownloadFile->write(starCatalogDownloadReply->read(size)); -} - -void ConfigurationDialog::downloadStars() -{ - Q_ASSERT(!nextStarCatalogToDownload.isEmpty()); - Q_ASSERT(!isDownloadingStarCatalog); - Q_ASSERT(starCatalogDownloadReply==NULL); - Q_ASSERT(currentDownloadFile==NULL); - Q_ASSERT(progressBar==NULL); - - QString path = StelFileMgr::getUserDir()+QString("/stars/default/")+nextStarCatalogToDownload.value("fileName").toString(); - currentDownloadFile = new QFile(path); - if (!currentDownloadFile->open(QIODevice::WriteOnly)) - { - qWarning() << "Can't open a writable file for storing new star catalog: " << QDir::toNativeSeparators(path); - currentDownloadFile->deleteLater(); - currentDownloadFile = NULL; - ui->downloadLabel->setText(q_("Error downloading %1:\n%2").arg(nextStarCatalogToDownload.value("id").toString()).arg(QString("Can't open a writable file for storing new star catalog: %1").arg(path))); - ui->downloadRetryButton->setVisible(true); - return; - } - - isDownloadingStarCatalog = true; - updateStarCatalogControlsText(); - ui->downloadCancelButton->setVisible(true); - ui->downloadRetryButton->setVisible(false); - ui->getStarsButton->setVisible(true); - ui->getStarsButton->setEnabled(false); - - QNetworkRequest req(nextStarCatalogToDownload.value("url").toString()); - req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); - req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false); - req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1()); - starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req); - starCatalogDownloadReply->setReadBufferSize(1024*1024*2); - connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData())); - connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished())); - connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); - - progressBar = StelApp::getInstance().addProgressBar(); - progressBar->setValue(0); - progressBar->setRange(0, nextStarCatalogToDownload.value("sizeMb").toDouble()*1024); - progressBar->setFormat(QString("%1: %p%").arg(nextStarCatalogToDownload.value("id").toString())); -} - -void ConfigurationDialog::downloadError(QNetworkReply::NetworkError) -{ - Q_ASSERT(currentDownloadFile); - Q_ASSERT(starCatalogDownloadReply); - - isDownloadingStarCatalog = false; - qWarning() << "Error downloading file" << starCatalogDownloadReply->url() << ": " << starCatalogDownloadReply->errorString(); - ui->downloadLabel->setText(q_("Error downloading %1:\n%2").arg(nextStarCatalogToDownload.value("id").toString()).arg(starCatalogDownloadReply->errorString())); - ui->downloadCancelButton->setVisible(false); - ui->downloadRetryButton->setVisible(true); - ui->getStarsButton->setVisible(false); - ui->getStarsButton->setEnabled(true); -} - -void ConfigurationDialog::downloadFinished() -{ - Q_ASSERT(currentDownloadFile); - Q_ASSERT(starCatalogDownloadReply); - Q_ASSERT(progressBar); - - if (starCatalogDownloadReply->error()!=QNetworkReply::NoError) - { - starCatalogDownloadReply->deleteLater(); - starCatalogDownloadReply = NULL; - currentDownloadFile->close(); - currentDownloadFile->deleteLater(); - currentDownloadFile = NULL; - StelApp::getInstance().removeProgressBar(progressBar); - progressBar=NULL; - return; - } - - Q_ASSERT(starCatalogDownloadReply->bytesAvailable()==0); - - const QVariant& redirect = starCatalogDownloadReply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (!redirect.isNull()) - { - // We got a redirection, we need to follow - starCatalogDownloadReply->deleteLater(); - QNetworkRequest req(redirect.toUrl()); - req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); - req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1()); - starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req); - starCatalogDownloadReply->setReadBufferSize(1024*1024*2); - connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData())); - connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished())); - connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); - return; - } - - isDownloadingStarCatalog = false; - currentDownloadFile->close(); - currentDownloadFile->deleteLater(); - currentDownloadFile = NULL; - starCatalogDownloadReply->deleteLater(); - starCatalogDownloadReply = NULL; - StelApp::getInstance().removeProgressBar(progressBar); - progressBar=NULL; - - ui->downloadLabel->setText(q_("Verifying file integrity...")); - if (GETSTELMODULE(StarMgr)->checkAndLoadCatalog(nextStarCatalogToDownload)==false) - { - ui->getStarsButton->setVisible(false); - ui->downloadLabel->setText(q_("Error downloading %1:\nFile is corrupted.").arg(nextStarCatalogToDownload.value("id").toString())); - ui->downloadCancelButton->setVisible(false); - ui->downloadRetryButton->setVisible(true); - } - else - { - hasDownloadedStarCatalog = true; - } - - resetStarCatalogControls(); -} - -void ConfigurationDialog::updateSelectedInfoCheckBoxes() -{ - const StelObject::InfoStringGroup& flags = gui->getInfoTextFilters(); - - ui->checkBoxName->setChecked(flags & StelObject::Name); - ui->checkBoxCatalogNumbers->setChecked(flags & StelObject::CatalogNumber); - ui->checkBoxVisualMag->setChecked(flags & StelObject::Magnitude); - ui->checkBoxAbsoluteMag->setChecked(flags & StelObject::AbsoluteMagnitude); - ui->checkBoxRaDecJ2000->setChecked(flags & StelObject::RaDecJ2000); - ui->checkBoxRaDecOfDate->setChecked(flags & StelObject::RaDecOfDate); - ui->checkBoxHourAngle->setChecked(flags & StelObject::HourAngle); - ui->checkBoxAltAz->setChecked(flags & StelObject::AltAzi); - ui->checkBoxDistance->setChecked(flags & StelObject::Distance); - ui->checkBoxSize->setChecked(flags & StelObject::Size); - ui->checkBoxExtra->setChecked(flags & StelObject::Extra); - ui->checkBoxGalacticCoordinates->setChecked(flags & StelObject::GalacticCoord); - ui->checkBoxType->setChecked(flags & StelObject::Type); -} - -void ConfigurationDialog::updateTabBarListWidgetWidth() -{ - QAbstractItemModel* model = ui->stackListWidget->model(); - if (!model) - return; - - // Update list item sizes after translation - ui->stackListWidget->adjustSize(); - - int width = 0; - for (int row = 0; row < model->rowCount(); row++) - { - QModelIndex index = model->index(row, 0); - width += ui->stackListWidget->sizeHintForIndex(index).width(); - } - - // TODO: Limit the width to the width of the screen *available to the window* - // FIXME: This works only sometimes... - /*if (width <= ui->stackListWidget->width()) - { - //qDebug() << width << ui->stackListWidget->width(); - return; - }*/ - - // Hack to force the window to be resized... - ui->stackListWidget->setMinimumWidth(width); - - // FIXME: This works only sometimes... - /* - dialog->adjustSize(); - dialog->update(); - // ... and allow manual resize later. - ui->stackListWidget->setMinimumWidth(0); - */ -} - -void ConfigurationDialog::populateDeltaTAlgorithmsList() -{ - Q_ASSERT(ui->deltaTAlgorithmComboBox); - - // TRANSLATORS: Full phrase is "Algorithm of DeltaT" - ui->deltaTLabel->setText(QString("%1 %2T:").arg(q_("Algorithm of")).arg(QChar(0x0394))); - - QComboBox* algorithms = ui->deltaTAlgorithmComboBox; - - //Save the current selection to be restored later - algorithms->blockSignals(true); - int index = algorithms->currentIndex(); - QVariant selectedAlgorithmId = algorithms->itemData(index); - algorithms->clear(); - //For each algorithm, display the localized name and store the key as user - //data. Unfortunately, there's no other way to do this than with a cycle. - algorithms->addItem(q_("Without correction"), "WithoutCorrection"); - algorithms->addItem(q_("Schoch (1931)"), "Schoch"); - algorithms->addItem(q_("Clemence (1948)"), "Clemence"); - algorithms->addItem(q_("IAU (1952)"), "IAU"); - algorithms->addItem(q_("Astronomical Ephemeris (1960)"), "AstronomicalEphemeris"); - algorithms->addItem(q_("Tuckerman (1962, 1964) & Goldstine (1973)"), "TuckermanGoldstine"); - algorithms->addItem(q_("Muller & Stephenson (1975)"), "MullerStephenson"); - algorithms->addItem(q_("Stephenson (1978)"), "Stephenson1978"); - algorithms->addItem(q_("Schmadel & Zech (1979)"), "SchmadelZech1979"); - algorithms->addItem(q_("Morrison & Stephenson (1982)"), "MorrisonStephenson1982"); - algorithms->addItem(q_("Stephenson & Morrison (1984)"), "StephensonMorrison1984"); - algorithms->addItem(q_("Stephenson & Houlden (1986)"), "StephensonHoulden"); - algorithms->addItem(q_("Espenak (1987, 1989)"), "Espenak"); - algorithms->addItem(q_("Borkowski (1988)"), "Borkowski"); - algorithms->addItem(q_("Schmadel & Zech (1988)"), "SchmadelZech1988"); - algorithms->addItem(q_("Chapront-Touze & Chapront (1991)"), "ChaprontTouze"); - algorithms->addItem(q_("Stephenson & Morrison (1995)"), "StephensonMorrison1995"); - algorithms->addItem(q_("Stephenson (1997)"), "Stephenson1997"); - // The dropdown label is too long for the string, and Meeus 1998 is very popular, this should be in the beginning of the tag. - algorithms->addItem(q_("Meeus (1998) (with Chapront, Chapront-Touze & Francou (1997))"), "ChaprontMeeus"); - algorithms->addItem(q_("JPL Horizons"), "JPLHorizons"); - algorithms->addItem(q_("Meeus & Simons (2000)"), "MeeusSimons"); - algorithms->addItem(q_("Montenbruck & Pfleger (2000)"), "MontenbruckPfleger"); - algorithms->addItem(q_("Reingold & Dershowitz (2002, 2007)"), "ReingoldDershowitz"); - algorithms->addItem(q_("Morrison & Stephenson (2004, 2005)"), "MorrisonStephenson2004"); - // Espenak & Meeus (2006) used by default - algorithms->addItem(q_("Espenak & Meeus (2006)").append(" *"), "EspenakMeeus"); - algorithms->addItem(q_("Reijs (2006)"), "Reijs"); - algorithms->addItem(q_("Banjevic (2006)"), "Banjevic"); - algorithms->addItem(q_("Islam, Sadiq & Qureshi (2008, 2013)"), "IslamSadiqQureshi"); - algorithms->addItem(q_("Custom equation of %1T").arg(QChar(0x0394)), "Custom"); - - //Restore the selection - index = algorithms->findData(selectedAlgorithmId, Qt::UserRole, Qt::MatchCaseSensitive); - algorithms->setCurrentIndex(index); - //algorithms->model()->sort(0); - algorithms->blockSignals(false); - setDeltaTAlgorithmDescription(); -} - -void ConfigurationDialog::setDeltaTAlgorithm(int algorithmID) -{ - StelCore* core = StelApp::getInstance().getCore(); - QString currentAlgorithm = ui->deltaTAlgorithmComboBox->itemData(algorithmID).toString(); - core->setCurrentDeltaTAlgorithmKey(currentAlgorithm); - setDeltaTAlgorithmDescription(); - if (currentAlgorithm.contains("Custom")) - ui->pushButtonCustomDeltaTEquationDialog->setEnabled(true); - else - ui->pushButtonCustomDeltaTEquationDialog->setEnabled(false); -} - -void ConfigurationDialog::setDeltaTAlgorithmDescription() -{ - ui->deltaTAlgorithmDescription->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->deltaTAlgorithmDescription->setHtml(StelApp::getInstance().getCore()->getCurrentDeltaTAlgorithmDescription()); -} - -void ConfigurationDialog::showCustomDeltaTEquationDialog() -{ - if (customDeltaTEquationDialog == NULL) - customDeltaTEquationDialog = new CustomDeltaTEquationDialog(); - - customDeltaTEquationDialog->setVisible(true); -} diff --git a/src/gui/ConfigurationDialog.hpp b/src/gui/ConfigurationDialog.hpp deleted file mode 100644 index b8b4011..0000000 --- a/src/gui/ConfigurationDialog.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _CONFIGURATIONDIALOG_HPP_ -#define _CONFIGURATIONDIALOG_HPP_ - -#include -#include -#include -#include "StelDialog.hpp" - -class Ui_configurationDialogForm; -class QSettings; -class QDataStream; -class QNetworkAccessManager; -class QListWidgetItem; -class StelGui; -class CustomDeltaTEquationDialog; - -class ConfigurationDialog : public StelDialog -{ - Q_OBJECT -public: - ConfigurationDialog(StelGui* agui, QObject* parent); - virtual ~ConfigurationDialog(); - //! Notify that the application style changed - void styleChanged(); - -public slots: - void retranslate(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - Ui_configurationDialogForm* ui; - -private: - //! Contains the parsed content of the starsConfig.json file - QVariantMap nextStarCatalogToDownload; - //! Reset the content of the "Star catalog updates" box. - //! Should be called only during initialization or - //! after a download is complete. - void resetStarCatalogControls(); - //! Re-translate the contents of the "Star calalogs" box. - //! Update the strings according to the state. - void updateStarCatalogControlsText(); - //! True if a star catalog download is in progress. - bool isDownloadingStarCatalog; - //! Value set by resetStarCatalogControls(). - int nextStarCatalogToDownloadIndex; - //! Value set by resetStarCatalogControls(). - int starCatalogsCount; - //! True when at least one star catalog has been downloaded successfully this session - bool hasDownloadedStarCatalog; - QNetworkReply* starCatalogDownloadReply; - QFile* currentDownloadFile; - class StelProgressController* progressBar; - -private slots: - void setNoSelectedInfo(); - void setAllSelectedInfo(); - void setBriefSelectedInfo(); - //! Set the selected object info fields from the "Displayed Fields" boxes. - //! Called when any of the boxes has been clicked. Sets the - //! "selected info" mode to "Custom". - void setSelectedInfoFromCheckBoxes(); - - void selectLanguage(const QString& languageCode); - void setStartupTimeMode(); - //! Show/bring to foreground the shortcut editor window. - void showShortcutsWindow(); - void setDiskViewport(bool); - void setSphericMirror(bool); - void cursorTimeOutChanged(); - void cursorTimeOutChanged(double) {cursorTimeOutChanged();} - - void newStarCatalogData(); - void downloadStars(); - void cancelDownload(); - void downloadFinished(); - void downloadError(QNetworkReply::NetworkError); - - //! Update the labels displaying the current default state - void updateConfigLabels(); - - //! open a file dialog to browse for a directory to save screenshots to - //! if a directory is selected (i.e. dialog not cancelled), current - //! value will be changed, but not saved to config file. - void browseForScreenshotDir(); - void selectScreenshotDir(const QString& dir); - - //! Save the current viewing option including landscape, location and sky culture - //! This doesn't include the current viewing direction, time and FOV since those - //! have specific controls - void saveCurrentViewOptions(); - - //! Reset all stellarium options. - //! This basically replaces the config.ini by the default one - void setDefaultViewOptions(); - - void populatePluginsList(); - void pluginsSelectionChanged(const QString&); - void pluginConfigureCurrentSelection(); - void loadAtStartupChanged(int); - - void populateDeltaTAlgorithmsList(); - void setDeltaTAlgorithm(int algorithmID); - void setDeltaTAlgorithmDescription(); - void showCustomDeltaTEquationDialog(); - - #ifndef DISABLE_SCRIPTING - //! The selection of script in the script list has changed - //! Updates the script information panel - void scriptSelectionChanged(const QString& s); - - //! Run the currently selected script from the script list. - void runScriptClicked(); - //! Stop the currently running script. - void stopScriptClicked(); - - void aScriptIsRunning(); - void aScriptHasStopped(); - - void populateScriptsList(); - #endif - void setFixedDateTimeToCurrent(); - -private: - StelGui* gui; - - CustomDeltaTEquationDialog* customDeltaTEquationDialog; - - int savedProjectionType; - - //! Set the displayed fields checkboxes from the current displayed fields. - void updateSelectedInfoCheckBoxes(); - //! Make sure that no tabs icons are outside of the viewport. - //! @todo Limit the width to the width of the screen *available to the window*. - void updateTabBarListWidgetWidth(); -}; - -#endif // _CONFIGURATIONDIALOG_HPP_ diff --git a/src/gui/CustomDeltaTEquationDialog.cpp b/src/gui/CustomDeltaTEquationDialog.cpp deleted file mode 100644 index 22bb362..0000000 --- a/src/gui/CustomDeltaTEquationDialog.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2013 Alexander Wolf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "CustomDeltaTEquationDialog.hpp" -#include "ui_CustomDeltaTEquationDialog.h" - -#include "Dialog.hpp" -#include "StelApp.hpp" -#include "StelTranslator.hpp" -#include "StelObjectMgr.hpp" - -#include - -CustomDeltaTEquationDialog::CustomDeltaTEquationDialog() -{ - ui = new Ui_CustomDeltaTEquationDialogForm; - conf = StelApp::getInstance().getSettings(); - core = StelApp::getInstance().getCore(); - - ndot = core->getDeltaTCustomNDot(); - year = core->getDeltaTCustomYear(); - coeff = core->getDeltaTCustomEquationCoefficients(); -} - -CustomDeltaTEquationDialog::~CustomDeltaTEquationDialog() -{ - delete ui; - ui=NULL; -} - -void CustomDeltaTEquationDialog::retranslate() -{ - if (dialog) - { - ui->retranslateUi(dialog); - setDescription(); - } -} - - -void CustomDeltaTEquationDialog::createDialogContent() -{ - ui->setupUi(dialog); - setDescription(); - - ui->labelNDot->setText(QString("%1:").arg(QChar(0x1E45))); - - ui->lineEditCoefficientA->setText(QString("%1").arg(coeff[0])); - ui->lineEditCoefficientB->setText(QString("%1").arg(coeff[1])); - ui->lineEditCoefficientC->setText(QString("%1").arg(coeff[2])); - ui->lineEditYear->setText(QString("%1").arg(year)); - ui->lineEditNDot->setText(QString("%1").arg(ndot)); - - //Signals and slots - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - connect(ui->lineEditNDot, SIGNAL(textEdited(const QString&)), this, SLOT(setNDot(const QString&))); - connect(ui->lineEditYear, SIGNAL(textEdited(const QString&)), this, SLOT(setYear(const QString&))); - connect(ui->lineEditCoefficientA, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffA(const QString&))); - connect(ui->lineEditCoefficientB, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffB(const QString&))); - connect(ui->lineEditCoefficientC, SIGNAL(textEdited(const QString&)), this, SLOT(setCoeffC(const QString&))); - -} - -void CustomDeltaTEquationDialog::setVisible(bool v) -{ - StelDialog::setVisible(v); -} - -void CustomDeltaTEquationDialog::saveSettings(void) const -{ - conf->beginGroup("custom_time_correction"); - - conf->setValue("year", year); - conf->setValue("ndot", ndot); - conf->setValue("coefficients", QString("%1,%2,%3").arg(coeff[0]).arg(coeff[1]).arg(coeff[2])); - - conf->endGroup(); -} - -void CustomDeltaTEquationDialog::setNDot(const QString& v) -{ - ndot = v.toFloat(); - core->setDeltaTCustomNDot(ndot); - saveSettings(); -} - -void CustomDeltaTEquationDialog::setYear(const QString& v) -{ - year = v.toFloat(); - core->setDeltaTCustomYear(year); - saveSettings(); -} - -void CustomDeltaTEquationDialog::setCoeffA(const QString& v) -{ - coeff[0] = v.toFloat(); - core->setDeltaTCustomEquationCoefficients(coeff); - saveSettings(); -} - -void CustomDeltaTEquationDialog::setCoeffB(const QString& v) -{ - coeff[1] = v.toFloat(); - core->setDeltaTCustomEquationCoefficients(coeff); - saveSettings(); -} - -void CustomDeltaTEquationDialog::setCoeffC(const QString& v) -{ - coeff[2] = v.toFloat(); - core->setDeltaTCustomEquationCoefficients(coeff); - saveSettings(); -} - -void CustomDeltaTEquationDialog::setDescription() const -{ - ui->stelWindowTitle->setText(q_("Custom equation for %1T").arg(QChar(0x0394))); - ui->labelDescription->setText(q_("A typical equation for calculation of %1T looks like:").arg(QChar(0x0394))); - ui->labelEquation->setText(QString("%1T = a + b%2u + c%3u%4,").arg(QChar(0x0394)).arg(QChar(0x00B7)).arg(QChar(0x00B7)).arg(QChar(0x00B2))); - ui->labelSubEquation->setText(QString("%1 u = (%2 - y)/100").arg(q_("where")).arg(q_("year"))); -} diff --git a/src/gui/CustomDeltaTEquationDialog.hpp b/src/gui/CustomDeltaTEquationDialog.hpp deleted file mode 100644 index e4a9ebc..0000000 --- a/src/gui/CustomDeltaTEquationDialog.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2013 Alexander Wolf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -// AW: Methods copied largely from AddRemoveLandscapesDialog - -#ifndef _CUSTOMDELTATEQUATIONDIALOG_HPP_ -#define _CUSTOMDELTATEQUATIONDIALOG_HPP_ - -#include -#include -#include "StelDialog.hpp" -#include "StelCore.hpp" - -class Ui_CustomDeltaTEquationDialogForm; - -//! @class CustomDeltaTEquationDialog -class CustomDeltaTEquationDialog : public StelDialog -{ - Q_OBJECT - -public: - CustomDeltaTEquationDialog(); - virtual ~CustomDeltaTEquationDialog(); - -public slots: - void retranslate(); - void setVisible(bool); - -protected: - //! Initialize the dialog widgets and connect the signals/slots. - virtual void createDialogContent(); - Ui_CustomDeltaTEquationDialogForm *ui; - -private slots: - void saveSettings(void) const; - - void setNDot(const QString& v); - void setYear(const QString& v); - void setCoeffA(const QString& v); - void setCoeffB(const QString& v); - void setCoeffC(const QString& v); - -private: - QSettings* conf; - StelCore* core; - - float year; - float ndot; - Vec3f coeff; - - void setDescription(void) const; - -}; - -#endif // _CUSTOMDELTATEQUATIONDIALOG_HPP_ diff --git a/src/gui/CustomDeltaTEquationDialog.ui b/src/gui/CustomDeltaTEquationDialog.ui deleted file mode 100644 index a20d71a..0000000 --- a/src/gui/CustomDeltaTEquationDialog.ui +++ /dev/null @@ -1,262 +0,0 @@ - - - CustomDeltaTEquationDialogForm - - - - 0 - 0 - 168 - 261 - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - - - - Qt::AlignCenter - - - - 0 - - - - - description - - - - - - - equation - - - Qt::RichText - - - Qt::AlignCenter - - - - - - - subequation - - - - - - - - - a: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - b: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - c: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - y: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - ndot: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - -
diff --git a/src/gui/DateTimeDialog.cpp b/src/gui/DateTimeDialog.cpp deleted file mode 100644 index c7bf773..0000000 --- a/src/gui/DateTimeDialog.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Nigel Kerr - * Copyright (C) 2012 Timothy Reaves - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "Dialog.hpp" -#include "DateTimeDialog.hpp" -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelLocaleMgr.hpp" -#include "StelUtils.hpp" - -#include "ui_dateTimeDialogGui.h" - -#include -#include -#include - -DateTimeDialog::DateTimeDialog(QObject* parent) : - StelDialog(parent), - year(0), - month(0), - day(0), - hour(0), - minute(0), - second(0) -{ - ui = new Ui_dateTimeDialogForm; -} - -DateTimeDialog::~DateTimeDialog() -{ - delete ui; - ui=NULL; -} - -void DateTimeDialog::createDialogContent() -{ - ui->setupUi(dialog); - double jd = StelApp::getInstance().getCore()->getJDay(); - // UTC -> local tz - // Add in a DeltaT correction. Divide DeltaT by 86400 to convert from seconds to days. - double deltaT = 0.; - if (StelApp::getInstance().getCore()->getCurrentLocation().planetName=="Earth") - deltaT = StelApp::getInstance().getCore()->getDeltaT(jd)/86400.; - setDateTime(jd + (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0)-deltaT); - - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - connectSpinnerEvents(); -} - -void DateTimeDialog::connectSpinnerEvents() const -{ - connect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int))); - connect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int))); - connect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayChanged(int))); - connect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int))); - connect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int))); - connect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(secondChanged(int))); -} - -void DateTimeDialog::disconnectSpinnerEvents()const -{ - disconnect(ui->spinner_year, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int))); - disconnect(ui->spinner_month, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int))); - disconnect(ui->spinner_day, SIGNAL(valueChanged(int)), this, SLOT(dayChanged(int))); - disconnect(ui->spinner_hour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int))); - disconnect(ui->spinner_minute, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int))); - disconnect(ui->spinner_second, SIGNAL(valueChanged(int)), this, SLOT(secondChanged(int))); -} - - -//! take in values, adjust for calendrical correctness if needed, and push to -//! the widgets and signals -bool DateTimeDialog::valid(int y, int m, int d, int h, int min, int s) -{ - int dy, dm, dd, dh, dmin, ds; - - if (!StelUtils::changeDateTimeForRollover(y, m, d, h, min, s, &dy, &dm, &dd, &dh, &dmin, &ds)) { - dy = y; - dm = m; - dd = d; - dh = h; - dmin = min; - ds = s; - } - - year = dy; - month = dm; - day = dd; - hour = dh; - minute = dmin; - second = ds; - pushToWidgets(); - StelApp::getInstance().getCore()->setJDay(newJd()); - return true; -} - -void DateTimeDialog::retranslate() -{ - if (dialog) { - ui->retranslateUi(dialog); - } -} - -void DateTimeDialog::styleChanged() -{ - // Nothing for now -} - -void DateTimeDialog::close() -{ - ui->dateTimeBox->setFocus(); - StelDialog::close(); -} - -/************************************************************************ - year slider or dial changed -************************************************************************/ - -void DateTimeDialog::yearChanged(int newyear) -{ - if ( year != newyear ) { - valid( newyear, month, day, hour, minute, second ); - } -} -void DateTimeDialog::monthChanged(int newmonth) -{ - if ( month != newmonth ) { - valid( year, newmonth, day, hour, minute, second ); - } -} -void DateTimeDialog::dayChanged(int newday) -{ - if ( day != newday ) { - valid( year, month, newday, hour, minute, second ); - } -} -void DateTimeDialog::hourChanged(int newhour) -{ - if ( hour != newhour ) { - valid( year, month, day, newhour, minute, second ); - } -} -void DateTimeDialog::minuteChanged(int newminute) -{ - if ( minute != newminute ) { - valid( year, month, day, hour, newminute, second ); - } -} -void DateTimeDialog::secondChanged(int newsecond) -{ - if ( second != newsecond ) { - valid( year, month, day, hour, minute, newsecond ); - } -} - -double DateTimeDialog::newJd() -{ - double jd; - StelUtils::getJDFromDate(&jd,year, month, day, hour, minute, second); - // Add in a DeltaT correction. Divide DeltaT by 86400 to convert from seconds to days. - double deltaT = 0.; - if (StelApp::getInstance().getCore()->getCurrentLocation().planetName=="Earth") - deltaT = StelApp::getInstance().getCore()->getDeltaT(jd)/86400.; - jd -= (StelApp::getInstance().getLocaleMgr().getGMTShift(jd)/24.0-deltaT); // local tz -> UTC - return jd; -} - -void DateTimeDialog::pushToWidgets() -{ - disconnectSpinnerEvents(); - ui->spinner_year->setValue(year); - ui->spinner_month->setValue(month); - ui->spinner_day->setValue(day); - ui->spinner_hour->setValue(hour); - if (!ui->spinner_minute->hasFocus() - || (ui->spinner_minute->value() == -1) - || (ui->spinner_minute->value() == 60)) { - ui->spinner_minute->setValue(minute); - } - if (!ui->spinner_second->hasFocus() - || (ui->spinner_second->value() == -1) - || (ui->spinner_second->value() == 60)) { - ui->spinner_second->setValue(second); - } - connectSpinnerEvents(); -} - -/************************************************************************ -Send newJd to spinner_* - ************************************************************************/ -void DateTimeDialog::setDateTime(double newJd) -{ - if (this->visible()) { - // Add in a DeltaT correction. Divide DeltaT by 86400 to convert from seconds to days. - double deltaT = 0.; - if (StelApp::getInstance().getCore()->getCurrentLocation().planetName=="Earth") - deltaT = StelApp::getInstance().getCore()->getDeltaT(newJd)/86400.; - newJd += (StelApp::getInstance().getLocaleMgr().getGMTShift(newJd)/24.0-deltaT); // UTC -> local tz - StelUtils::getDateFromJulianDay(newJd, &year, &month, &day); - StelUtils::getTimeFromJulianDay(newJd, &hour, &minute, &second); - pushToWidgets(); - } -} - diff --git a/src/gui/DateTimeDialog.hpp b/src/gui/DateTimeDialog.hpp deleted file mode 100644 index 17e5dcd..0000000 --- a/src/gui/DateTimeDialog.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Nigel Kerr - * Copyright (C) 2012 Timothy Reaves - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _DATETIMEDIALOG_HPP_ -#define _DATETIMEDIALOG_HPP_ - -#include -#include "StelDialog.hpp" - -class Ui_dateTimeDialogForm; - -class DateTimeDialog : public StelDialog -{ - Q_OBJECT -public: - DateTimeDialog(QObject* parent); - ~DateTimeDialog(); - double newJd(); - bool valid(int y, int m, int d, int h, int min, int s); - //! Notify that the application style changed - void styleChanged(); -public slots: - void retranslate(); - //! update the editing display with new JD. - void setDateTime(double newJd); - - void close(); - - -protected: - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - void connectSpinnerEvents() const; - void disconnectSpinnerEvents()const; - -private slots: - //! year slider or dial changed - void yearChanged(int ny); - //! year slider or dial changed - void monthChanged(int nm); - //! year slider or dial changed - void dayChanged(int nd); - //! year slider or dial changed - void hourChanged(int nh); - //! year slider or dial changed - void minuteChanged(int nm); - //! year slider or dial changed - void secondChanged(int ns); - -private: - Ui_dateTimeDialogForm* ui; - int year; - int month; - int day; - int hour; - int minute; - int second; - void pushToWidgets(); -}; - -#endif // _DATETIMEDIALOG_HPP_ diff --git a/src/gui/Dialog.cpp b/src/gui/Dialog.cpp deleted file mode 100644 index 9b912a4..0000000 --- a/src/gui/Dialog.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include - -#include "Dialog.hpp" -#include "StelMainView.hpp" - -void BarFrame::mousePressEvent(QMouseEvent *event) -{ - mousePos = event->pos(); - moving = true; -} - -void BarFrame::mouseReleaseEvent(QMouseEvent *) -{ - moving = false; -} - -void BarFrame::mouseMoveEvent(QMouseEvent *event) -{ - if (!moving) return; - QPoint dpos = event->pos() - mousePos; - QWidget* p = dynamic_cast(QFrame::parent()); - QPoint targetPos = p->pos() + dpos; - - // Prevent the title bar from being dragged to an unreachable position. - QWidget& mainWindow = StelMainView::getInstance(); - int leftBoundX = 10 - width(); - int rightBoundX = mainWindow.width() - 10; - if (targetPos.x() < leftBoundX) - targetPos.setX(leftBoundX); - else if (targetPos.x() > rightBoundX) - targetPos.setX(rightBoundX); - - int lowerBoundY = mainWindow.height() - height(); - if (targetPos.y() < 0) - targetPos.setY(0); - else if (targetPos.y() > lowerBoundY) - targetPos.setY(lowerBoundY); - - p->move(targetPos); -} - -void ResizeFrame::mouseMoveEvent(QMouseEvent *event) -{ - QPoint dpos = event->pos() - mousePos; - QWidget* p = dynamic_cast(QFrame::parent()->parent()); - int w = p->size().width(); - int h = p->size().height(); - int minw; - int minh; - - if (p->minimumSizeHint().isValid()) - { - minw = p->minimumSizeHint().width(); - minh = p->minimumSizeHint().height(); - } - else - { - minw = p->minimumWidth() > 0 ? p->minimumWidth() : 24; - minh = p->minimumHeight() > 0 ? p->minimumHeight() : 24; - } - - // The minimum size will only be enforced if the widget is being - // shrunk, and its size is larger than its minimum size. (If, for some - // reason, the widget's size is already *smaller* than its minimum - // size, and the user is actually trying to *shrink* it, then it would - // be rather odd to *enlarge* the widget to its minimum size.) - if (w + dpos.x() >= minw) - w += dpos.x(); - else if (w > minw && dpos.x() < 0) - w = minw; - if (h + dpos.y() >= minh) - h += dpos.y(); - else if (h > minh && dpos.y() < 0) - h = minh; - - p->setUpdatesEnabled(false); - p->resize(w, h); - p->setUpdatesEnabled(true); -} diff --git a/src/gui/Dialog.hpp b/src/gui/Dialog.hpp deleted file mode 100644 index 77e276e..0000000 --- a/src/gui/Dialog.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - - -#ifndef _DIALOG_HPP_ -#define _DIALOG_HPP_ - -#include -#include -#include - -//! \class BarFrame -//! A title bar control used in windows derived from StelDialog. -//! -//! As window classes derived from StelDialog are basic QWidgets, they have no -//! title bar. A BarFrame control needs to be used in each window's design -//! to allow the user to move them. -//! -//! Typically, the frame should contain a centered label displaying the window's -//! title and a button for closing the window (connected to the -//! StelDialog::close() slot). -//! -//! To use the default Stellarium style for title bars, the BarFrame object of a -//! given window should be named "TitleBar". See the normalStyle.css file for -//! the style sheet description. -class BarFrame : public QFrame -{ -Q_OBJECT -public: - QPoint mousePos; - - BarFrame(QWidget* parent) : QFrame(parent), moving(false) {} - - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); -protected: - bool moving; -}; - -class ResizeFrame : public QFrame -{ -Q_OBJECT -public: - QPoint mousePos; - - ResizeFrame(QWidget* parent) : QFrame(parent) {} - - virtual void mousePressEvent(QMouseEvent *event) { - mousePos = event->pos(); - } - virtual void mouseMoveEvent(QMouseEvent *event); -}; - - -#endif // _DIALOG_HPP_ diff --git a/src/gui/HelpDialog.cpp b/src/gui/HelpDialog.cpp deleted file mode 100644 index 74e6b9c..0000000 --- a/src/gui/HelpDialog.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2007 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ui_helpDialogGui.h" -#include "HelpDialog.hpp" - -#include "StelUtils.hpp" -#include "StelApp.hpp" -#include "StelFileMgr.hpp" -#include "StelGui.hpp" -#include "StelGuiItems.hpp" -#include "StelLocaleMgr.hpp" -#include "StelLogger.hpp" -#include "StelStyle.hpp" -#include "StelActionMgr.hpp" - -HelpDialog::HelpDialog(QObject* parent) : StelDialog(parent) -{ - ui = new Ui_helpDialogForm; -} - -HelpDialog::~HelpDialog() -{ - delete ui; - ui = NULL; -} - -void HelpDialog::retranslate() -{ - if (dialog) - { - ui->retranslateUi(dialog); - updateText(); - } -} - -void HelpDialog::styleChanged() -{ - if (dialog) - { - updateText(); - } -} - -void HelpDialog::createDialogContent() -{ - ui->setupUi(dialog); - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - ui->stackedWidget->setCurrentIndex(0); - ui->stackListWidget->setCurrentRow(0); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - // Help page - updateText(); - connect(ui->editShortcutsButton, SIGNAL(clicked()), - this, SLOT(showShortcutsWindow())); - - // Log page - ui->logPathLabel->setText(QString("%1/log.txt:").arg(StelFileMgr::getUserDir())); - connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(updateLog(int))); - connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshLog())); - - connect(ui->stackListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); -} - - -void HelpDialog::showShortcutsWindow() -{ - StelAction* action = StelApp::getInstance().getStelActionManager()->findAction("actionShow_Shortcuts_Window_Global"); - if (action) - action->setChecked(true); -} - -void HelpDialog::updateLog(int) -{ - if (ui->stackedWidget->currentWidget() == ui->pageLog) - refreshLog(); -} - -void HelpDialog::refreshLog() -{ - ui->logBrowser->setPlainText(StelLogger::getLog()); -} - -QString HelpDialog::getHelpText(void) -{ - #define E(x) q_(x).toHtmlEscaped() - QString htmlText = ""; - htmlText += E("Stellarium Help"); - htmlText += "\n"; - - // WARNING! Section titles are re-used below! - htmlText += "

" + - E("Keys") + - "" + - E("Further Reading") + - "

\n"; - - htmlText += "

" + E("Keys") + "

\n"; - htmlText += "\n"; - // Describe keys for those keys which do not have actions. - // navigate - htmlText += ""; - htmlText += "\n"; - // zoom in/out - htmlText += ""; - htmlText += "\n"; - htmlText += "\n"; - // select object - htmlText += ""; - htmlText += "\n"; - // clear selection - htmlText += ""; -#ifdef Q_OS_MAC - htmlText += ""; - htmlText += "\n"; -#ifdef Q_OS_MAC - htmlText += "\n"; - //htmlText += ""; -#endif - - htmlText += "
" + E("Pan view around the sky") + "" + E("Arrow keys & left mouse drag") + "
" + E("Zoom in/out") + - "" + E("Page Up/Down") + - "
" + E("CTRL + Up/Down") + - "
" + E("Select object") + "" + E("Left click") + "
"; -#else - htmlText += ""; -#endif - htmlText += E("Clear selection") + "" + E("Right click") + "
" + E("CTRL + Left click") + "
" + E("Clear selection") + "
\n

" + - q_("Below are listed only the actions with assigned keys. Further actions may be available via the \"%1\" button.") - .arg(ui->editShortcutsButton->text()).toHtmlEscaped() + - "

\n"; - - // Append all StelAction shortcuts. - StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager(); - typedef QPair KeyDescription; - foreach (QString group, actionMgr->getGroupList()) - { - QList descriptions; - foreach (StelAction* action, actionMgr->getActionList(group)) - { - if (action->getShortcut().isEmpty()) - continue; - QString text = action->getText(); - QString key = action->getShortcut().toString(QKeySequence::NativeText); - descriptions.append(KeyDescription(text, key)); - } - qSort(descriptions); - htmlText += "\n"; - foreach (const KeyDescription& desc, descriptions) - { - htmlText += ""; - htmlText += "\n"; - } - } - - // edit shortcuts -// htmlText += ""; -// htmlText += "\n"; - htmlText += "
" + E(group) + - ":
" + desc.first.toHtmlEscaped() + "" + desc.second.toHtmlEscaped() + - "
" + Qt::escape(q_("F7")) + "" + Qt::escape(q_("Show and edit all keyboard shortcuts")) + "
"; - - // Regexp to replace {text} with an HTML link. - QRegExp a_rx = QRegExp("[{]([^{]*)[}]"); - - // WARNING! Section titles are re-used above! - htmlText += "

" + E("Further Reading") + "

\n"; - htmlText += E("The following links are external web links, and will launch your web browser:\n"); - htmlText += "

" + E("The Stellarium User Guide") + ""; - - htmlText += "

"; - // TRANSLATORS: The text between braces is the text of an HTML link. - htmlText += E("{Frequently Asked Questions} about Stellarium. Answers too.").replace(a_rx, "\\1"); - htmlText += "

\n"; - - htmlText += "

"; - // TRANSLATORS: The text between braces is the text of an HTML link. - htmlText += E("{The Stellarium Wiki} - General information. You can also find user-contributed landscapes and scripts here.").replace(a_rx, "\\1"); - htmlText += "

\n"; - - htmlText += "

"; - // TRANSLATORS: The text between braces is the text of an HTML link. - htmlText += E("{Support ticket system} - if you need help using Stellarium, post a support request here and we'll try to help.").replace(a_rx, "\\1"); - htmlText += "

\n"; - - htmlText += "

"; - // TRANSLATORS: The text between braces is the text of an HTML link. - htmlText += E("{Bug reporting and feature request system} - if something doesn't work properly or is missing and is not listed in the tracker, you can open bug reports here.").replace(a_rx, "\\1"); - htmlText += "

\n"; - - htmlText += "

"; - // TRANSLATORS: The text between braces is the text of an HTML link. - htmlText += E("{Forums} - discuss Stellarium with other users.").replace(a_rx, "\\1"); - htmlText += "

\n"; - - htmlText += "\n"; - - return htmlText; -#undef E -} - -void HelpDialog::updateText(void) -{ - QString newHtml = getHelpText(); - ui->helpBrowser->clear(); - StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); - Q_ASSERT(gui); - ui->helpBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->helpBrowser->insertHtml(newHtml); - ui->helpBrowser->scrollToAnchor("top"); - - // populate About tab - newHtml = "

" + StelUtils::getApplicationName() + "

"; - // Note: this legal notice is not suitable for traslation - newHtml += "

Copyright © 2000-2013 Stellarium Developers

"; - newHtml += "

This program is free software; you can redistribute it and/or "; - newHtml += "modify it under the terms of the GNU General Public License "; - newHtml += "as published by the Free Software Foundation; either version 2 "; - newHtml += "of the License, or (at your option) any later version.

"; - newHtml += "

This program is distributed in the hope that it will be useful, "; - newHtml += "but WITHOUT ANY WARRANTY; without even the implied "; - newHtml += "warranty of MERCHANTABILITY or FITNESS FOR A "; - newHtml += "PARTICULAR PURPOSE. See the GNU General Public "; - newHtml += "License for more details.

"; - newHtml += "

You should have received a copy of the GNU General Public "; - newHtml += "License along with this program; if not, write to:

"; - newHtml += "
Free Software Foundation, Inc.\n";
-	newHtml += "51 Franklin Street, Suite 500\n";
-	newHtml += "Boston, MA  02110-1335, USA.\n
"; - newHtml += "

www.fsf.org

"; - newHtml += "

" + q_("Developers").toHtmlEscaped() + "

    "; - newHtml += "
  • " + q_("Project coordinator & lead developer: %1").arg(QString("Fabien Ch%1reau").arg(QChar(0x00E9))).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Doc author/developer: %1").arg(QString("Matthew Gates")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Bogdan Marinov")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Timothy Reaves")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Guillaume Ch%1reau").arg(QChar(0x00E9))).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Georg Zotti")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Alexander Wolf")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Continuous Integration: %1").arg(QString("Hans Lambermont")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Tester: %1").arg(QString("Barry Gerdes")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Tester: %1").arg(QString("Khalid AlAjaji")).toHtmlEscaped() + "
"; - newHtml += "

" + q_("Past Developers").toHtmlEscaped() + "

"; - newHtml += "

" + q_("Several people have made significant contributions, but are no longer active. Their work has made a big difference to the project:").toHtmlEscaped() + "

    "; - newHtml += "
  • " + q_("Graphic/other designer: %1").arg(QString("Johan Meuris")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Johannes Gajdosik")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Rob Spearman")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Andr%1s Mohari").arg(QChar(0x00E1))).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("Developer: %1").arg(QString("Mike Storm")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("OSX Developer: %1").arg(QString("Nigel Kerr")).toHtmlEscaped() + "
  • "; - newHtml += "
  • " + q_("OSX Developer: %1").arg(QString("Diego Marcos")).toHtmlEscaped() + "
"; - newHtml += "

"; - ui->aboutBrowser->clear(); - ui->aboutBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->aboutBrowser->insertHtml(newHtml); - ui->aboutBrowser->scrollToAnchor("top"); -} - -void HelpDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (!current) - current = previous; - ui->stackedWidget->setCurrentIndex(ui->stackListWidget->row(current)); -} diff --git a/src/gui/HelpDialog.hpp b/src/gui/HelpDialog.hpp deleted file mode 100644 index 174971a..0000000 --- a/src/gui/HelpDialog.hpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2007 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _HELPDIALOG_HPP_ -#define _HELPDIALOG_HPP_ - -#include -#include - -#include "StelDialog.hpp" - -class Ui_helpDialogForm; -class QListWidgetItem; - -class HelpDialog : public StelDialog -{ - Q_OBJECT -public: - HelpDialog(QObject* parent); - ~HelpDialog(); - - //! Notify that the application style changed - void styleChanged(); - -public slots: - void retranslate(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - - Ui_helpDialogForm* ui; - -private slots: - //! Show/bring to foreground the shortcut editor window. - void showShortcutsWindow(); - - //! On tab change, if the Log tab is selected, call refreshLog(). - void updateLog(int); - - //! Sync the displayed log. - void refreshLog(); - - void changePage(QListWidgetItem *current, QListWidgetItem *previous); - -private: - //! Return the help text with keys description and external links. - QString getHelpText(void); - - //! This function concatenates the header, key codes and footer to build - //! up the help text. - void updateText(void); -}; - -#endif /*_HELPDIALOG_HPP_*/ - diff --git a/src/gui/LocationDialog.cpp b/src/gui/LocationDialog.cpp deleted file mode 100644 index eeb1b63..0000000 --- a/src/gui/LocationDialog.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * Copyright (C) 2011 Alexander Wolf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "Dialog.hpp" -#include "LocationDialog.hpp" -#include "LandscapeMgr.hpp" -#include "StelLocationMgr.hpp" -#include "ui_locationDialogGui.h" -#include "StelApp.hpp" -#include "StelCore.hpp" - -#include "StelModuleMgr.hpp" -#include "SolarSystem.hpp" -#include "Planet.hpp" -#include "StelFileMgr.hpp" -#include "StelLocaleMgr.hpp" -#include "StelGui.hpp" -#include "StelGuiItems.hpp" - -#include -#include -#include -#include -#include -#include - -LocationDialog::LocationDialog(QObject* parent) : StelDialog(parent), isEditingNew(false) -{ - ui = new Ui_locationDialogForm; -} - -LocationDialog::~LocationDialog() -{ - delete ui; -} - -void LocationDialog::retranslate() -{ - if (dialog) - { - ui->retranslateUi(dialog); - populatePlanetList(); - populateCountryList(); - } -} - -void LocationDialog::styleChanged() -{ - // Make the map red if needed - if (dialog) - setMapForLocation(StelApp::getInstance().getCore()->getCurrentLocation()); -} - -// Initialize the dialog widgets and connect the signals/slots -void LocationDialog::createDialogContent() -{ - // We try to directly connect to the observer slots as much as we can - ui->setupUi(dialog); - - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - // Init the SpinBox entries - ui->longitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); - ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude); - ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); - ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude); - - QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); - proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelAll()); - proxyModel->sort(0, Qt::AscendingOrder); - proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - ui->citiesListView->setModel(proxyModel); - - populatePlanetList(); - populateCountryList(); - - connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&))); - connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), - this, SLOT(setPositionFromList(const QModelIndex&))); - - // Connect all the QT signals - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double))); - - connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList())); - connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList())); - - StelCore* core = StelApp::getInstance().getCore(); - const StelLocation& currentLocation = core->getCurrentLocation(); - setFieldsFromLocation(currentLocation); - - const bool b = (currentLocation.getID() == core->getDefaultLocationID()); - updateDefaultLocationControls(b); - connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked()), this, SLOT(setDefaultLocation())); - connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), - core, SLOT(returnToDefaultLocation())); - - connectEditSignals(); - - connect(core, SIGNAL(locationChanged(StelLocation)), - this, SLOT(updateFromProgram(StelLocation))); - - ui->citySearchLineEdit->setFocus(); -} - -// Update the widget to make sure it is synchrone if the location is changed programmatically -void LocationDialog::updateFromProgram(const StelLocation& currentLocation) -{ - if (!dialog->isVisible()) - return; - - StelCore* stelCore = StelApp::getInstance().getCore(); - //const StelLocation& currentLocation = stelCore->getCurrentLocation(); - - // Hack to avoid the coord spinbox receiving the focus and triggering - // "new location" editing mode. - // Disable hack below because it change behaviour of spinboxes and added difficulties of changes for this spinboxes --AW - // ui->citySearchLineEdit->setFocus(); - - isEditingNew = false; - - // Check that the use as default check box needs to be updated - // Move to setFieldsFromLocation()? --BM? - const bool b = currentLocation.getID() == stelCore->getDefaultLocationID(); - updateDefaultLocationControls(b); - - const QString& key1 = currentLocation.getID(); - const QString& key2 = locationFromFields().getID(); - if (key1!=key2) - { - setFieldsFromLocation(currentLocation); - } -} - -void LocationDialog::disconnectEditSignals() -{ - disconnect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setPositionFromCoords())); - disconnect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setPositionFromCoords())); - disconnect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setPositionFromCoords(int))); - disconnect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(moveToAnotherPlanet(const QString&))); - disconnect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit())); - // Why an edit should be reported even if the country is not changed? --BM - //disconnect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&))); - disconnect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), - this, SLOT(reportEdit())); -} - -void LocationDialog::connectEditSignals() -{ - connect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setPositionFromCoords())); - connect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setPositionFromCoords())); - connect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setPositionFromCoords(int))); - connect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(moveToAnotherPlanet(const QString&))); - connect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit())); - // Why an edit should be reported even if the country is not changed? --BM - //connect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&))); - connect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), - this, SLOT(reportEdit())); -} - -void LocationDialog::setFieldsFromLocation(const StelLocation& loc) -{ - // Deactivate edit signals - disconnectEditSignals(); - - ui->cityNameLineEdit->setText(loc.name); - int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive); - if (idx==-1) - { - // Use France as default - ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive); - } - ui->countryNameComboBox->setCurrentIndex(idx); - - ui->longitudeSpinBox->setDegrees(loc.longitude); - ui->latitudeSpinBox->setDegrees(loc.latitude); - ui->altitudeSpinBox->setValue(loc.altitude); - - idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); - if (idx==-1) - { - // Use Earth as default - idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive); - } - ui->planetNameComboBox->setCurrentIndex(idx); - setMapForLocation(loc); - - // Set pointer position - ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); - - ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID())); - - QSettings* conf = StelApp::getInstance().getSettings(); - bool atmosphere = conf->value("landscape/flag_atmosphere", true).toBool(); - bool fog = conf->value("landscape/flag_fog", true).toBool(); - SolarSystem* ssm = GETSTELMODULE(SolarSystem); - PlanetP p = ssm->searchByEnglishName(loc.planetName); - LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr); - ls->setFlagAtmosphere(p->hasAtmosphere() & atmosphere); - ls->setFlagFog(p->hasAtmosphere() & fog); - - // Reactivate edit signals - connectEditSignals(); -} - -// Update the map for the given location. -void LocationDialog::setMapForLocation(const StelLocation& loc) -{ - // Avoids usless processing - if (lastPlanet==loc.planetName) - return; - - QPixmap pixmap; - // Try to set the proper planet map image - if (loc.planetName=="Earth") - { - // Special case for earth, we don't want to see the clouds - pixmap = QPixmap(":/graphicGui/world.png"); - } - else - { - SolarSystem* ssm = GETSTELMODULE(SolarSystem); - PlanetP p = ssm->searchByEnglishName(loc.planetName); - if (p) - { - QString path = StelFileMgr::findFile("textures/"+p->getTextMapName()); - if (path.isEmpty()) - { - qWarning() << "ERROR - could not find planet map for " << loc.planetName; - return; - } - pixmap = QPixmap(path); - } - } - ui->mapLabel->setPixmap(pixmap); - // For caching - lastPlanet = loc.planetName; -} - -void LocationDialog::populatePlanetList() -{ - Q_ASSERT(ui->planetNameComboBox); - - QComboBox* planets = ui->planetNameComboBox; - SolarSystem* ssystem = GETSTELMODULE(SolarSystem); - QStringList planetNames(ssystem->getAllPlanetEnglishNames()); - - //Save the current selection to be restored later - planets->blockSignals(true); - int index = planets->currentIndex(); - QVariant selectedPlanetId = planets->itemData(index); - planets->clear(); - //For each planet, display the localized name and store the original as user - //data. Unfortunately, there's no other way to do this than with a cycle. - foreach(const QString& name, planetNames) - { - planets->addItem(q_(name), name); - } - //Restore the selection - index = planets->findData(selectedPlanetId, Qt::UserRole, Qt::MatchCaseSensitive); - planets->setCurrentIndex(index); - planets->model()->sort(0); - planets->blockSignals(false); -} - -void LocationDialog::populateCountryList() -{ - Q_ASSERT(ui->countryNameComboBox); - - QComboBox* countries = ui->countryNameComboBox; - QStringList countryNames(StelLocaleMgr::getAllCountryNames()); - - //Save the current selection to be restored later - countries->blockSignals(true); - int index = countries->currentIndex(); - QVariant selectedCountryId = countries->itemData(index); - countries->clear(); - //For each country, display the localized name and store the original as user - //data. Unfortunately, there's no other way to do this than with a cycle. - foreach(const QString& name, countryNames) - { - countries->addItem(q_(name), name); - } - //Restore the selection - index = countries->findData(selectedCountryId, Qt::UserRole, Qt::MatchCaseSensitive); - countries->setCurrentIndex(index); - countries->model()->sort(0); - countries->blockSignals(false); - -} - -// Create a StelLocation instance from the fields -StelLocation LocationDialog::locationFromFields() const -{ - StelLocation loc; - int index = ui->planetNameComboBox->currentIndex(); - if (index < 0) - loc.planetName = QString();//As returned by QComboBox::currentText() - else - loc.planetName = ui->planetNameComboBox->itemData(index).toString(); - loc.name = ui->cityNameLineEdit->text(); - loc.latitude = ui->latitudeSpinBox->valueDegrees(); - loc.longitude = ui->longitudeSpinBox->valueDegrees(); - loc.altitude = ui->altitudeSpinBox->value(); - index = ui->countryNameComboBox->currentIndex(); - if (index < 0) - loc.country = QString();//As returned by QComboBox::currentText() - else - loc.country = ui->countryNameComboBox->itemData(index).toString(); - - return loc; -} - -void LocationDialog::setPositionFromList(const QModelIndex& index) -{ - isEditingNew=false; - ui->addLocationToListPushButton->setEnabled(false); - StelLocation loc = StelApp::getInstance().getLocationMgr().locationForString(index.data().toString()); - setFieldsFromLocation(loc); - StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); - // This calls indirectly updateFromProgram() -} - -void LocationDialog::setPositionFromMap(double longitude, double latitude) -{ - reportEdit(); - StelLocation loc = locationFromFields(); - loc.latitude = latitude; - loc.longitude = longitude; - setFieldsFromLocation(loc); - StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); -} - -// Called when the planet name is changed by hand -void LocationDialog::moveToAnotherPlanet(const QString&) -{ - reportEdit(); - StelLocation loc = locationFromFields(); - StelCore* stelCore = StelApp::getInstance().getCore(); - LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr); - if (loc.planetName != stelCore->getCurrentLocation().planetName) - { - setFieldsFromLocation(loc); - if (ls->getFlagLandscapeAutoSelection()) - { - // If we have a landscape for selected planet then set it, otherwise use default landscape - // Details: https://bugs.launchpad.net/stellarium/+bug/1173254 - if (ls->getAllLandscapeNames().indexOf(loc.planetName)>0) - ls->setCurrentLandscapeName(loc.planetName); - else - ls->setCurrentLandscapeID(ls->getDefaultLandscapeID()); - } - - } - // Planet transition time also set to null to prevent uglyness when - // "use landscape location" is enabled for that planet's landscape. --BM - // NOTE: I think it also makes sense in the other cases. --BM - // FIXME: Avoid the unnecessary change of the location anyway. --BM - stelCore->moveObserverTo(loc, 0., 0.); -} - -void LocationDialog::setPositionFromCoords(int ) -{ - reportEdit(); - StelLocation loc = locationFromFields(); - StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); - //Update the position of the map pointer - ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); -} - -void LocationDialog::reportEdit() -{ - if (isEditingNew==false) - { - // The user starts editing manually a field, this creates automatically a new location - // and allows to save it to the user locations list - isEditingNew=true; - } - - StelLocation loc = locationFromFields(); - StelLocationMgr& locationMgr = StelApp::getInstance().getLocationMgr(); - bool canSave = locationMgr.canSaveUserLocation(loc); - if (!canSave) - { - if (ui->cityNameLineEdit->hasFocus()) - { - // The user is editing the location name: don't change it! - ui->addLocationToListPushButton->setEnabled(false); - ui->deleteLocationFromListPushButton->setEnabled(false); - return; - } - else - { - ui->cityNameLineEdit->setText(""); - ui->cityNameLineEdit->selectAll(); - loc = locationFromFields(); - } - } - ui->addLocationToListPushButton->setEnabled(isEditingNew && canSave); - ui->deleteLocationFromListPushButton->setEnabled(locationMgr.canDeleteUserLocation(loc.getID())); -} - -// Called when the user clic on the save button -void LocationDialog::addCurrentLocationToList() -{ - const StelLocation& loc = locationFromFields(); - ui->citySearchLineEdit->clear(); - StelApp::getInstance().getLocationMgr().saveUserLocation(loc); - isEditingNew=false; - ui->addLocationToListPushButton->setEnabled(false); - - const QAbstractItemModel* model = ui->citiesListView->model(); - const QString id = loc.getID(); - for (int i=0;irowCount();++i) - { - if (model->index(i,0).data()==id) - { - ui->citiesListView->scrollTo(model->index(i,0)); - ui->citiesListView->selectionModel()->select(model->index(i,0), QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows); - setPositionFromList(model->index(i,0)); - disconnectEditSignals(); - ui->citySearchLineEdit->setFocus(); - connectEditSignals(); - break; - } - } -} - -// Called when the user wants to use the current location as default -void LocationDialog::setDefaultLocation() -{ - StelCore* core = StelApp::getInstance().getCore(); - QString currentLocationId = core->getCurrentLocation().getID(); - core->setDefaultLocationID(currentLocationId); - - // Why this code even exists? After the previous code, this should always - // be true, except if setting the default location somehow fails. --BM - bool isDefault = (currentLocationId == core->getDefaultLocationID()); - disconnectEditSignals(); - updateDefaultLocationControls(isDefault); - //The focus need to be switched to another control, otherwise - //ui->latitudeSpinBox receives it and emits a valueChanged() signal when - //the window is closed. - ui->citySearchLineEdit->setFocus(); - connectEditSignals(); -} - -// Called when the user clicks on the delete button -void LocationDialog::deleteCurrentLocationFromList() -{ - const StelLocation& loc = locationFromFields(); - StelApp::getInstance().getLocationMgr().deleteUserLocation(loc.getID()); -} - -void LocationDialog::updateDefaultLocationControls(bool currentIsDefault) -{ - ui->useAsDefaultLocationCheckBox->setChecked(currentIsDefault); - ui->useAsDefaultLocationCheckBox->setEnabled(!currentIsDefault); - ui->pushButtonReturnToDefault->setEnabled(!currentIsDefault); -} diff --git a/src/gui/LocationDialog.hpp b/src/gui/LocationDialog.hpp deleted file mode 100644 index e85620a..0000000 --- a/src/gui/LocationDialog.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _LOCATIONDIALOG_HPP_ -#define _LOCATIONDIALOG_HPP_ - -#include -#include "StelDialog.hpp" - -class Ui_locationDialogForm; -class QModelIndex; -class StelLocation; - -class LocationDialog : public StelDialog -{ - Q_OBJECT -public: - LocationDialog(QObject* parent); - virtual ~LocationDialog(); - //! Notify that the application style changed - void styleChanged(); - -public slots: - void retranslate(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - Ui_locationDialogForm* ui; - -private: - //! Set the values of all the fields from a location info - //! Also move the observer to this position - void setFieldsFromLocation(const StelLocation& loc); - - //! Create a StelLocation instance from the fields - StelLocation locationFromFields() const; - - //! True if the user is currently editing a new location - bool isEditingNew; - - void disconnectEditSignals(); - void connectEditSignals(); - - //! Update the map for the given location. - void setMapForLocation(const StelLocation& loc); - - //! Populates the drop-down list of planets. - //! The displayed names are localized in the current interface language. - //! The original names are kept in the user data field of each QComboBox - //! item. - void populatePlanetList(); - - //! Populates the drop-down list of countries. - //! The displayed names are localized in the current interface language. - //! The original names are kept in the user data field of each QComboBox - //! item. - void populateCountryList(); - -private slots: - //! To be called when user edits any field - void reportEdit(); - - //! Update the widget to make sure it is synchrone if the location is changed programmatically - //! This function should be called repeatidly with e.g. a timer - void updateFromProgram(const StelLocation& location); - - //! Called when the map is clicked. - void setPositionFromMap(double longitude, double latitude); - - //! Called when the user activates an item from the locations list. - void setPositionFromList(const QModelIndex& index); - - //! Called when the planet is manually changed. - void moveToAnotherPlanet(const QString& text); - //! Called when latitude/longitude/altitude is modified - void setPositionFromCoords(int i=0); - - //! Called when the user clicks on the add to list button - void addCurrentLocationToList(); - - //! Called when the user clicks on the delete button - void deleteCurrentLocationFromList(); - - //! Called when the user wants to use the current location as default - void setDefaultLocation(); - -private: - QString lastPlanet; - //! Updates the check state and the enabled/disabled status. - void updateDefaultLocationControls(bool currentIsDefault); -}; - -#endif // _LOCATIONDIALOG_HPP_ diff --git a/src/gui/MapLabel.cpp b/src/gui/MapLabel.cpp deleted file mode 100644 index 98b361d..0000000 --- a/src/gui/MapLabel.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "MapLabel.hpp" -#include -#include - -MapLabel::MapLabel(QWidget *parent) : QLabel(parent) -{ - cursor = new QLabel(this); - cursor->setPixmap(QPixmap(":/graphicGui/map-pointeur.png")); - cursor->resize(cursor->pixmap()->size()); - cursor->show(); -} - -MapLabel::~MapLabel() -{ -} - -void MapLabel::setCursorPos(double longitude, double latitude) -{ - const int x = (int)((longitude+180.)/360.*size().width()); - const int y = (int)((latitude-90.)/-180.*size().height()); - cursor->move(x-cursor->size().width()/2, y-cursor->size().height()/2); -} - -void MapLabel::mousePressEvent(QMouseEvent* event) -{ - const double lon = ((double)event->pos().x())/size().width()*360.-180.; - const double lat = 90.-((double)event->pos().y())/size().height()*180.; - emit(positionChanged(lon, lat)); -} diff --git a/src/gui/MapLabel.hpp b/src/gui/MapLabel.hpp deleted file mode 100644 index 46804bd..0000000 --- a/src/gui/MapLabel.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - - -#ifndef _MAPLABEL_HPP_ -#define _MAPLABEL_HPP_ - -#include - -//! @class MapLabel -//! Special QLabel that shows a world map -class MapLabel : public QLabel -{ - Q_OBJECT - -public: - MapLabel(QWidget *parent = 0); - ~MapLabel(); - //! Set the current cursor position - //! @param longitude longitude in degree in range [-180;180[ - //! @param latitude latitude in degree in range [-90;90] - void setCursorPos(double longitude, double latitude); - -signals: - //! Signal emitted when we click on the map - void positionChanged(double longitude, double latitude); - -protected: - virtual void mousePressEvent(QMouseEvent * event); - -private: - QLabel* cursor; -}; - -#endif // _MAPLABEL_HPP_ diff --git a/src/gui/ScriptConsole.cpp b/src/gui/ScriptConsole.cpp deleted file mode 100644 index 4010db0..0000000 --- a/src/gui/ScriptConsole.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "ScriptConsole.hpp" -#include "ui_scriptConsole.h" -#include "StelMainView.hpp" -#include "StelScriptMgr.hpp" -#include "StelFileMgr.hpp" -#include "StelApp.hpp" -#include "StelTranslator.hpp" -#include "StelScriptSyntaxHighlighter.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -ScriptConsole::ScriptConsole() : highlighter(NULL) -{ - ui = new Ui_scriptConsoleForm; -} - -ScriptConsole::~ScriptConsole() -{ - delete ui; -} - -void ScriptConsole::retranslate() -{ - if (dialog) - ui->retranslateUi(dialog); -} - -void ScriptConsole::styleChanged() -{ - if (highlighter) - { - highlighter->setFormats(); - highlighter->rehighlight(); - } -} - -void ScriptConsole::createDialogContent() -{ - ui->setupUi(dialog); - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - - highlighter = new StelScriptSyntaxHighlighter(ui->scriptEdit->document()); - ui->includeEdit->setText(StelFileMgr::getInstallationDir() + "/scripts"); - - ui->quickrunCombo->addItem(q_("quickrun...")); - ui->quickrunCombo->addItem(q_("selected text")); - ui->quickrunCombo->addItem(q_("clear text")); - ui->quickrunCombo->addItem(q_("clear images")); - ui->quickrunCombo->addItem(q_("natural")); - ui->quickrunCombo->addItem(q_("starchart")); - - connect(ui->scriptEdit, SIGNAL(cursorPositionChanged()), this, SLOT(rowColumnChanged())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadScript())); - connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveScript())); - connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearButtonPressed())); - connect(ui->preprocessSSCButton, SIGNAL(clicked()), this, SLOT(preprocessScript())); - connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript())); - connect(ui->stopButton, SIGNAL(clicked()), &StelApp::getInstance().getScriptMgr(), SLOT(stopScript())); - connect(ui->includeBrowseButton, SIGNAL(clicked()), this, SLOT(includeBrowse())); - connect(ui->quickrunCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(quickRun(int))); - connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptStopped()), this, SLOT(scriptEnded())); - connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptDebug(const QString&)), this, SLOT(appendLogLine(const QString&))); -#ifndef ENABLE_STRATOSCRIPT_COMPAT - ui->preprocessSTSButton->setHidden(true); -#else - connect(ui->preprocessSTSButton, SIGNAL(clicked()), this, SLOT(preprocessScript())); -#endif - ui->tabs->setCurrentIndex(0); - ui->scriptEdit->setFocus(); -} - -void ScriptConsole::loadScript() -{ - QString fileName = QFileDialog::getOpenFileName(&StelMainView::getInstance(), - tr("Load Script"), - StelFileMgr::getInstallationDir() + "/scripts", - tr("Script Files") + " " + getFileMask()); - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) - { - ui->scriptEdit->setPlainText(file.readAll()); - ui->includeEdit->setText(StelFileMgr::dirName(fileName)); - file.close(); - } - ui->tabs->setCurrentIndex(0); -} - -void ScriptConsole::saveScript() -{ - QString saveDir = StelFileMgr::findFile("scripts", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::Directory)); - if (saveDir.isEmpty()) - saveDir = StelFileMgr::getUserDir(); - - QString fileName = QFileDialog::getSaveFileName(&StelMainView::getInstance(), - tr("Save Script"), - saveDir, - tr("Script Files") + " " + getFileMask()); - QFile file(fileName); - if (file.open(QIODevice::WriteOnly)) - { - QTextStream out(&file); - out << ui->scriptEdit->toPlainText(); - file.close(); - } - else - qWarning() << "ERROR - cannot write script file"; -} - -void ScriptConsole::clearButtonPressed() -{ - if (ui->tabs->currentIndex() == 0) - ui->scriptEdit->clear(); - else if (ui->tabs->currentIndex() == 1) - ui->outputBrowser->clear(); -} - -void ScriptConsole::preprocessScript() -{ - qDebug() << "ScriptConsole::preprocessScript"; - QTemporaryFile src(QDir::tempPath() + "/stelscriptXXXXXX"); - QString dest; - QString srcName; - if (src.open()) - { - QTextStream out(&src); - out << ui->scriptEdit->toPlainText(); - srcName = src.fileName(); - src.close(); - src.open(); - - if (sender() == ui->preprocessSSCButton) - { - qDebug() << "Preprocessing with SSC proprocessor"; - StelApp::getInstance().getScriptMgr().preprocessScript(src, dest, ui->includeEdit->text()); - } -#ifdef ENABLE_STRATOSCRIPT_COMPAT - else if (sender() == ui->preprocessSTSButton) - { - qDebug() << "Preprocessing with STS proprocessor"; - StelApp::getInstance().getScriptMgr().preprocessStratoScript(src, dest, ui->includeEdit->text()); - } -#endif - else - qWarning() << "WARNING: unknown preprocessor type"; - - ui->scriptEdit->setPlainText(dest); - } - ui->tabs->setCurrentIndex(0); -} - -void ScriptConsole::runScript() -{ - ui->tabs->setCurrentIndex(1); - ui->outputBrowser->setHtml(""); - QTemporaryFile file(QDir::tempPath() + "/stelscriptXXXXXX.ssc"); - QString fileName; - if (file.open()) { - QTextStream out(&file); - out << ui->scriptEdit->toPlainText() << "\n"; - fileName = file.fileName(); - file.close(); - } - else - { - QString msg = "ERROR - cannot open tmp file for writing script text"; - qWarning() << "ScriptConsole::runScript " + msg; - appendLogLine(msg); - return; - } - - ui->runButton->setEnabled(false); - ui->stopButton->setEnabled(true); - - appendLogLine(QString("Starting script at %1").arg(QDateTime::currentDateTime().toString())); - if (!StelApp::getInstance().getScriptMgr().runScript(fileName, ui->includeEdit->text())) - { - QString msg = QString("ERROR - cannot run script from temp file: \"%1\"").arg(fileName); - qWarning() << "ScriptConsole::runScript " + msg; - appendLogLine(msg); - if (file.open()) - { - int n=0; - while(!file.atEnd()) - { - appendLogLine(QString("%1:%2").arg(n,2).arg(QString(file.readLine()))); - } - file.close(); - } - return; - } -} - -void ScriptConsole::scriptEnded() -{ - qDebug() << "ScriptConsole::scriptEnded"; - QString html = ui->outputBrowser->toHtml(); - appendLogLine(QString("Script finished at %1").arg(QDateTime::currentDateTime().toString())); - ui->runButton->setEnabled(true); - ui->stopButton->setEnabled(false); -} - -void ScriptConsole::appendLogLine(const QString& s) -{ - QString html = ui->outputBrowser->toHtml(); - html.replace(QRegExp("^\\s+"), ""); - // if (html!="") - // html += "
"; - - html += s; - ui->outputBrowser->setHtml(html); -} - -void ScriptConsole::includeBrowse() -{ - ui->includeEdit->setText(QFileDialog::getExistingDirectory(&StelMainView::getInstance(), - tr("Select Script Includ Directory"), - StelFileMgr::getInstallationDir() + "/scripts")); -} - -void ScriptConsole::quickRun(int idx) -{ - ui->quickrunCombo->setCurrentIndex(0); - QString scriptText; - if (idx==1) - { - scriptText = QTextDocumentFragment::fromHtml(ui->scriptEdit->textCursor().selectedText(), ui->scriptEdit->document()).toPlainText(); - qDebug() << "selected script text is:" << scriptText; - } - if (idx==2) - { - scriptText = "LabelMgr.deleteAllLabels();\n"; - } - if (idx==3) - { - scriptText = "ScreenImageMgr.deleteAllImages()\n"; - } - if (idx==4) - { - scriptText = "core.clear(\"natural\");\n"; - } - if (idx==5) - { - scriptText = "core.clear(\"starchart\");\n"; - } - - if (scriptText.isEmpty()) - return; - - QTemporaryFile file(QDir::tempPath() + "/stelscriptXXXXXX.ssc"); - if (file.open()) - { - QString fileName = file.fileName(); - QTextStream out(&file); - out << scriptText; - file.close(); - appendLogLine(QString("Running: %1").arg(scriptText)); - StelApp::getInstance().getScriptMgr().runScript(fileName); - } - else - { - appendLogLine("Can't run quick script (could not open temp file)"); - } -} - -void ScriptConsole::rowColumnChanged() -{ - ui->rowColumnLabel->setText(QString("R:%1 C:%2").arg(ui->scriptEdit->textCursor().blockNumber()) - .arg(ui->scriptEdit->textCursor().columnNumber())); -} - -QString ScriptConsole::getFileMask() -{ -#ifdef ENABLE_STRATOSCRIPT_COMPAT - return "(*.ssc *.sts *.inc)"; -#else - return "(*.ssc *.inc)"; -#endif -} diff --git a/src/gui/ScriptConsole.hpp b/src/gui/ScriptConsole.hpp deleted file mode 100644 index 014f960..0000000 --- a/src/gui/ScriptConsole.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _SCRIPTCONSOLE_HPP_ -#define _SCRIPTCONSOLE_HPP_ - -#include -#include "StelDialog.hpp" - -class Ui_scriptConsoleForm; -class StelScriptSyntaxHighlighter; - -class ScriptConsole : public StelDialog -{ - Q_OBJECT -public: - ScriptConsole(); - virtual ~ScriptConsole(); - //! Notify that the application style changed - void styleChanged(); - -public slots: - void retranslate(); - void runScript(); - void loadScript(); - void saveScript(); - void clearButtonPressed(); - void preprocessScript(); - void scriptEnded(); - void appendLogLine(const QString& s); - void includeBrowse(); - void quickRun(int idx); - void rowColumnChanged(); - -protected: - Ui_scriptConsoleForm* ui; - - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - -private: - QString getFileMask(); - StelScriptSyntaxHighlighter* highlighter; - -}; - -#endif // _SCRIPTCONSOLE_HPP_ diff --git a/src/gui/SearchDialog.cpp b/src/gui/SearchDialog.cpp deleted file mode 100644 index 7474319..0000000 --- a/src/gui/SearchDialog.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#include "Dialog.hpp" -#include "SearchDialog.hpp" -#include "ui_searchDialogGui.h" -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelModuleMgr.hpp" -#include "StelMovementMgr.hpp" -#include "StelLocaleMgr.hpp" -#include "StelTranslator.hpp" - -#include "StelObjectMgr.hpp" -#include "StelUtils.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SimbadSearcher.hpp" - -// Start of members for class CompletionLabel -CompletionLabel::CompletionLabel(QWidget* parent) : QLabel(parent), selectedIdx(0) -{ -} - -CompletionLabel::~CompletionLabel() -{ -} - -void CompletionLabel::setValues(const QStringList& v) -{ - values=v; - updateText(); -} - -void CompletionLabel::appendValues(const QStringList& v) -{ - values+=v; - updateText(); -} - -void CompletionLabel::clearValues() -{ - values.clear(); - selectedIdx=0; - updateText(); -} - -QString CompletionLabel::getSelected() -{ - if (values.isEmpty()) - return QString(); - return values.at(selectedIdx); -} - -void CompletionLabel::selectNext() -{ - ++selectedIdx; - if (selectedIdx>=values.size()) - selectedIdx=0; - updateText(); -} - -void CompletionLabel::selectPrevious() -{ - --selectedIdx; - if (selectedIdx<0) - selectedIdx = values.size()-1; - updateText(); -} - -void CompletionLabel::selectFirst() -{ - selectedIdx=0; - updateText(); -} - -void CompletionLabel::updateText() -{ - QString newText; - - // Regenerate the list with the selected item in bold - for (int i=0;i"; - else - newText+=values[i]; - if (i!=values.size()-1) - newText += ", "; - } - setText(newText); -} - -// Start of members for class SearchDialog - -const char* SearchDialog::DEF_SIMBAD_URL = "http://simbad.u-strasbg.fr/"; - -SearchDialog::SearchDialog(QObject* parent) : StelDialog(parent), simbadReply(NULL) -{ - ui = new Ui_searchDialogForm; - simbadSearcher = new SimbadSearcher(this); - objectMgr = GETSTELMODULE(StelObjectMgr); - Q_ASSERT(objectMgr); - - flagHasSelectedText = false; - - greekLetters.insert("alpha", QString(QChar(0x03B1))); - greekLetters.insert("beta", QString(QChar(0x03B2))); - greekLetters.insert("gamma", QString(QChar(0x03B3))); - greekLetters.insert("delta", QString(QChar(0x03B4))); - greekLetters.insert("epsilon", QString(QChar(0x03B5))); - - greekLetters.insert("zeta", QString(QChar(0x03B6))); - greekLetters.insert("eta", QString(QChar(0x03B7))); - greekLetters.insert("theta", QString(QChar(0x03B8))); - greekLetters.insert("iota", QString(QChar(0x03B9))); - greekLetters.insert("kappa", QString(QChar(0x03BA))); - - greekLetters.insert("lambda", QString(QChar(0x03BB))); - greekLetters.insert("mu", QString(QChar(0x03BC))); - greekLetters.insert("nu", QString(QChar(0x03BD))); - greekLetters.insert("xi", QString(QChar(0x03BE))); - greekLetters.insert("omicron", QString(QChar(0x03BF))); - - greekLetters.insert("pi", QString(QChar(0x03C0))); - greekLetters.insert("rho", QString(QChar(0x03C1))); - greekLetters.insert("sigma", QString(QChar(0x03C3))); // second lower-case sigma shouldn't affect anything - greekLetters.insert("tau", QString(QChar(0x03C4))); - greekLetters.insert("upsilon", QString(QChar(0x03C5))); - - greekLetters.insert("phi", QString(QChar(0x03C6))); - greekLetters.insert("chi", QString(QChar(0x03C7))); - greekLetters.insert("psi", QString(QChar(0x03C8))); - greekLetters.insert("omega", QString(QChar(0x03C9))); - - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - useSimbad = conf->value("search/flag_search_online", true).toBool(); - useStartOfWords = conf->value("search/flag_start_words", false).toBool(); - simbadServerUrl = conf->value("search/simbad_server_url", DEF_SIMBAD_URL).toString(); -} - -SearchDialog::~SearchDialog() -{ - delete ui; - if (simbadReply) - { - simbadReply->deleteLater(); - simbadReply = NULL; - } -} - -void SearchDialog::retranslate() -{ - if (dialog) - { - QString text(ui->lineEditSearchSkyObject->text()); - ui->retranslateUi(dialog); - ui->lineEditSearchSkyObject->setText(text); - populateSimbadServerList(); - updateListTab(); - } -} - -void SearchDialog::styleChanged() -{ - // Nothing for now -} - -// Initialize the dialog widgets and connect the signals/slots -void SearchDialog::createDialogContent() -{ - ui->setupUi(dialog); - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - connect(ui->lineEditSearchSkyObject, SIGNAL(textChanged(const QString&)), - this, SLOT(onSearchTextChanged(const QString&))); - connect(ui->pushButtonGotoSearchSkyObject, SIGNAL(clicked()), this, SLOT(gotoObject())); - onSearchTextChanged(ui->lineEditSearchSkyObject->text()); - connect(ui->lineEditSearchSkyObject, SIGNAL(returnPressed()), this, SLOT(gotoObject())); - connect(ui->lineEditSearchSkyObject, SIGNAL(selectionChanged()), this, SLOT(setHasSelectedFlag())); - - ui->lineEditSearchSkyObject->installEventFilter(this); - ui->RAAngleSpinBox->setDisplayFormat(AngleSpinBox::HMSLetters); - ui->DEAngleSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); - ui->DEAngleSpinBox->setPrefixType(AngleSpinBox::NormalPlus); - - connect(ui->RAAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manualPositionChanged())); - connect(ui->DEAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manualPositionChanged())); - - connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->kappaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->lambdaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->muPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->nuPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->xiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->omicronPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->piPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->rhoPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->sigmaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); - - connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)), this, SLOT(enableSimbadSearch(bool))); - ui->checkBoxUseSimbad->setChecked(useSimbad); - - populateSimbadServerList(); - int idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::UserRole, Qt::MatchCaseSensitive); - if (idx==-1) - { - // Use University of Strasbourg as default - idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_URL), Qt::UserRole, Qt::MatchCaseSensitive); - } - ui->serverListComboBox->setCurrentIndex(idx); - connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectSimbadServer(int))); - - connect(ui->checkBoxUseStartOfWords, SIGNAL(clicked(bool)), this, SLOT(enableStartOfWordsAutofill(bool))); - ui->checkBoxUseStartOfWords->setChecked(useStartOfWords); - - // list views initialization - connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(updateListWidget(int))); - connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchListChanged(QString))); - connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateListTab())); - updateListTab(); - - // Set the focus directly on the line edit - if (ui->lineEditSearchSkyObject->isEnabled()) - ui->lineEditSearchSkyObject->setFocus(); -} - -void SearchDialog::setHasSelectedFlag() -{ - flagHasSelectedText = true; -} - -void SearchDialog::enableSimbadSearch(bool enable) -{ - useSimbad = enable; - - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - conf->setValue("search/flag_search_online", useSimbad); -} - -void SearchDialog::enableStartOfWordsAutofill(bool enable) -{ - useStartOfWords = enable; - - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - conf->setValue("search/flag_start_words", useStartOfWords); -} - -void SearchDialog::setSimpleStyle() -{ - ui->RAAngleSpinBox->setVisible(false); - ui->DEAngleSpinBox->setVisible(false); - ui->simbadStatusLabel->setVisible(false); - ui->raDecLabel->setVisible(false); -} - - -void SearchDialog::manualPositionChanged() -{ - ui->completionLabel->clearValues(); - StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); - Vec3d pos; - StelUtils::spheToRect(ui->RAAngleSpinBox->valueRadians(), ui->DEAngleSpinBox->valueRadians(), pos); - mvmgr->setFlagTracking(false); - mvmgr->moveToJ2000(pos, 0.05); -} - -void SearchDialog::onSearchTextChanged(const QString& text) -{ - // This block needs to go before the trimmedText.isEmpty() or the SIMBAD result does not - // get properly cleared. - if (useSimbad) { - if (simbadReply) { - disconnect(simbadReply, - SIGNAL(statusChanged()), - this, - SLOT(onSimbadStatusChanged())); - delete simbadReply; - simbadReply=NULL; - } - simbadResults.clear(); - } - - QString trimmedText = text.trimmed().toLower(); - if (trimmedText.isEmpty()) { - ui->completionLabel->clearValues(); - ui->completionLabel->selectFirst(); - ui->simbadStatusLabel->setText(""); - ui->pushButtonGotoSearchSkyObject->setEnabled(false); - } else { - if (useSimbad) - { - simbadReply = simbadSearcher->lookup(simbadServerUrl, trimmedText, 3); - onSimbadStatusChanged(); - connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onSimbadStatusChanged())); - } - - QString greekText = substituteGreek(trimmedText); - QStringList matches; - if(greekText != trimmedText) { - matches = objectMgr->listMatchingObjectsI18n(trimmedText, 3, useStartOfWords); - matches += objectMgr->listMatchingObjects(trimmedText, 3, useStartOfWords); - matches += objectMgr->listMatchingObjectsI18n(greekText, (8 - matches.size()), useStartOfWords); - } else { - matches = objectMgr->listMatchingObjectsI18n(trimmedText, 5, useStartOfWords); - matches += objectMgr->listMatchingObjects(trimmedText, 5, useStartOfWords); - } - - // remove possible duplicates from completion list - matches.removeDuplicates(); - - ui->completionLabel->setValues(matches); - ui->completionLabel->selectFirst(); - - // Update push button enabled state - ui->pushButtonGotoSearchSkyObject->setEnabled(true); - } -} - -// Called when the current simbad query status changes -void SearchDialog::onSimbadStatusChanged() -{ - Q_ASSERT(simbadReply); - if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookupErrorOccured) - { - ui->simbadStatusLabel->setText(QString("%1: %2") - .arg(q_("Simbad Lookup Error")) - .arg(simbadReply->getErrorString())); - if (ui->completionLabel->isEmpty()) - ui->pushButtonGotoSearchSkyObject->setEnabled(false); - } - else - { - ui->simbadStatusLabel->setText(QString("%1: %2") - .arg(q_("Simbad Lookup")) - .arg(simbadReply->getCurrentStatusString())); - // Query not over, don't disable button - ui->pushButtonGotoSearchSkyObject->setEnabled(true); - } - - if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookupFinished) - { - simbadResults = simbadReply->getResults(); - ui->completionLabel->appendValues(simbadResults.keys()); - // Update push button enabled state - ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completionLabel->isEmpty()); - } - - if (simbadReply->getCurrentStatus()!=SimbadLookupReply::SimbadLookupQuerying) - { - disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onSimbadStatusChanged())); - delete simbadReply; - simbadReply=NULL; - - // Update push button enabled state - ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completionLabel->isEmpty()); - } -} - -void SearchDialog::greekLetterClicked() -{ - QPushButton *sender = reinterpret_cast(this->sender()); - QLineEdit* sso = ui->lineEditSearchSkyObject; - if (sender) { - if (flagHasSelectedText) - { - sso->setText(sender->text()); - flagHasSelectedText = false; - } - else - sso->setText(sso->text() + sender->text()); - } - sso->setFocus(); -} - -void SearchDialog::gotoObject() -{ - QString name = ui->completionLabel->getSelected(); - gotoObject(name); -} - -void SearchDialog::gotoObject(const QString &nameI18n) -{ - if (nameI18n.isEmpty()) - return; - - StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); - if (simbadResults.contains(nameI18n)) - { - close(); - Vec3d pos = simbadResults[nameI18n]; - objectMgr->unSelect(); - mvmgr->moveToJ2000(pos, mvmgr->getAutoMoveDuration()); - ui->lineEditSearchSkyObject->clear(); - ui->completionLabel->clearValues(); - } - else if (objectMgr->findAndSelectI18n(nameI18n) || objectMgr->findAndSelect(nameI18n)) - { - const QList newSelected = objectMgr->getSelectedObject(); - if (!newSelected.empty()) - { - close(); - ui->lineEditSearchSkyObject->clear(); - ui->completionLabel->clearValues(); - // Can't point to home planet - if (newSelected[0]->getEnglishName()!=StelApp::getInstance().getCore()->getCurrentLocation().planetName) - { - mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMoveDuration()); - mvmgr->setFlagTracking(true); - } - else - { - GETSTELMODULE(StelObjectMgr)->unSelect(); - } - } - } - simbadResults.clear(); -} - -void SearchDialog::gotoObject(QListWidgetItem *item) -{ - QString objName = item->text(); - gotoObject(objName); -} - -void SearchDialog::searchListChanged(const QString &newText) -{ - QList items = ui->objectsListWidget->findItems(newText, Qt::MatchStartsWith); - ui->objectsListWidget->clearSelection(); - if (!items.isEmpty()) - { - items.at(0)->setSelected(true); - ui->objectsListWidget->scrollToItem(items.at(0)); - } -} - -bool SearchDialog::eventFilter(QObject*, QEvent *event) -{ - if (event->type() == QEvent::KeyRelease) - { - QKeyEvent *keyEvent = static_cast(event); - - if (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt::Key_Down) - { - ui->completionLabel->selectNext(); - event->accept(); - return true; - } - if (keyEvent->key() == Qt::Key_Up) - { - ui->completionLabel->selectPrevious(); - event->accept(); - return true; - } - } - - return false; -} - -QString SearchDialog::substituteGreek(const QString& keyString) -{ - if (!keyString.contains(' ')) - return getGreekLetterByName(keyString); - else - { - QStringList nameComponents = keyString.split(" ", QString::SkipEmptyParts); - if(!nameComponents.empty()) - nameComponents[0] = getGreekLetterByName(nameComponents[0]); - return nameComponents.join(" "); - } -} - -QString SearchDialog::getGreekLetterByName(const QString& potentialGreekLetterName) -{ - if(greekLetters.contains(potentialGreekLetterName)) - return greekLetters[potentialGreekLetterName.toLower()]; - - // There can be indices (e.g. "α1 Cen" instead of "α Cen A"), so strip - // any trailing digit. - int lastCharacterIndex = potentialGreekLetterName.length()-1; - if(potentialGreekLetterName.at(lastCharacterIndex).isDigit()) - { - QChar digit = potentialGreekLetterName.at(lastCharacterIndex); - QString name = potentialGreekLetterName.left(lastCharacterIndex); - if(greekLetters.contains(name)) - return greekLetters[name.toLower()] + digit; - } - - return potentialGreekLetterName; -} - -void SearchDialog::populateSimbadServerList() -{ - Q_ASSERT(ui->serverListComboBox); - - QComboBox* servers = ui->serverListComboBox; - //Save the current selection to be restored later - servers->blockSignals(true); - int index = servers->currentIndex(); - QVariant selectedUrl = servers->itemData(index); - servers->clear(); - //For each server, display the localized description and store the URL as user data. - servers->addItem(q_("University of Strasbourg (France)"), DEF_SIMBAD_URL); - servers->addItem(q_("Harvard University (USA)"), "http://simbad.harvard.edu/"); - - //Restore the selection - index = servers->findData(selectedUrl, Qt::UserRole, Qt::MatchCaseSensitive); - servers->setCurrentIndex(index); - servers->model()->sort(0); - servers->blockSignals(false); -} - -void SearchDialog::selectSimbadServer(int index) -{ - if (index < 0) - simbadServerUrl = DEF_SIMBAD_URL; - else - simbadServerUrl = ui->serverListComboBox->itemData(index).toString(); - - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - conf->setValue("search/simbad_server_url", simbadServerUrl); -} - -void SearchDialog::updateListWidget(int index) -{ - QString moduleId = ui->objectTypeComboBox->itemData(index).toString(); - ui->objectsListWidget->clear(); - bool englishNames = ui->searchInEnglishCheckBox->isChecked(); - ui->objectsListWidget->addItems(objectMgr->listAllModuleObjects(moduleId, englishNames)); - ui->objectsListWidget->sortItems(Qt::AscendingOrder); - connect(ui->objectsListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(gotoObject(QListWidgetItem*))); -} - -void SearchDialog::updateListTab() -{ - if (StelApp::getInstance().getLocaleMgr().getAppLanguage() == "en") - { - // hide "names in English" checkbox - ui->searchInEnglishCheckBox->hide(); - } - else - { - ui->searchInEnglishCheckBox->show(); - } - ui->objectTypeComboBox->clear(); - QMap modulesMap = objectMgr->objectModulesMap(); - for (QMap::const_iterator it = modulesMap.begin(); it != modulesMap.end(); ++it) - { - if (!objectMgr->listAllModuleObjects(it.key(), ui->searchInEnglishCheckBox->isChecked()).isEmpty()) - { - QString moduleName = (ui->searchInEnglishCheckBox->isChecked() ? it.value(): q_(it.value())); - ui->objectTypeComboBox->addItem(moduleName, QVariant(it.key())); - } - } - updateListWidget(ui->objectTypeComboBox->currentIndex()); -} diff --git a/src/gui/SearchDialog.hpp b/src/gui/SearchDialog.hpp deleted file mode 100644 index f19c09d..0000000 --- a/src/gui/SearchDialog.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Guillaume Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _SEARCHDIALOG_HPP_ -#define _SEARCHDIALOG_HPP_ - -#include -#include -#include -#include -#include "StelDialog.hpp" -#include "VecMath.hpp" - -// pre declaration of the ui class -class Ui_searchDialogForm; - -//! @class CompletionLabel -//! Display a list of results matching the search string, and allow to -//! tab through those selections. -class CompletionLabel : public QLabel -{ - Q_OBJECT - -public: - CompletionLabel(QWidget* parent=0); - ~CompletionLabel(); - - QString getSelected(void); - void setValues(const QStringList&); - bool isEmpty() const {return values.isEmpty();} - void appendValues(const QStringList&); - void clearValues(); - -public slots: - void selectNext(); - void selectPrevious(); - void selectFirst(); - -private: - void updateText(); - int selectedIdx; - QStringList values; -}; - -QT_FORWARD_DECLARE_CLASS(QListWidgetItem) - -//! @class SearchDialog -//! The sky object search dialog. -class SearchDialog : public StelDialog -{ - Q_OBJECT - -public: - SearchDialog(QObject* parent); - virtual ~SearchDialog(); - //! Notify that the application style changed - void styleChanged(); - bool eventFilter(QObject *object, QEvent *event); - -public slots: - void retranslate(); - //! This style only displays the text search field and the search button - void setSimpleStyle(); - -protected: - Ui_searchDialogForm* ui; - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); - -private slots: - void greekLetterClicked(); - //! Called when the current simbad query status changes - void onSimbadStatusChanged(); - //! Called when the user changed the input text - void onSearchTextChanged(const QString& text); - - void gotoObject(); - void gotoObject(const QString& nameI18n); - // for going from list views - void gotoObject(QListWidgetItem* item); - - void searchListChanged(const QString& newText); - - //! Called when the user edit the manual position controls - void manualPositionChanged(); - - //! Whether to use SIMBAD for searches or not. - void enableSimbadSearch(bool enable); - - //! Whether to use autofill for start of words or not. - void enableStartOfWordsAutofill(bool enable); - - //! Set flagHasSelectedText as true, if search box has selected text - void setHasSelectedFlag(); - - //! Called when a SIMBAD server is selected in the list. - void selectSimbadServer(int index); - - //! Called when new type of objects selected in list view tab - void updateListWidget(int index); - - // retranslate/recreate tab - void updateListTab(); - -private: - class SimbadSearcher* simbadSearcher; - class SimbadLookupReply* simbadReply; - QMap simbadResults; - class StelObjectMgr* objectMgr; - - QString substituteGreek(const QString& keyString); - QString getGreekLetterByName(const QString& potentialGreekLetterName); - QHash greekLetters; - //! Used when substituting text with a Greek letter. - bool flagHasSelectedText; - - bool useStartOfWords; - bool useSimbad; - //! URL of the server used for SIMBAD queries. - QString simbadServerUrl; - void populateSimbadServerList(); - //! URL of the default SIMBAD server (Strasbourg). - static const char* DEF_SIMBAD_URL; -}; - -#endif // _SEARCHDIALOG_HPP_ - diff --git a/src/gui/ShortcutLineEdit.cpp b/src/gui/ShortcutLineEdit.cpp deleted file mode 100644 index c5e0501..0000000 --- a/src/gui/ShortcutLineEdit.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2012 Anton Samoylov - * Copyright (C) 2012 Bogdan Marinov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include - -#include "ShortcutLineEdit.hpp" - -ShortcutLineEdit::ShortcutLineEdit(QWidget *parent) : - QLineEdit(parent) -{ - // call clear for setting up private fields - clear(); -} - -QKeySequence ShortcutLineEdit::getKeySequence() -{ - return QKeySequence(keys.value(0, 0), keys.value(1, 0), - keys.value(2, 0), keys.value(3, 0)); -} - -bool ShortcutLineEdit::isEmpty() const -{ - return (keys.isEmpty()); -} - -void ShortcutLineEdit::clear() -{ - keys.clear(); - QLineEdit::clear(); - emit contentsChanged(); -} - -void ShortcutLineEdit::backspace() -{ - if (keys.isEmpty()) - return; - keys.removeLast(); - setContents(getKeySequence()); -} - -void ShortcutLineEdit::setContents(QKeySequence ks) -{ - // Avoiding infinite loop of same signal-slot emitting/calling - if (ks.toString(QKeySequence::NativeText) == text()) - return; - - // Set the keys from the given key sequence - clear(); - for (int i = 0; i < ks.count(); ++i) - { - keys.append(ks[i]); - } - - // Show Ctrl button as Cmd on Mac - setText(ks.toString(QKeySequence::NativeText)); - emit contentsChanged(); -} - -void ShortcutLineEdit::keyPressEvent(QKeyEvent *e) -{ - int nextKey = e->key(); - if ( keys.count() > 3 || // too long shortcut - nextKey == Qt::Key_Control || // dont count modifier keys - nextKey == Qt::Key_Shift || - nextKey == Qt::Key_Meta || - nextKey == Qt::Key_Alt ) - return; - - // applying current modifiers to key - nextKey |= getModifiers(e->modifiers(), e->text()); - - // If there is selected text, replace *all* instead of appending. - if (hasSelectedText()) - { - keys.clear(); - } - keys.append(nextKey); - - // set displaying information - setText(getKeySequence().toString(QKeySequence::NativeText)); - emit contentsChanged(); - - // not call QLineEdit's event because we already changed contents - e->accept(); -} - -void ShortcutLineEdit::focusInEvent(QFocusEvent *e) -{ - // Select the contents so that they are replaced on the next edit - selectAll(); - emit focusChanged(false); - QLineEdit::focusInEvent(e); -} - -void ShortcutLineEdit::focusOutEvent(QFocusEvent *e) -{ - emit focusChanged(true); - QLineEdit::focusOutEvent(e); -} - - -int ShortcutLineEdit::getModifiers(Qt::KeyboardModifiers state, const QString &text) -{ - int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.size() == 0 - || !text.at(0).isPrint() - || text.at(0).isLetterOrNumber() - || text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) - result |= Qt::CTRL; - // META key is the same as WIN key on non-MACs - if (state & Qt::MetaModifier) - result |= Qt::META; - if (state & Qt::AltModifier) - result |= Qt::ALT; - return result; -} diff --git a/src/gui/ShortcutLineEdit.hpp b/src/gui/ShortcutLineEdit.hpp deleted file mode 100644 index b5439e5..0000000 --- a/src/gui/ShortcutLineEdit.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2012 Anton Samoylov - * Copyright (C) 2012 Bogdan Marinov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ -#ifndef SHORTCUTLINEEDIT_H -#define SHORTCUTLINEEDIT_H - -#include -#include - -//! Specialised GUI control for entering keyboard shortcut combinations. -//! Allows Emacs-style key sequences (for example "Ctrl+E, Ctrl+2") -//! no longer than four combinations. See the documentation of -//! QKeySequence for details. -//! -//! When ShortcutLineEdit receives the focus, its whole contents get -//! selected. On a key press, if any of the contents are selected, -//! the new key replaces @em all the previous contents. Otherwise, it's -//! appended to the sequence. -class ShortcutLineEdit : public QLineEdit -{ - Q_OBJECT - -public: - ShortcutLineEdit(QWidget* parent = 0); - - QKeySequence getKeySequence(); - bool isEmpty() const; - -public slots: - //! Clear contents and stored keys. - void clear(); - //! Remove the last key from the key sequence. - void backspace(); - //! Emits contentsChanged() if the new sequence is not the same. - void setContents(QKeySequence ks); - -signals: - //! Needed for enabling/disabling buttons in ShortcutsDialog. - //! @param[out] focus @b false if the widget has the focus, - //! true otherwise. - void focusChanged(bool focus); - void contentsChanged(); - -protected: - void keyPressEvent(QKeyEvent *e); - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); - -private: - //! transform modifiers to int. - static int getModifiers(Qt::KeyboardModifiers state, const QString &text); - - //! Codes of the keys in the manipulated key sequence. - QList keys; -}; - -#endif // SHORTCUTLINEEDIT_H diff --git a/src/gui/ShortcutsDialog.cpp b/src/gui/ShortcutsDialog.cpp deleted file mode 100644 index e4f5faf..0000000 --- a/src/gui/ShortcutsDialog.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2012 Anton Samoylov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include - -#include "StelApp.hpp" -#include "StelTranslator.hpp" -#include "StelActionMgr.hpp" -#include "ShortcutLineEdit.hpp" -#include "ShortcutsDialog.hpp" -#include "ui_shortcutsDialog.h" - - -ShortcutsFilterModel::ShortcutsFilterModel(QObject* parent) : - QSortFilterProxyModel(parent) -{ - // -} - -bool ShortcutsFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -{ - if (filterRegExp().isEmpty()) - return true; - - if (source_parent.isValid()) - { - QModelIndex index = source_parent.child(source_row, filterKeyColumn()); - QString data = sourceModel()->data(index, filterRole()).toString(); - return data.contains(filterRegExp()); - } - else - { - QModelIndex index = sourceModel()->index(source_row, filterKeyColumn()); - for (int row = 0; row < sourceModel()->rowCount(index); row++) - { - if (filterAcceptsRow(row, index)) - return true; - } - } - return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); -} - - -ShortcutsDialog::ShortcutsDialog(QObject* parent) : - StelDialog(parent), - ui(new Ui_shortcutsDialogForm), - filterModel(new ShortcutsFilterModel(this)), - mainModel(new QStandardItemModel(this)) -{ - actionMgr = StelApp::getInstance().getStelActionManager(); -} - -ShortcutsDialog::~ShortcutsDialog() -{ - collisionItems.clear(); - delete ui; - ui = NULL; -} - -void ShortcutsDialog::drawCollisions() -{ - QBrush brush(Qt::red); - foreach(QStandardItem* item, collisionItems) - { - // change colors of all columns for better visibility - item->setForeground(brush); - QModelIndex index = item->index(); - mainModel->itemFromIndex(index.sibling(index.row(), 1))->setForeground(brush); - mainModel->itemFromIndex(index.sibling(index.row(), 2))->setForeground(brush); - } -} - -void ShortcutsDialog::resetCollisions() -{ - QBrush brush = - ui->shortcutsTreeView->palette().brush(QPalette::Foreground); - foreach(QStandardItem* item, collisionItems) - { - item->setForeground(brush); - QModelIndex index = item->index(); - mainModel->itemFromIndex(index.sibling(index.row(), 1))->setForeground(brush); - mainModel->itemFromIndex(index.sibling(index.row(), 2))->setForeground(brush); - } - collisionItems.clear(); -} - -void ShortcutsDialog::retranslate() -{ - if (dialog) - { - ui->retranslateUi(dialog); - setModelHeader(); - updateTreeData(); - } -} - -void ShortcutsDialog::initEditors() -{ - QModelIndex index = filterModel->mapToSource(ui->shortcutsTreeView->currentIndex()); - index = index.sibling(index.row(), 0); - QStandardItem* currentItem = mainModel->itemFromIndex(index); - if (itemIsEditable(currentItem)) - { - // current item is shortcut, not group (group items aren't selectable) - ui->primaryShortcutEdit->setEnabled(true); - ui->altShortcutEdit->setEnabled(true); - // fill editors with item's shortcuts - QVariant data = mainModel->data(index.sibling(index.row(), 1)); - ui->primaryShortcutEdit->setContents(data.value()); - data = mainModel->data(index.sibling(index.row(), 2)); - ui->altShortcutEdit->setContents(data.value()); - } - else - { - // item is group, not shortcut - ui->primaryShortcutEdit->setEnabled(false); - ui->altShortcutEdit->setEnabled(false); - ui->applyButton->setEnabled(false); - ui->primaryShortcutEdit->clear(); - ui->altShortcutEdit->clear(); - } - polish(); -} - -bool ShortcutsDialog::prefixMatchKeySequence(const QKeySequence& ks1, - const QKeySequence& ks2) -{ - if (ks1.isEmpty() || ks2.isEmpty()) - { - return false; - } - for (int i = 0; i < qMin(ks1.count(), ks2.count()); ++i) - { - if (ks1[i] != ks2[i]) - { - return false; - } - } - return true; -} - -QList ShortcutsDialog::findCollidingItems(QKeySequence ks) -{ - QList result; - for (int row = 0; row < mainModel->rowCount(); row++) - { - QStandardItem* group = mainModel->item(row, 0); - if (!group->hasChildren()) - continue; - for (int subrow = 0; subrow < group->rowCount(); subrow++) - { - QKeySequence primary(group->child(subrow, 1) - ->data(Qt::DisplayRole).toString()); - QKeySequence secondary(group->child(subrow, 2) - ->data(Qt::DisplayRole).toString()); - if (prefixMatchKeySequence(ks, primary) || - prefixMatchKeySequence(ks, secondary)) - result.append(group->child(subrow, 0)); - } - } - return result; -} - -void ShortcutsDialog::handleCollisions(ShortcutLineEdit *currentEdit) -{ - resetCollisions(); - - // handle collisions - QString text = currentEdit->text(); - collisionItems = findCollidingItems(QKeySequence(text)); - QModelIndex index = - filterModel->mapToSource(ui->shortcutsTreeView->currentIndex()); - index = index.sibling(index.row(), 0); - QStandardItem* currentItem = mainModel->itemFromIndex(index); - collisionItems.removeOne(currentItem); - if (!collisionItems.isEmpty()) - { - drawCollisions(); - ui->applyButton->setEnabled(false); - // scrolling to first collision item - QModelIndex first = - filterModel->mapFromSource(collisionItems.first()->index()); - ui->shortcutsTreeView->scrollTo(first); - currentEdit->setProperty("collision", true); - } - else - { - // scrolling back to current item - QModelIndex current = filterModel->mapFromSource(index); - ui->shortcutsTreeView->scrollTo(current); - currentEdit->setProperty("collision", false); - } -} - -void ShortcutsDialog::handleChanges() -{ - // work only with changed editor - ShortcutLineEdit* editor = qobject_cast(sender()); - bool isPrimary = (editor == ui->primaryShortcutEdit); - // updating clear buttons - if (isPrimary) - { - ui->primaryBackspaceButton->setEnabled(!editor->isEmpty()); - } - else - { - ui->altBackspaceButton->setEnabled(!editor->isEmpty()); - } - // updating apply button - QModelIndex index = - filterModel->mapToSource(ui->shortcutsTreeView->currentIndex()); - if (!index.isValid() || - (isPrimary && - editor->text() == mainModel->data(index.sibling(index.row(), 1))) || - (!isPrimary && - editor->text() == mainModel->data(index.sibling(index.row(), 2)))) - { - // nothing to apply - ui->applyButton->setEnabled(false); - } - else - { - ui->applyButton->setEnabled(true); - } - handleCollisions(editor); - polish(); -} - -void ShortcutsDialog::applyChanges() -{ - // get ids stored in tree - QModelIndex index = - filterModel->mapToSource(ui->shortcutsTreeView->currentIndex()); - if (!index.isValid()) - return; - index = index.sibling(index.row(), 0); - QStandardItem* currentItem = mainModel->itemFromIndex(index); - QString actionId = currentItem->data(Qt::UserRole).toString(); - - StelAction* action = actionMgr->findAction(actionId); - action->setShortcut(ui->primaryShortcutEdit->getKeySequence().toString()); - action->setAltShortcut(ui->altShortcutEdit->getKeySequence().toString()); - updateShortcutsItem(action); - - // save shortcuts to file - actionMgr->saveShortcuts(); - - // nothing to apply until edits' content changes - ui->applyButton->setEnabled(false); -} - -void ShortcutsDialog::switchToEditors(const QModelIndex& index) -{ - QModelIndex mainIndex = filterModel->mapToSource(index); - QStandardItem* item = mainModel->itemFromIndex(mainIndex); - if (itemIsEditable(item)) - { - ui->primaryShortcutEdit->setFocus(); - } -} - -void ShortcutsDialog::createDialogContent() -{ - ui->setupUi(dialog); - - resetModel(); - filterModel->setSourceModel(mainModel); - filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - filterModel->setSortCaseSensitivity(Qt::CaseInsensitive); - filterModel->setDynamicSortFilter(true); - filterModel->setSortLocaleAware(true); - ui->shortcutsTreeView->setModel(filterModel); - ui->shortcutsTreeView->header()->setSectionsMovable(false); - ui->shortcutsTreeView->sortByColumn(0, Qt::AscendingOrder); - - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - connect(ui->shortcutsTreeView->selectionModel(), - SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, - SLOT(initEditors())); - connect(ui->shortcutsTreeView, - SIGNAL(activated(QModelIndex)), - this, - SLOT(switchToEditors(QModelIndex))); - connect(ui->lineEditSearch, SIGNAL(textChanged(QString)), - filterModel, SLOT(setFilterFixedString(QString))); - - // apply button logic - connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(applyChanges())); - // restore defaults button logic - connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaultShortcuts())); - // we need to disable all shortcut actions, so we can enter shortcuts without activating any actions - connect(ui->primaryShortcutEdit, SIGNAL(focusChanged(bool)), actionMgr, SLOT(setAllActionsEnabled(bool))); - connect(ui->altShortcutEdit, SIGNAL(focusChanged(bool)), actionMgr, SLOT(setAllActionsEnabled(bool))); - // handling changes in editors - connect(ui->primaryShortcutEdit, SIGNAL(contentsChanged()), this, SLOT(handleChanges())); - connect(ui->altShortcutEdit, SIGNAL(contentsChanged()), this, SLOT(handleChanges())); - - QString backspaceChar; - backspaceChar.append(QChar(0x232B)); // Erase left - //test.append(QChar(0x2672)); - //test.append(QChar(0x267B)); - //test.append(QChar(0x267C)); - //test.append(QChar(0x21BA)); // Counter-clockwise - //test.append(QChar(0x2221)); // Angle sign - ui->primaryBackspaceButton->setText(backspaceChar); - ui->altBackspaceButton->setText(backspaceChar); - - updateTreeData(); -} - -void ShortcutsDialog::updateText() -{ -} - -void ShortcutsDialog::polish() -{ - ui->primaryShortcutEdit->style()->unpolish(ui->primaryShortcutEdit); - ui->primaryShortcutEdit->style()->polish(ui->primaryShortcutEdit); - ui->altShortcutEdit->style()->unpolish(ui->altShortcutEdit); - ui->altShortcutEdit->style()->polish(ui->altShortcutEdit); -} - -QStandardItem* ShortcutsDialog::updateGroup(const QString& group) -{ - QStandardItem* groupItem = findItemByData(QVariant(group), - Qt::UserRole); - bool isNew = false; - if (!groupItem) - { - // create new - groupItem = new QStandardItem(); - isNew = true; - } - // group items aren't selectable, so reset default flag - groupItem->setFlags(Qt::ItemIsEnabled); - - // setup displayed text - groupItem->setText(q_(group)); - // store id - groupItem->setData(group, Qt::UserRole); - groupItem->setColumnCount(3); - // setup bold font for group lines - QFont rootFont = groupItem->font(); - rootFont.setBold(true); - rootFont.setPixelSize(14); - groupItem->setFont(rootFont); - if (isNew) - mainModel->appendRow(groupItem); - - - QModelIndex index = filterModel->mapFromSource(groupItem->index()); - ui->shortcutsTreeView->expand(index); - ui->shortcutsTreeView->setFirstColumnSpanned(index.row(), - QModelIndex(), - true); - ui->shortcutsTreeView->setRowHidden(index.row(), QModelIndex(), false); - - return groupItem; -} - -QStandardItem* ShortcutsDialog::findItemByData(QVariant value, int role, int column) -{ - for (int row = 0; row < mainModel->rowCount(); row++) - { - QStandardItem* item = mainModel->item(row, 0); - if (!item) - continue; //WTF? - if (column == 0) - { - if (item->data(role) == value) - return item; - } - - for (int subrow = 0; subrow < item->rowCount(); subrow++) - { - QStandardItem* subitem = item->child(subrow, column); - if (subitem->data(role) == value) - return subitem; - } - } - return 0; -} - -void ShortcutsDialog::updateShortcutsItem(StelAction *action, - QStandardItem *shortcutItem) -{ - QVariant shortcutId(action->getId()); - if (shortcutItem == NULL) - { - // search for item - shortcutItem = findItemByData(shortcutId, Qt::UserRole, 0); - } - // we didn't find item, create and add new - QStandardItem* groupItem = NULL; - if (shortcutItem == NULL) - { - // firstly search for group - QVariant groupId(action->getGroup()); - groupItem = findItemByData(groupId, Qt::UserRole, 0); - if (groupItem == NULL) - { - // create and add new group to treeWidget - groupItem = updateGroup(action->getGroup()); - } - // create shortcut item - shortcutItem = new QStandardItem(); - shortcutItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - groupItem->appendRow(shortcutItem); - // store shortcut id, so we can find it when shortcut changed - shortcutItem->setData(shortcutId, Qt::UserRole); - QStandardItem* primaryItem = new QStandardItem(); - QStandardItem* secondaryItem = new QStandardItem(); - primaryItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - secondaryItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - groupItem->setChild(shortcutItem->row(), 1, primaryItem); - groupItem->setChild(shortcutItem->row(), 2, secondaryItem); - } - // setup properties of item - shortcutItem->setText(action->getText()); - QModelIndex index = shortcutItem->index(); - mainModel->setData(index.sibling(index.row(), 1), - action->getShortcut(), Qt::DisplayRole); - mainModel->setData(index.sibling(index.row(), 2), - action->getAltShortcut(), Qt::DisplayRole); -} - -void ShortcutsDialog::restoreDefaultShortcuts() -{ - resetModel(); - actionMgr->restoreDefaultShortcuts(); - updateTreeData(); - initEditors(); -} - -void ShortcutsDialog::updateTreeData() -{ - // Create shortcuts tree - QStringList groups = actionMgr->getGroupList(); - foreach (const QString& group, groups) - { - updateGroup(group); - // display group's shortcuts - QList actions = actionMgr->getActionList(group); - foreach (StelAction* action, actions) - { - updateShortcutsItem(action); - } - } - updateText(); -} - -bool ShortcutsDialog::itemIsEditable(QStandardItem *item) -{ - if (item == NULL) return false; - // non-editable items(not group items) have no Qt::ItemIsSelectable flag - return (Qt::ItemIsSelectable & item->flags()); -} - -void ShortcutsDialog::resetModel() -{ - mainModel->clear(); - setModelHeader(); -} - -void ShortcutsDialog::setModelHeader() -{ - // Warning! The latter two strings are reused elsewhere in the GUI. - QStringList headerLabels; - headerLabels << q_("Action") - << q_("Primary shortcut") - << q_("Alternative shortcut"); - mainModel->setHorizontalHeaderLabels(headerLabels); -} diff --git a/src/gui/ShortcutsDialog.hpp b/src/gui/ShortcutsDialog.hpp deleted file mode 100644 index e891d31..0000000 --- a/src/gui/ShortcutsDialog.hpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2012 Anton Samoylov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef SHORTCUTSDIALOG_HPP -#define SHORTCUTSDIALOG_HPP - -#include -#include -#include - -#include "StelDialog.hpp" - - -class Ui_shortcutsDialogForm; -class ShortcutLineEdit; - -class QStandardItemModel; -class QStandardItem; - - -//! Custom filter class for filtering tree sub-items. -//! (The standard QSortFilterProxyModel shows child items only if the -//! parent item matches the filter.) -class ShortcutsFilterModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - ShortcutsFilterModel(QObject* parent = 0); - -protected: - bool filterAcceptsRow(int source_row, - const QModelIndex &source_parent) const; -}; - - -class ShortcutsDialog : public StelDialog -{ - Q_OBJECT - -public: - ShortcutsDialog(QObject* parent); - ~ShortcutsDialog(); - - //! higlight items that have collisions with current lineEdits' state according to css. - //! Note: previous collisions aren't redrawn. - void drawCollisions(); - -public slots: - //! restore colors of all items it TreeWidget to defaults. - void resetCollisions(); - void retranslate(); - //! ititialize editors state when current item changed. - void initEditors(); - //! checks whether one QKeySequence is prefix of another. - bool prefixMatchKeySequence(const QKeySequence &ks1, const QKeySequence &ks2); - //! Compile a list of items that share a prefix with this sequence. - QList findCollidingItems(QKeySequence ks); - void handleCollisions(ShortcutLineEdit* currentEdit); - //! called when editors' state changed. - void handleChanges(); - //! called when apply button clicked. - void applyChanges(); - //! called by doubleclick; if click is on editable item, switch to editors - void switchToEditors(const QModelIndex& index); - //! update shortcut representation in tree correspondingly to its actual contents. - //! if no item is specified, search for it in tree, if no items found, create new item - void updateShortcutsItem(class StelAction* action, QStandardItem* shortcutItem = NULL); - void restoreDefaultShortcuts(); - void updateTreeData(); - -protected: - //! Initialize the dialog widgets and connect the signals/slots. - virtual void createDialogContent(); - -private: - //! checks whether given item can be changed by editors. - static bool itemIsEditable(QStandardItem *item); - //! Concatenate the header, key codes and footer to build - //! up the help text. - //! @todo FIXME: This does nothing? - void updateText(); - - //! Apply style changes. - //! See http://qt-project.org/faq/answer/how_can_my_stylesheet_account_for_custom_properties - void polish(); - - QStandardItem* updateGroup(const QString& group); - - //! search for first appearence of item with requested data. - QStandardItem* findItemByData(QVariant value, int role, int column = 0); - - //! pointer to mgr, for not getting it from stelapp every time. - class StelActionMgr* actionMgr; - - //! list for storing collisions items, so we can easy restore their colors. - QList collisionItems; - - Ui_shortcutsDialogForm *ui; - ShortcutsFilterModel* filterModel; - QStandardItemModel* mainModel; - //! Initialize or reset the main model. - void resetModel(); - //! Set the main model's column lables. - void setModelHeader(); -}; - -#endif // SHORTCUTSDIALOG_HPP diff --git a/src/gui/SkyGui.cpp b/src/gui/SkyGui.cpp deleted file mode 100644 index f7c3e57..0000000 --- a/src/gui/SkyGui.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "SkyGui.hpp" -#include "StelObjectMgr.hpp" -#include "StelGuiItems.hpp" -#include "StelApp.hpp" -#include "StelGui.hpp" -#include "StelCore.hpp" -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_BUILD -#define round(dbl) dbl >= 0.0 ? (int)(dbl + 0.5) : ((dbl - (double)(int)dbl) <= -0.5 ? (int)dbl : (int)(dbl - 0.5)) -#endif - -InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent) -{ - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - QString objectInfo = conf->value("gui/selected_object_info", "all").toString(); - if (objectInfo == "all") - { - infoTextFilters = StelObject::InfoStringGroup(StelObject::AllInfo); - } - else if (objectInfo == "short") - { - infoTextFilters = StelObject::InfoStringGroup(StelObject::ShortInfo); - } - else if (objectInfo == "none") - { - infoTextFilters = StelObject::InfoStringGroup(0); - } - else if (objectInfo == "custom") - { - infoTextFilters = StelObject::InfoStringGroup(0); - - conf->beginGroup("custom_selected_info"); - if (conf->value("flag_show_name", false).toBool()) - infoTextFilters |= StelObject::Name; - if (conf->value("flag_show_catalognumber", false).toBool()) - infoTextFilters |= StelObject::CatalogNumber; - if (conf->value("flag_show_magnitude", false).toBool()) - infoTextFilters |= StelObject::Magnitude; - if (conf->value("flag_show_absolutemagnitude", false).toBool()) - infoTextFilters |= StelObject::AbsoluteMagnitude; - if (conf->value("flag_show_radecj2000", false).toBool()) - infoTextFilters |= StelObject::RaDecJ2000; - if (conf->value("flag_show_radecofdate", false).toBool()) - infoTextFilters |= StelObject::RaDecOfDate; - if (conf->value("flag_show_hourangle", false).toBool()) - infoTextFilters |= StelObject::HourAngle; - if (conf->value("flag_show_altaz", false).toBool()) - infoTextFilters |= StelObject::AltAzi; - if (conf->value("flag_show_distance", false).toBool()) - infoTextFilters |= StelObject::Distance; - if (conf->value("flag_show_size", false).toBool()) - infoTextFilters |= StelObject::Size; - if (conf->value("flag_show_extra", false).toBool()) - infoTextFilters |= StelObject::Extra; - if (conf->value("flag_show_type", false).toBool()) - infoTextFilters |= StelObject::Type; - if (conf->value("flag_show_galcoord", false).toBool()) - infoTextFilters |= StelObject::GalacticCoord; - conf->endGroup(); - } - else - { - qWarning() << "config.ini option gui/selected_object_info is invalid, using \"all\""; - infoTextFilters = StelObject::InfoStringGroup(StelObject::AllInfo); - } -} - -void InfoPanel::setTextFromObjects(const QList& selected) -{ - if (selected.isEmpty()) - { - if (!document()->isEmpty()) - document()->clear(); - } - else - { - // just print details of the first item for now - QString s = selected[0]->getInfoString(StelApp::getInstance().getCore(), infoTextFilters); - setHtml(s); - } -} - -const QString InfoPanel::getSelectedText(void) -{ - return toPlainText(); -} - -SkyGui::SkyGui(QGraphicsItem * parent): QGraphicsWidget(parent), stelGui(NULL) -{ - setObjectName("StelSkyGui"); - - // Construct the Windows buttons bar - winBar = new LeftStelBar(this); - // Construct the bottom buttons bar - buttonBar = new BottomStelBar(this, QPixmap(":/graphicGui/btbg-left.png"), QPixmap(":/graphicGui/btbg-right.png"), - QPixmap(":/graphicGui/btbg-middle.png"), QPixmap(":/graphicGui/btbg-single.png")); - infoPanel = new InfoPanel(this); - - // Used to display some progress bar in the lower right corner, e.g. when loading a file - progressBarMgr = new StelProgressBarMgr(this); - connect(&StelApp::getInstance(), SIGNAL(progressBarAdded(const StelProgressController*)), progressBarMgr, SLOT(addProgressBar(const StelProgressController*))); - connect(&StelApp::getInstance(), SIGNAL(progressBarRemoved(const StelProgressController*)), progressBarMgr, SLOT(removeProgressBar(const StelProgressController*))); - - // The path drawn around the button bars - buttonBarPath = new StelBarsPath(this); - - lastButtonbarWidth = 0; - autoHidebts = NULL; - - autoHideHorizontalButtonBar = true; - autoHideVerticalButtonBar = true; - - animLeftBarTimeLine = new QTimeLine(200, this); - animLeftBarTimeLine->setCurveShape(QTimeLine::EaseInOutCurve); - connect(animLeftBarTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(updateBarsPos())); - - animBottomBarTimeLine = new QTimeLine(200, this); - animBottomBarTimeLine->setCurveShape(QTimeLine::EaseInOutCurve); - connect(animBottomBarTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(updateBarsPos())); - - setAcceptHoverEvents(true); -} - -void SkyGui::init(StelGui* astelGui) -{ - stelGui = astelGui; - - winBar->setParentItem(this); - buttonBar->setParentItem(this); - buttonBarPath->setParentItem(this); - infoPanel->setParentItem(this); - progressBarMgr->setParentItem(this); - - // Create the 2 auto hide buttons in the bottom left corner - autoHidebts = new CornerButtons(); - QPixmap pxmapOn = QPixmap(":/graphicGui/HorizontalAutoHideOn.png"); - QPixmap pxmapOff = QPixmap(":/graphicGui/HorizontalAutoHideOff.png"); - btHorizAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPixmap(), "actionAutoHideHorizontalButtonBar", true); - pxmapOn = QPixmap(":/graphicGui/VerticalAutoHideOn.png"); - pxmapOff = QPixmap(":/graphicGui/VerticalAutoHideOff.png"); - btVertAutoHide = new StelButton(autoHidebts, pxmapOn, pxmapOff, QPixmap(), "actionAutoHideVerticalButtonBar", true); - - btHorizAutoHide->setPos(1,btVertAutoHide->pixmap().height()-btHorizAutoHide->pixmap().height()+1); - btVertAutoHide->setPos(0,0); - btVertAutoHide->setZValue(1000); - autoHidebts->setParentItem(this); - - infoPanel->setPos(8,8); - - // If auto hide is off, show the relevant toolbars - if (!autoHideHorizontalButtonBar) - { - animBottomBarTimeLine->setDirection(QTimeLine::Forward); - animBottomBarTimeLine->start(); - } - - if (!autoHideVerticalButtonBar) - { - animLeftBarTimeLine->setDirection(QTimeLine::Forward); - animLeftBarTimeLine->start(); - } - - buttonBarPath->setZValue(-0.1); - updateBarsPos(); - connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&))); -} - -void SkyGui::resizeEvent(QGraphicsSceneResizeEvent* event) -{ - QGraphicsWidget::resizeEvent(event); - updateBarsPos(); -} - -void SkyGui::hoverMoveEvent(QGraphicsSceneHoverEvent* event) -{ - const int hh = geometry().height(); - - double x = event->pos().x(); - double y = event->pos().y(); - double maxX = winBar->boundingRect().width()+2.*buttonBarPath->getRoundSize(); - double maxY = hh-(winBar->boundingRect().height()+buttonBar->boundingRect().height()+2.*buttonBarPath->getRoundSize()); - double minX = 0; - - if (x<=maxX && y>=maxY && animLeftBarTimeLine->state()==QTimeLine::NotRunning && winBar->pos().x()setDirection(QTimeLine::Forward); - animLeftBarTimeLine->start(); - } - if (autoHideVerticalButtonBar && (x>maxX+30 || ystate()==QTimeLine::NotRunning && winBar->pos().x()>=minX) - { - animLeftBarTimeLine->setDirection(QTimeLine::Backward); - animLeftBarTimeLine->start(); - } - - maxX = winBar->boundingRect().width()+buttonBar->boundingRect().width()+2.*buttonBarPath->getRoundSize(); - maxY = hh-buttonBar->boundingRect().height()+2.*buttonBarPath->getRoundSize(); - if (x<=maxX && y>=maxY && animBottomBarTimeLine->state()==QTimeLine::NotRunning && animBottomBarTimeLine->currentValue()<1.) - { - animBottomBarTimeLine->setDirection(QTimeLine::Forward); - animBottomBarTimeLine->start(); - } - if (autoHideHorizontalButtonBar && (x>maxX+30 || ystate()==QTimeLine::NotRunning && animBottomBarTimeLine->currentValue()>=0.9999999) - { - animBottomBarTimeLine->setDirection(QTimeLine::Backward); - animBottomBarTimeLine->start(); - } -} - -//! Update the position of the button bars in the main window -void SkyGui::updateBarsPos() -{ - const int ww = geometry().width(); - const int hh = geometry().height(); - bool updatePath = false; - - // Use a position cache to avoid useless redraw triggered by the position set if the bars don't move - double rangeX = winBar->boundingRectNoHelpLabel().width()+2.*buttonBarPath->getRoundSize()+1.; - const qreal newWinBarX = buttonBarPath->getRoundSize()-(1.-animLeftBarTimeLine->currentValue())*rangeX-0.5; - const qreal newWinBarY = hh-winBar->boundingRectNoHelpLabel().height()-buttonBar->boundingRectNoHelpLabel().height()-20; - if (winBar->pos().x()!=newWinBarX || winBar->pos().y()!=newWinBarY) - { - winBar->setPos(round(newWinBarX), round(newWinBarY)); - updatePath = true; - } - - double rangeY = buttonBar->boundingRectNoHelpLabel().height()+0.5-7.-buttonBarPath->getRoundSize(); - const qreal newButtonBarX = winBar->boundingRectNoHelpLabel().right()+buttonBarPath->getRoundSize(); - const qreal newButtonBarY = hh-buttonBar->boundingRectNoHelpLabel().height()-buttonBarPath->getRoundSize()+0.5+(1.-animBottomBarTimeLine->currentValue())*rangeY; - if (buttonBar->pos().x()!=newButtonBarX || buttonBar->pos().y()!=newButtonBarY) - { - buttonBar->setPos(round(newButtonBarX), round(newButtonBarY)); - updatePath = true; - } - - if (lastButtonbarWidth != buttonBar->boundingRectNoHelpLabel().width()) - { - updatePath = true; - lastButtonbarWidth = (int)(buttonBar->boundingRectNoHelpLabel().width()); - } - - if (updatePath) - buttonBarPath->updatePath(buttonBar, winBar); - - const qreal newProgressBarX = ww-progressBarMgr->boundingRect().width()-20; - const qreal newProgressBarY = hh-progressBarMgr->boundingRect().height()+7; - progressBarMgr->setPos(newProgressBarX, newProgressBarY); - progressBarMgr->setZValue(400); - - // Update position of the auto-hide buttons - autoHidebts->setPos(0, hh-autoHidebts->childrenBoundingRect().height()+1); - double opacity = qMax(animLeftBarTimeLine->currentValue(), animBottomBarTimeLine->currentValue()); - autoHidebts->setOpacity(opacity < 0.01 ? 0.01 : opacity); // Work around a qt bug -} - -void SkyGui::setStelStyle(const QString& style) -{ - Q_UNUSED(style); - buttonBarPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5)); - buttonBarPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0.2)); - buttonBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9)); - winBar->setColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9)); -} - -// Add a new progress bar in the lower right corner of the screen. -void SkyGui::addProgressBar(StelProgressController* p) -{ - return progressBarMgr->addProgressBar(p); -} - -void SkyGui::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) -{ - stelGui->update(); -} diff --git a/src/gui/SkyGui.hpp b/src/gui/SkyGui.hpp deleted file mode 100644 index 335af39..0000000 --- a/src/gui/SkyGui.hpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _SKYGUI_HPP_ -#define _SKYGUI_HPP_ - -#include "StelStyle.hpp" -#include "StelObject.hpp" - -#include -#include - -class QGraphicsSceneMouseEvent; -class QGraphicsTextItem; -class QTimeLine; -class StelButton; -class BottomStelBar; -class StelProgressController; - -//! The informations about the currently selected object -class InfoPanel : public QGraphicsTextItem -{ - public: - //! Reads "gui/selected_object_info", etc from the configuration file. - //! @todo Bad idea to read from the configuration file in a constructor? --BM - InfoPanel(QGraphicsItem* parent); - void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {infoTextFilters=aflags;} - const StelObject::InfoStringGroup& getInfoTextFilters(void) const {return infoTextFilters;} - void setTextFromObjects(const QList&); - const QString getSelectedText(void); - - private: - StelObject::InfoStringGroup infoTextFilters; -}; - -//! The class managing the layout for button bars, selected object info and loading bars. -class SkyGui: public QGraphicsWidget -{ - Q_OBJECT - -public: - friend class StelGui; - - SkyGui(QGraphicsItem * parent=NULL); - //! Add a new progress bar in the lower right corner of the screen. - //! When the progress bar is deleted with removeProgressBar() the layout is automatically rearranged. - //! @return a pointer to the progress bar - void addProgressBar(StelProgressController*); - - void init(class StelGui* stelGui); - - virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0); - -protected: - virtual void resizeEvent(QGraphicsSceneResizeEvent* event); - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event); - -private slots: - //! Load color scheme from the given ini file and section name - void setStelStyle(const QString& style); - - //! Update the position of the button bars in the main window - void updateBarsPos(); - -private: - class StelBarsPath* buttonBarPath; - QTimeLine* animLeftBarTimeLine; - QTimeLine* animBottomBarTimeLine; - int lastButtonbarWidth; - class LeftStelBar* winBar; - BottomStelBar* buttonBar; - class InfoPanel* infoPanel; - class StelProgressBarMgr* progressBarMgr; - - // The 2 auto hide buttons in the lower left corner - StelButton* btHorizAutoHide; - StelButton* btVertAutoHide; - - class CornerButtons* autoHidebts; - - bool autoHideHorizontalButtonBar; - bool autoHideVerticalButtonBar; - - StelGui* stelGui; -}; - -#endif // _SKYGUI_HPP_ diff --git a/src/gui/StelDialog.cpp b/src/gui/StelDialog.cpp deleted file mode 100644 index e5fcaa9..0000000 --- a/src/gui/StelDialog.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - - -#include "StelDialog.hpp" -#include "StelMainView.hpp" -#include "StelGui.hpp" -#include "StelApp.hpp" - -#include -#include -#include -#include - -class CustomProxy : public QGraphicsProxyWidget -{ - public: - CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0) : QGraphicsProxyWidget(parent, wFlags) - { - setFocusPolicy(Qt::StrongFocus); - } - //! Reimplement this method to add windows decorations. Currently there are invisible 2 px decorations - void paintWindowFrame(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) - { -/* QStyleOptionTitleBar bar; - initStyleOption(&bar); - bar.subControls = QStyle::SC_TitleBarCloseButton; - qWarning() << style()->subControlRect(QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton); - QGraphicsProxyWidget::paintWindowFrame(painter, option, widget);*/ - } - protected: - - virtual bool event(QEvent* event) - { - switch (event->type()) - { - case QEvent::WindowDeactivate: - widget()->setWindowOpacity(0.4); - break; - case QEvent::WindowActivate: - case QEvent::GrabMouse: - widget()->setWindowOpacity(0.9); - break; - default: - break; - } - return QGraphicsProxyWidget::event(event); - } -}; - -StelDialog::StelDialog(QObject* parent) : QObject(parent), dialog(NULL) -{ - if (parent == NULL) - setParent(StelMainView::getInstance().getGuiWidget()); -} - -StelDialog::~StelDialog() -{ -} - - -void StelDialog::close() -{ - setVisible(false); -} - -bool StelDialog::visible() const -{ - return dialog!=NULL && dialog->isVisible(); -} - -void StelDialog::setVisible(bool v) -{ - if (v) - { - QSize screenSize = StelMainView::getInstance().size(); - if (dialog) - { - dialog->show(); - StelMainView::getInstance().scene()->setActiveWindow(proxy); - // If the main window has been resized, it is possible the dialog - // will be off screen. Check for this and move it to a visible - // position if necessary - QPointF newPos = proxy->pos(); - if (newPos.x()>=screenSize.width()) - newPos.setX(screenSize.width() - dialog->size().width()); - if (newPos.y()>=screenSize.height()) - newPos.setY(screenSize.height() - dialog->size().height()); - if (newPos != dialog->pos()) - proxy->setPos(newPos); - - proxy->setFocus(); - return; - } - - QGraphicsWidget* parent = qobject_cast(this->parent()); - dialog = new QDialog(NULL); - // dialog->setParent(parent); - StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); - Q_ASSERT(gui); - //dialog->setAttribute(Qt::WA_OpaquePaintEvent, true); - connect(dialog, SIGNAL(rejected()), this, SLOT(close())); - createDialogContent(); - dialog->setStyleSheet(gui->getStelStyle().qtStyleSheet); - - proxy = new CustomProxy(parent, Qt::Tool); - proxy->setWidget(dialog); - QSizeF size = proxy->size(); - - // centre with dialog according to current window size. - int newX = (int)((screenSize.width() - size.width())/2); - int newY = (int)((screenSize.height() - size.height())/2); - // Make sure that the window's title bar is accessible - if (newY <-0) - newY = 0; - proxy->setPos(newX, newY); - proxy->setWindowFrameMargins(2,0,2,2); - // (this also changes the bounding rectangle size) - - // The caching is buggy on all plateforms with Qt 4.5.2 - proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache); - - proxy->setZValue(100); - StelMainView::getInstance().scene()->setActiveWindow(proxy); - proxy->setFocus(); - } - else - { - dialog->hide(); - emit visibleChanged(false); - //proxy->clearFocus(); - StelMainView::getInstance().focusSky(); - } -} diff --git a/src/gui/StelDialog.hpp b/src/gui/StelDialog.hpp deleted file mode 100644 index 4d6f86a..0000000 --- a/src/gui/StelDialog.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _STELDIALOG_HPP_ -#define _STELDIALOG_HPP_ - -#include - -//! @class StelDialog -//! Base class for all the GUI windows in Stellarium. -//! -//! Windows in Stellarium are actually basic QWidgets that have to be wrapped in -//! a QGraphicsProxyWidget (CustomProxy) to be displayed by StelMainView -//! (which is derived from QGraphicsView). See the Qt documentation for details. -//! -//! The base widget needs to be populated with controls in the implementation -//! of the createDialogContent() function. This can be done either manually, or -//! by using a .ui file. See the Qt documentation on using Qt Designer .ui files -//! for details. -//! -//! The createDialogContent() function itself is called automatically the first -//! time setVisible() is called with "true". -//! -//! Moving a window is done by dragging its title bar, defined in the BarFrame -//! class. Every derived window class needs a BarFrame object - it -//! has to be either included in a .ui file, or manually instantiated in -//! createDialogContent(). -class StelDialog : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged) -public: - StelDialog(QObject* parent=NULL); - virtual ~StelDialog(); - - bool visible() const; - -public slots: - //! Retranslate the content of the dialog. - //! Needs to be connected to StelApp::languageChanged(). - //! At the very least, if the window is - //! - //! based on a Qt Designer file (.ui), the implementation needs to call - //! the generated class' retranslateUi() method, like this: - //! \code - //! if (dialog) - //! ui->retranslateUi(dialog); - //! \endcode - virtual void retranslate() = 0; - //! On the first call with "true" populates the window contents. - void setVisible(bool); - //! Closes the window (the window widget is not deleted, just not visible). - void close(); -signals: - void visibleChanged(bool); - -protected: - //! Initialize the dialog widgets and connect the signals/slots. - virtual void createDialogContent()=0; - - //! The main dialog - QWidget* dialog; - class CustomProxy* proxy; -}; - -#endif // _STELDIALOG_HPP_ diff --git a/src/gui/StelGui.cpp b/src/gui/StelGui.cpp deleted file mode 100644 index a4031ca..0000000 --- a/src/gui/StelGui.cpp +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * Copyright (C) 2012 Timothy Reaves - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "StelGui.hpp" -#include "StelGuiItems.hpp" -#include "SkyGui.hpp" -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelProjector.hpp" -#include "StelMovementMgr.hpp" -#include "StelFileMgr.hpp" -#include "StelModuleMgr.hpp" -#include "StelIniParser.hpp" -#include "StelMainView.hpp" -#include "StelObjectMgr.hpp" -#include "LandscapeMgr.hpp" -#include "StarMgr.hpp" -#include "ConstellationMgr.hpp" -#include "GridLinesMgr.hpp" -#include "NebulaMgr.hpp" -#include "StelLocaleMgr.hpp" -#include "StelActionMgr.hpp" - -#include "StelObjectType.hpp" -#include "StelObject.hpp" -#include "StelProjector.hpp" -#include "SolarSystem.hpp" -#include "StelSkyLayerMgr.hpp" -#include "StelStyle.hpp" -#include "StelSkyDrawer.hpp" -#include "MeteorMgr.hpp" -#ifdef ENABLE_SCRIPT_CONSOLE -#include "ScriptConsole.hpp" -#endif -#ifndef DISABLE_SCRIPTING -#include "StelScriptMgr.hpp" -#endif - -#include "ConfigurationDialog.hpp" -#include "DateTimeDialog.hpp" -#include "HelpDialog.hpp" -#include "LocationDialog.hpp" -#include "SearchDialog.hpp" -#include "ViewDialog.hpp" -#include "ShortcutsDialog.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -StelGuiBase* StelStandardGuiPluginInterface::getStelGuiBase() const -{ - // Allow to load the resources when used as a static plugin - Q_INIT_RESOURCE(guiRes); - - return new StelGui(); -} - -StelGui::StelGui() : - topLevelGraphicsWidget(NULL), - locationDialog(0), - helpDialog(0), - dateTimeDialog(0), - searchDialog(0), - viewDialog(0), - shortcutsDialog(0), - configurationDialog(0), -#ifdef ENABLE_SCRIPT_CONSOLE - scriptConsole(0), -#endif - initDone(false) -{ - // QPixmapCache::setCacheLimit(30000); ? - flipHoriz = NULL; - flipVert = NULL; - btShowNebulaeBackground = NULL; -} - -StelGui::~StelGui() -{ - delete skyGui; - skyGui = NULL; - - if (locationDialog) - { - delete locationDialog; - locationDialog = 0; - } - if (helpDialog) - { - delete helpDialog; - helpDialog = 0; - } - if (dateTimeDialog) - { - delete dateTimeDialog; - dateTimeDialog = 0; - } - if (searchDialog) - { - delete searchDialog; - searchDialog = 0; - } - if (viewDialog) - { - delete viewDialog; - viewDialog = 0; - } - if (shortcutsDialog) - { - delete shortcutsDialog; - shortcutsDialog = NULL; - } - // configurationDialog is automatically deleted with its parent widget. -#ifdef ENABLE_SCRIPT_CONSOLE - if (scriptConsole) - { - delete scriptConsole; - scriptConsole = 0; - } -#endif -} - -void StelGui::init(QGraphicsWidget *atopLevelGraphicsWidget) -{ - qDebug() << "Creating GUI ..."; - - StelGuiBase::init(atopLevelGraphicsWidget); - skyGui = new SkyGui(atopLevelGraphicsWidget); - locationDialog = new LocationDialog(atopLevelGraphicsWidget); - helpDialog = new HelpDialog(atopLevelGraphicsWidget); - dateTimeDialog = new DateTimeDialog(atopLevelGraphicsWidget); - searchDialog = new SearchDialog(atopLevelGraphicsWidget); - viewDialog = new ViewDialog(atopLevelGraphicsWidget); - shortcutsDialog = new ShortcutsDialog(atopLevelGraphicsWidget); - configurationDialog = new ConfigurationDialog(this, atopLevelGraphicsWidget); -#ifdef ENABLE_SCRIPT_CONSOLE - scriptConsole = new ScriptConsole(); -#endif - - /////////////////////////////////////////////////////////////////////// - // Create all the main actions of the program, associated with shortcuts - - /////////////////////////////////////////////////////////////////////// - // Connect all the GUI actions signals with the Core of Stellarium - StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionManager(); - - // XXX: this should probably go into the script manager. - QString datetimeGroup = N_("Date and Time"); - QString windowsGroup = N_("Windows"); - QString miscGroup = N_("Miscellaneous"); - actionsMgr->addAction("actionQuit_Global", miscGroup, N_("Quit"), this, "quit()", "Ctrl+Q"); - actionsMgr->addAction("actionIncrease_Script_Speed", datetimeGroup, N_("Speed up the script execution rate"), this, "increaseScriptSpeed()"); - actionsMgr->addAction("actionDecrease_Script_Speed", datetimeGroup, N_("Slow down the script execution rate"), this, "decreaseScriptSpeed()"); - actionsMgr->addAction("actionSet_Real_Script_Speed", datetimeGroup, N_("Set the normal script execution rate"), this, "setRealScriptSpeed()"); - actionsMgr->addAction("actionStop_Script", datetimeGroup, N_("Stop script execution"), this, "stopScript()", "Ctrl+D, S"); - actionsMgr->addAction("actionPause_Script", datetimeGroup, N_("Pause script execution"), this, "pauseScript()", "Ctrl+D, P"); - actionsMgr->addAction("actionResume_Script", datetimeGroup, N_("Resume script execution"), this, "resumeScript()", "Ctrl+D, R"); - -#ifdef ENABLE_SCRIPT_CONSOLE - actionsMgr->addAction("actionShow_ScriptConsole_Window_Global", windowsGroup, N_("Script console window"), scriptConsole, "visible", "F12", "", true); -#endif - - actionsMgr->addAction("actionShow_Help_Window_Global", windowsGroup, N_("Help window"), helpDialog, "visible", "F1", "", true); - actionsMgr->addAction("actionShow_Configuration_Window_Global", windowsGroup, N_("Configuration window"), configurationDialog, "visible", "F2", "", true); - actionsMgr->addAction("actionShow_Search_Window_Global", windowsGroup, N_("Search window"), searchDialog, "visible", "F3", "Ctrl+F", true); - actionsMgr->addAction("actionShow_SkyView_Window_Global", windowsGroup, N_("Sky and viewing options window"), viewDialog, "visible", "F4", "", true); - actionsMgr->addAction("actionShow_DateTime_Window_Global", windowsGroup, N_("Date/time window"), dateTimeDialog, "visible", "F5", "", true); - actionsMgr->addAction("actionShow_Location_Window_Global", windowsGroup, N_("Location window"), locationDialog, "visible", "F6", "", true); - actionsMgr->addAction("actionShow_Shortcuts_Window_Global", windowsGroup, N_("Shortcuts window"), shortcutsDialog, "visible", "F7", "", true); - actionsMgr->addAction("actionSave_Copy_Object_Information_Global", miscGroup, N_("Copy selected object information to clipboard"), this, "copySelectedObjectInfo()", "Ctrl+C", "", true); - actionsMgr->addAction("actionToggle_GuiHidden_Global", miscGroup, N_("Toggle visibility of GUI"), this, "visible", "Ctrl+T", "", true); - - QSettings* conf = StelApp::getInstance().getSettings(); - Q_ASSERT(conf); - setAutoHideHorizontalButtonBar(conf->value("gui/auto_hide_horizontal_toolbar", true).toBool()); - setAutoHideVerticalButtonBar(conf->value("gui/auto_hide_vertical_toolbar", true).toBool()); - actionsMgr->addAction("actionAutoHideHorizontalButtonBar", miscGroup, N_("Auto hide horizontal button bar"), this, "autoHideHorizontalButtonBar"); - actionsMgr->addAction("actionAutoHideVerticalButtonBar", miscGroup, N_("Auto hide vertical button bar"), this, "autoHideVerticalButtonBar"); - -#ifndef DISABLE_SCRIPTING - StelScriptMgr* scriptMgr = &StelApp::getInstance().getScriptMgr(); - connect(scriptMgr, SIGNAL(scriptRunning()), this, SLOT(scriptStarted())); - connect(scriptMgr, SIGNAL(scriptStopped()), this, SLOT(scriptStopped())); -#endif - - /////////////////////////////////////////////////////////////////////////// - //// QGraphicsView based GUI - /////////////////////////////////////////////////////////////////////////// - - // Add everything - QPixmap pxmapDefault; - QPixmap pxmapGlow(":/graphicGui/glow.png"); - QPixmap pxmapOn(":/graphicGui/2-on-location.png"); - QPixmap pxmapOff(":/graphicGui/2-off-location.png"); - StelButton* b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Location_Window_Global"); - skyGui->winBar->addButton(b); - - pxmapOn = QPixmap(":/graphicGui/1-on-time.png"); - pxmapOff = QPixmap(":/graphicGui/1-off-time.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_DateTime_Window_Global"); - skyGui->winBar->addButton(b); - - pxmapOn = QPixmap(":/graphicGui/5-on-labels.png"); - pxmapOff = QPixmap(":/graphicGui/5-off-labels.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_SkyView_Window_Global"); - skyGui->winBar->addButton(b); - - pxmapOn = QPixmap(":/graphicGui/6-on-search.png"); - pxmapOff = QPixmap(":/graphicGui/6-off-search.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Search_Window_Global"); - skyGui->winBar->addButton(b); - - pxmapOn = QPixmap(":/graphicGui/8-on-settings.png"); - pxmapOff = QPixmap(":/graphicGui/8-off-settings.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Configuration_Window_Global"); - skyGui->winBar->addButton(b); - - pxmapOn = QPixmap(":/graphicGui/9-on-help.png"); - pxmapOff = QPixmap(":/graphicGui/9-off-help.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow, "actionShow_Help_Window_Global"); - skyGui->winBar->addButton(b); - - QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png"); - - pxmapOn = QPixmap(":/graphicGui/btConstellationLines-on.png"); - pxmapOff = QPixmap(":/graphicGui/btConstellationLines-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Lines"); - skyGui->buttonBar->addButton(b, "010-constellationsGroup"); - - pxmapOn = QPixmap(":/graphicGui/btConstellationLabels-on.png"); - pxmapOff = QPixmap(":/graphicGui/btConstellationLabels-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Labels"); - skyGui->buttonBar->addButton(b, "010-constellationsGroup"); - - pxmapOn = QPixmap(":/graphicGui/btConstellationArt-on.png"); - pxmapOff = QPixmap(":/graphicGui/btConstellationArt-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Constellation_Art"); - skyGui->buttonBar->addButton(b, "010-constellationsGroup"); - - pxmapOn = QPixmap(":/graphicGui/btEquatorialGrid-on.png"); - pxmapOff = QPixmap(":/graphicGui/btEquatorialGrid-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Equatorial_Grid"); - skyGui->buttonBar->addButton(b, "020-gridsGroup"); - - pxmapOn = QPixmap(":/graphicGui/btAzimuthalGrid-on.png"); - pxmapOff = QPixmap(":/graphicGui/btAzimuthalGrid-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Azimuthal_Grid"); - skyGui->buttonBar->addButton(b, "020-gridsGroup"); - - pxmapOn = QPixmap(":/graphicGui/btGround-on.png"); - pxmapOff = QPixmap(":/graphicGui/btGround-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Ground"); - skyGui->buttonBar->addButton(b, "030-landscapeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btCardinalPoints-on.png"); - pxmapOff = QPixmap(":/graphicGui/btCardinalPoints-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Cardinal_Points"); - skyGui->buttonBar->addButton(b, "030-landscapeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btAtmosphere-on.png"); - pxmapOff = QPixmap(":/graphicGui/btAtmosphere-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Atmosphere"); - skyGui->buttonBar->addButton(b, "030-landscapeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btNebula-on.png"); - pxmapOff = QPixmap(":/graphicGui/btNebula-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Nebulas"); - skyGui->buttonBar->addButton(b, "040-nebulaeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btPlanets-on.png"); - pxmapOff = QPixmap(":/graphicGui/btPlanets-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Planets_Labels"); - skyGui->buttonBar->addButton(b, "040-nebulaeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btEquatorialMount-on.png"); - pxmapOff = QPixmap(":/graphicGui/btEquatorialMount-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionSwitch_Equatorial_Mount"); - skyGui->buttonBar->addButton(b, "060-othersGroup"); - - pxmapOn = QPixmap(":/graphicGui/btGotoSelectedObject-on.png"); - pxmapOff = QPixmap(":/graphicGui/btGotoSelectedObject-off.png"); - buttonGotoSelectedObject = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionGoto_Selected_Object"); - skyGui->buttonBar->addButton(buttonGotoSelectedObject, "060-othersGroup"); - - pxmapOn = QPixmap(":/graphicGui/btNightView-on.png"); - pxmapOff = QPixmap(":/graphicGui/btNightView-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Night_Mode"); - skyGui->buttonBar->addButton(b, "060-othersGroup"); - - pxmapOn = QPixmap(":/graphicGui/btFullScreen-on.png"); - pxmapOff = QPixmap(":/graphicGui/btFullScreen-off.png"); - b = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionSet_Full_Screen_Global"); - skyGui->buttonBar->addButton(b, "060-othersGroup"); - - pxmapOn = QPixmap(":/graphicGui/btTimeRewind-on.png"); - pxmapOff = QPixmap(":/graphicGui/btTimeRewind-off.png"); - buttonTimeRewind = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionDecrease_Time_Speed"); - skyGui->buttonBar->addButton(buttonTimeRewind, "070-timeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btTimeRealtime-on.png"); - pxmapOff = QPixmap(":/graphicGui/btTimeRealtime-off.png"); - pxmapDefault = QPixmap(":/graphicGui/btTimePause-on.png"); - buttonTimeRealTimeSpeed = new StelButton(NULL, pxmapOn, pxmapOff, pxmapDefault, pxmapGlow32x32, "actionSet_Real_Time_Speed"); - skyGui->buttonBar->addButton(buttonTimeRealTimeSpeed, "070-timeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btTimeNow-on.png"); - pxmapOff = QPixmap(":/graphicGui/btTimeNow-off.png"); - buttonTimeCurrent = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionReturn_To_Current_Time"); - skyGui->buttonBar->addButton(buttonTimeCurrent, "070-timeGroup"); - - pxmapOn = QPixmap(":/graphicGui/btTimeForward-on.png"); - pxmapOff = QPixmap(":/graphicGui/btTimeForward-off.png"); - buttonTimeForward = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionIncrease_Time_Speed"); - skyGui->buttonBar->addButton(buttonTimeForward, "070-timeGroup"); - - skyGui->buttonBar->setGroupMargin("070-timeGroup", 32, 0); - - pxmapOn = QPixmap(":/graphicGui/btQuit.png"); - b = new StelButton(NULL, pxmapOn, pxmapOn, pxmapGlow32x32, "actionQuit_Global"); - skyGui->buttonBar->addButton(b, "080-quitGroup"); - - // add the flip buttons if requested in the config - setFlagShowFlipButtons(conf->value("gui/flag_show_flip_buttons", false).toBool()); - setFlagShowNebulaBackgroundButton(conf->value("gui/flag_show_nebulae_background_button", false).toBool()); - - /////////////////////////////////////////////////////////////////////// - // Create the main base widget - skyGui->init(this); - QGraphicsGridLayout* l = new QGraphicsGridLayout(); - l->setContentsMargins(0,0,0,0); - l->setSpacing(0); - l->addItem(skyGui, 0, 0); - atopLevelGraphicsWidget->setLayout(l); - - setStelStyle(StelApp::getInstance().getCurrentStelStyle()); - - skyGui->setGeometry(atopLevelGraphicsWidget->geometry()); - skyGui->updateBarsPos(); - - // The disabled text for checkboxes is embossed with the QPalette::Light setting for the ColorGroup Disabled. - // It doesn't appear to be possible to set this from the stylesheet. Instead we'll make it 100% transparent - // and set the text color for disabled in the stylesheets. - QPalette p = QGuiApplication::palette(); - p.setColor(QPalette::Disabled, QPalette::Light, QColor(0,0,0,0)); - - // And this is for the focus... apparently the focus indicator is the inverted value for Active/Button. - p.setColor(QPalette::Active, QPalette::Button, QColor(255,255,255)); - QGuiApplication::setPalette(p); - - // FIXME: Workaround for set UI language when app is started --AW - updateI18n(); - - StelApp *app = &StelApp::getInstance(); - connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); - connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&))); - initDone = true; -} - -void StelGui::quit() -{ -#ifndef DISABLE_SCRIPTING - StelApp::getInstance().getScriptMgr().stopScript(); -#endif - QCoreApplication::exit(); -} - -//! Reload the current Qt Style Sheet (Debug only) -void StelGui::reloadStyle() -{ - setStelStyle(StelApp::getInstance().getCurrentStelStyle()); -} - -//! Load color scheme from the given ini file and section name -void StelGui::setStelStyle(const QString& section) -{ - if (currentStelStyle.confSectionName!=section) - { - // Load the style sheets - currentStelStyle.confSectionName = section; - - QString qtStyleFileName; - QString htmlStyleFileName; - - if (section=="night_color") - { - qtStyleFileName = ":/graphicGui/nightStyle.css"; - htmlStyleFileName = ":/graphicGui/nightHtml.css"; - } - else if (section=="color") - { - qtStyleFileName = ":/graphicGui/normalStyle.css"; - htmlStyleFileName = ":/graphicGui/normalHtml.css"; - } - - // Load Qt style sheet - QFile styleFile(qtStyleFileName); - styleFile.open(QIODevice::ReadOnly); - currentStelStyle.qtStyleSheet = styleFile.readAll(); - - QFile htmlStyleFile(htmlStyleFileName); - htmlStyleFile.open(QIODevice::ReadOnly); - currentStelStyle.htmlStyleSheet = htmlStyleFile.readAll(); - } - - locationDialog->styleChanged(); - dateTimeDialog->styleChanged(); - configurationDialog->styleChanged(); - searchDialog->styleChanged(); - viewDialog->styleChanged(); -#ifdef ENABLE_SCRIPT_CONSOLE - scriptConsole->styleChanged(); -#endif // ENABLE_SCRIPT_CONSOLE -} - - -void StelGui::updateI18n() -{ - // Translate all action texts - foreach (QObject* obj, StelMainView::getInstance().children()) - { - QAction* a = qobject_cast(obj); - if (a) - { - const QString& englishText = a->property("englishText").toString(); - if (!englishText.isEmpty()) - { - a->setText(q_(englishText)); - } - } - } -} - -void StelGui::update() -{ - StelCore* core = StelApp::getInstance().getCore(); - if (core->getTimeRate()<-0.99*StelCore::JD_SECOND) { - if (buttonTimeRewind->isChecked()==false) - buttonTimeRewind->setChecked(true); - } else { - if (buttonTimeRewind->isChecked()==true) - buttonTimeRewind->setChecked(false); - } - if (core->getTimeRate()>1.01*StelCore::JD_SECOND) { - if (buttonTimeForward->isChecked()==false) { - buttonTimeForward->setChecked(true); - } - } else { - if (buttonTimeForward->isChecked()==true) - buttonTimeForward->setChecked(false); - } - if (core->getTimeRate() == 0) { - if (buttonTimeRealTimeSpeed->isChecked() != StelButton::ButtonStateNoChange) - buttonTimeRealTimeSpeed->setChecked(StelButton::ButtonStateNoChange); - } else if (core->getRealTimeSpeed()) { - if (buttonTimeRealTimeSpeed->isChecked() != StelButton::ButtonStateOn) - buttonTimeRealTimeSpeed->setChecked(StelButton::ButtonStateOn); - } else if (buttonTimeRealTimeSpeed->isChecked() != StelButton::ButtonStateOff) { - buttonTimeRealTimeSpeed->setChecked(StelButton::ButtonStateOff); - } - const bool isTimeNow=core->getIsTimeNow(); - if (buttonTimeCurrent->isChecked()!=isTimeNow) { - buttonTimeCurrent->setChecked(isTimeNow); - } - StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr); - const bool b = mmgr->getFlagTracking(); - if (buttonGotoSelectedObject->isChecked()!=b) { - buttonGotoSelectedObject->setChecked(b); - } - - bool flag; - - // XXX: this should probably be removed, we can use property NOTIFY instead. - flag = GETSTELMODULE(StelSkyLayerMgr)->getFlagShow(); - if (getAction("actionShow_DSS")->isChecked() != flag) - getAction("actionShow_DSS")->setChecked(flag); - - flag = StelApp::getInstance().getVisionModeNight(); - if (getAction("actionShow_Night_Mode")->isChecked() != flag) - getAction("actionShow_Night_Mode")->setChecked(flag); - - flag = StelMainView::getInstance().isFullScreen(); - if (getAction("actionSet_Full_Screen_Global")->isChecked() != flag) - getAction("actionSet_Full_Screen_Global")->setChecked(flag); - - skyGui->infoPanel->setTextFromObjects(GETSTELMODULE(StelObjectMgr)->getSelectedObject()); - - // Check if the progressbar window changed, if yes update the whole view - if (savedProgressBarSize!=skyGui->progressBarMgr->boundingRect().size()) - { - savedProgressBarSize=skyGui->progressBarMgr->boundingRect().size(); - skyGui->updateBarsPos(); - } - - dateTimeDialog->setDateTime(core->getJDay()); -} - -#ifndef DISABLE_SCRIPTING -void StelGui::setScriptKeys(bool b) -{ - if (b) - { - getAction("actionDecrease_Time_Speed")->setShortcut(""); - getAction("actionIncrease_Time_Speed")->setShortcut(""); - getAction("actionSet_Real_Time_Speed")->setShortcut(""); - getAction("actionDecrease_Script_Speed")->setShortcut("J"); - getAction("actionIncrease_Script_Speed")->setShortcut("L"); - getAction("actionSet_Real_Script_Speed")->setShortcut("K"); - } - else - { - getAction("actionDecrease_Script_Speed")->setShortcut(""); - getAction("actionIncrease_Script_Speed")->setShortcut(""); - getAction("actionSet_Real_Script_Speed")->setShortcut(""); - getAction("actionDecrease_Time_Speed")->setShortcut("J"); - getAction("actionIncrease_Time_Speed")->setShortcut("L"); - getAction("actionSet_Real_Time_Speed")->setShortcut("K"); - } -} - -void StelGui::increaseScriptSpeed() -{ - StelApp::getInstance().getScriptMgr().setScriptRate(StelApp::getInstance().getScriptMgr().getScriptRate()*2); -} - -void StelGui::decreaseScriptSpeed() -{ - StelApp::getInstance().getScriptMgr().setScriptRate(StelApp::getInstance().getScriptMgr().getScriptRate()/2); -} - -void StelGui::setRealScriptSpeed() -{ - StelApp::getInstance().getScriptMgr().setScriptRate(1); -} - -void StelGui::stopScript() -{ - StelApp::getInstance().getScriptMgr().stopScript(); -} - -void StelGui::pauseScript() -{ - StelApp::getInstance().getScriptMgr().pauseScript(); -} - -void StelGui::resumeScript() -{ - StelApp::getInstance().getScriptMgr().resumeScript(); -} -#endif - -void StelGui::setFlagShowFlipButtons(bool b) -{ - if (b==true) { - if (flipVert==NULL) { - // Create the vertical flip button - QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png"); - flipVert = new StelButton(NULL, - QPixmap(":/graphicGui/btFlipVertical-on.png"), - QPixmap(":/graphicGui/btFlipVertical-off.png"), - pxmapGlow32x32, - "actionVertical_Flip"); - } - if (flipHoriz==NULL) { - QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png"); - flipHoriz = new StelButton(NULL, - QPixmap(":/graphicGui/btFlipHorizontal-on.png"), - QPixmap(":/graphicGui/btFlipHorizontal-off.png"), - pxmapGlow32x32, - "actionHorizontal_Flip"); - } - getButtonBar()->addButton(flipVert, "060-othersGroup", "actionQuit_Global"); - getButtonBar()->addButton(flipHoriz, "060-othersGroup", "actionVertical_Flip"); - } else { - getButtonBar()->hideButton("actionVertical_Flip"); - getButtonBar()->hideButton("actionHorizontal_Flip"); - } - flagShowFlipButtons = b; - if (initDone) { - skyGui->updateBarsPos(); - } -} - - -// Define whether the button toggling nebulae backround images should be visible -void StelGui::setFlagShowNebulaBackgroundButton(bool b) -{ - if (b==true) { - if (btShowNebulaeBackground==NULL) { - // Create the nebulae background button - QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png"); - btShowNebulaeBackground = new StelButton(NULL, QPixmap(":/graphicGui/btDSS-on.png"), QPixmap(":/graphicGui/btDSS-off.png"), pxmapGlow32x32, "actionShow_DSS"); - } - getButtonBar()->addButton(btShowNebulaeBackground, "040-nebulaeGroup"); - } else { - getButtonBar()->hideButton("actionShow_DSS"); - } - flagShowNebulaBackgroundButton = b; -} - -void StelGui::setVisible(bool b) -{ - skyGui->setVisible(b); -} - -bool StelGui::getVisible() const -{ - return skyGui->isVisible(); -} - -bool StelGui::isCurrentlyUsed() const -{ - return skyGui->buttonBar->isUnderMouse() || skyGui->winBar->isUnderMouse(); -} - -void setScriptKeys() -{ -} - -void setNormalKeys() -{ -} - -void StelGui::setInfoTextFilters(const StelObject::InfoStringGroup& aflags) -{ - skyGui->infoPanel->setInfoTextFilters(aflags); -} - -const StelObject::InfoStringGroup& StelGui::getInfoTextFilters() const -{ - return skyGui->infoPanel->getInfoTextFilters(); -} - -BottomStelBar* StelGui::getButtonBar() const -{ - return skyGui->buttonBar; -} - -LeftStelBar* StelGui::getWindowsButtonBar() const -{ - return skyGui->winBar; -} - -SkyGui* StelGui::getSkyGui() const -{ - return skyGui; -} - -bool StelGui::getAutoHideHorizontalButtonBar() const -{ - return skyGui->autoHideHorizontalButtonBar; -} - -void StelGui::setAutoHideHorizontalButtonBar(bool b) -{ - skyGui->autoHideHorizontalButtonBar=b; -} - -bool StelGui::getAutoHideVerticalButtonBar() const -{ - return skyGui->autoHideVerticalButtonBar; -} - -void StelGui::setAutoHideVerticalButtonBar(bool b) -{ - skyGui->autoHideVerticalButtonBar=b; -} - -bool StelGui::getFlagShowFlipButtons() const -{ - return flagShowFlipButtons; -} - -bool StelGui::getFlagShowNebulaBackgroundButton() const -{ - return flagShowNebulaBackgroundButton; -} - -bool StelGui::initComplete(void) const -{ - return initDone; -} - -void StelGui::forceRefreshGui() -{ - skyGui->updateBarsPos(); -} - -#ifndef DISABLE_SCRIPTING -void StelGui::scriptStarted() -{ - setScriptKeys(true); -} - -void StelGui::scriptStopped() -{ - setScriptKeys(false); -} -#endif - -void StelGui::setGuiVisible(bool b) -{ - setVisible(b); -} - -StelAction* StelGui::getAction(const QString& actionName) -{ - return StelApp::getInstance().getStelActionManager()->findAction(actionName); -} - -/* ****************************************************************************************************************** */ -#if 0 -#pragma mark - -#pragma mark Process changes from the ConstellationMgr -#endif -/* ****************************************************************************************************************** */ - -/* ****************************************************************************************************************** */ -#if 0 -#pragma mark - -#pragma mark Process changes from the GridLinesMgr -#endif -/* ****************************************************************************************************************** */ - -/* ****************************************************************************************************************** */ -#if 0 -#pragma mark - -#pragma mark Process changes from the GridLinesMgr -#endif -/* ****************************************************************************************************************** */ - - -void StelGui::copySelectedObjectInfo(void) -{ - QGuiApplication::clipboard()->setText(skyGui->infoPanel->getSelectedText()); -} diff --git a/src/gui/StelGui.hpp b/src/gui/StelGui.hpp deleted file mode 100644 index db7f2e3..0000000 --- a/src/gui/StelGui.hpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _STELGUI_HPP_ -#define _STELGUI_HPP_ - -#include "StelModule.hpp" -#include "StelObject.hpp" -#include "StelGuiBase.hpp" -#include "StelStyle.hpp" - -#include - -class QGraphicsSceneMouseEvent; -class QTimeLine; -class StelButton; -class BottomStelBar; -class InfoPanel; -class ConfigurationDialog; -class DateTimeDialog; -class HelpDialog; -class LocationDialog; -class SearchDialog; -class ViewDialog; -class ShortcutsDialog; -#ifdef ENABLE_SCRIPT_CONSOLE -class ScriptConsole; -#endif - -//! @class StelGui -//! Main class for the GUI based on QGraphicView. -//! It manages the various qt configuration windows, the buttons bars, the list of shortcuts. -class StelGui : public QObject, public StelGuiBase -{ - Q_OBJECT - Q_PROPERTY(bool visible READ getVisible WRITE setVisible) - Q_PROPERTY(bool autoHideHorizontalButtonBar READ getAutoHideHorizontalButtonBar WRITE setAutoHideHorizontalButtonBar) - Q_PROPERTY(bool autoHideVerticalButtonBar READ getAutoHideVerticalButtonBar WRITE setAutoHideVerticalButtonBar) - -public: - friend class ViewDialog; - - StelGui(); - virtual ~StelGui(); - - /////////////////////////////////////////////////////////////////////////// - // Methods defined in the StelModule class - //! Initialize the StelGui object. - virtual void init(QGraphicsWidget* topLevelGraphicsWidget); - void update(); - - StelStyle getStelStyle() const {return currentStelStyle;} - - /////////////////////////////////////////////////////////////////////////// - // Methods specific to the StelGui class - //! Load a Qt style sheet to define the widgets style - void loadStyle(const QString& fileName); - - //! Get the button bar at the bottom of the screensetDateTime - BottomStelBar* getButtonBar() const; - - //! Get the button bar of the left of the screen - class LeftStelBar* getWindowsButtonBar() const; - - //! Get the SkyGui instance (useful for adding other interface elements). - //! It will return a valid object only if called after init(). - class SkyGui* getSkyGui() const; - - //! Get whether the buttons toggling image flip are visible - bool getFlagShowFlipButtons() const; - - //! Get whether the button toggling nebulae background is visible - bool getFlagShowNebulaBackgroundButton() const; - - //! returns true if the gui has complted init process. - bool initComplete(void) const; - -#ifdef ENABLE_SCRIPT_CONSOLE - ScriptConsole* getScriptConsole() {return scriptConsole;} -#endif - - //! Used to force a refreshing of the GUI elements such as the button bars. - virtual void forceRefreshGui(); - - virtual void setVisible(bool b); - - virtual bool getVisible() const; - - virtual bool isCurrentlyUsed() const; - - virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags); - virtual const StelObject::InfoStringGroup& getInfoTextFilters() const; - -public slots: - //! Define whether the buttons toggling image flip should be visible - void setFlagShowFlipButtons(bool b); - - //! Define whether the button toggling nebulae background should be visible - void setFlagShowNebulaBackgroundButton(bool b); - - //! Get the auto-hide status of the horizontal toolbar. - bool getAutoHideHorizontalButtonBar() const; - //! Set the auto-hide status of the horizontal toolbar. - //! When set to true, the horizontal toolbar will auto-hide itself, only - //! making an appearance when the mouse is nearby. When false, it will - //! remain on screen. - //! @param b to hide or not to hide - void setAutoHideHorizontalButtonBar(bool b); - - //! Get the auto-hide status of the vertical toolbar. - bool getAutoHideVerticalButtonBar() const; - //! Set the auto-hide status of the vertical toolbar. - //! When set to true, the vertical toolbar will auto-hide itself, only - //! making an appearance when the mouse is nearby. When false, it will - //! remain on screen. - //! @param b to hide or not to hide - void setAutoHideVerticalButtonBar(bool b); - -#ifndef DISABLE_SCRIPTING - //! change keys when a script is running / not running - void setScriptKeys(bool b); - void increaseScriptSpeed(); - void decreaseScriptSpeed(); - void setRealScriptSpeed(); - void stopScript(); - void pauseScript(); - void resumeScript(); -#endif - - //! Hide or show the GUI. Public so it can be called from scripts. - void setGuiVisible(bool); - -private slots: - void reloadStyle(); -#ifndef DISABLE_SCRIPTING - void scriptStarted(); - void scriptStopped(); -#endif - //! Load color scheme from the given ini file and section name - void setStelStyle(const QString& section); - void quit(); - void updateI18n(); - void copySelectedObjectInfo(void); - -private: - //! convenience method to find an action in the StelActionMgr. - StelAction* getAction(const QString& actionName); - - QGraphicsWidget* topLevelGraphicsWidget; - - class SkyGui* skyGui; - - StelButton* buttonTimeRewind; - StelButton* buttonTimeRealTimeSpeed; - StelButton* buttonTimeCurrent; - StelButton* buttonTimeForward; - - StelButton* buttonGotoSelectedObject; - - LocationDialog* locationDialog; - HelpDialog* helpDialog; - DateTimeDialog* dateTimeDialog; - SearchDialog* searchDialog; - ViewDialog* viewDialog; - ShortcutsDialog* shortcutsDialog; - ConfigurationDialog* configurationDialog; -#ifdef ENABLE_SCRIPT_CONSOLE - ScriptConsole* scriptConsole; -#endif - - bool flagShowFlipButtons; - StelButton* flipVert; - StelButton* flipHoriz; - - bool flagShowNebulaBackgroundButton; - StelButton* btShowNebulaeBackground; - - bool initDone; - bool guiHidden; - - QSizeF savedProgressBarSize; - - // Currently used StelStyle - StelStyle currentStelStyle; -}; - -//! Allow to load the GUI as a static plugin -class StelStandardGuiPluginInterface : public QObject, public StelGuiPluginInterface -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "stellarium.StelGuiPluginInterface/1.0") - Q_INTERFACES(StelGuiPluginInterface) -public: - virtual class StelGuiBase* getStelGuiBase() const; -}; - -#endif // _STELGUI_HPP_ diff --git a/src/gui/StelGuiItems.cpp b/src/gui/StelGuiItems.cpp deleted file mode 100644 index 3bf74ca..0000000 --- a/src/gui/StelGuiItems.cpp +++ /dev/null @@ -1,825 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelProjector.hpp" - -#include "StelUtils.hpp" -#include "StelGuiItems.hpp" -#include "StelLocaleMgr.hpp" -#include "StelLocation.hpp" -#include "StelMovementMgr.hpp" -#include "StelActionMgr.hpp" -#include "StelProgressController.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_BUILD -#define round(dbl) dbl >= 0.0 ? (int)(dbl + 0.5) : ((dbl - (double)(int)dbl) <= -0.5 ? (int)dbl : (int)(dbl - 0.5)) -#endif - -void StelButton::initCtor(const QPixmap& apixOn, - const QPixmap& apixOff, - const QPixmap& apixNoChange, - const QPixmap& apixHover, - StelAction* aaction, - bool noBackground, - bool isTristate) -{ - pixOn = apixOn; - pixOff = apixOff; - pixHover = apixHover; - pixNoChange = apixNoChange; - noBckground = noBackground; - isTristate_ = isTristate; - opacity = 1.; - hoverOpacity = 0.; - action = aaction; - - Q_ASSERT(!pixOn.isNull()); - Q_ASSERT(!pixOff.isNull()); - - if (isTristate_) - { - Q_ASSERT(!pixNoChange.isNull()); - } - - setShapeMode(QGraphicsPixmapItem::BoundingRectShape); - setAcceptHoverEvents(true); - timeLine = new QTimeLine(250, this); - timeLine->setCurveShape(QTimeLine::EaseOutCurve); - connect(timeLine, SIGNAL(valueChanged(qreal)), - this, SLOT(animValueChanged(qreal))); - - if (action!=NULL) - { - if (action->isCheckable()) - { - setChecked(action->isChecked()); - connect(action, SIGNAL(toggled(bool)), this, SLOT(setChecked(bool))); - connect(this, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool))); - } - else - { - QObject::connect(this, SIGNAL(triggered()), action, SLOT(trigger())); - } - } -} - -StelButton::StelButton(QGraphicsItem* parent, - const QPixmap& apixOn, - const QPixmap& apixOff, - const QPixmap& apixHover, - StelAction *aaction, - bool noBackground) : - QGraphicsPixmapItem(apixOff, parent) -{ - initCtor(apixOn, apixOff, QPixmap(), apixHover, aaction, noBackground, false); -} - -StelButton::StelButton(QGraphicsItem* parent, - const QPixmap& apixOn, - const QPixmap& apixOff, - const QPixmap& apixNoChange, - const QPixmap& apixHover, - const QString& aactionId, - bool noBackground, - bool isTristate) : - QGraphicsPixmapItem(apixOff, parent) -{ - StelAction *action = StelApp::getInstance().getStelActionManager()->findAction(aactionId); - initCtor(apixOn, apixOff, apixNoChange, apixHover, action, noBackground, isTristate); -} - -StelButton::StelButton(QGraphicsItem* parent, - const QPixmap& apixOn, - const QPixmap& apixOff, - const QPixmap& apixHover, - const QString& aactionId, - bool noBackground) - :QGraphicsPixmapItem(apixOff, parent) -{ - StelAction *action = StelApp::getInstance().getStelActionManager()->findAction(aactionId); - initCtor(apixOn, apixOff, QPixmap(), apixHover, action, noBackground, false); -} - - -int StelButton::toggleChecked(int checked) -{ - if (!isTristate_) - checked = !!!checked; - else - { - if (++checked > ButtonStateNoChange) - checked = ButtonStateOff; - } - return checked; -} -void StelButton::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ - QGraphicsItem::mousePressEvent(event); - event->accept(); - setChecked(toggleChecked(checked)); - emit(toggled(checked)); - emit(triggered()); -} - -void StelButton::hoverEnterEvent(QGraphicsSceneHoverEvent*) -{ - timeLine->setDirection(QTimeLine::Forward); - if (timeLine->state()!=QTimeLine::Running) - timeLine->start(); - - emit(hoverChanged(true)); -} - -void StelButton::hoverLeaveEvent(QGraphicsSceneHoverEvent*) -{ - timeLine->setDirection(QTimeLine::Backward); - if (timeLine->state()!=QTimeLine::Running) - timeLine->start(); - emit(hoverChanged(false)); -} - -void StelButton::mouseReleaseEvent(QGraphicsSceneMouseEvent*) -{ - if (action!=NULL && !action->isCheckable()) - setChecked(toggleChecked(checked)); -} - -void StelButton::updateIcon() -{ - if (opacity < 0.) - opacity = 0; - QPixmap pix(pixOn.size()); - pix.fill(QColor(0,0,0,0)); - QPainter painter(&pix); - painter.setOpacity(opacity); - if (!pixBackground.isNull() && noBckground==false) - painter.drawPixmap(0, 0, pixBackground); - painter.drawPixmap(0, 0, - (isTristate_ && checked == ButtonStateNoChange) ? (pixNoChange) : - (checked == ButtonStateOn) ? (pixOn) : - /* (checked == ButtonStateOff) ? */ (pixOff)); - if (hoverOpacity > 0) - { - painter.setOpacity(hoverOpacity * opacity); - painter.drawPixmap(0, 0, pixHover); - } - setPixmap(pix); -} - -void StelButton::animValueChanged(qreal value) -{ - hoverOpacity = value; - updateIcon(); -} - -void StelButton::setChecked(int b) -{ - checked=b; - updateIcon(); -} - -void StelButton::setBackgroundPixmap(const QPixmap &newBackground) -{ - pixBackground = newBackground; - updateIcon(); -} - -LeftStelBar::LeftStelBar(QGraphicsItem* parent) : QGraphicsItem(parent) -{ - // Create the help label - helpLabel = new QGraphicsSimpleTextItem("", this); - helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1))); -} - -LeftStelBar::~LeftStelBar() -{ -} - -void LeftStelBar::addButton(StelButton* button) -{ - double posY = 0; - if (QGraphicsItem::childItems().size()!=0) - { - const QRectF& r = childrenBoundingRect(); - posY += r.bottom()-1; - } - button->setParentItem(this); - button->prepareGeometryChange(); // could possibly be removed when qt 4.6 become stable - button->setPos(0., round(posY+10.5)); - - connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverChanged(bool))); -} - -void LeftStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) -{ -} - -QRectF LeftStelBar::boundingRect() const -{ - return childrenBoundingRect(); -} - -QRectF LeftStelBar::boundingRectNoHelpLabel() const -{ - // Re-use original Qt code, just remove the help label - QRectF childRect; - foreach (QGraphicsItem *child, QGraphicsItem::childItems()) - { - if (child==helpLabel) - continue; - QPointF childPos = child->pos(); - QTransform matrix = child->transform() * QTransform().translate(childPos.x(), childPos.y()); - childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect()); - } - return childRect; -} - - -// Update the help label when a button is hovered -void LeftStelBar::buttonHoverChanged(bool b) -{ - StelButton* button = qobject_cast(sender()); - Q_ASSERT(button); - if (b==true) - { - if (button->action) - { - QString tip(button->action->getText()); - QString shortcut(button->action->getShortcut().toString(QKeySequence::NativeText)); - if (!shortcut.isEmpty()) - { - //XXX: this should be unnecessary since we used NativeText. - if (shortcut == "Space") - shortcut = q_("Space"); - tip += " [" + shortcut + "]"; - } - helpLabel->setText(tip); - helpLabel->setPos(round(boundingRectNoHelpLabel().width()+15.5),round(button->pos().y()+button->pixmap().size().height()/2-8)); - } - } - else - { - helpLabel->setText(""); - } -} - -// Set the pen for all the sub elements -void LeftStelBar::setColor(const QColor& c) -{ - helpLabel->setBrush(c); -} - -BottomStelBar::BottomStelBar(QGraphicsItem* parent, - const QPixmap& pixLeft, - const QPixmap& pixRight, - const QPixmap& pixMiddle, - const QPixmap& pixSingle) : - QGraphicsItem(parent), - pixBackgroundLeft(pixLeft), - pixBackgroundRight(pixRight), - pixBackgroundMiddle(pixMiddle), - pixBackgroundSingle(pixSingle) -{ - // The text is dummy just for testing - datetime = new QGraphicsSimpleTextItem("2008-02-06 17:33", this); - location = new QGraphicsSimpleTextItem("Munich, Earth, 500m", this); - fov = new QGraphicsSimpleTextItem("FOV 43.45", this); - fps = new QGraphicsSimpleTextItem("43.2 FPS", this); - - // Create the help label - helpLabel = new QGraphicsSimpleTextItem("", this); - helpLabel->setBrush(QBrush(QColor::fromRgbF(1,1,1,1))); - - QColor color = QColor::fromRgbF(1,1,1,1); - setColor(color); - - datetime->font().setPixelSize(12); - location->font().setPixelSize(12); - fov->font().setPixelSize(12); - fps->font().setPixelSize(12); - - flagShowTime = true; - flagShowLocation = true; -} - -BottomStelBar::~BottomStelBar() -{ - // Remove currently hidden buttons which are not delete by a parent element - for (QMap::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter) - { - foreach (StelButton* b, iter.value().elems) - { - if (b->parentItem()==0) - { - delete b; - b=NULL; - } - } - } -} - -void BottomStelBar::addButton(StelButton* button, const QString& groupName, const QString& beforeActionName) -{ - QList& g = buttonGroups[groupName].elems; - bool done = false; - for (int i=0; iaction && g[i]->action->objectName()==beforeActionName) - { - g.insert(i, button); - done = true; - break; - } - } - if (done == false) - g.append(button); - - button->setVisible(true); - button->setParentItem(this); - updateButtonsGroups(); - - connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverChanged(bool))); -} - -StelButton* BottomStelBar::hideButton(const QString& actionName) -{ - QString gName; - StelButton* bToRemove = NULL; - for (QMap::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter) - { - int i=0; - foreach (StelButton* b, iter.value().elems) - { - if (b->action && b->action->objectName()==actionName) - { - gName = iter.key(); - bToRemove = b; - iter.value().elems.removeAt(i); - break; - } - ++i; - } - } - if (bToRemove == NULL) - return NULL; - if (buttonGroups[gName].elems.size() == 0) - { - buttonGroups.remove(gName); - } - // Cannot really delete because some part of the GUI depend on the presence of some buttons - // so just make invisible - bToRemove->setParentItem(NULL); - bToRemove->setVisible(false); - updateButtonsGroups(); - return bToRemove; -} - -// Set the margin at the left and right of a button group in pixels -void BottomStelBar::setGroupMargin(const QString& groupName, int left, int right) -{ - if (!buttonGroups.contains(groupName)) - return; - buttonGroups[groupName].leftMargin = left; - buttonGroups[groupName].rightMargin = right; - updateButtonsGroups(); -} - -//! Change the background of a group -void BottomStelBar::setGroupBackground(const QString& groupName, - const QPixmap& pixLeft, - const QPixmap& pixRight, - const QPixmap& pixMiddle, - const QPixmap& pixSingle) -{ - - if (!buttonGroups.contains(groupName)) - return; - - buttonGroups[groupName].pixBackgroundLeft = new QPixmap(pixLeft); - buttonGroups[groupName].pixBackgroundRight = new QPixmap(pixRight); - buttonGroups[groupName].pixBackgroundMiddle = new QPixmap(pixMiddle); - buttonGroups[groupName].pixBackgroundSingle = new QPixmap(pixSingle); - updateButtonsGroups(); -} - -QRectF BottomStelBar::getButtonsBoundingRect() const -{ - // Re-use original Qt code, just remove the help label - QRectF childRect; - bool hasBtn = false; - foreach (QGraphicsItem *child, QGraphicsItem::childItems()) - { - if (qgraphicsitem_cast(child)==0) - continue; - hasBtn = true; - QPointF childPos = child->pos(); - QTransform matrix = child->transform() * QTransform().translate(childPos.x(), childPos.y()); - childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect()); - } - - if (hasBtn) - return QRectF(0, 0, childRect.width()-1, childRect.height()-1); - else - return QRectF(); -} - -void BottomStelBar::updateButtonsGroups() -{ - double x = 0; - double y = datetime->boundingRect().height() + 3; - for (QMap::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter) - { - ButtonGroup& group = iter.value(); - QList& buttons = group.elems; - if (buttons.empty()) - continue; - x += group.leftMargin; - int n = 0; - foreach (StelButton* b, buttons) - { - // We check if the group has its own background if not the case - // We apply a default background. - if (n == 0) - { - if (buttons.size() == 1) - { - if (group.pixBackgroundSingle == NULL) - b->setBackgroundPixmap(pixBackgroundSingle); - else - b->setBackgroundPixmap(*group.pixBackgroundSingle); - } - else - { - if (group.pixBackgroundLeft == NULL) - b->setBackgroundPixmap(pixBackgroundLeft); - else - b->setBackgroundPixmap(*group.pixBackgroundLeft); - } - } - else if (n == buttons.size()-1) - { - if (buttons.size() != 1) - { - if (group.pixBackgroundSingle == NULL) - b->setBackgroundPixmap(pixBackgroundSingle); - else - b->setBackgroundPixmap(*group.pixBackgroundSingle); - } - if (group.pixBackgroundRight == NULL) - b->setBackgroundPixmap(pixBackgroundRight); - else - b->setBackgroundPixmap(*group.pixBackgroundRight); - } - else - { - if (group.pixBackgroundMiddle == NULL) - b->setBackgroundPixmap(pixBackgroundMiddle); - else - b->setBackgroundPixmap(*group.pixBackgroundMiddle); - } - // Update the button pixmap - b->animValueChanged(0.); - b->setPos(x, y); - x += b->getButtonPixmapWidth(); - ++n; - } - x+=group.rightMargin; - } - updateText(true); -} - -// Make sure to avoid any change if not necessary to avoid triggering useless redraw -void BottomStelBar::updateText(bool updatePos) -{ - StelCore* core = StelApp::getInstance().getCore(); - double jd = core->getJDay(); - double deltaT = 0.; - double sigma = -1.; - QString sigmaInfo = ""; - QString validRangeInfo = ""; - bool displayDeltaT = false; - if (core->getCurrentLocation().planetName.contains("Earth")) - { - deltaT = core->getDeltaT(jd); - displayDeltaT = true; - sigma = StelUtils::getDeltaTStandardError(jd); - core->getCurrentDeltaTAlgorithmValidRange(jd, &validRangeInfo); - } - - // Add in a DeltaT correction. Divide DeltaT by 86400 to convert from seconds to days. - QString newDate = flagShowTime ? StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(jd-deltaT/86400.) +" " - +StelApp::getInstance().getLocaleMgr().getPrintableTimeLocal(jd-deltaT/86400.) : " "; - if (datetime->text()!=newDate) - { - updatePos = true; - datetime->setText(newDate); - if (displayDeltaT && core->getCurrentDeltaTAlgorithm()!=StelCore::WithoutCorrection) - { - if (sigma>0) - sigmaInfo = QString("; %1(%2T) = %3s").arg(QChar(0x03c3)).arg(QChar(0x0394)).arg(sigma, 3, 'f', 1); - - if (std::abs(deltaT)>60.) - datetime->setToolTip(QString("%1T = %2 (%3s)%6 [n-dot @ -23.8946\"/cy%4%5]").arg(QChar(0x0394)).arg(StelUtils::hoursToHmsStr(deltaT/3600.)).arg(deltaT, 5, 'f', 2).arg(QChar(0x00B2)).arg(sigmaInfo).arg(validRangeInfo)); - else - datetime->setToolTip(QString("%1T = %2s%5 [n-dot @ -23.8946\"/cy%3%4]").arg(QChar(0x0394)).arg(deltaT, 3, 'f', 3).arg(QChar(0x00B2)).arg(sigmaInfo).arg(validRangeInfo)); - } - else - datetime->setToolTip(""); - } - - QString newLocation = ""; - const StelLocation* loc = &core->getCurrentLocation(); - if (flagShowLocation && !loc->name.isEmpty()) - { - newLocation = q_(loc->planetName) +", "+loc->name + ", "+q_("%1m").arg(loc->altitude); - } - if (flagShowLocation && loc->name.isEmpty()) - { - newLocation = q_(loc->planetName)+", " - +StelUtils::radToDmsStr(loc->latitude)+", " - +StelUtils::radToDmsStr(loc->longitude); - } - if (location->text()!=newLocation) - { - updatePos = true; - location->setText(newLocation); - float lat = core->getCurrentLocation().latitude; - float lon = core->getCurrentLocation().longitude; - QString latStr, lonStr, pm; - if (lat >= 0) - pm = "N"; - else - pm = "S"; - latStr = QString("%1%2%3").arg(pm).arg(lat).arg(QChar(0x00B0)); - if (lat >= 0) - pm = "E"; - else - pm = "W"; - lonStr = QString("%1%2%3").arg(pm).arg(lon).arg(QChar(0x00B0)); - location->setToolTip(QString("%1 %2").arg(latStr).arg(lonStr)); - } - - QSettings* confSettings = StelApp::getInstance().getSettings(); - QString str; - QTextStream wos(&str); - wos << "FOV " << qSetRealNumberPrecision(3) << core->getMovementMgr()->getCurrentFov() << QChar(0x00B0); - if (fov->text()!=str) - { - updatePos = true; - if (confSettings->value("gui/flag_show_fov", true).toBool()) - { - fov->setText(str); - } - else - { - fov->setText(""); - } - } - - str=""; - QTextStream wos2(&str); - wos2 << qSetRealNumberPrecision(3) << StelApp::getInstance().getFps() << " FPS"; - if (fps->text()!=str) - { - updatePos = true; - if (confSettings->value("gui/flag_show_fps", true).toBool()) - { - fps->setText(str); - } - else - { - fps->setText(""); - } - } - - if (updatePos) - { - QRectF rectCh = getButtonsBoundingRect(); - location->setPos(0, 0); - int dtp = rectCh.right()-datetime->boundingRect().width()-5; - if ((dtp%2) == 1) dtp--; // make even pixel - datetime->setPos(dtp,0); - fov->setPos(datetime->x()-200, 0); - fps->setPos(datetime->x()-95, 0); - } -} - -void BottomStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) -{ - updateText(); -} - -QRectF BottomStelBar::boundingRect() const -{ - if (QGraphicsItem::childItems().size()==0) - return QRectF(); - const QRectF& r = childrenBoundingRect(); - return QRectF(0, 0, r.width()-1, r.height()-1); -} - -QRectF BottomStelBar::boundingRectNoHelpLabel() const -{ - // Re-use original Qt code, just remove the help label - QRectF childRect; - foreach (QGraphicsItem *child, QGraphicsItem::childItems()) - { - if (child==helpLabel) - continue; - QPointF childPos = child->pos(); - QTransform matrix = child->transform() * QTransform().translate(childPos.x(), childPos.y()); - childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect()); - } - return childRect; -} - -// Set the pen for all the sub elements -void BottomStelBar::setColor(const QColor& c) -{ - datetime->setBrush(c); - location->setBrush(c); - fov->setBrush(c); - fps->setBrush(c); - helpLabel->setBrush(c); -} - -// Update the help label when a button is hovered -void BottomStelBar::buttonHoverChanged(bool b) -{ - StelButton* button = qobject_cast(sender()); - Q_ASSERT(button); - if (b==true) - { - StelAction* action = button->action; - if (action) - { - QString tip(action->getText()); - QString shortcut(action->getShortcut().toString(QKeySequence::NativeText)); - if (!shortcut.isEmpty()) - { - //XXX: this should be unnecessary since we used NativeText. - if (shortcut == "Space") - shortcut = q_("Space"); - tip += " [" + shortcut + "]"; - } - helpLabel->setText(tip); - //helpLabel->setPos(button->pos().x()+button->pixmap().size().width()/2,-27); - helpLabel->setPos(20,-27); - } - } - else - { - helpLabel->setText(""); - } -} - -StelBarsPath::StelBarsPath(QGraphicsItem* parent) : QGraphicsPathItem(parent) -{ - roundSize = 6; - QPen aPen(QColor::fromRgbF(0.7,0.7,0.7,0.5)); - aPen.setWidthF(1.); - setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, 0.2))); - setPen(aPen); -} - -void StelBarsPath::updatePath(BottomStelBar* bot, LeftStelBar* lef) -{ - QPainterPath newPath; - QPointF p = lef->pos(); - QRectF r = lef->boundingRectNoHelpLabel(); - QPointF p2 = bot->pos(); - QRectF r2 = bot->boundingRectNoHelpLabel(); - - newPath.moveTo(p.x()-roundSize, p.y()-roundSize); - newPath.lineTo(p.x()+r.width(),p.y()-roundSize); - newPath.arcTo(p.x()+r.width()-roundSize, p.y()-roundSize, 2.*roundSize, 2.*roundSize, 90, -90); - newPath.lineTo(p.x()+r.width()+roundSize, p2.y()-roundSize); - newPath.lineTo(p2.x()+r2.width(),p2.y()-roundSize); - newPath.arcTo(p2.x()+r2.width()-roundSize, p2.y()-roundSize, 2.*roundSize, 2.*roundSize, 90, -90); - newPath.lineTo(p2.x()+r2.width()+roundSize, p2.y()+r2.height()+roundSize); - newPath.lineTo(p.x()-roundSize, p2.y()+r2.height()+roundSize); - setPath(newPath); -} - -void StelBarsPath::setBackgroundOpacity(double opacity) -{ - setBrush(QBrush(QColor::fromRgbF(0.22, 0.22, 0.23, opacity))); -} - -StelProgressBarMgr::StelProgressBarMgr(QGraphicsItem*) -{ - setLayout(new QGraphicsLinearLayout(Qt::Vertical)); -} -/* -QRectF StelProgressBarMgr::boundingRect() const -{ - if (QGraphicsItem::children().size()==0) - return QRectF(); - const QRectF& r = childrenBoundingRect(); - return QRectF(0, 0, r.width()-1, r.height()-1); -}*/ - -void StelProgressBarMgr::addProgressBar(const StelProgressController* p) -{ - QProgressBar* pb = new QProgressBar(); - pb->setFixedHeight(25); - pb->setFixedWidth(200); - pb->setTextVisible(true); - pb->setValue(p->getValue()); - pb->setMinimum(p->getMin()); - pb->setMaximum(p->getMax()); - pb->setFormat(p->getFormat()); - QGraphicsProxyWidget* pbProxy = new QGraphicsProxyWidget(); - pbProxy->setWidget(pb); - pbProxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - pbProxy->setZValue(150); - static_cast(layout())->addItem(pbProxy); - allBars.insert(p, pb); - pb->setVisible(true); - - connect(p, SIGNAL(changed()), this, SLOT(oneBarChanged())); -} - -void StelProgressBarMgr::removeProgressBar(const StelProgressController *p) -{ - QProgressBar* pb = allBars[p]; - pb->deleteLater(); - allBars.remove(p); -} - -void StelProgressBarMgr::oneBarChanged() -{ - const StelProgressController *p = static_cast(QObject::sender()); - QProgressBar* pb = allBars[p]; - pb->setValue(p->getValue()); - pb->setMinimum(p->getMin()); - pb->setMaximum(p->getMax()); - pb->setFormat(p->getFormat()); -} - -CornerButtons::CornerButtons(QGraphicsItem*) : lastOpacity(10) -{ -} - -void CornerButtons::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) -{ - // Do nothing. Just paint the child widgets -} - -QRectF CornerButtons::boundingRect() const -{ - if (QGraphicsItem::childItems().size()==0) - return QRectF(); - const QRectF& r = childrenBoundingRect(); - return QRectF(0, 0, r.width()-1, r.height()-1); -} - -void CornerButtons::setOpacity(double opacity) -{ - if (opacity<=0. && lastOpacity<=0.) - return; - lastOpacity = opacity; - if (QGraphicsItem::childItems().size()==0) - return; - foreach (QGraphicsItem *child, QGraphicsItem::childItems()) - { - StelButton* sb = qgraphicsitem_cast(child); - Q_ASSERT(sb!=NULL); - sb->setOpacity(opacity); - } -} diff --git a/src/gui/StelGuiItems.hpp b/src/gui/StelGuiItems.hpp deleted file mode 100644 index 4b968d9..0000000 --- a/src/gui/StelGuiItems.hpp +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _STELGUIITEMS_HPP_ -#define _STELGUIITEMS_HPP_ - -#include -#include -#include -#include - -class QGraphicsSceneMouseEvent; -class QTimeLine; -class QGraphicsTextItem; -class QTimer; -class StelProgressController; -class QProgressBar; - -// Progess bars in the lower right corner -class StelProgressBarMgr : public QGraphicsWidget -{ - Q_OBJECT -public: - StelProgressBarMgr(QGraphicsItem* parent); - -public slots: - void addProgressBar(const StelProgressController *p); - void removeProgressBar(const StelProgressController *p); - void oneBarChanged(); -private: - QMap allBars; -}; - -// Buttons in the bottom left corner -class CornerButtons : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) -public: - CornerButtons(QGraphicsItem* parent=NULL); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual QRectF boundingRect() const; - void setOpacity(double opacity); -private: - mutable double lastOpacity; -}; - -//! A Button Graphicsitem for use in Stellarium's graphic widgets -class StelButton : public QObject, public QGraphicsPixmapItem -{ - friend class BottomStelBar; - friend class LeftStelBar; - Q_OBJECT -public: - //! Constructor - //! @param parent the parent item - //! @param pixOn the pixmap to display when the button is toggled - //! @param pixOff the pixmap to display when the button is not toggled - //! @param pixHover a pixmap slowly blended when mouse is over the button - //! @param action the associated action. Connections are automatically done with the signals if relevant. - //! @param noBackground define whether the button background image have to be used - StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixmap& pixOff, - const QPixmap& pixHover=QPixmap(), - class StelAction* action=NULL, bool noBackground=false); - - StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixmap& pixOff, - const QPixmap& pixHover=QPixmap(), - const QString& actionId=QString(), bool noBackground=false); - //! Constructor - //! @param parent the parent item - //! @param pixOn the pixmap to display when the button is toggled - //! @param pixOff the pixmap to display when the button is not toggled - //! @param pixNoChange the pixmap to display when the button state of a tristate is not changed - //! @param pixHover a pixmap slowly blended when mouse is over the button - //! @param actionId the associated action. Connections are automatically done with the signals if relevant. - //! @param noBackground define whether the button background image have to be used - //! @param isTristate define whether the button is a tristate or an on/off button - StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixmap& pixOff, const QPixmap& pixNoChange, - const QPixmap& pixHover=QPixmap(), - const QString& actionId=QString(), bool noBackground=false, bool isTristate=true); - - //! Button states - enum {ButtonStateOff = 0, ButtonStateOn = 1, ButtonStateNoChange = 2}; - - //! Get whether the button is checked - int isChecked() const {return checked;} - - //! Get the width of the button image. - //! The width is based on pixOn. - int getButtonPixmapWidth() const {return pixOn.width();} - - //! Set the button opacity - void setOpacity(double v) {opacity=v; updateIcon();} - - //! Set the background pixmap of the button. - void setBackgroundPixmap(const QPixmap& newBackground); - -signals: - //! Triggered when the button state changes - void toggled(bool); - //! Triggered when the button state changes - void triggered(); - //! Emitted when the hover state change - //! @param b true if the mouse entered the button - void hoverChanged(bool b); - -public slots: - //! set whether the button is checked - void setChecked(int b); - void setChecked(bool b) { setChecked((int)b); } - -protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); -private slots: - void animValueChanged(qreal value); -private: - void initCtor(const QPixmap& apixOn, - const QPixmap& apixOff, - const QPixmap& apixNoChange, - const QPixmap& apixHover, - StelAction* aaction, - bool noBackground, - bool isTristate); - void updateIcon(); - int toggleChecked(int); - - QPixmap pixOn; - QPixmap pixOff; - QPixmap pixNoChange; - QPixmap pixHover; - QPixmap pixBackground; - - int checked; - - QTimeLine* timeLine; - class StelAction* action; - bool noBckground; - bool isTristate_; - double opacity; - double hoverOpacity; -}; - -// The button bar on the left containing windows toggle buttons -class LeftStelBar : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem); -public: - LeftStelBar(QGraphicsItem* parent); - ~LeftStelBar(); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual QRectF boundingRect() const; - void addButton(StelButton* button); - QRectF boundingRectNoHelpLabel() const; - //! Set the color for all the sub elements - void setColor(const QColor& c); -private slots: - //! Update the help label when a button is hovered - void buttonHoverChanged(bool b); -private: - QTimeLine* hideTimeLine; - QGraphicsSimpleTextItem* helpLabel; -}; - -// The button bar on the bottom containing actions toggle buttons -class BottomStelBar : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem); -public: - BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft=QPixmap(), const QPixmap& pixRight=QPixmap(), const QPixmap& pixMiddle=QPixmap(), const QPixmap& pixSingle=QPixmap()); - virtual ~BottomStelBar(); - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual QRectF boundingRect() const; - QRectF boundingRectNoHelpLabel() const; - - //! Add a button in a group in the button bar. Group are displayed in alphabetic order. - //! @param button the button to add - //! @param groupName the name of the button group to which the button belongs to. If the group doesn't exist yet, a new one is created. - //! @param beforeActionName insert the button before the button associated to the given action. If the action doesn't exist, insert it at the end of the group. - void addButton(StelButton* button, const QString& groupName="defaultGroup", const QString& beforeActionName=""); - //! Hide the button associated with the action of the passed name - StelButton* hideButton(const QString& actionName); - - //! Set the margin at the left and right of a button group in pixels - void setGroupMargin(const QString& groupName, int left, int right); - - //! Set the background of a group - void setGroupBackground(const QString& groupName, const QPixmap& pixLeft=QPixmap(), - const QPixmap& pixRight=QPixmap(), const QPixmap& pixMiddle=QPixmap(), - const QPixmap& pixSingle=QPixmap()); - - //! Set the color for all the sub elements - void setColor(const QColor& c); - - //! Set whether time must be displayed in the bottom bar - void setFlagShowTime(bool b) {flagShowTime=b;} - //! Set whether location info must be displayed in the bottom bar - void setFlagShowLocation(bool b) {flagShowLocation=b;} - - -private slots: - //! Update the help label when a button is hovered - void buttonHoverChanged(bool b); - -private: - void updateText(bool forceUpdatePos=false); - void updateButtonsGroups(); - QRectF getButtonsBoundingRect() const; - QGraphicsSimpleTextItem* location; - QGraphicsSimpleTextItem* datetime; - QGraphicsSimpleTextItem* fov; - QGraphicsSimpleTextItem* fps; - - struct ButtonGroup - { - ButtonGroup() : leftMargin(0), rightMargin(0), - pixBackgroundLeft(NULL), pixBackgroundRight(NULL), - pixBackgroundMiddle(NULL), pixBackgroundSingle(NULL) {;} - //! Elements of the group - QList elems; - //! Left margin size in pixel - int leftMargin; - //! Right margin size in pixel - int rightMargin; - //! Background Images; - QPixmap* pixBackgroundLeft; - QPixmap* pixBackgroundRight; - QPixmap* pixBackgroundMiddle; - QPixmap* pixBackgroundSingle; - }; - - QMap buttonGroups; - QPixmap pixBackgroundLeft; - QPixmap pixBackgroundRight; - QPixmap pixBackgroundMiddle; - QPixmap pixBackgroundSingle; - - bool flagShowTime; - bool flagShowLocation; - - QGraphicsSimpleTextItem* helpLabel; -}; - -// The path around the bottom left button bars -class StelBarsPath : public QGraphicsPathItem -{ - public: - StelBarsPath(QGraphicsItem* parent); - void updatePath(BottomStelBar* bot, LeftStelBar* lef); - double getRoundSize() const {return roundSize;} - void setBackgroundOpacity(double opacity); - private: - double roundSize; -}; - -#endif // _STELGUIITEMS_HPP_ diff --git a/src/gui/StelScriptSyntaxHighlighter.cpp b/src/gui/StelScriptSyntaxHighlighter.cpp deleted file mode 100644 index fce5f1b..0000000 --- a/src/gui/StelScriptSyntaxHighlighter.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * Derived from the QT syntax highlighter example under the GNU GPL. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "StelScriptSyntaxHighlighter.hpp" -#include "StelApp.hpp" -#include "StelModuleMgr.hpp" -#include "StelUtils.hpp" - -#if QT_VERSION -#else -#include -#endif -#include -#include -#include -#include - -StelScriptSyntaxHighlighter::StelScriptSyntaxHighlighter(QTextDocument *parent) - : QSyntaxHighlighter(parent) -{ - HighlightingRule rule; - - setFormats(); - - // comments - rule.pattern = QRegExp("//[^\n]*"); - rule.format = &commentFormat; - highlightingRules.append(rule); - - // ECMAscript reserved words - QStringList keywordPatterns; - keywordPatterns << "\\bbreak\\b" - << "\\bcase\\b" - << "\\bcatch\\b" - << "\\bcontinue\\b" - << "\\bdefault\\b" - << "\\bdelete\\b" - << "\\bdo\\b" - << "\\belse\\b" - << "\\bfalse\\b" - << "\\bfinally\\b" - << "\\bfor\\b" - << "\\bfunction\\b" - << "\\bif\\b" - << "\\bin\\b" - << "\\binstanceof\\b" - << "\\bnew\\b" - << "\\breturn\\b" - << "\\bswitch\\b" - << "\\bthis\\b" - << "\\bthrow\\b" - << "\\btry\\b" - << "\\btrue\\b" - << "\\btypeof\\b" - << "\\bvar\\b" - << "\\bvoid\\b" - << "\\bundefined\\b" - << "\\bwhile\\b" - << "\\bwith\\b" - << "\\bArguments\\b" - << "\\bArray\\b" - << "\\bBoolean\\b" - << "\\bDate\\b" - << "\\bError\\b" - << "\\bEvalError\\b" - << "\\bFunction\\b" - << "\\bGlobal\\b" - << "\\bMath\\b" - << "\\bNumber\\b" - << "\\bObject\\b" - << "\\bRangeError\\b" - << "\\bReferenceError\\b" - << "\\bRegExp\\b" - << "\\bString\\b" - << "\\bSyntaxError\\b" - << "\\bTypeError\\b" - << "\\bURIError\\b"; - - foreach(const QString &pattern, keywordPatterns) - { - rule.pattern = QRegExp(pattern); - rule.format = &keywordFormat; - highlightingRules.append(rule); - } - - // highlight object names which can be used in scripting - QStringList moduleNames; - QStringList knownFunctionNames; - StelModuleMgr* mmgr = &StelApp::getInstance().getModuleMgr(); - foreach (StelModule* m, mmgr->getAllModules()) - { - moduleNames << "\\b" + m->objectName() + "\\b"; - - // for each one dump known public slots - const QMetaObject* metaObject = m->metaObject(); - for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i) - { - if (metaObject->method(i).methodType() == QMetaMethod::Slot && metaObject->method(i).access() == QMetaMethod::Public) - { - QString fn = metaObject->method(i).methodSignature(); - fn.replace(QRegExp("\\(.*$"), ""); - fn = m->objectName() + "\\." + fn; - knownFunctionNames << fn; - } - } - } - moduleNames << "\\bStelSkyImageMgr\\b" << "\\bStelSkyDrawer\\b" << "\\bcore\\b"; - foreach(const QString &pattern, moduleNames) - { - rule.pattern = QRegExp(pattern); - rule.format = &moduleFormat; - highlightingRules.append(rule); - } - - foreach(const QString &pattern, knownFunctionNames) - { - rule.pattern = QRegExp(pattern); - rule.format = &moduleFormat; - highlightingRules.append(rule); - } - - // quoted strings - rule.pattern = QRegExp("\".*\""); - rule.format = &constantFormat; - highlightingRules.append(rule); - - // decimal numeric constants - rule.pattern = QRegExp("\\b\\d+(\\.\\d+)?\\b"); - rule.format = &constantFormat; - highlightingRules.append(rule); - - // function calls - rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); - rule.format = &functionFormat; - highlightingRules.append(rule); - -} - -void StelScriptSyntaxHighlighter::setFormats(void) -{ - Vec3f col; - QString defaultColor = "0.8,0.8,0.8"; - QSettings* conf = StelApp::getInstance().getSettings(); - QString section; - - if (StelApp::getInstance().getVisionModeNight()) - section = "night_color"; - else - section = "color"; - - // comments - col = StelUtils::strToVec3f(conf->value(section + "/script_console_comment_color", defaultColor).toString()); - commentFormat.setForeground(QColor(col[0]*255, col[1]*255, col[2]*255)); - - // ECMAscript reserved words - col = StelUtils::strToVec3f(conf->value(section + "/script_console_keyword_color", defaultColor).toString()); - keywordFormat.setForeground(QColor(col[0]*255, col[1]*255, col[2]*255)); - keywordFormat.setFontWeight(QFont::Bold); - - // highlight object names which can be used in scripting - moduleFormat.setFontWeight(QFont::Bold); - col = StelUtils::strToVec3f(conf->value(section + "/script_console_module_color", defaultColor).toString()); - moduleFormat.setForeground(QColor(col[0]*255, col[1]*255, col[2]*255)); - - // constants - constantFormat.setFontWeight(QFont::Bold); - col = StelUtils::strToVec3f(conf->value(section + "/script_console_constant_color", defaultColor).toString()); - constantFormat.setForeground(QColor(col[0]*255, col[1]*255, col[2]*255)); - - // function calls - functionFormat.setFontItalic(true); - col = StelUtils::strToVec3f(conf->value(section + "/script_console_function_color", defaultColor).toString()); - functionFormat.setForeground(QColor(col[0]*255, col[1]*255, col[2]*255)); - -} - -void StelScriptSyntaxHighlighter::highlightBlock(const QString &text) -{ - foreach(const HighlightingRule &rule, highlightingRules) - { - QRegExp expression(rule.pattern); - int index = expression.indexIn(text); - while (index >= 0) - { - int length = expression.matchedLength(); - setFormat(index, length, *(rule.format)); - index = expression.indexIn(text, index + length); - } - } -} - diff --git a/src/gui/StelScriptSyntaxHighlighter.hpp b/src/gui/StelScriptSyntaxHighlighter.hpp deleted file mode 100644 index 4de46c6..0000000 --- a/src/gui/StelScriptSyntaxHighlighter.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * Derived from the QT syntax highlighter example under the GNU GPL. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_ -#define _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_ - -#include -#include -#include - -class QTextDocument; - -class StelScriptSyntaxHighlighter : public QSyntaxHighlighter -{ - Q_OBJECT - -public: - StelScriptSyntaxHighlighter(QTextDocument* parent=0); - void setFormats(void); - -protected: - void highlightBlock(const QString &text); - -private: - struct HighlightingRule - { - QRegExp pattern; - QTextCharFormat* format; - }; - QVector highlightingRules; - - QTextCharFormat keywordFormat; - QTextCharFormat moduleFormat; - QTextCharFormat commentFormat; - QTextCharFormat constantFormat; - QTextCharFormat functionFormat; -}; - -#endif // _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_ - diff --git a/src/gui/StelStyle.hpp b/src/gui/StelStyle.hpp deleted file mode 100644 index 7387996..0000000 --- a/src/gui/StelStyle.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _STELSTYLE_HPP_ -#define _STELSTYLE_HPP_ - -#include -#include - -//! @class StelStyle -//! Holds the information related to a color style for GUI and modules of Stellarium -class StelStyle -{ -public: - //! The content of the associated Qt Style Sheet for styling widgets - QByteArray qtStyleSheet; - - //! The content of the associated Html Style Sheet for styling rich text - QByteArray htmlStyleSheet; - - //! The name of the config.ini section where the modules store style data - QString confSectionName; -}; - -#endif // _STELSTYLE_HPP_ diff --git a/src/gui/ViewDialog.cpp b/src/gui/ViewDialog.cpp deleted file mode 100644 index 044bc7d..0000000 --- a/src/gui/ViewDialog.cpp +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * Copyright (C) 2012 Timothy Reaves - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - - -#include "ViewDialog.hpp" -#include "ui_viewDialog.h" -#include "AddRemoveLandscapesDialog.hpp" -#include "AtmosphereDialog.hpp" -#include "StelApp.hpp" -#include "StelCore.hpp" -#include "StelSkyCultureMgr.hpp" -#include "StelFileMgr.hpp" -#include "StelLocaleMgr.hpp" -#include "StelProjector.hpp" -#include "LandscapeMgr.hpp" -#include "StelModuleMgr.hpp" -#include "StarMgr.hpp" -#include "StelSkyDrawer.hpp" -#include "SolarSystem.hpp" -#include "NebulaMgr.hpp" -#include "MeteorMgr.hpp" -#include "MilkyWay.hpp" -#include "ConstellationMgr.hpp" -#include "StelStyle.hpp" -#include "StelSkyLayerMgr.hpp" -#include "StelGuiBase.hpp" -#include "StelGui.hpp" -#include "StelGuiItems.hpp" -#include "StelActionMgr.hpp" - -#include -#include -#include -#include -#include -#include -#include - -ViewDialog::ViewDialog(QObject* parent) : StelDialog(parent) -{ - ui = new Ui_viewDialogForm; - addRemoveLandscapesDialog = NULL; - atmosphereDialog=NULL; -} - -ViewDialog::~ViewDialog() -{ - delete ui; - ui=NULL; - delete addRemoveLandscapesDialog; - addRemoveLandscapesDialog = NULL; - delete atmosphereDialog; - atmosphereDialog = NULL; -} - -void ViewDialog::retranslate() -{ - if (dialog) - { - ui->retranslateUi(dialog); - setZhrFromControls(); - populateLists(); - - //Hack to shrink the tabs to optimal size after language change - //by causing the list items to be laid out again. - ui->stackListWidget->setWrapping(false); - } -} - -void ViewDialog::styleChanged() -{ - if (dialog) - { - populateLists(); - } -} - -void ViewDialog::connectCheckBox(QCheckBox* checkBox, const QString& actionId) -{ - StelAction* action = StelApp::getInstance().getStelActionManager()->findAction(actionId); - Q_ASSERT(action); - checkBox->setChecked(action->isChecked()); - connect(action, SIGNAL(toggled(bool)), checkBox, SLOT(setChecked(bool))); - connect(checkBox, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool))); -} - -void ViewDialog::createDialogContent() -{ - ui->setupUi(dialog); - connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); - - // Set the Sky tab activated by default - ui->stackedWidget->setCurrentIndex(0); - ui->stackListWidget->setCurrentRow(0); - - //ui->viewTabWidget->removeTab(4); - - connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); - - populateLists(); - connect(ui->culturesListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(skyCultureChanged(const QString&))); - connect(ui->projectionListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(projectionChanged(const QString&))); - connect(ui->landscapesListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(landscapeChanged(QListWidgetItem*))); - - // Connect and initialize checkboxes and other widgets - - // Stars section - ui->starTwinkleCheckBox->setChecked(StelApp::getInstance().getCore()->getSkyDrawer()->getFlagTwinkle()); - connect(ui->starTwinkleCheckBox, SIGNAL(toggled(bool)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setFlagTwinkle(bool))); - - ui->starScaleRadiusDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAbsoluteStarScale()); - connect(ui->starScaleRadiusDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setAbsoluteStarScale(double))); - - ui->starRelativeScaleDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getRelativeStarScale()); - connect(ui->starRelativeScaleDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setRelativeStarScale(double))); - - MilkyWay* mw = GETSTELMODULE(MilkyWay); - ui->milkyWayBrightnessDoubleSpinBox->setValue(mw->getIntensity()); - connect(ui->milkyWayBrightnessDoubleSpinBox, SIGNAL(valueChanged(double)), mw, SLOT(setIntensity(double))); - - ui->starTwinkleAmountDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getTwinkleAmount()); - connect(ui->starTwinkleAmountDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setTwinkleAmount(double))); - - ui->adaptationCheckbox->setChecked(StelApp::getInstance().getCore()->getSkyDrawer()->getFlagLuminanceAdaptation()); - connect(ui->adaptationCheckbox, SIGNAL(toggled(bool)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setFlagLuminanceAdaptation(bool))); - - // Limit Magnitudes - const StelSkyDrawer* drawer = StelApp::getInstance().getCore()->getSkyDrawer(); - ui->starLimitMagnitudeCheckBox->setChecked(drawer->getFlagStarMagnitudeLimit()); - ui->nebulaLimitMagnitudeCheckBox->setChecked(drawer->getFlagNebulaMagnitudeLimit()); - ui->starLimitMagnitudeDoubleSpinBox->setValue(drawer->getCustomStarMagnitudeLimit()); - ui->nebulaLimitMagnitudeDoubleSpinBox->setValue(drawer->getCustomNebulaMagnitudeLimit()); - - connect(ui->starLimitMagnitudeCheckBox, SIGNAL(toggled(bool)), - drawer, SLOT(setFlagStarMagnitudeLimit(bool))); - connect(ui->nebulaLimitMagnitudeCheckBox, SIGNAL(toggled(bool)), - drawer, SLOT(setFlagNebulaMagnitudeLimit(bool))); - connect(ui->starLimitMagnitudeDoubleSpinBox, SIGNAL(valueChanged(double)), - drawer, SLOT(setCustomStarMagnitudeLimit(double))); - connect(ui->nebulaLimitMagnitudeDoubleSpinBox, - SIGNAL(valueChanged(double)), - drawer, - SLOT(setCustomNebulaMagnitudeLimit(double))); - - // Planets section - SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); - ui->showPlanetCheckBox->setChecked(ssmgr->getFlagPlanets()); - connect(ui->showPlanetCheckBox, SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagPlanets(bool))); - - ui->planetMarkerCheckBox->setChecked(ssmgr->getFlagHints()); - connect(ui->planetMarkerCheckBox, SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagHints(bool))); - - ui->planetScaleMoonCheckBox->setChecked(ssmgr->getFlagMoonScale()); - connect(ui->planetScaleMoonCheckBox, SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagMoonScale(bool))); - - ui->planetOrbitCheckBox->setChecked(ssmgr->getFlagOrbits()); - connect(ui->planetOrbitCheckBox, SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagOrbits(bool))); - - ui->planetLightSpeedCheckBox->setChecked(ssmgr->getFlagLightTravelTime()); - connect(ui->planetLightSpeedCheckBox, SIGNAL(toggled(bool)), ssmgr, SLOT(setFlagLightTravelTime(bool))); - - // Shooting stars section - MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr); - Q_ASSERT(mmgr); - updateZhrControls(mmgr->getZHR()); - connect(mmgr, SIGNAL(zhrChanged(int)), - this, SLOT(updateZhrControls(int))); - connect(ui->zhrNone, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - connect(ui->zhr10, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - connect(ui->zhr80, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - connect(ui->zhr1000, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - connect(ui->zhr10000, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - connect(ui->zhr144000, SIGNAL(clicked()), this, SLOT(setZhrFromControls())); - - // Labels section - StarMgr* smgr = GETSTELMODULE(StarMgr); - ui->starLabelCheckBox->setChecked(smgr->getFlagLabels()); - connect(ui->starLabelCheckBox, SIGNAL(toggled(bool)), smgr, SLOT(setFlagLabels(bool))); - - connectCheckBox(ui->nebulaLabelCheckBox, "actionShow_Nebulas"); - connectCheckBox(ui->planetLabelCheckBox, "actionShow_Planets_Labels"); - - NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); - - ui->starsLabelsHorizontalSlider->setValue((int)(smgr->getLabelsAmount()*10.f)); - connect(ui->starsLabelsHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(starsLabelsValueChanged(int))); - ui->planetsLabelsHorizontalSlider->setValue((int)(ssmgr->getLabelsAmount()*10.f)); - connect(ui->planetsLabelsHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(planetsLabelsValueChanged(int))); - ui->nebulasLabelsHorizontalSlider->setValue((int)(nmgr->getHintsAmount()*10.f)); - connect(ui->nebulasLabelsHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(nebulasLabelsValueChanged(int))); - - // Landscape section - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - connectCheckBox(ui->showGroundCheckBox, "actionShow_Ground"); - connectCheckBox(ui->showFogCheckBox, "actionShow_Fog"); - connectCheckBox(ui->showAtmosphereCheckBox, "actionShow_Atmosphere"); - - ui->landscapePositionCheckBox->setChecked(lmgr->getFlagLandscapeSetsLocation()); - connect(ui->landscapePositionCheckBox, SIGNAL(toggled(bool)), lmgr, SLOT(setFlagLandscapeSetsLocation(bool))); - - ui->landscapeBrightnessCheckBox->setChecked(lmgr->getFlagLandscapeNightBrightness()); - connect(ui->landscapeBrightnessCheckBox, SIGNAL(toggled(bool)), lmgr, SLOT(setFlagLandscapeNightBrightness(bool))); - - ui->lightPollutionSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getBortleScale()); - connect(ui->lightPollutionSpinBox, SIGNAL(valueChanged(int)), lmgr, SLOT(setAtmosphereBortleLightPollution(int))); - connect(ui->lightPollutionSpinBox, SIGNAL(valueChanged(int)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setBortleScale(int))); - - ui->autoChangeLandscapesCheckBox->setChecked(lmgr->getFlagLandscapeAutoSelection()); - connect(ui->autoChangeLandscapesCheckBox, SIGNAL(toggled(bool)), lmgr, SLOT(setFlagLandscapeAutoSelection(bool))); - - // GZ: changes for refraction - //ui->pressureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmospherePressure()); - //connect(ui->pressureDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setAtmospherePressure(double))); - //ui->temperatureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmosphereTemperature()); - //connect(ui->temperatureDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setAtmosphereTemperature(double))); - //ui->extinctionDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getExtinctionCoefficient()); - //connect(ui->extinctionDoubleSpinBox, SIGNAL(valueChanged(double)), StelApp::getInstance().getCore()->getSkyDrawer(), SLOT(setExtinctionCoefficient(double))); - //// instead - connect(ui->pushButtonAtmosphereDetails, SIGNAL(clicked()), this, SLOT(showAtmosphereDialog())); - // GZ: Done - - - ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getCurrentLandscapeID()==lmgr->getDefaultLandscapeID()); - ui->useAsDefaultLandscapeCheckBox->setEnabled(lmgr->getCurrentLandscapeID()!=lmgr->getDefaultLandscapeID()); - connect(ui->useAsDefaultLandscapeCheckBox, SIGNAL(clicked()), this, SLOT(setCurrentLandscapeAsDefault())); - - connect(GETSTELMODULE(LandscapeMgr), SIGNAL(landscapesChanged()), this, SLOT(populateLists())); - connect(ui->pushButtonAddRemoveLandscapes, SIGNAL(clicked()), this, SLOT(showAddRemoveLandscapesDialog())); - - // Grid and lines - connectCheckBox(ui->showEquatorLineCheckBox, "actionShow_Equator_Line"); - connectCheckBox(ui->showEclipticLineCheckBox, "actionShow_Ecliptic_Line"); - connectCheckBox(ui->showMeridianLineCheckBox, "actionShow_Meridian_Line"); - connectCheckBox(ui->showHorizonLineCheckBox, "actionShow_Horizon_Line"); - connectCheckBox(ui->showEquatorialGridCheckBox, "actionShow_Equatorial_Grid"); - connectCheckBox(ui->showGalacticGridCheckBox, "actionShow_Galactic_Grid"); - connectCheckBox(ui->showGalacticPlaneLineCheckBox, "actionShow_Galactic_Plane_Line"); - connectCheckBox(ui->showAzimuthalGridCheckBox, "actionShow_Azimuthal_Grid"); - connectCheckBox(ui->showEquatorialJ2000GridCheckBox, "actionShow_Equatorial_J2000_Grid"); - connectCheckBox(ui->showEclipticGridJ2000CheckBox, "actionShow_Ecliptic_J2000_Grid"); - connectCheckBox(ui->showCardinalPointsCheckBox, "actionShow_Cardinal_Points"); - - // Constellations - ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); - connectCheckBox(ui->showConstellationLinesCheckBox, "actionShow_Constellation_Lines"); - connectCheckBox(ui->showConstellationLabelsCheckBox, "actionShow_Constellation_Labels"); - connectCheckBox(ui->showConstellationBoundariesCheckBox, "actionShow_Constellation_Boundaries"); - connectCheckBox(ui->showConstellationArtCheckBox, "actionShow_Constellation_Art"); - ui->constellationArtBrightnessSpinBox->setValue(cmgr->getArtIntensity()); - connect(ui->constellationArtBrightnessSpinBox, SIGNAL(valueChanged(double)), cmgr, SLOT(setArtIntensity(double))); - - // Starlore - connect(ui->useAsDefaultSkyCultureCheckBox, SIGNAL(clicked()), this, SLOT(setCurrentCultureAsDefault())); - const bool b = StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()==StelApp::getInstance().getSkyCultureMgr().getDefaultSkyCultureID(); - ui->useAsDefaultSkyCultureCheckBox->setChecked(b); - ui->useAsDefaultSkyCultureCheckBox->setEnabled(!b); - - // Sky layers - populateSkyLayersList(); - connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(populateSkyLayersList())); - connect(ui->skyLayerListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(skyLayersSelectionChanged(const QString&))); - connect(ui->stackListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); - connect(ui->skyLayerEnableCheckBox, SIGNAL(stateChanged(int)), this, SLOT(skyLayersEnabledChanged(int))); - - QTimer* refreshTimer = new QTimer(this); - connect(refreshTimer, SIGNAL(timeout()), this, SLOT(updateFromProgram())); - refreshTimer->start(200); -} - -void ViewDialog::populateLists() -{ - // Fill the culture list widget from the available list - QListWidget* l = ui->culturesListWidget; - l->blockSignals(true); - l->clear(); - l->addItems(StelApp::getInstance().getSkyCultureMgr().getSkyCultureListI18()); - l->setCurrentItem(l->findItems(StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureNameI18(), Qt::MatchExactly).at(0)); - l->blockSignals(false); - updateSkyCultureText(); - - const StelCore* core = StelApp::getInstance().getCore(); - StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); - Q_ASSERT(gui); - - // Fill the projection list - l = ui->projectionListWidget; - l->blockSignals(true); - l->clear(); - const QStringList mappings = core->getAllProjectionTypeKeys(); - foreach (QString s, mappings) - { - l->addItem(core->projectionTypeKeyToNameI18n(s)); - } - l->setCurrentItem(l->findItems(core->projectionTypeKeyToNameI18n(core->getCurrentProjectionTypeKey()), Qt::MatchExactly).at(0)); - l->blockSignals(false); - ui->projectionTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->projectionTextBrowser->setHtml(core->getProjection(StelCore::FrameJ2000)->getHtmlSummary()); - - // Fill the landscape list - l = ui->landscapesListWidget; - l->blockSignals(true); - l->clear(); - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - QStringList landscapeList = lmgr->getAllLandscapeNames(); - foreach (const QString landscapeId, landscapeList) - { - QString label = q_(landscapeId); - QListWidgetItem* item = new QListWidgetItem(label); - item->setData(Qt::UserRole, landscapeId); - l->addItem(item); - } - QString selectedLandscapeId = lmgr->getCurrentLandscapeName(); - for (int i = 0; i < l->count(); i++) - { - if (l->item(i)->data(Qt::UserRole).toString() == selectedLandscapeId) - { - l->setCurrentRow(i); - break; - } - } - l->blockSignals(false); - ui->landscapeTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->landscapeTextBrowser->setHtml(lmgr->getCurrentLandscapeHtmlDescription()); - ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getDefaultLandscapeID()==lmgr->getCurrentLandscapeID()); - ui->useAsDefaultLandscapeCheckBox->setEnabled(lmgr->getDefaultLandscapeID()!=lmgr->getCurrentLandscapeID()); -} - -void ViewDialog::populateSkyLayersList() -{ - ui->skyLayerListWidget->clear(); - StelSkyLayerMgr* skyLayerMgr = GETSTELMODULE(StelSkyLayerMgr); - ui->skyLayerListWidget->addItems(skyLayerMgr->getAllKeys()); -} - -void ViewDialog::skyLayersSelectionChanged(const QString& s) -{ - StelSkyLayerMgr* skyLayerMgr = GETSTELMODULE(StelSkyLayerMgr); - StelSkyLayerP l = skyLayerMgr->getSkyLayer(s); - - if (l.isNull()) - return; - - QString html = ""; - html += "

" + l->getShortName()+ "

"; - html += "

" + l->getLayerDescriptionHtml() + "

"; - if (!l->getShortServerCredits().isEmpty()) - html += "

" + q_("Contact") + ": " + l->getShortServerCredits() + "

"; - html += ""; - ui->skyLayerTextBrowser->setHtml(html); - ui->skyLayerEnableCheckBox->setChecked(skyLayerMgr->getShowLayer(s)); -} - -void ViewDialog::skyLayersEnabledChanged(int state) -{ - StelSkyLayerMgr* skyLayerMgr = GETSTELMODULE(StelSkyLayerMgr); - skyLayerMgr->showLayer(ui->skyLayerListWidget->currentItem()->text(), state); -} - -void ViewDialog::skyCultureChanged(const QString& cultureName) -{ - StelApp::getInstance().getSkyCultureMgr().setCurrentSkyCultureNameI18(cultureName); - updateSkyCultureText(); - const bool b = StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()==StelApp::getInstance().getSkyCultureMgr().getDefaultSkyCultureID(); - ui->useAsDefaultSkyCultureCheckBox->setChecked(b); - ui->useAsDefaultSkyCultureCheckBox->setEnabled(!b); -} - -void ViewDialog::updateSkyCultureText() -{ - StelApp& app = StelApp::getInstance(); - QString skyCultureId = app.getSkyCultureMgr().getCurrentSkyCultureID(); - QString lang = app.getLocaleMgr().getAppLanguage(); - if (!QString("pt_BR zh_CN zh_HK zh_TW").contains(lang)) - { - lang = lang.split("_").at(0); - } - QString descPath = StelFileMgr::findFile("skycultures/" + skyCultureId + "/description."+lang+".utf8"); - if (descPath.isEmpty()) - { - descPath = StelFileMgr::findFile("skycultures/" + skyCultureId + "/description.en.utf8"); - if (descPath.isEmpty()) - qWarning() << "WARNING: can't find description for skyculture" << skyCultureId; - } - - QStringList searchPaths; - searchPaths << StelFileMgr::findFile("skycultures/" + skyCultureId); - - ui->skyCultureTextBrowser->setSearchPaths(searchPaths); - StelGui* gui = dynamic_cast(app.getGui()); - Q_ASSERT(gui); - ui->skyCultureTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - - if (descPath.isEmpty()) - { - ui->skyCultureTextBrowser->setHtml(q_("No description")); - } - else - { - QFile f(descPath); - f.open(QIODevice::ReadOnly); - QString htmlFile = QString::fromUtf8(f.readAll()); - ui->skyCultureTextBrowser->setHtml(htmlFile); - } -} - -void ViewDialog::projectionChanged(const QString& projectionNameI18n) -{ - StelCore* core = StelApp::getInstance().getCore(); - core->setCurrentProjectionTypeKey(core->projectionNameI18nToTypeKey(projectionNameI18n)); - StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); - Q_ASSERT(gui); - ui->projectionTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->projectionTextBrowser->setHtml(core->getProjection(StelCore::FrameJ2000)->getHtmlSummary()); -} - -void ViewDialog::landscapeChanged(QListWidgetItem* item) -{ - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - lmgr->setCurrentLandscapeName(item->data(Qt::UserRole).toString()); - StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); - Q_ASSERT(gui); - ui->landscapeTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); - ui->landscapeTextBrowser->setHtml(lmgr->getCurrentLandscapeHtmlDescription()); - ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getDefaultLandscapeID()==lmgr->getCurrentLandscapeID()); - ui->useAsDefaultLandscapeCheckBox->setEnabled(lmgr->getDefaultLandscapeID()!=lmgr->getCurrentLandscapeID()); - //StelSkyDrawer *drawer=StelApp::getInstance().getSkyDrawer(); - // GZ: Reset values that might have changed. - ui->showFogCheckBox->setChecked(lmgr->getFlagFog()); - ui->lightPollutionSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getBortleScale()); -} - -void ViewDialog::showAddRemoveLandscapesDialog() -{ - if(addRemoveLandscapesDialog == NULL) - addRemoveLandscapesDialog = new AddRemoveLandscapesDialog(); - - addRemoveLandscapesDialog->setVisible(true); -} - -void ViewDialog::showAtmosphereDialog() -{ - if(atmosphereDialog == NULL) - atmosphereDialog = new AtmosphereDialog(); - //ui->temperatureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmosphereTemperature()); - //ui->extinctionDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getExtinctionCoefficient()); - //ui->pressureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmospherePressure()); - - atmosphereDialog->setVisible(true); -} - - -void ViewDialog::setZhrFromControls() -{ - MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr); - int zhr=-1; - if (ui->zhrNone->isChecked()) - { - mmgr->setFlagShow(false); - zhr = 0; - } - else - { - mmgr->setFlagShow(true); - } - if (ui->zhr10->isChecked()) - zhr = 10; - if (ui->zhr80->isChecked()) - zhr = 80; - if (ui->zhr1000->isChecked()) - zhr = 1000; - if (ui->zhr10000->isChecked()) - zhr = 10000; - if (ui->zhr144000->isChecked()) - zhr = 144000; - if (zhr!=mmgr->getZHR()) - { - mmgr->setZHR(zhr); - } - - updateZhrDescription(zhr); -} - -void ViewDialog::updateZhrControls(int zhr) -{ - // As the radio buttons are tied to the clicked() signal, - // it won't be triggered by setting the value programmatically. - switch(zhr) - { - case 0: ui->zhrNone->setChecked(true); break; - case 80: ui->zhr80->setChecked(true); break; - case 1000: ui->zhr1000->setChecked(true); break; - case 10000: ui->zhr10000->setChecked(true); break; - case 144000: ui->zhr144000->setChecked(true); break; - default: ui->zhr10->setChecked(true); break; - } - - updateZhrDescription(zhr); -} - -void ViewDialog::updateZhrDescription(int zhr) -{ - switch (zhr) - { - case 0: - ui->zhrLabel->setText(""+q_("No shooting stars")+""); - break; - case 10: - ui->zhrLabel->setText(""+q_("Normal rate")+""); - break; - case 80: - ui->zhrLabel->setText(""+q_("Standard Perseids rate")+""); - break; - case 1000: - ui->zhrLabel->setText(""+q_("Meteor storm rate")+""); - break; - case 10000: - ui->zhrLabel->setText(""+q_("Exceptional Leonid rate")+""); - break; - case 144000: - ui->zhrLabel->setText(""+q_("Highest rate ever (1966 Leonids)")+""); - break; - default: - ui->zhrLabel->setText(QString("")+"Error"+""); - } -} - -void ViewDialog::starsLabelsValueChanged(int v) -{ - StarMgr* smgr = GETSTELMODULE(StarMgr); - float a= ((float)v)/10.f; - smgr->setLabelsAmount(a); -} - -void ViewDialog::setCurrentLandscapeAsDefault(void) -{ - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - Q_ASSERT(lmgr); - lmgr->setDefaultLandscapeID(lmgr->getCurrentLandscapeID()); - ui->useAsDefaultLandscapeCheckBox->setChecked(true); - ui->useAsDefaultLandscapeCheckBox->setEnabled(false); -} - -void ViewDialog::setCurrentCultureAsDefault(void) -{ - StelApp::getInstance().getSkyCultureMgr().setDefaultSkyCultureID(StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()); - ui->useAsDefaultSkyCultureCheckBox->setChecked(true); - ui->useAsDefaultSkyCultureCheckBox->setEnabled(false); -} - -void ViewDialog::planetsLabelsValueChanged(int v) -{ - SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); - float a= ((float)v)/10.f; - ssmgr->setLabelsAmount(a); -} - -void ViewDialog::nebulasLabelsValueChanged(int v) -{ - NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); - float a= ((float)v)/10.f; - nmgr->setHintsAmount(a); - nmgr->setLabelsAmount(a); -} - -// Update the widget to make sure it is synchrone if a value was changed programmatically -void ViewDialog::updateFromProgram() -{ - if (!dialog->isVisible()) - return; - - // Check that the useAsDefaultSkyCultureCheckBox needs to be updated - bool b = StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID()==StelApp::getInstance().getSkyCultureMgr().getDefaultSkyCultureID(); - if (b!=ui->useAsDefaultSkyCultureCheckBox->isChecked()) - { - ui->useAsDefaultSkyCultureCheckBox->setChecked(b); - ui->useAsDefaultSkyCultureCheckBox->setEnabled(!b); - } - - LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); - Q_ASSERT(lmgr); - b = lmgr->getCurrentLandscapeID()==lmgr->getDefaultLandscapeID(); - if (b!=ui->useAsDefaultLandscapeCheckBox->isChecked()) - { - ui->useAsDefaultLandscapeCheckBox->setChecked(b); - ui->useAsDefaultLandscapeCheckBox->setEnabled(!b); - } -} - -void ViewDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (!current) - current = previous; - ui->stackedWidget->setCurrentIndex(ui->stackListWidget->row(current)); -} diff --git a/src/gui/ViewDialog.hpp b/src/gui/ViewDialog.hpp deleted file mode 100644 index 18c16f2..0000000 --- a/src/gui/ViewDialog.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2008 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. -*/ - -#ifndef _VIEWDIALOG_HPP_ -#define _VIEWDIALOG_HPP_ - -#include -#include "StelDialog.hpp" - -class Ui_viewDialogForm; -class QListWidgetItem; - -class AddRemoveLandscapesDialog; -class AtmosphereDialog; - -class ViewDialog : public StelDialog -{ -Q_OBJECT -public: - ViewDialog(QObject* parent); - virtual ~ViewDialog(); - //! Notify that the application style changed - void styleChanged(); - -public slots: - void retranslate(); - -protected: - Ui_viewDialogForm* ui; - //! Initialize the dialog widgets and connect the signals/slots - virtual void createDialogContent(); -private slots: - void populateLists(); - void skyCultureChanged(const QString& cultureName); - void projectionChanged(const QString& projectionName); - void landscapeChanged(QListWidgetItem* item); - void setZhrFromControls(); - void updateZhrControls(int zhr); - void updateZhrDescription(int zhr); - void planetsLabelsValueChanged(int); - void nebulasLabelsValueChanged(int); - void starsLabelsValueChanged(int); - void setCurrentLandscapeAsDefault(void); - void setCurrentCultureAsDefault(void); - //! Update the widget to make sure it is synchrone if a value was changed programmatically - //! This function should be called repeatidly with e.g. a timer - void updateFromProgram(); - - void showAddRemoveLandscapesDialog(); - void showAtmosphereDialog(); - - void populateSkyLayersList(); - void skyLayersSelectionChanged(const QString&); - void skyLayersEnabledChanged(int); - - void changePage(QListWidgetItem *current, QListWidgetItem *previous); -private: - //! convenience method to link a checkbox to a StelAction. - void connectCheckBox(class QCheckBox* checkBox, const QString& actionId); - void updateSkyCultureText(); - - AddRemoveLandscapesDialog * addRemoveLandscapesDialog; - AtmosphereDialog * atmosphereDialog; -}; - -#endif // _VIEWDIALOG_HPP_ diff --git a/src/gui/addRemoveLandscapesDialog.ui b/src/gui/addRemoveLandscapesDialog.ui deleted file mode 100644 index 1e2549c..0000000 --- a/src/gui/addRemoveLandscapesDialog.ui +++ /dev/null @@ -1,378 +0,0 @@ - - - addRemoveLandscapesDialogForm - - - - 0 - 0 - 450 - 400 - - - - - 0 - 0 - - - - - 400 - 400 - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 400 - 25 - - - - - 16777215 - 30 - - - - Qt::NoFocus - - - false - - - QFrame::StyledPanel - - - - 6 - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Add/Remove Landscapes - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - - 0 - 0 - - - - Add a new landscape - - - - 0 - - - - - - 0 - 0 - - - - Install a new landscape from a ZIP archive... - - - - - - - - 0 - 0 - - - - Switch to the new landscape after installation - - - true - - - - - - - - - - Message - - - - 0 - - - - - - 0 - 0 - - - - - DejaVu Sans - 12 - - - - - - - true - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - - - - :/graphicGui/closeButton-hover.png:/graphicGui/closeButton-hover.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - - - - Remove an installed landscape - - - - 0 - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - Remove - - - - - - - - 0 - 0 - - - - WARNING: Removing the selected landscape means deleting its files. This operation is irreversible. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - checkBoxUseLandscape - pushButtonBrowseForArchive - pushButtonMessageOK - listWidgetUserLandscapes - pushButtonRemove - - - - - -
diff --git a/src/gui/configurationDialog.ui b/src/gui/configurationDialog.ui deleted file mode 100644 index a43ed27..0000000 --- a/src/gui/configurationDialog.ui +++ /dev/null @@ -1,1464 +0,0 @@ - - - configurationDialogForm - - - - 0 - 0 - 480 - 444 - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - Configuration - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - 1 - - - - - 0 - - - 0 - - - - - Program language - - - - 0 - - - - - - 0 - 0 - - - - - 220 - 24 - - - - - 220 - 24 - - - - - - - - - - - Default options - - - - 0 - - - - - - - - 0 - 24 - - - - Save the settings you've changed this session to be the same the next time you start Stellarium - - - Save settings - - - - - - - - 0 - 24 - - - - Restore the default settings that came with Stellarium - - - Restore defaults - - - - - - - - - - 0 - 0 - - - - Restoring default settings requires a restart of Stellarium. Saving all the current options includes the current FOV and direction of view for use at next startup. - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - Qt::NoTextInteraction - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - The width of your view when Stellarium starts - - - Startup FOV: XX - - - Qt::TextSelectableByMouse - - - - - - - The direction you're looking when Stellarium starts - - - Startup direction of view: xxxx - - - Qt::TextSelectableByMouse - - - - - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Selected object information - - - - - - Display all information available - - - All available - - - - - - - Display no information - - - None - - - - - - - Display less information - - - Short - - - - - - - Display user settings information - - - Customized - - - - - - - - - - - 0 - 0 - - - - Displayed fields - - - - 0 - - - - - Geocentric equatorial coordinates, equinox of date - - - Right ascension/Declination (of date) - - - buttonGroupDisplayedFields - - - - - - - Distance - - - buttonGroupDisplayedFields - - - - - - - Catalog number(s) - - - buttonGroupDisplayedFields - - - - - - - Geocentric equatorial coordinates, equinox of J2000.0 - - - Right ascension/Declination (J2000) - - - buttonGroupDisplayedFields - - - - - - - Absolute magnitude - - - buttonGroupDisplayedFields - - - - - - - Galactic coordinates - - - buttonGroupDisplayedFields - - - - - - - Spectral class, nebula type, etc. - - - Additional information - - - buttonGroupDisplayedFields - - - - - - - Topocentric equatorial coordinates - - - Hour angle/Declination - - - buttonGroupDisplayedFields - - - - - - - Name - - - buttonGroupDisplayedFields - - - - - - - Visual magnitude - - - buttonGroupDisplayedFields - - - - - - - Horizontal coordinates - - - Altitude/Azimuth - - - buttonGroupDisplayedFields - - - - - - - Angular or physical size - - - Size - - - buttonGroupDisplayedFields - - - - - - - The type of the object (star, planet, etc.) - - - Type - - - - - - - - - - - - 0 - - - 0 - - - - - Control - - - - 0 - - - - - Allow keyboard to pan and zoom - - - Enable keyboard navigation - - - - - - - Allow mouse to pan (drag) and zoom (mousewheel) - - - Enable mouse navigation - - - - - - - Edit keyboard shortcuts... - - - - - - - - - Hides the mouse cursor when inactive - - - Mouse cursor timeout: - - - - - - - - 16777215 - 24 - - - - seconds - - - 1 - - - 0.000000000000000 - - - 3600.000000000000000 - - - 10.000000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Startup date and time - - - - 0 - - - - - - - Use a specific date and time when Stellarium starts up - - - Other: - - - - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - - 1952 - 5 - 11 - - - - - - - true - - - - - - - - - Use current local date and time - - - use current - - - - - - - Starts Stellarium at system clock date and time - - - System date and time - - - - - - - 6 - - - - - Sets the simulation time to the next instance of this time of day when Stellarium starts - - - System date at: - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - - - - true - - - Qt::AlignCenter - - - - - - 0 - - - - - - - - - - - - Time correction - - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - - - 6 - - - - - - - - - - - - - - - false - - - Edit equation - - - ... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - true - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAlwaysOff - - - true - - - true - - - - - - - - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Planetarium options - - - - - - Spheric mirror distortion is used when projecting Stellarium onto a spheric mirror for low-cost planetarium systems. - - - Spheric mirror distortion - - - - - - - Mask out everything outside a central circle in the main view - - - Disc viewport - - - - - - - Hide other constellations when you click one - - - Select single constellation - - - - - - - Align labels with the horizon - - - Gravity labels - - - - - - - Toggle display backgrounds of the nebulae. - - - Show nebula background button - - - - - - - Toggle vertical and horizontal image flip buttons. - - - Show flip buttons - - - - - - - When enabled, the "auto zoom out" key will also set the initial viewing direction - - - Auto zoom out returns to initial direction of view - - - - - - - Display solar shadows on planets and moons (For that feature needed OpenGL version 2 or higher) - - - Render Solar Shadows - - - - - - - - - - Screenshots - - - - 0 - - - - - - - Screenshot Directory - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - Invert colors - - - - - - - - - - Star catalog updates - - - - 0 - - - - - - 0 - 0 - - - - Click here to start downloading - - - Get catalog x of y - - - - :/graphicGui/btTimeRealtime-off.png:/graphicGui/btTimeRealtime-off.png - - - Download this file to view even more stars - - - - - - - xxx - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Restart the download - - - Retry - - - - - - - Stop the download. You can always restart it later - - - Cancel - - - - - - - - - - - - 0 - - - 0 - - - - - - 190 - 0 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - - - - - - - - - - Options - - - - 0 - - - - - - - - - - - - Close window when script runs - - - true - - - - - - - - - true - - - Run the selected script - - - - - - - :/graphicGui/btScriptRun-on.png - :/graphicGui/btScriptRun-off.png:/graphicGui/btScriptRun-on.png - - - - - - - true - - - Stop a running script - - - - - - - :/graphicGui/btScriptStop-on.png - :/graphicGui/btScriptStop-off.png:/graphicGui/btScriptStop-on.png - - - - - - - - - - - - - - - - 0 - - - 0 - - - - - - 180 - 0 - - - - - 180 - 16777215 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - - - - - - - - - - Options - - - - 0 - - - - - Load at startup - - - - - - - false - - - configure - - - - - - - - - - - - - - - - - 0 - 74 - - - - - 16777215 - 74 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::SingleSelection - - - - 50 - 50 - - - - QListView::Static - - - QListView::LeftToRight - - - false - - - QListView::Adjust - - - QListView::SinglePass - - - 0 - - - QListView::IconMode - - - false - - - false - - - false - - - - Main - - - - :/graphicGui/tabicon-main.png - - - - - - Information - - - Selected object information - - - - :/graphicGui/tabicon-info.png - - - - - - Navigation - - - - :/graphicGui/tabicon-navigation.png - - - - - - Tools - - - - :/graphicGui/tabicon-tools.png - - - - - - Scripts - - - - :/graphicGui/tabicon-scripts.png - - - - - - Plugins - - - - :/graphicGui/tabicon-plugins.png - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - programLanguageComboBox - setViewingOptionAsDefaultPushButton - restoreDefaultsButton - checkBoxName - checkBoxVisualMag - checkBoxCatalogNumbers - checkBoxAbsoluteMag - checkBoxRaDecJ2000 - checkBoxGalacticCoordinates - checkBoxRaDecOfDate - checkBoxHourAngle - checkBoxDistance - checkBoxAltAz - checkBoxSize - checkBoxExtra - enableKeysNavigationCheckBox - editShortcutsPushButton - systemTimeRadio - todayRadio - todayTimeSpinBox - fixedTimeRadio - fixedDateTimeEdit - fixedDateTimeCurrentButton - mouseTimeoutCheckbox - mouseTimeoutSpinBox - sphericMirrorCheckbox - diskViewportCheckbox - gravityLabelCheckbox - selectSingleConstellationButton - autoZoomResetsDirectionCheckbox - renderSolarShadowsCheckbox - screenshotBrowseButton - screenshotDirEdit - invertScreenShotColorsCheckBox - getStarsButton - downloadRetryButton - downloadCancelButton - scriptInfoBrowser - closeWindowAtScriptRunCheckbox - runScriptButton - stopScriptButton - pluginsInfoBrowser - pluginLoadAtStartupCheckBox - pluginConfigureButton - - - - - - - stackListWidget - currentRowChanged(int) - configurationStackedWidget - setCurrentIndex(int) - - - 237 - 62 - - - 237 - 281 - - - - - - - - false - - - -
diff --git a/src/gui/dateTimeDialogGui.ui b/src/gui/dateTimeDialogGui.ui deleted file mode 100644 index e1330b7..0000000 --- a/src/gui/dateTimeDialogGui.ui +++ /dev/null @@ -1,534 +0,0 @@ - - - dateTimeDialogForm - - - - 0 - 0 - 401 - 84 - - - - - - - - 1 - - - 0 - - - - - - 0 - 0 - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 75 - false - true - - - - Date and Time - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - - 0 - 1 - - - - QFrame::StyledPanel - - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - false - - - true - - - Qt::AlignCenter - - - -1000000 - - - 1000000 - - - - - - - true - - - - 0 - 0 - - - - - 10 - 16777215 - - - - / - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - true - - - Qt::AlignCenter - - - 0 - - - 13 - - - - - - - - 0 - 0 - - - - - 10 - 16777215 - - - - / - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - true - - - Qt::AlignCenter - - - 0 - - - 32 - - - - - - - - - - - 0 - 0 - - - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - Qt::AlignCenter - - - -1 - - - 24 - - - - - - - - 0 - 0 - - - - - 10 - 16777215 - - - - : - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - Qt::AlignCenter - - - -1 - - - 60 - - - - - - - - 0 - 0 - - - - - 10 - 16777215 - - - - false - - - : - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - Qt::NoContextMenu - - - true - - - Qt::AlignCenter - - - QAbstractSpinBox::UpDownArrows - - - true - - - - - - -1 - - - 60 - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - -
diff --git a/src/gui/helpDialogGui.ui b/src/gui/helpDialogGui.ui deleted file mode 100644 index 4b7086a..0000000 --- a/src/gui/helpDialogGui.ui +++ /dev/null @@ -1,479 +0,0 @@ - - - helpDialogForm - - - - 0 - 0 - 383 - 458 - - - - - 250 - 250 - - - - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Help - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - - 0 - 74 - - - - - 16777215 - 74 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::SingleSelection - - - - 50 - 50 - - - - QListView::Static - - - QListView::LeftToRight - - - false - - - QListView::Adjust - - - QListView::SinglePass - - - 0 - - - QListView::IconMode - - - false - - - false - - - false - - - - Help - - - - :/graphicGui/tabicon-help.png - - - - - - About - - - - :/graphicGui/tabicon-info.png - - - - - - Log - - - - :/graphicGui/tabicon-logs.png - - - - - - - - - - - 0 - - - 0 - - - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 190 - 20 - - - - - - - - Edit keyboard shortcuts... - - - - - - - - - - - 0 - 0 - - - - - - - - - 3 - 3 - 3 - - - - - - - 3 - 3 - 3 - - - - - - - - - 3 - 3 - 3 - - - - - - - 3 - 3 - 3 - - - - - - - - - 3 - 3 - 3 - - - - - - - 3 - 3 - 3 - - - - - - - - true - - - Qt::DefaultContextMenu - - - false - - - - - - true - - - - - - - - - 0 - - - 0 - - - - - true - - - - - - - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - xxx - - - false - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Refresh - - - - - - - - - - - Lucida Console - false - - - - Qt::ScrollBarAlwaysOff - - - QTextEdit::WidgetWidth - - - false - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - false - - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - -
diff --git a/src/gui/locationDialogGui.ui b/src/gui/locationDialogGui.ui deleted file mode 100644 index a8b8ace..0000000 --- a/src/gui/locationDialogGui.ui +++ /dev/null @@ -1,750 +0,0 @@ - - - locationDialogForm - - - - 0 - 0 - 700 - 452 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 30 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 75 - false - true - - - - Location - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 240 - - - - - 16777215 - 240 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 400 - 240 - - - - - 400 - 240 - - - - 0 - - - - - - ../../data/gui/world.png - - - true - - - Qt::AlignCenter - - - - - - - - 0 - 240 - - - - - 16777215 - 240 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 0 - - - - - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - - - - - - - - - Current location information - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - PreferDefault - - - - Use as default - - - - - - - Return to default - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - 60 - 0 - - - - Delete - - - - - - - false - - - - 100 - 0 - - - - Add to list - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - - - Latitude: - - - - - - - - 180 - 24 - - - - You can enter values in decimal degrees, or using dms format, for example: +1d 12m 8s - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Longitude: - - - - - - - - 140 - 24 - - - - You can enter values in decimal degrees, or using dms format, for example: +1d 12m 8s - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Altitude: - - - - - - - - 100 - 24 - - - - Enter the altitude in meter - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m - - - -2000 - - - 200000 - - - 100 - - - - - - - - - - - 350 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Name/City: - - - - - - - New Location - - - - - - - Country: - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - true - - - - - - - Planet: - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - false - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
- - AngleSpinBox - QSpinBox -
AngleSpinBox.hpp
-
- - MapLabel - QLabel -
MapLabel.hpp
-
-
- - -
diff --git a/src/gui/scriptConsole.ui b/src/gui/scriptConsole.ui deleted file mode 100644 index 63c910d..0000000 --- a/src/gui/scriptConsole.ui +++ /dev/null @@ -1,553 +0,0 @@ - - - scriptConsoleForm - - - - 0 - 0 - 680 - 394 - - - - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - Script console - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - - 0 - 1 - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - 3 - - - - - - 0 - 0 - - - - - 28 - 28 - - - - load script from file - - - - - - - :/graphicGui/folder.png:/graphicGui/folder.png - - - Ctrl+O - - - - - - - - 0 - 0 - - - - - 28 - 28 - - - - save script to file - - - - - - - :/graphicGui/filesave.png:/graphicGui/filesave.png - - - Ctrl+S - - - - - - - - 0 - 0 - - - - - 28 - 28 - - - - clear script - - - - - - - :/graphicGui/closeButton.png:/graphicGui/closeButton.png - - - - - - - - 16777215 - 28 - - - - pre-process script using SSC preprocessor - - - SSC - - - - :/graphicGui/btFlipVertical-off.png:/graphicGui/btFlipVertical-off.png - - - - - - - - 16777215 - 28 - - - - pre-process script using STS preprocessor - - - STS - - - - :/graphicGui/btFlipVertical-off.png:/graphicGui/btFlipVertical-off.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - quickly load and run a utility script - - - - - - - - 0 - 0 - - - - - 28 - 28 - - - - run script - - - - - - - :/graphicGui/btScriptRun-off.png:/graphicGui/btScriptRun-off.png - - - Ctrl+Return - - - - - - - false - - - - 0 - 0 - - - - - 28 - 28 - - - - stop script - - - - - - - :/graphicGui/btScriptStop-off.png:/graphicGui/btScriptStop-off.png - - - Ctrl+C - - - - - - - - - QTabBar::tab { - min-height: 28px; -} - - - QTabWidget::North - - - 0 - - - - Script - - - - 0 - - - - - - DejaVu Sans Mono - 8 - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOn - - - QTextEdit::NoWrap - - - - - - - - Output - - - - 0 - - - - - - DejaVu Sans Mono - 8 - - - - - - - - - - - - 2 - - - 4 - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cursor position - - - R:0 C:0 - - - - - - - Include dir: - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 24 - 24 - - - - ... - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - 24 - 24 - - - - - Sans Serif - - - - SizeFDiagCursor - - - QFrame::StyledPanel - - - - - - - - - - frame - TitleBar - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
- - ResizeFrame - QFrame -
Dialog.hpp
- 1 -
-
- - - - -
diff --git a/src/gui/searchDialogGui.ui b/src/gui/searchDialogGui.ui deleted file mode 100644 index d53d56e..0000000 --- a/src/gui/searchDialogGui.ui +++ /dev/null @@ -1,844 +0,0 @@ - - - searchDialogForm - - - - 0 - 0 - 507 - 213 - - - - - 0 - 0 - - - - - 390 - 0 - - - - Qt::ClickFocus - - - Find Object - - - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - Qt::NoFocus - - - false - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Find Object or Position - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - - - - - - - - - - - 0 - - - - Object - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - - 0 - - - - - - 0 - 0 - - - - - - - Qt::StrongFocus - - - Use tab key for select of found items - - - false - - - - - - - - - - - 0 - 0 - - - - - 45 - 30 - - - - - 16777215 - 30 - - - - Qt::NoFocus - - - - 24 - 24 - - - - false - - - - - - - - - - - 35 - 0 - - - - - 390 - 0 - - - - Use tab key for select of found items - - - QFrame::NoFrame - - - 1 - - - - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::TextSelectableByMouse - - - - - - - - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - - - Qt::NoFocus - - - iota - - - ι - - - - - - - Qt::NoFocus - - - alpha - - - α - - - - - - - Qt::NoFocus - - - beta - - - β - - - - - - - Qt::NoFocus - - - gamma - - - γ - - - - - - - Qt::NoFocus - - - delta - - - δ - - - - - - - Qt::NoFocus - - - epsilon - - - ε - - - - - - - Qt::NoFocus - - - zeta - - - ζ - - - - - - - Qt::NoFocus - - - eta - - - η - - - - - - - Qt::NoFocus - - - theta - - - θ - - - - - - - Qt::NoFocus - - - kappa - - - κ - - - - - - - Qt::NoFocus - - - lambda - - - λ - - - - - - - Qt::NoFocus - - - mu - - - μ - - - - - - - Qt::NoFocus - - - nu - - - ν - - - - - - - Qt::NoFocus - - - xi - - - ξ - - - - - - - Qt::NoFocus - - - omicron - - - ο - - - - - - - Qt::NoFocus - - - pi - - - π - - - - - - - Qt::NoFocus - - - rho - - - ρ - - - - - - - Qt::NoFocus - - - sigma - - - σ - - - - - - - Qt::NoFocus - - - tau - - - τ - - - - - - - Qt::NoFocus - - - upsilon - - - υ - - - - - - - Qt::NoFocus - - - phi - - - φ - - - - - - - Qt::NoFocus - - - chi - - - χ - - - - - - - Qt::NoFocus - - - psi - - - ψ - - - - - - - Qt::NoFocus - - - omega - - - ω - - - - - - - Greek letters for Bayer designations - - - Qt::AlignCenter - - - - - - - - - - - Position - - - - 0 - - - - - - - - RA/Dec (J2000): - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 8 - 8 - - - - - - - - - 0 - 0 - - - - - - - - - - - - - Ubuntu - - - - Lists - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - Some objects may be found after activation respective plug-ins - - - - - - - - - - names in English - - - - - - - Search in list... - - - - - - - - Options - - - - 0 - - - 0 - - - - - On-line astronomical database SIMBAD - - - - 0 - - - - - Extend search with SIMBAD - - - - - - - - - Server: - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - false - - - - - - - - - - - - Search options - - - - 0 - - - - - Use autofill only from the beginning of words - - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
- - AngleSpinBox - QSpinBox -
AngleSpinBox.hpp
-
- - CompletionLabel - QLabel -
SearchDialog.hpp
-
-
- - tabWidget - lineEditSearchSkyObject - RAAngleSpinBox - DEAngleSpinBox - - - -
diff --git a/src/gui/shortcutsDialog.ui b/src/gui/shortcutsDialog.ui deleted file mode 100644 index 1993730..0000000 --- a/src/gui/shortcutsDialog.ui +++ /dev/null @@ -1,338 +0,0 @@ - - - shortcutsDialogForm - - - - 0 - 0 - 654 - 436 - - - - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Keyboard Shortcuts - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - true - - - true - - - true - - - 200 - - - 100 - - - true - - - true - - - - - - - - - - QFrame::StyledPanel - - - - QLayout::SetMaximumSize - - - 9 - - - 9 - - - 9 - - - - - Primary shortcut - - - - - - - false - - - - - - - Alternative shortcut - - - - - - - false - - - - - - - false - - - - - - - false - - - - - - - Restore Defaults - - - - - - - false - - - Apply - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
- - ShortcutLineEdit - QLineEdit -
ShortcutsDialog.hpp
- - backspace() - -
-
- - - - closeStelWindow - clicked() - shortcutsDialogForm - close() - - - 493 - 150 - - - 260 - 151 - - - - - primaryBackspaceButton - clicked() - primaryShortcutEdit - backspace() - - - 540 - 380 - - - 352 - 380 - - - - - altBackspaceButton - clicked() - altShortcutEdit - backspace() - - - 540 - 413 - - - 352 - 413 - - - - - primaryBackspaceButton - clicked() - primaryShortcutEdit - setFocus() - - - 540 - 380 - - - 352 - 380 - - - - - altBackspaceButton - clicked() - altShortcutEdit - setFocus() - - - 540 - 413 - - - 352 - 413 - - - - -
diff --git a/src/gui/viewDialog.ui b/src/gui/viewDialog.ui deleted file mode 100644 index 365e627..0000000 --- a/src/gui/viewDialog.ui +++ /dev/null @@ -1,1924 +0,0 @@ - - - viewDialogForm - - - - 0 - 0 - 648 - 511 - - - - - - - false - - - - - - - 0 - - - 0 - - - - - - 16 - 25 - - - - - 16777215 - 25 - - - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 194 - 194 - 195 - - - - - - - 194 - 194 - 195 - - - - - - - - - 75 - false - true - - - - - - - QFrame::StyledPanel - - - 0 - - - View - - - -1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::NoFocus - - - Qt::DefaultContextMenu - - - - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - - 0 - 74 - - - - - 16777215 - 74 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::SingleSelection - - - - 50 - 50 - - - - QListView::Static - - - QListView::LeftToRight - - - false - - - QListView::Adjust - - - QListView::SinglePass - - - 0 - - - QListView::IconMode - - - false - - - false - - - false - - - - Sky - - - - :/graphicGui/tabicon-sky.png - - - - - - Markings - - - - :/graphicGui/tabicon-markings.png - - - - - - Landscape - - - - :/graphicGui/tabicon-landscape.png - - - - - - Starlore - - - - :/graphicGui/tabicon-starlore.png - - - - - - - - - 2 - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 150 - - - - - 10 - 50 - false - - - - Labels and Markers - - - false - - - - 0 - - - - - Stars - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - 33 - - - Qt::Horizontal - - - - - - - Planets - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - 33 - - - Qt::Horizontal - - - - - - - Labels and markers for deep-sky objects (star clusters, galaxies and nebulas) - - - DSOs - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - 33 - - - Qt::Horizontal - - - - - - - - - - - 10 - 50 - false - - - - Planets and satellites - - - false - - - - 0 - - - - - Show planets - - - true - - - - - - - Show planet markers - - - - - - - - 0 - 0 - - - - Show planet orbits - - - - - - - Simulate light speed - - - - - - - Scale Moon - - - - - - - Automatic change of landscape when planet is changed - - - Auto select landscapes - - - - - - - - - - - 10 - 50 - false - - - - Atmosphere - - - - 0 - - - - - Show atmosphere - - - - - - - - - Light pollution: - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - 9 - - - 1 - - - - - - - - - pressure, temperature, extinction coefficient - - - Refraction/Extinction settings... - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - - - - 10 - 50 - false - - - - Stars - - - Qt::AlignLeading - - - false - - - false - - - false - - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Absolute scale: - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - Qt::AlignCenter - - - 1 - - - 9.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Relative scale: - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - true - - - Qt::AlignCenter - - - QAbstractSpinBox::UpDownArrows - - - 2 - - - 0.250000000000000 - - - 5.000000000000000 - - - 0.050000000000000 - - - 1.000000000000000 - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - - - Milky Way brightness: - - - - - - - - 70 - 16777215 - - - - Qt::AlignCenter - - - 1 - - - 10.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - - - Twinkle: - - - true - - - - - - - - 70 - 16777215 - - - - Qt::AlignCenter - - - 1 - - - 1.500000000000000 - - - 0.100000000000000 - - - - - - - - - - Dim faint stars when a very bright object is visible - - - Dynamic eye adaptation - - - false - - - - - - - - - - - 0 - 0 - - - - - 10 - 50 - false - - - - Shooting Stars - - - false - - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - - - Hourly zenith rate - - - ZHR: - - - Qt::PlainText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - QFrame::StyledPanel - - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - - - 0 - - - - - - - 10 - - - true - - - - - - - 80 - - - - - - - 1000 - - - - - - - 10000 - - - - - - - 144000 - - - - - - - - - - - - - Qt::RichText - - - false - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 10 - 50 - false - - - - Limit Magnitudes (for unaided/binocular observers) - - - Limit Magnitudes - - - false - - - - 0 - - - - - Limit the magnitude of stars - - - Stars - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - true - - - Qt::AlignCenter - - - QAbstractSpinBox::UpDownArrows - - - 2 - - - 3.000000000000000 - - - 21.000000000000000 - - - 0.250000000000000 - - - 8.500000000000000 - - - - - - - Limit the magnitude of deep-sky objects (star clusters, galaxies and nebulas) - - - DSOs - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 70 - 16777215 - - - - true - - - Qt::AlignCenter - - - QAbstractSpinBox::UpDownArrows - - - 2 - - - 0.000000000000000 - - - 21.000000000000000 - - - 0.100000000000000 - - - 6.500000000000000 - - - - - - - - - - - - 0 - - - 0 - - - - - - 10 - 50 - false - - - - Constellations - - - false - - - - 0 - - - - - Show lines - - - - - - - Show labels - - - - - - - Show boundaries - - - - - - - Show art - - - - - - - - - Art brightness: - - - - - - - 1.000000000000000 - - - 0.050000000000000 - - - - - - - - - Qt::Vertical - - - - 20 - 5 - - - - - - - - - - - - 10 - 50 - false - - - - Celestial Sphere - - - false - - - - 0 - - - - - - - - - Equatorial J2000 grid - - - - - - - Equatorial grid - - - - - - - Ecliptic J2000 grid - - - - - - - Azimuthal grid - - - - - - - Galactic grid - - - - - - - - - - - Show equator line - - - Equator - - - - - - - Show meridian line - - - Meridian - - - - - - - Show horizon line - - - Horizon - - - - - - - Show ecliptic line - - - Ecliptic - - - - - - - Show Galactic plane line - - - Galactic plane - - - - - - - - - - - - - Cardinal points - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 150 - - - - - 10 - 50 - false - - - - Projection - - - false - - - - 0 - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 180 - 16777215 - - - - Qt::NoFocus - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAlwaysOff - - - - - - - true - - - - - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 180 - 0 - - - - - 120 - 16777215 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - - - - - true - - - - 0 - 0 - - - - - 10 - - - - QFrame::StyledPanel - - - 1 - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - - 0 - 37 - - - - margin-left: 10px; margin-right: 10px; margin-bottom:10px; - - - Add/remove landscapes... - - - - - - - - 0 - 0 - - - - - 10 - 50 - false - - - - Options - - - false - - - - 0 - - - - - Show ground - - - - - - - Show fog - - - - - - - Use associated planet and position - - - - - - - Use this landscape as default - - - - - - - Use brightness settings for landscapes - - - - - - - - - - - - 0 - - - 0 - - - - - - 100 - 0 - - - - - 180 - 0 - - - - - 120 - 16777213 - - - - Qt::NoFocus - - - Qt::ScrollBarAlwaysOff - - - false - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 10 - - - - QFrame::StyledPanel - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 10 - 50 - false - - - - Options - - - - 0 - - - - - Use this sky culture as default - - - - - - - - - - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - 0 - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - true - - - true - - - - - - - Options - - - - 0 - - - - - Visible - - - - - - - - - - - - - - - - - - - - - - - - BarFrame - QFrame -
Dialog.hpp
- 1 -
-
- - starScaleRadiusDoubleSpinBox - starRelativeScaleDoubleSpinBox - starTwinkleCheckBox - starTwinkleAmountDoubleSpinBox - adaptationCheckbox - showPlanetCheckBox - planetMarkerCheckBox - planetOrbitCheckBox - planetLightSpeedCheckBox - planetScaleMoonCheckBox - showAtmosphereCheckBox - lightPollutionSpinBox - starLabelCheckBox - starsLabelsHorizontalSlider - nebulaLabelCheckBox - nebulasLabelsHorizontalSlider - planetLabelCheckBox - planetsLabelsHorizontalSlider - zhrNone - zhr10 - zhr80 - zhr10000 - zhr144000 - showEquatorialJ2000GridCheckBox - showEquatorialGridCheckBox - showEclipticGridJ2000CheckBox - showAzimuthalGridCheckBox - showGalacticGridCheckBox - showCardinalPointsCheckBox - showEquatorLineCheckBox - showMeridianLineCheckBox - showHorizonLineCheckBox - showEclipticLineCheckBox - showGalacticPlaneLineCheckBox - showConstellationLinesCheckBox - showConstellationLabelsCheckBox - showConstellationBoundariesCheckBox - showConstellationArtCheckBox - constellationArtBrightnessSpinBox - projectionTextBrowser - landscapeTextBrowser - showGroundCheckBox - showFogCheckBox - landscapePositionCheckBox - useAsDefaultLandscapeCheckBox - pushButtonAddRemoveLandscapes - skyCultureTextBrowser - useAsDefaultSkyCultureCheckBox - skyLayerListWidget - skyLayerTextBrowser - skyLayerEnableCheckBox - - - -
diff --git a/src/noGui/StelNoGui.cpp b/src/noGui/StelNoGui.cpp deleted file mode 100644 index e09461a..0000000 --- a/src/noGui/StelNoGui.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "StelNoGui.hpp" -#include - -StelGuiBase* StelNoGuiPluginInterface::getStelGuiBase() const -{ - return new StelNoGui(); -} -Q_EXPORT_PLUGIN2(StelGui, StelNoGuiPluginInterface) - -QProgressBar* StelNoGui::addProgressBar() -{ - return new QProgressBar(); -} diff --git a/src/noGui/StelNoGui.hpp b/src/noGui/StelNoGui.hpp deleted file mode 100644 index daa4614..0000000 --- a/src/noGui/StelNoGui.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _STELNOGUI_HPP_ -#define _STELNOGUI_HPP_ - -#include "StelGuiBase.hpp" - -//! @class StelNoGui -//! Dummy implementation of StelGuiBase to use when no GUI is used. -class StelNoGui : public StelGuiBase -{ -public: - StelNoGui() {;} - ~StelNoGui() {;} - virtual void init(QGraphicsWidget* topLevelGraphicsWidget, class StelAppGraphicsWidget* stelAppGraphicsWidget) {;} - virtual void updateI18n() {;} - virtual void setStelStyle(const QString& section) {;} - virtual void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {dummyInfoTextFilter=aflags;} - virtual const StelObject::InfoStringGroup& getInfoTextFilters() const {return dummyInfoTextFilter;} - virtual class QProgressBar* addProgressBar(); - virtual QAction* addGuiActions(const QString& actionName, const QString& text, const QString& shortCut, const QString& helpGroup, bool checkable=true, bool autoRepeat=false) {return NULL;} - virtual void forceRefreshGui() {;} - virtual void setVisible(bool b) {visible=b;} - virtual bool getVisible() const {return visible;} - virtual bool isCurrentlyUsed() const {return false;} -private: - StelObject::InfoStringGroup dummyInfoTextFilter; - bool visible; -}; - -//! An example GUI plugin with an empty GUI. -class StelNoGuiPluginInterface : public QObject, public StelGuiPluginInterface -{ - Q_OBJECT - Q_INTERFACES(StelGuiPluginInterface) -public: - virtual class StelGuiBase* getStelGuiBase() const; -}; - - - -#endif // _STELNOGUI_HPP_ diff --git a/src/tests/testConversions.cpp b/src/tests/testConversions.cpp deleted file mode 100644 index d64f0bf..0000000 --- a/src/tests/testConversions.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2013 Alexander Wolf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "tests/testConversions.hpp" -#include "StelUtils.hpp" -#include -#include -#include -#include -#include - -#define ERROR_LIMIT 1e-6 - -QTEST_MAIN(TestConversions) - -void TestConversions::testHMSToRad() -{ - QVariantList data; - - data << 0 << 0 << 0 << 0.; - data << 1 << 0 << 0 << M_PI/12; - data << 6 << 0 << 0 << M_PI/2; - data << 12 << 0 << 0 << M_PI; - data << 15 << 0 << 0 << 5*M_PI/4; - data << 0 << 15 << 0 << M_PI/720; - data << 0 << 0 << 15 << M_PI/43200; - data << 2 << 15 << 45 << 269*M_PI/1600; - data << 20 << 0 << 0 << 5*M_PI/3; - data << 24 << 0 << 0 << 2*M_PI; - data << 0 << 59 << 0 << 59*M_PI/10800; - data << 0 << 0 << 59 << 59*M_PI/648000; - data << 0 << 59 << 59 << 3599*M_PI/648000; - data << 3 << 59 << 59 << 165599*M_PI/648000; - - while (data.count() >= 4) - { - int h, m, s; - double rad; - h = data.takeFirst().toInt(); - m = data.takeFirst().toInt(); - s = data.takeFirst().toInt(); - rad = data.takeFirst().toDouble(); - QVERIFY2(std::abs(StelUtils::hmsToRad(h, m, s)-rad)<=ERROR_LIMIT, qPrintable(QString("%1h%2m%3s=%4").arg(h).arg(m).arg(s).arg(rad))); - } -} - -void TestConversions::testDMSToRad() -{ - QVariantList data; - - data << 0 << 0 << 0 << 0.; - data << 30 << 0 << 0 << M_PI/6; - data << 45 << 0 << 0 << M_PI/4; - data << 60 << 0 << 0 << M_PI/3; - data << 90 << 0 << 0 << M_PI/2; - data << 120 << 0 << 0 << 2*M_PI/3; - data << 180 << 0 << 0 << M_PI; - data << 270 << 0 << 0 << 3*M_PI/2; - data << 360 << 0 << 0 << 2*M_PI; - data << 0 << 30 << 0 << M_PI/360; - data << 0 << 45 << 0 << M_PI/240; - data << 30 << 30 << 0 << 61*M_PI/360; - data << 0 << 0 << 1 << M_PI/648000; - data << 90 << 58 << 30 << 1213*M_PI/2400; - data << 10 << 59 << 59 << 39599*M_PI/648000; - - while (data.count() >= 4) - { - int deg, min, sec; - double rad; - deg = data.takeFirst().toInt(); - min = data.takeFirst().toInt(); - sec = data.takeFirst().toInt(); - rad = data.takeFirst().toDouble(); - QVERIFY2(std::abs(StelUtils::dmsToRad(deg, min, sec)-rad)<=ERROR_LIMIT, qPrintable(QString("%1d%2m%3s=%4").arg(deg).arg(min).arg(sec).arg(rad))); - } -} - -void TestConversions::testRadToHMS() -{ - QVariantList data; - - data << 0. << 0 << 0 << 0.; - data << M_PI/36 << 0 << 19 << 59.9; - data << 7*M_PI/8 << 10 << 30 << 0.; - data << 2*M_PI/5 << 4 << 48 << 0.; - - while (data.count()>=4) - { - double rad, s, so, t1, t2; - int h, m; - unsigned int ho, mo; - rad = data.takeFirst().toDouble(); - h = data.takeFirst().toInt(); - m = data.takeFirst().toInt(); - s = data.takeFirst().toDouble(); - t1 = s+m*60+h*3600; - StelUtils::radToHms(rad, ho, mo, so); - t2 = so+mo*60+ho*3600; - QVERIFY2(std::abs(t1-t2)<=0.1, qPrintable(QString("%1rad=%2h%3m%4s").arg(rad).arg(ho).arg(mo).arg(so))); - } -} - -void TestConversions::testRadToDMS() -{ - QVariantList data; - - data << 0. << 0 << 0 << 0.; - data << M_PI/6 << 30 << 0 << 0.; - data << M_PI/4 << 45 << 0 << 0.; - data << M_PI/3 << 60 << 0 << 0.; - data << M_PI/2 << 90 << 0 << 0.; - data << 2*M_PI/3 << 120 << 0 << 0.; - data << M_PI << 180 << 0 << 0.; - data << 3*M_PI/2 << 270 << 0 << 0.; - data << M_PI/360 << 0 << 30 << 0.; - data << M_PI/240 << 0 << 45 << 0.; - data << 61*M_PI/360 << 30 << 30 << 0.; - data << M_PI/648000 << 0 << 0 << 1.; - data << 1213*M_PI/2400 << 90 << 58 << 30.; - data << 39599*M_PI/648000 << 10 << 59 << 59.; - data << -M_PI/36 << -5 << 0 << 0.; - data << -7*M_PI/8 << -157 << 30 << 0.; - data << -2*M_PI/5 << -72 << 0 << 0.; - data << -M_PI << -180 << 0 << 0.; - data << -10*M_PI/648 << -2 << 46 << 40.0; - - while (data.count()>=4) - { - double rad, sec, seco, angle1, angle2; - int deg, min; - unsigned int dego, mino; - bool sign; - QString s; - rad = data.takeFirst().toDouble(); - deg = data.takeFirst().toInt(); - min = data.takeFirst().toInt(); - sec = data.takeFirst().toDouble(); - if (deg>=0) - angle1 = sec+min*60+deg*3600; - else - angle1 = -1*(sec+min*60+std::abs(deg)*3600); - StelUtils::radToDms(rad, sign, dego, mino, seco); - angle2 = seco+mino*60+dego*3600; - if (!sign) - { - angle2 = -1*angle2; - s = "-"; - } - else - s = "+"; - QVERIFY2(std::abs(angle1-angle2)<=ERROR_LIMIT, qPrintable(QString("%1rad=%2%3d%4m%5s").arg(rad).arg(s).arg(dego).arg(mino).arg(seco))); - } -} diff --git a/src/tests/testConversions.hpp b/src/tests/testConversions.hpp deleted file mode 100644 index dc052af..0000000 --- a/src/tests/testConversions.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2013 Alexander Wolf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTCONVERSIONS_HPP_ -#define _TESTCONVERSIONS_HPP_ - -#include -#include - -class TestConversions : public QObject -{ -Q_OBJECT -private slots: - void testHMSToRad(); - void testDMSToRad(); - void testRadToHMS(); - void testRadToDMS(); -}; - -#endif // _TESTCONVERSIONS_HPP_ - diff --git a/src/tests/testDates.cpp b/src/tests/testDates.cpp deleted file mode 100644 index b9ce632..0000000 --- a/src/tests/testDates.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "StelUtils.hpp" -#include "tests/testDates.hpp" - -#define IGREG 2299161 - -QTEST_MAIN(TestDates) - -void TestDates::dateRoundTrip() -{ - QMap map; - map[0.0] = "-4712-01-01T12:00:00"; - map[-1.0] = "-4713-12-31T12:00:00"; - map[2454466.0] = "2007-12-31T12:00:00"; - map[1721058.0] = "0000-01-01T12:00:00"; - map[2500000.0] = "2132-08-31T12:00:00"; - map[366.0] = "-4711-01-01T12:00:00"; - map[2454534] = "2008-03-08T12:00:00"; - map[2299161.0] = "1582-10-15T12:00:00"; - map[2454466.5] = "2008-01-01T00:00:00"; - map[1720692.0] = "-0002-12-31T12:00:00"; - map[1720693.0] = "-0001-01-01T12:00:00"; - map[2400000.0] = "1858-11-16T12:00:00"; - map[2110516.00000] = "1066-04-12T12:00:00"; - map[1918395.00000] = "0540-04-12T12:00:00"; - map[1794575.00000] = "0201-04-12T12:00:00"; - map[1757319.00000] = "0099-04-12T12:00:00"; - map[1721424.0] = "0001-01-01T12:00:00"; - map[1721789.0] = "0002-01-01T12:00:00"; - map[1721423.0] = "0000-12-31T12:00:00"; - map[1000000.0] = "-1975-11-07T12:00:00"; - map[-31.0] = "-4713-12-01T12:00:00"; - map[-61.0] = "-4713-11-01T12:00:00"; - map[-92.0] = "-4713-10-01T12:00:00"; - map[-122.0] = "-4713-09-01T12:00:00"; - map[-153.0] = "-4713-08-01T12:00:00"; - map[-184.0] = "-4713-07-01T12:00:00"; - map[-214.0] = "-4713-06-01T12:00:00"; - map[-245.0] = "-4713-05-01T12:00:00"; - map[-275.0] = "-4713-04-01T12:00:00"; - map[-306.0] = "-4713-03-01T12:00:00"; - map[-334.0] = "-4713-02-01T12:00:00"; // 28 days - map[-365.0] = "-4713-01-01T12:00:00"; - map[-699.0] = "-4714-02-01T12:00:00"; // 28 days - map[-1064.0] = "-4715-02-01T12:00:00"; // 28 days - map[-1430.0] = "-4716-02-01T12:00:00"; // 29 days - map[-1795.0] = "-4717-02-01T12:00:00"; // 28 days - map[-39388.5] = "-4820-02-29T00:00:00"; // 29 days - map[-1930711.0] ="-9998-01-01T12:00:00"; - map[-1930712.0] ="-9999-12-31T12:00:00"; - - bool ok; - Q_UNUSED(ok); - //FIXME: This unit test should be fixed - /* - for (QMap::ConstIterator i=map.constBegin();i!=map.constEnd();++i) - { - QCOMPARE(StelUtils::julianDayToISO8601String(i.key()), i.value()); - double tmp = StelUtils::getJulianDayFromISO8601String(i.value(), &ok); - QVERIFY(ok); - if (i.key()!=0.0) - qFuzzyCompare(i.key(), tmp); - else - qFuzzyCompare(i.key()+1.0, tmp+1.0); - } - */ -} - - -void TestDates::formatting() -{ - // test formatting of StelUtils::localeDateString, the fall-back if QDateTime cannot do it. - QLocale::setDefault(QLocale::German); - QVERIFY2(QString::compare(StelUtils::localeDateString(2008, 03, 10, 0), QString("10.03.08")) == 0, - qPrintable("german for 2008-03-10 wrong: " + (StelUtils::localeDateString(2008, 03, 10, 0)))); - QVERIFY2(QString::compare(StelUtils::localeDateString(8, 03, 10, 0), QString("10.03.08")) == 0, - qPrintable("german for 8-03-10 wrong: " + (StelUtils::localeDateString(8, 03, 10, 0)))); - QVERIFY2(QString::compare(StelUtils::localeDateString(-8, 03, 10, 0), QString("10.03.-8")) == 0, - qPrintable("german for -8-03-10 wrong: " + (StelUtils::localeDateString(-8, 03, 10, 0)))); - QVERIFY2(QString::compare(StelUtils::localeDateString(-1118, 03, 10, 0), QString("10.03.-18")) == 0, - qPrintable("german for -1118-03-10 wrong: " + (StelUtils::localeDateString(-1118, 03, 10, 0)))); - QVERIFY2(QString::compare(StelUtils::localeDateString(-5118, 03, 10, 0), QString("10.03.-18")) == 0, - qPrintable("german for -5118-03-10 wrong: " + (StelUtils::localeDateString(-5118, 03, 10, 0)))); - - QVERIFY2(-18 == (-5118 % 100), qPrintable("modulus arithmetic works diff: " + QString("%1").arg(-5118 % 100))); - - // test arbitrary fmt - // This is useless, as StelUtils::localeDateString() formats dates - // according to the *system* locale. On systems where it is not English, - // this test fails. - // See https://bugreports.qt-project.org/browse/QTBUG-27789. --BM -// QLocale::setDefault(QLocale::English); - -// QString easyLong("d dd ddd dddd M MM MMM MMMM yy yyyy"); -// QVERIFY2(QString::compare(QString("9 09 Sun Sunday 3 03 Mar March 08 2008"), StelUtils::localeDateString(2008, 3, 9, 6, easyLong)) == 0, -// qPrintable("formatter1 not working: " + StelUtils::localeDateString(2008, 3, 9, 6, easyLong))); -// QString hardLong("dddddddd '''doh' ''yyyyyyy"); -// QVERIFY2(QString::compare(QString("SundaySunday 'doh '200808y"), StelUtils::localeDateString(2008, 3, 9, 6, hardLong)) == 0, -// qPrintable("formatter2 not working: " + StelUtils::localeDateString(2008, 3, 9, 6, hardLong))); - - // test detection of offset from UTC. - double mar122008 = QDate(2008,3,12).toJulianDay(); - qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar122008), -4.f); - double mar012008 = QDate(2008,3,1).toJulianDay(); - qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar012008), -5.f); - -} - -void TestDates::testRolloverAndValidity() -{ - QVERIFY2(31==StelUtils::numberOfDaysInMonthInYear(1, 2008), "1a"); - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, 2008), "1b"); - QVERIFY2(28==StelUtils::numberOfDaysInMonthInYear(2, 2007), "1c"); - - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, 2000), "1d"); - QVERIFY2(28==StelUtils::numberOfDaysInMonthInYear(2, 1900), "1e"); - - QVERIFY2(28==StelUtils::numberOfDaysInMonthInYear(2, 1001), "1f"); - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, 1000), "1g"); - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, 1200), "1h"); - - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, 0), "1i"); - QVERIFY2(28==StelUtils::numberOfDaysInMonthInYear(2, 1), "1j"); - QVERIFY2(29==StelUtils::numberOfDaysInMonthInYear(2, -4), "1k"); - - int dy, dm, dd, dh, dmin,ds; - - QVERIFY2(StelUtils::changeDateTimeForRollover(2008, 1, 32, 12, 0, 0, &dy, &dm, &dd, &dh, &dmin, &ds), "1l"); - QVERIFY(2008==dy); - QVERIFY(2==dm); - QVERIFY(1==dd); - QVERIFY(12==dh); - QVERIFY(0==dmin); - QVERIFY(0==ds); - - QVERIFY2(StelUtils::changeDateTimeForRollover(-1, 12, 32, 12, 0, 0, &dy, &dm, &dd, &dh, &dmin, &ds), "1m"); - QVERIFY(0==dy); - QVERIFY(1==dm); - QVERIFY(1==dd); - QVERIFY(12==dh); - QVERIFY(0==dmin); - QVERIFY(0==ds); - - QVERIFY2(StelUtils::changeDateTimeForRollover(-1, 11, 45, 12, 0, 0, &dy, &dm, &dd, &dh, &dmin, &ds), "1n"); - QVERIFY(-1==dy); - QVERIFY(12==dm); - QVERIFY(15==dd); - QVERIFY(12==dh); - QVERIFY(0==dmin); - QVERIFY(0==ds); -} - -/* - * Original algorithm from "Numerical Recipes in c, 2nd Ed.", pp. 14-15 - */ -static void caldat(long julian, int *mm, int *id, int *iyyy) -{ - long ja, jalpha, jb, jc, jd, je; - if (julian >= IGREG) { - jalpha = (long)(((double)(julian - 1867216) - 0.25) / 36524.25); - ja = julian + 1 + jalpha -(long)(0.25 * jalpha); - } else if (julian < 0) { - ja = julian + 36525 * (1 - julian / 36525); - } else { - ja = julian; - } - jb = ja + 1524; - jc = (long)(6680.0 + ((double)(jb - 2439870) - 122.1) / 365.25); - jd = (long)(365 * jc + (0.25 * jc)); - je = (long)((jb - jd) / 30.6001); - *id = jb - jd -(long)(30.6001 * je); - - *mm = je - 1; - if (*mm > 12) { - *mm -= 12; - } - *iyyy = jc - 4715; - if (*mm > 2) { - --(*iyyy); - } - if (julian < 0) { - *iyyy -= 100 * (1 - julian / 36525); - } -} - -static void oldGetDateFromJulianDay(double jd, int *year, int *month, int *day) -{ - int y, m, d; - - // put us in the right calendar day for the time of day. - double fraction = jd - floor(jd); - if (fraction >= .5) - { - jd += 1.0; - } - - if (jd >= 2299161) - { - // Gregorian calendar starting from October 15, 1582 - // This algorithm is from Henry F. Fliegel and Thomas C. Van Flandern - qulonglong ell, n, i, j; - ell = qulonglong(floor(jd)) + 68569; - n = (4 * ell) / 146097; - ell = ell - (146097 * n + 3) / 4; - i = (4000 * (ell + 1)) / 1461001; - ell = ell - (1461 * i) / 4 + 31; - j = (80 * ell) / 2447; - d = ell - (2447 * j) / 80; - ell = j / 11; - m = j + 2 - (12 * ell); - y = 100 * (n - 49) + i + ell; - } - else - { - // Julian calendar until October 4, 1582 - // Algorithm from Frequently Asked Questions about Calendars by Claus Toendering - int julianDay = (int)floor(jd); - julianDay += 32082; - int dd = (4 * julianDay + 3) / 1461; - int ee = julianDay - (1461 * dd) / 4; - int mm = ((5 * ee) + 2) / 153; - d = ee - (153 * mm + 2) / 5 + 1; - m = mm + 3 - 12 * (mm / 10); - y = dd - 4800 + (mm / 10); - } - *year = y; - *month = m; - *day = d; -} - -static bool oldGetJDFromDate(double* newjd, int y, int m, int d, int h, int min, int s) -{ - double deltaTime = (h / 24.0) + (min / (24.0*60.0)) + (s / (24.0 * 60.0 * 60.0)) - 0.5; - QDate test((y <= 0 ? y-1 : y), m, d); - // if QDate will oblige, do so. - if ( test.isValid() ) - { - double qdjd = (double)test.toJulianDay(); - qdjd += deltaTime; - *newjd = qdjd; - return true; - } else - { - double jd = (double)((1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075) - 38; - jd += deltaTime; - *newjd = jd; - return true; - } - return false; -} - -void TestDates::testJulianDaysRange(int jd_a, int jd_b) -{ - int jd; - double djd; - int yy, mm, dd, yy0, mm0, dd0, dim; - int jdFirst, jdLast; - - if (jd_a > jd_b) - { - jdFirst = jd_a; - jdLast = jd_b; - } else { - jdFirst = jd_b; - jdLast = jd_a; - } - - qDebug() << "testing range " << jdLast << "..." << jdFirst; - - jd = jdFirst; - - StelUtils::getDateFromJulianDay(jd, &yy0, &mm0, &dd0); - - jd--; - - for ( ; jd >= jdLast; jd--) - { - StelUtils::getDateFromJulianDay(jd, &yy, &mm, &dd); - StelUtils::getJDFromDate(&djd, yy, mm, dd, 12, 0, 0); - - QVERIFY2((long)djd == jd, - qPrintable("wrong jd from day " + QString("%1/%2/%3").arg(yy).arg(mm).arg(dd) + - ": expected " + QString("%1").arg(jd) + ", found " + QString("%1").arg((long)djd) - ) - ); - - QVERIFY2(mm >= 1 && mm <= 12, - qPrintable("wrong month " + QString("%1").arg(mm) + " for jd " + QString("%1").arg(jd))); - dim = StelUtils::numberOfDaysInMonthInYear(mm, yy); - - QVERIFY2(dd >= 1 && dd <= dim, - qPrintable("bad date " + QString("%1/%2/%3").arg(yy).arg(mm).arg(dd) + - " for jd " + QString("%1").arg(jd) + "; previous date was " + - QString("%1/%2/%3").arg(yy0).arg(mm0).arg(dd0) + " for jd " + QString("%1").arg(jd + 1) - ) - ); - if (dd0 > 1) { - // day changed, month and year are the same - QVERIFY2(dd == (dd0 - 1), - qPrintable("wrong day: expected " + QString("%1").arg(dd0 - 1) + - ", found " + QString("%1").arg(dd) + ", jd " + QString("%1").arg(jd) - ) - ); - QCOMPARE(mm, mm0); - QCOMPARE(yy, yy0); - } else { - // day changed to the last day of previous month; - QVERIFY(dd > dd0); - if (mm0 > 1) { - // month changed; year is the same - QVERIFY2((mm0 - 1) == mm, - qPrintable("bad month change, month not adjacent; date is " + - QString("%1/%2/%3").arg(yy).arg(mm).arg(dd) + " for jd " + QString("%1").arg(jd) + - "; previous date was " +QString("%1/%2/%3").arg(yy0).arg(mm0).arg(dd0) + - " for jd " + QString("%1").arg(jd + 1) - ) - ); - QVERIFY2(yy0 == yy, - qPrintable("bad month change, year changed; date is " + - QString("%1/%2/%3").arg(yy).arg(mm).arg(dd) + " for jd " + QString("%1").arg(jd) + - "; previous date was " +QString("%1/%2/%3").arg(yy0).arg(mm0).arg(dd0) + - " for jd " + QString("%1").arg(jd + 1) - ) - ); - } else { - // month changed to december of the previous year - QCOMPARE(mm, 12); - QCOMPARE(yy, yy0 - 1); - } - } - dd0 = dd; - mm0 = mm; - yy0 = yy; - } - -} - -void TestDates::testJulianDays() -{ - testJulianDaysRange( 400000000, 400001000); - testJulianDaysRange( 200000000, 200001000); - testJulianDaysRange( 2299200, 2299161); - testJulianDaysRange( 2299160, 2299000); - testJulianDaysRange( 2211000, 2210000); - testJulianDaysRange( 1721789, 1721788); - testJulianDaysRange( 1721424, 1721423); - testJulianDaysRange( 1501000, 1500000); - testJulianDaysRange( 1001000, 1000000); - testJulianDaysRange( 501000, 500000); - testJulianDaysRange( 1000, -1000); - testJulianDaysRange( -32000, -33000); - testJulianDaysRange( -320000, -319000); - testJulianDaysRange( -1905086, -1905084); - testJulianDaysRange( -1001000, -1000000); - testJulianDaysRange( -2001000, -2000000); - testJulianDaysRange( -2301000, -2300000); - testJulianDaysRange( -99001000, -99000000); - testJulianDaysRange(-200001000, -200000000); - testJulianDaysRange(-400001000, -400000000); -} - -#define TJ1 (2450000) - -void TestDates::benchmarkOldGetDateFromJulianDay() -{ - long jd = TJ1; - int mm, dd, yy; - - QBENCHMARK { - oldGetDateFromJulianDay(jd++, &yy, &mm, &dd); - } -} - -void TestDates::benchmarkGetDateFromJulianDayFloatingPoint() -{ - long jd = TJ1; - int mm, dd, yy; - - QBENCHMARK { - caldat(jd++, &mm, &dd, &yy); - } -} - -void TestDates::benchmarkGetDateFromJulianDay() -{ - long jd = TJ1; - int mm, dd, yy; - - QBENCHMARK { - StelUtils::getDateFromJulianDay(jd++, &yy, &mm, &dd); - } -} - -static QList *newDatesTestList(void) -{ - QList *testDates = new QList(); - QDate *qd; - double djd; - long jd, jd1, jd2; - int yy, mm, dd; - - StelUtils::getJDFromDate(&djd, 2000, 1, 1, 12, 0, 0); - jd1 = (long)djd; - StelUtils::getJDFromDate(&djd, 2012, 1, 1, 12, 0, 0); - jd2 = (long)djd; - - for (jd = jd1; jd < jd2; jd++) - { - StelUtils::getDateFromJulianDay(jd, &yy, &mm, &dd); - qd = new QDate(yy, mm, dd); - testDates->append(qd); - } - return testDates; -} - -void TestDates::benchmarkOldGetJDFromDate() -{ -// oldGetJDFromDate(&djd, qd->year(), qd->month(), qd->day(), 12, 0, 0); - QList *testDates; - int ii, nn; - const QDate *qd; - double djd; - - testDates = newDatesTestList(); - - nn = testDates->size(); - ii = 0; - QBENCHMARK { - qd = testDates->at(ii); - oldGetJDFromDate(&djd, qd->year(), qd->month(), qd->day(), 12, 0, 0); - if (++ii >= nn) - { - ii = 0; - } - } - - while (!testDates->isEmpty()) - { - delete testDates->takeFirst(); - } - - delete testDates; -} - -void TestDates::benchmarkGetJDFromDate() -{ - QList *testDates; - int ii, nn; - const QDate *qd; - double djd; - - testDates = newDatesTestList(); - - nn = testDates->size(); - ii = 0; - QBENCHMARK { - qd = testDates->at(ii); - StelUtils::getJDFromDate(&djd, qd->year(), qd->month(), qd->day(), 12, 0, 0); - if (++ii >= nn) - { - ii = 0; - } - } - - while (!testDates->isEmpty()) - { - delete testDates->takeFirst(); - } - - delete testDates; -} diff --git a/src/tests/testDates.hpp b/src/tests/testDates.hpp deleted file mode 100644 index 53a1fc9..0000000 --- a/src/tests/testDates.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTDATES_HPP_ -#define _TESTDATES_HPP_ - -#include -#include - -class TestDates : public QObject -{ -Q_OBJECT -private slots: - void dateRoundTrip(); - void formatting(); - void testRolloverAndValidity(); - void testJulianDays(); - void benchmarkOldGetDateFromJulianDay(); - void benchmarkGetDateFromJulianDayFloatingPoint(); - void benchmarkGetDateFromJulianDay(); - void benchmarkOldGetJDFromDate(); - void benchmarkGetJDFromDate(); - -private: - void testJulianDaysRange(int jd_first, int jd_last); -}; - -#endif // _TESTDATES_HPP_ - diff --git a/src/tests/testDeltaT.cpp b/src/tests/testDeltaT.cpp deleted file mode 100644 index 91fed73..0000000 --- a/src/tests/testDeltaT.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2010 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "tests/testDeltaT.hpp" -#include -#include -#include -#include -#include -#include - -#include - -#define ERROR_THRESHOLD_PERCENT 5.0 - -QTEST_MAIN(TestDeltaT) - -void TestDeltaT::initTestCase() -{ -} - -void TestDeltaT::historicalTest() -{ - // test data from http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html#tab1 - QVariantList data; - - data << -500 << 17190 << 430; - data << -400 << 15530 << 390; - data << -300 << 14080 << 360; - data << -200 << 12790 << 330; - data << -100 << 11640 << 290; - data << 0 << 10580 << 260; - data << 100 << 9600 << 240; - data << 200 << 8640 << 210; - data << 300 << 7680 << 180; - data << 400 << 6700 << 160; - data << 500 << 5710 << 140; - data << 600 << 4740 << 120; - data << 700 << 3810 << 100; - data << 800 << 2960 << 80; - data << 900 << 2200 << 70; - data << 1000 << 1570 << 55; - data << 1100 << 1090 << 40; - data << 1200 << 740 << 30; - data << 1300 << 490 << 20; - data << 1400 << 320 << 20; - data << 1500 << 200 << 20; - data << 1600 << 120 << 20; - data << 1700 << 9 << 5; - data << 1750 << 13 << 2; - data << 1800 << 14 << 1; - data << 1850 << 7 << 1; - data << 1900 << -3 << 1; - data << 1950 << 29 << 0.1; - data << 1955 << 31.1 << 0.1; - data << 1960 << 33.2 << 0.1; - data << 1965 << 35.7 << 0.1; - data << 1970 << 40.2 << 0.1; - data << 1975 << 45.5 << 0.1; - data << 1980 << 50.5 << 0.1; - data << 1985 << 54.3 << 0.1; - data << 1990 << 56.9 << 0.1; - data << 1995 << 60.8 << 0.1; - data << 2000 << 63.8 << 0.1; - data << 2005 << 64.7 << 0.1; - - while(data.count() >= 3) - { - int year = data.takeFirst().toInt(); - int yout, mout, dout; - double JD; - double expectedResult = data.takeFirst().toDouble(); - double acceptableError = data.takeFirst().toDouble(); - StelUtils::getJDFromDate(&JD, year, 1, 1, 0, 0, 0); - double result = StelUtils::getDeltaTByEspenakMeeus(JD); - double actualError = std::abs(expectedResult) - std::abs(result); - StelUtils::getDateFromJulianDay(JD, &yout, &mout, &dout); - QVERIFY2(actualError <= acceptableError, QString("date=%2 year=%3 result=%4 error=%5 acceptable=%6") - .arg(QString("%1-%2-%3 00:00:00").arg(yout).arg(mout).arg(dout)) - .arg(year) - .arg(result) - .arg(actualError) - .arg(acceptableError) - .toUtf8()); - } -} - diff --git a/src/tests/testDeltaT.hpp b/src/tests/testDeltaT.hpp deleted file mode 100644 index 7082828..0000000 --- a/src/tests/testDeltaT.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2010 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTDELTAT_HPP_ -#define _TESTDELTAT_HPP_ - -#include -#include -#include -#include - -#include "StelUtils.hpp" - -class TestDeltaT : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - void historicalTest(); - -}; - -#endif // _TESTDELTAT_HPP_ - diff --git a/src/tests/testStelFileMgr.cpp b/src/tests/testStelFileMgr.cpp deleted file mode 100644 index 7605882..0000000 --- a/src/tests/testStelFileMgr.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "StelFileMgr.hpp" -#include "tests/testStelFileMgr.hpp" - -QTEST_MAIN(TestStelFileMgr) - -void TestStelFileMgr::initTestCase() -{ - partialPath1 = "testfilemgr/path1"; - partialPath2 = "testfilemgr/path2"; - workingDir = tempDir.path(); - workingDir.replace(QRegExp("/+$"), ""); // sometimes the temp path will have / on the end... zap it. - if (!QDir::setCurrent(workingDir)) - { - QFAIL(qPrintable("could not set the working directory to: "+workingDir)); - } - - qDebug() << "working directory: " << QDir::toNativeSeparators(QDir::currentPath()); - - // set up a directory hierarchy to test on... - testDirs << "data" - << "testfilemgr" - << partialPath1 - << partialPath1+"/landscapes" - << partialPath1+"/landscapes/ls1" - << partialPath1+"/landscapes/ls2" - << partialPath1+"/landscapes/emptydir" - << partialPath2 - << partialPath2+"/landscapes" - << partialPath2+"/landscapes/ls1" - << partialPath2+"/landscapes/ls3"; - - testFiles << "data/ssystem.ini" - << partialPath1+"/landscapes/ls1/landscape.ini" - << partialPath1+"/landscapes/ls2/landscape.ini" - << partialPath1+"/config.ini" - << partialPath1+"/inboth.txt" - << partialPath2+"/landscapes/dummy.txt" - << partialPath2+"/landscapes/ls1/landscape.ini" - << partialPath2+"/landscapes/ls3/landscape.ini" - << partialPath2+"/inboth.txt"; - - foreach(QString path, testDirs) - { - if (!QDir().mkdir(path)) - { - QFAIL(qPrintable("could not create test path " + path)); - } - } - - // create test files as empty files... - foreach(QString path, testFiles) - { - QFile f(path); - if (!f.open(QIODevice::WriteOnly)) - { - QFAIL(qPrintable("could not create test file " + path)); - } - f.close(); - } - - QStringList path; - path << "./"+partialPath1; - path << workingDir+"/"+partialPath2; - - StelFileMgr::init(); - StelFileMgr::setSearchPaths(path); - qDebug() << "search paths are: " << path; -} - -void TestStelFileMgr::testFindFileVanilla() -{ - QString exists, notExists; - exists = StelFileMgr::findFile("landscapes"); - notExists = StelFileMgr::findFile("notexists"); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="landscapes"); - QVERIFY(notExists.isEmpty()); -} - -void TestStelFileMgr::testFindFileVanillaAbs() -{ - QString exists, notExists; - exists = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/config.ini"); - notExists = StelFileMgr::findFile(workingDir + "/" + partialPath2 + "/config.ini"); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="config.ini"); - QVERIFY(notExists.isEmpty()); -} - -void TestStelFileMgr::testFindFileFile() -{ - QString exists, notExists, existsWrongType; - exists = StelFileMgr::findFile("config.ini", StelFileMgr::File); - notExists = StelFileMgr::findFile("notexists", StelFileMgr::File); - existsWrongType = StelFileMgr::findFile("landscapes", StelFileMgr::File); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="config.ini"); - QVERIFY(notExists.isEmpty()); - QVERIFY(existsWrongType.isEmpty()); -} - -void TestStelFileMgr::testFindFileFileAbs() -{ - QString exists, notExists, existsWrongType; - exists = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/config.ini", StelFileMgr::File); - notExists = StelFileMgr::findFile(workingDir + "/" + partialPath2 + "/config.ini", StelFileMgr::File); - existsWrongType = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/landscapes", StelFileMgr::File); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="config.ini"); - QVERIFY(notExists.isEmpty()); - QVERIFY(existsWrongType.isEmpty()); -} - -void TestStelFileMgr::testFindFileDir() -{ - QString exists, notExists, existsWrongType; - exists = StelFileMgr::findFile("landscapes", StelFileMgr::Directory); - notExists = StelFileMgr::findFile("notexists", StelFileMgr::Directory); - existsWrongType = StelFileMgr::findFile("config.ini", StelFileMgr::Directory); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="landscapes"); - QVERIFY(notExists.isEmpty()); - QVERIFY(existsWrongType.isEmpty()); -} - -void TestStelFileMgr::testFindFileDirAbs() -{ - QString exists, notExists, existsWrongType; - exists = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/landscapes", StelFileMgr::Directory); - notExists = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/notexists", StelFileMgr::Directory); - existsWrongType = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/config.ini", StelFileMgr::Directory); - - QVERIFY(!exists.isEmpty()); - QVERIFY(QFileInfo(exists).fileName()=="landscapes"); - QVERIFY(notExists.isEmpty()); - QVERIFY(existsWrongType.isEmpty()); -} - -void TestStelFileMgr::testFindFileNew() -{ - QString existsInBoth, notExistsInOne, notExistsInBoth; - existsInBoth = StelFileMgr::findFile("inboth.txt", StelFileMgr::New); - notExistsInOne = StelFileMgr::findFile("config.ini", StelFileMgr::New); - notExistsInBoth = StelFileMgr::findFile("notexists", StelFileMgr::New); - - //QVERIFY(existsInBoth.isEmpty()); - - QVERIFY(!notExistsInOne.isEmpty()); - QVERIFY(!QFileInfo(notExistsInOne).exists()); - QVERIFY(QFileInfo(notExistsInOne).fileName()=="config.ini"); - - QVERIFY(!notExistsInBoth.isEmpty()); - QVERIFY(!QFileInfo(notExistsInBoth).exists()); - QVERIFY(QFileInfo(notExistsInBoth).fileName()=="notexists"); -} - -void TestStelFileMgr::testFindFileNewAbs() -{ - QString existsInBoth, notExistsInOne; - existsInBoth = StelFileMgr::findFile(workingDir + "/" + partialPath1 + "/inboth.txt", StelFileMgr::New); - notExistsInOne = StelFileMgr::findFile(workingDir + "/" + partialPath2 + "/config.ini", StelFileMgr::New); - - QVERIFY(existsInBoth.isEmpty()); - - QVERIFY(!notExistsInOne.isEmpty()); - QVERIFY(!QFileInfo(notExistsInOne).exists()); - QVERIFY(QFileInfo(notExistsInOne).fileName()=="config.ini"); -} - -void TestStelFileMgr::testListContentsVanilla() -{ - QSet resultSetEmptyQuery; - QSet resultSetDotQuery; - QSet resultSetEmptyQueryExpected; - resultSetEmptyQuery = StelFileMgr::listContents(""); - resultSetDotQuery = StelFileMgr::listContents("."); - resultSetEmptyQueryExpected << "config.ini" << "landscapes" << "inboth.txt"; - //FIXME: unit test not work - /* - QVERIFY(resultSetEmptyQuery==resultSetEmptyQueryExpected); - QVERIFY(resultSetDotQuery==resultSetEmptyQueryExpected); - */ - - // now for some path within the hierarchy - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents("landscapes"); - resultSetQueryExpected << "ls1" << "ls2" << "ls3" << "emptydir" << "dummy.txt"; - //FIXME: unit test not work - /* - QVERIFY(resultSetQuery==resultSetQueryExpected); - */ -} - -void TestStelFileMgr::testListContentsVanillaAbs() -{ - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents(workingDir + "/" + partialPath2 + "/landscapes"); - resultSetQueryExpected << "ls1" << "ls3" << "dummy.txt"; - QVERIFY(resultSetQuery==resultSetQueryExpected); -} - -void TestStelFileMgr::testListContentsFile() -{ - QSet resultSetEmptyQuery; - QSet resultSetDotQuery; - QSet resultSetEmptyQueryExpected; - resultSetEmptyQuery = StelFileMgr::listContents("", StelFileMgr::File); - resultSetDotQuery = StelFileMgr::listContents(".", StelFileMgr::File); - resultSetEmptyQueryExpected << "config.ini" << "inboth.txt"; - //FIXME: unit test not work - /* - QVERIFY(resultSetEmptyQuery==resultSetEmptyQueryExpected); - QVERIFY(resultSetDotQuery==resultSetEmptyQueryExpected); - */ - - // now for some path within the hierarchy - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents("landscapes/ls1", StelFileMgr::File); - resultSetQueryExpected << "landscape.ini"; - //FIXME: unit test not work - /* - QVERIFY(resultSetQuery==resultSetQueryExpected); - */ -} - -void TestStelFileMgr::testListContentsFileAbs() -{ - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents(workingDir + "/" + partialPath2 + "/landscapes", StelFileMgr::File); - resultSetQueryExpected << "dummy.txt"; - QVERIFY(resultSetQuery==resultSetQueryExpected); -} - -void TestStelFileMgr::testListContentsDir() -{ - QSet resultSetEmptyQuery; - QSet resultSetDotQuery; - QSet resultSetEmptyQueryExpected; - resultSetEmptyQuery = StelFileMgr::listContents("", StelFileMgr::Directory); - resultSetDotQuery = StelFileMgr::listContents(".", StelFileMgr::Directory); - resultSetEmptyQueryExpected << "landscapes"; - //FIXME: unit test not work - /* - QVERIFY(resultSetEmptyQuery==resultSetEmptyQueryExpected); - QVERIFY(resultSetDotQuery==resultSetEmptyQueryExpected); - */ - - // now for some path within the hierarchy - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents("landscapes", StelFileMgr::Directory); - resultSetQueryExpected << "ls1" << "ls2" << "ls3" << "emptydir"; - //FIXME: unit test not work - /* - QVERIFY(resultSetQuery==resultSetQueryExpected); - */ -} - -void TestStelFileMgr::testListContentsDirAbs() -{ - QSet resultSetQuery; - QSet resultSetQueryExpected; - resultSetQuery = StelFileMgr::listContents(workingDir + "/" + partialPath2 + "/landscapes", StelFileMgr::Directory); - resultSetQueryExpected << "ls1" << "ls3"; - QVERIFY(resultSetQuery==resultSetQueryExpected); -} - diff --git a/src/tests/testStelFileMgr.hpp b/src/tests/testStelFileMgr.hpp deleted file mode 100644 index 5686147..0000000 --- a/src/tests/testStelFileMgr.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Matthew Gates - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTSTELFILEMGR_HPP_ -#define _TESTSTELFILEMGR_HPP_ - -#include -#include -#include -#include -#include - -class StelFileMgr; - -class TestStelFileMgr : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - - void testFindFileVanilla(); - void testFindFileVanillaAbs(); - void testFindFileFile(); - void testFindFileFileAbs(); - void testFindFileDir(); - void testFindFileDirAbs(); - void testFindFileNew(); - void testFindFileNewAbs(); - void testListContentsVanilla(); - void testListContentsVanillaAbs(); - void testListContentsFile(); - void testListContentsFileAbs(); - void testListContentsDir(); - void testListContentsDirAbs(); - -private: - QTemporaryDir tempDir; - QString workingDir; - QString partialPath1; - QString partialPath2; - QStringList testDirs; - QStringList testFiles; -}; - -#endif // _TESTSTELFILEMGR_HPP_ - diff --git a/src/tests/testStelJsonParser.cpp b/src/tests/testStelJsonParser.cpp deleted file mode 100644 index 64fa436..0000000 --- a/src/tests/testStelJsonParser.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include -#include - -#include "testStelJsonParser.hpp" -#include "StelJsonParser.hpp" - -QTEST_MAIN(TestStelJsonParser); - -void TestStelJsonParser::initTestCase() -{ - largeJsonBuff = "{\"test1\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test2\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test3\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test4\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test5\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test6\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test7\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test8\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test9\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test10\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test11\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}, \ - \"test12\": {\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}}"; - - listJsonBuff = "[{\"project\":\"GOODS\",\"license\":\"ESO Data License : http://www.myLicenseToBeDefinedAtSomePoint.html\",\"copyright\":\"(c) GOODS Sep 10 2007 12:00AM\",\"creator\":\"C. Cesarsky\",\"dataType\":\"image\",\"characterization\":{\"spatialAxis\":{\"footprint\":{\"worldCoords\":[[[53.111991,-27.725812],[53.164780,-27.725812],[53.164780,-27.772234],[53.111991,-27.772234]]]},\"boundingBox\":[[53.111991,-27.725812],[53.164780,-27.725812],[53.164780,-27.772234],[53.111991,-27.772234]],\"centralPos\":[53.138382,-27.749026]},\"temporalAxis\":{\"boundingBox\":[52220.243068,52263.181794],\"integratedCoverage\":0.208333,\"centralPos\":52241.712431,\"coverage\":[52220.243068,52263.181794]}},\"publisher\":\"ESO SAF\",\"collection\":\"168.A-0485(A\",\"targetSource\":{\"names\":[\"GOODS_09\"]},\"ESO\":{\"NGASFileId\":\"GOODS_ISAAC_09_H_V2.0\",\"metadataType\":\"DataProduct\",\"processingType\":\"HighlyProcessed\"},\"acquisitionSetup\":{\"filter\":\"H\",\"instrument\":\"ISAAC\",\"facility\":\"ESO-Paranal\",\"telescope\":\"ESO-VLT-U1\",\"mode\":\"Short Wavelength\"},\"title\":\"GOODS_ISAAC_09_H_v2.0\",\"id\":\"GOODS_ISAAC_09_H_V2.0\"},{\"project\":\"GOODS\",\"license\":\"ESO Data License : http://www.myLicenseToBeDefinedAtSomePoint.html\",\"copyright\":\"(c) GOODS Sep 10 2007 12:00AM\",\"creator\":\"C. Cesarsky\",\"dataType\":\"image\",\"characterization\":{\"spatialAxis\":{\"footprint\":{\"worldCoords\":[[[53.121222,-27.641601],[53.174252,-27.641601],[53.174252,-27.687943],[53.121222,-27.687943]]]},\"boundingBox\":[[53.121222,-27.641601],[53.174252,-27.641601],[53.174252,-27.687943],[53.121222,-27.687943]],\"centralPos\":[53.147732,-27.664775]},\"temporalAxis\":{\"boundingBox\":[53729.079417,53747.174968],\"integratedCoverage\":0.122222,\"centralPos\":53738.127193,\"coverage\":[53729.079417,53747.174968]}},\"publisher\":\"ESO SAF\",\"collection\":\"168.A-0485(G)\",\"targetSource\":{\"names\":[\"GOODS_01\"]},\"ESO\":{\"NGASFileId\":\"GOODS_ISAAC_01_J_V2.0\",\"metadataType\":\"DataProduct\",\"processingType\":\"HighlyProcessed\"},\"acquisitionSetup\":{\"filter\":\"J\",\"instrument\":\"ISAAC\",\"facility\":\"ESO-Paranal\",\"telescope\":\"ESO-VLT-U1\",\"mode\":\"Short Wavelength\"},\"title\":\"GOODS_ISAAC_01_J_v2.0\",\"id\":\"GOODS_ISAAC_01_J_V2.0\"},{\"project\":\"GOODS\",\"license\":\"ESO Data License : http://www.myLicenseToBeDefinedAtSomePoint.html\",\"copyright\":\"(c) GOODS Sep 10 2007 12:00AM\",\"creator\":\"C. Cesarsky\",\"dataType\":\"image\",\"characterization\":{\"spatialAxis\":{\"footprint\":{\"worldCoords\":[[[53.121081,-27.641392],[53.174488,-27.641392],[53.174488,-27.688027],[53.121081,-27.688027]]]},\"boundingBox\":[[53.121081,-27.641392],[53.174488,-27.641392],[53.174488,-27.688027],[53.121081,-27.688027]],\"centralPos\":[53.147779,-27.664712]},\"temporalAxis\":{\"boundingBox\":[53729.179656,53749.175133],\"integratedCoverage\":0.207292,\"centralPos\":53739.177395,\"coverage\":[53729.179656,53749.175133]}},\"publisher\":\"ESO SAF\",\"collection\":\"168.A-0485(G)\",\"targetSource\":{\"names\":[\"GOODS_01\"]},\"ESO\":{\"NGASFileId\":\"GOODS_ISAAC_01_KS_V2.0\",\"metadataType\":\"DataProduct\",\"processingType\":\"HighlyProcessed\"},\"acquisitionSetup\":{\"filter\":\"Ks\",\"instrument\":\"ISAAC\",\"facility\":\"ESO-Paranal\",\"telescope\":\"ESO-VLT-U1\",\"mode\":\"Short Wavelength\"},\"title\":\"GOODS_ISAAC_01_Ks_v2.0\",\"id\":\"GOODS_ISAAC_01_KS_V2.0\"}]"; -} - -void TestStelJsonParser::testBase() -{ - QVariant result = StelJsonParser::parse(largeJsonBuff); - QVERIFY(result.canConvert()); - QVERIFY(result.toMap().size()==12); - - result = StelJsonParser::parse(listJsonBuff); - QVERIFY(result.canConvert()); - QVERIFY(result.value().size()==3); - - result = StelJsonParser::parse("{\"val\": 0.000280}"); - bool ok; - QCOMPARE(result.toMap().value("val").toDouble(&ok), 0.000280); - QVERIFY(ok==true); - - result = StelJsonParser::parse("{\"valtrue\": true, \"valfalse\": false}"); - QVERIFY(result.toMap().value("valtrue").canConvert()); - QVERIFY(result.toMap().value("valtrue").toBool()==true); - QVERIFY(result.toMap().value("valfalse").canConvert()); - QVERIFY(result.toMap().value("valfalse").toBool()==false); - - result = StelJsonParser::parse("{\"val\": -12356}"); - QVERIFY(result.toMap().value("val").canConvert()); - QVERIFY(result.toMap().value("val").toInt(&ok)==-12356); - QVERIFY(ok==true); - - result = StelJsonParser::parse("{\"val\": -12356\n}"); - QVERIFY(result.toMap().value("val").canConvert()); - QVERIFY(result.toMap().value("val").toInt(&ok)==-12356); - QVERIFY(ok==true); - - // Test windows line ending - result = StelJsonParser::parse("{\"val\": -12356\r\n}"); - QVERIFY(result.toMap().value("val").canConvert()); - QVERIFY(result.toMap().value("val").toInt(&ok)==-12356); - QVERIFY(ok==true); -} - -void TestStelJsonParser::testIterator() -{ - QBuffer buf; - buf.setData(listJsonBuff); - buf.open(QIODevice::ReadOnly); - - try - { - int tot = 0; - JsonListIterator iter = StelJsonParser::initListIterator(&buf); - while (iter.hasNext()) - { - QVariant v = iter.next(); - QVERIFY(v.canConvert()); - ++tot; - } - QVERIFY(tot==3); - } - catch (std::runtime_error& e) - { - QString msg("Exception while loading JSON: "); - msg+=e.what(); - QFAIL(qPrintable(msg)); - } - buf.close(); -} - -void TestStelJsonParser::testErrors() -{ - bool wasCatched = false; - QVariant result; - QString erMsg; - try - { - result = StelJsonParser::parse("{val: -12356}"); - } - catch (std::runtime_error& e) - { - wasCatched = true; - erMsg=e.what(); - } - // qDebug() << erMsg; - QVERIFY(wasCatched); - QVERIFY(result.isNull()); -} - -void TestStelJsonParser::benchmarkParse() -{ - QBuffer buf; - buf.setData(largeJsonBuff); - buf.open(QIODevice::ReadOnly); - QVariant result; - QBENCHMARK { - result = StelJsonParser::parse(&buf); - } -} diff --git a/src/tests/testStelJsonParser.hpp b/src/tests/testStelJsonParser.hpp deleted file mode 100644 index 3b21c26..0000000 --- a/src/tests/testStelJsonParser.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTSTELJSONPARSER_HPP_ -#define _TESTSTELJSONPARSER_HPP_ - -#include -#include - -class TestStelJsonParser : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - void testBase(); - void testIterator(); - void benchmarkParse(); - void testErrors(); -private: - QByteArray largeJsonBuff; - QByteArray listJsonBuff; -}; - -#endif // _TESTSTELJSONPARSER_HPP_ diff --git a/src/tests/testStelSphereGeometry.cpp b/src/tests/testStelSphereGeometry.cpp deleted file mode 100644 index 842872a..0000000 --- a/src/tests/testStelSphereGeometry.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include -#include - -#include "StelJsonParser.hpp" -#include "StelSphereGeometry.hpp" -#include "StelUtils.hpp" - -#include "tests/testStelSphereGeometry.hpp" - -QTEST_MAIN(TestStelSphericalGeometry) - -void TestStelSphericalGeometry::initTestCase() -{ - // Testing code for new polygon code - QVector > contours; - QVector c1(4); - StelUtils::spheToRect(-0.5, -0.5, c1[3]); - StelUtils::spheToRect(0.5, -0.5, c1[2]); - StelUtils::spheToRect(0.5, 0.5, c1[1]); - StelUtils::spheToRect(-0.5, 0.5, c1[0]); - contours.append(c1); - QVector c2(4); - StelUtils::spheToRect(-0.2, 0.2, c2[3]); - StelUtils::spheToRect(0.2, 0.2, c2[2]); - StelUtils::spheToRect(0.2, -0.2, c2[1]); - StelUtils::spheToRect(-0.2, -0.2, c2[0]); - contours.append(c2); - - holySquare.setContours(contours); - bigSquare.setContour(c1); - bigSquareConvex.setContour(c1); - QVector c2inv(4); - c2inv[0]=c2[3]; c2inv[1]=c2[2]; c2inv[2]=c2[1]; c2inv[3]=c2[0]; - smallSquare.setContour(c2inv); - smallSquareConvex.setContour(c2inv); - - QVector triCont; - triCont << Vec3d(1,0,0) << Vec3d(0,0,1) << Vec3d(0,1,0); - triangle.setContour(triCont); - - - QVector c4(4); - StelUtils::spheToRect(M_PI-0.5, -0.5, c4[3]); - StelUtils::spheToRect(M_PI+0.5, -0.5, c4[2]); - StelUtils::spheToRect(M_PI+0.5, 0.5, c4[1]); - StelUtils::spheToRect(M_PI-0.5, 0.5, c4[0]); - opositeSquare.setContour(c4); - - QVector cpole(4); - StelUtils::spheToRect(0.1,M_PI/2.-0.1, cpole[3]); - StelUtils::spheToRect(0.1+M_PI/2., M_PI/2.-0.1, cpole[2]); - StelUtils::spheToRect(0.1+M_PI, M_PI/2.-0.1, cpole[1]); - StelUtils::spheToRect(0.1+M_PI+M_PI/2.,M_PI/2.-0.1, cpole[0]); - northPoleSquare.setContour(cpole); - - StelUtils::spheToRect(0.1,-M_PI/2.+0.1, cpole[0]); - StelUtils::spheToRect(0.1+M_PI/2., -M_PI/2.+0.1, cpole[1]); - StelUtils::spheToRect(0.1+M_PI, -M_PI/2.+0.1, cpole[2]); - StelUtils::spheToRect(0.1+M_PI+M_PI/2.,-M_PI/2.+0.1, cpole[3]); - southPoleSquare.setContour(cpole); -} - -void TestStelSphericalGeometry::testSphericalCap() -{ - Vec3d p0(1,0,0); - Vec3d p1(-1,0,0); - Vec3d p2(1,1,1); - p2.normalize(); - Vec3d p3(0,1,0); - - SphericalCap h0(p0, 0); - SphericalCap h1(p0, 0.8); - SphericalCap h2(p0, -0.5); - SphericalCap h3(p1, 0.5); - SphericalCap h4(p2, 0.8); - SphericalCap h5(p2, 1.); - SphericalCap h6(p1, 0); - - QVERIFY2(h0.contains(p0), "SphericalCap contains point failure"); - QVERIFY2(h1.contains(p0), "SphericalCap contains point failure"); - QVERIFY2(h0.contains(p3), "SphericalCap contains point on the edge failure"); - QVERIFY2(h6.contains(p3), "SphericalCap contains point on the edge failure"); - - QVERIFY(h0.intersects(h1)); - QVERIFY(h0.intersects(h2)); - QVERIFY(h1.intersects(h2)); - QVERIFY(h4.intersects(h1)); - QVERIFY(!h0.intersects(h3)); - QVERIFY(!h1.intersects(h3)); - QVERIFY(h2.intersects(h3)); - QVERIFY(h0.intersects(h5)); - - QVERIFY(h0.intersects(h0)); - QVERIFY(h1.intersects(h1)); - QVERIFY(h2.intersects(h2)); - QVERIFY(h3.intersects(h3)); - QVERIFY(h4.intersects(h4)); - QVERIFY(h5.intersects(h5)); - QVERIFY(h6.intersects(h0)); - QVERIFY(h0.intersects(h6)); - - QVERIFY(h0.contains(h1)); - QVERIFY(!h1.contains(h0)); - QVERIFY(h2.contains(h0)); - QVERIFY(!h0.contains(h2)); - QVERIFY(!h6.contains(h0)); - QVERIFY(!h0.contains(h6)); - QVERIFY(h2.contains(h1)); - QVERIFY(!h1.contains(h2)); - QVERIFY(!h0.contains(h3)); - QVERIFY(!h1.contains(h3)); - QVERIFY(h0.contains(h5)); - QVERIFY(h2.contains(h5)); - QVERIFY(!h5.contains(h0)); - QVERIFY(!h5.contains(h1)); - QVERIFY(!h5.contains(h2)); - QVERIFY(!h5.contains(h3)); - QVERIFY(!h5.contains(h4)); - QVERIFY(h0.contains(h0)); - QVERIFY(h1.contains(h1)); - QVERIFY(h2.contains(h2)); - QVERIFY(h3.contains(h3)); - QVERIFY(h4.contains(h4)); - QVERIFY(h5.contains(h5)); -} - -void TestStelSphericalGeometry::benchmarkSphericalCap() -{ - Vec3d p0(1,0,0); - Vec3d p2(1,1,1); - p2.normalize(); - SphericalCap h0(p0, 0); - SphericalCap h4(p2, 0.8); - QBENCHMARK { - h0.intersects(h4); - } -} - -void TestStelSphericalGeometry::testConsistency() -{ - QCOMPARE(bigSquare.getArea(), bigSquareConvex.getArea()); - QCOMPARE(smallSquare.getArea(), smallSquareConvex.getArea()); - QVERIFY(smallSquareConvex.checkValid()); - QVERIFY(bigSquareConvex.checkValid()); - QVERIFY(triangle.checkValid()); - QVERIFY(triangle.getConvexContour().size()==3); -} - -void TestStelSphericalGeometry::testContains() -{ - Vec3d p0(1,0,0); - Vec3d p1(1,1,1); - p1.normalize(); - - Vec3d v0; - Vec3d v1; - Vec3d v2; - Vec3d v3; - - // Triangle polygons - QVERIFY2(triangle.contains(p1), "Triangle contains point failure"); - Vec3d vt(-1, -1, -1); - vt.normalize(); - QVERIFY2(!triangle.contains(vt), "Triangle not contains point failure"); - - foreach(const SphericalCap& h, triangle.getBoundingSphericalCaps()) - { - QVERIFY(h.contains(p1)); - } - - // polygons-point intersect - double deg5 = 5.*M_PI/180.; - double deg2 = 2.*M_PI/180.; - StelUtils::spheToRect(-deg5, -deg5, v3); - StelUtils::spheToRect(+deg5, -deg5, v2); - StelUtils::spheToRect(+deg5, +deg5, v1); - StelUtils::spheToRect(-deg5, +deg5, v0); - //qDebug() << v0.toString() << v1.toString() << v2.toString() << v3.toString(); - SphericalConvexPolygon square1(v0, v1, v2, v3); - QVERIFY(square1.checkValid()); - QVERIFY2(square1.contains(p0), "Square contains point failure"); - QVERIFY2(!square1.contains(p1), "Square not contains point failure"); - - // polygons-polygons intersect - StelUtils::spheToRect(-deg2, -deg2, v3); - StelUtils::spheToRect(+deg2, -deg2, v2); - StelUtils::spheToRect(+deg2, +deg2, v1); - StelUtils::spheToRect(-deg2, +deg2, v0); - SphericalConvexPolygon square2(v0, v1, v2, v3); - QVERIFY(square2.checkValid()); - QVERIFY2(square1.contains(square2), "Square contains square failure"); - QVERIFY2(!square2.contains(square1), "Square not contains square failure"); - QVERIFY2(square1.intersects(square2), "Square intersect square failure"); - QVERIFY2(square2.intersects(square1), "Square intersect square failure"); - - // Check when the polygons are far appart - QVERIFY(!square1.intersects(opositeSquare)); - QVERIFY(!square2.intersects(opositeSquare)); - QVERIFY(!holySquare.intersects(opositeSquare)); - QVERIFY(!bigSquare.intersects(opositeSquare)); - QVERIFY(opositeSquare.intersects(opositeSquare)); - - // Test the tricky case where 2 polygons intersect without having point within each other - StelUtils::spheToRect(-deg5, -deg2, v3); - StelUtils::spheToRect(+deg5, -deg2, v2); - StelUtils::spheToRect(+deg5, +deg2, v1); - StelUtils::spheToRect(-deg5, +deg2, v0); - SphericalConvexPolygon squareHoriz(v0, v1, v2, v3); - QVERIFY(squareHoriz.checkValid()); - - StelUtils::spheToRect(-deg2, -deg5, v3); - StelUtils::spheToRect(+deg2, -deg5, v2); - StelUtils::spheToRect(+deg2, +deg5, v1); - StelUtils::spheToRect(-deg2, +deg5, v0); - SphericalConvexPolygon squareVerti(v0, v1, v2, v3); - QVERIFY(squareVerti.checkValid()); - QVERIFY2(!squareHoriz.contains(squareVerti), "Special intersect contains failure"); - QVERIFY2(!squareVerti.contains(squareHoriz), "Special intersect contains failure"); - QVERIFY2(squareHoriz.intersects(squareVerti), "Special intersect failure"); - QVERIFY2(squareVerti.intersects(squareHoriz), "Special intersect failure"); -} - -void TestStelSphericalGeometry::testPlaneIntersect2() -{ - Vec3d p1,p2; - Vec3d vx(1,0,0); - Vec3d vz(0,0,1); - SphericalCap hx(vx, 0); - SphericalCap hz(vz, 0); - QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane intersect failed"); - QVERIFY(p1==Vec3d(0,-1,0)); - QVERIFY(p2==Vec3d(0,1,0)); - QVERIFY2(SphericalCap::intersectionPoints(hx, hx, p1, p2)==false, "Plane non-intersecting failure"); - - hx.d = std::sqrt(2.)/2.; - QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane/convex intersect failed"); - Vec3d res(p1-Vec3d(hx.d,-hx.d,0)); - QVERIFY2(res.length()<0.0000001, QString("p1 wrong: %1").arg(p1.toString()).toUtf8()); - res = p2-Vec3d(hx.d,hx.d,0); - QVERIFY2(res.length()<0.0000001, QString("p2 wrong: %1").arg(p2.toString()).toUtf8()); -} - -void TestStelSphericalGeometry::testGreatCircleIntersection() -{ - Vec3d v0,v1,v2,v3; - double deg5 = 5.*M_PI/180.; - StelUtils::spheToRect(-deg5, -deg5, v3); - StelUtils::spheToRect(+deg5, -deg5, v2); - StelUtils::spheToRect(+deg5, +deg5, v1); - StelUtils::spheToRect(-deg5, +deg5, v0); - - bool ok; - Vec3d v(0); - QBENCHMARK { - v = greatCircleIntersection(v3, v1, v0, v2, ok); - } - QVERIFY(v.angle(Vec3d(1.,0.,0.))<0.00001); -} - - -void TestStelSphericalGeometry::benchmarkGetIntersection() -{ - SphericalRegionP bug1 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.023842, -49.177087], [122.167613, -49.177087], [122.167613, -48.631248], [123.023842, -48.631248]]]}"); - SphericalRegionP bug2 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.028902, -49.677124], [122.163995, -49.677124], [122.163995, -49.131382], [123.028902, -49.131382]]]}"); - QVERIFY(bug1->intersects(bug2)); - SphericalRegionP res; - QBENCHMARK { - res = bug1->getIntersection(bug2); - } -} - -void TestStelSphericalGeometry::testEnlarge() -{ - Vec3d vx(1,0,0); - SphericalRegionP reg(new SphericalCap(vx, 0.9)); - for (double margin=0.00000001;margin<15.;margin+=0.1) - { - QVERIFY(reg->getEnlarged(margin)->contains(reg)); - } -} - -void TestStelSphericalGeometry::testSphericalPolygon() -{ - SphericalRegionP holySquare2 = bigSquare.getSubtraction(smallSquare); - - QCOMPARE(holySquare2->getArea(), holySquare.getArea()); - - //Booleans methods - QCOMPARE(holySquare.getArea(), bigSquare.getArea()-smallSquare.getArea()); - QCOMPARE(bigSquare.getUnion(holySquare)->getArea(), bigSquare.getArea()); - QCOMPARE(bigSquare.getSubtraction(smallSquare)->getArea(), bigSquare.getArea()-smallSquare.getArea()); - QCOMPARE(bigSquare.getIntersection(smallSquare)->getArea(), smallSquare.getArea()); - - // Point contain methods - Vec3d v0, v1, v2; - StelUtils::spheToRect(0.00000, 0.00000, v0); - StelUtils::spheToRect(0.3, 0.3, v1); - QVERIFY(smallSquareConvex.contains(v0)); - QVERIFY(smallSquare.contains(v0)); - QVERIFY(bigSquareConvex.contains(v0)); - QVERIFY(bigSquare.contains(v0)); - // FIXME: '!holySquare.contains(v0)' returned FALSE. - //QVERIFY(!holySquare.contains(v0)); - - QVERIFY(!smallSquare.contains(v1)); - QVERIFY(bigSquare.contains(v1)); - QVERIFY(holySquare.contains(v1)); - - QVERIFY(holySquare.intersects(bigSquare)); - QVERIFY(bigSquare.intersects(smallSquare)); - QVERIFY(!holySquare.intersects(smallSquare)); - - SphericalCap cap(Vec3d(1,0,0), 0.99); - QVERIFY(bigSquareConvex.intersects(cap)); - - // A case which caused a problem - SphericalRegionP bug1 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.023842, -49.177087], [122.167613, -49.177087], [122.167613, -48.631248], [123.023842, -48.631248]]]}"); - SphericalRegionP bug2 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.028902, -49.677124], [122.163995, -49.677124], [122.163995, -49.131382], [123.028902, -49.131382]]]}"); - QVERIFY(bug1->intersects(bug2)); - - // Another one - bug1 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[52.99403, -27.683551], [53.047302, -27.683551], [53.047302, -27.729923], [52.99403, -27.729923]]]}"); - bug2 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[52.993701, -27.683092], [53.047302, -27.683092], [53.047302, -27.729839], [52.993701, -27.729839]]]}"); - SphericalRegionP bugIntersect = bug1->getIntersection(bug2); - -} - -void TestStelSphericalGeometry::testLoading() -{ - QByteArray ar = "{\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]], [[-0.2,-0.2],[0.2,-0.2],[0.2,0.2],[-0.2,0.2]]]}"; - //QByteArray arTex = "{\"worldCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]]], \"textureCoords\": [[[-0.5,0.5],[0.5,0.5],[0.5,-0.5],[-0.5,-0.5]]]}"; - SphericalRegionP reg; - //SphericalRegionP regTex; - try - { - reg = SphericalRegionP::loadFromJson(ar); -// regTex = SphericalRegionP::loadFromJson(arTex); - } - catch (std::runtime_error& e) - { - QString msg("Exception while loading: "); - msg+=e.what(); - QFAIL(qPrintable(msg)); - } - - QVERIFY(reg->getType()==SphericalRegion::Polygon); - qDebug() << reg->getArea()*180./M_PI*180/M_PI; - - //StelVertexArray vertexAr = reg->getOutlineVertexArray(); - //QVERIFY(vertexAr.primitiveType==StelVertexArray::Lines && vertexAr.vertex.size()%2==0); -} - -void TestStelSphericalGeometry::benchmarkContains() -{ - Vec3d v0, v1; - StelUtils::spheToRect(0., 0., v0); - StelUtils::spheToRect(0.3, 0.3, v1); - - QBENCHMARK { - holySquare.contains(v1); - holySquare.contains(v0); - } -} - -void TestStelSphericalGeometry::benchmarkCheckValid() -{ - Vec3d v0, v1, v2; - StelUtils::spheToRect(-0.5, -0.5, v0); - StelUtils::spheToRect(0.5, -0.5, v1); - StelUtils::spheToRect(0.5, 0.5, v2); - SphericalConvexPolygon cvx(v0, v1, v2); - QBENCHMARK { - cvx.checkValid(); - } -} - -void TestStelSphericalGeometry::testOctahedronPolygon() -{ - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(0.8,0.1,0))); - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(1,0.1,0))); - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(0.5,0.,0))); - - // Check points outside triangle - QVERIFY(!OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(0.,0.1,0))); - QVERIFY(!OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(-1.,-1.,0))); - - // Check that the corners are included into the triangle - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(0,0,0))); - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(1,0,0))); - QVERIFY(OctahedronPolygon::triangleContains2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0), Vec3d(1,1,0))); - - QVERIFY(OctahedronPolygon::isTriangleConvexPositive2D(Vec3d(0,0,0), Vec3d(1,0,0), Vec3d(1,1,0))); - - SubContour contour(smallSquareConvex.getConvexContour()); - OctahedronPolygon splittedSub(contour); - QCOMPARE(splittedSub.getArea(), smallSquareConvex.getArea()); - - //QVector va = northPoleSquare.getOutlineVertexArray().vertex; - //QCOMPARE(va.size(),16); - //va = southPoleSquare.getOutlineVertexArray().vertex; - //QCOMPARE(va.size(),16); - - // Copy - OctahedronPolygon splittedSubCopy; - splittedSubCopy = splittedSub; - - QCOMPARE(splittedSub.getArea(), splittedSubCopy.getArea()); - double oldArea = splittedSubCopy.getArea(); - splittedSub = OctahedronPolygon(); - QCOMPARE(splittedSub.getArea(), 0.); - QCOMPARE(splittedSubCopy.getArea(), oldArea); - splittedSubCopy.inPlaceIntersection(splittedSub); - QCOMPARE(splittedSubCopy.getArea(), 0.); - - QCOMPARE(southPoleSquare.getArea(), northPoleSquare.getArea()); - QCOMPARE(southPoleSquare.getIntersection(northPoleSquare)->getArea(), 0.); - QCOMPARE(southPoleSquare.getUnion(northPoleSquare)->getArea(), 2.*southPoleSquare.getArea()); - QCOMPARE(southPoleSquare.getSubtraction(northPoleSquare)->getArea(), southPoleSquare.getArea()); - - QCOMPARE(northPoleSquare.getIntersection(northPoleSquare)->getArea(), northPoleSquare.getArea()); - QCOMPARE(northPoleSquare.getUnion(northPoleSquare)->getArea(), northPoleSquare.getArea()); - QCOMPARE(northPoleSquare.getSubtraction(northPoleSquare)->getArea(), 0.); - - // Test binary IO - QByteArray ar; - QBuffer buf(&ar); - buf.open(QIODevice::WriteOnly); - QDataStream out(&buf); - out << northPoleSquare.getOctahedronPolygon(); - buf.close(); - QVERIFY(!ar.isEmpty()); - - // Re-read it - OctahedronPolygon northPoleSquareRead; - buf.open(QIODevice::ReadOnly); - QDataStream in(&buf); - in >> northPoleSquareRead; - buf.close(); - QVERIFY(!northPoleSquareRead.isEmpty()); - QCOMPARE(northPoleSquareRead.getArea(), northPoleSquare.getArea()); - QVERIFY(northPoleSquareRead.intersects(northPoleSquare.getOctahedronPolygon())); - - // Spherical cap with aperture > 90 deg - SphericalCap cap1(Vec3d(0,0,1), std::cos(95.*M_PI/180.)); - qDebug() << "---------------------"; - OctahedronPolygon northCapPoly = cap1.getOctahedronPolygon(); - qDebug() << "---------------------"; - qDebug() << northCapPoly.getArea() << OctahedronPolygon::getAllSkyOctahedronPolygon().getArea()/2; - QVERIFY(northCapPoly.getArea()>OctahedronPolygon::getAllSkyOctahedronPolygon().getArea()/2); -} - - -void TestStelSphericalGeometry::testSerialize() -{ - // Store a SphericalPolygon as QVariant - SphericalRegionP holyReg(new SphericalPolygon(holySquare)); - QVariant vHolyReg = QVariant::fromValue(holyReg); - QVERIFY(QString(vHolyReg.typeName())=="SphericalRegionP"); - QVERIFY(vHolyReg.canConvert()); - // and reconvert it - SphericalRegionP reg2 = vHolyReg.value(); - QCOMPARE(holyReg->getArea(), reg2->getArea()); - QVERIFY(holyReg->getType()==reg2->getType()); - - // Store a SphericalCap as QVariant - SphericalRegionP capReg(new SphericalCap(Vec3d(1,0,0), 0.12)); - QVariant vCapReg = QVariant::fromValue(capReg); - QVERIFY(QString(vCapReg.typeName())=="SphericalRegionP"); - QVERIFY(vCapReg.canConvert()); - // and reconvert it - reg2 = vCapReg.value(); - QCOMPARE(capReg->getArea(), reg2->getArea()); - QVERIFY(capReg->getType()==reg2->getType()); - - // Test serialize the QVariants as binary - QByteArray ar; - QBuffer buf(&ar); - buf.open(QIODevice::WriteOnly); - QDataStream out(&buf); - out << vHolyReg << vCapReg; - buf.close(); - QVERIFY(!ar.isEmpty()); - - // Re-read it - QVariant readVCapReg, readVHolyReg; - buf.open(QIODevice::ReadOnly); - QDataStream in(&buf); - in >> readVHolyReg >> readVCapReg; - buf.close(); - reg2 = readVHolyReg.value(); - QCOMPARE(holyReg->getArea(), reg2->getArea()); - QVERIFY(holyReg->getType()==reg2->getType()); - reg2 = readVCapReg.value(); - QCOMPARE(capReg->getArea(), reg2->getArea()); - QVERIFY(capReg->getType()==reg2->getType()); -} - -void TestStelSphericalGeometry::benchmarkCreatePolygon() -{ - QVector > contours; - QVector c1(4); - StelUtils::spheToRect(-0.5, -0.5, c1[3]); - StelUtils::spheToRect(0.5, -0.5, c1[2]); - StelUtils::spheToRect(0.5, 0.5, c1[1]); - StelUtils::spheToRect(-0.5, 0.5, c1[0]); - contours.append(c1); - QVector c2(4); - StelUtils::spheToRect(-0.2, 0.2, c2[3]); - StelUtils::spheToRect(0.2, 0.2, c2[2]); - StelUtils::spheToRect(0.2, -0.2, c2[1]); - StelUtils::spheToRect(-0.2, -0.2, c2[0]); - contours.append(c2); - QBENCHMARK - { - SphericalPolygon holySquare(contours); - } -} diff --git a/src/tests/testStelSphereGeometry.hpp b/src/tests/testStelSphereGeometry.hpp deleted file mode 100644 index 9d2ed5e..0000000 --- a/src/tests/testStelSphereGeometry.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTSTELSPHERICALGEOMETRY_HPP_ -#define _TESTSTELSPHERICALGEOMETRY_HPP_ - -#include -#include -#include "StelSphereGeometry.hpp" - -class TestStelSphericalGeometry : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - void testOctahedronPolygon(); - void testSphericalCap(); - void testContains(); - void testPlaneIntersect2(); - void testGreatCircleIntersection(); - void testSphericalPolygon(); - void testConsistency(); - void testLoading(); - void testEnlarge(); - void benchmarkContains(); - void benchmarkCheckValid(); - void benchmarkSphericalCap(); - void benchmarkGetIntersection(); - void testSerialize(); - void benchmarkCreatePolygon(); -private: - SphericalPolygon holySquare; - SphericalPolygon bigSquare; - SphericalPolygon smallSquare; - SphericalPolygon opositeSquare; - SphericalConvexPolygon bigSquareConvex; - SphericalConvexPolygon smallSquareConvex; - SphericalConvexPolygon triangle; - SphericalPolygon northPoleSquare; - SphericalPolygon southPoleSquare; -}; - -#endif // _TESTSTELSPHERICALGEOMETRY_HPP_ diff --git a/src/tests/testStelSphericalIndex.cpp b/src/tests/testStelSphericalIndex.cpp deleted file mode 100644 index 3687b70..0000000 --- a/src/tests/testStelSphericalIndex.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include -#include -#include -#include - -#include "StelSphereGeometry.hpp" -#include "StelUtils.hpp" -#include "tests/testStelSphericalIndex.hpp" - -QTEST_MAIN(TestStelSphericalIndex) - -class TestRegionObject : public StelRegionObject -{ - public: - TestRegionObject(SphericalRegionP reg) : region(reg) {;} - virtual SphericalRegionP getRegion() const {return region;} - SphericalRegionP region; -}; - -void TestStelSphericalIndex::initTestCase() -{ -} - -struct CountFuncObject -{ - CountFuncObject() : count(0) {;} - void operator()(const StelRegionObject* /* obj */) - { - count++; - } - int count; -}; - -void TestStelSphericalIndex::testBase() -{ - StelSphericalIndex grid(10); - grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP(new SphericalCap(Vec3d(1,0,0), 0.9))))); - grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP(new SphericalCap(Vec3d(-1,0,0), 0.99))))); - CountFuncObject countFunc; - grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Vec3d(1,0,0), 0.5)), countFunc); - grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Vec3d(1,0,0), 0.95)), countFunc); - QVERIFY(countFunc.count==2); - countFunc.count=0; - grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Vec3d(0,1,0), 0.99)), countFunc); - QVERIFY(countFunc.count==0); - - // Process all - countFunc.count=0; - grid.processAll(countFunc); - QVERIFY(countFunc.count==2); - - // Clear - grid.clear(); - countFunc.count=0; - grid.processAll(countFunc); - QVERIFY(countFunc.count==0); - - QVector c1(4); - StelUtils::spheToRect(-0.5, -0.5, c1[3]); - StelUtils::spheToRect(0.5, -0.5, c1[2]); - StelUtils::spheToRect(0.5, 0.5, c1[1]); - StelUtils::spheToRect(-0.5, 0.5, c1[0]); - SphericalConvexPolygon bigSquareConvex; - bigSquareConvex.setContour(c1); - - // try with many elements - for (int i=0;i<10000;++i) - { - grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP(new SphericalCap(Vec3d(1,0,0), 0.99))))); - grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP(new SphericalPoint(Vec3d(1,0,0)))))); - grid.insert(StelRegionObjectP(new TestRegionObject(SphericalRegionP(new SphericalConvexPolygon(c1))))); - } - countFunc.count=0; - grid.processIntersectingRegions(SphericalRegionP(new SphericalCap(Vec3d(1,0,0), 0.5)), countFunc); - QVERIFY(countFunc.count==30000); - countFunc.count=0; - grid.processIntersectingRegions(SphericalRegionP(new SphericalConvexPolygon(c1)), countFunc); - qDebug() << countFunc.count; - QVERIFY(countFunc.count==30000); -} - diff --git a/src/tests/testStelSphericalIndex.hpp b/src/tests/testStelSphericalIndex.hpp deleted file mode 100644 index e4ba897..0000000 --- a/src/tests/testStelSphericalIndex.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTSTELSPHERICALINDEX_HPP_ -#define _TESTSTELSPHERICALINDEX_HPP_ - -#include -#include -#include "StelSphereGeometry.hpp" -#include "StelSphericalIndex.hpp" - -class TestStelSphericalIndex : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - void testBase(); -private: -}; - -#endif // _TESTSTELSPHERICALINDEX_HPP_ diff --git a/src/tests/testStelVertexArray.cpp b/src/tests/testStelVertexArray.cpp deleted file mode 100644 index 5845a20..0000000 --- a/src/tests/testStelVertexArray.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#include "tests/testStelVertexArray.hpp" - - -QTEST_MAIN(TestStelVertexArray) - - -void TestStelVertexArray::initTestCase() -{ - QVector vertices; - QVector textureCoords; - - for (int i = 0; i < 1000; ++i) - { - Vec3d v(i+1, i+1, i+1); - v.normalize(); - vertices.append(v); - - Vec2f t(i, i); - textureCoords.append(t); - } - - array = StelVertexArray(vertices, StelVertexArray::TriangleStrip, textureCoords); -} - -struct EmptyVisitor -{ - inline void operator()(const Vec3d* , const Vec3d* , const Vec3d* , - const Vec2f* , const Vec2f* , const Vec2f* , - unsigned int , unsigned int , unsigned int ) - { - - } -}; - -void TestStelVertexArray::benchmarkForeachTriangleNoOp() -{ - QBENCHMARK { - array.foreachTriangle(EmptyVisitor()); - } -} - -struct VerticesVisitor -{ - VerticesVisitor(const VerticesVisitor& rst) : sum(rst.sum) {} - - VerticesVisitor() : sum(0, 0, 0) {} - inline void operator()(const Vec3d* , const Vec3d* v1, const Vec3d* v2, - const Vec2f* , const Vec2f* , const Vec2f* , - unsigned int , unsigned int , unsigned int ) - { - sum += *v1 + *v2; - } - - Vec3d sum; -}; - -void TestStelVertexArray::benchmarkForeachTriangle() -{ - Vec3d sum(0, 0, 0); - QBENCHMARK { - VerticesVisitor result = array.foreachTriangle(VerticesVisitor()); - sum = result.sum; - } - qDebug() << sum.toString(); -} - -void TestStelVertexArray::benchmarkForeachTriangleDirect() -{ - // Now we do the same thing "manually" - Vec3d sum(0, 0, 0); - QBENCHMARK { - sum = Vec3d(0, 0, 0); - for (int i = 2; i < array.vertex.size(); ++i) - { - if ((i % 2) == 0) - { - sum += array.vertex.at(i-1) + array.vertex.at(i); - } - else - { - sum += array.vertex.at(i-2) + array.vertex.at(i); - } - } - } - qDebug() << sum.toString(); -} - - diff --git a/src/tests/testStelVertexArray.hpp b/src/tests/testStelVertexArray.hpp deleted file mode 100644 index 81d8fa5..0000000 --- a/src/tests/testStelVertexArray.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Stellarium - * Copyright (C) 2009 Fabien Chereau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. - */ - -#ifndef _TESTSTELVERTEXARRAY_HPP_ -#define _TESTSTELVERTEXARRAY_HPP_ - -#include -#include - -#include "StelVertexArray.hpp" - -class TestStelVertexArray : public QObject -{ -Q_OBJECT -private slots: - void initTestCase(); - void benchmarkForeachTriangleNoOp(); - void benchmarkForeachTriangle(); - void benchmarkForeachTriangleDirect(); -private: - StelVertexArray array; -}; - -#endif // _TESTSTELVERTEXARRAY_HPP_ diff --git a/stellarium.pro b/stellarium.pro index c75a6b3..ff89107 100644 --- a/stellarium.pro +++ b/stellarium.pro @@ -84,101 +84,14 @@ HEADERS += \ src/StelAndroid.hpp \ src/StelLogger.hpp \ src/StelMainView.hpp \ - src/core/external/gsatellite/gException.hpp \ - src/core/external/gsatellite/gSatTEME.hpp \ - src/core/external/gsatellite/gTime.hpp \ - src/core/external/gsatellite/gVector.hpp \ - src/core/external/gsatellite/gVectorTempl.hpp \ - src/core/external/gsatellite/sgp4ext.h \ - src/core/external/gsatellite/sgp4io.h \ - src/core/external/gsatellite/sgp4unit.h \ - src/core/external/gsatellite/stdsat.h \ - src/core/external/GeographicLib/include/GeographicLib/Accumulator.hpp \ - src/core/external/GeographicLib/include/GeographicLib/AlbersEqualArea.hpp \ - src/core/external/GeographicLib/include/GeographicLib/AzimuthalEquidistant.hpp \ - src/core/external/GeographicLib/include/GeographicLib/CassiniSoldner.hpp \ - src/core/external/GeographicLib/include/GeographicLib/CircularEngine.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Constants.hpp \ - src/core/external/GeographicLib/include/GeographicLib/DMS.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Ellipsoid.hpp \ - src/core/external/GeographicLib/include/GeographicLib/EllipticFunction.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GARS.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Geocentric.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GeoCoords.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Geodesic.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GeodesicExact.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GeodesicLine.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GeodesicLineExact.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Geohash.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Geoid.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Georef.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Gnomonic.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GravityCircle.hpp \ - src/core/external/GeographicLib/include/GeographicLib/GravityModel.hpp \ - src/core/external/GeographicLib/include/GeographicLib/LambertConformalConic.hpp \ - src/core/external/GeographicLib/include/GeographicLib/LocalCartesian.hpp \ - src/core/external/GeographicLib/include/GeographicLib/MagneticCircle.hpp \ - src/core/external/GeographicLib/include/GeographicLib/MagneticModel.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Math.hpp \ - src/core/external/GeographicLib/include/GeographicLib/MGRS.hpp \ - src/core/external/GeographicLib/include/GeographicLib/NearestNeighbor.hpp \ - src/core/external/GeographicLib/include/GeographicLib/NormalGravity.hpp \ - src/core/external/GeographicLib/include/GeographicLib/OSGB.hpp \ - src/core/external/GeographicLib/include/GeographicLib/PolarStereographic.hpp \ - src/core/external/GeographicLib/include/GeographicLib/PolygonArea.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Rhumb.hpp \ - src/core/external/GeographicLib/include/GeographicLib/SphericalEngine.hpp \ - src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic.hpp \ - src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic1.hpp \ - src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic2.hpp \ - src/core/external/GeographicLib/include/GeographicLib/TransverseMercator.hpp \ - src/core/external/GeographicLib/include/GeographicLib/TransverseMercatorExact.hpp \ - src/core/external/GeographicLib/include/GeographicLib/Utility.hpp \ - src/core/external/GeographicLib/include/GeographicLib/UTMUPS.hpp + SOURCES += \ src/CLIProcessor.cpp \ src/main.cpp \ src/StelLogger.cpp \ src/StelMainView.cpp \ - src/core/external/GeographicLib/src/Accumulator.cpp \ - src/core/external/GeographicLib/src/AlbersEqualArea.cpp \ - src/core/external/GeographicLib/src/AzimuthalEquidistant.cpp \ - src/core/external/GeographicLib/src/CassiniSoldner.cpp \ - src/core/external/GeographicLib/src/CircularEngine.cpp \ - src/core/external/GeographicLib/src/DMS.cpp \ - src/core/external/GeographicLib/src/Ellipsoid.cpp \ - src/core/external/GeographicLib/src/EllipticFunction.cpp \ - src/core/external/GeographicLib/src/GARS.cpp \ - src/core/external/GeographicLib/src/Geocentric.cpp \ - src/core/external/GeographicLib/src/GeoCoords.cpp \ - src/core/external/GeographicLib/src/Geodesic.cpp \ - src/core/external/GeographicLib/src/GeodesicExact.cpp \ - src/core/external/GeographicLib/src/GeodesicExactC4.cpp \ - src/core/external/GeographicLib/src/GeodesicLine.cpp \ - src/core/external/GeographicLib/src/GeodesicLineExact.cpp \ - src/core/external/GeographicLib/src/Geohash.cpp \ - src/core/external/GeographicLib/src/Geoid.cpp \ - src/core/external/GeographicLib/src/Georef.cpp \ - src/core/external/GeographicLib/src/Gnomonic.cpp \ - src/core/external/GeographicLib/src/GravityCircle.cpp \ - src/core/external/GeographicLib/src/GravityModel.cpp \ - src/core/external/GeographicLib/src/LambertConformalConic.cpp \ - src/core/external/GeographicLib/src/LocalCartesian.cpp \ - src/core/external/GeographicLib/src/MagneticCircle.cpp \ - src/core/external/GeographicLib/src/MagneticModel.cpp \ - src/core/external/GeographicLib/src/Math.cpp \ - src/core/external/GeographicLib/src/MGRS.cpp \ - src/core/external/GeographicLib/src/NormalGravity.cpp \ - src/core/external/GeographicLib/src/OSGB.cpp \ - src/core/external/GeographicLib/src/PolarStereographic.cpp \ - src/core/external/GeographicLib/src/PolygonArea.cpp \ - src/core/external/GeographicLib/src/Rhumb.cpp \ - src/core/external/GeographicLib/src/SphericalEngine.cpp \ - src/core/external/GeographicLib/src/TransverseMercator.cpp \ - src/core/external/GeographicLib/src/TransverseMercatorExact.cpp \ - src/core/external/GeographicLib/src/Utility.cpp \ - src/core/external/GeographicLib/src/UTMUPS.cpp + android { HEADERS += \ @@ -314,7 +227,58 @@ HEADERS += \ src/core/planetsephems/sideral_time.h \ src/core/planetsephems/stellplanet.h \ src/core/planetsephems/tass17.h \ - src/core/planetsephems/vsop87.h + src/core/planetsephems/vsop87.h \ + src/core/external/gsatellite/gException.hpp \ + src/core/external/gsatellite/gSatTEME.hpp \ + src/core/external/gsatellite/gTime.hpp \ + src/core/external/gsatellite/gVector.hpp \ + src/core/external/gsatellite/gVectorTempl.hpp \ + src/core/external/gsatellite/sgp4ext.h \ + src/core/external/gsatellite/sgp4io.h \ + src/core/external/gsatellite/sgp4unit.h \ + src/core/external/gsatellite/stdsat.h \ + src/core/external/GeographicLib/include/GeographicLib/Accumulator.hpp \ + src/core/external/GeographicLib/include/GeographicLib/AlbersEqualArea.hpp \ + src/core/external/GeographicLib/include/GeographicLib/AzimuthalEquidistant.hpp \ + src/core/external/GeographicLib/include/GeographicLib/CassiniSoldner.hpp \ + src/core/external/GeographicLib/include/GeographicLib/CircularEngine.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Constants.hpp \ + src/core/external/GeographicLib/include/GeographicLib/DMS.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Ellipsoid.hpp \ + src/core/external/GeographicLib/include/GeographicLib/EllipticFunction.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GARS.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Geocentric.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GeoCoords.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Geodesic.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GeodesicExact.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GeodesicLine.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GeodesicLineExact.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Geohash.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Geoid.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Georef.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Gnomonic.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GravityCircle.hpp \ + src/core/external/GeographicLib/include/GeographicLib/GravityModel.hpp \ + src/core/external/GeographicLib/include/GeographicLib/LambertConformalConic.hpp \ + src/core/external/GeographicLib/include/GeographicLib/LocalCartesian.hpp \ + src/core/external/GeographicLib/include/GeographicLib/MagneticCircle.hpp \ + src/core/external/GeographicLib/include/GeographicLib/MagneticModel.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Math.hpp \ + src/core/external/GeographicLib/include/GeographicLib/MGRS.hpp \ + src/core/external/GeographicLib/include/GeographicLib/NearestNeighbor.hpp \ + src/core/external/GeographicLib/include/GeographicLib/NormalGravity.hpp \ + src/core/external/GeographicLib/include/GeographicLib/OSGB.hpp \ + src/core/external/GeographicLib/include/GeographicLib/PolarStereographic.hpp \ + src/core/external/GeographicLib/include/GeographicLib/PolygonArea.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Rhumb.hpp \ + src/core/external/GeographicLib/include/GeographicLib/SphericalEngine.hpp \ + src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic.hpp \ + src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic1.hpp \ + src/core/external/GeographicLib/include/GeographicLib/SphericalHarmonic2.hpp \ + src/core/external/GeographicLib/include/GeographicLib/TransverseMercator.hpp \ + src/core/external/GeographicLib/include/GeographicLib/TransverseMercatorExact.hpp \ + src/core/external/GeographicLib/include/GeographicLib/Utility.hpp \ + src/core/external/GeographicLib/include/GeographicLib/UTMUPS.hpp SOURCES += \ src/core/MultiLevelJsonBase.cpp \ @@ -361,7 +325,7 @@ SOURCES += \ src/core/StelVideoMgr.cpp \ src/core/StelViewportEffect.cpp \ src/core/TrailGroup.cpp \ - src/core/modules/gSatWrapper.cpp \ + src/core/modules/gSatWrapper.cpp \ src/core/modules/Atmosphere.cpp \ src/core/modules/Comet.cpp \ src/core/modules/Constellation.cpp \ @@ -418,7 +382,45 @@ SOURCES += \ src/core/planetsephems/sideral_time.c \ src/core/planetsephems/stellplanet.c \ src/core/planetsephems/tass17.c \ - src/core/planetsephems/vsop87.c + src/core/planetsephems/vsop87.c \ + src/core/external/GeographicLib/src/Accumulator.cpp \ + src/core/external/GeographicLib/src/AlbersEqualArea.cpp \ + src/core/external/GeographicLib/src/AzimuthalEquidistant.cpp \ + src/core/external/GeographicLib/src/CassiniSoldner.cpp \ + src/core/external/GeographicLib/src/CircularEngine.cpp \ + src/core/external/GeographicLib/src/DMS.cpp \ + src/core/external/GeographicLib/src/Ellipsoid.cpp \ + src/core/external/GeographicLib/src/EllipticFunction.cpp \ + src/core/external/GeographicLib/src/GARS.cpp \ + src/core/external/GeographicLib/src/Geocentric.cpp \ + src/core/external/GeographicLib/src/GeoCoords.cpp \ + src/core/external/GeographicLib/src/Geodesic.cpp \ + src/core/external/GeographicLib/src/GeodesicExact.cpp \ + src/core/external/GeographicLib/src/GeodesicExactC4.cpp \ + src/core/external/GeographicLib/src/GeodesicLine.cpp \ + src/core/external/GeographicLib/src/GeodesicLineExact.cpp \ + src/core/external/GeographicLib/src/Geohash.cpp \ + src/core/external/GeographicLib/src/Geoid.cpp \ + src/core/external/GeographicLib/src/Georef.cpp \ + src/core/external/GeographicLib/src/Gnomonic.cpp \ + src/core/external/GeographicLib/src/GravityCircle.cpp \ + src/core/external/GeographicLib/src/GravityModel.cpp \ + src/core/external/GeographicLib/src/LambertConformalConic.cpp \ + src/core/external/GeographicLib/src/LocalCartesian.cpp \ + src/core/external/GeographicLib/src/MagneticCircle.cpp \ + src/core/external/GeographicLib/src/MagneticModel.cpp \ + src/core/external/GeographicLib/src/Math.cpp \ + src/core/external/GeographicLib/src/MGRS.cpp \ + src/core/external/GeographicLib/src/NormalGravity.cpp \ + src/core/external/GeographicLib/src/OSGB.cpp \ + src/core/external/GeographicLib/src/PolarStereographic.cpp \ + src/core/external/GeographicLib/src/PolygonArea.cpp \ + src/core/external/GeographicLib/src/Rhumb.cpp \ + src/core/external/GeographicLib/src/SphericalEngine.cpp \ + src/core/external/GeographicLib/src/TransverseMercator.cpp \ + src/core/external/GeographicLib/src/TransverseMercatorExact.cpp \ + src/core/external/GeographicLib/src/Utility.cpp \ + src/core/external/GeographicLib/src/UTMUPS.cpp OTHER_FILES += \ data/qml/AboutDialog.qml \