Results 1 to 10 of 10

Thread: Plotting with OpenGL, searching for best library to use

  1. #1
    Join Date
    Jul 2016
    Posts
    57
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Question Plotting with OpenGL, searching for best library to use

    I am completely new to Qt.

    I am looking to develop primarily instrumentation applications with a lot of heavy/fast plotting. As a result, I am looking for the graph/plotting library which nicely supports and fully utilizes OpenGL. As for licensing, it would be nicer if it was LGPL, but for those specific programs I don't mind sharing code so I might be fine with regular GPL. Here is what I found so far:

    QCustomPlot - OpenGL support is only planned in some future release, maybe few months from now maybe more. So, not considering it yet, even though their lib looks cool.

    Qwt - been around for a while, But I do not see from multiple threads on forums etc, that it actually fully utilizes OpenGL, and that it all works really well? There is even a Subforum for Qwt in this thread!

    QCharts - integrated with Qt 5.7, which is great, and it seems to have some OpenGL support.

    I do not know for sure, but I am kinda leaning to QCharts, what do you think? Are the plotting functions (2D/3D) are well written there and really speed up the plotting process? Is it faster than Qwt when it comes to 2D OpenGL accelerated plots?

    And maybe you know of any other alternative to QCharts which provides good OpenGL support?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,118
    Thanks
    235
    Thanked 656 Times in 646 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Plotting with OpenGL, searching for best library to use

    I have been looking for a fast, modern, Qt-based OpenGL scientific plotting library for a long, long time. QCustomPlot isn't it, neither is Qwt. QwtPlot3D is old OpenGL - doesn't use shaders, etc., so will run very slowly for large data sets with changing content. I had actually ported most of a java library (Jzy3D) into C++/Qt/OpenGL, but then gave up because it was also old, slow GL-based and would have been very difficult to port to GL with shaders.

    QCharts has been a big disappointment for me. I signed up and paid for a commercial license so I could use QCharts in my app, only to discover that the implementation made it impossible to extend the library to customize anything. The entire API is exposed as a set of classes with public, non-virtual interfaces and private, hidden classes where the actual code runs. There is absolutely no way to customize it, so you are stuck with whatever it gives you. And it is only 2-D.

    The Qt Data Visualization module has some promise, but it too has some severe restrictions in the implementation which make it difficult or impossible to customize.

    Qt 3D is equally hopeless. Although it also shows promise, there is absolutely nothing there yet to support scientific graphics.

    An example of what I mean by "customize":

    I need the ability to draw a scatterplot (either 2- or 3-D) where each dot is a small glyph, typically a circle. Each circle needs to be customizable with a different radius, fill color, and border color, so it needs six dimensions to describe it: x, y, z, radius, fill, and border. With either Qt Charts or Qt Data Visualization, each of these points would have to be put into its own "series", since only at the series level can you specify sizes and colors. Every dot in a series must have the same size and color. For a plot with thousands of dots, this is completely infeasible. If it were possible to customize the library like you can with Qt Graphics / View, I could simply define a new plottable item that could draw itself and I could parameterize it with as many properties as I needed. I've done this in 2-D with my own plotting widget based on Graphics / View, but it isn't OpenGL-based and can't be extended to 3-D.


    Right now I am looking at VTK. It is based on modern OpenGL and has an API that allows drawing in a Qt-hosted window, but it also looks like a huge learning curve to get anything useful.

    Good luck. Report back if you find anything.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2016
    Posts
    57
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    Well, I just decided to test drive some Qt Charts 2D plotter with use of OpenGL acceleration, I took this example: https://blog.qt.io/blog/2016/01/18/q...2-1-0-release/
    As you see on that 2nd from top snapshot, it has 55FPS shown in the window.

    For me, It was the same when i just ran the program, however; when i expanded it to full screen on my 4k monitor, my FPS dropped to 8! Why?
    I have extremely powerful PC, with GTX 980 graphics card, where I play latest DOOM game with 60FPS on 4k resolution.... why would simple 2D plotting program with 100'000 points have only 8 FPS on my full screen? So I assume Qt Charts is not the right tool for those who want fast performance with OpenGL and heavy load of data? right?

    I'll try to see the demo for Qt Data Visualisation and will skim through that VTK as well...

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,118
    Thanks
    235
    Thanked 656 Times in 646 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Plotting with OpenGL, searching for best library to use

    Don't get me wrong - Qt Charts is a great library if the functions it provides are good enough for your needs. I will certainly use it in the next release of my app for basic 2-D plotting needs because it looks so much better than I can do, and someone else has to support it.

    I don't know how much OpenGL "acceleration" Qt Charts is doing. I am pretty sure it isn't using shaders, so all of the computation is probably being done on the PC and not on the GTX card. I have a GTX 750 on a 4K monitor. When I run the CUDA demos, things like the smoke particle demo run nearly as fast full screen as they do in a smaller window, so I know my card isn't the limiting factor.

    VTK is hard. I have tried several times over the past 5 - 6 years to make a start at it, but the learning curve for even basic things is very hard. Sort of like learning OpenGL itself. There is no primitive that says, "Draw me an X axis from x0 to x1, with sensible divisions".

    I guess I could make some good money if I came up with a 3-D scientific plotting library based on Qt and OpenGL.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Jul 2016
    Posts
    57
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    Actually, i was just comparing it wrong, I set the amount of data points for the case when both accelerated/non accelerated portion of code used to be 100'000 and with UseOpenGL OFF, with small default window i get 0.5FPS with so much data (plus, the window is super slow at respnse like move and resize...), but once i turn OpenGL ON, i get 60FPS.

    I still get 8 FPS with OpenGL ON when on 4k full screen, however; it doesnt look slow, and application still responds.

    So...after this test, is it then safe to assume that Qt Charts actually DOES use my GTX 980? (Note that im using its very latest version which comes with Qt 5.7)

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,195
    Thanked 847 Times in 796 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    In general a Qt based plot package has to make the decision whether to use QPainter or to go with naked OpenGL - or to implement both.

    Considering, that generating PDFs is a mandatory functionality you have to have a QPainter based render engine and using the same render engine for screen is an obvious decision. In the past ( Qt4) there had been a fully hardware accelerated backend - the X11 paint engine. Nowadays there is only the OpenGL2 paint engine left, but the quality of its implementation is IMHO not comparable - a problem that will hit you with every package that does OpenGL over QPainter.

    Qwt in SVN trunk has the options to render a plot using one of the OpenGL paint engines ( using an OpenGL plot canvas ). If you like you can play with it but the code is not tested much.

    Uwe

  7. #7
    Join Date
    Jul 2016
    Posts
    57
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    Uwe,

    you wrote "a problem that will hit you with every package that does OpenGL over QPainter."
    So QT CHarts is doing OpenGL over QPainter?

    Another question to you is, does it mean that Qwt can achieve a much higher performance over QT Charts?

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,195
    Thanked 847 Times in 796 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    So QT CHarts is doing OpenGL over QPainter?
    QChart is derived from QGraphicsWidget, ...

    Another question to you is, does it mean that Qwt can achieve a much higher performance over QT Charts?
    The graphic stack of all packages you mentioned should be similar, beside, that Qt Charts seems to have the graphics view framework as an extra package on top.
    So concerning performance it is more a question of the algorithmic parts on top of the stack and how successful it is with sorting out unnecessary operations early.

    Without knowing more details I can't tell you how to do it best with Qwt. For Qt Chart - no idea - you could try to ask on the Qt mailing list, but I never saw any maintainer responding for this module there.

    Uwe

  9. #9
    Join Date
    Jul 2016
    Posts
    57
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    d_stranz,

    So how is it going for you now with VTK? How easy it is to integrate it with Qt? Have you already managed to do for example some basic Cosine plot with it in a Qt application? Could you share some details if you did, or links to guides maybe? because the guides I see online are not much into specifically doing it with Qt programs.

    Also, how efficient you think is openGL utilized in VTK? And is there big overhead in upper layer code?

  10. #10
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    363
    Thanks
    87
    Thanked 12 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Plotting with OpenGL, searching for best library to use

    Hello! I'm a computer scientist with a similar problem, I also have to plot a lot of data in 2D and 3D for experimentation and presentation. After walking down this road for a while and not finding anything overly convincing, I ended up implementing my own little "framework" based on QPainter for 2D plotting and OpenGL for 3D plotting. Since I always plot graphs of time sequenced data, all I needed for 2D plotting is a QPainter and drawing lines. I made it as fast as can be by culling data that is not on the screen, and skipping lines that would draw into the same pixel as previously drawn lines. I added a few features for scaling and translating the plot widget and individual curves, and have been happily using this nifty little tool now for five years with almost no changes to the code. For generating PDFs and plots of conference papers, I export the relevant data and use gnuplot. For 3D plotting I use libQGLViewer to set up a camera-manipulatable plotting environment, and write OpenGL code for pretty much every individual plot. This doesn't take much time, say one hour development time per plot, not significantly more than you would need when using the interface of a well documented library. In my case I find that 3D plots are usually individual to the problem and most of the time spent on them is lost in thinking about what actually one wants to see, and what one does not, in order to be able to read conclusions out of a plot. Drawing points, lines, spheres, or quadrangles in OpenGL is pretty easy, it is the things around it (setting up a window and the OpenGL environment) that may be challenging for a beginner.

Similar Threads

  1. Replies: 2
    Last Post: 21st January 2016, 17:16
  2. Qt Creator Using alternate openGL library/header files in QT Creator
    By Willybood in forum Qt Tools
    Replies: 2
    Last Post: 24th May 2011, 09:06
  3. Replies: 1
    Last Post: 3rd February 2011, 10:38
  4. QAbstractListModel searching.
    By ComaWhite in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2009, 18:41
  5. Searching in a list.
    By kaushal_gaurav in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2008, 08:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.