Results 1 to 7 of 7

Thread: A crosshair which tracks a displayed curve

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default A crosshair which tracks a displayed curve

    Hi,
    I need to implement the following functionality and am having trouble getting
    started.

    With a qwtplot having focus hitting a 'c' on the keyboard will cause a red cross
    hair to appear in the graph. Using the mouse or the arrow keys will cause the
    intersection point of the red crosshairs to follow the displayed curve.

    I can get the red crosshair to appear when I click in the plot, but it disappears
    as soon as I release the mouse.

    Having the crosshair follow the curve - I have no idea...

    Can someone point me in the right direction?


    Thanks!
    Mark
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: A crosshair which tracks a displayed curve

    Can we see some code?

  3. #3
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A crosshair which tracks a displayed curve

    The only code I have is a hacked up version of the Bode plot..

    The images I attached are of a different app which I need to emulate.

    ie.

    d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    QwtPicker::PointSelection,
    QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
    d_plot->canvas());
    d_picker->setRubberBandPen(QColor(Qt::red));
    d_picker->setTrackerMode(QwtPicker::ActiveOnly);

    will give me the Cross hair when I left click.

    I want this to persist when I release the mouse and then be able to grab it and
    move it with it following the displayed curve..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A crosshair which tracks a displayed curve

    Shouldn't you use QwtPlotMarker instead?

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

    Default Re: A crosshair which tracks a displayed curve

    All type of rubberbands support interactions, but they are not intended to display something persistant on the plot canvas.

    So you need to insert a plot item, when your interaction is done. Of course you have to hide this item again, when you restart your interaction. So your code will be a combination of a picker and a plot item.

    The plot item, that represents a point ( or a x or a y coordinate ) is indeed a marker, but you can also implement your own type of item. See f.e: http://qwt.svn.sourceforge.net/viewv...pp?view=markup

    HTH,
    Uwe

  6. #6
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A crosshair which tracks a displayed curve

    Hi Uwe,

    I wanted to look at the Navigation example but realize that it references some
    files that are not part of my qwt version. QwtPlotRescaler for example.

    It appears that these files, QwtPlotRescaler.cpp, .h have been around for a while, yet they are not part of my qwt-5.0.2 build.

    Why are these files not part of my qwt system and what do I need to do to build the
    Navigation example?

    Many thanks.

    Mark

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

    Default Re: A crosshair which tracks a displayed curve

    Quote Originally Posted by MrGarbage View Post
    Why are these files not part of my qwt system and what do I need to do to build the
    See http://qwt.sourceforge.net

    Uwe

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.