StelApp.cpp   StelApp.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* 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 "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelLoadingBar.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "MilkyWay.hpp" #include "MilkyWay.hpp"
#include "MeteorMgr.hpp" #include "MeteorMgr.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLocationMgr.hpp" #include "StelLocationMgr.hpp"
#include "StelActionMgr.hpp"
#include "StelProgressController.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelShortcutMgr.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelSkyLayerMgr.hpp" #include "StelSkyLayerMgr.hpp"
#include "StelAudioMgr.hpp" #include "StelAudioMgr.hpp"
#include "StelVideoMgr.hpp" #include "StelVideoMgr.hpp"
#include "StelGuiBase.hpp" #include "StelGuiBase.hpp"
#include "StelPainter.hpp"
#include "renderer/StelRenderer.hpp" #ifndef DISABLE_SCRIPTING
#include "StelScriptMgr.hpp"
#include "StelMainScriptAPIProxy.hpp"
#endif
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox>
#include <QMouseEvent> #include <QMouseEvent>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkDiskCache> #include <QNetworkDiskCache>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QNetworkReply> #include <QNetworkReply>
#include <QOpenGLContext>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QSysInfo> #include <QSysInfo>
#include <QTextStream> #include <QTextStream>
#include <QTimer> #include <QTimer>
#include <QDir> #include <QDir>
#include <QCoreApplication>
#include <QScreen>
Q_IMPORT_PLUGIN(StelStandardGuiPluginInterface)
#ifdef USE_STATIC_PLUGIN_VIRGO
Q_IMPORT_PLUGIN(VirGOStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_SVMT
Q_IMPORT_PLUGIN(SVMTStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_HELLOSTELMODULE
Q_IMPORT_PLUGIN(HelloStelModuleStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_SIMPLEDRAWLINE
Q_IMPORT_PLUGIN(SimpleDrawLineStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_ANGLEMEASURE
Q_IMPORT_PLUGIN(AngleMeasureStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_COMPASSMARKS
Q_IMPORT_PLUGIN(CompassMarksStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_SATELLITES
Q_IMPORT_PLUGIN(SatellitesStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_TEXTUSERINTERFACE
Q_IMPORT_PLUGIN(TextUserInterfaceStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_LOGBOOK
Q_IMPORT_PLUGIN(LogBookStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_OCULARS
Q_IMPORT_PLUGIN(OcularsStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_TELESCOPECONTROL
Q_IMPORT_PLUGIN(TelescopeControlStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_SOLARSYSTEMEDITOR
Q_IMPORT_PLUGIN(SolarSystemEditorStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_TIMEZONECONFIGURATION
Q_IMPORT_PLUGIN(TimeZoneConfigurationStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_METEORSHOWERS
Q_IMPORT_PLUGIN(MeteorShowersStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_NAVSTARS
Q_IMPORT_PLUGIN(NavStarsStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_NOVAE
Q_IMPORT_PLUGIN(NovaeStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_SUPERNOVAE
Q_IMPORT_PLUGIN(SupernovaeStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_QUASARS
Q_IMPORT_PLUGIN(QuasarsStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_PULSARS
Q_IMPORT_PLUGIN(PulsarsStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_EXOPLANETS
Q_IMPORT_PLUGIN(ExoplanetsStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_EQUATIONOFTIME
Q_IMPORT_PLUGIN(EquationOfTimeStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_FOV
Q_IMPORT_PLUGIN(FOVStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_POINTERCOORDINATES
Q_IMPORT_PLUGIN(PointerCoordinatesStelPluginInterface)
#endif
#ifdef USE_STATIC_PLUGIN_OBSERVABILITY
Q_IMPORT_PLUGIN(ObservabilityStelPluginInterface)
#endif
// Initialize static variables // Initialize static variables
StelApp* StelApp::singleton = NULL; StelApp* StelApp::singleton = NULL;
QTime* StelApp::qtime = NULL; QTime* StelApp::qtime = NULL;
void StelApp::initStatic() void StelApp::initStatic()
{ {
StelApp::qtime = new QTime(); StelApp::qtime = new QTime();
StelApp::qtime->start(); StelApp::qtime->start();
} }
void StelApp::deinitStatic() void StelApp::deinitStatic()
{ {
delete StelApp::qtime; delete StelApp::qtime;
StelApp::qtime = NULL; StelApp::qtime = NULL;
} }
bool StelApp::getRenderSolarShadows() const
{
return renderSolarShadows;
}
/************************************************************************* /*************************************************************************
Create and initialize the main Stellarium application. Create and initialize the main Stellarium application.
*************************************************************************/ *************************************************************************/
StelApp::StelApp(QObject* parent) StelApp::StelApp(QObject* parent)
: QObject(parent), core(NULL), stelGui(NULL), fps(0), : QObject(parent)
frame(0), timefr(0.), timeBase(0.), flagNightVision(false), render , core(NULL)
SolarShadows(false), , planetLocationMgr(NULL)
confSettings(NULL), initialized(false), saveProjW(-1), saveProjH(- , audioMgr(NULL)
1), drawState(0) , videoMgr(NULL)
, skyImageMgr(NULL)
#ifndef DISABLE_SCRIPTING
, scriptAPIProxy(NULL)
, scriptMgr(NULL)
#endif
, stelGui(NULL)
, devicePixelsPerPixel(1.f)
, globalScalingRatio(1.f)
, fps(0)
, frame(0)
, timefr(0.)
, timeBase(0.)
, flagNightVision(false)
, confSettings(NULL)
, initialized(false)
, saveProjW(-1)
, saveProjH(-1)
{ {
// Stat variables // Stat variables
nbDownloadedFiles=0; nbDownloadedFiles=0;
totalDownloadedSize=0; totalDownloadedSize=0;
nbUsedCache=0; nbUsedCache=0;
totalUsedCacheSize=0; totalUsedCacheSize=0;
setObjectName("StelApp"); setObjectName("StelApp");
skyCultureMgr=NULL; skyCultureMgr=NULL;
localeMgr=NULL; localeMgr=NULL;
stelObjectMgr=NULL; stelObjectMgr=NULL;
textureMgr=NULL;
moduleMgr=NULL;
networkAccessManager=NULL; networkAccessManager=NULL;
shortcutMgr = NULL; actionMgr = NULL;
// Can't create 2 StelApp instances // Can't create 2 StelApp instances
Q_ASSERT(!singleton); Q_ASSERT(!singleton);
singleton = this; singleton = this;
moduleMgr = new StelModuleMgr(); moduleMgr = new StelModuleMgr();
wheelEventTimer = new QTimer(this); wheelEventTimer = new QTimer(this);
wheelEventTimer->setInterval(25); wheelEventTimer->setInterval(25);
wheelEventTimer->setSingleShot(TRUE); wheelEventTimer->setSingleShot(true);
// Reset delta accumulators
wheelEventDelta[0] = wheelEventDelta[1] = 0;
} }
/************************************************************************* /*************************************************************************
Deinitialize and destroy the main Stellarium application. Deinitialize and destroy the main Stellarium application.
*************************************************************************/ *************************************************************************/
StelApp::~StelApp() StelApp::~StelApp()
{ {
qDebug() << qPrintable(QString("Downloaded %1 files (%2 kbytes) in a session of %3 sec (average of %4 kB/s + %5 files from cache (%6 kB)).").ar g(nbDownloadedFiles).arg(totalDownloadedSize/1024).arg(getTotalRunTime()).a rg((double)(totalDownloadedSize/1024)/getTotalRunTime()).arg(nbUsedCache).a rg(totalUsedCacheSize/1024)); qDebug() << qPrintable(QString("Downloaded %1 files (%2 kbytes) in a session of %3 sec (average of %4 kB/s + %5 files from cache (%6 kB)).").ar g(nbDownloadedFiles).arg(totalDownloadedSize/1024).arg(getTotalRunTime()).a rg((double)(totalDownloadedSize/1024)/getTotalRunTime()).arg(nbUsedCache).a rg(totalUsedCacheSize/1024));
stelObjectMgr->unSelect(); stelObjectMgr->unSelect();
skipping to change at line 144 skipping to change at line 267
StelModuleMgr* tmp = moduleMgr; StelModuleMgr* tmp = moduleMgr;
moduleMgr = new StelModuleMgr(); // Create a secondary instance to a void crashes at other deinit moduleMgr = new StelModuleMgr(); // Create a secondary instance to a void crashes at other deinit
delete tmp; tmp=NULL; delete tmp; tmp=NULL;
delete skyImageMgr; skyImageMgr=NULL; delete skyImageMgr; skyImageMgr=NULL;
delete core; core=NULL; delete core; core=NULL;
delete skyCultureMgr; skyCultureMgr=NULL; delete skyCultureMgr; skyCultureMgr=NULL;
delete localeMgr; localeMgr=NULL; delete localeMgr; localeMgr=NULL;
delete audioMgr; audioMgr=NULL; delete audioMgr; audioMgr=NULL;
delete videoMgr; videoMgr=NULL; delete videoMgr; videoMgr=NULL;
delete stelObjectMgr; stelObjectMgr=NULL; // Delete the module by ha nd afterward delete stelObjectMgr; stelObjectMgr=NULL; // Delete the module by ha nd afterward
delete textureMgr; textureMgr=NULL;
delete planetLocationMgr; planetLocationMgr=NULL; delete planetLocationMgr; planetLocationMgr=NULL;
delete moduleMgr; moduleMgr=NULL; // Delete the secondary instance delete moduleMgr; moduleMgr=NULL; // Delete the secondary instance
delete shortcutMgr; shortcutMgr = NULL; delete actionMgr; actionMgr = NULL;
Q_ASSERT(singleton); Q_ASSERT(singleton);
singleton = NULL; singleton = NULL;
} }
void StelApp::setupHttpProxy() void StelApp::setupHttpProxy()
{ {
QString proxyHost = confSettings->value("proxy/host_name").toString( ); QString proxyHost = confSettings->value("proxy/host_name").toString( );
QString proxyPort = confSettings->value("proxy/port").toString(); QString proxyPort = confSettings->value("proxy/port").toString();
QString proxyUser = confSettings->value("proxy/user").toString(); QString proxyUser = confSettings->value("proxy/user").toString();
skipping to change at line 219 skipping to change at line 343
if (!proxyPass.isEmpty()) if (!proxyPass.isEmpty())
proxy.setPassword(proxyPass); proxy.setPassword(proxyPass);
QString ppDisp = proxyPass; QString ppDisp = proxyPass;
ppDisp.fill('*'); ppDisp.fill('*');
qDebug() << "Using HTTP proxy:" << proxyUser << ppDisp << pr oxyHost << proxyPort; qDebug() << "Using HTTP proxy:" << proxyUser << ppDisp << pr oxyHost << proxyPort;
QNetworkProxy::setApplicationProxy(proxy); QNetworkProxy::setApplicationProxy(proxy);
} }
} }
void StelApp::init(QSettings* conf, StelRenderer* renderer) #ifndef DISABLE_SCRIPTING
void StelApp::initScriptMgr(QSettings *conf)
{
scriptAPIProxy = new StelMainScriptAPIProxy(this);
scriptMgr = new StelScriptMgr(this);
scriptMgr->addModules();
QString startupScript;
if (qApp->property("onetime_startup_script").isValid())
startupScript = qApp->property("onetime_startup_script").toS
tring();
else
startupScript = conf->value("scripts/startup_script", "start
up.ssc").toString();
// Use a queued slot call to start the script only once the main qAp
p event loop is running...
QMetaObject::invokeMethod(scriptMgr,
"runScript",
Qt::QueuedConnection,
Q_ARG(QString, startupScript));
}
#else
void StelApp::initScriptMgr(QSettings *conf) {Q_UNUSED(conf);}
#endif
void StelApp::init(QSettings* conf)
{ {
confSettings = conf; confSettings = conf;
devicePixelsPerPixel = QOpenGLContext::currentContext()->screen()->d
evicePixelRatio();
core = new StelCore(); core = new StelCore();
if (saveProjW!=-1 && saveProjH!=-1) if (saveProjW!=-1 && saveProjH!=-1)
core->windowHasBeenResized(0, 0, saveProjW, saveProjH); core->windowHasBeenResized(0, 0, saveProjW, saveProjH);
renderSolarShadows = renderer->areFloatTexturesSupported(); // Initialize AFTER creation of openGL context
textureMgr = new StelTextureMgr();
QString splashFileName = "textures/logo24bits.png"; textureMgr->init();
#ifdef BUILD_FOR_MAEMO
StelLoadingBar loadingBar(splashFileName, "", 25, 320, 101, 800, 400
);
#else
#ifdef BZR_REVISION
StelLoadingBar loadingBar(splashFileName, QString("BZR r%1").arg(BZR
_REVISION), 25, 320, 101);
#elif SVN_REVISION
StelLoadingBar loadingBar(splashFileName, QString("SVN r%1").arg(SVN
_REVISION), 25, 320, 101);
#else
StelLoadingBar loadingBar(splashFileName, PACKAGE_VERSION, 45, 320,
121);
#endif
#endif
loadingBar.draw(renderer);
networkAccessManager = new QNetworkAccessManager(this); networkAccessManager = new QNetworkAccessManager(this);
// Activate http cache if Qt version >= 4.5 // Activate http cache if Qt version >= 4.5
QNetworkDiskCache* cache = new QNetworkDiskCache(networkAccessManage r); QNetworkDiskCache* cache = new QNetworkDiskCache(networkAccessManage r);
QString cachePath = StelFileMgr::getCacheDir(); QString cachePath = StelFileMgr::getCacheDir();
qDebug() << "Cache directory is: " << QDir::toNativeSeparators(cache Path); qDebug() << "Cache directory is: " << QDir::toNativeSeparators(cache Path);
cache->setCacheDirectory(cachePath); cache->setCacheDirectory(cachePath);
networkAccessManager->setCache(cache); networkAccessManager->setCache(cache);
connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), this , SLOT(reportFileDownloadFinished(QNetworkReply*))); connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), this , SLOT(reportFileDownloadFinished(QNetworkReply*)));
// Stel Object Data Base manager // Stel Object Data Base manager
stelObjectMgr = new StelObjectMgr(); stelObjectMgr = new StelObjectMgr();
stelObjectMgr->init(); stelObjectMgr->init();
getModuleMgr().registerModule(stelObjectMgr); getModuleMgr().registerModule(stelObjectMgr);
localeMgr = new StelLocaleMgr(); localeMgr = new StelLocaleMgr();
skyCultureMgr = new StelSkyCultureMgr(); skyCultureMgr = new StelSkyCultureMgr();
planetLocationMgr = new StelLocationMgr(); planetLocationMgr = new StelLocationMgr();
shortcutMgr = new StelShortcutMgr(); actionMgr = new StelActionMgr();
localeMgr->init(); localeMgr->init();
shortcutMgr->init();
// Init the solar system first // Init the solar system first
SolarSystem* ssystem = new SolarSystem(); SolarSystem* ssystem = new SolarSystem();
ssystem->init(); ssystem->init();
getModuleMgr().registerModule(ssystem); getModuleMgr().registerModule(ssystem);
// Load hipparcos stars & names // Load hipparcos stars & names
StarMgr* hip_stars = new StarMgr(); StarMgr* hip_stars = new StarMgr();
hip_stars->init(); hip_stars->init();
getModuleMgr().registerModule(hip_stars); getModuleMgr().registerModule(hip_stars);
core->init(renderer); core->init();
// Init nebulas // Init nebulas
NebulaMgr* nebulas = new NebulaMgr(); NebulaMgr* nebulas = new NebulaMgr();
nebulas->init(); nebulas->init();
getModuleMgr().registerModule(nebulas); getModuleMgr().registerModule(nebulas);
// Init milky way // Init milky way
MilkyWay* milky_way = new MilkyWay(); MilkyWay* milky_way = new MilkyWay();
milky_way->init(); milky_way->init();
getModuleMgr().registerModule(milky_way); getModuleMgr().registerModule(milky_way);
skipping to change at line 315 skipping to change at line 448
// Landscape, atmosphere & cardinal points section // Landscape, atmosphere & cardinal points section
LandscapeMgr* landscape = new LandscapeMgr(); LandscapeMgr* landscape = new LandscapeMgr();
landscape->init(); landscape->init();
getModuleMgr().registerModule(landscape); getModuleMgr().registerModule(landscape);
GridLinesMgr* gridLines = new GridLinesMgr(); GridLinesMgr* gridLines = new GridLinesMgr();
gridLines->init(); gridLines->init();
getModuleMgr().registerModule(gridLines); getModuleMgr().registerModule(gridLines);
// Meteors // Meteors
MeteorMgr* meteors = new MeteorMgr(10, 60); MeteorMgr* meteors = new MeteorMgr(10, 72);
meteors->init(); meteors->init();
getModuleMgr().registerModule(meteors); getModuleMgr().registerModule(meteors);
// User labels // User labels
LabelMgr* skyLabels = new LabelMgr(); LabelMgr* skyLabels = new LabelMgr();
skyLabels->init(); skyLabels->init();
getModuleMgr().registerModule(skyLabels); getModuleMgr().registerModule(skyLabels);
skyCultureMgr->init(); skyCultureMgr->init();
// Initialisation of the color scheme initScriptMgr(conf);
bool tmp = confSettings->value("viewing/flag_night").toBool();
flagNightVision=!tmp; // fool caching
setVisionModeNight(tmp);
// Initialisation of the render of solar shadows // Initialisation of the color scheme
setRenderSolarShadows(confSettings->value("viewing/flag_render_solar emit colorSchemeChanged("color");
_shadows", true).toBool()); setVisionModeNight(confSettings->value("viewing/flag_night").toBool(
));
// Proxy Initialisation // Proxy Initialisation
setupHttpProxy(); setupHttpProxy();
updateI18n(); updateI18n();
// Init actions.
actionMgr->addAction("actionShow_Night_Mode", N_("Display Options"),
N_("Night mode"), this, "nightMode");
initialized = true; initialized = true;
} }
// Load and initialize external modules (plugins) // Load and initialize external modules (plugins)
void StelApp::initPlugIns() void StelApp::initPlugIns()
{ {
// Load dynamically all the modules found in the modules/ directorie s // Load dynamically all the modules found in the modules/ directorie s
// which are configured to be loaded at startup // which are configured to be loaded at startup
foreach (StelModuleMgr::PluginDescriptor i, moduleMgr->getPluginsLis t()) foreach (StelModuleMgr::PluginDescriptor i, moduleMgr->getPluginsLis t())
{ {
skipping to change at line 359 skipping to change at line 493
continue; continue;
StelModule* m = moduleMgr->loadPlugin(i.info.id); StelModule* m = moduleMgr->loadPlugin(i.info.id);
if (m!=NULL) if (m!=NULL)
{ {
moduleMgr->registerModule(m, true); moduleMgr->registerModule(m, true);
m->init(); m->init();
} }
} }
} }
void StelApp::deinit()
{
#ifndef DISABLE_SCRIPTING
if (scriptMgr->scriptIsRunning())
scriptMgr->stopScript();
#endif
QCoreApplication::processEvents();
getModuleMgr().unloadAllPlugins();
QCoreApplication::processEvents();
StelPainter::deinitGLShaders();
}
StelProgressController* StelApp::addProgressBar()
{
StelProgressController* p = new StelProgressController();
progressControllers.append(p);
emit(progressBarAdded(p));
return p;
}
void StelApp::removeProgressBar(StelProgressController* p)
{
progressControllers.removeOne(p);
emit(progressBarRemoved(p));
delete p;
}
void StelApp::update(double deltaTime) void StelApp::update(double deltaTime)
{ {
if (!initialized) if (!initialized)
return; return;
++frame; ++frame;
timefr+=deltaTime; timefr+=deltaTime;
if (timefr-timeBase > 1.) if (timefr-timeBase > 1.)
{ {
// Calc the FPS rate every seconds // Calc the FPS rate every seconds
skipping to change at line 387 skipping to change at line 549
// Send the event to every StelModule // Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionU pdate)) foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionU pdate))
{ {
i->update(deltaTime); i->update(deltaTime);
} }
stelObjectMgr->update(deltaTime); stelObjectMgr->update(deltaTime);
} }
//! Iterate through the drawing sequence. //! Main drawing function called at each frame
bool StelApp::drawPartial(StelRenderer* renderer) void StelApp::draw()
{ {
if (drawState == 0) if (!initialized)
{ return;
if (!initialized) core->preDraw();
return false;
core->preDraw();
drawState = 1;
return true;
}
const QList<StelModule*> modules = moduleMgr->getCallOrders(StelModu le::ActionDraw); const QList<StelModule*> modules = moduleMgr->getCallOrders(StelModu le::ActionDraw);
int index = drawState - 1; foreach(StelModule* module, modules)
if (index < modules.size())
{ {
if (modules[index]->drawPartial(core, renderer)) module->draw(core);
return true; }
drawState++; core->postDraw();
return true;
}
core->postDraw(renderer);
drawState = 0;
return false;
} }
/************************************************************************* /*************************************************************************
Call this when the size of the window has changed Call this when the size of the GL window has changed
*************************************************************************/ *************************************************************************/
void StelApp::windowHasBeenResized(float x, float y, float w, float h) void StelApp::glWindowHasBeenResized(float x, float y, float w, float h)
{ {
if (core) if (core)
core->windowHasBeenResized(x, y, w, h); core->windowHasBeenResized(x, y, w, h);
else else
{ {
saveProjW = w; saveProjW = w;
saveProjH = h; saveProjH = h;
} }
} }
// Handle mouse clics // Handle mouse clics
void StelApp::handleClick(QMouseEvent* event) void StelApp::handleClick(QMouseEvent* inputEvent)
{ {
event->setAccepted(false); inputEvent->setAccepted(false);
QMouseEvent event(inputEvent->type(), QPoint(inputEvent->pos().x()*d
evicePixelsPerPixel, inputEvent->pos().y()*devicePixelsPerPixel), inputEven
t->button(), inputEvent->buttons(), inputEvent->modifiers());
event.setAccepted(false);
// Send the event to every StelModule // Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseClicks)) foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseClicks))
{ {
i->handleMouseClicks(event); i->handleMouseClicks(&event);
if (event->isAccepted()) if (event.isAccepted())
{
inputEvent->setAccepted(true);
return; return;
}
} }
} }
// Handle mouse wheel. // Handle mouse wheel.
// This deltaEvent is a work-around for QTBUG-22269 // This deltaEvent is a work-around for QTBUG-22269
void StelApp::handleWheel(QWheelEvent* event) void StelApp::handleWheel(QWheelEvent* event)
{ {
// variables used to track the changes
static int delta = 0;
event->setAccepted(false); event->setAccepted(false);
if (wheelEventTimer->isActive()) {
// Collect the values; we only care about the fianl position
values, but we want to accumalate the delta.
delta += event->delta();
} else {
// The first time in, the values will not have been set.
if (delta == 0) {
delta += event->delta();
}
wheelEventTimer->start(); const int deltaIndex = event->orientation() == Qt::Horizontal ? 0 :
QWheelEvent deltaEvent(event->pos(), event->globalPos(), del 1;
ta, event->buttons(), event->modifiers(), event->orientation()); wheelEventDelta[deltaIndex] += event->delta();
deltaEvent.setAccepted(FALSE); if (wheelEventTimer->isActive())
// Send the event to every StelModule {
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule: // Collect the values. If delta is small enough we wait for
:ActionHandleMouseClicks)) { more values or the end
i->handleMouseWheel(&deltaEvent); // of the timer period to process them.
if (deltaEvent.isAccepted()) { if (qAbs(wheelEventDelta[deltaIndex]) < 120)
event->accept(); return;
break; }
}
wheelEventTimer->start();
// Create a new event with the accumulated delta
QWheelEvent deltaEvent(QPoint(event->pos().x()*devicePixelsPerPixel,
event->pos().y()*devicePixelsPerPixel),
QPoint(event->globalPos().x()*devicePixelsPer
Pixel, event->globalPos().y()*devicePixelsPerPixel),
wheelEventDelta[deltaIndex], event->buttons()
, event->modifiers(), event->orientation());
deltaEvent.setAccepted(false);
// Reset the collected values
wheelEventDelta[deltaIndex] = 0;
// Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH
andleMouseClicks)) {
i->handleMouseWheel(&deltaEvent);
if (deltaEvent.isAccepted()) {
event->accept();
break;
} }
// Reset the collected values
delta = 0;
} }
} }
// Handle mouse move // Handle mouse move
void StelApp::handleMove(int x, int y, Qt::MouseButtons b) void StelApp::handleMove(int x, int y, Qt::MouseButtons b)
{ {
// Send the event to every StelModule // Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseMoves)) foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseMoves))
{ {
if (i->handleMouseMoves(x, y, b)) if (i->handleMouseMoves(x*devicePixelsPerPixel, y*devicePixe lsPerPixel, b))
return; return;
} }
} }
// Handle key press and release // Handle key press and release
void StelApp::handleKeys(QKeyEvent* event) void StelApp::handleKeys(QKeyEvent* event)
{ {
event->setAccepted(false); event->setAccepted(false);
// First try to trigger a shortcut.
if (event->type() == QEvent::KeyPress)
{
if (getStelActionManager()->pushKey(event->key() + event->mo
difiers()))
{
event->setAccepted(true);
return;
}
}
// Send the event to every StelModule // Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleKeys)) foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleKeys))
{ {
i->handleKeys(event); i->handleKeys(event);
if (event->isAccepted()) if (event->isAccepted())
return; return;
} }
} }
void StelApp::setRenderSolarShadows(bool b) // Handle pinch on multi touch devices
void StelApp::handlePinch(qreal scale, bool started)
{ {
renderSolarShadows = b; // Send the event to every StelModule
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH
andleMouseMoves))
{
if (i->handlePinch(scale, started))
return;
}
} }
//! Set flag for activating night vision mode //! Set flag for activating night vision mode
void StelApp::setVisionModeNight(bool b) void StelApp::setVisionModeNight(bool b)
{ {
if (flagNightVision!=b) if (flagNightVision!=b)
{ {
flagNightVision=b; flagNightVision=b;
emit(colorSchemeChanged(b ? "night_color" : "color")); emit(visionNightModeChanged(b));
} }
} }
// Update translations and font for sky everywhere in the program // Update translations and font for sky everywhere in the program
void StelApp::updateI18n() void StelApp::updateI18n()
{ {
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
emit(languageChanged()); emit(languageChanged());
#endif #endif
} }
skipping to change at line 547 skipping to change at line 723
{ {
++nbUsedCache; ++nbUsedCache;
totalUsedCacheSize+=reply->bytesAvailable(); totalUsedCacheSize+=reply->bytesAvailable();
} }
else else
{ {
++nbDownloadedFiles; ++nbDownloadedFiles;
totalDownloadedSize+=reply->bytesAvailable(); totalDownloadedSize+=reply->bytesAvailable();
} }
} }
void StelApp::quit()
{
emit aboutToQuit();
QCoreApplication::exit(0);
}
void StelApp::setDevicePixelsPerPixel(float dppp)
{
// Check that the device-independent pixel size didn't change
if (devicePixelsPerPixel!=dppp)
{
devicePixelsPerPixel = dppp;
StelProjector::StelProjectorParams params = core->getCurrent
StelProjectorParams();
params.devicePixelsPerPixel = devicePixelsPerPixel;
core->setCurrentStelProjectorParams(params);
}
}
 End of changes. 46 change blocks. 
106 lines changed or deleted 288 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/