FreeCAD Qt5 plan for deprecated WebKit?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
f3nix
Posts: 213
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby f3nix » Sat Jan 28, 2017 11:34 am

wmayer wrote:
f3nix wrote:I've been working on QOpenGLWidget port during past few days. I think I will have something shareable in the near future.

At the moment we use the old QGLWidget in two places: the view port of the 3d view and in the image module to render images. A few weeks ago I started to port the image viewer to QOpenGLWidget which was quite straightforward and everything worked correctly.

However, the problems started when opening a 3d view at the same time. The image view becomes black and for every new image view you create it never goes back to normal.


Hi Werner,
I do not know if I understood correctly but I do not seem to get this problem. 3d views and images in image workbench seem to display ok.
Screenshot_20170128_121717.png
Screenshot_20170128_121717.png (213.77 KiB) Viewed 331 times


Do you have a branch somewhere to test?

Cheers,
Mateusz
triplus
Posts: 4857
Joined: Mon Dec 12, 2011 4:45 pm

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby triplus » Sat Jan 28, 2017 11:58 am

f3nix wrote:Do you have a branch somewhere to test?

Cheers,
Mateusz


Not to waste words my question to you would be the same.

P.S. Take your time no pressure whatsoever. :)
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby wmayer » Sat Jan 28, 2017 12:00 pm

f3nix wrote:I do not know if I understood correctly but I do not seem to get this problem. 3d views and images in image workbench seem to display ok.

Just to be clear the issue comes up with the image viewer ported to QOpenGLWidget while the Quarter viewer uses the QGLWidget. I haven't moved the Quarter viewer to the new QOpenGLWidget so far. So, maybe the issue is solved when both use the QOpenGLWidget.

The black window only comes up when a 3d view and image view is opened at the same time. If you open and close a 3d view and then open an image view the problem doesn't come up.

Furthermore I found out that it's related to how QuarterWidget::paintEvent is implemented. When I use the paintEvent method of the base class QGraphicsView then the issue doesn't appear.

Btw, when moving to the new OpenGL classes then it's not only a matter of replacing QGLWidget with QOpenGLWidget. There are a few more classes to replace. Deprecated classes in QtOpenGL:
  • QGLBuffer => QOpenGLBuffer (not used)
  • QGLFunctions => QOpenGLFunctions (not used)
  • QGLShader => QOpenGLShader (not used)
  • QGLShaderProgram => QOpenGLShaderProgram (not used)
  • QGLColormap => ??? (not used)
  • QGLContext => QOpenGLContext (todo)
  • QGLFormat => QSurfaceFormat (todo)
  • QGLFramebufferObject => QOpenGLFramebufferObject (todo)
  • QGLFramebufferObjectFormat => QOpenGLFramebufferObjectFormat (todo)
  • QGLPixelBuffer => QOpenGLFramebufferObject (todo)
  • QGLWidget => QOpenGLWidget (todo)

Do you have a branch somewhere to test?

Not yet.
User avatar
f3nix
Posts: 213
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby f3nix » Sat Jan 28, 2017 5:42 pm

wmayer wrote:
f3nix wrote:I do not know if I understood correctly but I do not seem to get this problem. 3d views and images in image workbench seem to display ok.

Just to be clear the issue comes up with the image viewer ported to QOpenGLWidget while the Quarter viewer uses the QGLWidget. I haven't moved the Quarter viewer to the new QOpenGLWidget so far. So, maybe the issue is solved when both use the QOpenGLWidget.


Ok. Thanks. I was under the impression that both were already ported to QOpenGLWidget.

triplus wrote:P.S. Take your time no pressure whatsoever. :)


No. No pressure at all... :D

Cheers,
Mateusz
ian.rees
Posts: 529
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby ian.rees » Mon Mar 06, 2017 2:39 am

Just wanted to see if there's anything new with the Quarter viewer port to Qt5? I'd be glad to help out, but don't want to duplicate effort (or step on any toes). -Ian-
User avatar
f3nix
Posts: 213
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby f3nix » Mon Mar 06, 2017 4:08 pm

Hi Ian!
I have it sort of working but the code is not shareable yet... :/

After the introduction of VBO I'm getting some strange crashes with the Qt5 build. Will have to sort it out first.

So if You have time go for it (unless @wmayer would like to do it himself).

Cheers,
Mateusz
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby wmayer » Tue Mar 07, 2017 3:41 pm

On the OpenInventor mailing list somebody offered a Qt5 port of Quarter but IIRC he only replaced QGLWidget but not the other classes. Currently I am working on a solution working with typedefs. This way the conditional compilation is set to a minimum and only if the new QtOpenGL classes have a different API we need the #ifdef's.

I hope to push a branch soon.
User avatar
f3nix
Posts: 213
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby f3nix » Tue Mar 07, 2017 4:36 pm

wmayer wrote:I hope to push a branch soon.


Hi wmayer!
This is great news!
According to bblacey's testing this will fix at list these issues: issue #0001401, issue #0002953, issue #0002942 and at least one more that is not in the tracker.

Cheers,
Mateusz
blacey
Posts: 337
Joined: Tue Dec 08, 2015 11:28 pm

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby blacey » Tue Mar 07, 2017 6:12 pm

f3nix wrote:
wmayer wrote:I hope to push a branch soon.


Hi wmayer!
This is great news!
According to bblacey's testing this will fix at list these issues: issue #0001401, issue #0002953, issue #0002942 and at least one more that is not in the tracker.

Cheers,
Mateusz


Excellent @wmayer! As Mateusz said, based upon limited testing of Mateusz' proof-of-concept QOpenGLWidget branch, it will significantly improve the macOS user experience by squashing a number of known issues and actually make Qt5 very usable! No pressure, but once your branch is available and integrated, we will probably be able to drop the macOS Qt4 builds. Happy to help if you want or need any pre-integration testing on macOS.
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Postby wmayer » Wed Mar 08, 2017 6:26 pm

As also discussed in issue #2952 we have some major problems with OpenGL with Qt5. With Qt4 we had three options to create an image from the 3d view using off-screen rendering:
  1. QGLPixelBuffer: this gives (if supported by the HW/driver) the best results and supported anti-aliasing and handled transparencies pretty well
  2. QGLFramebufferObject: if the 1st option is not supported this option can be used. It also supports anti-aliasing but gives totally garbage for transparencies
  3. Coin's off-screen renderer: this method is independent of Qt stuff and internally also uses pixel buffers. Like the 1st option it also supports transparencies but doesn't offer a way to handle anti-aliasing.

Now with Qt5 it seems pixel buffer support has been completely dropped (at least I didn't find a way to get it back). Although with the deprecated OpenGL classes it's still offered by the API but internally it uses QGLFramebufferObject. This means we now have two sub-optimal solutions to create images.

So if someone knows if pixel buffer is possible with Qt5 tell me, please.

Now to the QOpenGL* port:
I have moved this branch https://github.com/wwmayer/FreeCAD/tree/qtopengl which at least compiles but the 3d view doesn't work at all. I guess it's related to our changes on the QuarterWidget class. So, if you create a new document then sometimes you can see the 3d window for a little moment but then the whole application becomes black.

At the moment at least the image viewer works fine.

If someone wants to test you have to set the option BUILD_QT5 of course and additionally the option FREECAD_USE_QTOPENGL_WIDGET which is off by default.

Currently there are some open points:
  • Get the 3d view working again (works with limitations)
  • Implement a way to get some information about OpenGL support at startup (done)
  • Find a replacement to get real pixel buffer support (done)
  • Find a replacement for qglColor (done)
  • Find a replacement for QGLWidget::renderText (done)
  • Find a replacement for QtGLWidget::convertToGLFormat (done)

Edit: for off-screen rendering it seems QOffscreenSurface is the way to go. And the good thing is that internally it uses pixel buffers if supported.