Results 1 to 3 of 3

Thread: plotmatrix axes alignment and QwtPlotZoomer

  1. #1
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question plotmatrix axes alignment and QwtPlotZoomer

    I'm trying to adapt axes alignment code from the PlotMatrix playground example to my application. But It doesn't work as I expect when I add QwtPlotZoomer to the plots.

    Problem is when I zoom into a plot with rectangle selection other plots axes aren't updated immediately. And Y axes stay out of alignment. But they are correctly updated when I resize the window.How can I correctly trigger an update on axis widgets?

    Problem can be reproduced by adding a QwtPlotZoomer to `Plot` class in plotmatrix playground example. Code:

    Qt Code:
    1. public:
    2. QwtPlotZoomer* zoomer;
    3. Plot( QWidget *parent = NULL ):
    4. QwtPlot( parent )
    5. {
    6. QwtPlotCanvas *canvas = new QwtPlotCanvas();
    7. canvas->setLineWidth( 1 );
    8. canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
    9.  
    10. setCanvas( canvas );
    11.  
    12. zoomer = new QwtPlotZoomer(canvas);
    13. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: plotmatrix axes alignment and QwtPlotZoomer

    Changing the connection to a Qt::QueuedConnection should fix this issue:

    Qt Code:
    1. connect( plot->axisWidget( axis ), SIGNAL( scaleDivChanged() ),
    2. SLOT( scaleDivChanged() ), Qt::QueuedConnection );
    To copy to clipboard, switch view to plain text mode 
    But don't forget to synchronize the zoom stacks of the various zoomer objects.

    Uwe

  3. #3
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: plotmatrix axes alignment and QwtPlotZoomer

    Uwe, thanks for your recommendation. I've worked on it a bit. It seems to work. But in certain cases it doesn't. I've uploaded the plotmatrix.cpp file I modified here: https://gist.github.com/hyOzd/4e3e9f...ff3c57efb9dc56

    Let me explain. When I zoom in to one of the plots for the first time, in the first or second row left scales are updated correctly. But third row isn't updated correctly. When I continue zooming deeper, third row is updated correctly and it works fine for all levels. When I unzoom with right click, third row again isn't updated properly. When third row is out of sync, changing the window size fixes the problem. But I've noticed that changing window size should result in a size change in the leftmost plot widget, otherwise it isn't effective.

    By the way here is the ZoomGroup class I've added to sync zoom stacks of plot widgets (also present in above gist):

    Qt Code:
    1. class ZoomGroup : public QObject
    2. {
    3.  
    4. private:
    5. bool inSync = false;
    6.  
    7. void onZoomed(const QRectF &rect)
    8. {
    9. if (inSync)
    10. {
    11. qDebug() << "in sync";
    12. return;
    13. }
    14.  
    15. inSync = true;
    16. QwtPlotZoomer* source = qobject_cast<QwtPlotZoomer*>(sender());
    17. Q_ASSERT(source != NULL);
    18. for (int i = 0; i < zoomers.length(); i++)
    19. {
    20. if (source == zoomers[i])
    21. continue;
    22. zoomers[i]->setZoomStack(source->zoomStack(),
    23. source->zoomRectIndex());
    24. }
    25. inSync = false;
    26. }
    27.  
    28. public:
    29. void addZoomer(QwtPlotZoomer* zoomer)
    30. {
    31. connect(
    32. zoomer, &QwtPlotZoomer::zoomed,
    33. this, &ZoomGroup::onZoomed,
    34. Qt::QueuedConnection);
    35. zoomers.append(zoomer);
    36. }
    37. private:
    38. QList<QwtPlotZoomer*> zoomers;
    39. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 23rd October 2015, 14:00
  2. Axis or Axes?
    By Momergil in forum Qwt
    Replies: 1
    Last Post: 21st May 2014, 20:10
  3. plotmatrix canvas size after rescale
    By bbrondel in forum Qwt
    Replies: 2
    Last Post: 31st July 2013, 16:30
  4. Help with axes, again! :(
    By bigjoeystud in forum Qwt
    Replies: 2
    Last Post: 15th October 2012, 20:46
  5. Replies: 1
    Last Post: 6th May 2010, 11: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.