Results 1 to 5 of 5

Thread: How to harmonize the scales and pannings of various QwtPlot?

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to harmonize the scales and pannings of various QwtPlot?

    Hello!

    In my software I need to draw 2 or more QwtPlot, one under the other. The case is that theese graphs are connected: many events that happens in one graph must release a equivalente event in the other.

    For now there are two things that I need to connect: the XBottom axis scale and the horizontal panning event.

    For the panning, always when its done the horizontal component of the panning (the vertical move is irrelevant) that is performed in one graph must also occur iddentically in the other, so if I move 10.0 to the right in one, the other must also move 10.0 to the right at the same time.

    For the scale, one must also be connected to the other so each xBottom scale modification in one graph affects the equivalent in the other. So for example if I perform a zoom in one graph and therefore the xBottom scale changes, the equivalent change must occur in the other graph.


    The problem is: i simply have no idea of how to do this :P

    Any typ?

    Details:

    Qt Code:
    1. //panner:
    2. graphCandlePanner = new QwtPlotPanner( graphCandle->canvas() );
    3. graphCandlePanner->setMouseButton( Qt::MidButton );
    4. graphCandlePanner->setCursor(QCursor(Qt::ClosedHandCursor));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //Scale draw modifications
    2.  
    3. class DateScaleDraw: public QwtDateScaleDraw
    4. {
    5. public:
    6. DateScaleDraw( Qt::TimeSpec timeSpec ):
    7. QwtDateScaleDraw( timeSpec )
    8. {
    9. //setDateFormat( QwtDate::Millisecond, "hh:mm:ss:zzz" );
    10. setDateFormat( QwtDate::Second, "hh:mm:ss\ndd" );
    11. setDateFormat( QwtDate::Minute, "hh:mm\n dd MMM" );
    12. setDateFormat( QwtDate::Hour, "hh:mm\ndd MMM" );
    13. setDateFormat( QwtDate::Day, "dd MMM" );
    14. setDateFormat( QwtDate::Week, "ww/MMM" );
    15. setDateFormat( QwtDate::Month, "MMM/yyyy" );
    16. }
    17. };
    18.  
    19. //Axis code
    20. QwtDateScaleDraw *scaleDraw = new DateScaleDraw( Qt::UTC );
    21. QwtDateScaleEngine *scaleEngine = new QwtDateScaleEngine( Qt::UTC );
    22.  
    23. graphCandle->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw );
    24. graphCandle->setAxisScaleEngine( QwtPlot::xBottom, scaleEngine );
    25. //graphCandle->setAxisScale(QwtPlot::xBottom,0,intervalo);
    26. graphCandle->setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    27. graphCandle->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );
    28. //graphCandle->setAxisTitle( QwtPlot::yLeft, QString( "Price [R$]" ) );
    29. graphCandle->setMinimumHeight(200);
    30.  
    31. //the second graph have a very similar code.
    To copy to clipboard, switch view to plain text mode 

    Thanks,

    Momergil

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

    Default Re: How to harmonize the scales and pannings of various QwtPlot?

    Modifications of an axis scale are indicated by:

    Qt Code:
    1. QwtScaleWidget::scaleDivChanged();
    To copy to clipboard, switch view to plain text mode 
    Connect to these signals and update whatever needs to be updated on the other plot.

    Uwe

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to harmonize the scales and pannings of various QwtPlot?

    Well, I simply can't find any way to reach this signals. Could you give me a code example please?

  4. #4
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to harmonize the scales and pannings of various QwtPlot?

    And none of the examples show how to use it either...

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

    Default Re: How to harmonize the scales and pannings of various QwtPlot?

    Qt Code:
    1. plot->connect( plot->axisWidget( ... ), SIGNAL( scaleDivChanged() ), ... );
    To copy to clipboard, switch view to plain text mode 

    Uwe

  6. The following 2 users say thank you to Uwe for this useful post:

    Momergil (22nd January 2013), qt_gotcha (23rd January 2013)

Similar Threads

  1. Scales alignment
    By fruzzo in forum Qwt
    Replies: 6
    Last Post: 28th September 2011, 16:32
  2. QwtPlot: how to auto-scale two Y scales?
    By paradiza in forum Qwt
    Replies: 4
    Last Post: 24th March 2009, 01:28
  3. Replies: 0
    Last Post: 1st January 2009, 18:47
  4. Replies: 1
    Last Post: 2nd December 2008, 22:22
  5. Replies: 10
    Last Post: 18th September 2008, 15:14

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
  •  
Qt is a trademark of The Qt Company.