Results 1 to 15 of 15

Thread: QwtPlotPicker::trackertex for labels in qwtplot problem

  1. #1
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QwtPlotPicker::trackertex for labels in qwtplot problem

    Hi,

    I am using QwtPlotPicker::trackertex for showing labels on points. I have setTrackerMode(AlwaysOn); I can easily display x and y values but what I am looking for, is to display special label for each point.
    what I am trying to do in following code is...after getting x axis and y axis I wants to search for xaxis value in vector of x values and yaxis value in vector of y values and if the xaxis value and yaxis value matches any value in vector x and vector y then I will use index to retrieve the label for that position from another vector.
    Its not giving me any error with this code but also not showing me desired labels.
    Qt Code:
    1. #define EPS 1.0e-6 //tolerance for comparing double values
    2. xaxis=pos1.x();
    3. yaxis=pos1.y();
    4. int size=vec_xaxisvalues.size();
    5. for(int index=0;index<size;index++)
    6. {
    7.  
    8. if ((vec_xaxisvalues[index]-xaxis)<EPS && (vec_yaxisvalues[index]-yaxis)<EPS)
    9.  
    10. {
    11. //QwtText text( QwtPlotPicker::trackerText(pos1));
    12. text.setText("good");
    13. return text;
    14. }
    15.  
    16. else
    17. {
    18. return QwtText();
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance.

    Cheers,

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    You have to translate your values into widget coordinates ( = pixel positions ) and compare them with the mouse position also in widget coordinates.

    Don't forget, that a screen is only a raster device !

    Uwe

  3. #3
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Hi Uwe,

    Thanks for the reply. I actually did it here is what I did...
    Qt Code:
    1. #define EPS 1.0e-4
    2. QPoint p;
    3. QPoint p1;
    4. p1=QwtPlotPicker::transform(pos1);
    5. const double xaxis=p1.x();
    6. const double yaxis=p1.y();
    7. for(int i=0;i<size;i++)
    8. {
    9. QwtDoublePoint qwtdp(vec_xaxisvalues[i],vec_yaxisvalues[i]);
    10. p=QwtPlotPicker::transform(qwtdp);
    11. if ((p.x()-xaxis)<EPS && (p.y()-yaxis)<EPS)
    12.  
    13. {
    14. text.setText("good");
    15. return text;
    16. }
    To copy to clipboard, switch view to plain text mode 
    But still its not showing me anything on plot...unless I increase my EPS value to really big like 1.0e10 then whole plot shows me "good"

    I would really appreciate your help.

    Cheers,
    Last edited by wysota; 15th April 2010 at 13:37. Reason: missing [code] tags

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Quote Originally Posted by hamid ghous View Post
    #define EPS 1.0e-4
    This value is the acceptable radius around the position of a translated point in screen geometries ( = number of pixels ). An integer between 0-5 might be useful but something like 1.0e-4 makes no sense.

    Overload QwtPlotPicker::trackerText(const QPoint &) instead of QwtPlotPicker::trackerText(const QwtDoublePoint &) and remove the first transformation. The rest of your code snippet looks o.k for me - assuming, that pos1 is the parameter you got from QwtPlotPicker::trackerText(const QwtDoublePoint &).

    Before you post the next time I recommend to insert a qDebug statement printing the mouse position and one of your transformed curve points to see if they are in the same coordinate system.

    Uwe

  5. #5
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    I got your point about EPS 1.0-e4 after seeing the transform values I also did the changes you mentioned earlier but still the result is the same its showing me label everywhere on plot...
    Here is the transform value and Mouse position..
    Mouse position is: 15,159 Transform values are:17,42

    Cheers,

  6. #6
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    sorry forgot to mention ...pos1 is the parameter or position I am getting from QwtPlotPicker::trackerText(const QPoint &) now..

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Quote Originally Posted by hamid ghous View Post
    Here is the transform value and Mouse position..
    Mouse position is: 15,159 Transform values are:17,42
    At least both look like reasonable positions now. The x coordinate seems to match, but the y coordinate not: 42 means your point is 42 pixels below the top border of the canvas.

    - Assuming your mouse is over the point: which value (42 or 159) is wrong ?
    - What is the geometry of the canvas ( is one of the y values the distance from the bottom ? )
    - Is the picker attached to the same y axis as your curve ?

    Uwe
    Last edited by Uwe; 15th April 2010 at 14:52.

  8. #8
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Hi Uwe,

    I just figured out the problem was for loop so I just removed the loop out of the program and used distance function of vectors to get the index of the value and now its showing me the labels (problem solved)...but as I am showing label on the basis of pixel coordinates so its really hard to see the label cursor has to be on exact pixel coordinates. I am using Xcross as symbol. Is there any way that I can see label whenever cursor comes to the symbol.
    Also how can I perform zooming with pixel coordinates?

    I really appreciate your help.

    Cheers,

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    but as I am showing label on the basis of pixel coordinates so its really hard to see the label cursor has to be on exact pixel coordinates.
    ?????

    I am using Xcross as symbol. Is there any way that I can see label whenever cursor comes to the symbol.
    Setting EPS to 0.5 + symbol.size and you will have matches for the bounding rectangle of the cross. If you need exact compares with the shape of a symbol you could paint the symbol on a bitmap translate its center to the mapped curve point and compare the mouse position with the corresponding bit.

    Also how can I perform zooming with pixel coordinates?
    The only thing that need to be done in pixel coordinates is the point matching algo. I don't see a reason to do anything else in pixel coordinates.

    Your code should be like this:

    Qt Code:
    1. virtual QwtText YourPicker::trackerText(const QPoint &pos) const
    2. {
    3. QwtText text;
    4. if ( isNearToACurvePoint(pos) );
    5. text = QwtPlotPicker::trackerText(pos);
    6.  
    7. return text;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Uwe

  10. The following user says thank you to Uwe for this useful post:

    hamid ghous (17th April 2010)

  11. #10
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Thanks Uwe for your help..

  12. #11
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Hi Uwe,

    Here is what I was trying to say about zooming; I was performing simple zooming by using following code:

    I am not after complicated zooming just the simple one.
    Qt Code:
    1. QwtPlotZoomer *zoomer;
    2. zoomer= new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yRight,myPlot->canvas());
    3. zoomer->setTrackerMode(QwtPicker::AlwaysOff);
    To copy to clipboard, switch view to plain text mode 

    But Now when I zoom in,it doesn't show me the label on the point. Any idea how can I do it...

    Regards,

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Read this thread and do the same for your zoomer ( QwtPlotZoomer is derived from QwtPlotPicker ).

    Uwe

  14. #13
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Where is this thread?

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

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    It starts at the beginning of this page and ends at the bottom - are you serious ?

    Uwe

  16. #15
    Join Date
    Jun 2009
    Posts
    27
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QwtPlotPicker::trackertex for labels in qwtplot problem

    Oh sorry I thought may be you were saying the thread title is ( QwtPlotZoomer is derived from QwtPlotPicker )

Similar Threads

  1. Replies: 1
    Last Post: 16th March 2010, 15:23
  2. QWTPLOT problem
    By umulingu in forum Qwt
    Replies: 5
    Last Post: 25th August 2009, 16:34
  3. QwtPlotPicker questions
    By ttvo in forum Qwt
    Replies: 7
    Last Post: 28th February 2009, 09:44
  4. Problem regarding QWTPLOT
    By sudheer168 in forum Qwt
    Replies: 1
    Last Post: 6th January 2009, 14:18
  5. Problem with QwtPlot
    By sudheer168 in forum Qwt
    Replies: 1
    Last Post: 11th September 2008, 09:04

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.