arrayfire / forge

High Performance Visualization
224 stars 48 forks source link

Add qt5 support #134

Closed caseymcc closed 5 years ago

caseymcc commented 7 years ago

Added qt5 support and a CPU example that opens 2 windows. The Qt5 support opens the first window as a QMainWindow, all the remaining windows are opened as QDockWidgets in floating mode. This allows them to be docked if the user wished.

image

image

9prady9 commented 7 years ago

@caseymcc It is nice to have Qt5 as another backend. I believe std::make_unique is not available until C++14 which is causing compilation errors in src/backend/opengl/qt5/window.cpp. Can you please fix them. forge uses C++11 standard as of now.

Edit: I am using Ubuntu 16.04 with GCC 5.4.

caseymcc commented 7 years ago

Updated it, I'm using VS2015 so there could be all kinds of compile issues I am not seeing.

caseymcc commented 7 years ago

Also I am currently adding a Qt widget to the code that can be used inside other qt windows (and mainly inside the qt event loop). By default I am providing functionality to let it be drawn outside of the main Qt UI thread as most of the stuff I work on is already threaded in this manner (UI is separate from OpenGL rendering). So it may end up looking oddly coded but I will also allow the default to be drawn from the ui thread.

I am adding the widget to the API but only when a cmake option is on.

9prady9 commented 7 years ago

@caseymcc I was able to build the library and examples with latest changes, however the new example you added is crashing on linux with the following stack trace.

#12 0x00007ffff780dccb in forge::wtk::Widget::Widget(int, int, char const*, forge::wtk::Widget const*, bool) () from /home/pradeep/gitroot/forge/build_qt5/src/backend/opengl/libforge.so.0
#13 0x00007ffff780c3a4 in forge::opengl::window_impl::window_impl(int, int, char const*, std::weak_ptr<forge::opengl::window_impl>, bool) ()
   from /home/pradeep/gitroot/forge/build_qt5/src/backend/opengl/libforge.so.0
#14 0x00007ffff77cd29e in fg_create_window () from /home/pradeep/gitroot/forge/build_qt5/src/backend/opengl/libforge.so.0
#15 0x00007ffff77d840e in forge::Window::Window(int, int, char const*, forge::Window const*, bool) () from /home/pradeep/gitroot/forge/build_qt5/src/backend/opengl/libforge.so.0
#16 0x00000000004011e6 in main ()

Also, we maintain a few consistent features across windowing toolkits that we support such as close window on hitting esc key etc. You can look at the glfw/window.cpp and sdl2/glfw.cpp for reference.

caseymcc commented 7 years ago

What about the regular example (not including multiple windows)?

You going to end up making me bust out my Ubuntu VM and enter the bane of my existence GDB. :)

9prady9 commented 7 years ago

Other examples ran but they don't have the standard key stroke responses I explained earlier such as closing the window upon on hitting ESC.

9prady9 commented 7 years ago

build forge windows ci

caseymcc commented 7 years ago

Added key/mouse events, it should match up to the rest. I removed the multiWindow example as I don't have the time to debug it for the moment. (my Ubuntu VM does not have GPU support so will have to setup an Ubuntu machine before I debug it)

9prady9 commented 7 years ago

@caseymcc I think the code is broken now - it used to compile earlier though. Following is the error.

In file included from /home/pradeep/gitroot/forge/src/backend/opengl/window_impl.hpp:19:0,
                 from /home/pradeep/gitroot/forge/src/backend/window.hpp:13,
                 from /home/pradeep/gitroot/forge/src/backend/handle.hpp:14,
                 from /home/pradeep/gitroot/forge/src/api/c/font.cpp:12:
/home/pradeep/gitroot/forge/src/backend/opengl/qt5/window.hpp:51:25: error: extra qualification ‘forge::wtk::Widget::’ on member ‘findTransform’ [-fpermissive]
         const glm::mat4 Widget::findTransform(const MatrixHashMap& pMap, const float pX, const float pY);
                         ^
/home/pradeep/gitroot/forge/src/backend/opengl/qt5/window.hpp:53:14: error: extra qualification ‘forge::wtk::Widget::’ on member ‘setTransform’ [-fpermissive]
         void Widget::setTransform(MatrixHashMap& pMap, const float pX, const float pY, const glm::mat4 &pMat);
              ^
9prady9 commented 6 years ago

@caseymcc If you don't mind, can you please rebase from master after https://github.com/arrayfire/forge/pull/150 is merged and push your additions. Thank you.

caseymcc commented 6 years ago

updated, but it is built on top of the Hunter PR (https://github.com/arrayfire/forge/pull/155)

9prady9 commented 6 years ago

@caseymcc Would it possible for you to send the Qt5 PR without hunter commit ? as the hunter commit hasn't been completely tested out yet. I don't that to keep the Qt5 support pending as both are unrelated. If everything checks out fine with Qt5 support, I want to merge this in.

9prady9 commented 6 years ago

@caseymcc Can you please rebase this from master and remove the hunter commit.

9prady9 commented 6 years ago

@caseymcc Thanks, I will need to test this offline as the CI jobs don't have Qt5 backend yet.

9prady9 commented 6 years ago

@caseymcc What is the minimum Qt version that is required ?

9prady9 commented 6 years ago

I was able to compile it successfully after setting the following cmake variables in CMake-GUI.

When I tried to run an example, I got the following error. @caseymcc Have you seen such error while working on Qt Support ? entry_point

I did a fresh install of Qt5 and added the C:\Qt\5.10.0\msvc2017_64\bin to my PATH variable. Should I be adding anything else ?

caseymcc commented 6 years ago

I was testing with 5.9.3, maybe some update in 5.10.X has changed. I know the QGLWidget has been deprecated so it maybe related to that. I wont be able to look at it today, maybe over the weekend I can check it out.

caseymcc commented 6 years ago

Finally got around to testing with 5.10.0 and I have no issues. I am curious if for some reason you maybe be linking against a different version than you are running against?

image

caseymcc commented 6 years ago

I just noticed you are using VS2017, I haven't tested on that at all. I am using VS2015.

caseymcc commented 6 years ago

Upon reading your error some more if you are using VS2015 (you reference "added the C:\Qt\5.10.0\ msvc2015_64 \bin to my PATH variable") however your error lists "D:\Qt:5.10.0\ msvc2017_64 \bin\Qt5OpenGL.dll"

If this is true looks like you are linking against one and running against another.

9prady9 commented 6 years ago

@caseymcc Thanks for looking into it. I will recheck on my windows platform.

On arch linux, it builds out of the box but examples are seg faulting for some reason. I haven't looked into it yet. If you get a chance, please try running examples on any linux distro and let me know how that goes. Below is the stack trace in case you look into it.

#0  0x00007ffff6c9ae36 in __strlen_sse2 () at /usr/lib/libc.so.6
#1  0x00007ffff2ee97cd in QCoreApplication::arguments() () at /usr/lib/libQt5Core.so.5
#2  0x00007fffed5f46c2 in  () at /usr/lib/libQt5XcbQpa.so.5
#3  0x00007fffed5f4be7 in QXcbIntegration::wmClass() const () at /usr/lib/libQt5XcbQpa.so.5
#4  0x00007fffed60c5d5 in QXcbWindow::create() () at /usr/lib/libQt5XcbQpa.so.5
#5  0x00007fffed5f5d22 in QXcbIntegration::createPlatformWindow(QWindow*) const () at /usr/lib/libQt5XcbQpa.so.5
#6  0x00007ffff3460ece in QWindowPrivate::create(bool, unsigned long long) () at /usr/lib/libQt5Gui.so.5
#7  0x00007ffff4388256 in QGLContext::chooseContext(QGLContext const*) () at /usr/lib/libQt5OpenGL.so.5
#8  0x00007ffff4386c17 in QGLContext::create(QGLContext const*) () at /usr/lib/libQt5OpenGL.so.5
#9  0x00007ffff43849d9 in QGLWidget::setContext(QGLContext*, QGLContext const*, bool) () at /usr/lib/libQt5OpenGL.so.5
#10 0x00007ffff4386f73 in QGLWidgetPrivate::initContext(QGLContext*, QGLWidget const*) () at /usr/lib/libQt5OpenGL.so.5
#11 0x00007ffff4387249 in QGLWidget::QGLWidget(QWidget*, QGLWidget const*, QFlags<Qt::WindowType>) () at /usr/lib/libQt5OpenGL.so.5
#12 0x00007ffff7901adf in forge::wtk::Widget::initWindow(int, int, char const*, forge::wtk::Widget const*) () at /home/pradeep/gitroot/forge/worktrees/qt5/build/src/backend/opengl/libforge.so
#13 0x00007ffff79021a3 in forge::wtk::Widget::Widget(int, int, char const*, forge::wtk::Widget const*, bool) () at /home/pradeep/gitroot/forge/worktrees/qt5/build/src/backend/opengl/libforge.so
#14 0x00007ffff78ff5ea in forge::opengl::window_impl::window_impl(int, int, char const*, std::weak_ptr<forge::opengl::window_impl>, bool) ()
    at /home/pradeep/gitroot/forge/worktrees/qt5/build/src/backend/opengl/libforge.so
#15 0x00007ffff7915b85 in fg_create_window () at /home/pradeep/gitroot/forge/worktrees/qt5/build/src/backend/opengl/libforge.so
#16 0x00007ffff791fd9e in forge::Window::Window(int, int, char const*, forge::Window const*, bool) () at /home/pradeep/gitroot/forge/worktrees/qt5/build/src/backend/opengl/libforge.so
9prady9 commented 6 years ago

@caseymcc I have rechecked on windows, I must mistakenly pasted 2015 VS path in the above comment. I have corrected the comment now. I used VS2017 for compiling and I have VS2017 dlls in my path.

This is what is happening, in Debug mode I am able to see the rendering. However, none of the GUI controls like pan, zoom are working. I ran bubblechart example, which is 2D, and we can pan/zoom with GLFW or SDL2. The error I have shown is in release mode, try release mode build.

9prady9 commented 6 years ago

@caseymcc Were you able to get back to this ?

9prady9 commented 6 years ago

@caseymcc Did you get a chance to look into again ?

caseymcc commented 6 years ago

Sorry, been busy. Will see if I can look at it this week.

9prady9 commented 5 years ago

@caseymcc Closing this for now due to inactivity and since you probably need to update your branch from latest master as well. Feel free to reopen the PR when the changes are ready and running successfully.