Qt5 port: workaround to keep multi-sampling when undocking mdi window

This commit is contained in:
wmayer
2017-05-01 18:53:58 +02:00
parent 9ec00ebce8
commit d02a34c03b
5 changed files with 39 additions and 1 deletions

View File

@@ -147,8 +147,10 @@ using namespace SIM::Coin3D::Quarter;
#if defined(HAVE_QT5_OPENGL)
class CustomGLWidget : public QOpenGLWidget {
public:
QSurfaceFormat myFormat;
CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = 0)
: QOpenGLWidget(parent, f)
: QOpenGLWidget(parent, f), myFormat(format)
{
Q_UNUSED(shareWidget);
QSurfaceFormat surfaceFormat(format);
@@ -299,6 +301,20 @@ QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewi
initialized = false;
}
void
QuarterWidget::replaceViewport()
{
#if defined(HAVE_QT5_OPENGL)
CustomGLWidget* oldvp = static_cast<CustomGLWidget*>(viewport());
CustomGLWidget* newvp = new CustomGLWidget(oldvp->myFormat, this);
PRIVATE(this)->replaceGLWidget(newvp);
setViewport(newvp);
setAutoFillBackground(false);
viewport()->setAutoFillBackground(false);
#endif
}
/*! destructor */
QuarterWidget::~QuarterWidget()
{

View File

@@ -189,6 +189,9 @@ public Q_SLOTS:
Q_SIGNALS:
void devicePixelRatioChanged(qreal dev_pixel_ratio);
private Q_SLOTS:
void replaceViewport();
protected:
virtual void paintEvent(QPaintEvent*);
virtual void resizeEvent(QResizeEvent*);

View File

@@ -179,6 +179,14 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co
}
}
void
QuarterWidgetP::replaceGLWidget(const QtGLWidget * newviewport)
{
QtGLWidget* oldviewport = static_cast<QtGLWidget*>(this->master->viewport());
cachecontext->widgetlist.removeItem(oldviewport);
cachecontext->widgetlist.append(newviewport);
}
/*!
*/

View File

@@ -110,6 +110,7 @@ public:
mutable ContextMenu * contextmenu;
static bool nativeEventFilter(void * message, long * result);
void replaceGLWidget(const QtGLWidget * newviewport);
private:
QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget);

View File

@@ -1006,6 +1006,16 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode)
MDIView::setCurrentViewMode(newmode);
#if defined(HAVE_QT5_OPENGL)
// Internally the QOpenGLWidget switches of the multi-sampling and there is no
// way to switch it on again. So as a workaround we just re-create a new viewport
// The method is private but defined as slot to avoid to call it by accident.
int index = _viewer->metaObject()->indexOfMethod("replaceViewport()");
if (index >= 0) {
_viewer->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0);
}
#endif
// This widget becomes the focus proxy of the embedded GL widget if we leave
// the 'Child' mode. If we reenter 'Child' mode the focus proxy is reset to 0.
// If we change from 'TopLevel' mode to 'Fullscreen' mode or vice versa nothing