StelApp.cpp   StelApp.cpp 
skipping to change at line 49 skipping to change at line 49
#include "StelProgressController.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 "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelSkyLayerMgr.hpp" #include "StelSkyLayerMgr.hpp"
#include "StelAudioMgr.hpp" #include "StelAudioMgr.hpp"
#include "StelVideoMgr.hpp" #include "StelVideoMgr.hpp"
#include "StelViewportEffect.hpp"
#include "StelGuiBase.hpp" #include "StelGuiBase.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#ifndef DISABLE_SCRIPTING #ifndef DISABLE_SCRIPTING
#include "StelScriptMgr.hpp" #include "StelScriptMgr.hpp"
#include "StelMainScriptAPIProxy.hpp" #include "StelMainScriptAPIProxy.hpp"
#endif #endif
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QMouseEvent> #include <QMouseEvent>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkDiskCache> #include <QNetworkDiskCache>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QNetworkReply> #include <QNetworkReply>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QOpenGLFramebufferObject>
#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 <QCoreApplication>
#include <QScreen> #include <QScreen>
Q_IMPORT_PLUGIN(StelStandardGuiPluginInterface) Q_IMPORT_PLUGIN(StelStandardGuiPluginInterface)
skipping to change at line 216 skipping to change at line 218
, globalScalingRatio(1.f) , globalScalingRatio(1.f)
, fps(0) , fps(0)
, frame(0) , frame(0)
, timefr(0.) , timefr(0.)
, timeBase(0.) , timeBase(0.)
, flagNightVision(false) , flagNightVision(false)
, confSettings(NULL) , confSettings(NULL)
, initialized(false) , initialized(false)
, saveProjW(-1) , saveProjW(-1)
, saveProjH(-1) , saveProjH(-1)
, baseFontSize(13)
, renderBuffer(NULL)
, viewportEffect(NULL)
{ {
// 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;
skipping to change at line 370 skipping to change at line 375
#else #else
void StelApp::initScriptMgr(QSettings *conf) {Q_UNUSED(conf);} void StelApp::initScriptMgr(QSettings *conf) {Q_UNUSED(conf);}
#endif #endif
void StelApp::init(QSettings* conf) void StelApp::init(QSettings* conf)
{ {
confSettings = conf; confSettings = conf;
devicePixelsPerPixel = QOpenGLContext::currentContext()->screen()->d evicePixelRatio(); devicePixelsPerPixel = QOpenGLContext::currentContext()->screen()->d evicePixelRatio();
setBaseFontSize(confSettings->value("gui/base_font_size", 13).toInt(
));
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);
// Initialize AFTER creation of openGL context // Initialize AFTER creation of openGL context
textureMgr = new StelTextureMgr(); textureMgr = new StelTextureMgr();
textureMgr->init(); textureMgr->init();
networkAccessManager = new QNetworkAccessManager(this); networkAccessManager = new QNetworkAccessManager(this);
// Activate http cache if Qt version >= 4.5 // Activate http cache if Qt version >= 4.5
skipping to change at line 465 skipping to change at line 472
getModuleMgr().registerModule(skyLabels); getModuleMgr().registerModule(skyLabels);
skyCultureMgr->init(); skyCultureMgr->init();
initScriptMgr(conf); initScriptMgr(conf);
// Initialisation of the color scheme // Initialisation of the color scheme
emit colorSchemeChanged("color"); emit colorSchemeChanged("color");
setVisionModeNight(confSettings->value("viewing/flag_night").toBool( )); setVisionModeNight(confSettings->value("viewing/flag_night").toBool( ));
// Enable viewport effect at startup if he set
setViewportEffect(confSettings->value("video/viewport_effect", "none
").toString());
// Proxy Initialisation // Proxy Initialisation
setupHttpProxy(); setupHttpProxy();
updateI18n(); updateI18n();
// Init actions. // Init actions.
actionMgr->addAction("actionShow_Night_Mode", N_("Display Options"), N_("Night mode"), this, "nightMode"); actionMgr->addAction("actionShow_Night_Mode", N_("Display Options"), N_("Night mode"), this, "nightMode");
initialized = true; initialized = true;
} }
skipping to change at line 549 skipping to change at line 559
// 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);
} }
void StelApp::prepareRenderBuffer()
{
if (!viewportEffect) return;
if (!renderBuffer)
{
StelProjector::StelProjectorParams params = core->getCurrent
StelProjectorParams();
int w = params.viewportXywh[2];
int h = params.viewportXywh[3];
viewportEffect = new StelViewportDistorterFisheyeToSphericMi
rror(w, h);
renderBuffer = new QOpenGLFramebufferObject(w, h, QOpenGLFra
mebufferObject::CombinedDepthStencil);
}
renderBuffer->bind();
}
void StelApp::applyRenderBuffer()
{
if (!renderBuffer) return;
renderBuffer->release();
viewportEffect->paintViewportBuffer(renderBuffer);
}
//! Main drawing function called at each frame //! Main drawing function called at each frame
void StelApp::draw() void StelApp::draw()
{ {
if (!initialized) if (!initialized)
return; return;
prepareRenderBuffer();
core->preDraw(); core->preDraw();
const QList<StelModule*> modules = moduleMgr->getCallOrders(StelModu le::ActionDraw); const QList<StelModule*> modules = moduleMgr->getCallOrders(StelModu le::ActionDraw);
foreach(StelModule* module, modules) foreach(StelModule* module, modules)
{ {
module->draw(core); module->draw(core);
} }
core->postDraw(); core->postDraw();
applyRenderBuffer();
} }
/************************************************************************* /*************************************************************************
Call this when the size of the GL window has changed Call this when the size of the GL window has changed
*************************************************************************/ *************************************************************************/
void StelApp::glWindowHasBeenResized(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;
} }
if (renderBuffer)
{
delete renderBuffer;
renderBuffer = NULL;
}
} }
// Handle mouse clics // Handle mouse clics
void StelApp::handleClick(QMouseEvent* inputEvent) void StelApp::handleClick(QMouseEvent* inputEvent)
{ {
inputEvent->setAccepted(false); QPointF pos = inputEvent->pos();
float x, y;
x = pos.x();
y = pos.y();
if (viewportEffect)
viewportEffect->distortXY(x, y);
QMouseEvent event(inputEvent->type(), QPoint(inputEvent->pos().x()*d evicePixelsPerPixel, inputEvent->pos().y()*devicePixelsPerPixel), inputEven t->button(), inputEvent->buttons(), inputEvent->modifiers()); QMouseEvent event(inputEvent->type(), QPoint(x*devicePixelsPerPixel, y*devicePixelsPerPixel), inputEvent->button(), inputEvent->buttons(), inpu tEvent->modifiers());
event.setAccepted(false); 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); inputEvent->setAccepted(true);
return; return;
skipping to change at line 635 skipping to change at line 678
foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseClicks)) { foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionH andleMouseClicks)) {
i->handleMouseWheel(&deltaEvent); i->handleMouseWheel(&deltaEvent);
if (deltaEvent.isAccepted()) { if (deltaEvent.isAccepted()) {
event->accept(); event->accept();
break; break;
} }
} }
} }
// Handle mouse move // Handle mouse move
void StelApp::handleMove(int x, int y, Qt::MouseButtons b) void StelApp::handleMove(float x, float y, Qt::MouseButtons b)
{ {
if (viewportEffect)
viewportEffect->distortXY(x, y);
// 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*devicePixelsPerPixel, y*devicePixe lsPerPixel, 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)
skipping to change at line 741 skipping to change at line 786
{ {
// Check that the device-independent pixel size didn't change // Check that the device-independent pixel size didn't change
if (devicePixelsPerPixel!=dppp) if (devicePixelsPerPixel!=dppp)
{ {
devicePixelsPerPixel = dppp; devicePixelsPerPixel = dppp;
StelProjector::StelProjectorParams params = core->getCurrent StelProjectorParams(); StelProjector::StelProjectorParams params = core->getCurrent StelProjectorParams();
params.devicePixelsPerPixel = devicePixelsPerPixel; params.devicePixelsPerPixel = devicePixelsPerPixel;
core->setCurrentStelProjectorParams(params); core->setCurrentStelProjectorParams(params);
} }
} }
void StelApp::setViewportEffect(const QString& name)
{
if (name == getViewportEffect()) return;
if (renderBuffer)
{
delete renderBuffer;
renderBuffer = NULL;
}
if (viewportEffect)
{
delete viewportEffect;
viewportEffect = NULL;
}
if (name == "none") return;
StelProjector::StelProjectorParams params = core->getCurrentStelProj
ectorParams();
int w = params.viewportXywh[2];
int h = params.viewportXywh[3];
if (name == "sphericMirrorDistorter")
{
viewportEffect = new StelViewportDistorterFisheyeToSphericMi
rror(w, h);
}
else
{
qDebug() << "unknown viewport effect name:" << name;
Q_ASSERT(false);
}
}
QString StelApp::getViewportEffect() const
{
if (viewportEffect)
return viewportEffect->getName();
return "none";
}
 End of changes. 14 change blocks. 
3 lines changed or deleted 53 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/