Supernovae.cpp   Supernovae.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 "Supernova.hpp" #include "Supernova.hpp"
#include "Supernovae.hpp" #include "Supernovae.hpp"
#include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "SupernovaeDialog.hpp" #include "SupernovaeDialog.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 <QFile> #include <QFile>
#include <QFileInfo>
#include <QTimer> #include <QTimer>
#include <QVariantMap>
#include <QVariant>
#include <QList> #include <QList>
#include <QSettings>
#include <QSharedPointer> #include <QSharedPointer>
#include <QStringList> #include <QStringList>
#include <QVariant>
#include <QVariantMap>
#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
*/ */
StelModule* SupernovaeStelPluginInterface::getStelModule() const StelModule* SupernovaeStelPluginInterface::getStelModule() const
{ {
return new Supernovae(); return new Supernovae();
skipping to change at line 83 skipping to change at line 84
info.description = N_("A plugin that shows some historical supernova e brighter than 10 visual magnitude."); info.description = N_("A plugin that shows some historical supernova e brighter than 10 visual magnitude.");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Supernovae, SupernovaeStelPluginInterface) Q_EXPORT_PLUGIN2(Supernovae, SupernovaeStelPluginInterface)
/* /*
Constructor Constructor
*/ */
Supernovae::Supernovae() Supernovae::Supernovae()
: progressBar(NULL) : texPointer(NULL)
, progressBar(NULL)
{ {
setObjectName("Supernovae"); setObjectName("Supernovae");
configDialog = new SupernovaeDialog(); configDialog = new SupernovaeDialog();
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
*/ */
Supernovae::~Supernovae() Supernovae::~Supernovae()
{ {
delete configDialog; delete configDialog;
} }
void Supernovae::deinit() void Supernovae::deinit()
{ {
texPointer.clear(); if(NULL != texPointer)
{
delete texPointer;
}
} }
/* /*
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*/ */
double Supernovae::getCallOrder(StelModuleActionName actionName) const double Supernovae::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 134 skipping to change at line 139
if (!conf->childGroups().contains("Supernovae")) if (!conf->childGroups().contains("Supernovae"))
{ {
qDebug() << "Supernovae::init no Supernovae section exists in main config file - creating with defaults"; qDebug() << "Supernovae::init no Supernovae 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();
sneJsonPath = StelFileMgr::findFile("modules/Supernovae", (S telFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/super novae.json"; sneJsonPath = StelFileMgr::findFile("modules/Supernovae", (S telFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/super novae.json";
texPointer = StelApp::getInstance().getTextureManager().crea
teTexture("textures/pointeur2.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_Supernovae_ConfigDialog", N_( "Historical Supernovae configuration window"), "", groupName, true);
connect(gui->getGuiActions("actionShow_Supernovae_ConfigDial connect(gui->getGuiAction("actionShow_Supernovae_ConfigDialo
og"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); g"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get
GuiActions("actionShow_Supernovae_ConfigDialog"), SLOT(setChecked(bool))); GuiAction("actionShow_Supernovae_ConfigDialog"), SLOT(setChecked(bool)));
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Supernovas::init error: " << e.what(); qWarning() << "Supernovas::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 193 skipping to change at line 192
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 SNe in the main window Draw our module. This should print name of first SNe in the main window
*/ */
void Supernovae::draw(StelCore* core) void Supernovae::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 SupernovaP& sn, snstar) foreach (const SupernovaP& sn, snstar)
{ {
if (sn && sn->initialized) if (sn && sn->initialized)
sn->draw(core, painter); {
sn->draw(core, renderer, prj);
}
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, painter); {
drawPointer(core, renderer, prj);
}
} }
void Supernovae::drawPointer(StelCore* core, StelPainter& painter) void Supernovae::drawPointer(StelCore* core, StelRenderer* renderer, StelPr ojectorP projector)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Supernova"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Supernova");
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> Supernovae::searchAround(const Vec3d& av, double limitFo v, const StelCore*) const QList<StelObjectP> Supernovae::searchAround(const Vec3d& av, double limitFo v, 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 306 skipping to change at line 310
result << sn->getNameI18n().toUpper(); result << sn->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 Supernovae::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
foreach (const SupernovaP& sn, snstar)
{
result << sn->getEnglishName();
}
}
else
{
foreach (const SupernovaP& sn, snstar)
{
result << sn->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 Supernovae::restoreDefaultJsonFile(void) void Supernovae::restoreDefaultJsonFile(void)
{ {
if (QFileInfo(sneJsonPath).exists()) if (QFileInfo(sneJsonPath).exists())
backupJsonFile(true); backupJsonFile(true);
QFile src(":/Supernovae/supernovae.json"); QFile src(":/Supernovae/supernovae.json");
if (!src.copy(sneJsonPath)) if (!src.copy(sneJsonPath))
skipping to change at line 457 skipping to change at line 481
return sn; return sn;
} }
return SupernovaP(); return SupernovaP();
} }
bool Supernovae::configureGui(bool show) bool Supernovae::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_Supernovae_ConfigDialog")->se tChecked(true); gui->getGuiAction("actionShow_Supernovae_ConfigDialog")->set Checked(true);
} }
return true; return true;
} }
void Supernovae::restoreDefaults(void) void Supernovae::restoreDefaults(void)
{ {
restoreDefaultConfigIni(); restoreDefaultConfigIni();
restoreDefaultJsonFile(); restoreDefaultJsonFile();
readJsonFile(); readJsonFile();
 End of changes. 26 change blocks. 
38 lines changed or deleted 60 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/