Exoplanets.cpp   Exoplanets.cpp 
skipping to change at line 20 skipping to change at line 20
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelTextureMgr.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "Exoplanets.hpp" #include "Exoplanets.hpp"
#include "Exoplanet.hpp" #include "Exoplanet.hpp"
#include "ExoplanetsDialog.hpp" #include "ExoplanetsDialog.hpp"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
#include <QAction> #include <QAction>
#include <QProgressBar> #include <QProgressBar>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
#include <QSettings>
#include <QSharedPointer> #include <QSharedPointer>
#include <QStringList> #include <QStringList>
#include <QPixmap> #include <QPixmap>
#define CATALOG_FORMAT_VERSION 1 /* Version of format of catalog */ #define CATALOG_FORMAT_VERSION 1 /* Version of format of catalog */
/* /*
This method is the one called automatically by the StelModuleMgr just This method is the one called automatically by the StelModuleMgr just
after loading the dynamic library after loading the dynamic library
*/ */
skipping to change at line 84 skipping to change at line 85
info.description = N_("This plugin plots the position of stars with exoplanets. Exoplanets data is derived from the 'Extrasolar Planets Encyclo paedia' at exoplanet.eu"); info.description = N_("This plugin plots the position of stars with exoplanets. Exoplanets data is derived from the 'Extrasolar Planets Encyclo paedia' at exoplanet.eu");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Exoplanets, ExoplanetsStelPluginInterface) Q_EXPORT_PLUGIN2(Exoplanets, ExoplanetsStelPluginInterface)
/* /*
Constructor Constructor
*/ */
Exoplanets::Exoplanets() Exoplanets::Exoplanets()
: flagShowExoplanets(false), OnIcon(NULL), OffIcon(NULL), GlowIcon(N : texPointer(NULL)
ULL), toolbarButton(NULL), progressBar(NULL) , markerTexture(NULL)
, flagShowExoplanets(false)
, OnIcon(NULL)
, OffIcon(NULL)
, GlowIcon(NULL)
, toolbarButton(NULL)
, progressBar(NULL)
{ {
setObjectName("Exoplanets"); setObjectName("Exoplanets");
exoplanetsConfigDialog = new ExoplanetsDialog(); exoplanetsConfigDialog = new ExoplanetsDialog();
conf = StelApp::getInstance().getSettings(); conf = StelApp::getInstance().getSettings();
font.setPixelSize(conf->value("gui/base_font_size", 13).toInt()); font.setPixelSize(conf->value("gui/base_font_size", 13).toInt());
} }
/* /*
Destructor Destructor
*/ */
skipping to change at line 110 skipping to change at line 118
delete GlowIcon; delete GlowIcon;
if (OnIcon) if (OnIcon)
delete OnIcon; delete OnIcon;
if (OffIcon) if (OffIcon)
delete OffIcon; delete OffIcon;
} }
void Exoplanets::deinit() void Exoplanets::deinit()
{ {
ep.clear(); ep.clear();
Exoplanet::markerTexture.clear(); if(NULL != texPointer) {delete texPointer;}
texPointer.clear(); if(NULL != markerTexture) {delete markerTexture;}
texPointer = markerTexture = NULL;
} }
void Exoplanets::update(double) //deltaTime void Exoplanets::update(double) //deltaTime
{ {
// //
} }
/* /*
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*/ */
skipping to change at line 150 skipping to change at line 159
{ {
qDebug() << "Exoplanets::init no Exoplanets section exists in main config file - creating with defaults"; qDebug() << "Exoplanets::init no Exoplanets section exists in main config file - creating with defaults";
restoreDefaultConfigIni(); restoreDefaultConfigIni();
} }
// populate settings from main config file. // populate settings from main config file.
readSettingsFromConfig(); readSettingsFromConfig();
jsonCatalogPath = StelFileMgr::findFile("modules/Exoplanets" , (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/e xoplanets.json"; jsonCatalogPath = StelFileMgr::findFile("modules/Exoplanets" , (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/e xoplanets.json";
texPointer = StelApp::getInstance().getTextureManager().crea
teTexture("textures/pointeur2.png");
Exoplanet::markerTexture = StelApp::getInstance().getTexture
Manager().createTexture(":/Exoplanets/exoplanet.png");
// key bindings and other actions // key bindings and other actions
// TRANSLATORS: Title of a group of key bindings in the Help
window
QString groupName = N_("Plugin Key Bindings");
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
GlowIcon = new QPixmap(":/graphicsGui/glow32x32.png"); GlowIcon = new QPixmap(":/graphicsGui/glow32x32.png");
OnIcon = new QPixmap(":/Exoplanets/btExoplanets-on.png"); OnIcon = new QPixmap(":/Exoplanets/btExoplanets-on.png");
OffIcon = new QPixmap(":/Exoplanets/btExoplanets-off.png"); OffIcon = new QPixmap(":/Exoplanets/btExoplanets-off.png");
gui->addGuiActions("actionShow_Exoplanets_ConfigDialog", N_( gui->getGuiAction("actionShow_Exoplanets")->setChecked(flagS
"Exoplanets configuration window"), "", groupName, true, false); howExoplanets);
gui->addGuiActions("actionShow_Exoplanets", N_("Show exoplan toolbarButton = new StelButton(NULL, *OnIcon, *OffIcon, *Glo
ets"), "Ctrl+Alt+E", groupName, true, false); wIcon, gui->getGuiAction("actionShow_Exoplanets"));
gui->getGuiActions("actionShow_Exoplanets")->setChecked(flag
ShowExoplanets);
toolbarButton = new StelButton(NULL, *OnIcon, *OffIcon, *Glo
wIcon, gui->getGuiActions("actionShow_Exoplanets"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
connect(gui->getGuiActions("actionShow_Exoplanets_ConfigDial connect(gui->getGuiAction("actionShow_Exoplanets_ConfigDialo
og"), SIGNAL(toggled(bool)), exoplanetsConfigDialog, SLOT(setVisible(bool)) g"), SIGNAL(toggled(bool)), exoplanetsConfigDialog, SLOT(setVisible(bool)))
); ;
connect(exoplanetsConfigDialog, SIGNAL(visibleChanged(bool)) connect(exoplanetsConfigDialog, SIGNAL(visibleChanged(bool))
, gui->getGuiActions("actionShow_Exoplanets_ConfigDialog"), SLOT(setChecked , gui->getGuiAction("actionShow_Exoplanets_ConfigDialog"), SLOT(setChecked(
(bool))); bool)));
connect(gui->getGuiActions("actionShow_Exoplanets"), SIGNAL( connect(gui->getGuiAction("actionShow_Exoplanets"), SIGNAL(t
toggled(bool)), this, SLOT(setFlagShowExoplanets(bool))); oggled(bool)), this, SLOT(setFlagShowExoplanets(bool)));
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Exoplanets::init error: " << e.what(); qWarning() << "Exoplanets::init error: " << e.what();
return; return;
} }
// A timer for hiding alert messages // A timer for hiding alert messages
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
messageTimer->setSingleShot(true); // recurring check for update messageTimer->setSingleShot(true); // recurring check for update
skipping to change at line 219 skipping to change at line 221
updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update
connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate()) ); connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate()) );
updateTimer->start(); updateTimer->start();
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
} }
/* /*
Draw our module. This should print name of first PSR in the main window Draw our module. This should print name of first PSR in the main window
*/ */
void Exoplanets::draw(StelCore* core) void Exoplanets::draw(StelCore* core, StelRenderer* renderer)
{ {
if (!flagShowExoplanets) if (!flagShowExoplanets)
return; return;
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
StelPainter painter(prj); renderer->setFont(font);
painter.setFont(font);
if(NULL == texPointer)
{
Q_ASSERT_X(NULL == markerTexture, Q_FUNC_INFO, "Textures nee
d to be created simultaneously");
texPointer = renderer->createTexture("textures/pointeur2.
png");
markerTexture = renderer->createTexture(":/Exoplanets/exopla
net.png");
}
foreach (const ExoplanetP& eps, ep) foreach (const ExoplanetP& eps, ep)
{ {
if (eps && eps->initialized) if (eps && eps->initialized)
eps->draw(core, painter); eps->draw(core, renderer, prj, markerTexture);
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, painter); drawPointer(core, renderer, prj);
} }
void Exoplanets::drawPointer(StelCore* core, StelPainter& painter) void Exoplanets::drawPointer(StelCore* core, StelRenderer* renderer, StelPr ojectorP projector)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Exoplanet"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Exoplanet");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos; Vec3d screenpos;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!painter.getProjector()->project(pos, screenpos)) if (!projector->project(pos, screenpos))
return; return;
const Vec3f& c(obj->getInfoColor()); const Vec3f& c(obj->getInfoColor());
painter.setColor(c[0],c[1],c[2]); renderer->setGlobalColor(c[0],c[1],c[2]);
texPointer->bind(); texPointer->bind();
painter.enableTexture2d(true); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND); renderer->drawTexturedRect(screenpos[0] - 13.0f, screenpos[1
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal ] - 13.0f, 26.0f,
transparency mode 26.0f, StelApp::getInstance().get
painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, S TotalRunTime() * 40.0f);
telApp::getInstance().getTotalRunTime()*40.);
} }
} }
QList<StelObjectP> Exoplanets::searchAround(const Vec3d& av, double limitFo v, const StelCore*) const QList<StelObjectP> Exoplanets::searchAround(const Vec3d& av, double limitFo v, const StelCore*) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!flagShowExoplanets) if (!flagShowExoplanets)
return result; return result;
skipping to change at line 341 skipping to change at line 346
{ {
if (eps->getNameI18n().toUpper().left(objw.length()) == objw ) if (eps->getNameI18n().toUpper().left(objw.length()) == objw )
{ {
result << eps->getNameI18n().toUpper(); result << eps->getNameI18n().toUpper();
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result;
}
QStringList Exoplanets::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
foreach (const ExoplanetP& planet, ep)
{
result << planet->getEnglishName();
}
}
else
{
foreach (const ExoplanetP& planet, ep)
{
result << planet->getNameI18n();
}
}
return result; return result;
} }
/* /*
Replace the JSON file with the default from the compiled-in resource Replace the JSON file with the default from the compiled-in resource
*/ */
void Exoplanets::restoreDefaultJsonFile(void) void Exoplanets::restoreDefaultJsonFile(void)
{ {
if (QFileInfo(jsonCatalogPath).exists()) if (QFileInfo(jsonCatalogPath).exists())
backupJsonFile(true); backupJsonFile(true);
skipping to change at line 492 skipping to change at line 517
return eps; return eps;
} }
return ExoplanetP(); return ExoplanetP();
} }
bool Exoplanets::configureGui(bool show) bool Exoplanets::configureGui(bool show)
{ {
if (show) if (show)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
gui->getGuiActions("actionShow_Exoplanets_ConfigDialog")->se tChecked(true); gui->getGuiAction("actionShow_Exoplanets_ConfigDialog")->set Checked(true);
} }
return true; return true;
} }
void Exoplanets::restoreDefaults(void) void Exoplanets::restoreDefaults(void)
{ {
restoreDefaultConfigIni(); restoreDefaultConfigIni();
restoreDefaultJsonFile(); restoreDefaultJsonFile();
readJsonFile(); readJsonFile();
readSettingsFromConfig(); readSettingsFromConfig();
} }
void Exoplanets::restoreDefaultConfigIni(void) void Exoplanets::restoreDefaultConfigIni(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
// delete all existing Exoplanets settings... // delete all existing Exoplanets settings...
conf->remove(""); conf->remove("");
conf->setValue("distribution_enabled", false);
conf->setValue("timeline_enabled", false);
conf->setValue("updates_enabled", true); conf->setValue("updates_enabled", true);
conf->setValue("flag_show_exoplanets", false); conf->setValue("flag_show_exoplanets", false);
conf->setValue("url", "http://stellarium.org/json/exoplanets.json"); conf->setValue("url", "http://stellarium.org/json/exoplanets.json");
conf->setValue("update_frequency_hours", 72); conf->setValue("update_frequency_hours", 72);
conf->endGroup(); conf->endGroup();
} }
void Exoplanets::readSettingsFromConfig(void) void Exoplanets::readSettingsFromConfig(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
updateUrl = conf->value("url", "http://stellarium.org/json/exoplanet s.json").toString(); updateUrl = conf->value("url", "http://stellarium.org/json/exoplanet s.json").toString();
updateFrequencyHours = conf->value("update_frequency_hours", 72).toI nt(); updateFrequencyHours = conf->value("update_frequency_hours", 72).toI nt();
lastUpdate = QDateTime::fromString(conf->value("last_update", "2012- 05-24T12:00:00").toString(), Qt::ISODate); lastUpdate = QDateTime::fromString(conf->value("last_update", "2012- 05-24T12:00:00").toString(), Qt::ISODate);
updatesEnabled = conf->value("updates_enabled", true).toBool(); updatesEnabled = conf->value("updates_enabled", true).toBool();
distributionEnabled = conf->value("distribution_enabled", false).toB
ool();
timelineEnabled = conf->value("timeline_enabled", false).toBool();
flagShowExoplanets = conf->value("flag_show_exoplanets", false).toBo ol(); flagShowExoplanets = conf->value("flag_show_exoplanets", false).toBo ol();
conf->endGroup(); conf->endGroup();
} }
void Exoplanets::saveSettingsToConfig(void) void Exoplanets::saveSettingsToConfig(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
conf->setValue("url", updateUrl); conf->setValue("url", updateUrl);
conf->setValue("update_frequency_hours", updateFrequencyHours); conf->setValue("update_frequency_hours", updateFrequencyHours);
conf->setValue("updates_enabled", updatesEnabled ); conf->setValue("updates_enabled", updatesEnabled );
conf->setValue("distribution_enabled", distributionEnabled);
conf->setValue("timeline_enabled", timelineEnabled);
conf->setValue("flag_show_exoplanets", flagShowExoplanets); conf->setValue("flag_show_exoplanets", flagShowExoplanets);
conf->endGroup(); conf->endGroup();
} }
int Exoplanets::getSecondsToUpdate(void) int Exoplanets::getSecondsToUpdate(void)
{ {
QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0); QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0);
return QDateTime::currentDateTime().secsTo(nextUpdate); return QDateTime::currentDateTime().secsTo(nextUpdate);
} }
 End of changes. 24 change blocks. 
48 lines changed or deleted 76 lines changed or added

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