Pulsars.cpp   Pulsars.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 "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "Pulsar.hpp" #include "Pulsar.hpp"
#include "Pulsars.hpp" #include "Pulsars.hpp"
#include "PulsarsDialog.hpp" #include "PulsarsDialog.hpp"
#include "renderer/StelRenderer.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>
#define CATALOG_FORMAT_VERSION 2 /* Version of format of catalog */ #define CATALOG_FORMAT_VERSION 2 /* 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
*/ */
StelModule* PulsarsStelPluginInterface::getStelModule() const StelModule* PulsarsStelPluginInterface::getStelModule() const
skipping to change at line 83 skipping to change at line 83
info.description = N_("This plugin plots the position of various pul sars, with object information about each one."); info.description = N_("This plugin plots the position of various pul sars, with object information about each one.");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Pulsars, PulsarsStelPluginInterface) Q_EXPORT_PLUGIN2(Pulsars, PulsarsStelPluginInterface)
/* /*
Constructor Constructor
*/ */
Pulsars::Pulsars() Pulsars::Pulsars()
: progressBar(NULL) : texPointer(NULL)
, markerTexture(NULL)
, progressBar(NULL)
{ {
setObjectName("Pulsars"); setObjectName("Pulsars");
configDialog = new PulsarsDialog(); configDialog = new PulsarsDialog();
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
*/ */
Pulsars::~Pulsars() Pulsars::~Pulsars()
{ {
delete configDialog; delete configDialog;
} }
void Pulsars::deinit() void Pulsars::deinit()
{ {
psr.clear(); psr.clear();
Pulsar::markerTexture.clear(); if(NULL != markerTexture)
texPointer.clear(); {
delete markerTexture;
}
if(NULL != texPointer)
{
delete texPointer;
}
} }
/* /*
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*/ */
double Pulsars::getCallOrder(StelModuleActionName actionName) const double Pulsars::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Cons tellationMgr")->getCallOrder(actionName)+10.; return StelApp::getInstance().getModuleMgr().getModule("Cons tellationMgr")->getCallOrder(actionName)+10.;
return 0; return 0;
skipping to change at line 137 skipping to change at line 145
{ {
qDebug() << "Pulsars::init no Pulsars section exists in main config file - creating with defaults"; qDebug() << "Pulsars::init no Pulsars 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/Pulsars", ( StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/puls ars.json"; jsonCatalogPath = StelFileMgr::findFile("modules/Pulsars", ( StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/puls ars.json";
texPointer = StelApp::getInstance().getTextureManager().crea
teTexture("textures/pointeur2.png");
Pulsar::markerTexture = StelApp::getInstance().getTextureMan
ager().createTexture(":/Pulsars/pulsar.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());
gui->addGuiActions("actionShow_Pulsars_ConfigDialog", N_("Pu lsars configuration window"), "", groupName, true);
connect(gui->getGuiActions("actionShow_Pulsars_ConfigDialog" connect(gui->getGuiAction("actionShow_Pulsars_ConfigDialog")
), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); , SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get
GuiActions("actionShow_Pulsars_ConfigDialog"), SLOT(setChecked(bool))); GuiAction("actionShow_Pulsars_ConfigDialog"), SLOT(setChecked(bool)));
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Pulsars::init error: " << e.what(); qWarning() << "Pulsars::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 196 skipping to change at line 198
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 Pulsars::draw(StelCore* core) void Pulsars::draw(StelCore* core, StelRenderer* renderer)
{ {
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
StelPainter painter(prj); renderer->setFont(font);
painter.setFont(font);
foreach (const PulsarP& pulsar, psr) foreach (const PulsarP& pulsar, psr)
{ {
if (pulsar && pulsar->initialized) if (pulsar && pulsar->initialized)
pulsar->draw(core, painter); {
if(NULL == markerTexture)
{
markerTexture = renderer->createTexture(":/P
ulsars/pulsar.png");
}
pulsar->draw(core, renderer, prj, markerTexture);
}
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, painter); {
drawPointer(core, renderer, prj);
}
} }
void Pulsars::drawPointer(StelCore* core, StelPainter& painter) void Pulsars::drawPointer(StelCore* core, StelRenderer* renderer, StelProje ctorP projector)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Pulsar"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Pulsar");
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]);
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur2.png");
}
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, 26.0f,
transparency mode StelApp::getInstance().getTotalRu
painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, S nTime() * 40.0f);
telApp::getInstance().getTotalRunTime()*40.);
} }
} }
QList<StelObjectP> Pulsars::searchAround(const Vec3d& av, double limitFov, const StelCore*) const QList<StelObjectP> Pulsars::searchAround(const Vec3d& av, double limitFov, const StelCore*) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
Vec3d v(av); Vec3d v(av);
v.normalize(); v.normalize();
double cosLimFov = cos(limitFov * M_PI/180.); double cosLimFov = cos(limitFov * M_PI/180.);
skipping to change at line 309 skipping to change at line 320
result << pulsar->getNameI18n().toUpper(); result << pulsar->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; return result;
} }
QStringList Pulsars::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
foreach(const PulsarP& pulsar, psr)
{
result << pulsar->getEnglishName();
}
}
else
{
foreach(const PulsarP& pulsar, psr)
{
result << pulsar->getNameI18n();
}
}
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 Pulsars::restoreDefaultJsonFile(void) void Pulsars::restoreDefaultJsonFile(void)
{ {
if (QFileInfo(jsonCatalogPath).exists()) if (QFileInfo(jsonCatalogPath).exists())
backupJsonFile(true); backupJsonFile(true);
QFile src(":/Pulsars/pulsars.json"); QFile src(":/Pulsars/pulsars.json");
if (!src.copy(jsonCatalogPath)) if (!src.copy(jsonCatalogPath))
skipping to change at line 457 skipping to change at line 488
return pulsar; return pulsar;
} }
return PulsarP(); return PulsarP();
} }
bool Pulsars::configureGui(bool show) bool Pulsars::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_Pulsars_ConfigDialog")->setCh ecked(true); gui->getGuiAction("actionShow_Pulsars_ConfigDialog")->setChe cked(true);
} }
return true; return true;
} }
void Pulsars::restoreDefaults(void) void Pulsars::restoreDefaults(void)
{ {
restoreDefaultConfigIni(); restoreDefaultConfigIni();
restoreDefaultJsonFile(); restoreDefaultJsonFile();
readJsonFile(); readJsonFile();
 End of changes. 21 change blocks. 
38 lines changed or deleted 67 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/