From a1dd462de9225b9eeaf57b2e0f9d25970be37365 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 8 Mar 2017 18:28:26 +0100 Subject: [PATCH] move QuarterWidget to QOpenGLWidget --- src/Gui/Application.cpp | 19 ++++++------- src/Gui/Document.cpp | 8 +----- src/Gui/Flag.cpp | 17 ++++++++++-- src/Gui/Flag.h | 4 +-- src/Gui/GLPainter.cpp | 3 +- src/Gui/GLPainter.h | 4 +-- src/Gui/ManualAlignment.cpp | 15 +++------- src/Gui/MouseSelection.cpp | 6 ++-- src/Gui/Qt4All.h | 6 ---- src/Gui/Quarter/QuarterWidget.cpp | 35 ++++++++++++++++++++---- src/Gui/Quarter/QuarterWidget.h | 10 +++---- src/Gui/Quarter/QuarterWidgetP.cpp | 20 +++++++------- src/Gui/Quarter/QuarterWidgetP.h | 8 +++--- src/Gui/Quarter/SoQTQuarterAdaptor.cpp | 6 ++-- src/Gui/Quarter/SoQTQuarterAdaptor.h | 6 ++-- src/Gui/SoFCInteractiveElement.cpp | 4 +-- src/Gui/SoFCInteractiveElement.h | 10 +++---- src/Gui/SoFCOffscreenRenderer.cpp | 38 ++++++++++++++++++-------- src/Gui/SoFCOffscreenRenderer.h | 25 +++++++++-------- src/Gui/SoFCSelection.cpp | 1 - src/Gui/SoFCUnifiedSelection.cpp | 5 ++-- src/Gui/SoTextLabel.cpp | 10 +++++-- src/Gui/SplitView3DInventor.cpp | 8 +++++- src/Gui/Thumbnail.cpp | 9 ++++-- src/Gui/View3DInventor.cpp | 26 +++++++++++------- src/Gui/View3DInventor.h | 4 +-- src/Gui/View3DInventorViewer.cpp | 26 ++++++++++-------- src/Gui/View3DInventorViewer.h | 9 +++--- src/Gui/View3DPy.cpp | 19 +++++++------ 29 files changed, 207 insertions(+), 154 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 90877c7010..b8d286f7a7 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -38,11 +38,6 @@ # include #endif # include -# include -# include -#if QT_VERSION >= 0x040200 -# include -#endif # include # include # include @@ -50,6 +45,7 @@ #endif #include +#include // FreeCAD Base header @@ -1553,26 +1549,26 @@ void Application::runApplication(void) ActionStyleEvent::EventType = QEvent::registerEventType(QEvent::User + 1); // check for OpenGL +#if !defined(HAVE_QT5_OPENGL) if (!QGLFormat::hasOpenGL()) { QMessageBox::critical(0, QObject::tr("No OpenGL"), QObject::tr("This system does not support OpenGL")); throw Base::Exception("This system does not support OpenGL"); } -#if QT_VERSION >= 0x040200 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) { Base::Console().Log("This system does not support framebuffer objects\n"); } -#endif if (!QGLPixelBuffer::hasOpenGLPbuffers()) { Base::Console().Log("This system does not support pbuffers\n"); } +#endif +#if defined(HAVE_QT5_OPENGL) + // FIXME: HAVE_QT5_OPENGL +#else QGLFormat::OpenGLVersionFlags version = QGLFormat::openGLVersionFlags (); -#if QT_VERSION >= 0x040500 if (version & QGLFormat::OpenGL_Version_3_0) Base::Console().Log("OpenGL version 3.0 or higher is present\n"); - else -#endif - if (version & QGLFormat::OpenGL_Version_2_1) + else if (version & QGLFormat::OpenGL_Version_2_1) Base::Console().Log("OpenGL version 2.1 or higher is present\n"); else if (version & QGLFormat::OpenGL_Version_2_0) Base::Console().Log("OpenGL version 2.0 or higher is present\n"); @@ -1588,6 +1584,7 @@ void Application::runApplication(void) Base::Console().Log("OpenGL version 1.1 or higher is present\n"); else if (version & QGLFormat::OpenGL_Version_None) Base::Console().Log("No OpenGL is present or no OpenGL context is current\n"); +#endif #if !defined(Q_OS_LINUX) QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QString::fromLatin1(":/icons/FreeCAD-default")); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 0d00fc8e9d..512001d671 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1055,13 +1055,7 @@ void Document::createView(const Base::Type& typeId) std::list theViews = this->getMDIViewsOfType(typeId); if (typeId == View3DInventor::getClassTypeId()) { View3DInventor* firstView = 0; - QGLWidget* shareWidget = 0; - if (!theViews.empty()) { - firstView = static_cast(theViews.front()); - shareWidget = qobject_cast(firstView->getViewer()->getGLWidget()); - } - - View3DInventor* view3D = new View3DInventor(this, getMainWindow(), shareWidget); + View3DInventor* view3D = new View3DInventor(this, getMainWindow()); if (firstView) { std::string overrideMode = firstView->getViewer()->getOverrideMode(); view3D->getViewer()->setOverrideMode(overrideMode); diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index 9dbd582169..f3fb4ce46b 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -138,7 +138,7 @@ void drawImage(QGLWidget* w,double x1, double y1, double x2, double y2, QImage p // Embed complete widgets Flag::Flag(QWidget* parent) - : QGLWidget(parent), coord(0.0f, 0.0f, 0.0f) + : QtGLWidget(parent), coord(0.0f, 0.0f, 0.0f) { this->setFixedHeight(20); } @@ -146,15 +146,28 @@ Flag::Flag(QWidget* parent) void Flag::initializeGL() { const QPalette& p = this->palette(); +#if !defined(HAVE_QT5_OPENGL) qglClearColor(/*Qt::white*/p.color(QPalette::Window)); +#else + QColor c(p.color(QPalette::Window)); + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + f->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); +#endif } void Flag::paintGL() { const QPalette& p = this->palette(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#if !defined(HAVE_QT5_OPENGL) qglColor(/*Qt::black*/p.color(QPalette::Text)); renderText(10,15,this->text); +#else + QColor c(p.color(QPalette::Text)); + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + f->glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); + //FIXME: HAVE_QT5_OPENGL +#endif } void Flag::resizeGL(int width, int height) @@ -243,7 +256,7 @@ void Flag::resizeEvent(QResizeEvent * ) void Flag::paintEvent(QPaintEvent* e) { #if 1 - QGLWidget::paintEvent(e); + QtGLWidget::paintEvent(e); #else #if 1 QPainter painter; diff --git a/src/Gui/Flag.h b/src/Gui/Flag.h index 79a77760bb..18ea5eee3d 100644 --- a/src/Gui/Flag.h +++ b/src/Gui/Flag.h @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include #include namespace Gui { @@ -38,7 +38,7 @@ class View3DInventorViewer; * @author Werner Mayer */ #if 1 -class GuiExport Flag : public QGLWidget +class GuiExport Flag : public QtGLWidget { Q_OBJECT diff --git a/src/Gui/GLPainter.cpp b/src/Gui/GLPainter.cpp index 2b76cd28e5..078b020830 100644 --- a/src/Gui/GLPainter.cpp +++ b/src/Gui/GLPainter.cpp @@ -26,7 +26,6 @@ #ifndef _PreComp_ #endif -#include #include "GLPainter.h" #include "View3DInventorViewer.h" #include @@ -49,7 +48,7 @@ bool GLPainter::begin(QPaintDevice * device) if (viewer) return false; - viewer = dynamic_cast(device); + viewer = dynamic_cast(device); if (!viewer) return false; diff --git a/src/Gui/GLPainter.h b/src/Gui/GLPainter.h index f297fe7256..2758533598 100644 --- a/src/Gui/GLPainter.h +++ b/src/Gui/GLPainter.h @@ -35,10 +35,10 @@ #endif #include +#include #include class QPaintDevice; -class QGLWidget; namespace Gui { class View3DInventorViewer; @@ -72,7 +72,7 @@ public: //@} private: - QGLWidget* viewer; + QtGLWidget* viewer; GLfloat depthrange[2]; GLdouble projectionmatrix[16]; GLint width, height; diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 7e88741b13..af069fb2f6 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -337,14 +337,14 @@ class AlignmentView : public Gui::AbstractSplitView public: QLabel* myLabel; - AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0) + AlignmentView(Gui::Document* pcDocument, QWidget* parent, Qt::WindowFlags wflags=0) : AbstractSplitView(pcDocument, parent, wflags) { QSplitter* mainSplitter=0; mainSplitter = new QSplitter(Qt::Horizontal, this); - _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget)); + _viewer.push_back(new View3DInventorViewer(mainSplitter)); _viewer.back()->setDocument(pcDocument); - _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget)); + _viewer.push_back(new View3DInventorViewer(mainSplitter)); _viewer.back()->setDocument(pcDocument); QFrame* vbox = new QFrame(this); @@ -759,15 +759,8 @@ void ManualAlignment::startAlignment(Base::Type mousemodel) if (myAlignModel.isEmpty()) return; - QGLWidget* shareWidget = 0; - std::list theViews = myDocument->getMDIViewsOfType(View3DInventor::getClassTypeId()); - if (!theViews.empty()) { - shareWidget = qobject_cast(static_cast - (theViews.front())->getViewer()->getGLWidget()); - } - // create a splitted window for picking the points - myViewer = new AlignmentView(myDocument,Gui::getMainWindow(),shareWidget); + myViewer = new AlignmentView(myDocument,Gui::getMainWindow()); myViewer->setWindowTitle(tr("Alignment[*]")); myViewer->setWindowIcon(QApplication::windowIcon()); myViewer->resize(400, 300); diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index 7815feb8de..488304efcf 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -28,7 +28,6 @@ # include # include # include -# include # include # include # include @@ -37,6 +36,7 @@ # include #endif +#include #include #include "MouseSelection.h" @@ -640,7 +640,7 @@ void RubberbandSelection::initialize() rubberband.setViewer(_pcView3D); rubberband.setWorking(false); _pcView3D->addGraphicsItem(&rubberband); - if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) { + if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) { _pcView3D->setRenderType(View3DInventorViewer::Image); } _pcView3D->redraw(); @@ -649,7 +649,7 @@ void RubberbandSelection::initialize() void RubberbandSelection::terminate() { _pcView3D->removeGraphicsItem(&rubberband); - if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) { + if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) { _pcView3D->setRenderType(View3DInventorViewer::Native); } _pcView3D->redraw(); diff --git a/src/Gui/Qt4All.h b/src/Gui/Qt4All.h index a081aae33a..0cb2d699a1 100644 --- a/src/Gui/Qt4All.h +++ b/src/Gui/Qt4All.h @@ -158,12 +158,6 @@ #include #include #include -// QtOpenGL -#include -#if QT_VERSION >= 0x040200 -#include -#endif -#include // QtSvg #include #include diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index 2a383a659d..baff18fa54 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -138,6 +138,19 @@ using namespace SIM::Coin3D::Quarter; #endif //We need to avoid buffer swaping when initializing a QPainter on this widget +#if defined(HAVE_QT5_OPENGL) +class CustomGLWidget : public QOpenGLWidget { +public: + CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = 0) + : QOpenGLWidget(parent, f) + { + Q_UNUSED(shareWidget); + QSurfaceFormat surfaceFormat(format); + surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); + setFormat(surfaceFormat); + } + }; +#else class CustomGLWidget : public QGLWidget { public: CustomGLWidget(const QGLFormat& fo, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0) @@ -146,9 +159,10 @@ public: setAutoBufferSwap(false); } }; +#endif /*! constructor */ -QuarterWidget::QuarterWidget(const QGLFormat & format, QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f) +QuarterWidget::QuarterWidget(const QtGLFormat & format, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f) : inherited(parent) { Q_UNUSED(f); @@ -156,15 +170,15 @@ QuarterWidget::QuarterWidget(const QGLFormat & format, QWidget * parent, const Q } /*! constructor */ -QuarterWidget::QuarterWidget(QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f) +QuarterWidget::QuarterWidget(QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f) : inherited(parent) { Q_UNUSED(f); - this->constructor(QGLFormat(), sharewidget); + this->constructor(QtGLFormat(), sharewidget); } /*! constructor */ -QuarterWidget::QuarterWidget(QGLContext * context, QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f) +QuarterWidget::QuarterWidget(QtGLContext * context, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f) : inherited(parent) { Q_UNUSED(f); @@ -172,7 +186,7 @@ QuarterWidget::QuarterWidget(QGLContext * context, QWidget * parent, const QGLWi } void -QuarterWidget::constructor(const QGLFormat & format, const QGLWidget * sharewidget) +QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewidget) { QGraphicsScene* scene = new QGraphicsScene; setScene(scene); @@ -759,7 +773,7 @@ void QuarterWidget::paintEvent(QPaintEvent* event) glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); - QGLWidget* w = static_cast(this->viewport()); + QtGLWidget* w = static_cast(this->viewport()); assert(w->isValid() && "No valid GL context found!"); // We might have to process the delay queue here since we don't know // if paintGL() is called from Qt, and we might have some sensors @@ -785,7 +799,11 @@ void QuarterWidget::paintEvent(QPaintEvent* event) assert(w->isValid() && "No valid GL context found!"); +#if defined(HAVE_QT5_OPENGL) + glDrawBuffer(w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer ? GL_BACK : GL_FRONT); +#else glDrawBuffer(w->doubleBuffer() ? GL_BACK : GL_FRONT); +#endif w->makeCurrent(); this->actualRedraw(); @@ -797,7 +815,12 @@ void QuarterWidget::paintEvent(QPaintEvent* event) inherited::paintEvent(event); glPopAttrib(); +#if defined(HAVE_QT5_OPENGL) + if (w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer) + w->context()->swapBuffers(w->context()->surface()); +#else if (w->doubleBuffer()) { w->swapBuffers(); } +#endif PRIVATE(this)->autoredrawenabled = true; diff --git a/src/Gui/Quarter/QuarterWidget.h b/src/Gui/Quarter/QuarterWidget.h index 804298b531..2b117440e7 100644 --- a/src/Gui/Quarter/QuarterWidget.h +++ b/src/Gui/Quarter/QuarterWidget.h @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include "Gui/Quarter/Basic.h" class QMenu; @@ -81,9 +81,9 @@ class QUARTER_DLL_API QuarterWidget : public QGraphicsView { public: - explicit QuarterWidget(QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0); - explicit QuarterWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0); - explicit QuarterWidget(const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0); + explicit QuarterWidget(QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = 0); + explicit QuarterWidget(QtGLContext * context, QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = 0); + explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = 0, const QtGLWidget * shareWidget = 0, Qt::WindowFlags f = 0); virtual ~QuarterWidget(); enum TransparencyType { @@ -199,7 +199,7 @@ protected: double renderTime; private: - void constructor(const QGLFormat& format, const QGLWidget* sharewidget); + void constructor(const QtGLFormat& format, const QtGLWidget* sharewidget); friend class QuarterWidgetP; class QuarterWidgetP * pimpl; bool initialized; diff --git a/src/Gui/Quarter/QuarterWidgetP.cpp b/src/Gui/Quarter/QuarterWidgetP.cpp index 89d12182c1..984f61ba4c 100644 --- a/src/Gui/Quarter/QuarterWidgetP.cpp +++ b/src/Gui/Quarter/QuarterWidgetP.cpp @@ -64,12 +64,12 @@ using namespace SIM::Coin3D::Quarter; class QuarterWidgetP_cachecontext { public: uint32_t id; - SbList widgetlist; + SbList widgetlist; }; static SbList * cachecontext_list = NULL; -QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QGLWidget * sharewidget) +QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sharewidget) : master(masterptr), scene(NULL), eventfilter(NULL), @@ -100,7 +100,7 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QGLWidget * shar QuarterWidgetP::~QuarterWidgetP() { - QGLWidget* glMaster = static_cast(this->master->viewport()); + QtGLWidget* glMaster = static_cast(this->master->viewport()); removeFromCacheContext(this->cachecontext, glMaster); if (this->contextmenu) { delete this->contextmenu; @@ -131,7 +131,7 @@ QuarterWidgetP::getCacheContextId(void) const } QuarterWidgetP_cachecontext * -QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QGLWidget * sharewidget) +QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget) { if (cachecontext_list == NULL) { // FIXME: static memory leak @@ -142,23 +142,23 @@ QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QGLWidget * share for (int j = 0; j < cachecontext->widgetlist.getLength(); j++) { if (cachecontext->widgetlist[j] == sharewidget) { - cachecontext->widgetlist.append(static_cast(widget->viewport())); + cachecontext->widgetlist.append(static_cast(widget->viewport())); return cachecontext; } } } QuarterWidgetP_cachecontext * cachecontext = new QuarterWidgetP_cachecontext; cachecontext->id = SoGLCacheContextElement::getUniqueCacheContext(); - cachecontext->widgetlist.append(static_cast(widget->viewport())); + cachecontext->widgetlist.append(static_cast(widget->viewport())); cachecontext_list->append(cachecontext); return cachecontext; } void -QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QGLWidget * widget) +QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget) { - context->widgetlist.removeItem((const QGLWidget*) widget); + context->widgetlist.removeItem((const QtGLWidget*) widget); if (context->widgetlist.getLength() == 0) { // last context in this share group? assert(cachecontext_list); @@ -166,12 +166,12 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co for (int i = 0; i < cachecontext_list->getLength(); i++) { if ((*cachecontext_list)[i] == context) { // set the context while calling destructingContext() (might trigger OpenGL calls) - const_cast (widget)->makeCurrent(); + const_cast (widget)->makeCurrent(); // fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818 (void) cc_glglue_instance(context->id); cachecontext_list->removeFast(i); SoContextHandler::destructingContext(context->id); - const_cast (widget)->doneCurrent(); + const_cast (widget)->doneCurrent(); delete context; return; } diff --git a/src/Gui/Quarter/QuarterWidgetP.h b/src/Gui/Quarter/QuarterWidgetP.h index 8bb746f52f..0b954f3978 100644 --- a/src/Gui/Quarter/QuarterWidgetP.h +++ b/src/Gui/Quarter/QuarterWidgetP.h @@ -38,6 +38,7 @@ #include #include #include +#include class SoNode; class SoCamera; @@ -45,7 +46,6 @@ class SoRenderManager; class SoEventManager; class SoDirectionalLight; class QuarterWidgetP_cachecontext; -class QGLWidget; class QAction; class QActionGroup; class QMenu; @@ -62,7 +62,7 @@ class ContextMenu; class QuarterWidgetP { public: - QuarterWidgetP(class QuarterWidget * master, const QGLWidget * sharewidget); + QuarterWidgetP(class QuarterWidget * master, const QtGLWidget * sharewidget); ~QuarterWidgetP(); SoCamera * searchForCamera(SoNode * root); @@ -112,8 +112,8 @@ public: static bool nativeEventFilter(void * message, long * result); private: - QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QGLWidget * sharewidget); - static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QGLWidget * widget); + QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget); + static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget); }; #endif // QUARTER_QUARTERWIDGETP_H diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp index a35f229eb9..5ef109615f 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp @@ -132,19 +132,19 @@ static unsigned char fps2dfont[][12] = { { 0, 0, 0, 0, 0, 0, 78, 57, 0, 0, 0, 0 } // ~ }; -SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f) +SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent, const QtGLWidget* sharewidget, Qt::WindowFlags f) : QuarterWidget(parent, sharewidget, f), matrixaction(SbViewportRegion(100,100)) { init(); } -SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f) +SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent, const QtGLWidget* shareWidget, Qt::WindowFlags f) : QuarterWidget(format, parent, shareWidget, f), matrixaction(SbViewportRegion(100,100)) { init(); } -SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QGLContext* context, QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f) +SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent, const QtGLWidget* sharewidget, Qt::WindowFlags f) : QuarterWidget(context, parent, sharewidget, f), matrixaction(SbViewportRegion(100,100)) { init(); diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.h b/src/Gui/Quarter/SoQTQuarterAdaptor.h index 45df528df1..f0c51c2b92 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.h +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.h @@ -46,9 +46,9 @@ typedef void SoQTQuarterAdaptorCB(void* data, SoQTQuarterAdaptor* viewer); class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget { public: - explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0); - explicit SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0); - explicit SoQTQuarterAdaptor(QGLContext* context, QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0); + explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = 0); + explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = 0, const QtGLWidget* shareWidget = 0, Qt::WindowFlags f = 0); + explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = 0); virtual ~SoQTQuarterAdaptor(); //the functions available in soqtviewer but missing in quarter diff --git a/src/Gui/SoFCInteractiveElement.cpp b/src/Gui/SoFCInteractiveElement.cpp index 02156523ac..c5bb38fdb2 100644 --- a/src/Gui/SoFCInteractiveElement.cpp +++ b/src/Gui/SoFCInteractiveElement.cpp @@ -87,14 +87,14 @@ SoGLWidgetElement::~SoGLWidgetElement() { } -void SoGLWidgetElement::set(SoState * state, QGLWidget * window) +void SoGLWidgetElement::set(SoState * state, QtGLWidget * window) { SoGLWidgetElement * elem = static_cast (SoElement::getElement(state, classStackIndex)); elem->window = window; } -void SoGLWidgetElement::get(SoState * state, QGLWidget *& window) +void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window) { const SoGLWidgetElement* that = static_cast (SoElement::getConstElement(state, classStackIndex)); diff --git a/src/Gui/SoFCInteractiveElement.h b/src/Gui/SoFCInteractiveElement.h index b7c9f8dcfd..059c20b255 100644 --- a/src/Gui/SoFCInteractiveElement.h +++ b/src/Gui/SoFCInteractiveElement.h @@ -28,7 +28,7 @@ # include "InventorAll.h" #endif -class QGLWidget; +#include namespace Gui { /** @@ -70,14 +70,14 @@ public: virtual SbBool matches(const SoElement * element) const; virtual SoElement * copyMatchInfo(void) const; - static void set(SoState * state, QGLWidget * window); - static void get(SoState * state, QGLWidget *& window); + static void set(SoState * state, QtGLWidget * window); + static void get(SoState * state, QtGLWidget *& window); protected: virtual ~SoGLWidgetElement(); protected: - QGLWidget * window; + QtGLWidget * window; }; class GuiExport SoGLRenderActionElement : public SoElement { @@ -114,7 +114,7 @@ public: static void initClass(void); SoGLWidgetNode(void); - QGLWidget * window; + QtGLWidget * window; virtual void doAction(SoAction * action); virtual void GLRender(SoGLRenderAction * action); diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index 14aaeb9abe..a0670d8c96 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -29,9 +29,6 @@ # include # include # include -# include -# include -# include # include # include #endif @@ -403,11 +400,17 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr, this->didallocation = glrenderaction ? false : true; this->viewport = vpr; +#if !defined(HAVE_QT5_OPENGL) this->pixelbuffer = NULL; // constructed later +#endif this->framebuffer = NULL; this->numSamples = -1; this->cache_context = 0; +#if !defined(HAVE_QT5_OPENGL) this->pbuffer = QGLPixelBuffer::hasOpenGLPbuffers(); +#else + this->pbuffer = false; +#endif } /*! @@ -434,7 +437,9 @@ SoQtOffscreenRenderer::SoQtOffscreenRenderer(SoGLRenderAction * action) */ SoQtOffscreenRenderer::~SoQtOffscreenRenderer() { +#if !defined(HAVE_QT5_OPENGL) delete pixelbuffer; +#endif delete framebuffer; if (this->didallocation) { @@ -538,6 +543,7 @@ SoQtOffscreenRenderer::pre_render_cb(void * /*userdata*/, SoGLRenderAction * act action->setRenderingIsRemote(false); } +#if !defined(HAVE_QT5_OPENGL) void SoQtOffscreenRenderer::makePixelBuffer(int width, int height, int samples) { @@ -560,6 +566,7 @@ SoQtOffscreenRenderer::makePixelBuffer(int width, int height, int samples) pixelbuffer = new QGLPixelBuffer(width, height, fmt); cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure } +#endif void SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples) @@ -572,15 +579,15 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples) viewport.setWindowSize(width, height); #if QT_VERSION >= 0x040600 - QGLFramebufferObjectFormat fmt; + QtGLFramebufferObjectFormat fmt; fmt.setSamples(samples); - fmt.setAttachment(QGLFramebufferObject::Depth); + fmt.setAttachment(QtGLFramebufferObject::Depth); #else - QGLFramebufferObject::Attachment fmt; - fmt = QGLFramebufferObject::Depth; + QtGLFramebufferObject::Attachment fmt; + fmt = QtGLFramebufferObject::Depth; #endif - framebuffer = new QGLFramebufferObject(width, height, fmt); + framebuffer = new QtGLFramebufferObject(width, height, fmt); cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure } @@ -589,6 +596,7 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base) { const SbVec2s fullsize = this->viewport.getViewportSizePixels(); +#if !defined(HAVE_QT5_OPENGL) if (PRIVATE(this)->pbuffer) { if (!pixelbuffer) { makePixelBuffer(fullsize[0], fullsize[1], PRIVATE(this)->numSamples); @@ -600,7 +608,9 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base) pixelbuffer->makeCurrent(); // activate us! } - else { + else +#endif + { if (!framebuffer) { makeFrameBuffer(fullsize[0], fullsize[1], PRIVATE(this)->numSamples); } @@ -638,10 +648,13 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base) this->renderaction->removePreRenderCallback(pre_render_cb, NULL); +#if !defined(HAVE_QT5_OPENGL) if (PRIVATE(this)->pbuffer) { pixelbuffer->doneCurrent(); } - else { + else +#endif + { framebuffer->release(); } @@ -712,11 +725,14 @@ SoQtOffscreenRenderer::render(SoPath * scene) void SoQtOffscreenRenderer::writeToImage (QImage& img) const { +#if !defined(HAVE_QT5_OPENGL) if (PRIVATE(this)->pbuffer) { if (pixelbuffer) img = pixelbuffer->toImage(); } - else { + else +#endif + { if (framebuffer) img = framebuffer->toImage(); } diff --git a/src/Gui/SoFCOffscreenRenderer.h b/src/Gui/SoFCOffscreenRenderer.h index c3d363b1c3..2a8c260f02 100644 --- a/src/Gui/SoFCOffscreenRenderer.h +++ b/src/Gui/SoFCOffscreenRenderer.h @@ -27,10 +27,9 @@ #include #include #include +#include class QImage; -class QGLFramebufferObject; -class QGLPixelBuffer; namespace Gui { @@ -114,12 +113,12 @@ public: void setGLRenderAction(SoGLRenderAction * action); SoGLRenderAction * getGLRenderAction(void) const; - - void setNumPasses(const int num); - int getNumPasses(void) const; - - void setPbufferEnable(SbBool enable); - SbBool getPbufferEnable(void) const; + + void setNumPasses(const int num); + int getNumPasses(void) const; + + void setPbufferEnable(SbBool enable); + SbBool getPbufferEnable(void) const; SbBool render(SoNode * scene); SbBool render(SoPath * scene); @@ -131,12 +130,16 @@ private: void init(const SbViewportRegion & vpr, SoGLRenderAction * glrenderaction = NULL); static void pre_render_cb(void * userdata, SoGLRenderAction * action); SbBool renderFromBase(SoBase * base); +#if !defined(HAVE_QT5_OPENGL) void makePixelBuffer(int width, int height, int samples); +#endif void makeFrameBuffer(int width, int height, int samples); - QGLPixelBuffer* pixelbuffer; // the offscreen rendering supported by Qt - QGLFramebufferObject* framebuffer; - uint32_t cache_context; // our unique context id +#if !defined(HAVE_QT5_OPENGL) + QGLPixelBuffer* pixelbuffer; // the offscreen rendering supported by Qt +#endif + QtGLFramebufferObject* framebuffer; + uint32_t cache_context; // our unique context id SbViewportRegion viewport; SbColor backgroundcolor; diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index c47ac9b8ee..8905c273bd 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include # include -# include # include # include #endif diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 18157dcc0a..d9e8672af6 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include # include -# include # include # include #endif @@ -65,6 +64,8 @@ #include #include +#include + #include #include #include @@ -561,7 +562,7 @@ void SoFCUnifiedSelection::GLRenderBelowPath(SoGLRenderAction * action) // this is called when a selection gate forbade to select an object // and the user moved the mouse to an empty area this->preSelection = -1; - QGLWidget* window; + QtGLWidget* window; SoState *state = action->getState(); SoGLWidgetElement::get(state, window); QWidget* parent = window ? window->parentWidget() : 0; diff --git a/src/Gui/SoTextLabel.cpp b/src/Gui/SoTextLabel.cpp index c074389a51..cd289cea78 100644 --- a/src/Gui/SoTextLabel.cpp +++ b/src/Gui/SoTextLabel.cpp @@ -35,7 +35,6 @@ # include # include # include -# include # include # include # include @@ -62,6 +61,7 @@ #include #endif +#include #include "SoTextLabel.h" #include "SoFCInteractiveElement.h" #include "BitmapFactory.h" @@ -318,7 +318,7 @@ SoStringLabel::SoStringLabel() */ void SoStringLabel::GLRender(SoGLRenderAction *action) { - QGLWidget* window; + QtGLWidget* window; SoState * state = action->getState(); state->push(); SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR); @@ -376,7 +376,11 @@ void SoStringLabel::GLRender(SoGLRenderAction *action) QStringList list; for (int i=0; istring.getNum(); i++) list << QLatin1String(this->string[i].getString()); +#if !defined(HAVE_QT5_OPENGL) window->renderText(nil[0],nil[1],nil[2],list.join(QLatin1String("\n")),font); +#else + //FIXME: HAVE_QT5_OPENGL +#endif // Leave 2D screen mode glPopAttrib(); @@ -492,7 +496,7 @@ void SoFrameLabel::GLRender(SoGLRenderAction *action) { inherited::GLRender(action); #if 0 - QGLWidget* window; + QtGLWidget* window; SoState * state = action->getState(); state->push(); SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR); diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index edbf9e4f4c..bb9c077655 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -684,23 +684,29 @@ SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, Q hGrp->Attach(this); //anti-aliasing settings - QGLFormat f; + QtGLFormat f; bool smoothing = false; bool glformat = false; switch (hGrp->GetInt("AntiAliasing",0) ) { case View3DInventorViewer::MSAA2x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(2); break; case View3DInventorViewer::MSAA4x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(4); break; case View3DInventorViewer::MSAA8x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(8); break; case View3DInventorViewer::Smoothing: diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index 9f7bb17760..33426b6731 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -29,10 +29,9 @@ # include # include # include -# include -# include #endif +#include #include "Thumbnail.h" #include "BitmapFactory.h" #include "View3DInventorViewer.h" @@ -88,7 +87,11 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const if (!this->viewer) return; QImage img; +#if !defined(HAVE_QT5_OPENGL) bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers(); +#else + bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects(); +#endif if (App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) { this->createThumbnailFromFramebuffer(img); @@ -131,7 +134,7 @@ void Thumbnail::RestoreDocFile(Base::Reader &reader) void Thumbnail::createThumbnailFromFramebuffer(QImage& img) const { // Alternative way of off-screen rendering - QGLFramebufferObject fbo(this->size, this->size,QGLFramebufferObject::Depth); + QtGLFramebufferObject fbo(this->size, this->size,QtGLFramebufferObject::Depth); if (this->viewer->isActiveWindow()) { this->viewer->renderToFramebuffer(&fbo); img = fbo.toImage(); diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 751798705d..9254e272eb 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -27,15 +27,11 @@ # include # include # include -# include # include # include # include # include # include -# include -# include -# include # include # include # include @@ -105,7 +101,7 @@ void GLOverlayWidget::paintEvent(QPaintEvent*) TYPESYSTEM_SOURCE_ABSTRACT(Gui::View3DInventor,Gui::MDIView); View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, - const QGLWidget* sharewidget, Qt::WindowFlags wflags) + const QtGLWidget* sharewidget, Qt::WindowFlags wflags) : MDIView(pcDocument, parent, wflags), _viewerPy(0) { stack = new QStackedWidget(this); @@ -119,23 +115,29 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, hGrp->Attach(this); //anti-aliasing settings - QGLFormat f; + QtGLFormat f; bool smoothing = false; bool glformat = false; switch( hGrp->GetInt("AntiAliasing",0) ) { case View3DInventorViewer::MSAA2x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(2); break; case View3DInventorViewer::MSAA4x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(4); break; case View3DInventorViewer::MSAA8x: glformat = true; +#if !defined(HAVE_QT5_OPENGL) f.setSampleBuffers(true); +#endif f.setSamples(8); break; case View3DInventorViewer::Smoothing: @@ -552,7 +554,11 @@ void View3DInventor::print(QPrinter* printer) } QRect rect = printer->pageRect(); +#if !defined(HAVE_QT5_OPENGL) bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers(); +#else + bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects(); +#endif if (App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) { previewFromFramebuffer(rect, img); @@ -574,12 +580,12 @@ void View3DInventor::print(QPrinter* printer) void View3DInventor::previewFromFramebuffer(const QRect& rect, QImage& img) { #if QT_VERSION >= 0x040600 - QGLFramebufferObjectFormat format; + QtGLFramebufferObjectFormat format; format.setSamples(8); - format.setAttachment(QGLFramebufferObject::Depth); - QGLFramebufferObject fbo(rect.width(), rect.height(), format); + format.setAttachment(QtGLFramebufferObject::Depth); + QtGLFramebufferObject fbo(rect.width(), rect.height(), format); #else - QGLFramebufferObject fbo(rect.width(), rect.height(), QGLFramebufferObject::Depth); + QtGLFramebufferObject fbo(rect.width(), rect.height(), QtGLFramebufferObject::Depth); #endif const QColor col = _viewer->backgroundColor(); bool on = _viewer->hasGradientBackground(); diff --git a/src/Gui/View3DInventor.h b/src/Gui/View3DInventor.h index 1af621d8cc..c50491783c 100644 --- a/src/Gui/View3DInventor.h +++ b/src/Gui/View3DInventor.h @@ -28,9 +28,9 @@ #include #include +#include class SoNode; -class QGLWidget; class QPrinter; class QStackedWidget; @@ -68,7 +68,7 @@ class GuiExport View3DInventor : public MDIView, public ParameterGrp::ObserverTy TYPESYSTEM_HEADER(); public: - View3DInventor(Gui::Document* pcDocument, QWidget* parent, const QGLWidget* sharewidget = 0, Qt::WindowFlags wflags=0); + View3DInventor(Gui::Document* pcDocument, QWidget* parent, const QtGLWidget* sharewidget = 0, Qt::WindowFlags wflags=0); ~View3DInventor(); /// Message handler diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 44f0d47ad3..47b61773c8 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -75,8 +75,6 @@ # include # include # include -# include -# include # include # include # include @@ -335,7 +333,7 @@ public: // ************************************************************************* -View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sharewidget) +View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QtGLWidget* sharewidget) : Quarter::SoQTQuarterAdaptor(parent, sharewidget), editViewProvider(0), navigation(0), renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(false), redirected(false), allowredir(false), overrideMode("As Is"), _viewerPy(0) @@ -343,7 +341,7 @@ View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sha init(); } -View3DInventorViewer::View3DInventorViewer(const QGLFormat& format, QWidget* parent, const QGLWidget* sharewidget) +View3DInventorViewer::View3DInventorViewer(const QtGLFormat& format, QWidget* parent, const QtGLWidget* sharewidget) : Quarter::SoQTQuarterAdaptor(format, parent, sharewidget), editViewProvider(0), navigation(0), renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(false), redirected(false), allowredir(false), overrideMode("As Is"), _viewerPy(0) @@ -767,7 +765,7 @@ void View3DInventorViewer::setGLWidgetCB(void* userdata, SoAction* action) // Separator (set envvar COIN_GLERROR_DEBUGGING=1 and re-run to get more information) if (action->isOfType(SoGLRenderAction::getClassTypeId())) { QWidget* gl = reinterpret_cast(userdata); - SoGLWidgetElement::set(action->getState(), qobject_cast(gl)); + SoGLWidgetElement::set(action->getState(), qobject_cast(gl)); } } @@ -777,7 +775,7 @@ void View3DInventorViewer::handleEventCB(void* ud, SoEventCallback* n) SoGLRenderAction* glra = that->getSoRenderManager()->getGLRenderAction(); SoAction* action = n->getAction(); SoGLRenderActionElement::set(action->getState(), glra); - SoGLWidgetElement::set(action->getState(), qobject_cast(that->getGLWidget())); + SoGLWidgetElement::set(action->getState(), qobject_cast(that->getGLWidget())); } void View3DInventorViewer::setGradientBackground(bool on) @@ -930,7 +928,11 @@ void View3DInventorViewer::savePicture(int w, int h, const QColor& bg, QImage& i // If 'QGLPixelBuffer::hasOpenGLPbuffers()' returns false then // SoQtOffscreenRenderer won't work. In this case we try to use // Coin's implementation of the off-screen rendering. +#if !defined(HAVE_QT5_OPENGL) bool useCoinOffscreenRenderer = !QGLPixelBuffer::hasOpenGLPbuffers(); +#else + bool useCoinOffscreenRenderer = !QtGLFramebufferObject::hasOpenGLFramebufferObjects(); +#endif useCoinOffscreenRenderer = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")-> GetBool("CoinOffscreenRenderer", useCoinOffscreenRenderer); @@ -1304,15 +1306,15 @@ void View3DInventorViewer::setRenderType(const RenderType type) const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion(); SbVec2s size = vp.getViewportSizePixels(); - QGLWidget* gl = static_cast(this->viewport()); + QtGLWidget* gl = static_cast(this->viewport()); gl->makeCurrent(); - framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth); + framebuffer = new QtGLFramebufferObject(size[0],size[1],QtGLFramebufferObject::Depth); renderToFramebuffer(framebuffer); } break; case Image: { - QGLWidget* gl = static_cast(this->viewport()); + QtGLWidget* gl = static_cast(this->viewport()); gl->makeCurrent(); int w = gl->width(); int h = gl->height(); @@ -1329,9 +1331,9 @@ View3DInventorViewer::RenderType View3DInventorViewer::getRenderType() const return this->renderType; } -void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo) +void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo) { - static_cast(this->viewport())->makeCurrent(); + static_cast(this->viewport())->makeCurrent(); fbo->bind(); int width = fbo->size().width(); int height = fbo->size().height(); @@ -1483,7 +1485,7 @@ void View3DInventorViewer::renderScene(void) // Render our scenegraph with the image. SoGLRenderAction* glra = this->getSoRenderManager()->getGLRenderAction(); SoState* state = glra->getState(); - SoGLWidgetElement::set(state, qobject_cast(this->getGLWidget())); + SoGLWidgetElement::set(state, qobject_cast(this->getGLWidget())); SoGLRenderActionElement::set(state, glra); SoGLVBOActivatedElement::set(state, this->vboEnabled); glra->apply(this->backgroundroot); diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index e58ee96cf5..5169c53997 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -52,7 +52,6 @@ class SbSphereSheetProjector; class SoEventCallback; class SbBox2s; class SoVectorizeAction; -class QGLFramebufferObject; class QImage; class SoGroup; @@ -124,8 +123,8 @@ public: }; //@} - View3DInventorViewer (QWidget *parent, const QGLWidget* sharewidget = 0); - View3DInventorViewer (const QGLFormat& format, QWidget *parent, const QGLWidget* sharewidget = 0); + View3DInventorViewer (QWidget *parent, const QtGLWidget* sharewidget = 0); + View3DInventorViewer (const QtGLFormat& format, QWidget *parent, const QtGLWidget* sharewidget = 0); virtual ~View3DInventorViewer(); void init(); @@ -158,7 +157,7 @@ public: void setRenderType(const RenderType type); RenderType getRenderType() const; - void renderToFramebuffer(QGLFramebufferObject*); + void renderToFramebuffer(QtGLFramebufferObject*); virtual void setViewing(SbBool enable); virtual void setCursorEnabled(SbBool enable); @@ -409,7 +408,7 @@ private: SoFCUnifiedSelection* selectionRoot; RenderType renderType; - QGLFramebufferObject* framebuffer; + QtGLFramebufferObject* framebuffer; QImage glImage; SbBool shading; SoSwitch *dimensionRoot; diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 9deefd0ca3..f66d1f37e3 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -30,14 +30,11 @@ # include # include # include -# include -# include -# include # include # include #endif - +#include #include "View3DPy.h" #include "ViewProviderDocumentObject.h" #include "ViewProviderExtern.h" @@ -699,18 +696,18 @@ Py::Object View3DInventorPy::isAnimationEnabled(const Py::Tuple& args) void View3DInventorPy::createImageFromFramebuffer(int width, int height, const QColor& bgcolor, QImage& img) { - const QGLContext* context = QGLContext::currentContext(); + const QtGLContext* context = QtGLContext::currentContext(); if (!context) { Base::Console().Warning("createImageFromFramebuffer failed because no context is active\n"); return; } #if QT_VERSION >= 0x040600 - QGLFramebufferObjectFormat format; + QtGLFramebufferObjectFormat format; format.setSamples(8); - format.setAttachment(QGLFramebufferObject::Depth); - QGLFramebufferObject fbo(width, height, format); + format.setAttachment(QtGLFramebufferObject::Depth); + QtGLFramebufferObject fbo(width, height, format); #else - QGLFramebufferObject fbo(width, height, QGLFramebufferObject::Depth); + QtGLFramebufferObject fbo(width, height, QtGLFramebufferObject::Depth); #endif const QColor col = _view->getViewer()->backgroundColor(); bool on = _view->getViewer()->hasGradientBackground(); @@ -749,7 +746,11 @@ Py::Object View3DInventorPy::saveImage(const Py::Tuple& args) bg.setNamedColor(colname); QImage img; +#if !defined(HAVE_QT5_OPENGL) bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers(); +#else + bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects(); +#endif if (App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) { createImageFromFramebuffer(w, h, bg, img);