Results 1 to 3 of 3

Thread: Qwt move marker with mouse between interpolated points(data interpolation)

  1. #1
    Join Date
    Dec 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Qwt move marker with mouse between interpolated points(data interpolation)

    Hello,

    Let's say i have curve with coordinates (x, y)(1, 1) (2, 1) (3, 1) and a marker. I want to get more x points for my marker to snap on when i move it with mouse. In other words i want my marker to snap to 1.1 , 1.2 , 1.3 x coordinates( now it only snaps to 1, 2 ,3).

    Code snippet of how i move my marker:
    Qt Code:
    1. marker->setLineStyle(QwtPlotMarker::VLine);
    2. marker->attach(tracePlot);
    3.  
    4. picker = new QwtPlotPicker(tracePlot->xBottom, tracePlot->yLeft, QwtPicker::NoRubberBand,
    5. QwtPicker::AlwaysOff, tracePlot->canvas());
    6. pickerMachine = new QwtPickerDragPointMachine();
    7. picker->setStateMachine(pickerMachine);
    8.  
    9. connect(picker, &QwtPicker::moved, this, &Widget::moveMarker);
    10.  
    11. void Widget::moveMarker(QPoint actualMousePosition)
    12. {
    13. if(!flagZoom)
    14. {
    15. QwtText label;
    16. QString temp;
    17. int x = curve->closestPoint(actualMousePosition, NULL);
    18. QPointF position = curve->sample(x);
    19. marker->setValue(position);
    20. temp = QString::number(marker->xValue());
    21. label.setText(temp);
    22. marker->setLabel(label);
    23. }
    24. tracePlot->replot();
    25. }
    To copy to clipboard, switch view to plain text mode 

    From what i know marker moves between curve vector indexes because
    Qt Code:
    1. curve->closestPoint(actualMousePosition, NULL);
    To copy to clipboard, switch view to plain text mode 
    returns index of my data vector. So even tho i could use a fitter and get my curve interpolated my marker still would not move between those interpolated points only indexes. Does qwt have data interpolation methods? Or is there a way to move my marker differently? What's the best approach here?

  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: Qwt move marker with mouse between interpolated points(data interpolation)

    Guess you are looking for something like what is implemented in the curvetracker example.

    Using a marker for such a feature might be the wrong idea as it ends up in full replots, what might be an expansive operation, when having many points. Using a widget overlay ( like in the example ) avoids this problem.
    Sometimes you need both - the overlay while moving and a plot item when it has its final position. Such a thing is implemented in the itemeditor example.

    Uwe

  3. #3
    Join Date
    Dec 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Qwt move marker with mouse between interpolated points(data interpolation)

    Thanks for quick answer. I thought about something like bode(plot curve) example where a marker would get it's coordinates from x axis but issue that comes up is that i can't get y value of my curve(where vertical marker and curve crosses).

Similar Threads

  1. Replies: 3
    Last Post: 23rd November 2015, 06:44
  2. Replies: 3
    Last Post: 22nd February 2013, 19:56
  3. Replies: 3
    Last Post: 23rd February 2011, 07:29
  4. move/drag points on qwt plot
    By rambo83 in forum Qwt
    Replies: 5
    Last Post: 23rd November 2009, 08:36
  5. Moving plot marker with the mouse
    By viridis in forum Qwt
    Replies: 2
    Last Post: 23rd September 2008, 20:39

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.