Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by vocx »

maxlem wrote: Sat Jul 27, 2019 10:08 pm ...
I followed https://www.freecadweb.org/wiki/CompileOnUnix for ubuntu, used the daily ppa, but qt4/python2 instructions have been removed. I installed the single command qt5 build instruciton and tried anyway.

cmake failed to find shiboken.

...
You shouldn't try to compile using Python 2 and Qt4, as both of them are essentially obsolete. If you tried installing the freecad-daily packages you should be aware that currently there are two versions of FreeCAD, one for Python 2/Qt4, and one for Python 3/Qt5. The first one is just for compatibility purposes, but it is assumed that in a new installation you'd have the Python 3/Qt5 version.

If CMake didn't find Shiboken, this could be a case that you have some Python 2 files installed, or that you didn't specify the options to use Python 3 and Qt5. I suggest you double check that you don't have any Python 2 packages and try again.

Code: Select all

freecad-python2
libfreecad-python2-0.18
freecad-daily-python2
libfreecad-daily-python2-0.19
I recently rewrote many parts of the CompileOnUnix page, particularly for Ubuntu, and tested that the compilation worked okay. After some trial and error, I didn't have any problems compiling; you just need to be sure you have the dependencies needed for Python3 and Qt5.

Code: Select all

sudo apt install cmake cmake-gui libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-thread-dev libcoin-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libopencv-dev libproj-dev libpyside2-dev libqt5opengl5-dev libqt5svg5-dev libqt5webkit5-dev libqt5x11extras5-dev libqt5xmlpatterns5-dev libshiboken2-dev libspnav-dev libvtk7-dev libx11-dev libxerces-c-dev libzipios++-dev occt-draw pyside2-tools python3-dev python3-matplotlib python3-pivy python3-ply python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtsvg python3-pyside2.qtwidgets python3-pyside2uic qtbase5-dev qttools5-dev swig
Then, inside a build directory, it's as simple as

Code: Select all

cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 ../freecad-source
make -j3
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
maxlem
Posts: 26
Joined: Fri Jul 26, 2019 2:32 am

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by maxlem »

Thanks vocx,

The errors I encountered were when I tried to build ickby's latest rebase, which is "2617 commits behind FreeCAD:master.". I don't think I would have an issue building master's head.

That said, thanks for the hints but I don't plan to spend effort managing to build the old qt4 stuff. I will use ickby's effort as an inspiration, probably reusing some QML if possible. I will also study how he interacted with FreeCAD's core to achieve what he did.

I should have a bit of time to work on this over the next few days. It will be quite long before I can show results.
maxlem
Posts: 26
Joined: Fri Jul 26, 2019 2:32 am

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by maxlem »

Ok, so, I did study the first few commits made by ickby

https://github.com/ickby/FreeCAD_sf_mas ... its/layout

I learn that FreeCAD is based on Quarter, a Qt-wrapper for Coin3D.

I notice that ickby had to modify the source of QuarterWidget.cpp, which is part of Coin3D/quarter but at the time, had been embedded in FreeCAD source (not as a git submodule iiuc)

https://bitbucket.org/Coin3D/quarter/sr ... Widget.cpp

I don't know what to do of this.

I also found some 2018 discussion about using a packaged version of Quarter.

This all leads me to think that if I'm not getting help to my first "hello world, qtquick2" I WILL do it all wrong. I need someone who knows the codebase well enough to help me plug my code in the right place.

So here's my plan:

- Like ickby, I will want to replace MDI's center widget with my own
- I will use https://doc.qt.io/qt-5/qwidget.html#cre ... wContainer
- In there I will embed my QWindow, and this QWindow will be filled with my QQuickFramebufferObject derivation instance
- QQuickFramebufferObject always has a companion QQuickFramebufferObject::Renderer instance which is called from the rendering thread
- in this QQuickFramebufferObject::Renderer derivation, I will overload the virtual QQuickFramebufferObject::Renderer::render() and that is where I must call the actual opengl stuff.
- One thing that must be understood, is that QtQuick2 is NOT QPainter-based.
- Then, I wonder, is Quarter still pertinent for my use case. I think not. I think the right thing to do is to call Coin3D directly. I basically need a QtQuick version of Quarter.
- So that leads me to think that I'm on the wrong forum


Please enlighten me friends!
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by kkremitzki »

Is the change to Quarter still needed with the current upstream? It's had some development activity recently.

If it is still needed, could we upstream the change needed to support what you're doing? If you think it's a reasonable thing to try to upstream, I can assist with that.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
maxlem
Posts: 26
Joined: Fri Jul 26, 2019 2:32 am

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by maxlem »

Well as I ended up concluding, I think my best bet is to bypass Quarter altogether and go straight to Coin3D.

Why?

Quarter wraps Coin3D in a QPainter-based QWidget. QtQuick2 is neighter QPainter nor QWidget based. I will wrap my qtquick2 QWindow in a QWidget's QWindow container, but I will do everything in a QQuickFramebufferObject::Renderer instance, and there, we are outside QWidget's territory. So as I said, I think Quarter is useless to me. It's the wrong wrapper, plain and simple. Using it in a QtQuickItem would almost be almost as pointless as using the GTK wrapper code.

What I need is
A) the opengl calls (note that inside QQuickFramebufferObject::Renderer::render, the active render target will be a texture, if Coin3D is well done, that should not matter)
B) the even mapping (that's pretty much what Quarter does, but the QtQuick Events are a different set of classes)
C) guidance. I promise I will walk on my own as soon as I see the light, that is: Coin3D rendering properly, events back'n'forth (picking, etc)
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by kkremitzki »

Interesting! Wouldn't one downside of this approach be that, unlike ickby's approach, the existing UI could not be partially reused? That might be a fine trade-off to make some progress, though.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
maxlem
Posts: 26
Joined: Fri Jul 26, 2019 2:32 am

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by maxlem »

Frankly, I can't say, but I suspect everything but central widget will work as before. In the end both QWidget and QWindow are based on QObject, Q_PROPERTY, signals and slots. So everything *can* play nice. The Quarter thingy is really just a bridge to map qt mouse and keyboard events to Coin3D, and to tell Coin3D where to render on the screen (inside the qwidget paint area). But I'm looking at things from very far. I'd love someone who knows to confirm me that.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by ickby »

A few thougth from my side:
- Like ickby, I will want to replace MDI's center widget with my own
Thats the way to go, to redefine the MDIView so it can handle the QML stuff. However, IMHO you don't want to replace FreeCADs MDIView implementation, but change it. The reason for this is the deep integration of MDIVIew and MDIViewPage into freecad documents and viewproviders. Basically you want to make sure the MDIView API stays untouched, but generates the correct QML stuff instead of the Widget stuff. That would be the most minimalistic change. But, to be honest, i'm not sure if this is easily possible when not using widgets (especially if one wants to support both, old and new interface).

- Then, I wonder, is Quarter still pertinent for my use case. I think not. I think the right thing to do is to call Coin3D directly. I basically need a QtQuick version of Quarter.
Sound very much like you can drop it. If you don't use a QGLWidget of any kind than quarter is not needed. The link I gave above for the View3dInventorViewer shows how to render to a Framebuffer, that can be done completely without quarter.

From a breif view I think you will run into some problems not using the widget approach, as this idea that there is an widget is used everywhere in the code, many segments work with this as assumption. Maybe it makes sense to abstract the MDIView, MDIViewPage and the View3dViewer more, so that everything outside of those classes do not touch or use any Qwidget spezific functionality. Than it would be easier to switch to annother implementation. The advantage of doing the abstraction first is that you can easily check if something is broken or still works :)

Good luck with your work, I will help out whereever I can!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by Kunda1 »

@maxlem thank you for digging in to this. :)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Alternative GUI for FreeCAD: Overlayed Layout (Devs needed)

Post by Kunda1 »

maxlem wrote: Sun Aug 04, 2019 2:15 am
Any progress in to this endeavor ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply