Commit 9040d69b authored by Tobias WEBER's avatar Tobias WEBER

qt compatibility

parent f3d3abe8
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <QtGui/QSurfaceFormat> #include <QtGui/QSurfaceFormat>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <QtCore/QtGlobal>
#include <iostream> #include <iostream>
#include <boost/scope_exit.hpp> #include <boost/scope_exit.hpp>
...@@ -670,7 +671,9 @@ void main() ...@@ -670,7 +671,9 @@ void main()
// set glsl version and constants // set glsl version and constants
const std::string strGlsl = std::to_string(_GLSL_MAJ_VER*100 + _GLSL_MIN_VER*10); const std::string strGlsl = std::to_string(_GLSL_MAJ_VER*100 + _GLSL_MIN_VER*10);
const std::string strPi = std::to_string(m::pi<t_real_gl>); std::string strPi = std::to_string(m::pi<t_real_gl>); // locale-dependent !
algo::replace_all(strPi, std::string(","), std::string(".")); // ensure decimal point
for(std::string* strSrc : { &strFragShader, &strVertexShader }) for(std::string* strSrc : { &strFragShader, &strVertexShader })
{ {
algo::replace_all(*strSrc, std::string("${GLSL_VERSION}"), strGlsl); algo::replace_all(*strSrc, std::string("${GLSL_VERSION}"), strGlsl);
...@@ -882,9 +885,15 @@ void GlPlot_impl::UpdateCam() ...@@ -882,9 +885,15 @@ void GlPlot_impl::UpdateCam()
*/ */
void GlPlot_impl::RequestPlotUpdate() void GlPlot_impl::RequestPlotUpdate()
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QMetaObject::invokeMethod((QOpenGLWidget*)m_pPlot, QMetaObject::invokeMethod((QOpenGLWidget*)m_pPlot,
static_cast<void (QOpenGLWidget::*)()>(&QOpenGLWidget::update), static_cast<void (QOpenGLWidget::*)()>(&QOpenGLWidget::update),
Qt::ConnectionType::QueuedConnection); Qt::ConnectionType::QueuedConnection);
#else
QMetaObject::invokeMethod((QOpenGLWidget*)m_pPlot,
"update",
Qt::ConnectionType::QueuedConnection);
#endif
} }
...@@ -1325,7 +1334,11 @@ void GlPlot_impl::paintGL() ...@@ -1325,7 +1334,11 @@ void GlPlot_impl::paintGL()
if(auto *pContext = m_pPlot->context(); !pContext) return; if(auto *pContext = m_pPlot->context(); !pContext) return;
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QMetaObject::invokeMethod(m_pPlot, &GlPlot::MoveContextToThread, Qt::ConnectionType::BlockingQueuedConnection); QMetaObject::invokeMethod(m_pPlot, &GlPlot::MoveContextToThread, Qt::ConnectionType::BlockingQueuedConnection);
#else
QMetaObject::invokeMethod(m_pPlot, "MoveContextToThread", Qt::ConnectionType::BlockingQueuedConnection);
#endif
if(!m_pPlot->IsContextInThread()) if(!m_pPlot->IsContextInThread())
{ {
std::cerr << __func__ << ": Context is not in thread!" << std::endl; std::cerr << __func__ << ": Context is not in thread!" << std::endl;
...@@ -1560,7 +1573,11 @@ void GlPlot::afterComposing() ...@@ -1560,7 +1573,11 @@ void GlPlot::afterComposing()
if constexpr(m_isthreaded) if constexpr(m_isthreaded)
{ {
m_mutex.unlock(); m_mutex.unlock();
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QMetaObject::invokeMethod(m_impl.get(), &GlPlot_impl::paintGL, Qt::ConnectionType::QueuedConnection); QMetaObject::invokeMethod(m_impl.get(), &GlPlot_impl::paintGL, Qt::ConnectionType::QueuedConnection);
#else
QMetaObject::invokeMethod(m_impl.get(), "paintGL", Qt::ConnectionType::QueuedConnection);
#endif
} }
} }
......
...@@ -299,7 +299,7 @@ public: ...@@ -299,7 +299,7 @@ public:
bool IsInitialised() const { return m_bInitialised; } bool IsInitialised() const { return m_bInitialised; }
public /*slots*/: public slots:
void paintGL(); void paintGL();
void startedThread(); void startedThread();
...@@ -350,12 +350,6 @@ protected: ...@@ -350,12 +350,6 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent *Evt) override; virtual void mouseReleaseEvent(QMouseEvent *Evt) override;
virtual void wheelEvent(QWheelEvent *pEvt) override; virtual void wheelEvent(QWheelEvent *pEvt) override;
protected slots:
void beforeComposing();
void afterComposing();
void beforeResizing();
void afterResizing();
private: private:
mutable QMutex m_mutex{QMutex::Recursive}; mutable QMutex m_mutex{QMutex::Recursive};
std::unique_ptr<GlPlot_impl> m_impl; std::unique_ptr<GlPlot_impl> m_impl;
...@@ -369,6 +363,12 @@ public: ...@@ -369,6 +363,12 @@ public:
void MoveContextToThread(); void MoveContextToThread();
bool IsContextInThread() const; bool IsContextInThread() const;
protected slots:
void beforeComposing();
void afterComposing();
void beforeResizing();
void afterResizing();
signals: signals:
void AfterGLInitialisation(); void AfterGLInitialisation();
void GLInitialisationFailed(); void GLInitialisationFailed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment