Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

  1. #1
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Hi.

    I need to port the Qwt build system from the qmake to QBS in my project. Previous Qwt stable version 6.2.0 was compiled successfully on any Linux. But now I have updated it to the version from the trunk r2921.

    And right now compilation fails with following errors:

    /usr/bin/g++ -g -O0 -Wall -Wextra -m64 -pipe -fexceptions -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -DQWT_MOC_INCLUDE=1 -DQWT_NO_SVG -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_PRINTSUPPORT_LIB -DQT_SVG_LIB -I/home/denis/Documents/Projects/project-git/project/src/libs -I/opt/Qt/5.9.6/gcc_64/include -I/opt/Qt/5.9.6/gcc_64/include/QtConcurrent -I/opt/Qt/5.9.6/gcc_64/include/QtCore -I/opt/Qt/5.9.6/gcc_64/mkspecs/linux-g++ -I/home/denis/Documents/Projects/project-git/build-project-desktop-debug/qtc_Desktop_Qt_5_9_6_GCC_64bit_Debug/qwt.91a462ca/qt.headers -I/opt/Qt/5.9.6/gcc_64/include/QtGui -I/opt/Qt/5.9.6/gcc_64/include/QtOpenGL -I/opt/Qt/5.9.6/gcc_64/include/QtWidgets -I/opt/Qt/5.9.6/gcc_64/include/QtPrintSupport -I/opt/Qt/5.9.6/gcc_64/include/QtSvg -std=c++14 -o /home/denis/Documents/Projects/project-git/build-project-desktop-debug/qtc_Desktop_Qt_5_9_6_GCC_64bit_Debug/qwt.91a462ca/3a52ce780950d4d9/qwt_plot.cpp.o -c /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp
    In file included from /opt/Qt/5.9.6/gcc_64/include/QtCore/qmetatype.h:49:0,
    from /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot_item.h:14,
    from /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot_dict.h:15,
    from /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.h:14,
    from /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp:10:
    /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp: In function ‘void qwtEnableLegendItems(QwtPlot*, bool)’:
    /opt/Qt/5.9.6/gcc_64/include/QtCore/qobjectdefs.h:271:35: error: initializer fails to determine size of ‘sig’
    # define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp:29:24: note: in expansion of macro ‘SIGNAL’
    const char sig[] = SIGNAL(legendDataChanged(QVariant,QList<QwtLegendD ata>));
    ^~~~~~
    /opt/Qt/5.9.6/gcc_64/include/QtCore/qobjectdefs.h:271:35: error: array must be initialized with a brace-enclosed initializer
    # define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp:29:24: note: in expansion of macro ‘SIGNAL’
    const char sig[] = SIGNAL(legendDataChanged(QVariant,QList<QwtLegendD ata>));
    ^~~~~~
    /opt/Qt/5.9.6/gcc_64/include/QtCore/qobjectdefs.h:270:35: error: initializer fails to determine size of ‘slot’
    # define SLOT(a) qFlagLocation("1"#a QLOCATION)
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp:30:25: note: in expansion of macro ‘SLOT’
    const char slot[] = SLOT(updateLegendItems(QVariant,QList<QwtLegendDat a>));
    ^~~~
    /opt/Qt/5.9.6/gcc_64/include/QtCore/qobjectdefs.h:270:35: error: array must be initialized with a brace-enclosed initializer
    # define SLOT(a) qFlagLocation("1"#a QLOCATION)
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
    /home/denis/Documents/Projects/project-git/project/src/libs/qwt/qwt_plot.cpp:30:25: note: in expansion of macro ‘SLOT’
    const char slot[] = SLOT(updateLegendItems(QVariant,QList<QwtLegendDat a>));
    ^~~~
    Process failed with exit code 1.
    My env is:

    * Ubuntu 18.04 LTS 64 bit
    * GCC 7.3.0
    * Qt official 5.9.6

    PS: Hovewer on Windows it compiles successfully with MSVC2015 32-bit && Qt 5.9.6.

  2. #2
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    I compiled the file with your options on my box without problems, but on my box it is a gcc 7.3.1.

    What happens, when changing the offending lines from:

    Qt Code:
    1. const char sig[] = ...
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. const char* sig = ...
    To copy to clipboard, switch view to plain text mode 

    Or do you see another way to change the code to work around the compiler issue - bside writing the SIGNAL/SLOT signatures twice ?

    Uwe

    PS1: your compiler flags differ from those you find in qwtbuild.pri. At least -fno-math-errno -funsafe-math-optimizations should have an impact on the performance, when using methods from cmath. Also you should use a higher optimization level.
    PS2: do you see an effect on your CPU usage, when enabling QwtPlotCurve::FilterPointsAggressive ?

  3. #3
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    > What happens, when changing the offending lines from:

    Yes, many thanks, with:

    Qt Code:
    1. const char* sig = ...
    To copy to clipboard, switch view to plain text mode 

    it is successfully compiled.

  4. #4
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Weird - seems to be a compiler bug of gcc 7.3.0.

    I will adjust the code - thanks for reporting,

    Uwe

  5. #5
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Weird - seems to be a compiler bug of gcc 7.3.0.
    Same happens and with ARM Linaro GCC 5.4.1, and with ARM GCC 6.3.

    PS1: your compiler flags differ from those you find in qwtbuild.pri. At least -fno-math-errno -funsafe-math-optimizations should have an impact on the performance, when using methods from cmath. Also you should use a higher optimization level.
    PS2: do you see an effect on your CPU usage, when enabling QwtPlotCurve::FilterPointsAggressive ?
    I have added QwtPlotCurve::FilterPointsAggressive for each of 8 curves and to add the -fno-math-errno -funsafe-math-optimizations with -O2, but nothing changes. The CPU load still stays in range 36-50% (on iMX6 with X11 && xcb backend).

    PS: My plotting area has 1280x800 pixels, and updates every ~100 msec and has ~400 samples with each update.


    Added after 40 minutes:


    A high GPU loading ~40% stays even if I just periodically update the interest interval without of samples (when the X-axis with a grid moves left).
    Last edited by kuzulis; 30th August 2018 at 16:08.

  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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Quote Originally Posted by kuzulis View Post
    Same happens and with ARM Linaro GCC 5.4.1, and with ARM GCC 6.3.
    I also tried the other gcc versions on my box ( f.e 6.2.1 ) without any problems. So it might be related to any of your compiler option. Maybe you can play with them - even if we already have a workaround it would be good to know where to be careful.
    Quote Originally Posted by kuzulis View Post
    PS: My plotting area has 1280x800 pixels, and updates every ~100 msec and has ~400 samples with each update.
    Oh boy - this is almost nothing and of course any sort of point reduction algos will have no effect when having almost no samples.

    Concerning the raster paint engine: disabling antialiasing and using a pen width <= 1 are common ways to speed it up.

    What numbers do you see when using a QOpenGLWidget instead of a QWidget with your test program you have posted to the devel mailing list. When running it with an update rate ~100ms you can at least see how much of it is related to Qwt. I would also try to run your test with an FBO and QImage to get an idea how much time the rendering takes and what is related to the rest of your graphics pipeline.

    Uwe

  7. #7
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    I also tried the other gcc versions on my box ( f.e 6.2.1 ) without any problems.
    Yes, I'm too have no any issues using qmake projects.

    So it might be related to any of your compiler option.
    I thought that need to use the GNU extension -std=gnu++xxx (maybe qmake uses it),
    but results with QBS and this option is not success (same error).

    But ok, I will use that workaround with const char*.

    What numbers do you see when using a QOpenGLWidget instead of a QWidget
    I will try test it tomorrow...

  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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Quote Originally Posted by kuzulis View Post
    I thought that need to use the GNU extension -std=gnu++xxx (maybe qmake uses it),
    but results with QBS and this option is not success (same error).
    This is not a matter of qmake vs. QBS. It is about compiling with different options and I would really like to know which of your compiler options is responsible.

    Actually I already checked with the options that can be seen on your original posting - without running into a compiler error. So could you please play with these options by comparing them with those you get from the qmake build environment until we know. When removing "CONFIG += silent" from qwtbuild.pri you can see the usual build options.

    Uwe

  9. #9
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    What numbers do you see when using a QOpenGLWidget instead of a QWidget
    I have checked following test example:

    Qt Code:
    1. #include <QApplication>
    2. #include <QOpenGLWidget>
    3. #include <QPaintEvent>
    4. #include <QPainter>
    5.  
    6. class Widget final : public QOpenGLWidget
    7. {
    8. public:
    9. explicit Widget(QWidget *parent = nullptr);
    10. private:
    11. void paintEvent(QPaintEvent *event) final;
    12. void timerEvent(QTimerEvent *event) final;
    13. };
    14.  
    15. Widget::Widget(QWidget *parent)
    16. : QOpenGLWidget(parent)
    17. {
    18. startTimer(100);
    19. }
    20.  
    21. void Widget::paintEvent(QPaintEvent *event)
    22. {
    23. QPainter p(this);
    24.  
    25. static bool toggled = false;
    26. const auto color = (toggled) ? QColor(Qt::red) : QColor(Qt::green);
    27. const auto rect = event->rect();
    28. p.fillRect(rect, color);
    29. toggled = !toggled;
    30. }
    31.  
    32. void Widget::timerEvent(QTimerEvent *event)
    33. {
    34. Q_UNUSED(event);
    35. update();
    36. }
    37.  
    38. int main(int argc, char *argv[])
    39. {
    40. QApplication app(argc, argv);
    41.  
    42. Widget w;
    43. w.setMinimumSize(1280, 800);
    44. w.show();
    45. return app.exec();
    46. }
    To copy to clipboard, switch view to plain text mode 

    on iMX6 with Qt5 && X11 && xcb backend, and I got less than 2% of CPU loading (in non-optimized debug mode). Then I have speed up it to 50 msecs and I have same < 2%.


    Added after 25 minutes:


    But with this simple Qwt code I got ~50% CPU loading (as with "xcb'' and "eglfs" backends):

    Qt Code:
    1. #include <QApplication>
    2. #include <QDateTime>
    3. #include <QPen>
    4. #include <QTimer>
    5.  
    6. #include <qwt/qwt_interval.h>
    7. #include <qwt/qwt_plot.h>
    8. #include <qwt/qwt_plot_grid.h>
    9. #include <qwt/qwt_plot_opengl_canvas.h>
    10. #include <qwt/qwt_scale_draw.h>
    11. #include <qwt/qwt_text.h>
    12.  
    13. class TimeScaleDraw final : public QwtScaleDraw
    14. {
    15. private:
    16. QwtText label(double v) const final;
    17. };
    18.  
    19. QwtText TimeScaleDraw::label(double v) const
    20. {
    21. const auto dt = QDateTime::fromMSecsSinceEpoch(qint64(v));
    22. const auto text = dt.time().toString();
    23. return text;
    24. }
    25.  
    26. int main(int argc, char *argv[])
    27. {
    28. QApplication app(argc, argv);
    29.  
    30. QwtPlot plot;
    31.  
    32. const auto canvas = new QwtPlotOpenGLCanvas;
    33. canvas->setCursor(QCursor());
    34. canvas->setFrameStyle(QFrame::NoFrame);
    35. plot.setCanvas(new QwtPlotOpenGLCanvas);
    36.  
    37. const auto grid = new QwtPlotGrid;
    38. grid->enableXMin(true);
    39. grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
    40. grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    41. grid->attach(&plot);
    42.  
    43. // Configure X-axis.
    44. const auto xScaleDraw = new TimeScaleDraw;
    45. plot.setAxisScaleDraw(QwtPlot::xBottom, xScaleDraw);
    46. const QwtText xAxisName(QObject::tr("Time"), QwtText::PlainText);
    47. plot.setAxisTitle(QwtPlot::xBottom, xAxisName);
    48. plot.setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignCenter | Qt::AlignBottom);
    49.  
    50. // Configure Y-axis
    51. plot.setAxisScale(QwtPlot::yLeft, 0, 65535);
    52. const QwtText yAxisName(QObject::tr("RAW"), QwtText::PlainText);
    53. plot.setAxisTitle(QwtPlot::yLeft, yAxisName);
    54.  
    55. QTimer timer;
    56. QObject::connect(&timer, &QTimer::timeout, [&]() {
    57.  
    58. const auto kWindowInterval = 20000; // 20 seconds
    59. const auto maximum = QDateTime::currentMSecsSinceEpoch();
    60. const auto minimum = maximum - kWindowInterval;
    61.  
    62. plot.setAxisScale(QwtPlot::xBottom, minimum, maximum);
    63. plot.replot();
    64. });
    65.  
    66. timer.start(100);
    67. plot.showFullScreen();
    68.  
    69. return app.exec();
    70. }
    To copy to clipboard, switch view to plain text mode 

    But, in this case I have a black color of OpenGL canvas by unknown reason.
    Last edited by kuzulis; 31st August 2018 at 10:23.

  10. #10
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Well the plot example has to paint the axes and the grid for each frame. The grid lines are done by the OpenGL paint engine, while the axes are done by raster.
    So you could check what happens, when using no grid lines or when using a solid pen. Another check might be to disable the tick labels ( QwtAbstractScaleDraw::enableComponent ) - rendering text is an expensive operation.

    Uwe

    The black content might be related to the fact, that your code creates 2 OpenGl canvases ?

  11. #11
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    The black content might be related to the fact, that your code creates 2 OpenGl canvases ?
    Where is two OpenGl canvases ?

    The grid lines are done by the OpenGL paint engine, while the axes are done by raster.
    What if try to derive the QwtPlot from the QOpenGLWidget?

    UPD: When I have replaced the QFrame with QOpenGLWidget (it is QwtPlot deriving) then I got a funny colored plotting with all rainbow and also the CPU loading ~12% instead of previous ~0% on Windows.
    Last edited by kuzulis; 31st August 2018 at 14:29.

  12. #12
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Where is two OpenGl canvases ?.
    The posted code creates a canvas, but the setCanvas call assigns a second one also created by new.

    What if try to derive the QwtPlot from the QOpenGLWidget?[
    QwtPlot is a composite widget, that consists of other widgets: title/footer + 4 scales + canvas + legend ( usually with widgets as legend items ).

    So all of them need to be derived from QOpenGLWidget, what is only possible by patching Qwt code.
    You might also need to replace some QPixmaps by QOpenGLFramebufferObjects.

    Before working on qskinny ( https://github.com/uwerat/qskinny ) I played with the idea of a widget library on top of QOpenGLWidget to get the benefits of hardware accelerated graphics without suffering from the downsides of JavaScript. But I had to give up because of fundamental problems: see https://bugreports.qt.io/browse/QTBUG-50916.

    But using the OpenGl paint engine does not mean, that everything is hardware accelerated. OpenGL does not support the complete set of primitives you can define with QPainter and the process of translating them to something OpenGL can handle is done by the CPU. F.e I once compared rendering our SVG icons to a QImage + translating it to a FBO, with another implementation, that painted directly to the FBO using the OpenGL paint engine ( see https://github.com/uwerat/qskinny/bl.../Benchmark.cpp ). At that time the second implementation was not faster, what might indicate, that the tesselation took almost the same time as the actual rendering.

    That said: it's worth to check if the text labels or creating the dots are a factor.

    Uwe

  13. #13
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    The posted code creates a canvas, but the setCanvas call assigns a second one also created by new.
    Oops.. But in result (after I fixed this), the canvas area still is black.

    That said: it's worth to check if the text labels or creating the dots are a factor.
    When I have disabled the grid creation:

    Qt Code:
    1. // const auto grid = new QwtPlotGrid;
    2. // grid->enableXMin(true);
    3. // grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
    4. // grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    5. // grid->attach(&plot);
    To copy to clipboard, switch view to plain text mode 

    or to use a solid grid lines:

    Qt Code:
    1. const auto grid = new QwtPlotGrid;
    2. grid->enableXMin(true);
    3. grid->setMajorPen(QPen(Qt::gray, 0, Qt::SolidLine));
    4. grid->setMinorPen(QPen(Qt::gray, 0, Qt::SolidLine));
    5. grid->attach(&plot);
    To copy to clipboard, switch view to plain text mode 

    the CPU load decreased from ~50% to ~36%. But I don't see those grid lines anyway, as my canvas is black.

    QwtPlot is a composite widget, that consists of other widgets: title/footer + 4 scales + canvas + legend ( usually with widgets as legend items ).
    Yes, then I try to replace this elements to QOpenGLWidget sequentially, maybe it will be enough to replace the scales only.


    Added after 11 minutes:


    Yes, then I try to replace this elements to QOpenGLWidget sequentially, maybe it will be enough to replace the scales only.
    Sadly.. It does not work at all.. I got a colored artifacts and a huge ~10% CPU load even on Windows (even if I comments out the
    Qt Code:
    1. QwtScaleWidget::paintEvent()
    To copy to clipboard, switch view to plain text mode 
    method).

    axes-artifact.png

    UPD2: Most likelly, I need to get rid from Qwt && QtWidgets and try to port my app to Quick2 where I need try to create an own graphics library... ((( Besides, my application crashes at using painter.drawText() with OpenGL widget on IMX6.. ((( Seems it is some bug in OpenGL driver or something else.

    Uwe, many thanks anyway!
    Last edited by kuzulis; 31st August 2018 at 16:16.

  14. #14
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Quote Originally Posted by kuzulis View Post
    Most likelly, I need to get rid from Qwt && QtWidgets and try to port my app to Quick2 where I need try to create an own graphics library...
    Well you have a working application running the xcb platform using QwtPlotOpenGLCanvas and you might also have the option of using EGLFS with QwtPlotCanvas::OpenGLBuffer ( you didn't report any results with this combination so far ).

    Furthermore you found out, that calculating the dots for your grid is responsible for ~25% of your CPU load I guess the rest is used for creating the glyphs for the text labels.

    So your simple option is to go with solid grid lines and maybe finding a workaround for the texts - nobody can read labels that are changing 10 times a second. Drawing the curves should be fast and I would expect, that your requirement of 400 points is no problem, when drawing with a solid line. F.e. you could change your plot in a way that you have a stable coordinate system by using an axis always going from [-10,0] - indicating the time until now. This way you can avoid having to repaint the expensive parts for each update.

    Don't expect that Qt/Quick offers you any faster implementation for this - there is not even a public C++ APIs for simple stuff like rendering text. Even worse all kind of primitives have to be heavy QQuickItems and the only way to access them is by Javascript. But I would even say that for an oscilloscope the scene graph does not buy you anything.

    So if you really want to start your own graphics library better do it using native OpenGL ( see https://doc.qt.io/qt-5/qopenglwidget.html#paintGL ).

    If you are interested you could also have a look at https://github.com/QUItCoding/qnanopainter. I have not tested it myself, but from what I read it seems to outperform the corresponding implementations you find in Qt.

    Uwe
    Last edited by Uwe; 1st September 2018 at 12:50.

  15. #15
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    For the record: it turned out, that the X11 paint engine has been reintroduced with Qt 5.10. It can be enabled by setting "export QT_XCB_NATIVE_PAINTING=1".
    Doing a few tests it looks like it works with Qwt as good as with Qt4/X11.

    This is a good ( AFAIK the only existing one for Qt5 ) option, for running QWidget applications with a hardware accelerated graphics pipeline.
    Not to mention, that it is the only implementation, that offers satisfying results for running QWidget applications on remote desktops.

    Uwe

  16. #16
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    Hi Uwe,

    seems that the QT_XCB_NATIVE_PAINTING=1 option has not effect to me.

    I have created a simple test app as before (with usual widget and 50 msecs timer),
    where I have added the additional drawText() function:

    Qt Code:
    1. void Widget::paintEvent(QPaintEvent *event)
    2. {
    3. QPainter p(this);
    4.  
    5. static bool toggled = false;
    6.  
    7. const auto c = toggled ? Qt::red : Qt::green;
    8. p.save();
    9. p.fillRect(event->rect(), QColor(c));
    10. p.restore();
    11.  
    12. p.save();
    13. p.drawText(event->rect().center(), tr("FOOOOOO"));
    14. p.restore();
    15.  
    16. toggled = !toggled;
    17. }
    To copy to clipboard, switch view to plain text mode 

    And the results are following:

    == without of drawText ==

    XCB/X11 (with/without QT_XCB_NATIVE_PAINTING) => CPU usage ~3.6%
    EFLFS => CPU usage ~92%

    == with drawText ==

    XCB/X11 (with/without QT_XCB_NATIVE_PAINTING) => CPU usage ~36%
    EFLFS => CPU usage ~100%

    Summary, so, you are right. The drawText() takes a lot of CPU time, the CPU usage is in ~10 times more..

    Also I have added your proposal to get a paint engine type to my paint event:

    Qt Code:
    1. void Widget::paintEvent(QPaintEvent *event)
    2. {
    3. ...
    4. const auto type = p.paintEngine()->type();
    5. qDebug() << "Type:" << type;
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

    And I always get the 0 as with and as without of QT_XCB_NATIVE_PAINTING (with XCB/X11 backend).
    So, seems, the "native X11" acceleration is accepted, but it does not help much...

    UPD: If try to use the QQuickPaintedItem class with the QtQuick application, then it is even worse than with the QtWidgets:

    XCB/X11 (with/without QT_XCB_NATIVE_PAINTING) => CPU usage ~100%
    EFLFS => CPU usage ~100%


    Added after 56 minutes:


    Uwe,

    seems, that:

    Qt Code:
    1. ...
    2. canvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
    3. ...
    To copy to clipboard, switch view to plain text mode 

    helpes a bit... it decreased the CPU usage from 65% to 30%...

    and adding this:

    Qt Code:
    1. ...
    2. canvas->setPaintAttribute(QwtPlotCanvas::OpenGLBuffer, true);
    3. ...
    To copy to clipboard, switch view to plain text mode 

    decreases even more up to ~26%..
    Is any other tricks to improve the Qwt performance?
    Last edited by kuzulis; 11th September 2018 at 11:47.

  17. #17
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    IMO the CPU is mostly spent on creating the glyphs for the text, what is always done by the CPU - and the part, that is needed to for drawing them later is less important.

    By using QQuickPaintedItem you are still using QPainter and don't enter the path for rendering texts with Qt/Quick. If you want to check that one you need to use QQuickText - what is not so easy without doing QML.
    For your test code it would have a significant effect as you don't change the text and the existing scene graph nodes do not need to be recreated. This is not different to an implementation, where
    drawing the text to a pixmap - once in the beginning - and use it with each update.

    But this is not the situation of your application, where you change the labels for each update and you have to recreate the glyph nodes too.

    But for drawing the curves/grid etc you will see a significant effect with using a hardware accelerated graphic stack - like with the X11 paint engine. Maybe disable the tick labels ( QwtAbstractScaleDraw::enableComponent ) and do some checks with your real application. Maybe you can compare it with one of the solutions using opengl paint engine - it might be interesting to know if creating the dots for the grid lines differs.

    Out of interest: what happens, when using QStaticText instead of QString ?

    Uwe

  18. #18
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    > Out of interest: what happens, when using QStaticText instead of QString ?


    I get same ~36% with drawStaticText() as with drawText().

    > Maybe disable the tick labels ( QwtAbstractScaleDraw::enableComponent ) and do some checks with your real application.

    It is not an option for me..

    But, many thanks, anyway.

    UPD:

    It is interest, that when I use the QCP, then CPU usage is ~18%, but with Qwt is %25% in following tests:

    == QCP ==

    Qt Code:
    1. #include <QApplication>
    2. #include <QDateTime>
    3. #include <QFont>
    4. #include <QFontDatabase>
    5. #include <QPen>
    6. #include <QTimer>
    7.  
    8. #include <qcp/qcustomplot.h>
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QApplication app(argc, argv);
    13.  
    14. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-B.ttf"));
    15. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-BI.ttf"));
    16. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-R.ttf"));
    17. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-RI.ttf"));
    18.  
    19. const QFont font(QLatin1String("Ubuntu Mono"));
    20. QApplication::setFont(font);
    21.  
    22. QCustomPlot plot;
    23. //plot.setOpenGl(true, 0);
    24.  
    25. QTimer timer;
    26. QObject::connect(&timer, &QTimer::timeout, [&]() {
    27.  
    28. const auto kWindowInterval = 20000; // 20 seconds
    29. const auto maximum = QDateTime::currentMSecsSinceEpoch();
    30. const auto minimum = maximum - kWindowInterval;
    31.  
    32. QCPRange range(minimum, maximum);
    33.  
    34. plot.xAxis->setRange(range);
    35. plot.replot();
    36. });
    37.  
    38. timer.start(100);
    39.  
    40. plot.showFullScreen();
    41.  
    42. return app.exec();
    43. }
    To copy to clipboard, switch view to plain text mode 

    == QWT ==

    Qt Code:
    1. #include <QApplication>
    2. #include <QDateTime>
    3. #include <QFont>
    4. #include <QFontDatabase>
    5. #include <QPen>
    6. #include <QTimer>
    7.  
    8. #include <qwt/qwt_interval.h>
    9. #include <qwt/qwt_plot.h>
    10. #include <qwt/qwt_plot_grid.h>
    11. #include <qwt/qwt_plot_canvas.h>
    12. #include <qwt/qwt_scale_draw.h>
    13. #include <qwt/qwt_text.h>
    14. #include <qwt/qwt_scale_widget.h>
    15.  
    16. class TimeScaleDraw final : public QwtScaleDraw
    17. {
    18. private:
    19. QwtText label(double v) const final;
    20. };
    21.  
    22. QwtText TimeScaleDraw::label(double v) const
    23. {
    24. const auto dt = QDateTime::fromMSecsSinceEpoch(qint64(v));
    25. const auto text = dt.time().toString();
    26. return text;
    27. }
    28.  
    29. class Plot : public QwtPlot
    30. {
    31. Q_OBJECT
    32. public:
    33. explicit Plot(QWidget *parent = nullptr);
    34.  
    35. private slots:
    36. void updatePlot();
    37.  
    38. private:
    39. QTimer *m_timer = nullptr;
    40. };
    41.  
    42. Plot::Plot(QWidget *parent)
    43. : QwtPlot(parent)
    44. {
    45. setAutoReplot(false);
    46.  
    47. const auto canvas = new QwtPlotCanvas;
    48. canvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
    49. canvas->setPaintAttribute(QwtPlotCanvas::Opaque, true);
    50. canvas->setPaintAttribute(QwtPlotCanvas::OpenGLBuffer, true);
    51. canvas->setCursor(QCursor());
    52. canvas->setFrameStyle(QFrame::NoFrame);
    53. setCanvas(canvas);
    54.  
    55. const auto grid = new QwtPlotGrid;
    56. grid->enableXMin(true);
    57. grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
    58. grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
    59. grid->attach(this);
    60.  
    61. // Configure X-axis.
    62. const auto xScaleDraw = new TimeScaleDraw;
    63. setAxisScaleDraw(QwtPlot::xBottom, xScaleDraw);
    64. const QwtText xAxisName(QObject::tr("Time"), QwtText::PlainText);
    65. setAxisTitle(QwtPlot::xBottom, xAxisName);
    66. setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignCenter | Qt::AlignBottom);
    67.  
    68. // Configure Y-axis
    69. setAxisScale(QwtPlot::yLeft, 0, 65535);
    70. const QwtText yAxisName(QObject::tr("RAW"), QwtText::PlainText);
    71. setAxisTitle(QwtPlot::yLeft, yAxisName);
    72.  
    73. m_timer = new QTimer(this);
    74. connect(m_timer, SIGNAL(timeout()), this, SLOT(updatePlot()));
    75.  
    76. m_timer->start(100);
    77. }
    78.  
    79. void Plot::updatePlot()
    80. {
    81. const auto kWindowInterval = 20000; // 20 seconds
    82. const auto maximum = QDateTime::currentMSecsSinceEpoch();
    83. const auto minimum = maximum - kWindowInterval;
    84.  
    85. setAxisScale(QwtPlot::xBottom, minimum, maximum);
    86. replot();
    87. }
    88.  
    89. int main(int argc, char *argv[])
    90. {
    91. QApplication app(argc, argv);
    92.  
    93. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-B.ttf"));
    94. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-BI.ttf"));
    95. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-R.ttf"));
    96. QFontDatabase::addApplicationFont(QLatin1String(":/fonts/UbuntuMono-RI.ttf"));
    97.  
    98. const QFont font(QLatin1String("Ubuntu Mono"));
    99. QApplication::setFont(font);
    100.  
    101. Plot plot;
    102. plot.showFullScreen();
    103.  
    104. return app.exec();
    105. }
    106.  
    107. #include "qwt_rendering.moc"
    To copy to clipboard, switch view to plain text mode 

    But it is not a big differences, related to implementation details...
    Last edited by kuzulis; 11th September 2018 at 13:08.

  19. #19
    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: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    > Maybe disable the tick labels ( QwtAbstractScaleDraw::enableComponent ) and do some checks with your real application.
    It is not an option for me..
    This was for finding out the costs of the labels - not to be the solution for your plot.

    But in the end you only have 2 options: reduce how often you repaint the tick labels
    or accept the CPU load.

    At some point you have to accept, that you have to adjust your application to your system and a solution would be simple: use a scale with a range of [-10s, 0] and let your curve be moving from right to left.

    It is interest, that when I use the QCP, ...
    Comparing an empty plot with one, that draws a grid with dotted lines does not mean much.
    Consider, that f.e the raster paint engine has to calculate and pixel down all dots one by one and we also expected, that this part is responsible for the high CPU load of the OpenGL paint engine.

    Uwe

  20. #20
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt 6.3.0 (from qwt-code-r2921-trunk) compilation fails on Ubuntu 18.04.

    At some point you have to accept, that you have to adjust your application to your system and a solution would be simple: use a scale with a range of [-10s, 0] and let your curve be moving from right to left.
    I'm don't understand a bit, how I can do it?

    My every sample contains in the 'X' dimension some timestamp in milliseconds. So, there are a big numbers...

    So, how it will work if I try to set the fixed axis scale:

    Qt Code:
    1. ...
    2. setAxisScale(QwtPlot::xBottom, -10, 0);
    3. ...
    To copy to clipboard, switch view to plain text mode 

    ? I don't understand...

Similar Threads

  1. Replies: 2
    Last Post: 13th December 2011, 16:44
  2. Mingw Cross-compilation of trunk webkit-qt
    By zcrendel in forum Qt Programming
    Replies: 0
    Last Post: 3rd November 2011, 17:23
  3. Compilation fails in Windows XP
    By sim in forum Newbie
    Replies: 3
    Last Post: 1st July 2010, 16:56
  4. qgl_use_font error during compilation of QT git trunk
    By manuels in forum Installation and Deployment
    Replies: 0
    Last Post: 6th March 2010, 14:05
  5. Qt 4.6.1 Compilation fails!
    By Diegol in forum Installation and Deployment
    Replies: 1
    Last Post: 10th February 2010, 16:36

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.