StelMainView.cpp   StelMainView.cpp 
skipping to change at line 32 skipping to change at line 32
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelOpenGL.hpp" #include "StelOpenGL.hpp"
#include "StelOpenGLArray.hpp"
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#ifdef USE_OLD_QGLWIDGET #ifdef USE_OLD_QGLWIDGET
#include <QGLWidget> #include <QGLWidget>
#else #else
#include <QOpenGLWidget> #include <QOpenGLWidget>
#endif #endif
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
skipping to change at line 59 skipping to change at line 60
#include <QMoveEvent> #include <QMoveEvent>
#include <QPluginLoader> #include <QPluginLoader>
#include <QScreen> #include <QScreen>
#include <QSettings> #include <QSettings>
#include <QtPlugin> #include <QtPlugin>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
#include <QWidget> #include <QWidget>
#include <QWindow> #include <QWindow>
#include <QMessageBox> #include <QMessageBox>
#include <QStandardPaths>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QPinchGesture> #include <QPinchGesture>
#endif #endif
#include <QOpenGLShader> #include <QOpenGLShader>
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <QOpenGLPaintDevice> #include <QOpenGLPaintDevice>
#ifdef OPENGL_DEBUG_LOGGING #ifdef OPENGL_DEBUG_LOGGING
#include <QOpenGLDebugLogger> #include <QOpenGLDebugLogger>
#endif #endif
#include <clocale> #include <clocale>
// Initialize static variables // Initialize static variables
StelMainView* StelMainView::singleton = NULL; StelMainView* StelMainView::singleton = Q_NULLPTR;
#ifdef USE_OLD_QGLWIDGET #ifdef USE_OLD_QGLWIDGET
class StelGLWidget : public QGLWidget class StelGLWidget : public QGLWidget
#else #else
class StelGLWidget : public QOpenGLWidget class StelGLWidget : public QOpenGLWidget
#endif #endif
{ {
public: public:
StelGLWidget(const QSurfaceFormat& fmt, StelMainView* parent) StelGLWidget(const QSurfaceFormat& fmt, StelMainView* parent)
: :
skipping to change at line 169 skipping to change at line 171
private: private:
StelMainView* parent; StelMainView* parent;
bool initialized; bool initialized;
}; };
// A custom QGraphicsEffect to apply the night mode on top of the screen. // A custom QGraphicsEffect to apply the night mode on top of the screen.
class NightModeGraphicsEffect : public QGraphicsEffect class NightModeGraphicsEffect : public QGraphicsEffect
{ {
public: public:
NightModeGraphicsEffect(StelMainView* parent = NULL) NightModeGraphicsEffect(StelMainView* parent = Q_NULLPTR)
: QGraphicsEffect(parent), : QGraphicsEffect(parent),
parent(parent), fbo(NULL) parent(parent), fbo(Q_NULLPTR)
{ {
Q_ASSERT(parent->glContext() == QOpenGLContext::currentConte xt()); Q_ASSERT(parent->glContext() == QOpenGLContext::currentConte xt());
program = new QOpenGLShaderProgram(this); program = new QOpenGLShaderProgram(this);
QString vertexCode = QString vertexCode =
"attribute highp vec4 a_pos;\n" "attribute highp vec4 a_pos;\n"
"attribute highp vec2 a_texCoord;\n" "attribute highp vec2 a_texCoord;\n"
"varying highp vec2 v_texCoord;\n" "varying highp vec2 v_texCoord;\n"
"void main(void)\n" "void main(void)\n"
"{\n" "{\n"
skipping to change at line 224 skipping to change at line 226
QPaintDevice* paintDevice = painter->device(); QPaintDevice* paintDevice = painter->device();
int mainFBO; int mainFBO;
gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mainFBO); gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mainFBO);
int pixelRatio = paintDevice->devicePixelRatio(); int pixelRatio = paintDevice->devicePixelRatio();
QSize size(paintDevice->width() * pixelRatio, paintDevice->h eight() * pixelRatio); QSize size(paintDevice->width() * pixelRatio, paintDevice->h eight() * pixelRatio);
if (fbo && fbo->size() != size) if (fbo && fbo->size() != size)
{ {
delete fbo; delete fbo;
fbo = NULL; fbo = Q_NULLPTR;
} }
if (!fbo) if (!fbo)
{ {
QOpenGLFramebufferObjectFormat format; QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::Combi nedDepthStencil); format.setAttachment(QOpenGLFramebufferObject::Combi nedDepthStencil);
format.setInternalTextureFormat(GL_RGBA); format.setInternalTextureFormat(GL_RGBA);
fbo = new QOpenGLFramebufferObject(size, format); fbo = new QOpenGLFramebufferObject(size, format);
} }
// we have to use our own paint device // we have to use our own paint device
skipping to change at line 309 skipping to change at line 311
QGraphicsScene::keyPressEvent(event); QGraphicsScene::keyPressEvent(event);
} }
private: private:
StelMainView* parent; StelMainView* parent;
}; };
class StelRootItem : public QGraphicsObject class StelRootItem : public QGraphicsObject
{ {
public: public:
StelRootItem(StelMainView* mainView, QGraphicsItem* parent = NULL) StelRootItem(StelMainView* mainView, QGraphicsItem* parent = Q_NULLP TR)
: QGraphicsObject(parent), mainView(mainView) : QGraphicsObject(parent), mainView(mainView)
{ {
setFlag(QGraphicsItem::ItemClipsToShape); setFlag(QGraphicsItem::ItemClipsToShape);
setFlag(QGraphicsItem::ItemClipsChildrenToShape); setFlag(QGraphicsItem::ItemClipsChildrenToShape);
setFlag(QGraphicsItem::ItemIsFocusable); setFlag(QGraphicsItem::ItemIsFocusable);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
setAcceptTouchEvents(true); setAcceptTouchEvents(true);
skipping to change at line 523 skipping to change at line 525
QRectF rect; QRectF rect;
double previousPaintTime; double previousPaintTime;
StelMainView* mainView; StelMainView* mainView;
}; };
//! Initialize and render Stellarium gui. //! Initialize and render Stellarium gui.
class StelGuiItem : public QGraphicsWidget class StelGuiItem : public QGraphicsWidget
{ {
public: public:
StelGuiItem(QGraphicsItem* parent = NULL) StelGuiItem(QGraphicsItem* parent = Q_NULLPTR)
: QGraphicsWidget(parent) : QGraphicsWidget(parent)
{ {
StelApp::getInstance().getGui()->init(this); StelApp::getInstance().getGui()->init(this);
} }
protected: protected:
void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE
{ {
Q_UNUSED(event); Q_UNUSED(event);
//widget->setGeometry(0, 0, size().width(), size().height()) ; //widget->setGeometry(0, 0, size().width(), size().height()) ;
StelApp::getInstance().getGui()->forceRefreshGui(); StelApp::getInstance().getGui()->forceRefreshGui();
} }
private: private:
//QGraphicsWidget *widget; //QGraphicsWidget *widget;
// void onSizeChanged(); // void onSizeChanged();
}; };
StelMainView::StelMainView(QSettings* settings) StelMainView::StelMainView(QSettings* settings)
: QGraphicsView(), : QGraphicsView(),
guiItem(NULL), guiItem(Q_NULLPTR),
gui(NULL), gui(Q_NULLPTR),
stelApp(NULL), stelApp(Q_NULLPTR),
updateQueued(false), updateQueued(false),
flagInvertScreenShotColors(false), flagInvertScreenShotColors(false),
flagOverwriteScreenshots(false), flagOverwriteScreenshots(false),
screenShotPrefix("stellarium-"), screenShotPrefix("stellarium-"),
screenShotDir(""), screenShotDir(""),
cursorTimeout(-1.f), flagCursorTimeout(false), maxfps(10000.f) cursorTimeout(-1.f), flagCursorTimeout(false), maxfps(10000.f)
{ {
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
setAutoFillBackground(false); setAutoFillBackground(false);
skipping to change at line 751 skipping to change at line 753
// Should be check of requirements disabled? // Should be check of requirements disabled?
if (conf->value("main/check_requirements", true).toBool()) if (conf->value("main/check_requirements", true).toBool())
{ {
// Find out lots of debug info about supported version of Op enGL and vendor/renderer. // Find out lots of debug info about supported version of Op enGL and vendor/renderer.
processOpenGLdiagnosticsAndWarnings(conf, QOpenGLContext::cu rrentContext()); processOpenGLdiagnosticsAndWarnings(conf, QOpenGLContext::cu rrentContext());
} }
//create and initialize main app //create and initialize main app
stelApp = new StelApp(this); stelApp = new StelApp(this);
stelApp->setGui(gui); stelApp->setGui(gui);
stelApp->init(conf); stelApp->init(conf);
//setup StelOpenGLArray global state
StelOpenGLArray::initGL();
//this makes sure the app knows how large the window is //this makes sure the app knows how large the window is
connect(stelScene,SIGNAL(sceneRectChanged(QRectF)),stelApp,SLOT(glWi ndowHasBeenResized(QRectF))); connect(stelScene,SIGNAL(sceneRectChanged(QRectF)),stelApp,SLOT(glWi ndowHasBeenResized(QRectF)));
//also immediately set the current values //also immediately set the current values
stelApp->glWindowHasBeenResized(stelScene->sceneRect()); stelApp->glWindowHasBeenResized(stelScene->sceneRect());
StelActionMgr *actionMgr = stelApp->getStelActionManager(); StelActionMgr *actionMgr = stelApp->getStelActionManager();
actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneo us"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S"); actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneo us"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");
actionMgr->addAction("actionReload_Shaders", N_("Miscellaneous"), N_ ("Reload shaders (for development)"), this, "reloadShaders()", "Ctrl+R, P") ;
actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Opt ions"), N_("Full-screen mode"), this, "fullScreen", "F11"); actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Opt ions"), N_("Full-screen mode"), this, "fullScreen", "F11");
StelPainter::initGLShaders(); StelPainter::initGLShaders();
guiItem = new StelGuiItem(rootItem); guiItem = new StelGuiItem(rootItem);
scene()->addItem(rootItem); scene()->addItem(rootItem);
//set the default focus to the sky //set the default focus to the sky
focusSky(); focusSky();
nightModeEffect = new NightModeGraphicsEffect(this); nightModeEffect = new NightModeGraphicsEffect(this);
updateNightModeProperty(StelApp::getInstance().getVisionModeNight()) ; updateNightModeProperty(StelApp::getInstance().getVisionModeNight()) ;
skipping to change at line 813 skipping to change at line 817
int x = conf->value("video/screen_x", 0).toInt(); int x = conf->value("video/screen_x", 0).toInt();
int y = conf->value("video/screen_y", 0).toInt(); int y = conf->value("video/screen_y", 0).toInt();
move(x + screenGeom.x(), y + screenGeom.y()); move(x + screenGeom.x(), y + screenGeom.y());
} }
flagInvertScreenShotColors = conf->value("main/invert_screenshots_co lors", false).toBool(); flagInvertScreenShotColors = conf->value("main/invert_screenshots_co lors", false).toBool();
setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool()); setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool());
setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at()); setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at());
setMaxFps(conf->value("video/maximum_fps",10000.f).toFloat()); setMaxFps(conf->value("video/maximum_fps",10000.f).toFloat());
setMinFps(conf->value("video/minimum_fps",10000.f).toFloat()); setMinFps(conf->value("video/minimum_fps",10000.f).toFloat());
setFlagUseButtonsBackground(conf->value("gui/flag_show_buttons_backg round", true).toBool());
// XXX: This should be done in StelApp::init(), unfortunately for th e moment we need to init the gui before the // XXX: This should be done in StelApp::init(), unfortunately for th e moment we need to init the gui before the
// plugins, because the gui creates the QActions needed by some plug ins. // plugins, because the gui creates the QActions needed by some plug ins.
stelApp->initPlugIns(); stelApp->initPlugIns();
// The script manager can only be fully initialized after the plugin s have loaded. // The script manager can only be fully initialized after the plugin s have loaded.
stelApp->initScriptMgr(); stelApp->initScriptMgr();
// Set the global stylesheet, this is only useful for the tooltips. // Set the global stylesheet, this is only useful for the tooltips.
StelGui* gui = dynamic_cast<StelGui*>(stelApp->getGui()); StelGui* gui = dynamic_cast<StelGui*>(stelApp->getGui());
if (gui!=NULL) if (gui!=Q_NULLPTR)
setStyleSheet(gui->getStelStyle().qtStyleSheet); setStyleSheet(gui->getStelStyle().qtStyleSheet);
connect(stelApp, SIGNAL(visionNightModeChanged(bool)), this, SLOT(up dateNightModeProperty(bool))); connect(stelApp, SIGNAL(visionNightModeChanged(bool)), this, SLOT(up dateNightModeProperty(bool)));
// I doubt this will have any effect on framerate, but may cause pro blems elsewhere? // I doubt this will have any effect on framerate, but may cause pro blems elsewhere?
QThread::currentThread()->setPriority(QThread::HighestPriority); QThread::currentThread()->setPriority(QThread::HighestPriority);
#ifndef NDEBUG #ifndef NDEBUG
// Get an overview of module callOrders // Get an overview of module callOrders
if (qApp->property("verbose")==true) if (qApp->property("verbose")==true)
{ {
StelApp::getInstance().dumpModuleActionPriorities(StelModule ::ActionDraw); StelApp::getInstance().dumpModuleActionPriorities(StelModule ::ActionDraw);
skipping to change at line 849 skipping to change at line 854
#endif #endif
} }
void StelMainView::updateNightModeProperty(bool b) void StelMainView::updateNightModeProperty(bool b)
{ {
// So that the bottom bar tooltips get properly rendered in night mo de. // So that the bottom bar tooltips get properly rendered in night mo de.
setProperty("nightMode", b); setProperty("nightMode", b);
nightModeEffect->setEnabled(b); nightModeEffect->setEnabled(b);
} }
void StelMainView::reloadShaders()
{
//make sure GL context is bound
glContextMakeCurrent();
emit reloadShadersRequested();
}
// This is a series of various diagnostics based on "bugs" reported for 0.1 3.0 and 0.13.1. // This is a series of various diagnostics based on "bugs" reported for 0.1 3.0 and 0.13.1.
// Almost all can be traced to insufficient driver level. // Almost all can be traced to insufficient driver level.
// No changes of OpenGL state is done here. // No changes of OpenGL state is done here.
// If problems are detected, warn the user one time, but continue. Warning panel will be suppressed on next start. // If problems are detected, warn the user one time, but continue. Warning panel will be suppressed on next start.
// Work in progress, as long as we get reports about bad systems or until O penGL startup is finalized and safe. // Work in progress, as long as we get reports about bad systems or until O penGL startup is finalized and safe.
// Several tests do not apply to MacOS X. // Several tests do not apply to MacOS X.
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOp enGLContext *context) const void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOp enGLContext *context) const
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
Q_UNUSED(conf); Q_UNUSED(conf);
skipping to change at line 1205 skipping to change at line 1217
qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context"; qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context";
} }
} }
void StelMainView::deinit() void StelMainView::deinit()
{ {
glContextMakeCurrent(); glContextMakeCurrent();
deinitGL(); deinitGL();
delete stelApp; delete stelApp;
stelApp = NULL; stelApp = Q_NULLPTR;
} }
// Update the translated title // Update the translated title
void StelMainView::initTitleI18n() void StelMainView::initTitleI18n()
{ {
QString appNameI18n = q_("Stellarium %1").arg(StelUtils::getApplicat ionVersion()); QString appNameI18n = q_("Stellarium %1").arg(StelUtils::getApplicat ionVersion());
setWindowTitle(appNameI18n); setWindowTitle(appNameI18n);
} }
void StelMainView::setFullScreen(bool b) void StelMainView::setFullScreen(bool b)
skipping to change at line 1331 skipping to change at line 1343
//! Delete openGL textures (to call before the GLContext disappears) //! Delete openGL textures (to call before the GLContext disappears)
void StelMainView::deinitGL() void StelMainView::deinitGL()
{ {
//fix for bug 1628072 caused by QTBUG-56798 //fix for bug 1628072 caused by QTBUG-56798
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
StelOpenGL::clearGLErrors(); StelOpenGL::clearGLErrors();
#endif #endif
stelApp->deinit(); stelApp->deinit();
delete gui; delete gui;
gui = NULL; gui = Q_NULLPTR;
} }
void StelMainView::saveScreenShot(const QString& filePrefix, const QString& saveDir, const bool overwrite) void StelMainView::saveScreenShot(const QString& filePrefix, const QString& saveDir, const bool overwrite)
{ {
screenShotPrefix = filePrefix; screenShotPrefix = filePrefix;
screenShotDir = saveDir; screenShotDir = saveDir;
flagOverwriteScreenshots=overwrite; flagOverwriteScreenshots=overwrite;
emit(screenshotRequested()); emit(screenshotRequested());
} }
skipping to change at line 1366 skipping to change at line 1378
stelScene->render(&painter); stelScene->render(&painter);
painter.end(); painter.end();
QImage im = fbObj->toImage(); QImage im = fbObj->toImage();
fbObj->release(); fbObj->release();
delete fbObj; delete fbObj;
#endif #endif
if (flagInvertScreenShotColors) if (flagInvertScreenShotColors)
im.invertPixels(); im.invertPixels();
if (StelFileMgr::getScreenshotDir().isEmpty())
{
qWarning() << "Oops, the directory for screenshots is not se
t! Let's try create and set it...";
// Create a directory for screenshots if main/screenshot_dir
option is unset and user do screenshot at the moment!
QString screenshotDirSuffix = "/Stellarium";
QString screenshotDir;
if (!QStandardPaths::standardLocations(QStandardPaths::Pictu
resLocation).isEmpty())
screenshotDir = QStandardPaths::standardLocations(QS
tandardPaths::PicturesLocation)[0].append(screenshotDirSuffix);
else
screenshotDir = StelFileMgr::getUserDir().append(scr
eenshotDirSuffix);
try
{
StelFileMgr::setScreenshotDir(screenshotDir);
StelApp::getInstance().getSettings()->setValue("main
/screenshot_dir", screenshotDir);
}
catch (std::runtime_error &e)
{
qDebug("Error: cannot create screenshot directory: %
s", e.what());
}
}
if (screenShotDir == "") if (screenShotDir == "")
shotDir = QFileInfo(StelFileMgr::getScreenshotDir()); shotDir = QFileInfo(StelFileMgr::getScreenshotDir());
else else
shotDir = QFileInfo(screenShotDir); shotDir = QFileInfo(screenShotDir);
if (!shotDir.isDir()) if (!shotDir.isDir())
{ {
qWarning() << "ERROR requested screenshot directory is not a directory: " << QDir::toNativeSeparators(shotDir.filePath()); qWarning() << "ERROR requested screenshot directory is not a directory: " << QDir::toNativeSeparators(shotDir.filePath());
return; return;
} }
 End of changes. 18 change blocks. 
13 lines changed or deleted 54 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/