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:
Code:
marker->attach(tracePlot);
picker->setStateMachine(pickerMachine);
connect(picker, &QwtPicker::moved, this, &Widget::moveMarker);
void Widget
::moveMarker(QPoint actualMousePosition
) {
if(!flagZoom)
{
int x = curve->closestPoint(actualMousePosition, NULL);
QPointF position
= curve
->sample
(x
);
marker->setValue(position);
temp
= QString::number(marker
->xValue
());
label.setText(temp);
marker->setLabel(label);
}
tracePlot->replot();
}
From what i know marker moves between curve vector indexes because
Code:
curve->closestPoint(actualMousePosition, NULL);
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?
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
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).