StelMainView.cpp   StelMainView.cpp 
skipping to change at line 50 skipping to change at line 50
#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 <QDeclarativeContext> #include <QDeclarativeContext>
#include <QPinchGesture>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <clocale> #include <clocale>
// Initialize static variables // Initialize static variables
StelMainView* StelMainView::singleton = NULL; StelMainView* StelMainView::singleton = NULL;
//! Render Stellarium sky. //! Render Stellarium sky.
class StelSkyItem : public QDeclarativeItem class StelSkyItem : public QDeclarativeItem
{ {
public: public:
StelSkyItem(QDeclarativeItem* parent = NULL); StelSkyItem(QDeclarativeItem* parent = NULL);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option , QWidget* widget = 0); void paint(QPainter* painter, const QStyleOptionGraphicsItem* option , QWidget* widget = 0);
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void wheelEvent(QGraphicsSceneWheelEvent *event); void wheelEvent(QGraphicsSceneWheelEvent *event);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
bool event(QEvent * e);
private: private:
double previousPaintTime; double previousPaintTime;
void onSizeChanged(); void onSizeChanged();
void pinchTriggered(QPinchGesture *gesture);
bool gestureEvent(QGestureEvent *event);
}; };
//! Initialize and render Stellarium gui. //! Initialize and render Stellarium gui.
class StelGuiItem : public QDeclarativeItem class StelGuiItem : public QDeclarativeItem
{ {
public: public:
StelGuiItem(QDeclarativeItem* parent = NULL); StelGuiItem(QDeclarativeItem* parent = NULL);
private: private:
QGraphicsWidget *widget; QGraphicsWidget *widget;
void onSizeChanged(); void onSizeChanged();
}; };
StelSkyItem::StelSkyItem(QDeclarativeItem* parent) StelSkyItem::StelSkyItem(QDeclarativeItem* parent)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
setObjectName("SkyItem"); setObjectName("SkyItem");
setFlag(QGraphicsItem::ItemHasNoContents, false); setFlag(QGraphicsItem::ItemHasNoContents, false);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
setAcceptTouchEvents(true);
grabGesture(Qt::PinchGesture);
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::Middl eButton); setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::Middl eButton);
connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSize Changed); connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSize Changed);
connect(this, &StelSkyItem::heightChanged, this, &StelSkyItem::onSiz eChanged); connect(this, &StelSkyItem::heightChanged, this, &StelSkyItem::onSiz eChanged);
previousPaintTime = StelApp::getTotalRunTime(); previousPaintTime = StelApp::getTotalRunTime();
StelMainView::getInstance().skyItem = this; StelMainView::getInstance().skyItem = this;
setFocus(true); setFocus(true);
} }
void StelSkyItem::onSizeChanged() void StelSkyItem::onSizeChanged()
{ {
skipping to change at line 126 skipping to change at line 134
StelApp::getInstance().draw(); StelApp::getInstance().draw();
painter->endNativePainting(); painter->endNativePainting();
} }
void StelSkyItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void StelSkyItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
//To get back the focus from dialogs //To get back the focus from dialogs
this->setFocus(true); this->setFocus(true);
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
// XXX: to reintroduce
//distortPos(&pos);
pos.setY(height() - 1 - pos.y()); pos.setY(height() - 1 - pos.y());
QMouseEvent newEvent(QEvent::MouseButtonPress, QMouseEvent newEvent(QEvent::MouseButtonPress, QPoint(pos.x(), pos.y
QPoint(pos.x ()), event->button(), event->buttons(), event->modifiers());
(), pos.y()),
event->butto
n(),
event->butto
ns(),
event->modif
iers());
StelApp::getInstance().handleClick(&newEvent); StelApp::getInstance().handleClick(&newEvent);
} }
void StelSkyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void StelSkyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
// XXX: to reintroduce
// distortPos(&pos);
pos.setY(height() - 1 - pos.y()); pos.setY(height() - 1 - pos.y());
QMouseEvent newEvent(QEvent::MouseButtonRelease, QMouseEvent newEvent(QEvent::MouseButtonRelease, QPoint(pos.x(), pos
QPoint(pos.x .y()), event->button(), event->buttons(), event->modifiers());
(), pos.y()),
event->butto
n(),
event->butto
ns(),
event->modif
iers());
StelApp::getInstance().handleClick(&newEvent); StelApp::getInstance().handleClick(&newEvent);
} }
void StelSkyItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) void StelSkyItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
// XXX: to reintroduce
// distortPos(&pos);
pos.setY(height() - 1 - pos.y()); pos.setY(height() - 1 - pos.y());
StelApp::getInstance().handleMove(pos.x(), pos.y(), event->buttons() ); StelApp::getInstance().handleMove(pos.x(), pos.y(), event->buttons() );
} }
void StelSkyItem::wheelEvent(QGraphicsSceneWheelEvent *event) void StelSkyItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
// XXX: to reintroduce
// distortPos(&pos);
pos.setY(height() - 1 - pos.y()); pos.setY(height() - 1 - pos.y());
QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event- >buttons(), event->modifiers(), event->orientation()); QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event- >buttons(), event->modifiers(), event->orientation());
StelApp::getInstance().handleWheel(&newEvent); StelApp::getInstance().handleWheel(&newEvent);
} }
bool StelSkyItem::event(QEvent * e)
{
switch (e->type()){
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->tou
chPoints();
if (touchPoints.count() == 1)
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightBu
tton | Qt::MiddleButton);
return true;
}
break;
case QEvent::Gesture:
setAcceptedMouseButtons(0);
return gestureEvent(static_cast<QGestureEvent*>(e));
break;
default:
return false;
}
}
bool StelSkyItem::gestureEvent(QGestureEvent *event)
{
if (QGesture *pinch = event->gesture(Qt::PinchGesture))
pinchTriggered(static_cast<QPinchGesture *>(pinch));
return true;
}
void StelSkyItem::pinchTriggered(QPinchGesture *gesture)
{
QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal zoom = gesture->scaleFactor();
if (zoom < 2 && zoom > 0.5){
StelApp::getInstance().handlePinch(zoom, true);
}
}
}
void StelSkyItem::keyPressEvent(QKeyEvent* event) void StelSkyItem::keyPressEvent(QKeyEvent* event)
{ {
StelApp::getInstance().handleKeys(event); StelApp::getInstance().handleKeys(event);
} }
void StelSkyItem::keyReleaseEvent(QKeyEvent* event) void StelSkyItem::keyReleaseEvent(QKeyEvent* event)
{ {
StelApp::getInstance().handleKeys(event); StelApp::getInstance().handleKeys(event);
} }
skipping to change at line 302 skipping to change at line 341
Q_ASSERT(gui); Q_ASSERT(gui);
Q_ASSERT(glWidget->isValid()); Q_ASSERT(glWidget->isValid());
glWidget->makeCurrent(); glWidget->makeCurrent();
// Debug info about supported version of OpenGL and vendor/renderer // Debug info about supported version of OpenGL and vendor/renderer
qDebug() << "OpenGL versions supported:" << getSupportedOpenGLVersio n(); qDebug() << "OpenGL versions supported:" << getSupportedOpenGLVersio n();
qDebug() << "Driver version string:" << QString(reinterpret_cast<con st char*>(glGetString(GL_VERSION))); qDebug() << "Driver version string:" << QString(reinterpret_cast<con st char*>(glGetString(GL_VERSION)));
qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>( glGetString(GL_VENDOR))); qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>( glGetString(GL_VENDOR)));
qDebug() << "GL renderer is" << QString(reinterpret_cast<const char* >(glGetString(GL_RENDERER))); qDebug() << "GL renderer is" << QString(reinterpret_cast<const char* >(glGetString(GL_RENDERER)));
qDebug() << "GL Shading Language version is" << QString(reinterpret_
cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
// Only give extended info if called on command line, for diagnostic
.
if (qApp->property("dump_OpenGL_details").toBool())
dumpOpenGLdiagnostics();
stelApp= new StelApp(); stelApp= new StelApp();
stelApp->setGui(gui); stelApp->setGui(gui);
stelApp->init(conf); stelApp->init(conf);
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("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();
skipping to change at line 403 skipping to change at line 447
if (version&QGLFormat::OpenGL_ES_Common_Version_1_0) if (version&QGLFormat::OpenGL_ES_Common_Version_1_0)
ver << "1.0 (ES C)"; ver << "1.0 (ES C)";
if (version&QGLFormat::OpenGL_ES_Common_Version_1_1) if (version&QGLFormat::OpenGL_ES_Common_Version_1_1)
ver << "1.1 (ES C)"; ver << "1.1 (ES C)";
if (version&QGLFormat::OpenGL_ES_Version_2_0) if (version&QGLFormat::OpenGL_ES_Version_2_0)
ver << "2.0 (ES)"; ver << "2.0 (ES)";
return ver.join(", "); return ver.join(", ");
} }
void StelMainView::dumpOpenGLdiagnostics() const
{
// GZ: Debug info about OpenGL capabilities.
QOpenGLContext *context = QOpenGLContext::currentContext();
if (context)
{
context->functions()->initializeOpenGLFunctions();
qDebug() << "initializeOpenGLFunctions()...";
}
else
qDebug() << "No OpenGL context";
QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->o
penGLFeatures();
qDebug() << "OpenGL Features:";
qDebug() << " - glActiveTexture() function" << (oglFeatures&QOpenGLF
unctions::Multitexture ? "is" : "is NOT") << "available.";
qDebug() << " - Shader functions" << (oglFeatures&QOpenGLFunctions::
Shaders ? "are" : "are NOT ") << "available.";
qDebug() << " - Vertex and index buffer functions" << (oglFeatures&Q
OpenGLFunctions::Buffers ? "are" : "are NOT") << "available.";
qDebug() << " - Framebuffer object functions" << (oglFeatures&QOpenG
LFunctions::Framebuffers ? "are" : "are NOT") << "available.";
qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunctions::Bl
endColor ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFunctions:
:BlendEquation ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&QOpenGLFu
nctions::BlendEquationSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendFuncSeparate()" << (oglFeatures&QOpenGLFuncti
ons::BlendFuncSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - Blend subtract mode" << (oglFeatures&QOpenGLFunction
s::BlendSubtract ? "is" : "is NOT") << "available.";
qDebug() << " - Compressed texture functions" << (oglFeatures&QOpenG
LFunctions::CompressedTextures ? "are" : "are NOT") << "available.";
qDebug() << " - glSampleCoverage() function" << (oglFeatures&QOpenGL
Functions::Multisample ? "is" : "is NOT") << "available.";
qDebug() << " - Separate stencil functions" << (oglFeatures&QOpenGLF
unctions::StencilSeparate ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFu
nctions::NPOTTextures ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFu
nctions::NPOTTextureRepeat ? "can" : "CANNOT") << "use GL_REPEAT as wrap pa
rameter.";
qDebug() << " - The fixed function pipeline" << (oglFeatures&QOpenGL
Functions::FixedFunctionPipeline ? "is" : "is NOT") << "available.";
qDebug() << "OpenGL shader capabilities and details:";
qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGLShaders(
QOpenGLShader::Vertex, context) ? "YES" : "NO");
qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpenGLShader
s(QOpenGLShader::Fragment, context) ? "YES" : "NO");
qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpenGLShader
s(QOpenGLShader::Geometry, context) ? "YES" : "NO");
qDebug() << " - TessellationControl Shader:" << (QOpenGLShader::hasO
penGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" : "NO");
qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLShader::h
asOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "YES" : "
NO");
qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenGLShaders
(QOpenGLShader::Compute, context) ? "YES" : "NO");
// GZ: List available extensions. Not sure if this is in any way use
ful?
QSet<QByteArray> extensionSet=context->extensions();
qDebug() << "We have" << extensionSet.count() << "OpenGL extensions:
";
QMap<QString, QString> extensionMap;
QSetIterator<QByteArray> iter(extensionSet);
while (iter.hasNext())
{
if (!iter.peekNext().isEmpty()) // Don't insert empty lines
extensionMap.insert(QString(iter.peekNext()), QStrin
g(iter.peekNext()));
iter.next();
}
QMapIterator<QString, QString> iter2(extensionMap);
while (iter2.hasNext())
qDebug() << " -" << iter2.next().key();
QFunctionPointer programParameterPtr =context->getProcAddress("glPro
gramParameteri");
if (programParameterPtr == 0)
qDebug() << "glProgramParameteri cannot be resolved here. BA
D!";
//else
// qDebug() << "glProgramParameteri can be resolved. GOOD!";
programParameterPtr =context->getProcAddress("glProgramParameteriEXT
");
if (programParameterPtr == 0)
qDebug() << "glProgramParameteriEXT cannot be resolved here.
BAD!";
//else
// qDebug() << "glProgramParameteriEXT can be resolved here. GO
OD!";
}
void StelMainView::deinit() void StelMainView::deinit()
{ {
deinitGL(); deinitGL();
delete stelApp; delete stelApp;
stelApp = NULL; stelApp = NULL;
} }
// Update the translated title // Update the translated title
void StelMainView::initTitleI18n() void StelMainView::initTitleI18n()
{ {
 End of changes. 13 change blocks. 
26 lines changed or deleted 166 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/