Results 1 to 13 of 13

Thread: QwtPlotZoomer locks up, possibly bug?

  1. #1
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default QwtPlotZoomer locks up, possibly bug?

    Hi everybody!

    I've implemented simple class derived from QwtPlot , it contains 3 pointers:
    Qt Code:
    1. QwtPlotCurve *curve1;
    2. QwtPlotCurve *curve2;
    3. QwtPlotZoomer* zoomer;
    To copy to clipboard, switch view to plain text mode 
    in constructor I create objects:
    Qt Code:
    1. curve1 = new QwtPlotCurve("Curve 1");
    2. curve1->attach(this);
    3. curve2 = new QwtPlotCurve("Curve 2");
    4. curve2->attach(this);
    5.  
    6. zoomer = new QwtPlotZoomer( canvas() );
    7. zoomer->setTrackerPen( QColor( Qt::black ) );
    8. zoomer->setTrackerMode(QwtPicker::AlwaysOff);
    9. zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier );
    10. zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton );
    11. zoomer->setZoomBase();
    To copy to clipboard, switch view to plain text mode 
    There is a function inside my class to assign data to curves, it basically does:
    Qt Code:
    1. QwtPointSeriesData* myData = new QwtPointSeriesData;
    2. ...
    3. curve1->setData(myData); // or curve2->setData(myData); , only one curve updated at a time
    4. zoomer->setZoomBase();
    To copy to clipboard, switch view to plain text mode 
    And here is what happens - I have two different data sets with quite different value scales. I can call function to assign one particular dataset to curve. If I assign one dataset and then another without zooming graph it works perfect, but , if I zoom with first dataset and then switch to another zoomer will lock on a range of the first datset. It seems to me that there is something that prevents value ranges from update so, to fix this I tried:
    - to reset zoom to 0 level before actual update of curve - not working
    - to detach curve object from plot and attach it after update of dataset - not working

    Is there anything I can do to correctly update zoomer state after data changes?

    Thanks in advance!

    PS: QWT ver 6.0.1 , Qt 4.7.4

  2. #2
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Lightbulb Re: QwtPlotZoomer locks up, possibly bug?

    Ok, fixed this adding following code after curve data change(thanks to adjascent topic on scrolling plot):
    Qt Code:
    1. double max= curve1->maxYValue(),min = curve1->minYValue();
    2. if(curve2->maxYValue() > curve1->maxYValue()) max = curve2->maxYValue();
    3. if(curve2->minYValue() < curve1->minYValue()) min = curve2->minYValue();
    4.  
    5. setAxisScale(QwtPlot::yLeft,min,max,0);
    To copy to clipboard, switch view to plain text mode 
    Still don't get why this scale is not updated automatically.

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotZoomer locks up, possibly bug?

    When you use zoom the auto scale function gets turned off.
    If you want the axsis to have correct values after you change/add a curve you need to turn it back on and only after set the zoom base.

    Qt Code:
    1. this->setAxisAutoScale( QwtPlot::xBottom );
    2. plot->setAxisAutoScale( QwtPlot::yLeft );
    3. plot->updateAxes();
    4. zoomer->setZoomBase( true );
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Spitfire View Post
    When you use zoom the auto scale function gets turned off.
    If you want the axsis to have correct values after you change/add a curve you need to turn it back on and only after set the zoom base.
    Nice workaround, thanks! Replaced manual scale calculations with
    setAxisAutoScale( QwtPlot::xBottom );
    setAxisAutoScale( QwtPlot::yLeft );
    just before actual data updates. updateAxes seems doing nothing

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

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Read the docs about how the scales are set by the application ( or by autoscaling ) - then try to understand what the zoomStack is.
    Then you should be able to help yourself.

    Uwe

  6. #6
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Uwe View Post
    Read the docs about how the scales are set by the application ( or by autoscaling ) - then try to understand what the zoomStack is.
    Then you should be able to help yourself.
    Well, Uwe, there is a problem with that, even several:
    - I see no documents on QWT at all, only reference on classes
    - the way library works seems illogical - this, still, normally, bearable if there is an explanation on how it works - but you don't have one. So, I do implementation then see what kind of gotchas I have with QWT. Example - show me the particular place in 'documentation' where reset of autoscale parameter mentioned .
    - I like to see other's sources, it is quite educating sometimes. But, in case of QWT, to get a simple plot work as I need, I'm forced to be at least an expert in ALL of classes inside QWT(maybe less rudiment control widgets), and it seems, that you support it in this way, only sometimes giving a hint to drowning people. I personally like how QWT works, but from outside, inside it is a plain example of overengineering, so do not see any point to study it completely, sorry, it is just waste of time.

    resume: QWT is a good library, but the complexity of using it is way greater, than outcome from it, thus (from my perspective) it will always be like QWT + workarounds, since it is easier to write own library on graphs than discover a "correct way to use QWT described in documents"

  7. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Neekeetos View Post
    Example - show me the particular place in 'documentation' where reset of autoscale parameter mentioned .
    There are no "autoscale" parameter, that could be reset.

    http://qwt.sourceforge.net/class_qwt...95d0c16924eed6
    http://qwt.sourceforge.net/class_qwt...440fceead50432
    http://qwt.sourceforge.net/class_qwt...2fa4f6378c225a

    This is the complete API for modifying the scales - it's that simple and there is not more to say.

    --

    A different story is the zoom stack - that is indeed heavily underdocumented and a main reason for support request. But it has been asked and answered so many times in this forum, that you should have been able to find what you need after I gave you the right keyword.

    But once more for you:

    All helper classes for the plot navigation ( zoomer, panner, magnifier, ... ) don't have special APIs - they all use QwtPlot::setAxisScale(). In consequence autoscaling gets disabled as soon as the scales are modified from a zoomer ( or any other of the helper classes ). Read the links above.

    The zoomer maintains a history of the scales it had set. When the application code changes the scales behind the back of the zoomer ( f.e by re-enabling autoscaling + replot, or using it in combination with panning ), this history ( the zoom stack ) is not changed. Understanding this it should be no surprise, that you don't get the same scales when you go back the top of the zoom stack, than those you get from autoscaling, when the plot contents has changed in the meantime.

    For these situations the application code has to adjust the zoom stack manually.

    HTH,
    Uwe

  8. #8
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Uwe View Post
    There are no "autoscale" parameter, that could be reset.
    There is, when you say "autoscaling gets disabled" , "re-enabling autoscaling", or, reading your links on Plot api, "Disable autoscaling", "Autoscaling is enabled by default" etc. Means there is underlying parameter for each scale which gets set or reset when you enable or disable autoscaling, you call it doAutoScale inside library.

    Quote Originally Posted by Uwe View Post
    The zoomer maintains a history of the scales it had set. When the application code changes the scales behind the back of the zoomer ( f.e by re-enabling autoscaling + replot, or using it in combination with panning ), this history ( the zoom stack ) is not changed. Understanding this it should be no surprise, that you don't get the same scales when you go back the top of the zoom stack, than those you get from autoscaling, when the plot contents has changed in the meantime.
    Uwe, it is always surprise, because for plot it is normal to expect that when you manually set range for particular scale this range is not reset even after new data is assigned, but for zoomer, it is just you implemented it the way, that zoomer is bound to fixed ranges, it is not obvious. I think now that it is not about autoscale disable/enable( and thus switching autoscale on/off is a true workaround), it is a zoomer that is not working correctly - ie what is the point for zoomer to keep using invalid scales? At least outer scale in zoom stack (ie bondary) should be updated with data changes, otherwise it is not possible for user to access a data outside old boundary for no reason.

    Quote Originally Posted by Uwe View Post
    For these situations the application code has to adjust the zoom stack manually.
    in my opinion these situations are 100% of all, so maybe it is a library to adjust zoom stack, at least in cases when data becomes inaccessible within old ranges?

  9. #9
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Neekeetos View Post
    There is, when you say "autoscaling gets disabled" , "re-enabling autoscaling", or, reading your links on Plot api,
    O.k. but don't blame the documentation for not reading it.

    Quote Originally Posted by Neekeetos View Post
    Uwe, it is always surprise, because for plot it is normal to expect that when you manually set range for particular scale this range is not reset even after new data is assigned, ...
    This is exactly how it is implemented - what's your point ?

    Quote Originally Posted by Neekeetos View Post
    ... but for zoomer, it is just you implemented it the way, that zoomer is bound to fixed ranges
    I have to repeat myself: once you have understood that the zoom stack is simply a history of the scale ranges recorded by zoom operations it is very obvious what happens. If this is good or bad is a different story - the point is that you can only help yourself when you know what is going on.

    Or more explicit: modify the rectangles in the zoom stack, whenever you want to have different rectangles in the zoom stack.

    Quote Originally Posted by Neekeetos View Post
    I think now that it is not about autoscale disable/enable( and thus switching autoscale on/off is a true workaround), it is a zoomer that is not working correctly - ie what is the point for zoomer to keep using invalid scales?
    The idea of the zoom history is very straight, understandable and working correctly. It is o.k. for most of the applications. because they don't change the scene while zooming.

    The problem is the concept not its implementation. It should be a common navigation stack for the plot - not a zoom stack inside a single zoomer. This way panning, zooming and whatever could be combined more easily. Nevertheless the application code will have to decide how this stack has to be fed.

    But in general the default behavior of a library rarely meets the requirements of an application in all details. A good library design offers a reasonable default implementation but is aware that the application will have to modify it. You seem to call this "workarounds" - but it is simply your job as application developer.

    Uwe

  10. #10
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Uwe View Post
    But in general the default behavior of a library rarely meets the requirements of an application in all details. A good library design offers a reasonable default implementation but is aware that the application will have to modify it. You seem to call this "workarounds" - but it is simply your job as application developer.
    So, why do you argue? Im calling this workaround because for me it is behaving incorrectly. And because of this I've created this topic. Regarding my job - for me, normal process is to use feedback to correct issues, not building workarounds. That is so because of two reasons - workarounds are impossible to support, second - development of (in this case your) library is not suffering from hidden bugs. For now QWT have no documents other than class reference, no description of logic behind = no guaranty that you will not change something, happily breaking my code (note - code is based on assumptions, because you don't state anything explicitely ).

  11. #11
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Neekeetos View Post
    So, why do you argue? Im calling this workaround because for me it is behaving incorrectly.
    QwtPlotZoomer does something different than what you need, but that doesn't mean that it is wrong. Call it whatever you want, but for the maintainer of a library "incorrectly" means having to fix a bug, while changing the concept or design of a class is something completely different. In fact changing the behavior of the zoomer so that you would call it "correct" would break all existing applications relying on the current implementation.

    The documentation is far from being good, but in your particular case all I can see is that you had problems with the very, very basics of the plot widget and out of frustration you were complaining about the documentation without even having read the 3-4 most basic methods ( stable since 15 years ) every application has to use.

    And instead of trying to find out what needs to be done and if this is really that difficult you ...

    ... no guaranty that you will not change something, happily breaking my code
    Then read my promise that I will change something breaking your code :


    • The concept of the zoom stack is too simple and needs to be replaced by a more general navigation stack.
    • But even more important: Qwt has to be adopted to Qt5 where you also have the scene graph that doesn't work with widgets anymore.


    Uwe

  12. #12
    Join Date
    Feb 2012
    Posts
    10
    Qt products
    Qt4

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Uwe View Post
    but for the maintainer of a library "incorrectly" means having to fix a bug, while changing the concept or design of a class is something completely different. In fact changing the behavior of the zoomer so that you would call it "correct" would break all existing applications relying on the current implementation.
    That is the whole point of doing library - it is not about internal structure,classes but about api, nobody should care of internals. The fact that it is not possible to apply a minor change to behaviour just prooves internal structure of a library is not adopted good enough for its task, not about how well user of a library can read documentation or library code.

    Quote Originally Posted by Uwe View Post
    The documentation is far from being good, but in your particular case all I can see is that you had problems with the very, very basics of the plot widget and out of frustration you were complaining about the documentation without even having read the 3-4 most basic methods ( stable since 15 years ) every application has to use.
    It is not stable, examples of fifth version do not work with 6th...

    Quote Originally Posted by Uwe View Post
    And instead of trying to find out what needs to be done and if this is really that difficult you ...
    To me it is really difficult to prove you simple basic things,because I solved my problem in second message of a thread if you remember, and I also found a cause for it.

    Quote Originally Posted by Uwe View Post
    Then read my promise that I will change something breaking your code :

    • The concept of the zoom stack is too simple and needs to be replaced by a more general navigation stack.
    • But even more important: Qwt has to be adopted to Qt5 where you also have the scene graph that doesn't work with widgets anymore.
    Ok, that is the main thing here. You put some effort to guide me to "correct way of doing things", like reading documentation and study methods etc, but you admit now that there is no correct answer, nice . In my attempt I basically did nothing but manually corrected axis scales. And you are telling me that even this simple thing will break the whole application because of scene changes? That is absolutely what I was talking about previously, something Im avoiding!

  13. #13
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotZoomer locks up, possibly bug?

    Quote Originally Posted by Neekeetos View Post
    The fact that it is not possible to apply a minor change to behaviour just prooves internal structure of a library is not adopted good enough for its task, not about how well user of a library can read documentation or library code.
    Or it proves the weakness of both - but both are no excuse for complaining about the docs instead of trying to read them.

    Concerning the design of how to set the scales: tell me what is bad or hard to understand about following methods:


    • QwtPlot::setAxisScale()
    • QwtPlot::setAxisAutoScale()
    • QwtPlot::replot()


    You can also send me patches for the documentation writing all what would have helped you with your situation.
    I'm open to suggestions - but please no more of this unspecific noise.

    Quote Originally Posted by Neekeetos View Post
    Ok, that is the main thing here ..
    These statement are completely unrelated to what you had quoted. What do you expect from a discussion when you don't read or try to understand the other side - winning by writing the final posting ?

    Uwe

Similar Threads

  1. Replies: 2
    Last Post: 28th December 2010, 06:20
  2. Replies: 2
    Last Post: 7th July 2010, 00:14
  3. QSqlDatabase, threaded access and locks
    By neuron in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2009, 15:55
  4. QThread locks my gui ??
    By LordQt in forum Qt Programming
    Replies: 8
    Last Post: 8th December 2008, 19:53
  5. Possibly an inheritance problem with QObject?
    By chadkeck in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2008, 01:26

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.