Results 1 to 3 of 3

Thread: plotmatrix axes alignment and QwtPlotZoomer

  1. #1
    Join Date
    Jan 2011
    Qt products

    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 );
    10. setCanvas( canvas );
    12. zoomer = new QwtPlotZoomer(canvas);
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Munich, Germany
    Thanked 811 Times in 760 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    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.


  3. #3
    Join Date
    Jan 2011
    Qt products

    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:

    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. {
    4. private:
    5. bool inSync = false;
    7. void onZoomed(const QRectF &rect)
    8. {
    9. if (inSync)
    10. {
    11. qDebug() << "in sync";
    12. return;
    13. }
    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. }
    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, 15:00
  2. Axis or Axes?
    By Momergil in forum Qwt
    Replies: 1
    Last Post: 21st May 2014, 21:10
  3. plotmatrix canvas size after rescale
    By bbrondel in forum Qwt
    Replies: 2
    Last Post: 31st July 2013, 17:30
  4. Help with axes, again! :(
    By bigjoeystud in forum Qwt
    Replies: 2
    Last Post: 15th October 2012, 21:46
  5. Replies: 1
    Last Post: 6th May 2010, 12:36

Tags for this Thread


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.