Results 1 to 3 of 3

Thread: QwtPlotzoomer for more 4 -yleft axis

  1. #1
    Join Date
    Oct 2014
    Location
    Paris
    Posts
    15
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtPlotzoomer for more 4 -yleft axis

    In my app i use the qwtplotzommer, it works fine for one y-left axis. when zooming into the graph only the y-axis (first to the left) is updated.
    my section code for zooming is as following:

    d_zoomer[0] = new myZoomer(
    QwtAxis::xBottom,QwtAxisId(QwtAxis::yLeft, 0).id, canvas() );
    d_zoomer[0]->setRubberBand( QwtPicker::RectRubberBand );
    d_zoomer[0]->setRubberBandPen( QColor( Qt::red ) );
    d_zoomer[0]->setTrackerMode( QwtPicker::ActiveOnly );
    d_zoomer[0]->setTrackerPen( QColor( Qt::white ) );
    d_zoomer[0]->setZoomBase();

    connect(d_zoomer[0],SIGNAL(zoomed(QRectF)),this,SLOT(ZoomedRect(QRect F)));

    ---------------
    setAxesCount(QwtAxisId(QwtPlot::yLeft).id,nChannel +1);// set nChannel axis on y direction
    d_curve->setYAxis(QwtAxisId(QwtAxis::yLeft,nChannel));
    setAxisVisible(d_curve->yAxis(),true);
    this->setAxisScale(QwtAxisId(QwtAxis::yLeft,nChannel) , 0, 85,10 );
    this->setAxisAutoScale(QwtAxisId(QwtAxis::yLeft,nChanne l),true);
    _________

    I have 2 problems:

    1) If my plot has more than one y-left axis for example 4-y-left Axis, the zooming works but without updating y-left2 to y-left4 axis, only the y-left1 is updated, for all the graphs the zooming works fine.

    2) If i add this section code to my programs and I add more curves by drag and drop to the plot, my programs works only with 4 curves and in case of more curves it crashes. And the section below is causing that problem.

    d_zoomer[nChannel] = new myZoomer(
    QwtAxis::xBottom, QwtAxisId(QwtAxis::yLeft, nChannel).id, canvas() );

    Do you know, how zooming can work for all integrated axis?
    Thanks,

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotzoomer for more 4 -yleft axis

    In general the idea of your implementation should work, maybe beside of one aspect: all of your zoomers are connected to the same x axis. If it is not a dummy one you will have some unexpected effects.
    Assuming that xBottom is your common x-axis and you don't use xTop, I would connect only the first zoomer to xBottom all others to xTop. In case you need xTop and xBottom you could add an invisible dummy x axis.

    Why things are not working in your application is hard to say from the code snippets. But as you have a crash I would start with a debugger session.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    Abderrahim (20th January 2016)

  4. #3
    Join Date
    Oct 2014
    Location
    Paris
    Posts
    15
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtPlotzoomer for more 4 -yleft axis

    Hello Uwe,

    with debugger i found that my programs crashes when the element pos gets the value 4 in this code section:

    inline QwtPlotAxisData &axisData( const QwtAxisId &axisId )
    {
    return d[ axisId.pos ].axisData[ axisId.id ];
    }



    the axisId.pos must be between 0 and 3 -->{ "yLeft", "yRight", "xBottom", "xTop" };


    I think that myzoomer sets the value to 4. but why?

    d_zoomer[nChannel] = new myZoomer(
    QwtAxis::xTop, QwtAxisId(QwtAxis::yLeft,nChannel).id, canvas() );

    ---------------

    class myZoomer: public QwtPlotZoomer
    {
    public:

    myZoomer( int xAxis, int yAxis, QWidget *canvas ):
    QwtPlotZoomer( xAxis, yAxis, canvas )
    {
    setTrackerMode( QwtPicker::AlwaysOff );
    setRubberBand( QwtPicker::NoRubberBand );
    // RightButton: zoom out by 1
    // Ctrl+RightButton: zoom out to full size
    setMousePattern( QwtEventPattern::MouseSelect2,
    Qt::RightButton, Qt::ControlModifier );
    setMousePattern( QwtEventPattern::MouseSelect3,
    Qt::RightButton );

    }
    };


    Added after 5 minutes:


    Problem is solved.

    Sorry:
    declaration was false:

    myZoomer( QwtAxisId xAxis, QwtAxisId yAxis, QWidget *canvas ):
    QwtPlotZoomer( xAxis, yAxis, canvas )
    Last edited by Abderrahim; 20th January 2016 at 12:20.

Similar Threads

  1. yLeft axis constant width
    By baray98 in forum Qwt
    Replies: 4
    Last Post: 4th January 2013, 17:40
  2. Replies: 3
    Last Post: 6th December 2011, 08:56
  3. Replies: 4
    Last Post: 31st August 2011, 14:57
  4. Replies: 1
    Last Post: 2nd May 2010, 19:27
  5. Axis yLeft cuts of numbers
    By sun in forum Qwt
    Replies: 17
    Last Post: 9th October 2009, 22:36

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.