diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 89f0992544..af0fea0d04 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -1551,6 +1551,49 @@ void StdViewDockUndockFullscreen::activated(int iMsg) MDIView* view = getMainWindow()->activeWindow(); if (!view) return; // no active view +#if defined(HAVE_QT5_OPENGL) + // nothing to do when the view is docked and 'Docked' is pressed + if (iMsg == 0 && view->currentViewMode() == MDIView::Child) + return; + // Change the view mode after an mdi view was already visible doesn't + // work well with Qt5 any more because of some strange OpenGL behaviour. + // A workaround is to clone the mdi view, set its view mode and delete + // the original view. + Gui::Document* doc = Gui::Application::Instance->activeDocument(); + if (doc) { + Gui::MDIView* clone = doc->cloneView(view); + if (!clone) + return; + + const char* ppReturn = 0; + if (view->onMsg("GetCamera", &ppReturn)) { + std::string sMsg = "SetCamera "; + sMsg += ppReturn; + + const char** pReturnIgnore=0; + clone->onMsg(sMsg.c_str(), pReturnIgnore); + } + + if (iMsg==0) { + getMainWindow()->addWindow(clone); + } + else if (iMsg==1) { + if (view->currentViewMode() == MDIView::TopLevel) + getMainWindow()->addWindow(clone); + else + clone->setCurrentViewMode(MDIView::TopLevel); + } + else if (iMsg==2) { + if (view->currentViewMode() == MDIView::FullScreen) + getMainWindow()->addWindow(clone); + else + clone->setCurrentViewMode(MDIView::FullScreen); + } + + // destroy the old view + view->deleteSelf(); + } +#else if (iMsg==0) { view->setCurrentViewMode(MDIView::Child); } @@ -1566,6 +1609,7 @@ void StdViewDockUndockFullscreen::activated(int iMsg) else view->setCurrentViewMode(MDIView::FullScreen); } +#endif } bool StdViewDockUndockFullscreen::isActive(void) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index ad4ccc5796..18da789c65 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1093,6 +1093,33 @@ void Document::createView(const Base::Type& typeId) } } +Gui::MDIView* Document::cloneView(Gui::MDIView* oldview) +{ + if (!oldview) + return 0; + + if (oldview->getTypeId() == View3DInventor::getClassTypeId()) { + View3DInventor* view3D = new View3DInventor(this, getMainWindow()); + + // attach the viewprovider + std::map::const_iterator It1; + for (It1=d->_ViewProviderMap.begin();It1!=d->_ViewProviderMap.end();++It1) + view3D->getViewer()->addViewProvider(It1->second); + std::map::const_iterator It2; + for (It2=d->_ViewProviderMapAnnotation.begin();It2!=d->_ViewProviderMapAnnotation.end();++It2) + view3D->getViewer()->addViewProvider(It2->second); + + view3D->setWindowTitle(oldview->windowTitle()); + view3D->setWindowModified(oldview->isWindowModified()); + view3D->setWindowIcon(oldview->windowIcon()); + view3D->resize(oldview->size()); + + return view3D; + } + + return 0; +} + void Document::attachView(Gui::BaseView* pcView, bool bPassiv) { if (!bPassiv) diff --git a/src/Gui/Document.h b/src/Gui/Document.h index f12ee307cf..01ebc29935 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -162,6 +162,8 @@ public: Gui::MDIView* getViewOfNode(SoNode*) const; /// Create a new view void createView(const Base::Type& typeId); + /// Create a clone of the given view + Gui::MDIView* cloneView(Gui::MDIView*); /** send messages to the active view * Send a specific massage to the active view and is able to recive a * return massage diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index d451aba462..6b1b03a069 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -1010,10 +1010,10 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode) // 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); - } + //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 diff --git a/src/Mod/Image/Gui/OpenGLImageBox.cpp b/src/Mod/Image/Gui/OpenGLImageBox.cpp index 58c460e755..36c41cad15 100644 --- a/src/Mod/Image/Gui/OpenGLImageBox.cpp +++ b/src/Mod/Image/Gui/OpenGLImageBox.cpp @@ -870,7 +870,7 @@ void GLImageBox::renderText(int x, int y, const QString& str, const QFont& fnt) GLint view[4]; bool use_scissor_testing = f->glIsEnabled(GL_SCISSOR_TEST); - if (!use_scissor_testing) + //if (!use_scissor_testing) f->glGetIntegerv(GL_VIEWPORT, &view[0]); diff --git a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp index d3709a0223..2f61b6f6f4 100644 --- a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp +++ b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp @@ -337,11 +337,11 @@ void SoDatumLabel::generatePrimitives(SoAction * action) } else if (this->datumtype.getValue() == SYMMETRIC) { // Get the Scale. See GLRender function for details on the viewport width calculation - SoState *state = action->getState(); - const SbViewVolume & vv = SoViewVolumeElement::get(state); - float scale = vv.getWorldToScreenScale(SbVec3f(0.f,0.f,0.f), 1.0f); - SbVec2s vp_size = SoViewportRegionElement::get(state).getViewportSizePixels(); - scale /= float(vp_size[0]); + //SoState *state = action->getState(); + //const SbViewVolume & vv = SoViewVolumeElement::get(state); + //float scale = vv.getWorldToScreenScale(SbVec3f(0.f,0.f,0.f), 1.0f); + //SbVec2s vp_size = SoViewportRegionElement::get(state).getViewportSizePixels(); + //scale /= float(vp_size[0]); SbVec3f dir = (p2-p1); dir.normalize();