Results 1 to 10 of 10

Thread: Get y value vertical line

  1. #1
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Get y value vertical line

    Hello, I use the library qwt 6.0.1. Needed know the y-value of when you click on the chart.
    An example is shown in the picture. When you click on the chart I need to know the value is not the nearest to the point of clicking, and the nearest of the vertical line. That is, when you click the mouse must be received by the value of point 2, not 1 point.

    Before I do so:
    Qt Code:
    1. int index = _curve1->closestPoint(_picker->trackerPosition());
    To copy to clipboard, switch view to plain text mode 
    But in this way I get the value of point 1 and not 2.

    Sorry for my English.

    pic.jpg

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

    Default Re: Get y value vertical line

    Then you have to write some code. Have a look at the playground/curvetracker example in Qwt 6.1.

    Uwe

  3. #3
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get y value vertical line

    Thank you. I used an older version of qwt 6.0.1, because for her there was a patch on the 10 axes y.
    Do I have any problems installing the patch to version 6.1.0? Or enough to make changes to source files, or automatically through the app "patch" or manually replacing the lines?

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

    Default Re: Get y value vertical line

    My hint was to have a look at the example in Qwt 6.1 how it could be done. It doesn't mean, that you have to upgrade your Qwt version only to implement something similar with Qwt 6.0.

    Concerning the multi axes patch: there is a branch of Qwt 6.1 ( see the svn repository ), that implements multi axes in a much better way. This branch is actively maintained and planned to be released as one of the next versions of Qwt ( 6.3 or 6.4 ).

    Uwe

  5. #5
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get y value vertical line

    Hello Uwe. I downloaded a version of qwt 6.1.0-multiaxes. Displayed on the chart two curves, each curve has its own axis-y. Everything works fine.
    But when connecting the does not work properly.

    I write as follows:
    Qt Code:
    1. for (;i < axesCount(QwtPlot::yLeft);i++)
    2. {
    3. QwtAxisId axisId(QwtPlot::yLeft,i);
    4.  
    5. _curve[i] = new QwtPlotCurve();
    6. _curve[i]->setAxes(QwtPlot::xBottom,axisId);
    7. _symbol[i] = new QwtSymbol();
    8. _zoomer[i] = new Zoomer(QwtAxis::xBottom,axisId,this->canvas());
    9. _color[i] = /*QColor(*/trendColors[i]/*)*/;
    10. _curve[i]->setPen(QPen(_color[i]));
    11. _curve[i]->attach(this);
    12. _symbol[i]->setStyle(QwtSymbol::Ellipse);
    13. _symbol[i]->setPen(QColor(_color[i]));
    14. _palette[i].setColor(QPalette::WindowText, _color[i]);
    15. _palette[i].setColor(QPalette::Text, _color[i]);
    16. }
    To copy to clipboard, switch view to plain text mode 
    By the number of y-axes I create an object zoomer.
    But with the increase of the graph increases is not what I want. Example I tried to show in the picture.

    Tell me, please, what I'm doing wrong.
    Attached Images Attached Images

  6. #6
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get y value vertical line

    corrected so:
    Qt Code:
    1. for (;i < axesCount(QwtPlot::yLeft);i++)
    2. {
    3. QwtAxisId axisId(QwtPlot::yLeft,i);
    4. _curve[i] = new QwtPlotCurve();
    5. _curve[i]->setAxes(QwtAxisId(xBottom),axisId);
    6. _zoomer[i] = new Zoomer(QwtAxisId(xBottom),axisId,this->canvas());
    7. .....
    8. .....
    9. }
    To copy to clipboard, switch view to plain text mode 

    I have to chart two curves have a common axis X and each curve has its own Y axis

    Сhart increases normally on both y-axes, and the X-axis chart increases with the double force.
    That is, if I select the area on the chart axis X from 1 to 2, the screen will show the area from 1.3 to 1.7. On the y axis is zooming as it should.

    I understand why this is happening, since the declaration of zoomer object i do increase the axes [X,Y1] and [X,Y2] therefore X axis is increased twice.


    I can not understand how can I do so that the increase of the axes working correctly.

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

    Default Re: Get y value vertical line

    Qt Code:
    1. if ( i == 0 )
    2. _zoomer[i] = new Zoomer(QwtAxisId(xBottom),axisId,this->canvas());
    3. else
    4. _zoomer[i] = new Zoomer(QwtAxisId(xTop),axisId,this->canvas());
    To copy to clipboard, switch view to plain text mode 
    Uwe

  8. #8
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get y value vertical line

    Uwe, thanks for the answer.I did as you wrote

    The zooming in working very strange. First time with an zooming in any area everything works fine, next if you go back to the original scale, and zooming again the same area of ​​the graph occurs something strange. Scale of the axis is not changed and the graphics are not clear.

    If I again return to the original scale, and again zooming graph back all will work fine.

    That is, there is a constant alternation of successful and unsuccessful zooming the plot area.

    Here is an example of 3 Pictures:
    1. Initial scale of the graph.
    2. Successful zooming in the plot area.
    3. Unsuccessful zooming the plot area.

    Can you please tell how to fix it?
    Attached Images Attached Images

  9. #9
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get y value vertical line

    Hello, my problem, I have not decided yet. Somebody tell me how to use Zoomer with multiple y-axes&

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

    Default Re: Get y value vertical line

    From showing 3 screenshots you can't expect, that someone knows what is going on on your system - I didn't even get what exactly goes wrong.
    Guess you need to upload a small compilable demo application.

    Uwe

Similar Threads

  1. Vertical line in StatusBar
    By corban_dallas in forum Newbie
    Replies: 3
    Last Post: 7th August 2013, 09:19
  2. Execute window command line-by-line using QProcess
    By nhocjerry in forum Qt Programming
    Replies: 5
    Last Post: 30th July 2013, 12:21
  3. Replies: 4
    Last Post: 11th May 2011, 19:15
  4. Replies: 3
    Last Post: 13th August 2010, 11:50
  5. Draw vertical Line in QTextEdit
    By ericV in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2009, 15:50

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.