Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [QWT] Plotting curves with gaps with QWT 6.1.0
Forum Updated to NodeBB v4.3 + New Features

[QWT] Plotting curves with gaps with QWT 6.1.0

Scheduled Pinned Locked Moved 3rd Party Software
9 Posts 2 Posters 7.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #1

    So far, I have been using qwt v6.0.1 and v6.0.2 without problems. Because of Qt 5 I had to upgrade to v 6.1.0 and the statement above does not seem to do its job anymore.

    For about two years I am plotting curves with gaps and I do not like to have an additional entry in the legend. In order to suppress the additional entries, the second and subsequent entries are marked using following statement:
    QwtPlotItem::setItemAttribute( QwtPlotItem::Legend, false );

    Every single snippet of the curve will have a separate entry in the legend.

    QWT has been compiled using MinGW 4.8 as supplied with Qt 5.1 SDK.

    Anyone an idea what is wrong or what I have to change?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      IIRC there have been some changes in between, some function renaming at least.

      Do you have a little example that could be tested ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        Unfortunately, No small example.

        I have done a bit of debugging today. In the mean time I have a solution by changing the init method of QwtPlotCurve contructor. Doing a bit more checks tomorrow. Maybe I can change one of the examples to demonstrate show the issue.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That looks almost like a regression then

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            I have isolated the issue for the bode example.

            Changes in plot.h:
            @
            QwtPlotCurve *d_curve11;
            QwtPlotCurve *d_curve12;
            QwtPlotCurve *d_curve21;
            QwtPlotCurve *d_curve22;
            QwtPlotMarker *d_marker1;
            QwtPlotMarker *d_marker2;
            @

            plot.cpp:
            @
            Plot::Plot( QWidget *parent ):
            QwtPlot( parent )
            {
            setAutoReplot( false );

            ...
            // curves
            d_curve11 = new QwtPlotCurve( "Amplitude" );
            d_curve11->setRenderHint( QwtPlotItem::RenderAntialiased );
            d_curve11->setPen( Qt::yellow );
            d_curve11->setLegendAttribute( QwtPlotCurve::LegendShowLine );

            #define QWT_CURVE_CHECK0
            #if defined ( QWT_CURVE_CHECK )
            d_curve11->setItemAttribute( QwtPlotItem::Legend, true );
            #endif
            d_curve11->setYAxis( QwtPlot::yLeft );
            d_curve11->attach( this );
            d_curve12 = new QwtPlotCurve( "Amplitude" );
            d_curve12->setRenderHint( QwtPlotItem::RenderAntialiased );
            d_curve12->setPen( Qt::yellow );
            d_curve12->setLegendAttribute( QwtPlotCurve::LegendShowLine );
            #if defined ( QWT_CURVE_CHECK )
            d_curve12->setItemAttribute( QwtPlotItem::Legend, false );
            #endif
            d_curve12->setYAxis( QwtPlot::yLeft );
            d_curve12->attach( this );

            d_curve21 = new QwtPlotCurve( "Phase" );
            d_curve21->setRenderHint( QwtPlotItem::RenderAntialiased );
            d_curve21->setPen( Qt::cyan );
            d_curve21->setLegendAttribute( QwtPlotCurve::LegendShowLine );
            

            #if defined ( QWT_CURVE_CHECK )
            d_curve21->setItemAttribute( QwtPlotItem::Legend, true );
            #endif
            d_curve21->setYAxis( QwtPlot::yRight );
            d_curve21->attach( this );
            d_curve22 = new QwtPlotCurve( "Phase" );
            d_curve22->setRenderHint( QwtPlotItem::RenderAntialiased );
            d_curve22->setPen( Qt::cyan );
            d_curve22->setLegendAttribute( QwtPlotCurve::LegendShowLine );
            #if defined ( QWT_CURVE_CHECK )
            d_curve22->setItemAttribute( QwtPlotItem::Legend, false );
            #endif
            d_curve22->setYAxis( QwtPlot::yRight );
            d_curve22->attach( this );
            // marker
            ...
            setAutoReplot( true );
            }

            void Plot::showData( const double *frequency, const double *amplitude,
            const double *phase, int count )
            {
            int cnt2 = count / 2;
            int count2 = count - cnt2;
            #if ! defined ( QWT_CURVE_CHECK )
            d_curve11->setItemAttribute( QwtPlotItem::Legend, true );
            d_curve12->setItemAttribute( QwtPlotItem::Legend, false );
            d_curve21->setItemAttribute( QwtPlotItem::Legend, true );
            d_curve22->setItemAttribute( QwtPlotItem::Legend, false );
            #endif
            d_curve11->setSamples( frequency, amplitude, cnt2 );
            d_curve21->setSamples( frequency, phase, cnt2 );
            d_curve12->setSamples( &frequency[cnt2], &amplitude[cnt2], count2 );
            d_curve22->setSamples( &frequency[cnt2], &phase[cnt2], count2 );
            }
            @

            The example as given above shows duplicated legend entries, when qwt is untouched.

            When QWT_CURVE_CHECK macro is defined only single entries are shown.

            There is a dependency when
            @
            d_curveX2->setItemAttribute( QwtPlotItem::Legend, false );
            @
            are called.

            The example has also proper legend entries when the QWT_CURVE_CHECK macro is not defined, but qwt is slightly changed in qwt_plot_curve.cpp from
            @
            void QwtPlotCurve::init()
            {
            setItemAttribute( QwtPlotItem::Legend );
            setItemAttribute( QwtPlotItem::AutoScale );
            @

            to:
            @
            void QwtPlotCurve::init()
            {
            setItemAttribute( QwtPlotItem::Legend, false );
            setItemAttribute( QwtPlotItem::AutoScale );
            @

            in qwt-6.0.1 it did not matter where the actual entries for the legend were set to false. At least not in my plotting setup.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              I tried with Qt 4.8.6 and had the same results. It might be a good idea to check with the Qwt guys

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                HI,
                Thanks for feedback.

                I had placed the question on the QWT mailing list before posting here. Without any feedback and not even showing my entry in the archive next day, I decided to place here.

                Nevertheless," Uwe has answered":http://sourceforge.net/p/qwt/mailman/qwt-interest/?viewmonth=201308&viewday=10 and I am going to guide him to here.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  As an update Uwe responded on the qwt mailing list:
                  [quote]
                  This is an update issue - it has to do with the fact, that Qwt 6.1 is
                  more accurate with item and legend changes ( see
                  QwtPlotItem::legenChanged(), QwtPlotItem::itemChanged() to avoid
                  pointless expensive replots.

                  I have to check what goes wrong in the example, but an easy workaround
                  is to call QwtPlot::updateLegend() manually after changing the
                  QwtPlotItem::Legend flags.

                  Uwe
                  [/quote]

                  Just verified with the prepared "bode" example. Changing showData to:
                  @
                  void Plot::showData( const double *frequency, const double *amplitude,
                  const double *phase, int count )
                  {
                  int cnt2 = count / 2;
                  int count2 = count - cnt2;
                  #if ! defined ( QWT_CURVE_CHECK )
                  d_curve11->setItemAttribute( QwtPlotItem::Legend, true );
                  d_curve12->setItemAttribute( QwtPlotItem::Legend, false );
                  d_curve21->setItemAttribute( QwtPlotItem::Legend, true );
                  d_curve22->setItemAttribute( QwtPlotItem::Legend, false );
                  #endif
                  d_curve11->setSamples( frequency, amplitude, cnt2 );
                  d_curve21->setSamples( frequency, phase, cnt2 );
                  d_curve12->setSamples( &frequency[cnt2], &amplitude[cnt2], count2 );
                  d_curve22->setSamples( &frequency[cnt2], &phase[cnt2], count2 );

                  QwtPlot::updateLegend();
                  

                  }
                  @

                  does also solve the problem.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    This might be a good trick to add in their documentation

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved